Lib Namespace

Lib

Classes

Class Description
Assert

COD130000 applies to RES,ERM,SCM,COSTING,W1,All.
Library - Calc Complexity

COD130010 applies to RES,ERM,SCM,COSTING,W1,All.
Library - Payment Export

COD130100 applies to ERM,W1,AT,AU,BE,CA,DE,ES,FI,FR,GB,IN,IS,IT,NL,NO,SE,NZ,MX,US,RU,CZ.
Library - Payment Format

COD130101 applies to ERM,W1,All.
Library - Item Tracking

COD130502 applies to ERM,SCM,RES,W1,All.

Unsupported version tags: NA: Unable to Compile

Library - Sales

COD130509 applies to ERM,SCM,RES,W1,IN.

Contains all utility functions related to Sales.

Library - Resource

COD130511 applies to ERM,SCM,RES,W1,All.

Contains all utility functions related to Resource.

Library - Purchase

COD130512 applies to ERM,SCM,RES,W1,All.

Contains all utility functions related to Purchase.

Library - Utility

COD131000 applies to RES,ERM,SCM,W1,All.

Contains all generic utility functions.

Library - Dimension

COD131001 applies to RES,ERM,SCM,COSTING,W1,All.

Contains all utility functions related to Dimensions.

Library - Report Validation

COD131002 applies to RES,W1,All.

// Contains all functions related to report Validation.

Library - Text File Validation

COD131003 applies to ERM,W1,All.

// Contains functions for text file validation.

Library - Variable Storage

COD131004 applies to ERM,SCM,RES,W1,All.
Library - Report Dataset

COD131007 applies to RES,ERM,SCM,All.
Library UT Utility

COD131008 applies to UT,RES,ERM,SCM,W1,All.
Library - Setup Storage

COD131009 applies to W1,All.
Library - Incoming Documents

COD131100 applies to ERM,W1,All.
Library - Workflow

COD131101 applies to ERM,W1,All.
Library - ERM

COD131300 applies to RES,ERM,SCM,W1,IN.

All utility functions related to ERM.

Library - ERM Unapply

COD131301 applies to RES,ERM,SCM,W1,All.

Branching extension library for CU131300: Library - ERM

Encapsulates functionality for unapplying customer and vendor ledger entries because the function GenJnlPostLine.UnapplyVendLedgEntry has different signatures in AU,NZ builds.

Library - Fiscal Year

COD131302 applies to ERM,W1,All.

Library Functions related to Fiscal Year.

Library - Pmt Disc Setup

COD131303 applies to ERM,W1,All.

Library for Payment Discount Test Cases.

Library - Account Schedule

COD131304 applies to ERM,W1,All.

Utility functions related to Account Schedule

Library - ERM Country Data

COD131305 applies to ERM,W1,IN.

Procedures to create demo data present in W1 but missing in countries

Library - Journals

COD131306 applies to ERM,W1,All.

Library containing functions related to various Journals.

Library - Fixed Asset

COD131330 applies to RES,ERM,SCM,W1,IN.
Library - Cash Flow

COD131331 applies to ERM,W1,All.
Library - Cash Flow Helper

COD131332 applies to ERM,W1,All.

Feature: Cash Flow Area: Filling Cash Flow Journal Provides helper functions for codeunits in this area.

Library - XML Read

COD131335 applies to ERM,W1,All.
Library - XPath XML Reader

COD131337 applies to ERM,W1,All.
Library - Cost Accounting

COD131340 applies to ERM,W1,All.

Feature: 92842 - Cost Accounting. Test Brief: http://vstfnav/Sites/DynamicsNAV7/Document Repository/Test Briefs and TDS/92842 - TDS - Cost Accounting.docx

Library - Document Approvals

COD131352 applies to ERM,W1,All.
Library - Marketing

COD131900 applies to RES,ERM,SCM,W1,All.

Contains all utility functions related to Marketing.

Library - Human Resource

COD131901 applies to RES,ERM,SCM,W1,All.

Contains all utility functions related to Human Resource.

Library - Service

COD131902 applies to RES,ERM,SCM,W1,All.

Contains all utility functions related to Service.

Library - Rapid Start

COD131903 applies to RES,RIM,W1,All.

Contains all utility functions related to Rapid Implementation Methodology.

Library - Time Sheet

COD131904 applies to RES,W1,All.
Library - Job

COD131920 applies to RES,Jobs,W1,IN.
Library - Costing

COD132200 applies to SCM,COSTING,W1,All.

Unsupported version tags:

Contains all utility functions related to Costing.

Library - Inventory

COD132201 applies to SCM,COSTING,W1,IN.

Unsupported version tags:

Contains all utility functions related to Inventory Management.

Library - Manufacturing

COD132202 applies to SCM,COSTING,W1,All.

Unsupported version tags:

Contains all utility functions related to Manufacturing.

Library - Planning

COD132203 applies to SCM,COSTING,W1,All.

Unsupported version tags:

Contains all utility functions related to Planning.

Library - Warehouse

COD132204 applies to SCM,COSTING,W1,All.

Unsupported version tags:

Contains all utility functions related to Warehouse Management.

Library - Kitting

COD132205 applies to SCM,W1,All.
Library - Assembly

COD132207 applies to SCM,W1,All.
Library - Trees

COD132208 applies to SCM,W1,All.
Library - Location

COD132209 applies to SCM,W1,IN.
Library - Patterns

COD132212 applies to SCM,W1,All.
Library - Small Business

COD132213 applies to W1,All.
Library - Permissions

COD132214 applies to W1,All.
Library - Error Message

COD132215 applies to W1,All.
Library - TCS

COD143008 applies to ERM,IN.


Assert Class

Lib.Assert

COD130000 applies to RES,ERM,SCM,COSTING,W1,All.

Methods

Name | Description
AreEqual@2 | The procedure AreEqual is available in codeunit 130000.
AreNearlyEqual@3 | The procedure AreNearlyEqual is available in codeunit 130000.
AreNotEqual@9 | The procedure AreNotEqual is available in codeunit 130000.
AreNotNearlyEqual@8 | The procedure AreNotNearlyEqual is available in codeunit 130000.
AssertNoFilter@19 | The procedure AssertNoFilter is available in codeunit 130000.
AssertNothingInsideFilter@17 | The procedure AssertNothingInsideFilter is available in codeunit 130000.
AssertPrimRecordNotFound@18 | The procedure AssertPrimRecordNotFound is available in codeunit 130000.
AssertRecordAlreadyExists@16 | The procedure AssertRecordAlreadyExists is available in codeunit 130000.
AssertRecordNotFound@15 | The procedure AssertRecordNotFound is available in codeunit 130000.
Compare@21 | The procedure Compare is available in codeunit 130000.
ExpectedError@13 | The procedure ExpectedError is available in codeunit 130000.
ExpectedErrorCode@20 | The procedure ExpectedErrorCode is available in codeunit 130000.
ExpectedErrorSubstring@33 | The procedure ExpectedErrorSubstring is available in codeunit 130000.
ExpectedMessage@23 | The procedure ExpectedMessage is available in codeunit 130000.
Fail@7 | The procedure Fail is available in codeunit 130000.
IsDataTypeSupported@22 | The procedure IsDataTypeSupported is available in codeunit 130000.
IsFalse@4 | The procedure IsFalse is available in codeunit 130000.
IsTrue@1 | The procedure IsTrue is available in codeunit 130000.
KnownFailure@6 | The procedure KnownFailure is available in codeunit 130000.
RecordCount@31 | The procedure RecordCount is available in codeunit 130000.
RecordIsEmpty@28 | The procedure RecordIsEmpty is available in codeunit 130000.
RecordIsNotEmpty@27 | The procedure RecordIsNotEmpty is available in codeunit 130000.
TableIsEmpty@25 | The procedure TableIsEmpty is available in codeunit 130000.
TableIsNotEmpty@32 | The procedure TableIsNotEmpty is available in codeunit 130000.
VerifyFailure@14 | The procedure VerifyFailure is available in codeunit 130000.

See Also

Lib


AreEqual@2 Method

The procedure AreEqual is available in codeunit 130000.

Syntax

AreEqual@2(
    Expected@1000 : Variant Expected, //Input parameter of type Variant
    Actual@1001 : Variant Actual, //Input parameter of type Variant
    Msg@1002 : Text Msg //Input parameter of type Text
);

Parameters

Expected
Input parameter of type Variant
Actual
Input parameter of type Variant
Msg
Input parameter of type Text

Remarks

The relevant search keywords are: Are, Equal.

For a clarification about how this function works, refer to the code listed below.

      IF NOT Equal(Expected,Actual) THEN
        ERROR(AreEqualFailedMsg,Expected,TypeNameOf(Expected),Actual,TypeNameOf(Actual),Msg)

Example

The below example is extracted from the test automation codeunit 134000 to show one way of using this function.

      // Verify Error when Unapply Entry of the type Appln. Rounding from Detailed Customer Ledger Entry.

      // Setup.
      CurrencyCode := CreateCurrency(0);  // Using 0 for Application Rounding Precision for Currency.
      LibraryERM.SetAddReportingCurrency(CurrencyCode);
      AppRounding := LibraryRandom.RandDec(5,2);

      CreatePostApplyGenJournalLine(
        GenJournalLine,GenJournalLine."Document Type"::Invoice,GenJournalLine."Document Type"::Payment,CurrencyCode,
        10 * LibraryRandom.RandDec(100,2),AppRounding);

      FindDetailedLedgerEntry(
        DetailedCustLedgEntry,GenJournalLine."Document No.",DetailedCustLedgEntry."Entry Type"::"Appln. Rounding");

      // Exercise. Unapply Payment from Detailed Customer ledger Entry.
      ASSERTERROR CustEntryApplyPostedEntries.UnApplyDtldCustLedgEntry(DetailedCustLedgEntry);

      // Verify: Verify Error when Unapply Entry of the type Appln. Rounding from Detailed Customer Ledger Entry.
      Assert.AreEqual(
        STRSUBSTNO(ApplnRoundingError,DetailedCustLedgEntry.FIELDCAPTION("Entry Type"),DetailedCustLedgEntry.TABLECAPTION,
          DetailedCustLedgEntry.FIELDCAPTION("Entry No."),DetailedCustLedgEntry."Entry No."),GETLASTERRORTEXT,ErrorMessage);
Member of Lib.Assert


AreNearlyEqual@3 Method

The procedure AreNearlyEqual is available in codeunit 130000.

Syntax

AreNearlyEqual@3(
    Expected@1000 : Decimal Expected, //Input parameter of type Decimal
    Actual@1001 : Decimal Actual, //Input parameter of type Decimal
    Delta@1002 : Decimal Delta, //Input parameter of type Decimal
    Msg@1003 : Text Msg //Input parameter of type Text
);

Parameters

Expected
Input parameter of type Decimal
Actual
Input parameter of type Decimal
Delta
Input parameter of type Decimal
Msg
Input parameter of type Text

Remarks

The relevant search keywords are: Are, Nearly, Equal.

For a clarification about how this function works, refer to the code listed below.

      IF ABS(Expected - Actual) > ABS(Delta) THEN
        ERROR(AreNearlyEqualFailedMsg,Delta,Expected,Actual,Msg)

Example

The below example is extracted from the test automation codeunit 134000 to show one way of using this function.

      Currency.GET(CurrencyCode);
      GLEntry.SETRANGE("Document Type",DocumentType);
      GLEntry.SETRANGE("Document No.",DocumentNo);
      GLEntry.FINDFIRST;
      Assert.AreNearlyEqual(
        Amount / 2,LibraryERM.ConvertCurrency(Amount,'',CurrencyCode,WORKDATE),Currency."Amount Rounding Precision",
        'Amount must be equal');
Member of Lib.Assert


AreNotEqual@9 Method

The procedure AreNotEqual is available in codeunit 130000.

Syntax

AreNotEqual@9(
    Expected@1000 : Variant Expected, //Input parameter of type Variant
    Actual@1001 : Variant Actual, //Input parameter of type Variant
    Msg@1002 : Text Msg //Input parameter of type Text
);

Parameters

Expected
Input parameter of type Variant
Actual
Input parameter of type Variant
Msg
Input parameter of type Text

Remarks

The relevant search keywords are: Are, Not, Equal.

For a clarification about how this function works, refer to the code listed below.

      IF Equal(Expected,Actual) THEN
        ERROR(AreNotEqualFailedMsg,Expected,TypeNameOf(Expected),Actual,TypeNameOf(Actual),Msg)

Example

The below example is extracted from the test automation codeunit 134024 to show one way of using this function.

      CustLedgerEntry.GET(CustLedgerEntry."Entry No.");
      CustLedgerEntry.CALCFIELDS("Remaining Amount",Amount);
      CustLedgerEntry.TESTFIELD("Remaining Amount",CustLedgerEntry.Amount - AmountApplied);
      Assert.AreNotEqual(
        CustLedgerEntry.Amount,
        CustLedgerEntry."Remaining Amount",
        STRSUBSTNO(AmountError,CustLedgerEntry.FIELDCAPTION(Amount),CustLedgerEntry.FIELDCAPTION("Remaining Amount")));
Member of Lib.Assert


AreNotNearlyEqual@8 Method

The procedure AreNotNearlyEqual is available in codeunit 130000.

Syntax

AreNotNearlyEqual@8(
    Expected@1000 : Decimal Expected, //Input parameter of type Decimal
    Actual@1001 : Decimal Actual, //Input parameter of type Decimal
    Delta@1002 : Decimal Delta, //Input parameter of type Decimal
    Msg@1003 : Text Msg //Input parameter of type Text
);

Parameters

Expected
Input parameter of type Decimal
Actual
Input parameter of type Decimal
Delta
Input parameter of type Decimal
Msg
Input parameter of type Text

Remarks

The relevant search keywords are: Are, Not, Nearly, Equal.

For a clarification about how this function works, refer to the code listed below.

      IF ABS(Expected - Actual) <= ABS(Delta) THEN
        ERROR(AreNotNearlyEqualFailedMsg,Delta,Expected,Actual,Msg)

Example

There are no examples available.
Member of Lib.Assert


AssertNoFilter@19 Method

The procedure AssertNoFilter is available in codeunit 130000.

Syntax

AssertNoFilter@19(
      //param element not supplied
);

Remarks

The relevant search keywords are: Assert, No, Filter.

For a clarification about how this function works, refer to the code listed below.

      VerifyFailure(NoFilterErrorCode,STRSUBSTNO(AssertErrorMsg,NoFilterErrorCode,GETLASTERRORCODE));

Example

The below example is extracted from the test automation codeunit 134335 to show one way of using this function.

      // Check Vendor Balance To Date without any option selected.

      // Setup.
      Initialize;
      CLEAR(VendorBalanceToDate);
      VendorBalanceToDate.InitializeRequest(FALSE,FALSE,FALSE);

      // Exercise: Try to Save Vendor Balance to Date Report.
      ASSERTERROR VendorBalanceToDate.SAVEASEXCEL('Test');

      // Verify: Verify Error which is Raised during Save without any option selected.
      Assert.AssertNoFilter;
Member of Lib.Assert


AssertNothingInsideFilter@17 Method

The procedure AssertNothingInsideFilter is available in codeunit 130000.

Syntax

AssertNothingInsideFilter@17(
      //param element not supplied
);

Remarks

The relevant search keywords are: Assert, Nothing, Inside, Filter.

For a clarification about how this function works, refer to the code listed below.

      VerifyFailure(RecordNothingInsideFilterErrorCode,STRSUBSTNO(AssertErrorMsg,RecordNothingInsideFilterErrorCode,GETLASTERRORCODE));

Example

The below example is extracted from the test automation codeunit 134087 to show one way of using this function.

      // Check after changing Posting Date, Application generates an error if Exchange Rate does not exist.

      // 1. Setup: Create Sales Invoice and new Currency with Exchange Rate.
      Initialize;
      CreateSalesDocument(SalesHeader,CurrencyExchangeRate,SalesHeader."Document Type"::Invoice);

      // 2. Exercise: Modify Posting Date with a date lesser that Existing Starting Date of Exchange Rate.
      SalesHeader.SetHideValidationDialog(TRUE);
      ASSERTERROR SalesHeader.VALIDATE("Posting Date",
          CALCDATE('<-' + FORMAT(LibraryRandom.RandInt(10)) + 'D>',CurrencyExchangeRate."Starting Date"));

      // 3. Verify: Error occurs while changing Posting Date.
      Assert.AssertNothingInsideFilter;
Member of Lib.Assert


AssertPrimRecordNotFound@18 Method

The procedure AssertPrimRecordNotFound is available in codeunit 130000.

Syntax

AssertPrimRecordNotFound@18(
      //param element not supplied
);

Remarks

The relevant search keywords are: Assert, Prim, Record, Not, Found.

For a clarification about how this function works, refer to the code listed below.

      VerifyFailure(PrimRecordNotFoundErrorCode,STRSUBSTNO(AssertErrorMsg,PrimRecordNotFoundErrorCode,GETLASTERRORCODE));

Example

The below example is extracted from the test automation codeunit 136503 to show one way of using this function.

      // Test case checks that Resource cannot be linked with non-existent USER ID
      Initialize;
      SetUp;
      // 1. Create User ID, Resource
      LibraryTimeSheet.CreateTimeSheetResource(Resource);
      // 2. Fill 'User ID' field with non-existent User ID
      ASSERTERROR Resource.VALIDATE("Time Sheet Owner User ID",NonExistentUser);
      // 3. Verify: Verify User does not exist error message.
      Assert.AssertPrimRecordNotFound;

      TearDown;
Member of Lib.Assert


AssertRecordAlreadyExists@16 Method

The procedure AssertRecordAlreadyExists is available in codeunit 130000.

Syntax

AssertRecordAlreadyExists@16(
      //param element not supplied
);

Remarks

The relevant search keywords are: Assert, Record, Already, Exists.

For a clarification about how this function works, refer to the code listed below.

      VerifyFailure(RecordAlreadyExistsErrorCode,STRSUBSTNO(AssertErrorMsg,RecordAlreadyExistsErrorCode,GETLASTERRORCODE));

Example

The below example is extracted from the test automation codeunit 136400 to show one way of using this function.

      // Create new Employee with No. of existing Employee and verify that application generates an error message.

      // 1. Setup: Create first Employee.
      Initialize;
      LibraryHumanResource.CreateEmployee(Employee);
      FirstEmployeeNo := Employee."No.";
      CLEAR(Employee);

      // 2. Exercise:Try to create another Employee with No. of existing Employee.
      Employee.INIT;
      Employee.VALIDATE("No.",FirstEmployeeNo);
      ASSERTERROR Employee.INSERT(TRUE);

      // 3. Verify: Verify that application generates an error message.
      Assert.AssertRecordAlreadyExists;
Member of Lib.Assert


AssertRecordNotFound@15 Method

The procedure AssertRecordNotFound is available in codeunit 130000.

Syntax

AssertRecordNotFound@15(
      //param element not supplied
);

Remarks

The relevant search keywords are: Assert, Record, Not, Found.

For a clarification about how this function works, refer to the code listed below.

      VerifyFailure(RecordNotFoundErrorCode,STRSUBSTNO(AssertErrorMsg,RecordNotFoundErrorCode,GETLASTERRORCODE));

Example

The below example is extracted from the test automation codeunit 134141 to show one way of using this function.

      // Setup.
      Initialize;
      CreateBankReconciliationWithLedgerEntries(BankAccountStatement);

      // Exercise.
      LibraryVariableStorage.Enqueue(TRUE);
      BankAccountStatement.DELETE(TRUE);

      // Verify.
      ASSERTERROR
        BankAccountStatement.GET(BankAccountStatement."Bank Account No.",
          BankAccountStatement."Statement No.");
      Assert.AssertRecordNotFound;
Member of Lib.Assert


Compare@21 Method

The procedure Compare is available in codeunit 130000.

Syntax

Compare@21(
    Left@1000 : Variant Left, //Input parameter of type Variant
    Right@1001 : Variant Right //Input parameter of type Variant
);

Parameters

Left
Input parameter of type Variant
Right
Input parameter of type Variant

Return Value

Boolean

Remarks

The relevant search keywords are: Compare.

For a clarification about how this function works, refer to the code listed below.

      EXIT(Equal(Left,Right))

Example

There are no examples available.
Member of Lib.Assert


ExpectedError@13 Method

The procedure ExpectedError is available in codeunit 130000.

Syntax

ExpectedError@13(
    Expected@1000 : Text Expected //Input parameter of type Text
);

Parameters

Expected
Input parameter of type Text

Remarks

The relevant search keywords are: Expected, Error.

For a clarification about how this function works, refer to the code listed below.

      IF (GETLASTERRORTEXT = '') AND (Expected = '') THEN BEGIN
        IF GETLASTERRORCALLSTACK = '' THEN
          ERROR(ErrorHasNotBeenThrownErr);
      END ELSE
        IF STRPOS(GETLASTERRORTEXT,Expected) = 0 THEN
          ERROR(ExpectedErrorFailed,Expected,GETLASTERRORTEXT);

Example

The below example is extracted from the test automation codeunit 134000 to show one way of using this function.

      // [FEATURE] [Dimension] [Payment Discount]
      // [SCENARIO 376797] Error try posting sales payment journal without dimension applied to posted Invoice in case of Discount, "Payment Disc. Debit Acc." with default dimension with "Value Posting" = "Same Code"
      Initialize;

      // [GIVEN] Customer with "Payment Disc. Debit Acc." = "A"
      // [GIVEN] Default Dimension "D" with "Value Posting" = "Same Code" is set for G/L Account "A"
      CustomerNo := CreateCustomer;
      CreateDefaultDimensionGLAccSameValue(DimensionValue,CreateCustPostingGrPmtDiscDebitAccNo(CustomerNo));

      // [GIVEN] Posted Sales Invoice with Amount Including VAT = 10000 and possible Discount = 2%. No dimension is set.
      CreateAndPostGenJnlLine(
        GenJournalLine,WORKDATE,GenJournalLine."Document Type"::Invoice,LibraryRandom.RandIntInRange(1000,2000),CustomerNo,'');
      PaymentAmount := -GenJournalLine.Amount + GenJournalLine.Amount * GetPmtTermsDiscountPct / 100;

      // [GIVEN] Sales Journal with Payment Amount = 9800 and applied to posted Invoice. No dimension is set.
      // [WHEN] Post Sales Journal
      ASSERTERROR LibrarySales.CreatePaymentAndApplytoInvoice(
          GenJournalLine,CustomerNo,GenJournalLine."Document No.",PaymentAmount);

      // [THEN] Error occurs: "A dimension used in Gen. Journal Line GENERAL, CASH, 10000 has caused an error."
      Assert.ExpectedErrorCode(DialogTxt);
      Assert.ExpectedError(
        STRSUBSTNO(DimensionUsedErr,
          GenJournalLine.TABLECAPTION,GenJournalLine."Journal Template Name",
          GenJournalLine."Journal Batch Name",GenJournalLine."Line No."));
Member of Lib.Assert


ExpectedErrorCode@20 Method

The procedure ExpectedErrorCode is available in codeunit 130000.

Syntax

ExpectedErrorCode@20(
    Expected@1000 : Text Expected //Input parameter of type Text
);

Parameters

Expected
Input parameter of type Text

Remarks

The relevant search keywords are: Expected, Error, Code.

For a clarification about how this function works, refer to the code listed below.

      IF STRPOS(GETLASTERRORCODE,Expected) = 0 THEN
        ERROR(ExpectedErrorCodeFailed,Expected,GETLASTERRORCODE,GETLASTERRORTEXT);

Example

The below example is extracted from the test automation codeunit 134000 to show one way of using this function.

      // [FEATURE] [Dimension] [Payment Discount]
      // [SCENARIO 376797] Error try posting sales payment journal without dimension applied to posted Invoice in case of Discount, "Payment Disc. Debit Acc." with default dimension with "Value Posting" = "Same Code"
      Initialize;

      // [GIVEN] Customer with "Payment Disc. Debit Acc." = "A"
      // [GIVEN] Default Dimension "D" with "Value Posting" = "Same Code" is set for G/L Account "A"
      CustomerNo := CreateCustomer;
      CreateDefaultDimensionGLAccSameValue(DimensionValue,CreateCustPostingGrPmtDiscDebitAccNo(CustomerNo));

      // [GIVEN] Posted Sales Invoice with Amount Including VAT = 10000 and possible Discount = 2%. No dimension is set.
      CreateAndPostGenJnlLine(
        GenJournalLine,WORKDATE,GenJournalLine."Document Type"::Invoice,LibraryRandom.RandIntInRange(1000,2000),CustomerNo,'');
      PaymentAmount := -GenJournalLine.Amount + GenJournalLine.Amount * GetPmtTermsDiscountPct / 100;

      // [GIVEN] Sales Journal with Payment Amount = 9800 and applied to posted Invoice. No dimension is set.
      // [WHEN] Post Sales Journal
      ASSERTERROR LibrarySales.CreatePaymentAndApplytoInvoice(
          GenJournalLine,CustomerNo,GenJournalLine."Document No.",PaymentAmount);

      // [THEN] Error occurs: "A dimension used in Gen. Journal Line GENERAL, CASH, 10000 has caused an error."
      Assert.ExpectedErrorCode(DialogTxt);
      Assert.ExpectedError(
        STRSUBSTNO(DimensionUsedErr,
          GenJournalLine.TABLECAPTION,GenJournalLine."Journal Template Name",
          GenJournalLine."Journal Batch Name",GenJournalLine."Line No."));
Member of Lib.Assert


ExpectedErrorSubstring@33 Method

The procedure ExpectedErrorSubstring is available in codeunit 130000.

Syntax

ExpectedErrorSubstring@33(
    Expected@1000 : Text Expected, //Input parameter of type Text
    Position@1001 : Integer Position //Input parameter of type Integer
);

Parameters

Expected
Input parameter of type Text
Position
Input parameter of type Integer

Remarks

The relevant search keywords are: Expected, Error, Substring.

For a clarification about how this function works, refer to the code listed below.

      IF (GETLASTERRORTEXT = '') AND (Expected = '') THEN BEGIN
        IF GETLASTERRORCALLSTACK = '' THEN
          ERROR(ErrorHasNotBeenThrownErr);
      END ELSE
        IF STRPOS(GETLASTERRORTEXT,Expected) <> Position THEN
          ERROR(STRSUBSTNO(ExpectedErrorSubstringFailedErr,Expected,Position,GETLASTERRORTEXT));

Example

There are no examples available.
Member of Lib.Assert


ExpectedMessage@23 Method

The procedure ExpectedMessage is available in codeunit 130000.

Syntax

ExpectedMessage@23(
    Expected@1000 : Text Expected, //Input parameter of type Text
    Actual@1001 : Text Actual //Input parameter of type Text
);

Parameters

Expected
Input parameter of type Text
Actual
Input parameter of type Text

Remarks

The relevant search keywords are: Expected, Message.

For a clarification about how this function works, refer to the code listed below.

      IF STRPOS(Actual,Expected) = 0 THEN
        ERROR(ExpectedMessageFailedErr,Expected,Actual);

Example

The below example is extracted from the test automation codeunit 134170 to show one way of using this function.

      Assert.ExpectedMessage(LibraryVariableStorage.DequeueText,Message)
Member of Lib.Assert


Fail@7 Method

The procedure Fail is available in codeunit 130000.

Syntax

Fail@7(
    Msg@1000 : Text Msg //Input parameter of type Text
);

Parameters

Msg
Input parameter of type Text

Remarks

The relevant search keywords are: Fail.

For a clarification about how this function works, refer to the code listed below.

      ERROR(FailFailedMsg,Msg)

Example

The below example is extracted from the test automation codeunit 134029 to show one way of using this function.

      // Setup: Update the General Ledger Setup, Update General Journal Template and Find General Journal Batch.
      Initialize;
      MaxVATDiffAmt := LibraryRandom.RandDec(2,2);
      // Take a random decimal amount between 0.01 to 2.00, value is not important.
      LibraryERM.SetMaxVATDifferenceAllowed(MaxVATDiffAmt);
      FindGenJournalBatch(GenJournalBatch);

      // Exercise: Create a General Journal Line with any Random Amount between 1001 to 1100. Value is not important.
      // Post the General Journal Line if option selected.
      LibraryERM.CreateGeneralJnlLine(
        GenJournalLine,GenJournalBatch."Journal Template Name",GenJournalBatch.Name,GenJournalLine."Document Type"::" ",
        GenJournalLine."Account Type"::"G/L Account",LibraryERM.CreateGLAccountWithSalesSetup,
        1000 + LibraryRandom.RandInt(100));

      IF Posting THEN
        LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // Verify: Verification based on the options selected.
      CASE OptionSelected OF
        VerificationType::"VAT Base":
          // Verify the VAT Base Amount on General Journal Line.
          Assert.AreEqual(GetVATBaseAmount(GenJournalLine),GenJournalLine."VAT Base Amount",'Incorrect VAT Base Amount Calculated.');
        VerificationType::"VAT Diff. Positive":
          // Verify the VAT Difference with an amount greater than the generated VAT Difference on General Journal Line.
          VerifyVATDiffOnGenJnlLine(GenJournalLine,MaxVATDiffAmt,TRUE);
        VerificationType::"VAT Diff. Negative":
          // Verify the VAT Difference with an amount lesser than the generated VAT Difference on General Journal Line.
          VerifyVATDiffOnGenJnlLine(GenJournalLine,MaxVATDiffAmt,FALSE);
        VerificationType::Posting:
          // Verify the VAT Amount and Amount on GL Entry after posting General Journal Line.
          VerifyGLEntriesAfterPosting(GenJournalLine."Document No.",GenJournalLine."VAT %",GenJournalLine.Amount);
        ELSE
          Assert.Fail(STRSUBSTNO('Invalid option selected: %1',FORMAT(OptionSelected)))
      END;
Member of Lib.Assert


IsDataTypeSupported@22 Method

The procedure IsDataTypeSupported is available in codeunit 130000.

Syntax

IsDataTypeSupported@22(
    Value@1000 : Variant Value //Input parameter of type Variant
);

Parameters

Value
Input parameter of type Variant

Return Value

Boolean

Remarks

The relevant search keywords are: Is, Data, Type, Supported.

For a clarification about how this function works, refer to the code listed below.

      EXIT(Value.ISBOOLEAN OR
        Value.ISOPTION OR
        Value.ISINTEGER OR
        Value.ISDECIMAL OR
        Value.ISTEXT OR
        Value.ISCODE OR
        Value.ISDATE OR
        Value.ISDATETIME OR
        Value.ISDATEFORMULA OR
        Value.ISGUID OR
        Value.ISDURATION OR
        Value.ISRECORDID OR
        Value.ISBIGINTEGER OR
        Value.ISCHAR OR
        Value.ISTIME);

Example

The below example is extracted from the test automation codeunit 138000 to show one way of using this function.

      FOR I := 1 TO RecordRef1.FIELDCOUNT DO BEGIN
        FieldRef1 := RecordRef1.FIELDINDEX(I);
        FieldRef2 := RecordRef2.FIELDINDEX(I);

        IF NOT ExcludeFromComparisment(FieldRef1,FieldRefArrayToExclude) AND Assert.IsDataTypeSupported(FieldRef1.VALUE) THEN
          Assert.AreEqual(FieldRef1.VALUE,FieldRef2.VALUE,STRSUBSTNO('Field values for field %1 do not match',FieldRef1.CAPTION));
      END;
Member of Lib.Assert


IsFalse@4 Method

The procedure IsFalse is available in codeunit 130000.

Syntax

IsFalse@4(
    Condition@1000 : Boolean Condition, //Input parameter of type Boolean
    Msg@1001 : Text Msg //Input parameter of type Text
);

Parameters

Condition
Input parameter of type Boolean
Msg
Input parameter of type Text

Remarks

The relevant search keywords are: Is, False.

For a clarification about how this function works, refer to the code listed below.

      IF Condition THEN
        ERROR(IsFalseFailedMsg,Msg)

Example

The below example is extracted from the test automation codeunit 134001 to show one way of using this function.

      WITH VendorLedgerEntry DO BEGIN
        // Update record to reflect changes done by codeunit.
        GET("Entry No.");
        CALCFIELDS(Amount,"Remaining Amount");

        // Check that the invoice closed and has no remaining amount.
        Assert.IsFalse(Open,InvoiceError);
        Assert.IsTrue("Remaining Amount" = 0.0,'Invoice has remaining amount');
      END;
Member of Lib.Assert


IsTrue@1 Method

The procedure IsTrue is available in codeunit 130000.

Syntax

IsTrue@1(
    Condition@1000 : Boolean Condition, //Input parameter of type Boolean
    Msg@1001 : Text Msg //Input parameter of type Text
);

Parameters

Condition
Input parameter of type Boolean
Msg
Input parameter of type Text

Remarks

The relevant search keywords are: Is, True.

For a clarification about how this function works, refer to the code listed below.

      IF NOT Condition THEN
        ERROR(IsTrueFailedMsg,Msg)

Example

The below example is extracted from the test automation codeunit 134001 to show one way of using this function.

      Assert.IsTrue(NumberOfInvoices <= 10,'Not more than 10 invoices');
      Assert.IsTrue(NumberOfPayments <= 10,'Not more than 10 payments');

      // Find a random vendor and update the payment terms.
      GetVendorAndUpdatePmtTerms(Vendor);

      // Compute Invoice and Payment amounts.
      ComputeAmounts(InvLCYFullAmount,PmtLCYFullAmount,PaymentPercentage,CALCDATE(PostingDelta));

      // Create Invoices.
      FOR i := 1 TO NumberOfInvoices DO
        // Make a partial invoice.
        CreateVendorPartialInvoice(InvVendorLedgerEntry[i],InvLCYFullAmount,Vendor,InvCurrency,i,NumberOfInvoices);

      // Create multiple Payments.
      FOR i := 1 TO NumberOfPayments DO
        // Make a partial payment.
        CreateVendorPartialPayment(PmtVendorLedgerEntry[i],PmtLCYFullAmount,Vendor,PostingDelta,PmtCurrency,i,NumberOfPayments);

      // Sanity check that the full amount has been paid.
      Assert.AreEqual(ROUND(InvLCYFullAmount),0,STRSUBSTNO(InternalError,'Invoice'));
      Assert.AreEqual(ROUND(PmtLCYFullAmount),0,STRSUBSTNO(InternalError,'Payment'));

      // Excercise application of invoice and payments.
      IF StepWisePost THEN
        PostApplicationStepwise(InvVendorLedgerEntry,PmtVendorLedgerEntry,NumberOfInvoices,NumberOfPayments)
      ELSE
        PostApplication(InvVendorLedgerEntry,PmtVendorLedgerEntry,NumberOfInvoices,NumberOfPayments);

      // Validate that all invoices closed.
      FOR i := 1 TO NumberOfInvoices DO
        ValidateVendLedgEntrClosed(InvVendorLedgerEntry[i])
Member of Lib.Assert


KnownFailure@6 Method

The procedure KnownFailure is available in codeunit 130000.

Syntax

KnownFailure@6(
    Expected@1000 : Text Expected, //Input parameter of type Text
    WorkItemNo@1001 : Integer WorkItemNo //Input parameter of type Integer
);

Parameters

Expected
Input parameter of type Text
WorkItemNo
Input parameter of type Integer

Remarks

The relevant search keywords are: Known, Failure.

For a clarification about how this function works, refer to the code listed below.

      ExpectedError(Expected);
      ERROR(KnownFailureMsg,WorkItemNo)

Example

The below example is extracted from the test automation codeunit 137353 to show one way of using this function.

      Initialize;
      Qty := LibraryRandom.RandDec(100,2);
      QtyPer := LibraryRandom.RandDec(5,2);
      ExecuteUIHandlers;
      LibraryERM.SetAllowPostingFromTo(0D,0D);
      LibraryERM.SetUseLegacyGLEntryLocking(TRUE);
      LibraryInventory.UpdateInventorySetup(InventorySetup,TRUE,TRUE,
        InventorySetup."Automatic Cost Adjustment",InventorySetup."Average Cost Calc. Type",InventorySetup."Average Cost Period");

      // Setup. Make BOM structure.
      SetupInventoryForReportWithoutPurchOrder(
        ParentItem,ChildItem,ProductionOrder,ProdOrderLine,ParentItem."Costing Method"::FIFO,
        ChildItem."Costing Method"::FIFO,FALSE,Qty,QtyPer,WORKDATE);

      LibraryPatterns.POSTConsumption(ProdOrderLine,ChildItem,'','',Qty * QtyPer,WORKDATE,0);
      PostExplodedOutput(ProdOrderLine,WORKDATE,ProdOrderLine.Quantity,0);

      // Exercise. Adjust, revalue and run Inventory Valuation - WIP report.
      LibraryCosting.AdjustCostItemEntries(ParentItem."No." + '|' + ChildItem."No.",'');
      RunInventoryValuationWIPReport(ProductionOrder."No.",WORKDATE - 30,WORKDATE);

      // Verify. Inventory Valuation - WIP report.
      ASSERTERROR BEGIN
        VerifyInventoryValuationWIPReport(ProductionOrder,WORKDATE - 30,WORKDATE,TRUE);
        Assert.KnownFailure('ValueEntryCostPostedToGL',48268);
      END;

      // Tear down.
      LibraryInventory.UpdateInventorySetup(InventorySetup,FALSE,FALSE,
        InventorySetup."Automatic Cost Adjustment",InventorySetup."Average Cost Calc. Type",InventorySetup."Average Cost Period");
Member of Lib.Assert


RecordCount@31 Method

The procedure RecordCount is available in codeunit 130000.

Syntax

RecordCount@31(
    RecVariant@1000 : Variant RecVariant, //Input parameter of type Variant
    ExpectedCount@1001 : Integer ExpectedCount //Input parameter of type Integer
);

Parameters

RecVariant
Input parameter of type Variant
ExpectedCount
Input parameter of type Integer

Remarks

The relevant search keywords are: Record, Count.

For a clarification about how this function works, refer to the code listed below.

      RecRef.GETTABLE(RecVariant);
      IF ExpectedCount <> RecRef.COUNT THEN
        ERROR(RecordCountErr,RecRef.CAPTION,ExpectedCount,RecRef.COUNT);
      RecRef.CLOSE;

Example

The below example is extracted from the test automation codeunit 134006 to show one way of using this function.

      WITH GLEntry DO BEGIN
        SETCURRENTKEY("Transaction No.");
        SETRANGE("Document No.",DocumentNo);
        FINDLAST;
        SETRANGE("Transaction No.","Transaction No.");
        Assert.RecordCount(GLEntry,DimSetArrLen + 1);
        FINDSET;
        FOR Index := 1 TO DimSetArrLen DO BEGIN
          Assert.AreEqual(DimSetIDs[1],"Dimension Set ID",FIELDCAPTION("Dimension Set ID"));
          Assert.AreEqual(-Amounts[Index],Amount,FIELDCAPTION(Amount));
          Sum += Amounts[Index];
          NEXT;
        END;
        Assert.AreEqual(DimSetIDs[1],"Dimension Set ID",FIELDCAPTION("Dimension Set ID"));
        Assert.AreEqual(Sum,Amount,FIELDCAPTION(Amount));
      END;
Member of Lib.Assert


RecordIsEmpty@28 Method

The procedure RecordIsEmpty is available in codeunit 130000.

Syntax

RecordIsEmpty@28(
    RecVariant@1004 : Variant RecVariant //Input parameter of type Variant
);

Parameters

RecVariant
Input parameter of type Variant

Remarks

The relevant search keywords are: Record, Is, Empty.

For a clarification about how this function works, refer to the code listed below.

      RecRef.GETTABLE(RecVariant);
      RecRefIsEmpty(RecRef);

Example

The below example is extracted from the test automation codeunit 134012 to show one way of using this function.

      // [SCENARIO 228341] Issue reminder after posted sales invoice and post customer payment
      // Covers documents TC_ID= 122638 AND 137017.
      Initialize;
      CurrentDate := WORKDATE;

      // [GIVEN] Posted sales invoice with Amount = 1000
      // [GIVEN] Create reminder "R". Suggest, issue reminder (issued reminder no. = "IR")
      // [WHEN] Post customer payment with Amount = 1000
      ReminderNo := CreateInvoiceReminder(GenJournalLine);

      // [THEN] Reminder "R" doesn't exist
      // [THEN] There is a "Payment" customer ledger entry with "Remaining Amount" = 1000
      DummyReminderHeader.SETRANGE("No.",ReminderNo);
      Assert.RecordIsEmpty(DummyReminderHeader);
      VerifyCustLedgerEntryForRemAmt(GenJournalLine);

      // Cleanup: Roll back the previous Workdate.
      WORKDATE := CurrentDate;
      ModifyReminderTerms(FALSE);
Member of Lib.Assert


RecordIsNotEmpty@27 Method

The procedure RecordIsNotEmpty is available in codeunit 130000.

Syntax

RecordIsNotEmpty@27(
    RecVariant@1004 : Variant RecVariant //Input parameter of type Variant
);

Parameters

RecVariant
Input parameter of type Variant

Remarks

The relevant search keywords are: Record, Is, Not, Empty.

For a clarification about how this function works, refer to the code listed below.

      RecRef.GETTABLE(RecVariant);
      RecRefIsNotEmpty(RecRef);

Example

The below example is extracted from the test automation codeunit 134088 to show one way of using this function.

      WITH DummyGLEntry DO BEGIN
        INIT;
        SETRANGE("Document No.",DocumentNo);
        SETRANGE("G/L Account No.",GLAccountNo);
        IF IsPositiveAmount THEN
          SETFILTER(Amount,'>%1',0)
        ELSE
          SETFILTER(Amount,'<%1',0);
        SETRANGE("Gen. Posting Type",ExpectedGenPostingType);
        Assert.RecordIsNotEmpty(DummyGLEntry);
      END;
Member of Lib.Assert


TableIsEmpty@25 Method

The procedure TableIsEmpty is available in codeunit 130000.

Syntax

TableIsEmpty@25(
    TableNo@1004 : Integer TableNo //Input parameter of type Integer
);

Parameters

TableNo
Input parameter of type Integer

Remarks

The relevant search keywords are: Table, Is, Empty.

For a clarification about how this function works, refer to the code listed below.

      RecRef.OPEN(TableNo);
      RecRefIsEmpty(RecRef);
      RecRef.CLOSE;

Example

There are no examples available.
Member of Lib.Assert


TableIsNotEmpty@32 Method

The procedure TableIsNotEmpty is available in codeunit 130000.

Syntax

TableIsNotEmpty@32(
    TableNo@1004 : Integer TableNo //Input parameter of type Integer
);

Parameters

TableNo
Input parameter of type Integer

Remarks

The relevant search keywords are: Table, Is, Not, Empty.

For a clarification about how this function works, refer to the code listed below.

      RecRef.OPEN(TableNo);
      RecRefIsNotEmpty(RecRef);
      RecRef.CLOSE;

Example

There are no examples available.
Member of Lib.Assert


VerifyFailure@14 Method

The procedure VerifyFailure is available in codeunit 130000.

Syntax

VerifyFailure@14(
    expectedErrorCode@1000 : Text expectedErrorCode, //Input parameter of type Text
    failureText@1001 : Text failureText //Input parameter of type Text
);

Parameters

expectedErrorCode
Input parameter of type Text
failureText
Input parameter of type Text

Remarks

The relevant search keywords are: Verify, Failure.

For a clarification about how this function works, refer to the code listed below.

      errorCode := GETLASTERRORCODE;

      IsTrue(errorCode = expectedErrorCode,failureText);
      CLEARLASTERROR;

Example

The below example is extracted from the test automation codeunit 134151 to show one way of using this function.

      // Check Out of Balance error while posting General Journal Lines for two IC Partner.

      // Setup.
      Initialize;
      CreateICJournalBatch(GenJournalBatch);
      CreateICGLAccount(ICGLAccount);

      // Using RANDOM value for Amount.
      CreateAndUpdateICJournalUsingSameBatch(
        GenJournalLine,GenJournalBatch,GenJournalLine."Document Type"::" ",GenJournalLine."Account Type"::"IC Partner",
        CreateICPartner,LibraryRandom.RandDec(100,2),ICGLAccount."Map-to G/L Acc. No.",ICGLAccount."No.");
      CreateAndUpdateICJournalUsingSameBatch(
        GenJournalLine,GenJournalBatch,GenJournalLine."Document Type"::" ",GenJournalLine."Account Type"::"IC Partner",
        GenJournalLine."Account No.",GenJournalLine.Amount,ICGLAccount."Map-to G/L Acc. No.",ICGLAccount."No.");

      // Exercise.
      ASSERTERROR LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // Verify.
      ICOutboxTransaction.FINDLAST;
      Assert.VerifyFailure(RecordExistsErr,InsertDuplicateKeyPassedTxt);
Member of Lib.Assert


Library - Account Schedule Class

Lib.Library - Account Schedule

COD131304 applies to ERM,W1,All.
Utility functions related to Account Schedule

Methods

Name | Description
CalcCell@2 | The procedure CalcCell is available in codeunit 131304.
GetAutoFormatString@188 | The procedure GetAutoFormatString is available in codeunit 131304.
GetCustomFormatString@106 | The procedure GetCustomFormatString is available in codeunit 131304.

See Also

Lib


CalcCell@2 Method

The procedure CalcCell is available in codeunit 131304.

Syntax

CalcCell@2(
    VAR AccSchedLine@1002 : Record 85 AccSchedLine, //Reference parameter of type Record
    VAR ColumnLayout@1001 : Record 334 ColumnLayout, //Reference parameter of type Record
    CalcAddCurr@1000 : Boolean CalcAddCurr, //Input parameter of type Boolean
    IncludeSimEntries@1003 : Boolean IncludeSimEntries //Input parameter of type Boolean
);

Parameters

AccSchedLine
Reference parameter of type Record
ColumnLayout
Reference parameter of type Record
CalcAddCurr
Input parameter of type Boolean
IncludeSimEntries
Input parameter of type Boolean

Return Value

Decimal

Remarks

The relevant search keywords are: Calc, Cell.

For a clarification about how this function works, refer to the code listed below.

      // Wrapper function
      IncludeSimEntries := FALSE; // just for precal
      EXIT(AccSchedManagement.CalcCell(AccSchedLine,ColumnLayout,CalcAddCurr));

Example

The below example is extracted from the test automation codeunit 134902 to show one way of using this function.

      // Test Value on Account Schedule Overview for Cost Accounting

      // 1. Setup: Create Cost Type and Account Schedule Lines with created Cost Type.
      Initialize;
      LibraryCostAccounting.CreateCostType(CostType);
      LibraryCostAccounting.CreateCostCenter(CostCenter);
      CreateColumnLayout(ColumnLayout);
      CreateAccountScheduleAndLine(AccScheduleLine,ColumnLayout."Column Layout Name");
      UpdateAccScheduleForCA(AccScheduleLine,CostType."No.",'','');
      Amount := LibraryRandom.RandDec(10,2);

      // 2. Exercise:
      CreateAndPostCostJournal(CostType."No.",CostCenter.Code,'',Amount);

      // 3. Verify: Verify Account Schedule Overview cell value (NetChange column) with the Amount posted on Cost Journal.
      AccScheduleLine.SETRANGE("Date Filter",WORKDATE);
      Assert.AreEqual(Amount,LibraryAccSchedule.CalcCell(AccScheduleLine,ColumnLayout,FALSE,FALSE),UnknownErr);

      // 4. Tear Down: Reset Cost Accounting alignment.
      LibraryCostAccounting.SetAlignment(
        CostAccountingSetup.FIELDNO("Align G/L Account"),CostAccountingSetup."Align G/L Account"::"No Alignment");
Member of Lib.Library - Account Schedule


GetAutoFormatString@188 Method

The procedure GetAutoFormatString is available in codeunit 131304.

Syntax

GetAutoFormatString@188(
      //param element not supplied
);

Return Value

Text

Remarks

The relevant search keywords are: Get, Auto, Format, String.

For a clarification about how this function works, refer to the code listed below.

      GLSetup.GET;
      EXIT(GetCustomFormatString(GLSetup."Amount Decimal Places"));

Example

There are no examples available.
Member of Lib.Library - Account Schedule


GetCustomFormatString@106 Method

The procedure GetCustomFormatString is available in codeunit 131304.

Syntax

GetCustomFormatString@106(
    Decimals@1001 : Text Decimals //Input parameter of type Text
);

Parameters

Decimals
Input parameter of type Text

Return Value

Text

Remarks

The relevant search keywords are: Get, Custom, Format, String.

For a clarification about how this function works, refer to the code listed below.

      EXIT(STRSUBSTNO(RoundingFormatTok,Decimals));

Example

The below example is extracted from the test automation codeunit 134490 to show one way of using this function.

      // [FEATURE] [Rounding Factor] [UT]
      // [SCENARIO 362971] MatrixMgt.FormatValue returns Decimals according to AdditionalCurrency."Amount Decimal Places" for RoundingFactor::None.
      Decimals := LibraryRandom.RandIntInRange(5,7);
      Value := LibraryRandom.RandDec(100,Decimals);
      SetAddCurrency(CreateCurrencyWithDecimals(Decimals));

      IntPart := ROUND(Value,1,'<');
      ExpectedValue :=
        FORMAT(IntPart) + COPYSTR(FORMAT(Value - IntPart,0,LibraryAccSchedule.GetCustomFormatString(FORMAT(Decimals))),2);

      FormatValueWithRoundingFactor(
        ExpectedValue,Value,RoundingFactorRef::None,TRUE);
Member of Lib.Library - Account Schedule


Library - Assembly Class

Lib.Library - Assembly

COD132207 applies to SCM,W1,All.

Methods

Name | Description
AddAssemblyHeaderComment@160 | The procedure AddAssemblyHeaderComment is available in codeunit 132207.
AddAssemblyLineComment@93 | The procedure AddAssemblyLineComment is available in codeunit 132207.
AddCompInventory@52 | The procedure AddCompInventory is available in codeunit 132207.
AddCompInventoryToBin@27 | The procedure AddCompInventoryToBin is available in codeunit 132207.
AddEntityDimensions@155 | The procedure AddEntityDimensions is available in codeunit 132207.
AddItemInventory@126 | The procedure AddItemInventory is available in codeunit 132207.
AsmOrder_CreateInvtMovement@94 | The procedure AsmOrder_CreateInvtMovement is available in codeunit 132207.
BatchPostAssemblyHeaders@38 | The procedure BatchPostAssemblyHeaders is available in codeunit 132207.
BlockDimensions@168 | The procedure BlockDimensions is available in codeunit 132207.
BlockOrderDimensions@131 | The procedure BlockOrderDimensions is available in codeunit 132207.
CalcExpectedPrice@7 | The procedure CalcExpectedPrice is available in codeunit 132207.
CalcExpectedStandardCost@6 | The procedure CalcExpectedStandardCost is available in codeunit 132207.
CalcOrderCostAmount@16 | The procedure CalcOrderCostAmount is available in codeunit 132207.
ChangeResourceUsage@64 | The procedure ChangeResourceUsage is available in codeunit 132207.
CheckOrderDimensions@72 | The procedure CheckOrderDimensions is available in codeunit 132207.
ClearOrderPostingSetup@154 | The procedure ClearOrderPostingSetup is available in codeunit 132207.
ComponentsAvailable@184 | The procedure ComponentsAvailable is available in codeunit 132207.
CreateAdjustmentSource@153 | The procedure CreateAdjustmentSource is available in codeunit 132207.
CreateAssemblyHeader@53 | The procedure CreateAssemblyHeader is available in codeunit 132207.
CreateAssemblyLine@43 | The procedure CreateAssemblyLine is available in codeunit 132207.
CreateAssemblyLines@48 | The procedure CreateAssemblyLines is available in codeunit 132207.
CreateAssemblyList@21 | The procedure CreateAssemblyList is available in codeunit 132207.
CreateAssemblyListComponent@12 | The procedure CreateAssemblyListComponent is available in codeunit 132207.
CreateAssemblyOrder@19 | The procedure CreateAssemblyOrder is available in codeunit 132207.
CreateAssemblyQuote@51 | The procedure CreateAssemblyQuote is available in codeunit 132207.
CreateAssemblySetup@127 | The procedure CreateAssemblySetup is available in codeunit 132207.
CreateBOM@115 | The procedure CreateBOM is available in codeunit 132207.
CreateDimensionSetup@165 | The procedure CreateDimensionSetup is available in codeunit 132207.
CreateGLAccount@176 | The procedure CreateGLAccount is available in codeunit 132207.
CreateInvtMovement@28 | The procedure CreateInvtMovement is available in codeunit 132207.
CreateInvtPostingSetup@142 | The procedure CreateInvtPostingSetup is available in codeunit 132207.
CreateItem@22 | The procedure CreateItem is available in codeunit 132207.
CreateItemSubstitution@140 | The procedure CreateItemSubstitution is available in codeunit 132207.
CreateItemWithSKU@208 | The procedure CreateItemWithSKU is available in codeunit 132207.
CreateMultipleLvlTree@85 | The procedure CreateMultipleLvlTree is available in codeunit 132207.
CreateResource@3 | The procedure CreateResource is available in codeunit 132207.
CreateRouting@189 | The procedure CreateRouting is available in codeunit 132207.
CreateWhsePick@30 | The procedure CreateWhsePick is available in codeunit 132207.
DeleteAssemblyLine@10 | The procedure DeleteAssemblyLine is available in codeunit 132207.
DeleteAssemblyLines@9 | The procedure DeleteAssemblyLines is available in codeunit 132207.
DeleteAssemblyList@44 | The procedure DeleteAssemblyList is available in codeunit 132207.
DeleteAssemblyListComponent@26 | The procedure DeleteAssemblyListComponent is available in codeunit 132207.
EarliestAvailableDate@183 | The procedure EarliestAvailableDate is available in codeunit 132207.
EditAssemblyLine@11 | The procedure EditAssemblyLine is available in codeunit 132207.
EditAssemblyLines@8 | The procedure EditAssemblyLines is available in codeunit 132207.
EditAssemblyList@79 | The procedure EditAssemblyList is available in codeunit 132207.
EditAssemblyListComponent@23 | The procedure EditAssemblyListComponent is available in codeunit 132207.
EditOrderDimensions@105 | The procedure EditOrderDimensions is available in codeunit 132207.
FindLinkedAssemblyOrder@95 | The procedure FindLinkedAssemblyOrder is available in codeunit 132207.
FindPostedAssemblyHeaders@40 | The procedure FindPostedAssemblyHeaders is available in codeunit 132207.
FindPostedAssemblyLines@55 | The procedure FindPostedAssemblyLines is available in codeunit 132207.
GetAdjAmounts@206 | The procedure GetAdjAmounts is available in codeunit 132207.
GetBOMComponentLines@36 | The procedure GetBOMComponentLines is available in codeunit 132207.
GetCompsToAdjust@5 | The procedure GetCompsToAdjust is available in codeunit 132207.
GetCostInformation@61 | The procedure GetCostInformation is available in codeunit 132207.
GetPostingSetup@68 | The procedure GetPostingSetup is available in codeunit 132207.
GetUnitOfMeasureCode@14 | The procedure GetUnitOfMeasureCode is available in codeunit 132207.
LineCount@45 | The procedure LineCount is available in codeunit 132207.
ModifyCostParams@15 | The procedure ModifyCostParams is available in codeunit 132207.
ModifyItem@24 | The procedure ModifyItem is available in codeunit 132207.
ModifyOrderCostParams@13 | The procedure ModifyOrderCostParams is available in codeunit 132207.
NeedsAdjustment@20 | The procedure NeedsAdjustment is available in codeunit 132207.
PostAssemblyHeader@172 | The procedure PostAssemblyHeader is available in codeunit 132207.
PostInvtCostToGL@1 | The procedure PostInvtCostToGL is available in codeunit 132207.
PrepareOrderPosting@31 | The procedure PrepareOrderPosting is available in codeunit 132207.
ReleaseAO@84 | The procedure ReleaseAO is available in codeunit 132207.
ReopenAO@75 | The procedure ReopenAO is available in codeunit 132207.
RevaluateItem@194 | The procedure RevaluateItem is available in codeunit 132207.
RollUpAsmCost@73 | The procedure RollUpAsmCost is available in codeunit 132207.
RollUpAsmPrice@71 | The procedure RollUpAsmPrice is available in codeunit 132207.
SetLinkToLines@182 | The procedure SetLinkToLines is available in codeunit 132207.
SetStockoutWarning@97 | The procedure SetStockoutWarning is available in codeunit 132207.
SetupAssemblyData@2 | The procedure SetupAssemblyData is available in codeunit 132207.
SetupAssemblyItem@88 | The procedure SetupAssemblyItem is available in codeunit 132207.
SetupComponents@25 | The procedure SetupComponents is available in codeunit 132207.
SetupItemJournal@138 | The procedure SetupItemJournal is available in codeunit 132207.
SetupPostingToGL@177 | The procedure SetupPostingToGL is available in codeunit 132207.
SetupWarehouseJournal@35 | The procedure SetupWarehouseJournal is available in codeunit 132207.
UndoPostedAssembly@74 | The procedure UndoPostedAssembly is available in codeunit 132207.
UpdateAssemblyHeader@91 | The procedure UpdateAssemblyHeader is available in codeunit 132207.
UpdateAssemblyLine@92 | The procedure UpdateAssemblyLine is available in codeunit 132207.
UpdateAssemblySetup@18 | The procedure UpdateAssemblySetup is available in codeunit 132207.
UpdateInventorySetup@49 | The procedure UpdateInventorySetup is available in codeunit 132207.
UpdateInvtPeriod@161 | The procedure UpdateInvtPeriod is available in codeunit 132207.
UpdateOrderCost@137 | The procedure UpdateOrderCost is available in codeunit 132207.
UpdateSKUCards@171 | The procedure UpdateSKUCards is available in codeunit 132207.
VerifyAdjustmentEntries@222 | The procedure VerifyAdjustmentEntries is available in codeunit 132207.
VerifyApplicationEntry@46 | The procedure VerifyApplicationEntry is available in codeunit 132207.
VerifyApplicationEntryUndo@80 | The procedure VerifyApplicationEntryUndo is available in codeunit 132207.
VerifyBinContent@101 | The procedure VerifyBinContent is available in codeunit 132207.
VerifyBinContents@86 | The procedure VerifyBinContents is available in codeunit 132207.
VerifyCapEntries@41 | The procedure VerifyCapEntries is available in codeunit 132207.
VerifyCapEntriesATO@62 | The procedure VerifyCapEntriesATO is available in codeunit 132207.
VerifyCapEntriesGeneric@65 | The procedure VerifyCapEntriesGeneric is available in codeunit 132207.
VerifyCapEntriesUndo@77 | The procedure VerifyCapEntriesUndo is available in codeunit 132207.
VerifyComments@82 | The procedure VerifyComments is available in codeunit 132207.
VerifyEntityDimensions@59 | The procedure VerifyEntityDimensions is available in codeunit 132207.
VerifyGLEntries@66 | The procedure VerifyGLEntries is available in codeunit 132207.
VerifyGLEntry@124 | The procedure VerifyGLEntry is available in codeunit 132207.
VerifyHardLinkEntry@50 | The procedure VerifyHardLinkEntry is available in codeunit 132207.
VerifyHeaderAdjustmentEntry@195 | The procedure VerifyHeaderAdjustmentEntry is available in codeunit 132207.
VerifyHeaderVarianceEntry@215 | The procedure VerifyHeaderVarianceEntry is available in codeunit 132207.
VerifyILEATOAndSale@89 | The procedure VerifyILEATOAndSale is available in codeunit 132207.
VerifyILEs@32 | The procedure VerifyILEs is available in codeunit 132207.
VerifyILESale@90 | The procedure VerifyILESale is available in codeunit 132207.
VerifyILEsForAsmOnATO@54 | The procedure VerifyILEsForAsmOnATO is available in codeunit 132207.
VerifyILEsGeneric@56 | The procedure VerifyILEsGeneric is available in codeunit 132207.
VerifyILEsUndo@78 | The procedure VerifyILEsUndo is available in codeunit 132207.
VerifyIndirectCostEntries@76 | The procedure VerifyIndirectCostEntries is available in codeunit 132207.
VerifyItemRegister@37 | The procedure VerifyItemRegister is available in codeunit 132207.
VerifyLineAdjustmentEntry@218 | The procedure VerifyLineAdjustmentEntry is available in codeunit 132207.
VerifyLineComment@83 | The procedure VerifyLineComment is available in codeunit 132207.
VerifyPartialPosting@63 | The procedure VerifyPartialPosting is available in codeunit 132207.
VerifyPostedAssemblyHeader@29 | The procedure VerifyPostedAssemblyHeader is available in codeunit 132207.
VerifyPostedComments@42 | The procedure VerifyPostedComments is available in codeunit 132207.
VerifyPostedLineComment@47 | The procedure VerifyPostedLineComment is available in codeunit 132207.
VerifyResEntries@34 | The procedure VerifyResEntries is available in codeunit 132207.
VerifyResEntriesATO@58 | The procedure VerifyResEntriesATO is available in codeunit 132207.
VerifyResEntriesGeneric@57 | The procedure VerifyResEntriesGeneric is available in codeunit 132207.
VerifySaleReservationEntryATO@39 | The procedure VerifySaleReservationEntryATO is available in codeunit 132207.
VerifySKUCost@4 | The procedure VerifySKUCost is available in codeunit 132207.
VerifytAsmReservationEntryATO@60 | The procedure VerifytAsmReservationEntryATO is available in codeunit 132207.
VerifyValueEntries@33 | The procedure VerifyValueEntries is available in codeunit 132207.
VerifyValueEntriesAsm@70 | The procedure VerifyValueEntriesAsm is available in codeunit 132207.
VerifyValueEntriesATO@67 | The procedure VerifyValueEntriesATO is available in codeunit 132207.
VerifyValueEntriesSale@69 | The procedure VerifyValueEntriesSale is available in codeunit 132207.
VerifyValueEntriesUndo@81 | The procedure VerifyValueEntriesUndo is available in codeunit 132207.
VerifyWarehouseEntries@125 | The procedure VerifyWarehouseEntries is available in codeunit 132207.

See Also

Lib


AddAssemblyHeaderComment@160 Method

The procedure AddAssemblyHeaderComment is available in codeunit 132207.

Syntax

AddAssemblyHeaderComment@160(
    AssemblyHeader@1000 : Record 900 AssemblyHeader, //Input parameter of type Record
    AssemblyLineNo@1001 : Integer AssemblyLineNo //Input parameter of type Integer
);

Parameters

AssemblyHeader
Input parameter of type Record
AssemblyLineNo
Input parameter of type Integer

Remarks

The relevant search keywords are: Add, Assembly, Header, Comment.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(AssemblyCommentLine);
      AssemblyCommentLine.INIT;
      AssemblyCommentLine.VALIDATE("Document Type",AssemblyHeader."Document Type");
      AssemblyCommentLine.VALIDATE("Document No.",AssemblyHeader."No.");
      AssemblyCommentLine.VALIDATE("Document Line No.",AssemblyLineNo);
      AssemblyCommentLine.VALIDATE(Comment,'Order:' + AssemblyHeader."No." + ', Line:' + FORMAT(AssemblyLineNo));
      AssemblyCommentLine.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137097 to show one way of using this function.

      LibraryAssembly.AddAssemblyHeaderComment(AssemblyHeader,0);
      AssemblyLine.SETRANGE("Document Type",AssemblyHeader."Document Type");
      AssemblyLine.SETRANGE("Document No.",AssemblyHeader."No.");
      IF NOT AssemblyLine.FINDSET THEN
        EXIT;

      REPEAT
        LibraryAssembly.AddAssemblyHeaderComment(AssemblyHeader,AssemblyLine."Line No.");
      UNTIL AssemblyLine.NEXT = 0;
Member of Lib.Library - Assembly


AddAssemblyLineComment@93 Method

The procedure AddAssemblyLineComment is available in codeunit 132207.

Syntax

AddAssemblyLineComment@93(
    VAR AssemblyCommentLine@1000 : Record 906 AssemblyCommentLine, //Reference parameter of type Record
    DocType@1001 : Option DocType, //Input parameter of type Option
    DocumentNo@1002 : Code[20] DocumentNo, //Input parameter of type Code
    DocumentLineNo@1003 : Integer DocumentLineNo, //Input parameter of type Integer
    Date@1004 : Date Date, //Input parameter of type Date
    Comment@1005 : Text[80] Comment //Input parameter of type Text
);

Parameters

AssemblyCommentLine
Reference parameter of type Record
DocType
Input parameter of type Option
DocumentNo
Input parameter of type Code
DocumentLineNo
Input parameter of type Integer
Date
Input parameter of type Date
Comment
Input parameter of type Text

Remarks

The relevant search keywords are: Add, Assembly, Line, Comment.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(AssemblyCommentLine);
      AssemblyCommentLine.VALIDATE("Document Type",DocType);
      AssemblyCommentLine.VALIDATE("Document No.",DocumentNo);
      AssemblyCommentLine.VALIDATE("Document Line No.",DocumentLineNo);
      RecRef.GETTABLE(AssemblyCommentLine);
      AssemblyCommentLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,AssemblyCommentLine.FIELDNO("Line No.")));
      AssemblyCommentLine.INSERT(TRUE);
      AssemblyCommentLine.VALIDATE(Date,Date);
      AssemblyCommentLine.VALIDATE(Comment,Comment);
      AssemblyCommentLine.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - Assembly


AddCompInventory@52 Method

The procedure AddCompInventory is available in codeunit 132207.

Syntax

AddCompInventory@52(
    AssemblyHeader@1000 : Record 900 AssemblyHeader, //Input parameter of type Record
    PostingDate@1002 : Date PostingDate, //Input parameter of type Date
    QtySupplement@1001 : Decimal QtySupplement //Input parameter of type Decimal
);

Parameters

AssemblyHeader
Input parameter of type Record
PostingDate
Input parameter of type Date
QtySupplement
Input parameter of type Decimal

Remarks

The relevant search keywords are: Add, Comp, Inventory.

For a clarification about how this function works, refer to the code listed below.

      AssemblyLine.RESET;
      AssemblyLine.SETRANGE("Document Type",AssemblyHeader."Document Type");
      AssemblyLine.SETRANGE("Document No.",AssemblyHeader."No.");
      AssemblyLine.SETRANGE(Type,AssemblyLine.Type::Item);
      IF AssemblyLine.FINDSET THEN
        REPEAT
          AddItemInventory(
            AssemblyLine,PostingDate,AssemblyLine."Location Code",AssemblyLine."Bin Code",AssemblyLine.Quantity + QtySupplement);
        UNTIL AssemblyLine.NEXT = 0;

Example

The below example is extracted from the test automation codeunit 134900 to show one way of using this function.

      AssemblyHeader.SETRANGE("Item No.",ItemNo);
      AssemblyHeader.FINDFIRST;
      LibraryAssembly.AddCompInventory(AssemblyHeader,WORKDATE,0);
Member of Lib.Library - Assembly


AddCompInventoryToBin@27 Method

The procedure AddCompInventoryToBin is available in codeunit 132207.

Syntax

AddCompInventoryToBin@27(
    AssemblyHeader@1000 : Record 900 AssemblyHeader, //Input parameter of type Record
    PostingDate@1005 : Date PostingDate, //Input parameter of type Date
    QtySupplement@1001 : Decimal QtySupplement, //Input parameter of type Decimal
    LocationCode@1004 : Code[10] LocationCode, //Input parameter of type Code
    BinCode@1002 : Code[20] BinCode //Input parameter of type Code
);

Parameters

AssemblyHeader
Input parameter of type Record
PostingDate
Input parameter of type Date
QtySupplement
Input parameter of type Decimal
LocationCode
Input parameter of type Code
BinCode
Input parameter of type Code

Remarks

The relevant search keywords are: Add, Comp, Inventory, To, Bin.

For a clarification about how this function works, refer to the code listed below.

      isDirected := FALSE;

      IF BinCode <> '' THEN BEGIN
        Bin.SETRANGE(Code,BinCode);
        Bin.SETRANGE("Location Code",LocationCode);
        Bin.FINDFIRST;

        Location.GET(LocationCode);
        IF Location."Directed Put-away and Pick" THEN
          isDirected := TRUE;
      END;

      SetupItemJournal(ItemJournalTemplate,ItemJournalBatch);
      IF isDirected THEN BEGIN
        SetupWarehouseJournal(WarehouseJournalTemplate,WarehouseJournalBatch,LocationCode);

        AssemblyLine.RESET;
        AssemblyLine.SETRANGE("Document Type",AssemblyHeader."Document Type");
        AssemblyLine.SETRANGE("Document No.",AssemblyHeader."No.");
        AssemblyLine.SETRANGE(Type,AssemblyLine.Type::Item);
        IF AssemblyLine.FINDSET THEN
          REPEAT
            LibraryWarehouse.CreateWhseJournalLine(WarehouseJournalLine,WarehouseJournalTemplate.Name,WarehouseJournalBatch.Name,
              LocationCode,Bin."Zone Code",BinCode,
              WarehouseJournalLine."Entry Type"::"Positive Adjmt.",AssemblyLine."No.",AssemblyLine.Quantity + QtySupplement);
          UNTIL AssemblyLine.NEXT = 0;

        LibraryWarehouse.RegisterWhseJournalLine(WarehouseJournalTemplate.Name,WarehouseJournalBatch.Name,LocationCode,
          TRUE);

        // Add to inventory
        Item.SETRANGE("Location Filter",LocationCode);
        LibraryWarehouse.CalculateWhseAdjustment(Item,ItemJournalBatch);
      END ELSE BEGIN
        AssemblyLine.RESET;
        AssemblyLine.SETRANGE("Document Type",AssemblyHeader."Document Type");
        AssemblyLine.SETRANGE("Document No.",AssemblyHeader."No.");
        AssemblyLine.SETRANGE(Type,AssemblyLine.Type::Item);
        IF AssemblyLine.FINDSET THEN
          REPEAT
            LibraryInventory.CreateItemJournalLine(ItemJournalLine,ItemJournalTemplate.Name,ItemJournalBatch.Name,
              ItemJournalLine."Entry Type"::"Positive Adjmt.",AssemblyLine."No.",AssemblyLine.Quantity + QtySupplement);
            ItemJournalLine.VALIDATE("Posting Date",CALCDATE('<-1D>',PostingDate));
            ItemJournalLine.VALIDATE("Document Date",CALCDATE('<-1D>',ItemJournalLine."Posting Date"));
            ItemJournalLine.VALIDATE("Unit of Measure Code",AssemblyLine."Unit of Measure Code");
            ItemJournalLine.VALIDATE("Variant Code",AssemblyLine."Variant Code");
            ItemJournalLine.VALIDATE("Unit Cost",LibraryRandom.RandDec(50,2));
            ItemJournalLine.VALIDATE("Location Code",LocationCode);
            ItemJournalLine.VALIDATE("Bin Code",BinCode);
            ItemJournalLine.MODIFY(TRUE);

          UNTIL AssemblyLine.NEXT = 0;
      END;

      LibraryInventory.PostItemJournalLine(ItemJournalTemplate.Name,ItemJournalBatch.Name);

Example

The below example is extracted from the test automation codeunit 137097 to show one way of using this function.

      CreateAssembledItem(Item,Item."Assembly Policy"::"Assemble-to-Stock",LibraryRandom.RandInt(10),
        LibraryRandom.RandInt(10),LibraryRandom.RandInt(10),1);
      DueDate := CALCDATE('<+' + FORMAT(LibraryRandom.RandInt(30)) + 'D>',WorkDate2);
      CreateAssemblyOrder(AssemblyHeader,Item,LocationCode,HeaderBinCode,'',DueDate,OrderQty);

      // Add enough inventory for comp and post
      LibraryAssembly.AddCompInventoryToBin(AssemblyHeader,WORKDATE,0,LocationCode,ComponentsBinCode);
Member of Lib.Library - Assembly


AddEntityDimensions@155 Method

The procedure AddEntityDimensions is available in codeunit 132207.

Syntax

AddEntityDimensions@155(
    Type@1004 : Option Type, //Input parameter of type Option
    No@1000 : Code[20] No //Input parameter of type Code
);

Parameters

Type
Input parameter of type Option
No
Input parameter of type Code

Remarks

The relevant search keywords are: Add, Entity, Dimensions.

For a clarification about how this function works, refer to the code listed below.

      CreateDimensionSetup(TempDimension,TempDimensionValue);
      TempDimension.FINDSET;
      TempDimensionValue.FINDSET;
      REPEAT
        CASE Type OF
          AssemblyLine.Type::Item:
            LibraryDimension.CreateDefaultDimensionItem(DefaultDimension,No,TempDimension.Code,TempDimensionValue.Code);
          AssemblyLine.Type::Resource:
            LibraryDimension.CreateDefaultDimensionResource(DefaultDimension,No,TempDimension.Code,TempDimensionValue.Code);
        END;
        TempDimensionValue.NEXT;
      UNTIL TempDimension.NEXT = 0;

Example

The below example is extracted from the test automation codeunit 137097 to show one way of using this function.

      // Add components - qty per is increasing same as no of components
      FOR CompCount := 1 TO NoOfComponents DO BEGIN
        CLEAR(Item);
        LibraryInventory.CreateItem(Item);
        LibraryAssembly.AddEntityDimensions(AssemblyLine.Type::Item,Item."No.");
        AddComponentToAssemblyList(
          BOMComponent,BOMComponent.Type::Item,Item."No.",ParentItem."No.",'',
          BOMComponent."Resource Usage Type"::Direct,Item."Base Unit of Measure",QtyPer);
      END;

      // Add resources - qty per is increasing same as no of components
      FOR CompCount := 1 TO NoOfResources DO BEGIN
        LibraryAssembly.CreateResource(Resource,TRUE,GenProdPostingGr);
        LibraryAssembly.AddEntityDimensions(AssemblyLine.Type::Resource,Resource."No.");
        AddComponentToAssemblyList(
          BOMComponent,BOMComponent.Type::Resource,Resource."No.",ParentItem."No.",'',
          BOMComponent."Resource Usage Type"::Direct,Resource."Base Unit of Measure",QtyPer);
      END;

      // Add simple text
      FOR CompCount := 1 TO NoOfTexts DO
        AddComponentToAssemblyList(BOMComponent,BOMComponent.Type::" ",'',ParentItem."No.",'',
          BOMComponent."Resource Usage Type"::Direct,'',0);
Member of Lib.Library - Assembly


AddItemInventory@126 Method

The procedure AddItemInventory is available in codeunit 132207.

Syntax

AddItemInventory@126(
    AssemblyLine@1000 : Record 901 AssemblyLine, //Input parameter of type Record
    PostingDate@1013 : Date PostingDate, //Input parameter of type Date
    LocationCode@1014 : Code[10] LocationCode, //Input parameter of type Code
    BinCode@1001 : Code[20] BinCode, //Input parameter of type Code
    Qty@1005 : Decimal Qty //Input parameter of type Decimal
);

Parameters

AssemblyLine
Input parameter of type Record
PostingDate
Input parameter of type Date
LocationCode
Input parameter of type Code
BinCode
Input parameter of type Code
Qty
Input parameter of type Decimal

Remarks

The relevant search keywords are: Add, Item, Inventory.

For a clarification about how this function works, refer to the code listed below.

      isDirected := FALSE;

      IF BinCode <> '' THEN BEGIN
        Bin.SETRANGE(Code,BinCode);
        Bin.SETRANGE("Location Code",LocationCode);
        Bin.FINDFIRST;

        Location.GET(LocationCode);
        IF Location."Directed Put-away and Pick" THEN
          isDirected := TRUE;
      END;

      SetupItemJournal(ItemJournalTemplate,ItemJournalBatch);
      IF isDirected THEN BEGIN
        SetupWarehouseJournal(WarehouseJournalTemplate,WarehouseJournalBatch,LocationCode);

        LibraryWarehouse.CreateWhseJournalLine(WarehouseJournalLine,WarehouseJournalTemplate.Name,WarehouseJournalBatch.Name,
          LocationCode,Bin."Zone Code",BinCode,
          WarehouseJournalLine."Entry Type"::"Positive Adjmt.",AssemblyLine."No.",Qty);
        LibraryWarehouse.RegisterWhseJournalLine(WarehouseJournalTemplate.Name,WarehouseJournalBatch.Name,LocationCode,
          TRUE);

        // Add to inventory
        Item.SETRANGE("No.",AssemblyLine."No.");
        Item.SETRANGE("Location Filter",LocationCode);
        LibraryWarehouse.CalculateWhseAdjustment(Item,ItemJournalBatch);
      END ELSE BEGIN
        LibraryInventory.CreateItemJournalLine(ItemJournalLine,ItemJournalTemplate.Name,ItemJournalBatch.Name,
          ItemJournalLine."Entry Type"::"Positive Adjmt.",AssemblyLine."No.",Qty);
        ItemJournalLine.VALIDATE("Posting Date",CALCDATE('<-1D>',PostingDate));
        ItemJournalLine.VALIDATE("Document Date",CALCDATE('<-1D>',ItemJournalLine."Posting Date"));
        ItemJournalLine.VALIDATE("Unit of Measure Code",AssemblyLine."Unit of Measure Code");
        ItemJournalLine.VALIDATE("Variant Code",AssemblyLine."Variant Code");
        ItemJournalLine.VALIDATE("Unit Cost",LibraryRandom.RandDec(50,2));
        ItemJournalLine.VALIDATE("Location Code",LocationCode);
        ItemJournalLine.VALIDATE("Bin Code",BinCode);
        ItemJournalLine.MODIFY(TRUE);
      END;

      LibraryInventory.PostItemJournalLine(ItemJournalTemplate.Name,ItemJournalBatch.Name);

Example

The below example is extracted from the test automation codeunit 137104 to show one way of using this function.

      AssemblyLine.RESET;
      AssemblyLine.SETRANGE("Document Type",AssemblyHeader."Document Type");
      AssemblyLine.SETRANGE("Document No.",AssemblyHeader."No.");
      AssemblyLine.SETRANGE(Type,AssemblyLine.Type::Item);
      AssemblyLine.FINDSET;

      // Calculate result quantities
      i := 1;
      REPEAT
        ResultQtys[i] := AssemblyLine.Quantity * CompQtyFactor / 100;
        IF i = NotEnoughNo THEN BEGIN
          Item.GET(AssemblyLine."No.");
          NotEnoughItemNo := Item."No.";
          ResultQtys[i] := ROUND(ResultQtys[i],0.00001,'>');
          ResultQtys[i] -= 0.00002;
          ItemsCount := AssemblyLine.COUNT + 1;
          ResultQtys[ItemsCount] := 0.00002;
        END ELSE
          ResultQtys[i] := ROUND(ResultQtys[i],0.00001,'>');

        i += 1;
      UNTIL AssemblyLine.NEXT = 0;

      // Add inventory
      i := 1;
      AssemblyLine.FINDSET;
      REPEAT
        LibraryAssembly.AddItemInventory(AssemblyLine,WorkDate2,AssemblyLine."Location Code",BinToPutCode,ResultQtys[i]);
        i += 1;
      UNTIL AssemblyLine.NEXT = 0;

      // Add rest inventory to additional bin
      IF AddAdditionalQty THEN BEGIN
        AssemblyLine.RESET;
        AssemblyLine.SETRANGE("Document Type",AssemblyHeader."Document Type");
        AssemblyLine.SETRANGE("Document No.",AssemblyHeader."No.");
        AssemblyLine.SETRANGE(Type,AssemblyLine.Type::Item);
        AssemblyLine.SETRANGE("No.",NotEnoughItemNo);
        AssemblyLine.FINDFIRST;

        LibraryAssembly.AddItemInventory(
          AssemblyLine,WorkDate2,AssemblyLine."Location Code",LocationAdditionalBinCode,ResultQtys[ItemsCount]);
      END;
Member of Lib.Library - Assembly


AsmOrder_CreateInvtMovement@94 Method

The procedure AsmOrder_CreateInvtMovement is available in codeunit 132207.

Syntax

AsmOrder_CreateInvtMovement@94(
    VAR WarehouseRequest@1008 : Record 5765 WarehouseRequest, //Reference parameter of type Record
    NewCreateInvtPutAway@1006 : Boolean NewCreateInvtPutAway, //Input parameter of type Boolean
    NewCreateInvtPick@1005 : Boolean NewCreateInvtPick, //Input parameter of type Boolean
    NewCreateInvtMovement@1007 : Boolean NewCreateInvtMovement, //Input parameter of type Boolean
    NewPrintDocument@1001 : Boolean NewPrintDocument, //Input parameter of type Boolean
    NewShowError@1002 : Boolean NewShowError //Input parameter of type Boolean
);

Parameters

WarehouseRequest
Reference parameter of type Record
NewCreateInvtPutAway
Input parameter of type Boolean
NewCreateInvtPick
Input parameter of type Boolean
NewCreateInvtMovement
Input parameter of type Boolean
NewPrintDocument
Input parameter of type Boolean
NewShowError
Input parameter of type Boolean

Remarks

The relevant search keywords are: Asm, Order_, Create, Invt, Movement.

For a clarification about how this function works, refer to the code listed below.

      // TODO - align with previous function

      COMMIT;
      CreateInvtPutAwayPick.InitializeRequest(
        NewCreateInvtPutAway,NewCreateInvtPick,NewCreateInvtMovement,NewPrintDocument,NewShowError);
      IF WarehouseRequest.HASFILTER THEN
        TmpWarehouseRequest.COPYFILTERS(WarehouseRequest)
      ELSE BEGIN
        WarehouseRequest.GET(WarehouseRequest.Type,
          WarehouseRequest."Location Code",
          WarehouseRequest."Source Type",
          WarehouseRequest."Source Subtype",
          WarehouseRequest."Source No.");
        TmpWarehouseRequest.SETRANGE(Type,WarehouseRequest.Type);
        TmpWarehouseRequest.SETRANGE("Location Code",WarehouseRequest."Location Code");
        TmpWarehouseRequest.SETRANGE("Source Type",WarehouseRequest."Source Type");
        TmpWarehouseRequest.SETRANGE("Source Subtype",WarehouseRequest."Source Subtype");
        TmpWarehouseRequest.SETRANGE("Source No.",WarehouseRequest."Source No.");
      END;
      CreateInvtPutAwayPick.SETTABLEVIEW(TmpWarehouseRequest);
      CreateInvtPutAwayPick.USEREQUESTPAGE(FALSE);
      CreateInvtPutAwayPick.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 137913 to show one way of using this function.

      WarehouseRequest.SETCURRENTKEY("Source Document","Source No.");
      WarehouseRequest.SETRANGE("Source Document",WarehouseRequest."Source Document"::"Assembly Consumption");
      WarehouseRequest.SETRANGE("Source No.",AsmHeader."No.");
      LibraryAssembly.AsmOrder_CreateInvtMovement(WarehouseRequest,FALSE,CreatePick,CreateMvmt,FALSE,TRUE);
Member of Lib.Library - Assembly


BatchPostAssemblyHeaders@38 Method

The procedure BatchPostAssemblyHeaders is available in codeunit 132207.

Syntax

BatchPostAssemblyHeaders@38(
    VAR AssemblyHeader@1000 : Record 900 AssemblyHeader, //Reference parameter of type Record
    PostingDate@1003 : Date PostingDate, //Input parameter of type Date
    ReplacePostingDate@1004 : Boolean ReplacePostingDate, //Input parameter of type Boolean
    ExpectedError@1001 : Text[1024] ExpectedError //Input parameter of type Text
);

Parameters

AssemblyHeader
Reference parameter of type Record
PostingDate
Input parameter of type Date
ReplacePostingDate
Input parameter of type Boolean
ExpectedError
Input parameter of type Text

Remarks

The relevant search keywords are: Batch, Post, Assembly, Headers.

For a clarification about how this function works, refer to the code listed below.

      BatchPostAssemblyOrders.USEREQUESTPAGE(FALSE);
      BatchPostAssemblyOrders.InitializeRequest(PostingDate,ReplacePostingDate);
      BatchPostAssemblyOrders.SETTABLEVIEW(AssemblyHeader);
      IF ExpectedError = '' THEN
        BatchPostAssemblyOrders.RUNMODAL
      ELSE BEGIN
        ASSERTERROR BatchPostAssemblyOrders.RUNMODAL;
        Assert.IsTrue(STRPOS(GETLASTERRORTEXT,ExpectedError) > 0,'Actual:' + GETLASTERRORTEXT);
        CLEARLASTERROR;
      END;

Example

The below example is extracted from the test automation codeunit 137096 to show one way of using this function.

      // TC137 from the TDS - see Documentation

      CreateAssembledItem(Item,Item."Assembly Policy"::"Assemble-to-Order",LibraryRandom.RandInt(10),
        LibraryRandom.RandInt(10),LibraryRandom.RandInt(10),LibraryRandom.RandInt(1000),
        Item."Costing Method"::FIFO);

      // Exercise - create SOL with ATO item
      OrderQty := LibraryRandom.RandInt(1000);
      DueDate := CALCDATE('<+' + FORMAT(LibraryRandom.RandInt(30)) + 'D>',WorkDate2);
      CreateSalesOrder(SalesHeader,Item."No.",'',OrderQty,DueDate,LocationCode);
      FindAssemblyHeader(AssemblyHeaderATO,AssemblyHeader."Document Type"::Order,Item,'',LocationCode,
        DueDate,Item."Base Unit of Measure",OrderQty);

      // Create manually an AO for ATO item
      CreateAssemblyOrder(AssemblyHeaderRegular,Item,LocationCode,'',DueDate,OrderQty);
      AddInvNonDirectLocAllComponent(AssemblyHeaderRegular,100);

      // Exercise - batch post AOs - for the ATO item
      CLEAR(AssemblyHeader);
      AssemblyHeader.SETRANGE("Item No.",Item."No.");
      LibraryAssembly.BatchPostAssemblyHeaders(AssemblyHeader,0D,FALSE,'');

      // Verify - only manually created AO is posted
      AssertNoAssemblyHeader(AssemblyHeaderRegular."Document Type",AssemblyHeaderRegular."No.");
      AssemblyHeaderATO.GET(AssemblyHeaderATO."Document Type",AssemblyHeaderATO."No.");
      Assert.AreEqual(0,AssemblyHeaderATO."Assembled Quantity",NoQtyPostedMsg);
Member of Lib.Library - Assembly


BlockDimensions@168 Method

The procedure BlockDimensions is available in codeunit 132207.

Syntax

BlockDimensions@168(
    TableID@1003 : Integer TableID, //Input parameter of type Integer
    DimBlockType@1000 : Option DimBlockType, //Input parameter of type Option
    EntityNo@1001 : Code[20] EntityNo, //Input parameter of type Code
    OrderNo@1008 : Code[20] OrderNo, //Input parameter of type Code
    LineNo@1009 : Text[30] LineNo //Input parameter of type Text
);

Parameters

TableID
Input parameter of type Integer
DimBlockType
Input parameter of type Option
EntityNo
Input parameter of type Code
OrderNo
Input parameter of type Code
LineNo
Input parameter of type Text

Return Value

Text[1024]

Remarks

The relevant search keywords are: Block, Dimensions.

For a clarification about how this function works, refer to the code listed below.

      LibraryDimension.FindDefaultDimension(DefaultDimension,TableID,EntityNo);
      DefaultDimension.FINDSET;
      FOR Count := 1 TO DefaultDimension.COUNT DO BEGIN
        DimensionCode[Count] := DefaultDimension."Dimension Code";
        DefaultDimension.NEXT;
      END;

      ExpectedError := '';
      CASE DimBlockType OF
        BlockType::Dimension:
          BEGIN
            Dimension.GET(DefaultDimension."Dimension Code");
            Dimension.VALIDATE(Blocked,TRUE);
            Dimension.MODIFY(TRUE);
            ExpectedError := 'Dimension ' + Dimension.Code + ' is blocked.';
          END;
        BlockType::"Dimension Value":
          BEGIN
            DimensionValue.GET(DefaultDimension."Dimension Code",DefaultDimension."Dimension Value Code");
            DimensionValue.VALIDATE(Blocked,TRUE);
            DimensionValue.MODIFY(TRUE);
            ExpectedError := 'Dimension Value ' + DimensionValue."Dimension Code" + ' - ' + DimensionValue.Code + ' is blocked.';
          END;
        BlockType::"Dimension Combination":
          BEGIN
            DimensionCombination.GET(DimensionCode[1],DimensionCode[2]);
            DimensionCombination.VALIDATE("Combination Restriction",DimensionCombination."Combination Restriction"::Blocked);
            DimensionCombination.MODIFY(TRUE);
            ExpectedError := STRSUBSTNO(ErrorDimCombination,OrderNo,LineNo,DimensionCode[1],DimensionCode[2]);
          END;
      END;

      EXIT(ExpectedError);

Example

There are no examples available.
Member of Lib.Library - Assembly


BlockOrderDimensions@131 Method

The procedure BlockOrderDimensions is available in codeunit 132207.

Syntax

BlockOrderDimensions@131(
    AssemblyHeader@1000 : Record 900 AssemblyHeader, //Input parameter of type Record
    HeaderBlockType@1001 : Option HeaderBlockType, //Input parameter of type Option
    CompBlockType@1008 : Option CompBlockType //Input parameter of type Option
);

Parameters

AssemblyHeader
Input parameter of type Record
HeaderBlockType
Input parameter of type Option
CompBlockType
Input parameter of type Option

Return Value

Text[1024]

Remarks

The relevant search keywords are: Block, Order, Dimensions.

For a clarification about how this function works, refer to the code listed below.

      AssemblyLine.SETRANGE("Document Type",AssemblyHeader."Document Type");
      AssemblyLine.SETRANGE("Document No.",AssemblyHeader."No.");
      IF AssemblyLine.FINDFIRST THEN BEGIN
        CASE AssemblyLine.Type OF
          AssemblyLine.Type::Item:
            TableID := 27;
          AssemblyLine.Type::Resource:
            TableID := 156;
          AssemblyLine.Type::" ":
            BEGIN
              TableID := 0;
              AssemblyLine.TESTFIELD("Dimension Set ID",0);
            END;
        END;
        CompError := BlockDimensions(TableID,CompBlockType,AssemblyLine."No.",
            AssemblyLine."Document No.",', line no. ' + FORMAT(AssemblyLine."Line No."));
      END;

      HeaderError := BlockDimensions(27,HeaderBlockType,AssemblyHeader."Item No.",AssemblyHeader."No.",'');

      IF HeaderError <> '' THEN
        EXIT(HeaderError);
      IF CompError <> '' THEN
        EXIT(CompError);
      EXIT('');

Example

The below example is extracted from the test automation codeunit 137092 to show one way of using this function.

      // Setup.
      Initialize;
      LibraryAssembly.UpdateAssemblySetup(AssemblySetup,'',DimensionsFrom,LibraryUtility.GetGlobalNoSeriesCode);
      LibraryAssembly.SetupAssemblyData(AssemblyHeader,WorkDate2,Item."Costing Method"::Standard,Item."Costing Method"::Average,
        Item."Replenishment System"::Assembly,'',TRUE);
      LibraryAssembly.AddCompInventory(AssemblyHeader,WorkDate2,0);

      // Exercise.
      LibraryAssembly.CheckOrderDimensions(AssemblyHeader,DimensionsFrom);
      IF OverrideDimensions THEN
        LibraryAssembly.EditOrderDimensions(AssemblyHeader);
      ExpectedError := LibraryAssembly.BlockOrderDimensions(AssemblyHeader,HeaderBlockType,CompBlockType);

      IF ExpectedError = '' THEN
        ExpectedError := AddAOItemDimension(AssemblyHeader,DefaultHeaderValuePosting,DefaultCompValuePosting);

      SetShortcutDimensions(AssemblyHeader,1);
      SetShortcutDimensions(AssemblyHeader,2);

      LibraryAssembly.PrepareOrderPosting(AssemblyHeader,TempAssemblyLine,100,100,TRUE,WorkDate2);
      LibraryAssembly.PostAssemblyHeader(AssemblyHeader,ExpectedError);

      // Verify.
      IF ExpectedError = '' THEN BEGIN
        LibraryAssembly.VerifyPostedAssemblyHeader(TempAssemblyLine,AssemblyHeader,AssemblyHeader.Quantity);
        LibraryAssembly.VerifyPostedComments(AssemblyHeader);
        LibraryAssembly.VerifyILEs(TempAssemblyLine,AssemblyHeader,AssemblyHeader."Quantity to Assemble");
        LibraryAssembly.VerifyValueEntries(TempAssemblyLine,AssemblyHeader,AssemblyHeader."Quantity to Assemble");
        LibraryAssembly.VerifyResEntries(TempAssemblyLine,AssemblyHeader);
        LibraryAssembly.VerifyCapEntries(TempAssemblyLine,AssemblyHeader);
        LibraryAssembly.VerifyItemRegister(AssemblyHeader);
      END;

      // Tear down.
Member of Lib.Library - Assembly


CalcExpectedPrice@7 Method

The procedure CalcExpectedPrice is available in codeunit 132207.

Syntax

CalcExpectedPrice@7(
    ParentItemNo@1000 : Code[20] ParentItemNo //Input parameter of type Code
);

Parameters

ParentItemNo
Input parameter of type Code

Return Value

Decimal

Remarks

The relevant search keywords are: Calc, Expected, Price.

For a clarification about how this function works, refer to the code listed below.

      ExpectedPrice := 0;
      BOMComponent.SETRANGE("Parent Item No.",ParentItemNo);
      BOMComponent.SETRANGE(Type,BOMComponent.Type::Item);
      IF BOMComponent.FINDSET THEN
        REPEAT
          Item.GET(BOMComponent."No.");
          ItemUnitOfMeasure.GET(Item."No.",BOMComponent."Unit of Measure Code");
          ExpectedPrice += Item."Unit Price" * BOMComponent."Quantity per" * ItemUnitOfMeasure."Qty. per Unit of Measure";
        UNTIL BOMComponent.NEXT = 0;

      Item.GET(ParentItemNo);
      BOMComponent.SETRANGE(Type,BOMComponent.Type::Resource);
      IF BOMComponent.FINDSET THEN
        REPEAT
          Resource.GET(BOMComponent."No.");
          ResUnitOfMeasure.GET(Resource."No.",BOMComponent."Unit of Measure Code");
          ExpectedPrice += Resource."Unit Price" * BOMComponent."Quantity per" * ResUnitOfMeasure."Qty. per Unit of Measure"
        UNTIL BOMComponent.NEXT = 0;

      IF ExpectedPrice = 0 THEN
        EXIT(Item."Unit Price");
      EXIT(ROUND(ExpectedPrice,LibraryERM.GetUnitAmountRoundingPrecision));

Example

The below example is extracted from the test automation codeunit 137090 to show one way of using this function.

      // Setup.
      Initialize;
      LibraryAssembly.CreateItem(Item,Item."Costing Method"::Standard,Item."Replenishment System"::Assembly,'','');
      LibraryAssembly.CreateAssemblyList(Item."Costing Method"::Standard,Item."No.",UseBaseUoM,
        NoOfItems,NoOfResources,NoOfTexts,QtyPerFactor,'','');

      StdCostLevel := 1;
      // Exercise.
      CalculateStandardCost.CalcItem(Item."No.",TRUE);
      CalculateStandardCost.CalcAssemblyItemPrice(Item."No.");

      // Validate.
      Item.GET(Item."No.");
      Item.CALCFIELDS("Assembly BOM");
      Assert.AreNearlyEqual(LibraryAssembly.CalcExpectedStandardCost(MaterialCost,CapacityCost,CapOverhead,Item."No."),
        Item."Standard Cost",LibraryERM.GetAmountRoundingPrecision,'Wrong std. cost for:' + Item."No.");
      Assert.AreNearlyEqual(MaterialCost,Item."Single-Level Material Cost",LibraryERM.GetUnitAmountRoundingPrecision,'Material Cost');
      Assert.AreNearlyEqual(CapacityCost,Item."Single-Level Capacity Cost",LibraryERM.GetUnitAmountRoundingPrecision,'Cap Cost');
      Assert.AreNearlyEqual(CapOverhead,Item."Single-Level Cap. Ovhd Cost",LibraryERM.GetUnitAmountRoundingPrecision,'Cap Overhead');
      Assert.AreNearlyEqual(CapOverhead,Item."Rolled-up Cap. Overhead Cost",LibraryERM.GetUnitAmountRoundingPrecision,
        'Rolled up Cap Overhead');
      Assert.AreNearlyEqual(
        LibraryAssembly.CalcExpectedPrice(Item."No."),Item."Unit Price",LibraryERM.GetUnitAmountRoundingPrecision,
        'Wrong unit price for:' + Item."No.");
      Assert.AreEqual(NoOfItems + NoOfResources + NoOfTexts > 0,Item."Assembly BOM",'Wrong Assembly BOM flag');
Member of Lib.Library - Assembly


CalcExpectedStandardCost@6 Method

The procedure CalcExpectedStandardCost is available in codeunit 132207.

Syntax

CalcExpectedStandardCost@6(
    VAR MaterialCost@1011 : Decimal MaterialCost, //Reference parameter of type Decimal
    VAR CapacityCost@1010 : Decimal CapacityCost, //Reference parameter of type Decimal
    VAR CapOverhead@1009 : Decimal CapOverhead, //Reference parameter of type Decimal
    ParentItemNo@1000 : Code[20] ParentItemNo //Input parameter of type Code
);

Parameters

MaterialCost
Reference parameter of type Decimal
CapacityCost
Reference parameter of type Decimal
CapOverhead
Reference parameter of type Decimal
ParentItemNo
Input parameter of type Code

Return Value

Decimal

Remarks

The relevant search keywords are: Calc, Expected, Standard, Cost.

For a clarification about how this function works, refer to the code listed below.

      ExpectedCost := 0;
      MaterialCost := 0;
      CapacityCost := 0;
      CapOverhead := 0;
      BOMComponent.SETRANGE("Parent Item No.",ParentItemNo);
      Item.GET(ParentItemNo);

      IF BOMComponent.FINDSET THEN
        REPEAT
          CASE BOMComponent.Type OF
            BOMComponent.Type::Item:
              BEGIN
                Item1.GET(BOMComponent."No.");
                ItemUnitOfMeasure.GET(Item1."No.",BOMComponent."Unit of Measure Code");
                LineCost := Item1."Unit Cost" * BOMComponent."Quantity per" * ItemUnitOfMeasure."Qty. per Unit of Measure";
                ExpectedCost += LineCost;
                MaterialCost += LineCost;
              END;
            BOMComponent.Type::Resource:
              BEGIN
                Resource.GET(BOMComponent."No.");
                ResourceUnitOfMeasure.GET(Resource."No.",BOMComponent."Unit of Measure Code");
                IF (BOMComponent."Resource Usage Type" = BOMComponent."Resource Usage Type"::Direct) OR (Item."Lot Size" = 0) THEN
                  LotSize := 1
                ELSE
                  LotSize := Item."Lot Size";

                LineCost := (Resource."Unit Cost" * BOMComponent."Quantity per" * ResourceUnitOfMeasure."Qty. per Unit of Measure"
                             ) / LotSize;
                CapOverhead += LineCost - Resource."Direct Unit Cost" *
                  BOMComponent."Quantity per" * ResourceUnitOfMeasure."Qty. per Unit of Measure" / LotSize;
                CapacityCost += LineCost;
                ExpectedCost += LineCost;
              END
          END;
        UNTIL BOMComponent.NEXT = 0;

      IF ExpectedCost = 0 THEN
        EXIT(Item."Standard Cost");
      ExpectedCost := ExpectedCost * (1 + Item."Indirect Cost %" / 100) + Item."Overhead Rate";

      MaterialCost := ROUND(MaterialCost,LibraryERM.GetUnitAmountRoundingPrecision);
      CapacityCost := ROUND(CapacityCost,LibraryERM.GetUnitAmountRoundingPrecision);
      CapOverhead := ROUND(CapOverhead,LibraryERM.GetUnitAmountRoundingPrecision);
      EXIT(ROUND(ExpectedCost,LibraryERM.GetUnitAmountRoundingPrecision));

Example

The below example is extracted from the test automation codeunit 137090 to show one way of using this function.

      // Setup.
      Initialize;
      LibraryAssembly.CreateItem(Item,Item."Costing Method"::Standard,Item."Replenishment System"::Assembly,'','');
      LibraryAssembly.CreateAssemblyList(Item."Costing Method"::Standard,Item."No.",UseBaseUoM,
        NoOfItems,NoOfResources,NoOfTexts,QtyPerFactor,'','');

      StdCostLevel := 1;
      // Exercise.
      CalculateStandardCost.CalcItem(Item."No.",TRUE);
      CalculateStandardCost.CalcAssemblyItemPrice(Item."No.");

      // Validate.
      Item.GET(Item."No.");
      Item.CALCFIELDS("Assembly BOM");
      Assert.AreNearlyEqual(LibraryAssembly.CalcExpectedStandardCost(MaterialCost,CapacityCost,CapOverhead,Item."No."),
        Item."Standard Cost",LibraryERM.GetAmountRoundingPrecision,'Wrong std. cost for:' + Item."No.");
      Assert.AreNearlyEqual(MaterialCost,Item."Single-Level Material Cost",LibraryERM.GetUnitAmountRoundingPrecision,'Material Cost');
      Assert.AreNearlyEqual(CapacityCost,Item."Single-Level Capacity Cost",LibraryERM.GetUnitAmountRoundingPrecision,'Cap Cost');
      Assert.AreNearlyEqual(CapOverhead,Item."Single-Level Cap. Ovhd Cost",LibraryERM.GetUnitAmountRoundingPrecision,'Cap Overhead');
      Assert.AreNearlyEqual(CapOverhead,Item."Rolled-up Cap. Overhead Cost",LibraryERM.GetUnitAmountRoundingPrecision,
        'Rolled up Cap Overhead');
      Assert.AreNearlyEqual(
        LibraryAssembly.CalcExpectedPrice(Item."No."),Item."Unit Price",LibraryERM.GetUnitAmountRoundingPrecision,
        'Wrong unit price for:' + Item."No.");
      Assert.AreEqual(NoOfItems + NoOfResources + NoOfTexts > 0,Item."Assembly BOM",'Wrong Assembly BOM flag');
Member of Lib.Library - Assembly


CalcOrderCostAmount@16 Method

The procedure CalcOrderCostAmount is available in codeunit 132207.

Syntax

CalcOrderCostAmount@16(
    VAR MaterialCost@1009 : Decimal MaterialCost, //Reference parameter of type Decimal
    VAR ResourceCost@1011 : Decimal ResourceCost, //Reference parameter of type Decimal
    VAR ResourceOvhd@1012 : Decimal ResourceOvhd, //Reference parameter of type Decimal
    VAR AssemblyOvhd@1006 : Decimal AssemblyOvhd, //Reference parameter of type Decimal
    AssemblyHeaderNo@1000 : Code[20] AssemblyHeaderNo //Input parameter of type Code
);

Parameters

MaterialCost
Reference parameter of type Decimal
ResourceCost
Reference parameter of type Decimal
ResourceOvhd
Reference parameter of type Decimal
AssemblyOvhd
Reference parameter of type Decimal
AssemblyHeaderNo
Input parameter of type Code

Return Value

Decimal

Remarks

The relevant search keywords are: Calc, Order, Cost, Amount.

For a clarification about how this function works, refer to the code listed below.

      ExpectedCost := 0;
      MaterialCost := 0;
      ResourceCost := 0;
      ResourceOvhd := 0;

      AssemblyLine.SETCURRENTKEY("Document Type","Document No.",Type);
      AssemblyLine.SETRANGE("Document Type",AssemblyLine."Document Type"::Order);
      AssemblyLine.SETRANGE("Document No.",AssemblyHeaderNo);
      AssemblyLine.SETFILTER(Type,'<>%1',AssemblyLine.Type::" ");
      IF AssemblyLine.FINDSET THEN
        REPEAT
          GetCostInformation(UnitCost,Overhead,IndirectCost,AssemblyLine.Type,AssemblyLine."No.",'','');
          LineOverhead := Overhead * AssemblyLine.Quantity * AssemblyLine."Qty. per Unit of Measure";
          LineCost := AssemblyLine."Unit Cost" * AssemblyLine.Quantity ;
          IF AssemblyLine.Type = AssemblyLine.Type::Item THEN
            MaterialCost += LineCost
          ELSE BEGIN
            ResourceCost += LineCost;
            ResourceOvhd += LineOverhead;
          END
        UNTIL AssemblyLine.NEXT = 0;

      AssemblyHeader.GET(AssemblyHeader."Document Type"::Order,AssemblyHeaderNo);
      Item.GET(AssemblyHeader."Item No.");
      AssemblyOvhd := Item."Indirect Cost %" / 100 * (MaterialCost + ResourceCost + ResourceOvhd) +
        Item."Overhead Rate" * AssemblyHeader.Quantity * AssemblyHeader."Qty. per Unit of Measure";

      IF Item."Costing Method" = Item."Costing Method"::Standard THEN
        EXIT((Item."Standard Cost" * (100 + Item."Indirect Cost %") / 100 + Item."Overhead Rate") *
          AssemblyHeader.Quantity * AssemblyHeader."Qty. per Unit of Measure");

      MaterialCost := ROUND(MaterialCost,LibraryERM.GetAmountRoundingPrecision);
      ResourceCost := ROUND(ResourceCost,LibraryERM.GetAmountRoundingPrecision);
      ResourceOvhd := ROUND(ResourceOvhd,LibraryERM.GetAmountRoundingPrecision);
      AssemblyOvhd := ROUND(AssemblyOvhd,LibraryERM.GetAmountRoundingPrecision);
      ExpectedCost := MaterialCost + ResourceCost + ResourceOvhd + AssemblyOvhd;
      EXIT(ROUND(ExpectedCost,LibraryERM.GetAmountRoundingPrecision));

Example

The below example is extracted from the test automation codeunit 137091 to show one way of using this function.

      AssemblyHeader.GET(AssemblyHeader."Document Type"::Order,AssemblyHeaderNo);
      CostAmount := LibraryAssembly.CalcOrderCostAmount(MaterialCost,ResourceCost,ResourceOvhd,AssemblyOvhd,AssemblyHeaderNo);

      Assert.AreNearlyEqual(
        CostAmount,AssemblyHeader."Cost Amount",LibraryERM.GetAmountRoundingPrecision,'Wrong header cost amount.');
      Assert.AreNearlyEqual(CostAmount,
        ROUND(AssemblyHeader.Quantity * AssemblyHeader."Unit Cost",LibraryERM.GetAmountRoundingPrecision),
        LibraryERM.GetAmountRoundingPrecision,'Wrong header unit cost.');
Member of Lib.Library - Assembly


ChangeResourceUsage@64 Method

The procedure ChangeResourceUsage is available in codeunit 132207.

Syntax

ChangeResourceUsage@64(
    AssemblyHeaderNo@1005 : Code[20] AssemblyHeaderNo //Input parameter of type Code
);

Parameters

AssemblyHeaderNo
Input parameter of type Code

Remarks

The relevant search keywords are: Change, Resource, Usage.

For a clarification about how this function works, refer to the code listed below.

      AssemblyLine.SETCURRENTKEY("Document Type","Document No.",Type);
      AssemblyLine.SETRANGE("Document Type",AssemblyLine."Document Type"::Order);
      AssemblyLine.SETRANGE("Document No.",AssemblyHeaderNo);
      AssemblyLine.SETRANGE(Type,AssemblyLine.Type::Resource);
      AssemblyLine.NEXT(RANDOM(AssemblyLine.COUNT));

      IF AssemblyLine."Resource Usage Type" = AssemblyLine."Resource Usage Type"::Fixed THEN
        AssemblyLine.VALIDATE("Resource Usage Type",AssemblyLine."Resource Usage Type"::Direct)
      ELSE
        AssemblyLine.VALIDATE("Resource Usage Type",AssemblyLine."Resource Usage Type"::Fixed)

Example

There are no examples available.
Member of Lib.Library - Assembly


CheckOrderDimensions@72 Method

The procedure CheckOrderDimensions is available in codeunit 132207.

Syntax

CheckOrderDimensions@72(
    AssemblyHeader@1000 : Record 900 AssemblyHeader, //Input parameter of type Record
    DimensionsFrom@1001 : Option DimensionsFrom //Input parameter of type Option
);

Parameters

AssemblyHeader
Input parameter of type Record
DimensionsFrom
Input parameter of type Option

Remarks

The relevant search keywords are: Check, Order, Dimensions.

For a clarification about how this function works, refer to the code listed below.

      VerifyEntityDimensions(
        DATABASE::Item,AssemblyHeader."Item No.",AssemblyHeader."Item No.",TRUE,AssemblyHeader."Dimension Set ID");

      AssemblyLine.SETRANGE("Document Type",AssemblyHeader."Document Type");
      AssemblyLine.SETRANGE("Document No.",AssemblyHeader."No.");
      IF AssemblyLine.FINDSET THEN
        REPEAT
          CASE AssemblyLine.Type OF
            AssemblyLine.Type::Item:
              TableID := DATABASE::Item;
            AssemblyLine.Type::Resource:
              TableID := DATABASE::Resource;
            AssemblyLine.Type::" ":
              BEGIN
                TableID := 0;
                AssemblyLine.TESTFIELD("Dimension Set ID",0);
              END;
          END;
          VerifyEntityDimensions(
            TableID,AssemblyLine."No.",AssemblyHeader."Item No.",
            DimensionsFrom = AssemblySetup."Copy Component Dimensions from"::"Order Header",
            AssemblyLine."Dimension Set ID");
        UNTIL AssemblyLine.NEXT = 0;

Example

The below example is extracted from the test automation codeunit 137092 to show one way of using this function.

      // Setup.
      Initialize;
      LibraryAssembly.UpdateAssemblySetup(AssemblySetup,'',DimensionsFrom,LibraryUtility.GetGlobalNoSeriesCode);
      LibraryAssembly.SetupAssemblyData(AssemblyHeader,WorkDate2,Item."Costing Method"::Standard,Item."Costing Method"::Average,
        Item."Replenishment System"::Assembly,'',TRUE);
      LibraryAssembly.AddCompInventory(AssemblyHeader,WorkDate2,0);

      // Exercise.
      LibraryAssembly.CheckOrderDimensions(AssemblyHeader,DimensionsFrom);
      IF OverrideDimensions THEN
        LibraryAssembly.EditOrderDimensions(AssemblyHeader);
      ExpectedError := LibraryAssembly.BlockOrderDimensions(AssemblyHeader,HeaderBlockType,CompBlockType);

      IF ExpectedError = '' THEN
        ExpectedError := AddAOItemDimension(AssemblyHeader,DefaultHeaderValuePosting,DefaultCompValuePosting);

      SetShortcutDimensions(AssemblyHeader,1);
      SetShortcutDimensions(AssemblyHeader,2);

      LibraryAssembly.PrepareOrderPosting(AssemblyHeader,TempAssemblyLine,100,100,TRUE,WorkDate2);
      LibraryAssembly.PostAssemblyHeader(AssemblyHeader,ExpectedError);

      // Verify.
      IF ExpectedError = '' THEN BEGIN
        LibraryAssembly.VerifyPostedAssemblyHeader(TempAssemblyLine,AssemblyHeader,AssemblyHeader.Quantity);
        LibraryAssembly.VerifyPostedComments(AssemblyHeader);
        LibraryAssembly.VerifyILEs(TempAssemblyLine,AssemblyHeader,AssemblyHeader."Quantity to Assemble");
        LibraryAssembly.VerifyValueEntries(TempAssemblyLine,AssemblyHeader,AssemblyHeader."Quantity to Assemble");
        LibraryAssembly.VerifyResEntries(TempAssemblyLine,AssemblyHeader);
        LibraryAssembly.VerifyCapEntries(TempAssemblyLine,AssemblyHeader);
        LibraryAssembly.VerifyItemRegister(AssemblyHeader);
      END;

      // Tear down.
Member of Lib.Library - Assembly


ClearOrderPostingSetup@154 Method

The procedure ClearOrderPostingSetup is available in codeunit 132207.

Syntax

ClearOrderPostingSetup@154(
    OrderClearType@1000 : Option OrderClearType, //Input parameter of type Option
    InvtPostingGroup@1001 : Code[10] InvtPostingGroup, //Input parameter of type Code
    GenProdPostingGroup@1002 : Code[10] GenProdPostingGroup, //Input parameter of type Code
    LocationCode@1003 : Code[10] LocationCode //Input parameter of type Code
);

Parameters

OrderClearType
Input parameter of type Option
InvtPostingGroup
Input parameter of type Code
GenProdPostingGroup
Input parameter of type Code
LocationCode
Input parameter of type Code

Return Value

Text[1024]

Remarks

The relevant search keywords are: Clear, Order, Posting, Setup.

For a clarification about how this function works, refer to the code listed below.

      ExpectedError := '';
      CASE OrderClearType OF
        ClearType::"Posting Group Setup":
          BEGIN
            InventoryPostingSetup.SETRANGE("Invt. Posting Group Code",InvtPostingGroup);
            IF InventoryPostingSetup.FINDFIRST THEN
              InventoryPostingSetup.DELETEALL;
            GeneralPostingSetup.SETRANGE("Gen. Prod. Posting Group",GenProdPostingGroup);
            IF GeneralPostingSetup.FINDFIRST THEN
              GeneralPostingSetup.DELETEALL;
            ExpectedError := ErrorPostingSetup;
          END;
        ClearType::"Location Posting Setup":
          BEGIN
            InventoryPostingSetup.SETRANGE("Location Code",LocationCode);
            InventoryPostingSetup.SETRANGE("Invt. Posting Group Code",InvtPostingGroup);
            IF InventoryPostingSetup.FINDFIRST THEN
              InventoryPostingSetup.DELETEALL;
            ExpectedError := ErrorInvtPostingSetup;
          END;
      END;
      EXIT(ExpectedError);

Example

The below example is extracted from the test automation codeunit 137092 to show one way of using this function.

      // Setup.
      Initialize;
      LibraryWarehouse.CreateLocation(Location);
      LibraryAssembly.UpdateAssemblySetup(AssemblySetup,Location.Code,AssemblySetup."Copy Component Dimensions from"::"Order Header",
        LibraryUtility.GetGlobalNoSeriesCode);
      LibraryAssembly.SetupAssemblyData(AssemblyHeader,WorkDate2,Item."Costing Method"::Standard,Item."Costing Method"::Average,
        Item."Replenishment System"::Assembly,Location.Code,TRUE);
      LibraryAssembly.AddCompInventory(AssemblyHeader,WorkDate2,0);
      ExpectedError :=
        LibraryAssembly.ClearOrderPostingSetup(HeaderClearType,AssemblyHeader."Inventory Posting Group",
          AssemblyHeader."Gen. Prod. Posting Group",AssemblyHeader."Location Code");

      // Exercise.
      LibraryAssembly.PrepareOrderPosting(AssemblyHeader,TempAssemblyLine,100,100,TRUE,WorkDate2);

      // Verify.
      LibraryAssembly.PostAssemblyHeader(AssemblyHeader,ExpectedError);

      // Tear down.
      LibraryAssembly.UpdateAssemblySetup(AssemblySetup,'',AssemblySetup."Copy Component Dimensions from"::"Order Header",
        LibraryUtility.GetGlobalNoSeriesCode);
Member of Lib.Library - Assembly


ComponentsAvailable@184 Method

The procedure ComponentsAvailable is available in codeunit 132207.

Syntax

ComponentsAvailable@184(
    AssemblyHeader@1000 : Record 900 AssemblyHeader //Input parameter of type Record
);

Parameters

AssemblyHeader
Input parameter of type Record

Return Value

Boolean

Remarks

The relevant search keywords are: Components, Available.

For a clarification about how this function works, refer to the code listed below.

      SetLinkToLines(AssemblyHeader,AssemblyLine);
      ItemCheckAvail.AsmOrderCalculate(AssemblyHeader,Inventory,
        GrossRequirement,ReservedRequirement,ScheduledReceipts,ReservedReceipts);
      EarliestAvailableDate(AssemblyHeader,AssemblyLine,QtyAvailToMake,EarliestAvailableDateX);
      EXIT(QtyAvailToMake >= AssemblyHeader."Remaining Quantity");

Example

The below example is extracted from the test automation codeunit 137093 to show one way of using this function.

      EXIT(LibraryAssembly.ComponentsAvailable(AssemblyHeader));
Member of Lib.Library - Assembly


CreateAdjustmentSource@153 Method

The procedure CreateAdjustmentSource is available in codeunit 132207.

Syntax

CreateAdjustmentSource@153(
    AssemblyHeader@1000 : Record 900 AssemblyHeader, //Input parameter of type Record
    PostingDate@1005 : Date PostingDate, //Input parameter of type Date
    AdjustHeader@1001 : Boolean AdjustHeader, //Input parameter of type Boolean
    AdjustmentSource@1002 : Option AdjustmentSource, //Input parameter of type Option
    ItemNo@1011 : Code[20] ItemNo, //Input parameter of type Code
    ResourceNo@1012 : Code[20] ResourceNo //Input parameter of type Code
);

Parameters

AssemblyHeader
Input parameter of type Record
PostingDate
Input parameter of type Date
AdjustHeader
Input parameter of type Boolean
AdjustmentSource
Input parameter of type Option
ItemNo
Input parameter of type Code
ResourceNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Adjustment, Source.

For a clarification about how this function works, refer to the code listed below.

      IF AdjustHeader THEN
        ItemNo := AssemblyHeader."Item No.";
      Item.GET(ItemNo);

      CASE AdjustmentSource OF
        AdjSource::Purchase:
          BEGIN
            LibraryPurchase.CreatePurchHeader(
              PurchaseHeader,PurchaseHeader."Document Type"::Order,'');
            LibraryPurchase.CreatePurchaseLine(
              PurchaseLine,PurchaseHeader,PurchaseLine.Type::Item,ItemNo,LibraryRandom.RandInt(10));
            PurchaseHeader.VALIDATE(
              "Vendor Invoice No.",LibraryUtility.GenerateRandomCode(PurchaseHeader.FIELDNO("Vendor Invoice No."),
                DATABASE::"Purchase Header"));
            PurchaseHeader.MODIFY(TRUE);
            LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);
          END;
        AdjSource::Revaluation:
          BEGIN
            RevaluateItem(Item,ItemJournalLine,Item."Unit Cost",PostingDate);
            LibraryInventory.PostItemJournalLine(ItemJournalLine."Journal Template Name",ItemJournalLine."Journal Batch Name");
          END;
        AdjSource::"Item Card":
          BEGIN
            Item."Unit Cost" := Item."Unit Cost" + LibraryRandom.RandDec(10,2);
            IF Item."Costing Method" = Item."Costing Method"::Standard THEN
              Item."Standard Cost" := Item."Standard Cost" + LibraryRandom.RandDec(10,2);
            Item.MODIFY(TRUE);
          END;
        AdjSource::"Order Lines":
          BEGIN
            ResourceNo := CreateResource(Resource,TRUE,Item."Gen. Prod. Posting Group");
            EditAssemblyLines(ChangeType::Add,AssemblyLine.Type::Resource,AssemblyLine.Type::Resource,ResourceNo,
              AssemblyHeader."No.",TRUE);
          END;
        AdjSource::Resource:
          BEGIN
            Resource.GET(ResourceNo);
            Resource."Unit Cost" := Resource."Unit Cost" + LibraryRandom.RandDec(10,2);
            Resource.MODIFY(TRUE);
          END
      END;

Example

The below example is extracted from the test automation codeunit 137094 to show one way of using this function.

      // Setup.
      Initialize;
      LibraryAssembly.UpdateInventorySetup(InventorySetup,AutCostPosting,FALSE,AutCostAdj,
        InventorySetup."Average Cost Calc. Type"::"Item & Location & Variant",
        InventorySetup."Average Cost Period"::Day);

      // Create Assembly BOM structure.
      LibraryAssembly.SetupAssemblyData(AssemblyHeader,WorkDate2,ParentCostingMethod,CompCostingMethod,
        Item."Replenishment System"::Assembly,'',NOT AdjustHeader);
      ItemFilter := LibraryAssembly.GetCompsToAdjust(ItemNo,ResourceNo,AssemblyHeader);

      // Add inventory for components to allow posting.
      LibraryAssembly.AddCompInventory(AssemblyHeader,WorkDate2,LibraryRandom.RandDec(10,2));

      // Introduce a source of adjustment.
      LibraryAssembly.CreateAdjustmentSource(AssemblyHeader,WorkDate2,AdjustHeader,AdjSource1,ItemNo[1],ResourceNo[1]);
      LibraryAssembly.PrepareOrderPosting(AssemblyHeader,TempAssemblyLine,100,100,TRUE,WorkDate2);

      // Exercise.
      // Post Assembly Order, introduce a second source of adjustment and adjust.
      LibraryAssembly.PostAssemblyHeader(AssemblyHeader,'');
      LibraryAssembly.CreateAdjustmentSource(AssemblyHeader,WorkDate2,AdjustHeader,AdjSource2,ItemNo[1],ResourceNo[1]);
      LibraryCosting.AdjustCostItemEntries(ItemFilter,'');

      // Verify: Posted documents and entries.
      LibraryAssembly.VerifyPostedAssemblyHeader(TempAssemblyLine,AssemblyHeader,AssemblyHeader.Quantity);
      LibraryAssembly.VerifyILEs(TempAssemblyLine,AssemblyHeader,AssemblyHeader."Quantity to Assemble");
      LibraryAssembly.VerifyValueEntries(TempAssemblyLine,AssemblyHeader,AssemblyHeader."Quantity to Assemble");
      LibraryAssembly.VerifyPostedComments(AssemblyHeader);
      LibraryAssembly.VerifyResEntries(TempAssemblyLine,AssemblyHeader);
      LibraryAssembly.VerifyCapEntries(TempAssemblyLine,AssemblyHeader);
      LibraryAssembly.VerifyAdjustmentEntries(AssemblyHeader,AdjSource2);
      LibraryAssembly.VerifyItemRegister(AssemblyHeader);

      // Tear down.
      LibraryAssembly.UpdateInventorySetup(InventorySetup,FALSE,FALSE,InventorySetup."Automatic Cost Adjustment"::Never,
        InventorySetup."Average Cost Calc. Type"::Item,InventorySetup."Average Cost Period"::Day);

      EXIT(AssemblyHeader."No.");
Member of Lib.Library - Assembly


CreateAssemblyHeader@53 Method

The procedure CreateAssemblyHeader is available in codeunit 132207.

Syntax

CreateAssemblyHeader@53(
    VAR AssemblyHeader@1001 : Record 900 AssemblyHeader, //Reference parameter of type Record
    DueDate@1004 : Date DueDate, //Input parameter of type Date
    ParentItemNo@1000 : Code[20] ParentItemNo, //Input parameter of type Code
    LocationCode@1002 : Code[10] LocationCode, //Input parameter of type Code
    Quantity@1003 : Decimal Quantity, //Input parameter of type Decimal
    VariantCode@1005 : Code[10] VariantCode //Input parameter of type Code
);

Parameters

AssemblyHeader
Reference parameter of type Record
DueDate
Input parameter of type Date
ParentItemNo
Input parameter of type Code
LocationCode
Input parameter of type Code
Quantity
Input parameter of type Decimal
VariantCode
Input parameter of type Code

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Assembly, Header.

For a clarification about how this function works, refer to the code listed below.

      EXIT(
        CreateAssemblyHeaderLocal(
          AssemblyHeader,DueDate,ParentItemNo,LocationCode,Quantity,AssemblyHeader."Document Type"::Order,VariantCode));

Example

The below example is extracted from the test automation codeunit 136137 to show one way of using this function.

      // SETUP: Create a new location for 3 items.
      LibraryWarehouse.CreateLocation(Location);

      FOR i := 1 TO 3 DO BEGIN
        LibraryInventory.CreateItem(ParentItem);
        LibraryInventory.CreateItem(Item);

        // SETUP: Create Assembly Order.
        Quantity := LibraryRandom.RandDec(10,2);
        QuantityPer := LibraryRandom.RandDec(10,2);
        LibraryAssembly.CreateAssemblyHeader(AssemblyHeader,WORKDATE,ParentItem."No.",Location.Code,Quantity,'');
        LibraryAssembly.CreateAssemblyLine(AssemblyHeader,AssemblyLine,AssemblyLine.Type::Item,Item."No.",'',Quantity,QuantityPer,'');

        // EXECUTE: Create Stockkeeping Unit.
        CreateStockkeepingUnit(Item."No.",Location.Code);

        // VERIFY: Qty. on Asm. Component field is correct when location contains mutiple different items.
        StockkeepingUnit.SETRANGE("Item No.",Item."No.");
        StockkeepingUnit.FINDFIRST;
        StockkeepingUnit.CALCFIELDS("Qty. on Asm. Component");
        Assert.AreEqual(Quantity * QuantityPer,StockkeepingUnit."Qty. on Asm. Component",QtyOnAsmComponentErr);
      END;
Member of Lib.Library - Assembly


CreateAssemblyLine@43 Method

The procedure CreateAssemblyLine is available in codeunit 132207.

Syntax

CreateAssemblyLine@43(
    AssemblyHeader@1000 : Record 900 AssemblyHeader, //Input parameter of type Record
    VAR AssemblyLine@1008 : Record 901 AssemblyLine, //Reference parameter of type Record
    Type@1001 : Option Type, //Input parameter of type Option
    No@1002 : Code[20] No, //Input parameter of type Code
    UOMCode@1003 : Code[10] UOMCode, //Input parameter of type Code
    Quantity@1004 : Decimal Quantity, //Input parameter of type Decimal
    QtyPer@1005 : Decimal QtyPer, //Input parameter of type Decimal
    Desc@1006 : Text[50] Desc //Input parameter of type Text
);

Parameters

AssemblyHeader
Input parameter of type Record
AssemblyLine
Reference parameter of type Record
Type
Input parameter of type Option
No
Input parameter of type Code
UOMCode
Input parameter of type Code
Quantity
Input parameter of type Decimal
QtyPer
Input parameter of type Decimal
Desc
Input parameter of type Text

Remarks

The relevant search keywords are: Create, Assembly, Line.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(AssemblyLine);
      AssemblyLine."Document Type" := AssemblyHeader."Document Type";
      AssemblyLine."Document No." := AssemblyHeader."No.";
      RecRef.GETTABLE(AssemblyLine);
      AssemblyLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,AssemblyLine.FIELDNO("Line No.")));
      AssemblyLine.INSERT(TRUE);
      AssemblyLine.VALIDATE(Type,Type);
      AssemblyLine.VALIDATE("No.",No);
      IF AssemblyHeader.Quantity <> 0 THEN
        AssemblyLine."Quantity per" := AssemblyLine.CalcQuantityPer(Quantity);
      AssemblyLine.VALIDATE(Quantity,Quantity);
      AssemblyLine.VALIDATE("Unit of Measure Code",UOMCode);
      IF QtyPer <> 0 THEN
        AssemblyLine.VALIDATE("Quantity per",QtyPer);
      AssemblyLine.VALIDATE(Description,Desc);
      AssemblyLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 136137 to show one way of using this function.

      // SETUP: Create a new location for 3 items.
      LibraryWarehouse.CreateLocation(Location);

      FOR i := 1 TO 3 DO BEGIN
        LibraryInventory.CreateItem(ParentItem);
        LibraryInventory.CreateItem(Item);

        // SETUP: Create Assembly Order.
        Quantity := LibraryRandom.RandDec(10,2);
        QuantityPer := LibraryRandom.RandDec(10,2);
        LibraryAssembly.CreateAssemblyHeader(AssemblyHeader,WORKDATE,ParentItem."No.",Location.Code,Quantity,'');
        LibraryAssembly.CreateAssemblyLine(AssemblyHeader,AssemblyLine,AssemblyLine.Type::Item,Item."No.",'',Quantity,QuantityPer,'');

        // EXECUTE: Create Stockkeeping Unit.
        CreateStockkeepingUnit(Item."No.",Location.Code);

        // VERIFY: Qty. on Asm. Component field is correct when location contains mutiple different items.
        StockkeepingUnit.SETRANGE("Item No.",Item."No.");
        StockkeepingUnit.FINDFIRST;
        StockkeepingUnit.CALCFIELDS("Qty. on Asm. Component");
        Assert.AreEqual(Quantity * QuantityPer,StockkeepingUnit."Qty. on Asm. Component",QtyOnAsmComponentErr);
      END;
Member of Lib.Library - Assembly


CreateAssemblyLines@48 Method

The procedure CreateAssemblyLines is available in codeunit 132207.

Syntax

CreateAssemblyLines@48(
    CostingMethod@1009 : Option CostingMethod, //Input parameter of type Option
    AssemblyHeaderNo@1000 : Code[20] AssemblyHeaderNo, //Input parameter of type Code
    NoOfItems@1001 : Integer NoOfItems, //Input parameter of type Integer
    NoOfResources@1002 : Integer NoOfResources //Input parameter of type Integer
);

Parameters

CostingMethod
Input parameter of type Option
AssemblyHeaderNo
Input parameter of type Code
NoOfItems
Input parameter of type Integer
NoOfResources
Input parameter of type Integer

Remarks

The relevant search keywords are: Create, Assembly, Lines.

For a clarification about how this function works, refer to the code listed below.

      SetupComponents(TempItem,TempResource,CostingMethod,NoOfItems,NoOfResources,'','');
      AssemblyHeader.GET(AssemblyHeader."Document Type"::Order,AssemblyHeaderNo);

      IF TempItem.FINDSET THEN
        REPEAT
          CreateAssemblyLine(AssemblyHeader,AssemblyLine,AssemblyLine.Type::Item,TempItem."No.",
            GetUnitOfMeasureCode(AssemblyLine.Type::Item,TempItem."No.",TRUE),LibraryRandom.RandDec(20,2),0,'');
        UNTIL TempItem.NEXT = 0;

      IF TempResource.FINDSET THEN
        REPEAT
          CreateAssemblyLine(AssemblyHeader,AssemblyLine,AssemblyLine.Type::Resource,TempResource."No.",
            GetUnitOfMeasureCode(AssemblyLine.Type::Resource,TempResource."No.",TRUE),LibraryRandom.RandDec(20,2),0,'');
        UNTIL TempResource.NEXT = 0;

Example

The below example is extracted from the test automation codeunit 137091 to show one way of using this function.

      // Setup.
      Initialize;
      LibraryAssembly.CreateItem(Item,Item."Costing Method"::Standard,ReplSystem,'','');
      LibraryAssembly.CreateAssemblyList(Item."Costing Method"::Standard,Item."No.",TRUE,NoOfItems,NoOfResources,NoOfTexts,1,'','');

      // Exercise.
      LibraryAssembly.CreateAssemblyHeader(AssemblyHeader,WorkDate2,Item."No.",'',LibraryRandom.RandDec(10,2),'');
      LibraryAssembly.CreateAssemblyLines(Item."Costing Method"::Standard,AssemblyHeader."No.",NewComps,NewComps);

      // Validate.
      VerifyOrderLines(AssemblyHeader."No.",(NewComps > 0));
      VerifyParentFlowFields(AssemblyHeader);
Member of Lib.Library - Assembly


CreateAssemblyList@21 Method

The procedure CreateAssemblyList is available in codeunit 132207.

Syntax

CreateAssemblyList@21(
    CostingMethod@1009 : Option CostingMethod, //Input parameter of type Option
    ParentItemNo@1000 : Code[20] ParentItemNo, //Input parameter of type Code
    UseBaseUnitOfMeasure@1005 : Boolean UseBaseUnitOfMeasure, //Input parameter of type Boolean
    NoOfItems@1001 : Integer NoOfItems, //Input parameter of type Integer
    NoOfResources@1002 : Integer NoOfResources, //Input parameter of type Integer
    NoOfTexts@1003 : Integer NoOfTexts, //Input parameter of type Integer
    QtyPerFactor@1004 : Integer QtyPerFactor, //Input parameter of type Integer
    GenProdPostingGroup@1007 : Code[10] GenProdPostingGroup, //Input parameter of type Code
    InventoryPostingGroup@1012 : Code[10] InventoryPostingGroup //Input parameter of type Code
);

Parameters

CostingMethod
Input parameter of type Option
ParentItemNo
Input parameter of type Code
UseBaseUnitOfMeasure
Input parameter of type Boolean
NoOfItems
Input parameter of type Integer
NoOfResources
Input parameter of type Integer
NoOfTexts
Input parameter of type Integer
QtyPerFactor
Input parameter of type Integer
GenProdPostingGroup
Input parameter of type Code
InventoryPostingGroup
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Assembly, List.

For a clarification about how this function works, refer to the code listed below.

      SetupComponents(TempItem,TempResource,CostingMethod,NoOfItems,NoOfResources,GenProdPostingGroup,InventoryPostingGroup);

      IF TempItem.FINDSET THEN
        REPEAT
          CreateAssemblyListComponent(BOMComponent.Type::Item,TempItem."No.",ParentItemNo,'',
            BOMComponent."Resource Usage Type"::Direct,QtyPerFactor * LibraryRandom.RandDec(20,5),UseBaseUnitOfMeasure);
        UNTIL TempItem.NEXT = 0;

      CompCount := 1;
      IF TempResource.FINDSET THEN
        REPEAT
          IF CompCount MOD 2 = 0 THEN
            CreateAssemblyListComponent(BOMComponent.Type::Resource,TempResource."No.",ParentItemNo,'',
              BOMComponent."Resource Usage Type"::Direct,QtyPerFactor * LibraryRandom.RandDec(20,5),UseBaseUnitOfMeasure)
          ELSE
            CreateAssemblyListComponent(BOMComponent.Type::Resource,TempResource."No.",ParentItemNo,'',
              BOMComponent."Resource Usage Type"::Fixed,QtyPerFactor * LibraryRandom.RandDec(20,5),UseBaseUnitOfMeasure);
          CompCount += 1;
        UNTIL TempResource.NEXT = 0;

      FOR CompCount := 1 TO NoOfTexts DO
        CreateAssemblyListComponent(BOMComponent.Type::" ",'',ParentItemNo,'',
          BOMComponent."Resource Usage Type"::Direct,0,UseBaseUnitOfMeasure);

      COMMIT;

Example

The below example is extracted from the test automation codeunit 137089 to show one way of using this function.

      LibraryAssembly.CreateAssemblyList(
        Item."Costing Method"::Standard,ParentItem."No.",TRUE,1,0,0,1,SelectGenProdPostingGroupCode,InventoryPostingGroupCode);

      BOMCompItem.SETRANGE("Parent Item No.",ParentItem."No.");
      BOMCompItem.FINDFIRST;
      Item.GET(BOMCompItem."No.");

      Item.VALIDATE("Replenishment System",ReplenishmentSystem);
      Item.VALIDATE("Reordering Policy",Item."Reordering Policy"::"Lot-for-Lot");
      EVALUATE(Item."Rescheduling Period",'<1M>');
      Item.MODIFY(TRUE);

      // Make sure that the Quantity per is always >= 1
      BOMCompItem.VALIDATE("Quantity per",BOMCompItem."Quantity per" + 1);
      BOMCompItem.MODIFY(TRUE);

      QtyPer := BOMCompItem."Quantity per";
Member of Lib.Library - Assembly


CreateAssemblyListComponent@12 Method

The procedure CreateAssemblyListComponent is available in codeunit 132207.

Syntax

CreateAssemblyListComponent@12(
    ComponentType@1000 : Option ComponentType, //Input parameter of type Option
    ComponentNo@1001 : Code[20] ComponentNo, //Input parameter of type Code
    ParentItemNo@1005 : Code[20] ParentItemNo, //Input parameter of type Code
    VariantCode@1007 : Code[10] VariantCode, //Input parameter of type Code
    ResourceUsage@1006 : Option ResourceUsage, //Input parameter of type Option
    Qty@1002 : Decimal Qty, //Input parameter of type Decimal
    UseBaseUnitOfMeasure@1003 : Boolean UseBaseUnitOfMeasure //Input parameter of type Boolean
);

Parameters

ComponentType
Input parameter of type Option
ComponentNo
Input parameter of type Code
ParentItemNo
Input parameter of type Code
VariantCode
Input parameter of type Code
ResourceUsage
Input parameter of type Option
Qty
Input parameter of type Decimal
UseBaseUnitOfMeasure
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, Assembly, List, Component.

For a clarification about how this function works, refer to the code listed below.

      LibraryManufacturing.CreateBOMComponent(BOMComponent,ParentItemNo,ComponentType,ComponentNo,Qty,
        GetUnitOfMeasureCode(ComponentType,ComponentNo,UseBaseUnitOfMeasure));
      IF ComponentType = BOMComponent.Type::Resource THEN
        BOMComponent.VALIDATE("Resource Usage Type",ResourceUsage);
      BOMComponent.VALIDATE("Variant Code",VariantCode);
      BOMComponent.VALIDATE(
        Description,LibraryUtility.GenerateRandomCode(BOMComponent.FIELDNO(Description),DATABASE::"BOM Component"));
      BOMComponent.MODIFY(TRUE);
      COMMIT;

Example

The below example is extracted from the test automation codeunit 134900 to show one way of using this function.

      CreateAssemblyItemWithAssemblyPolicy(AssemblyItem,AssemblyPolicy);
      LibraryAssembly.CreateItem(
        ComponentItem,ComponentItem."Costing Method"::Standard,ComponentItem."Replenishment System"::Purchase,'','');
      LibraryAssembly.CreateAssemblyListComponent(
        BOMComponent.Type::Item,ComponentItem."No.",AssemblyItem."No.",'',BOMComponent."Resource Usage Type",Quantity,TRUE);
Member of Lib.Library - Assembly


CreateAssemblyOrder@19 Method

The procedure CreateAssemblyOrder is available in codeunit 132207.

Syntax

CreateAssemblyOrder@19(
    VAR AssemblyHeader@1001 : Record 900 AssemblyHeader, //Reference parameter of type Record
    DueDate@1004 : Date DueDate, //Input parameter of type Date
    LocationCode@1008 : Code[10] LocationCode, //Input parameter of type Code
    NoOfItems@1003 : Integer NoOfItems //Input parameter of type Integer
);

Parameters

AssemblyHeader
Reference parameter of type Record
DueDate
Input parameter of type Date
LocationCode
Input parameter of type Code
NoOfItems
Input parameter of type Integer

Remarks

The relevant search keywords are: Create, Assembly, Order.

For a clarification about how this function works, refer to the code listed below.

      SetupAssemblyItem(
        Item,Item."Costing Method"::Standard,Item."Costing Method"::Standard,Item."Replenishment System"::Assembly,LocationCode,FALSE,
        NoOfItems,
        LibraryRandom.RandIntInRange(1,3),
        LibraryRandom.RandIntInRange(1,3),
        LibraryRandom.RandIntInRange(1,10));

      CreateAssemblyHeader(AssemblyHeader,DueDate,Item."No.",LocationCode,LibraryRandom.RandDec(10,2),'');

Example

The below example is extracted from the test automation codeunit 137104 to show one way of using this function.

      // Test posting on not allowed date
      Initialize;

      LibraryTimeSheet.CreateUserSetup(UserSetup,TRUE);
      UserSetup.VALIDATE("Allow Posting From",CALCDATE('<-11M>',WORKDATE));
      UserSetup.VALIDATE("Allow Posting To",CALCDATE('<11M>',WORKDATE));
      UserSetup.MODIFY(TRUE);

      AssignBinCodesBM;

      NoOfItems := LibraryRandom.RandIntInRange(1,3);
      LibraryAssembly.CreateAssemblyOrder(AssemblyHeader,WorkDate2,LocationBM.Code,NoOfItems);

      LibraryAssembly.AddCompInventoryToBin(AssemblyHeader,WorkDate2,0,AssemblyHeader."Location Code",LocationToBinCode);

      LibraryAssembly.PrepareOrderPosting(AssemblyHeader,TempAssemblyLine,100,100,TRUE,WorkDate2);

      AssemblyHeader.VALIDATE("Posting Date",CALCDATE('<-11M-1D>',WORKDATE));

      LibraryAssembly.PostAssemblyHeader(AssemblyHeader,MSG_POSTING_DATE_NOTALLOWED);

      UserSetup.DELETE;
Member of Lib.Library - Assembly


CreateAssemblyQuote@51 Method

The procedure CreateAssemblyQuote is available in codeunit 132207.

Syntax

CreateAssemblyQuote@51(
    VAR AssemblyHeader@1001 : Record 900 AssemblyHeader, //Reference parameter of type Record
    DueDate@1004 : Date DueDate, //Input parameter of type Date
    ParentItemNo@1000 : Code[20] ParentItemNo, //Input parameter of type Code
    LocationCode@1002 : Code[10] LocationCode, //Input parameter of type Code
    Quantity@1003 : Decimal Quantity, //Input parameter of type Decimal
    VariantCode@1005 : Code[10] VariantCode //Input parameter of type Code
);

Parameters

AssemblyHeader
Reference parameter of type Record
DueDate
Input parameter of type Date
ParentItemNo
Input parameter of type Code
LocationCode
Input parameter of type Code
Quantity
Input parameter of type Decimal
VariantCode
Input parameter of type Code

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Assembly, Quote.

For a clarification about how this function works, refer to the code listed below.

      EXIT(
        CreateAssemblyHeaderLocal(
          AssemblyHeader,DueDate,ParentItemNo,LocationCode,Quantity,AssemblyHeader."Document Type"::Quote,VariantCode));

Example

There are no examples available.
Member of Lib.Library - Assembly


CreateAssemblySetup@127 Method

The procedure CreateAssemblySetup is available in codeunit 132207.

Syntax

CreateAssemblySetup@127(
    VAR AssemblySetup@1002 : Record 905 AssemblySetup, //Reference parameter of type Record
    LocationCode@1000 : Code[10] LocationCode, //Input parameter of type Code
    DimensionsFrom@1003 : Option DimensionsFrom, //Input parameter of type Option
    PostedOrdersNo@1004 : Code[10] PostedOrdersNo //Input parameter of type Code
);

Parameters

AssemblySetup
Reference parameter of type Record
LocationCode
Input parameter of type Code
DimensionsFrom
Input parameter of type Option
PostedOrdersNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Assembly, Setup.

For a clarification about how this function works, refer to the code listed below.

      IF AssemblySetup."Assembly Order Nos." = '' THEN
        AssemblySetup.VALIDATE("Assembly Order Nos.",
          LibraryUtility.GetGlobalNoSeriesCode);
      IF AssemblySetup."Posted Assembly Order Nos." = '' THEN
        AssemblySetup.VALIDATE("Posted Assembly Order Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      IF AssemblySetup."Assembly Quote Nos." = '' THEN
        AssemblySetup.VALIDATE("Assembly Quote Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      IF AssemblySetup."Blanket Assembly Order Nos." = '' THEN
        AssemblySetup.VALIDATE("Blanket Assembly Order Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      AssemblySetup.VALIDATE("Default Location for Orders",LocationCode);
      AssemblySetup.VALIDATE("Copy Component Dimensions from",DimensionsFrom);
      AssemblySetup.VALIDATE("Posted Assembly Order Nos.",PostedOrdersNo);
      AssemblySetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137089 to show one way of using this function.

      LibraryAssembly.CreateAssemblySetup(AssemblySetup,'',0,LibraryUtility.GetGlobalNoSeriesCode);
Member of Lib.Library - Assembly


CreateBOM@115 Method

The procedure CreateBOM is available in codeunit 132207.

Syntax

CreateBOM@115(
    VAR Item@1000 : Record 27 Item, //Reference parameter of type Record
    NoOfComps@1001 : Integer NoOfComps //Input parameter of type Integer
);

Parameters

Item
Reference parameter of type Record
NoOfComps
Input parameter of type Integer

Remarks

The relevant search keywords are: Create, BOM.

For a clarification about how this function works, refer to the code listed below.

      LibraryManufacturing.CreateProductionBOMHeader(ProductionBOMHeader,Item."Base Unit of Measure");

      FOR count := 1 TO NoOfComps DO BEGIN
        CreateItem(Item1,Item."Costing Method"::Standard,Item."Replenishment System"::Purchase,'','');
        LibraryManufacturing.CreateProductionBOMLine(
          ProductionBOMHeader,ProductionBOMLine,'',ProductionBOMLine.Type::Item,Item1."No.",1);
      END;

      ProductionBOMHeader.VALIDATE(Status,ProductionBOMHeader.Status::Certified);
      ProductionBOMHeader.MODIFY(TRUE);
      Item.VALIDATE("Production BOM No.",ProductionBOMHeader."No.");
      Item.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137111 to show one way of using this function.

      // Setup.
      Initialize;
      FOR count := 1 TO ProdItems DO BEGIN
        LibraryAssembly.CreateItem(Item,Item."Costing Method"::Standard,Item."Replenishment System"::"Prod. Order",'','');
        LibraryAssembly.CreateBOM(Item,1);
        CreateProdOrders(Item."No.",ProductionOrder.Status::Simulated,Simulated);
        CreateProdOrders(Item."No.",ProductionOrder.Status::Planned,Planned);
        CreateProdOrders(Item."No.",ProductionOrder.Status::"Firm Planned",FirmPlanned);
        CreateProdOrders(Item."No.",ProductionOrder.Status::Released,Released);
        TempItem := Item;
        TempItem.INSERT;
      END;

      // Verify query: Query - database consistency.
      DelayedProdOrdersByCost.OPEN;
      count := 0;
      WHILE DelayedProdOrdersByCost.READ DO BEGIN
        count += 1;
        GetExpectedProdOrderBacklog(
          Qty,CostAmount,TotalCostAmount,'<=',FALSE,DelayedProdOrdersByCost.Status,DelayedProdOrdersByCost.Item_No);
        IF count > 1 THEN
          Assert.IsTrue(
            PrevTotalCostAmount >= TotalCostAmount,
            'Query is not sorted by ' + DelayedProdOrdersByCost.COLUMNCAPTION(Cost_of_Open_Production_Orders));
        Assert.AreEqual(Qty,DelayedProdOrdersByCost.Sum_Remaining_Quantity,'Item: ' + DelayedProdOrdersByCost.Item_No + '; field: ' + DelayedProdOrdersByCost.COLUMNCAPTION(Sum_Remaining_Quantity));
        Assert.AreEqual(
          TotalCostAmount,DelayedProdOrdersByCost.Cost_of_Open_Production_Orders,'Item: ' + DelayedProdOrdersByCost.Item_No + '; field: ' + DelayedProdOrdersByCost.COLUMNCAPTION(Cost_of_Open_Production_Orders));
        Assert.AreNotEqual(
          ProductionOrder.Status::Simulated,DelayedProdOrdersByCost.Status,'Item: ' + DelayedProdOrdersByCost.Item_No + '; field: ' + DelayedProdOrdersByCost.COLUMNCAPTION(Status));
        Assert.AreNotEqual(
          ProductionOrder.Status::Finished,DelayedProdOrdersByCost.Status,'Item: ' + DelayedProdOrdersByCost.Item_No + '; field: ' + DelayedProdOrdersByCost.COLUMNCAPTION(Status));
        PrevTotalCostAmount := TotalCostAmount;
      END;
      DelayedProdOrdersByCost.CLOSE;

      // Verify query: Database - query consistency.
      TempItem.FINDSET;
      REPEAT
        VerifyDelayedBacklogRecords(TempItem."No.",ProductionOrder.Status::Planned);
        VerifyDelayedBacklogRecords(TempItem."No.",ProductionOrder.Status::"Firm Planned");
        VerifyDelayedBacklogRecords(TempItem."No.",ProductionOrder.Status::Released);
      UNTIL TempItem.NEXT = 0;
Member of Lib.Library - Assembly


CreateDimensionSetup@165 Method

The procedure CreateDimensionSetup is available in codeunit 132207.

Syntax

CreateDimensionSetup@165(
    VAR TempDimension@1000 : TEMPORARY Record 348 TempDimension, //Reference Temporary parameter of type Record
    VAR TempDimensionValue@1005 : TEMPORARY Record 349 TempDimensionValue //Reference Temporary parameter of type Record
);

Parameters

TempDimension
Reference Temporary parameter of type Record
TempDimensionValue
Reference Temporary parameter of type Record

Remarks

The relevant search keywords are: Create, Dimension, Setup.

For a clarification about how this function works, refer to the code listed below.

      FOR Count := 1 TO 2 DO BEGIN
        LibraryDimension.CreateDimension(Dimension);
        DimensionCode[Count] := Dimension.Code;
        TempDimension := Dimension;
        TempDimension.INSERT;
        LibraryDimension.CreateDimensionValue(DimensionValue,Dimension.Code);
        TempDimensionValue := DimensionValue;
        TempDimensionValue.INSERT;
      END;
      LibraryDimension.CreateDimensionCombination(DimensionCombination,DimensionCode[1],DimensionCode[2]);

Example

There are no examples available.
Member of Lib.Library - Assembly


CreateGLAccount@176 Method

The procedure CreateGLAccount is available in codeunit 132207.

Syntax

CreateGLAccount@176(
    VAR GLAccount@1002 : Record 15 GLAccount, //Reference parameter of type Record
    IncomeBalance@1001 : Option IncomeBalance, //Input parameter of type Option
    Name@1000 : Text[30] Name //Input parameter of type Text
);

Parameters

GLAccount
Reference parameter of type Record
IncomeBalance
Input parameter of type Option
Name
Input parameter of type Text

Remarks

The relevant search keywords are: Create, General Ledger, Account.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.CreateGLAccount(GLAccount);
      GLAccount.VALIDATE("Income/Balance",IncomeBalance);
      GLAccount.VALIDATE("Debit/Credit",GLAccount."Debit/Credit"::Both);
      GLAccount.VALIDATE("Account Type",GLAccount."Account Type"::Posting);
      GLAccount.VALIDATE(Name,Name);
      GLAccount.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134152 to show one way of using this function.

      // Check General Ledger Entries after posting a General Journal Line with Account type as Customer.

      // Setup: Create G/L Account, Customer and post an General Journal Line for Customer with IC Partner Code, used blank for IC Partner G/L Account No. and 1 for sign factor.
      Initialize;
      SelectGeneralJournalBatch(GenJournalBatch);
      LibraryERM.CreateGLAccount(GLAccount);
      CustomerNo := CreateICCustomer(CreateICPartner);

      CreateGeneralJournalLine(
        GenJournalLine,GenJournalBatch,GenJournalLine."Account Type"::Customer,CustomerNo,
        GenJournalLine."Bal. Account Type"::"G/L Account",GLAccount."No.",'',1);
      CustomerPostingGroup.GET(GenJournalLine."Posting Group");

      // Exercise: Post IC Journal Line.
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // Verify: Verify GL Entry.
      VerifyGLEntry(
        GenJournalLine."Document No.",GenJournalLine."IC Partner Code",GenJournalLine."Bal. Account No.",-GenJournalLine.Amount);
      VerifyGLEntry(
        GenJournalLine."Document No.",GenJournalLine."IC Partner Code",CustomerPostingGroup."Receivables Account",
        GenJournalLine.Amount);
Member of Lib.Library - Assembly


CreateInvtMovement@28 Method

The procedure CreateInvtMovement is available in codeunit 132207.

Syntax

CreateInvtMovement@28(
    AssemblyHeaderNo@1000 : Code[20] AssemblyHeaderNo, //Input parameter of type Code
    NewCreateInvtPutAway@1001 : Boolean NewCreateInvtPutAway, //Input parameter of type Boolean
    NewCreateInvtPick@1002 : Boolean NewCreateInvtPick, //Input parameter of type Boolean
    NewCreateInvtMovement@1003 : Boolean NewCreateInvtMovement //Input parameter of type Boolean
);

Parameters

AssemblyHeaderNo
Input parameter of type Code
NewCreateInvtPutAway
Input parameter of type Boolean
NewCreateInvtPick
Input parameter of type Boolean
NewCreateInvtMovement
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, Invt, Movement.

For a clarification about how this function works, refer to the code listed below.

      WarehouseRequest.SETCURRENTKEY("Source Document","Source No.");
      WarehouseRequest.SETRANGE("Source Document",WarehouseRequest."Source Document"::"Assembly Consumption");
      WarehouseRequest.SETRANGE("Source No.",AssemblyHeaderNo);

      COMMIT;
      CreateInvtPutAwayPick.InitializeRequest(
        NewCreateInvtPutAway,NewCreateInvtPick,NewCreateInvtMovement,FALSE,FALSE);
      IF WarehouseRequest.HASFILTER THEN
        TmpWarehouseRequest.COPYFILTERS(WarehouseRequest)
      ELSE BEGIN
        WarehouseRequest.GET(WarehouseRequest.Type,
          WarehouseRequest."Location Code",
          WarehouseRequest."Source Type",
          WarehouseRequest."Source Subtype",
          WarehouseRequest."Source No.");
        TmpWarehouseRequest.SETRANGE(Type,WarehouseRequest.Type);
        TmpWarehouseRequest.SETRANGE("Location Code",WarehouseRequest."Location Code");
        TmpWarehouseRequest.SETRANGE("Source Type",WarehouseRequest."Source Type");
        TmpWarehouseRequest.SETRANGE("Source Subtype",WarehouseRequest."Source Subtype");
        TmpWarehouseRequest.SETRANGE("Source No.",WarehouseRequest."Source No.");
      END;
      CreateInvtPutAwayPick.SETTABLEVIEW(TmpWarehouseRequest);
      CreateInvtPutAwayPick.USEREQUESTPAGE(FALSE);
      CreateInvtPutAwayPick.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 137104 to show one way of using this function.

      IF WhseActivity = WhseActivityType::None THEN
        EXIT;

      AssemblyHeader.SETRANGE("No.",AssemblyHeaderNo);
      AssemblyHeader.FINDFIRST;

      CASE WhseActivity OF
        WhseActivityType::WhsePick:
          LibraryAssembly.CreateWhsePick(AssemblyHeader,USERID,0,FALSE,FALSE,FALSE);
        WhseActivityType::InvtMvmt:
          LibraryAssembly.CreateInvtMovement(AssemblyHeader."No.",FALSE,FALSE,TRUE);
      END;

      AutoFillQtyWhseActivity(AssemblyHeader,WhseActivityHeader);

      IF AssignITOnWhseAct THEN
        AssignITWhseActivity(AssemblyHeader,WhseActivityHeader,ITPartial,FindDirection);

      IF ExpectedError = '' THEN
        LibraryWarehouse.RegisterWhseActivity(WhseActivityHeader)
      ELSE BEGIN
        ASSERTERROR LibraryWarehouse.RegisterWhseActivity(WhseActivityHeader);
        Assert.IsTrue(STRPOS(GETLASTERRORTEXT,ExpectedError) > 0,
          'Expected:' + ExpectedError + '. Actual:' + GETLASTERRORTEXT);
        CLEARLASTERROR;
      END;
Member of Lib.Library - Assembly


CreateInvtPostingSetup@142 Method

The procedure CreateInvtPostingSetup is available in codeunit 132207.

Syntax

CreateInvtPostingSetup@142(
    VAR InventoryPostingSetup@1000 : Record 5813 InventoryPostingSetup, //Reference parameter of type Record
    LocationCode@1001 : Code[10] LocationCode, //Input parameter of type Code
    InvtPostingGroupCode@1002 : Code[10] InvtPostingGroupCode, //Input parameter of type Code
    InvtAccount@1003 : Code[20] InvtAccount, //Input parameter of type Code
    MatVarAccount@1004 : Code[20] MatVarAccount, //Input parameter of type Code
    CapVarAcc@1005 : Code[20] CapVarAcc, //Input parameter of type Code
    CapOvhdVarAcc@1006 : Code[20] CapOvhdVarAcc, //Input parameter of type Code
    MfgOvhdVarAcc@1007 : Code[20] MfgOvhdVarAcc, //Input parameter of type Code
    InvtAccInterim@1250 : Code[20] InvtAccInterim //Input parameter of type Code
);

Parameters

InventoryPostingSetup
Reference parameter of type Record
LocationCode
Input parameter of type Code
InvtPostingGroupCode
Input parameter of type Code
InvtAccount
Input parameter of type Code
MatVarAccount
Input parameter of type Code
CapVarAcc
Input parameter of type Code
CapOvhdVarAcc
Input parameter of type Code
MfgOvhdVarAcc
Input parameter of type Code
InvtAccInterim
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Invt, Posting, Setup.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(InventoryPostingSetup);
      InventoryPostingSetup.INIT;
      InventoryPostingSetup.VALIDATE("Location Code",LocationCode);
      InventoryPostingSetup.VALIDATE("Invt. Posting Group Code",InvtPostingGroupCode);
      InventoryPostingSetup.VALIDATE("Inventory Account",InvtAccount);
      InventoryPostingSetup.VALIDATE("Material Variance Account",MatVarAccount);
      InventoryPostingSetup.VALIDATE("Capacity Variance Account",CapVarAcc);
      InventoryPostingSetup.VALIDATE("Cap. Overhead Variance Account",CapOvhdVarAcc);
      InventoryPostingSetup.VALIDATE("Mfg. Overhead Variance Account",MfgOvhdVarAcc);
      InventoryPostingSetup.VALIDATE("Inventory Account (Interim)",InvtAccInterim);
      LibraryERM.CreateGLAccount(GLAccount);
      InventoryPostingSetup.VALIDATE("WIP Account",GLAccount."No.");
      InventoryPostingSetup.INSERT(TRUE);

Example

There are no examples available.
Member of Lib.Library - Assembly


CreateItem@22 Method

The procedure CreateItem is available in codeunit 132207.

Syntax

CreateItem@22(
    VAR Item@1000 : Record 27 Item, //Reference parameter of type Record
    CostingMethod@1002 : Option CostingMethod, //Input parameter of type Option
    ReplenishmentMethod@1004 : Option ReplenishmentMethod, //Input parameter of type Option
    GenProdPostingGroup@1006 : Code[10] GenProdPostingGroup, //Input parameter of type Code
    InventoryPostingGroup@1007 : Code[10] InventoryPostingGroup //Input parameter of type Code
);

Parameters

Item
Reference parameter of type Record
CostingMethod
Input parameter of type Option
ReplenishmentMethod
Input parameter of type Option
GenProdPostingGroup
Input parameter of type Code
InventoryPostingGroup
Input parameter of type Code

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Item.

For a clarification about how this function works, refer to the code listed below.

      LibraryInventory.CreateItem(Item);
      Item.VALIDATE("Replenishment System",ReplenishmentMethod);
      Item.VALIDATE("Costing Method",CostingMethod);

      IF ReplenishmentMethod <> Item."Replenishment System"::Assembly THEN BEGIN
        IF CostingMethod = Item."Costing Method"::Standard THEN
          Item.VALIDATE("Standard Cost",LibraryRandom.RandDec(25,2))
        ELSE
          Item.VALIDATE("Unit Cost",LibraryRandom.RandDec(25,2));
        Item.VALIDATE("Unit Price",Item."Unit Cost" + LibraryRandom.RandDec(25,2));
      END ELSE BEGIN
        Item.VALIDATE("Standard Cost",0);
        Item.VALIDATE("Unit Cost",0);
        Item.VALIDATE("Unit Price",0);
      END;

      Item.VALIDATE("Last Direct Cost",Item."Unit Cost");
      IF InventoryPostingGroup <> '' THEN
        Item.VALIDATE("Inventory Posting Group",InventoryPostingGroup);
      IF GenProdPostingGroup = '' THEN BEGIN
        LibraryERM.FindGeneralPostingSetupInvtToGL(GeneralPostingSetup);
        GenProdPostingGroup := GeneralPostingSetup."Gen. Prod. Posting Group";
      END;
      Item.VALIDATE("Gen. Prod. Posting Group",GenProdPostingGroup);
      CLEAR(VATPostingSetup);
      LibraryERM.FindVATPostingSetup(VATPostingSetup,VATPostingSetup."VAT Calculation Type"::"Normal VAT");
      Item.VALIDATE("VAT Prod. Posting Group",VATPostingSetup."VAT Prod. Posting Group");
      Item.MODIFY(TRUE);

      UnitOfMeasure.SETFILTER(Code,'<>%1',Item."Base Unit of Measure");
      UnitOfMeasure.FINDFIRST;
      LibraryInventory.CreateItemUnitOfMeasure(
        ItemUnitOfMeasure,Item."No.",UnitOfMeasure.Code,LibraryRandom.RandInt(10));
      EXIT(Item."No.");

Example

The below example is extracted from the test automation codeunit 134152 to show one way of using this function.

      // Check Sales Line existence in IC Outbox Transaction after renaming IC Partner Code.

      // Setup: Create Item, IC Customer, create and post Sales Order for Customer with random Quantity.
      Initialize;
      ICPartnerCode := CreateICPartner;
      ItemNo := LibraryInventory.CreateItem(Item);  // Assigning value to global variable.
      LibraryVariableStorage.Enqueue(ItemNo);
      LibrarySales.CreateSalesHeader(SalesHeader,SalesHeader."Document Type"::Order,CreateICCustomer(ICPartnerCode));
      LibrarySales.CreateSalesLine(SalesLine,SalesHeader,SalesLine.Type::Item,ItemNo,LibraryRandom.RandInt(10));
      LibraryVariableStorage.Enqueue(SalesLine.Quantity);
      LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      // Exercise: Rename IC Partner using Random Integer value.
      LibraryVariableStorage.Enqueue(RenameICPartner(ICPartnerCode));

      // Verify: Verify Sales Line in IC Outbox Transactions. Verification done in Page Handler.
      FindICOutboxTransaction(
        ICOutboxTransaction,SalesHeader."No.",ICOutboxTransaction."Document Type"::Order,
        ICOutboxTransaction."Source Type"::"Sales Document");
      ICOutboxTransaction.ShowDetails;
Member of Lib.Library - Assembly


CreateItemSubstitution@140 Method

The procedure CreateItemSubstitution is available in codeunit 132207.

Syntax

CreateItemSubstitution@140(
    VAR ItemSubstitution@1001 : Record 5715 ItemSubstitution, //Reference parameter of type Record
    ItemNo@1000 : Code[20] ItemNo //Input parameter of type Code
);

Parameters

ItemSubstitution
Reference parameter of type Record
ItemNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Item, Substitution.

For a clarification about how this function works, refer to the code listed below.

      CreateItem(Item1,Item1."Costing Method"::Standard,Item1."Replenishment System"::Purchase,'','');
      CLEAR(ItemSubstitution);
      ItemSubstitution.INIT;
      ItemSubstitution.VALIDATE(Type,ItemSubstitution.Type::Item);
      ItemSubstitution.VALIDATE("No.",ItemNo);
      ItemSubstitution.VALIDATE("Substitute Type",ItemSubstitution."Substitute Type"::Item);
      ItemSubstitution.VALIDATE("Substitute No.",Item1."No.");
      ItemSubstitution.INSERT;

Example

The below example is extracted from the test automation codeunit 137091 to show one way of using this function.

      // Setup.
      Initialize;
      StdCostLevel := 1;
      LibraryAssembly.SetupAssemblyData(AssemblyHeader,WorkDate2,Item."Costing Method"::Standard,Item."Costing Method"::Standard,
        Item."Replenishment System"::Assembly,'',FALSE);
      BOMComponent.SETRANGE("Parent Item No.",AssemblyHeader."Item No.");
      BOMComponent.SETRANGE(Type,BOMComponent.Type::Item);
      BOMComponent.FINDFIRST;
      LibraryAssembly.CreateItemSubstitution(ItemSubstitution,BOMComponent."No.");

      // Exercise.
      AssemblyLine.SETCURRENTKEY("Document Type","Document No.",Type);
      AssemblyLine.SETRANGE("Document Type",AssemblyHeader."Document Type");
      AssemblyLine.SETRANGE("Document No.",AssemblyHeader."No.");
      AssemblyLine.SETRANGE(Type,AssemblyLine.Type::Item);
      AssemblyLine.SETRANGE("No.",BOMComponent."No.");

      IF AssemblyLine.FINDFIRST THEN
        AssemblyLine.ShowItemSub;

      // Validate.
      VerifyOrderLines(AssemblyHeader."No.",TRUE);
      Assert.AreEqual(AssemblyLine."No.",ItemSubstitution."Substitute No.",'Wrong substitution selected.');
Member of Lib.Library - Assembly


CreateItemWithSKU@208 Method

The procedure CreateItemWithSKU is available in codeunit 132207.

Syntax

CreateItemWithSKU@208(
    VAR Item@1008 : Record 27 Item, //Reference parameter of type Record
    CostingMethod@1003 : Option CostingMethod, //Input parameter of type Option
    ReplenishmentSystem@1004 : Option ReplenishmentSystem, //Input parameter of type Option
    CreatePer@1007 : Option CreatePer, //Input parameter of type Option
    GenProdPostingGr@1005 : Code[10] GenProdPostingGr, //Input parameter of type Code
    InvtPostingGr@1001 : Code[10] InvtPostingGr, //Input parameter of type Code
    LocationCode@1000 : Code[10] LocationCode //Input parameter of type Code
);

Parameters

Item
Reference parameter of type Record
CostingMethod
Input parameter of type Option
ReplenishmentSystem
Input parameter of type Option
CreatePer
Input parameter of type Option
GenProdPostingGr
Input parameter of type Code
InvtPostingGr
Input parameter of type Code
LocationCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Item, SKU.

For a clarification about how this function works, refer to the code listed below.

      CreateItem(Item,CostingMethod,ReplenishmentSystem,GenProdPostingGr,InvtPostingGr);
      IF CreatePer <> CreatePer::Location THEN
        LibraryInventory.CreateVariant(ItemVariant,Item);
      Item."Location Filter" := LocationCode;
      Item.MODIFY;
      Item.SETRANGE("Location Filter",LocationCode);
      Item.SETRECFILTER;
      LibraryInventory.CreateStockKeepingUnit(Item,CreatePer,FALSE,TRUE);
      UpdateSKUCards(Item);

Example

The below example is extracted from the test automation codeunit 137094 to show one way of using this function.

      // Setup.
      Initialize;
      LocationCode := '';
      LibraryAssembly.UpdateInventorySetup(InventorySetup,FALSE,FALSE,InventorySetup."Automatic Cost Adjustment"::Never,
        InventorySetup."Average Cost Calc. Type"::"Item & Location & Variant",InventorySetup."Average Cost Period"::Day);

      // Prepare setup for creating SKU per Location.
      IF CreatePer <> CreatePer::Variant THEN BEGIN
        LibraryWarehouse.CreateLocation(Location);
        LibraryAssembly.UpdateAssemblySetup(AssemblySetup,
          Location.Code,AssemblySetup."Copy Component Dimensions from"::"Order Header",LibraryUtility.GetGlobalNoSeriesCode);
        LocationCode := Location.Code;
      END;

      // Create Assembly BOM structure. Add inventory to allow posting.
      LibraryAssembly.SetupPostingToGL(GenProdPostingGr,AsmInvtPostingGr,CompInvtPostingGr,LocationCode);
      BlankLocation.INIT;
      LibraryInventory.UpdateInventoryPostingSetup(BlankLocation);
      LibraryAssembly.CreateItemWithSKU(
        Item,ParentCostingMethod,Item."Replenishment System"::Assembly,CreatePer,GenProdPostingGr,AsmInvtPostingGr,LocationCode);
      LibraryAssembly.CreateItemWithSKU(
        Item1,CompCostingMethod,Item."Replenishment System"::Purchase,CreatePer,GenProdPostingGr,CompInvtPostingGr,LocationCode);
      LibraryAssembly.CreateAssemblyListComponent(
        BOMComponent.Type::Item,Item1."No.",Item."No.",LibraryInventory.GetVariant(Item1."No.",''),
        BOMComponent."Resource Usage Type"::Direct,LibraryRandom.RandDec(20,5),TRUE);
      LibraryAssembly.CreateAssemblyHeader(AssemblyHeader,WorkDate2,Item."No.",'',LibraryRandom.RandDec(10,2),'');
      LibraryAssembly.AddCompInventory(AssemblyHeader,WorkDate2,0);

      // Verify: SKU cost is loaded correctly on the Assembly Order.
      LibraryAssembly.VerifySKUCost(TempAssemblyLine,AssemblyHeader);

      // Exercise. Post Assembly Order and adjust.
      LibraryAssembly.PrepareOrderPosting(AssemblyHeader,TempAssemblyLine,100,100,TRUE,WorkDate2);
      LibraryAssembly.PostAssemblyHeader(AssemblyHeader,'');
      LibraryCosting.AdjustCostItemEntries(Item."No." + '|' + Item1."No.",'');

      // Verify.
      LibraryAssembly.VerifyPostedAssemblyHeader(TempAssemblyLine,AssemblyHeader,AssemblyHeader.Quantity);
      LibraryAssembly.VerifyILEs(TempAssemblyLine,AssemblyHeader,AssemblyHeader."Quantity to Assemble");
      LibraryAssembly.VerifyValueEntries(TempAssemblyLine,AssemblyHeader,AssemblyHeader."Quantity to Assemble");
      LibraryAssembly.VerifyAdjustmentEntries(AssemblyHeader,AdjSource::None);
      LibraryAssembly.VerifyPostedComments(AssemblyHeader);

      // Tear down.
      LibraryAssembly.UpdateAssemblySetup(AssemblySetup,'',AssemblySetup."Copy Component Dimensions from"::"Order Header",
        LibraryUtility.GetGlobalNoSeriesCode);
      LibraryAssembly.UpdateInventorySetup(InventorySetup,FALSE,FALSE,InventorySetup."Automatic Cost Adjustment"::Never,
        InventorySetup."Average Cost Calc. Type"::Item,InventorySetup."Average Cost Period"::Day);
Member of Lib.Library - Assembly


CreateMultipleLvlTree@85 Method

The procedure CreateMultipleLvlTree is available in codeunit 132207.

Syntax

CreateMultipleLvlTree@85(
    VAR Item@1001 : Record 27 Item, //Reference parameter of type Record
    VAR Item1@1002 : Record 27 Item1, //Reference parameter of type Record
    ReplenishmentMethod@1006 : Option ReplenishmentMethod, //Input parameter of type Option
    CostingMethod@1005 : Option CostingMethod, //Input parameter of type Option
    TreeDepth@1000 : Integer TreeDepth, //Input parameter of type Integer
    NoOfComps@1007 : Integer NoOfComps //Input parameter of type Integer
);

Parameters

Item
Reference parameter of type Record
Item1
Reference parameter of type Record
ReplenishmentMethod
Input parameter of type Option
CostingMethod
Input parameter of type Option
TreeDepth
Input parameter of type Integer
NoOfComps
Input parameter of type Integer

Remarks

The relevant search keywords are: Create, Multiple, Lvl, Tree.

For a clarification about how this function works, refer to the code listed below.

      CreateItem(Item,CostingMethod,ReplenishmentMethod,'','');
      IF ReplenishmentMethod = Item."Replenishment System"::"Prod. Order" THEN
        CreateBOM(Item,NoOfComps)
      ELSE
        CreateAssemblyList(Item."Costing Method"::Standard,Item."No.",TRUE,NoOfComps,NoOfComps,NoOfComps,1,'','');

      CreateItem(Item1,Item."Costing Method"::Standard,Item."Replenishment System"::Assembly,'','');
      CreateAssemblyList(Item."Costing Method"::Standard,Item1."No.",TRUE,2,1,0,1,'','');
      CreateAssemblyListComponent(
        BOMComponent.Type::Item,Item."No.",Item1."No.",'',BOMComponent."Resource Usage Type"::Direct,
        LibraryRandom.RandDec(20,2),TRUE);

      FOR Depth := 2 TO TreeDepth DO BEGIN
        CreateItem(Item2,Item."Costing Method"::Standard,Item."Replenishment System"::Assembly,'','');
        CreateAssemblyList(Item."Costing Method"::Standard,Item2."No.",TRUE,2,1,0,1,'','');
        CreateAssemblyListComponent(BOMComponent.Type::Item,Item1."No.",Item2."No.",'',BOMComponent."Resource Usage Type"::Direct,
          LibraryRandom.RandDec(20,2),TRUE);
        Item := Item1;
        Item1 := Item2;
        Item.FIND;
        Item.VALIDATE("Replenishment System",ReplenishmentMethod);
        Item.MODIFY(TRUE);
        IF ReplenishmentMethod = Item."Replenishment System"::"Prod. Order" THEN
          CreateBOM(Item,NoOfComps);
      END;
      COMMIT;

Example

The below example is extracted from the test automation codeunit 137090 to show one way of using this function.

      // Setup.
      Initialize;
      LibraryAssembly.CreateMultipleLvlTree(Item,Item1,Item."Replenishment System"::Assembly,
        Item."Costing Method"::Standard,TreeDepth,NoOfComps);
      LibraryAssembly.EditAssemblyList(ChangeType,ComponentType,ComponentType,'',Item."No.");

      // Exercise.
      Item1.GET(Item1."No.");
      Item.GET(Item."No.");
      InitialCost := Item."Standard Cost";
      InitialPrice := Item."Unit Price";
      StdCostLevel := CalcLevel;
      CalculateStandardCost.CalcItem(Item1."No.",TRUE);
      CalculateStandardCost.CalcAssemblyItemPrice(Item1."No.");

      // Validate.
      Item1.GET(Item1."No.");
      Item.GET(Item."No.");
      Item.CALCFIELDS("Assembly BOM");
      Assert.AreNearlyEqual(LibraryAssembly.CalcExpectedStandardCost(MaterialCost,CapacityCost,CapOverhead,Item1."No."),
        Item1."Standard Cost",LibraryERM.GetAmountRoundingPrecision,'Wrong std. cost for:' + Item1."No.");
      Assert.AreNearlyEqual(MaterialCost,Item1."Single-Level Material Cost",LibraryERM.GetUnitAmountRoundingPrecision,'Material Cost');
      Assert.AreNearlyEqual(CapacityCost,Item1."Single-Level Capacity Cost",LibraryERM.GetUnitAmountRoundingPrecision,'Capacity Cost');
      Assert.AreNearlyEqual(CapOverhead,Item1."Rolled-up Cap. Overhead Cost",LibraryERM.GetUnitAmountRoundingPrecision,
        'Rolled up Cap Overhead');
      Assert.AreNearlyEqual(
        LibraryAssembly.CalcExpectedPrice(Item1."No."),Item1."Unit Price",
        LibraryERM.GetUnitAmountRoundingPrecision,'Wrong unit price for:' + Item1."No.");
      Assert.AreEqual(NoOfComps > 0,Item."Assembly BOM",'Wrong Assembly BOM flag.');

      IF CalcLevel = 1 THEN BEGIN
        Assert.AreEqual(InitialCost,Item."Standard Cost",Item."No.");
        Assert.AreEqual(InitialPrice,Item."Unit Price",'Wrong unit price for:' + Item."No.");
      END
      ELSE BEGIN
        Assert.AreNearlyEqual(LibraryAssembly.CalcExpectedStandardCost(MaterialCost,CapacityCost,CapOverhead,Item."No."),
          Item."Standard Cost",LibraryERM.GetAmountRoundingPrecision,'Wrong std. cost for:' + Item."No.");
        Assert.AreNearlyEqual(
          MaterialCost,Item."Single-Level Material Cost",LibraryERM.GetUnitAmountRoundingPrecision,'Material Cost');
        Assert.AreNearlyEqual(
          CapacityCost,Item."Single-Level Capacity Cost",LibraryERM.GetUnitAmountRoundingPrecision,'Capacity Cost');
        Assert.AreNearlyEqual(
          CapOverhead,Item."Single-Level Cap. Ovhd Cost",LibraryERM.GetUnitAmountRoundingPrecision,'Cap. Overhead');
        Assert.AreNearlyEqual(CapOverhead,Item."Rolled-up Cap. Overhead Cost",LibraryERM.GetUnitAmountRoundingPrecision,
          'Rolled up Cap Overhead');
        Assert.AreNearlyEqual(
          LibraryAssembly.CalcExpectedPrice(Item."No."),
          Item."Unit Price",LibraryERM.GetUnitAmountRoundingPrecision,'Wrong unit price for:' + Item."No.");
      END;
Member of Lib.Library - Assembly


CreateResource@3 Method

The procedure CreateResource is available in codeunit 132207.

Syntax

CreateResource@3(
    VAR Resource@1000 : Record 156 Resource, //Reference parameter of type Record
    UseRelatedUnitOfMeasure@1002 : Boolean UseRelatedUnitOfMeasure, //Input parameter of type Boolean
    GenProdPostingGroup@1005 : Code[10] GenProdPostingGroup //Input parameter of type Code
);

Parameters

Resource
Reference parameter of type Record
UseRelatedUnitOfMeasure
Input parameter of type Boolean
GenProdPostingGroup
Input parameter of type Code

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Resource.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.FindVATPostingSetup(VATPostingSetup,VATPostingSetup."VAT Calculation Type"::"Normal VAT");
      LibraryResource.CreateResource(Resource,VATPostingSetup."VAT Bus. Posting Group");
      UnitOfMeasure.SETFILTER(Code,'<>%1',Resource."Base Unit of Measure");
      UnitOfMeasure.FINDFIRST;

      // Add a second non-base unit of measure.
      CLEAR(ResourceUnitOfMeasure);
      ResourceUnitOfMeasure.INIT;
      ResourceUnitOfMeasure.VALIDATE("Resource No.",Resource."No.");
      ResourceUnitOfMeasure.VALIDATE(Code,UnitOfMeasure.Code);
      ResourceUnitOfMeasure.INSERT(TRUE);
      ResourceUnitOfMeasure.VALIDATE("Qty. per Unit of Measure",RANDOM(10));
      ResourceUnitOfMeasure.VALIDATE("Related to Base Unit of Meas.",UseRelatedUnitOfMeasure);
      ResourceUnitOfMeasure.MODIFY(TRUE);

      IF GenProdPostingGroup = '' THEN BEGIN
        LibraryERM.FindGeneralPostingSetupInvtToGL(GeneralPostingSetup);
        GenProdPostingGroup := GeneralPostingSetup."Gen. Prod. Posting Group";
      END;
      Resource.VALIDATE("Gen. Prod. Posting Group",GenProdPostingGroup);
      Resource.MODIFY(TRUE);

      EXIT(Resource."No.")

Example

The below example is extracted from the test automation codeunit 137090 to show one way of using this function.

      // Setup.
      Initialize;
      LibraryAssembly.CreateItem(Item,Item."Costing Method"::Standard,Item."Replenishment System"::Assembly,'','');
      LibraryAssembly.CreateAssemblyList(Item."Costing Method"::Standard,Item."No.",TRUE,2,2,1,1,'','');

      IF NewComponentType = BOMComponent.Type::Item THEN
        NewComponentNo := LibraryAssembly.CreateItem(Item1,Item."Costing Method"::Standard,Item."Replenishment System"::Purchase,'','')
      ELSE
        NewComponentNo := LibraryAssembly.CreateResource(Resource1,TRUE,'');
      LibraryAssembly.EditAssemblyList(ChangeType,ComponentType,NewComponentType,NewComponentNo,Item."No.");

      // Exercise.
      StdCostLevel := 1;
      CalculateStandardCost.CalcItem(Item."No.",TRUE);
      CalculateStandardCost.CalcAssemblyItemPrice(Item."No.");

      // Validate.
      Item.GET(Item."No.");
      Assert.AreNearlyEqual(LibraryAssembly.CalcExpectedStandardCost(MaterialCost,CapacityCost,CapOverhead,Item."No."),
        Item."Standard Cost",LibraryERM.GetAmountRoundingPrecision,'Wrong std. cost for:' + Item."No.");
      Assert.AreNearlyEqual(MaterialCost,Item."Single-Level Material Cost",LibraryERM.GetUnitAmountRoundingPrecision,'Material Cost');
      Assert.AreNearlyEqual(CapacityCost,Item."Single-Level Capacity Cost",LibraryERM.GetUnitAmountRoundingPrecision,'Capacity Cost');
      Assert.AreNearlyEqual(CapOverhead,Item."Single-Level Cap. Ovhd Cost",LibraryERM.GetUnitAmountRoundingPrecision,'Cap. Overhead');
      Assert.AreNearlyEqual(CapOverhead,Item."Rolled-up Cap. Overhead Cost",LibraryERM.GetUnitAmountRoundingPrecision,
        'Rolled up Cap Overhead');
      Assert.AreNearlyEqual(
        LibraryAssembly.CalcExpectedPrice(Item."No."),Item."Unit Price",LibraryERM.GetUnitAmountRoundingPrecision,
        'Wrong unit price for:' + Item."No.");
Member of Lib.Library - Assembly


CreateRouting@189 Method

The procedure CreateRouting is available in codeunit 132207.

Syntax

CreateRouting@189(
    VAR Item@1000 : Record 27 Item, //Reference parameter of type Record
    NoOfLines@1005 : Integer NoOfLines //Input parameter of type Integer
);

Parameters

Item
Reference parameter of type Record
NoOfLines
Input parameter of type Integer

Remarks

The relevant search keywords are: Create, Routing.

For a clarification about how this function works, refer to the code listed below.

      LibraryManufacturing.CreateRoutingHeader(RoutingHeader,RoutingHeader.Type::Serial);
      LibraryManufacturing.CreateWorkCenter(WorkCenter);

      FOR count := 1 TO NoOfLines DO
        IF count MOD 2 = 0 THEN BEGIN
          RoutingLine.VALIDATE(Type,RoutingLine.Type::"Work Center");
          LibraryManufacturing.CreateRoutingLineSetup(RoutingLine,RoutingHeader,WorkCenter."No.",
            COPYSTR(
              LibraryUtility.GenerateRandomCode(RoutingLine.FIELDNO("Operation No."),DATABASE::"Routing Line"),1,
              LibraryUtility.GetFieldLength(DATABASE::"Routing Line",RoutingLine.FIELDNO("Operation No."))),
            LibraryRandom.RandDec(10,2),LibraryRandom.RandDec(10,2));
        END ELSE BEGIN
          LibraryManufacturing.CreateMachineCenter(MachineCenter,WorkCenter."No.",LibraryRandom.RandInt(5));
          RoutingLine.VALIDATE(Type,RoutingLine.Type::"Machine Center");
          LibraryManufacturing.CreateRoutingLineSetup(RoutingLine,RoutingHeader,MachineCenter."No.",
            COPYSTR(
              LibraryUtility.GenerateRandomCode(RoutingLine.FIELDNO("Operation No."),DATABASE::"Routing Line"),1,
              LibraryUtility.GetFieldLength(DATABASE::"Routing Line",RoutingLine.FIELDNO("Operation No."))),
            LibraryRandom.RandDec(10,2),LibraryRandom.RandDec(10,2));
        END;

      RoutingHeader.VALIDATE(Status,RoutingHeader.Status::Certified);
      RoutingHeader.MODIFY(TRUE);
      Item.VALIDATE("Routing No.",RoutingHeader."No.");
      Item.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - Assembly


CreateWhsePick@30 Method

The procedure CreateWhsePick is available in codeunit 132207.

Syntax

CreateWhsePick@30(
    AssemblyHeader@1000 : Record 900 AssemblyHeader, //Input parameter of type Record
    AssignedUserID@1001 : Code[50] AssignedUserID, //Input parameter of type Code
    SortingMethod@1002 : Option SortingMethod, //Input parameter of type Option
    SetBreakBulkFilter@1003 : Boolean SetBreakBulkFilter, //Input parameter of type Boolean
    DoNotFillQtyToHandle@1004 : Boolean DoNotFillQtyToHandle, //Input parameter of type Boolean
    PrintDocument@1005 : Boolean PrintDocument //Input parameter of type Boolean
);

Parameters

AssemblyHeader
Input parameter of type Record
AssignedUserID
Input parameter of type Code
SortingMethod
Input parameter of type Option
SetBreakBulkFilter
Input parameter of type Boolean
DoNotFillQtyToHandle
Input parameter of type Boolean
PrintDocument
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, Warehouse, Pick.

For a clarification about how this function works, refer to the code listed below.

      AssemblyHeader.CreatePick(FALSE,AssignedUserID,SortingMethod,SetBreakBulkFilter,DoNotFillQtyToHandle,PrintDocument);

Example

The below example is extracted from the test automation codeunit 137097 to show one way of using this function.

      // Release and create whse pick
      LibraryAssembly.ReleaseAO(AssemblyHeader);
      LibraryAssembly.CreateWhsePick(AssemblyHeader,USERID,0,FALSE,FALSE,FALSE);

      // Find the whse pick
      FindWhseActivityLine(WarehouseActivityLine,AssemblyHeader);

      WarehouseActivityHeader.GET(WarehouseActivityLine."Activity Type",WarehouseActivityLine."No.");

      // Register pick
      LibraryWarehouse.RegisterWhseActivity(WarehouseActivityHeader);
Member of Lib.Library - Assembly


DeleteAssemblyLine@10 Method

The procedure DeleteAssemblyLine is available in codeunit 132207.

Syntax

DeleteAssemblyLine@10(
    ComponentType@1000 : Option ComponentType, //Input parameter of type Option
    AssemblyHeaderNo@1005 : Code[20] AssemblyHeaderNo //Input parameter of type Code
);

Parameters

ComponentType
Input parameter of type Option
AssemblyHeaderNo
Input parameter of type Code

Remarks

The relevant search keywords are: Delete, Assembly, Line.

For a clarification about how this function works, refer to the code listed below.

      AssemblyLine.SETCURRENTKEY("Document Type","Document No.",Type);
      AssemblyLine.SETRANGE("Document Type",AssemblyLine."Document Type"::Order);
      AssemblyLine.SETRANGE("Document No.",AssemblyHeaderNo);
      AssemblyLine.SETRANGE(Type,ComponentType);
      IF NOT AssemblyLine.FINDSET THEN
        EXIT;
      AssemblyLine.NEXT(RANDOM(AssemblyLine.COUNT));
      AssemblyLine.DELETE;

Example

The below example is extracted from the test automation codeunit 137097 to show one way of using this function.

      // Get bins
      BinIndex := 1;
      IF LocationCode <> '' THEN BEGIN
        Location.GET(LocationCode);
        LibraryWarehouse.FindBin(HeaderBin,LocationCode,'',BinIndex + 2);
        LibraryWarehouse.FindBin(ComponentsBin,LocationCode,'',BinIndex);
      END;

      LibraryWarehouse.FindBin(BinSilver1,LocationSilver.Code,'',BinIndex + 2);
      LibraryWarehouse.FindBin(BinSilver2,LocationSilver.Code,'',BinIndex + 1);

      // Create AO item
      LibraryInventory.CreateItem(NewItem);
      CreateAssembledItem(Item,Item."Assembly Policy"::"Assemble-to-Stock",LibraryRandom.RandInt(10),
        LibraryRandom.RandInt(10),LibraryRandom.RandInt(10),LibraryRandom.RandDec(1000,2));
      OrderQty := LibraryRandom.RandDec(1000,2) + 1;
      DueDate := CALCDATE('<+' + FORMAT(LibraryRandom.RandInt(30)) + 'D>',WorkDate2);

      // Create AO and add enough inventory for comp
      IF (LocationCode <> '') AND Location."Bin Mandatory" THEN BEGIN
        CreateAssemblyOrder(AssemblyHeader,Item,LocationCode,HeaderBin.Code,'',DueDate,OrderQty);
        SetLocAndBinCodeOnAsmLines(AssemblyHeader,ComponentsBin);
        LibraryAssembly.AddCompInventoryToBin(AssemblyHeader,WORKDATE,0,LocationCode,ComponentsBin.Code);
      END ELSE BEGIN
        CreateAssemblyOrder(AssemblyHeader,Item,LocationCode,'','',DueDate,OrderQty);
        LibraryAssembly.AddCompInventoryToBin(AssemblyHeader,WORKDATE,0,LocationCode,'');
      END;

      // Post partial
      PostAssemblyOrderQty(AssemblyHeader,OrderQty / 2);
      FindPostedAssemblyHeaderNotReversed(PostedAssemblyHeader,AssemblyHeader."No.");
      LibraryAssembly.ReopenAO(AssemblyHeader);

      // Change the initial AO
      CASE ChangeOption OF
        ChangeOption::"New Line":
          LibraryAssembly.CreateAssemblyLine(
            AssemblyHeader,AssemblyLine,AssemblyLine.Type::Item,NewItem."No.",NewItem."Base Unit of Measure",
            LibraryRandom.RandDec(1000,2),0,NewItem.Description);
        ChangeOption::"Delete Line":
          LibraryAssembly.DeleteAssemblyLine(AssemblyLine.Type::Item,AssemblyHeader."No.");
        ChangeOption::"Change Location Lines": // Assumes current function is called with Location <> Location Silver as param
          SetLocAndBinCodeOnAsmLines(AssemblyHeader,BinSilver1);
        ChangeOption::"Change Bin Lines": // Assumes current function is called with Location Silver as param
          SetLocAndBinCodeOnAsmLines(AssemblyHeader,BinSilver1);
        ChangeOption::"Change Location": // Assumes current function is called with Location <> Location Silver as param
          BEGIN
            AssemblyHeader.VALIDATE("Location Code",LocationSilver.Code);
            AssemblyHeader.MODIFY(TRUE);
          END;
        ChangeOption::"Change Bin": // Assumes current function is called with Location Silver as param
          BEGIN
            AssemblyHeader.VALIDATE("Bin Code",BinSilver2.Code);
            AssemblyHeader.MODIFY(TRUE);
          END;
      END;

      // Undo - error
      IF ChangeOption IN [ChangeOption::"New Line",ChangeOption::"Delete Line"] THEN
        LibraryAssembly.UndoPostedAssembly(PostedAssemblyHeader,TRUE,MSG_CANNOT_RESTORE_2)
      ELSE
        LibraryAssembly.UndoPostedAssembly(PostedAssemblyHeader,TRUE,MSG_CANNOT_RESTORE);
Member of Lib.Library - Assembly


DeleteAssemblyLines@9 Method

The procedure DeleteAssemblyLines is available in codeunit 132207.

Syntax

DeleteAssemblyLines@9(
    AssemblyHeaderNo@1005 : Code[20] AssemblyHeaderNo //Input parameter of type Code
);

Parameters

AssemblyHeaderNo
Input parameter of type Code

Remarks

The relevant search keywords are: Delete, Assembly, Lines.

For a clarification about how this function works, refer to the code listed below.

      AssemblyLine.SETRANGE("Document No.",AssemblyHeaderNo);
      AssemblyLine.DELETEALL;

Example

There are no examples available.
Member of Lib.Library - Assembly


DeleteAssemblyList@44 Method

The procedure DeleteAssemblyList is available in codeunit 132207.

Syntax

DeleteAssemblyList@44(
    ParentItemNo@1005 : Code[20] ParentItemNo //Input parameter of type Code
);

Parameters

ParentItemNo
Input parameter of type Code

Remarks

The relevant search keywords are: Delete, Assembly, List.

For a clarification about how this function works, refer to the code listed below.

      BOMComponent.SETRANGE("Parent Item No.",ParentItemNo);
      BOMComponent.DELETEALL;

Example

The below example is extracted from the test automation codeunit 137090 to show one way of using this function.

      // Setup.
      Initialize;
      LibraryAssembly.CreateItem(Item,Item."Costing Method"::Standard,Item."Replenishment System"::Assembly,'','');
      LibraryAssembly.CreateAssemblyList(Item."Costing Method"::Standard,Item."No.",TRUE,2,2,1,1,'','');
      LibraryAssembly.DeleteAssemblyList(Item."No.");

      // Exercise.
      ASSERTERROR CalculateStandardCost.CalcItem(Item."No.",TRUE);

      // Validate.
      Assert.AreEqual(
        STRSUBSTNO(ErrorNoAssemblyList,Item."No.",Item.Description,'Standard Cost'),ConvertMessage(GETLASTERRORTEXT),GETLASTERRORTEXT);
      CLEARLASTERROR;
Member of Lib.Library - Assembly


DeleteAssemblyListComponent@26 Method

The procedure DeleteAssemblyListComponent is available in codeunit 132207.

Syntax

DeleteAssemblyListComponent@26(
    ComponentType@1000 : Option ComponentType, //Input parameter of type Option
    ParentItemNo@1005 : Code[20] ParentItemNo //Input parameter of type Code
);

Parameters

ComponentType
Input parameter of type Option
ParentItemNo
Input parameter of type Code

Remarks

The relevant search keywords are: Delete, Assembly, List, Component.

For a clarification about how this function works, refer to the code listed below.

      BOMComponent.SETRANGE("Parent Item No.",ParentItemNo);
      BOMComponent.SETRANGE(Type,ComponentType);
      IF NOT BOMComponent.FINDSET THEN
        EXIT;
      BOMComponent.NEXT(RANDOM(BOMComponent.COUNT));
      BOMComponent.DELETE;

Example

There are no examples available.
Member of Lib.Library - Assembly


EarliestAvailableDate@183 Method

The procedure EarliestAvailableDate is available in codeunit 132207.

Syntax

EarliestAvailableDate@183(
    AsmHeader@1000 : Record 900 AsmHeader, //Input parameter of type Record
    VAR AssemblyLine@1001 : Record 901 AssemblyLine, //Reference parameter of type Record
    VAR ReturnQtyAvailable@1002 : Decimal ReturnQtyAvailable, //Reference parameter of type Decimal
    VAR EarliestDueDate@1003 : Date EarliestDueDate //Reference parameter of type Date
);

Parameters

AsmHeader
Input parameter of type Record
AssemblyLine
Reference parameter of type Record
ReturnQtyAvailable
Reference parameter of type Decimal
EarliestDueDate
Reference parameter of type Date

Remarks

The relevant search keywords are: Earliest, Available, Date.

For a clarification about how this function works, refer to the code listed below.

      SetLinkToLines(AsmHeader,AssemblyLine);
      AssemblyLine.SETRANGE(Type,AssemblyLine.Type::Item);
      AssemblyLine.SETFILTER("No.",'<>%1','');
      AssemblyLine.SETFILTER("Quantity per",'<>%1',0);
      Proportion := AsmHeader."Remaining Quantity";
      IF AssemblyLine.FINDFIRST THEN
        REPEAT
          AssemblyLine.CalcAvailToAssemble(
            AsmHeader,
            Item,
            GrossRequirement,
            ScheduledRcpt,
            ExpectedInventory,
            LineInventory,
            LineAvailabilityDate,
            LineAbleToAssemble);

          LineProportion := LineAbleToAssemble;
          IF LineProportion < Proportion THEN
            Proportion := LineProportion;
          IF LineAvailabilityDate > 0D THEN BEGIN
            LineStartingDate := CALCDATE(AssemblyLine."Lead-Time Offset",LineAvailabilityDate);
            IF LineStartingDate > EarliestStartingDate THEN
              EarliestStartingDate := LineStartingDate; // latest of all line starting dates
          END;
        UNTIL AssemblyLine.NEXT = 0;

      ReturnQtyAvailable := Proportion;
      WITH AsmHeader DO BEGIN
        EarliestDueDate := 0D;
        IF EarliestStartingDate > 0D THEN BEGIN
          EarliestEndingDate := // earliest starting date + lead time calculation
            LeadTimeMgt.PlannedEndingDate2("Item No.","Location Code","Variant Code",
              '',LeadTimeMgt.ManufacturingLeadTime("Item No.","Location Code","Variant Code"),
              ReqLine."Ref. Order Type"::Assembly,EarliestStartingDate);
          EarliestDueDate := // earliest ending date + (default) safety lead time
            LeadTimeMgt.PlannedDueDate("Item No.","Location Code","Variant Code",
              EarliestEndingDate,'',ReqLine."Ref. Order Type"::Assembly);
        END;
      END;

Example

The below example is extracted from the test automation codeunit 137104 to show one way of using this function.

      // TC-BINPOST
      // There is enough item in inventory, but there is not enough item in ToBin.
      // Test checks that partial posting works fine after reducing Qty To Assemble to smallest avaliable
      Initialize;
      AssignBinCodesBM;

      NoOfItems := LibraryRandom.RandIntInRange(1,3);
      LibraryAssembly.CreateAssemblyOrder(AssemblyHeader,WorkDate2,LocationBM.Code,NoOfItems);

      NotEnoughNo := LibraryRandom.RandIntInRange(1,NoOfItems) - 1;
      AddCompInventoryNotEnough(AssemblyHeader,NotEnoughNo,NotEnoughItemNo,100,Qtys,FALSE,LocationToBinCode);

      LibraryAssembly.SetLinkToLines(AssemblyHeader,AssemblyLine);
      LibraryAssembly.EarliestAvailableDate(AssemblyHeader,AssemblyLine,AssembledQty,EarliestDate);
      UpdateQtysConsume(AssemblyHeader,TempAssemblyLine,AssembledQty,Qtys);
      AssembledQty := AssemblyHeader."Quantity to Assemble";

      LibraryAssembly.PostAssemblyHeader(AssemblyHeader,'');

      // Verify.
      LibraryAssembly.VerifyILEs(TempAssemblyLine,AssemblyHeader,AssembledQty);
      LibraryAssembly.VerifyItemRegister(AssemblyHeader);

      TempAssemblyLine.RESET;
      TempAssemblyLine.SETRANGE(Type,TempAssemblyLine.Type::Item);
      VerifyWarehouseEntries(
        AssemblyHeader,TempAssemblyLine,AssembledQty,TRUE,TempAssemblyLine.COUNT + 1,AssemblyHeader."Posting Date");

      // Veryfy bin content for header assembly item
      VerifyBinContent(AssemblyHeader."Location Code",AssemblyHeader."Bin Code",AssemblyHeader."Item No.",AssembledQty);

      // Verify bin contents for components
      Assert.AreEqual(NoOfItems,TempAssemblyLine.COUNT,'Too many component item ' + AssemblyHeader."Item No." + ' in a bin content');
      i := 1;
      TempAssemblyLine.FINDSET;
      REPEAT
        VerifyBinContent(TempAssemblyLine."Location Code",TempAssemblyLine."Bin Code",
          TempAssemblyLine."No.",Qtys[i] - TempAssemblyLine."Quantity to Consume");
        i += 1;
      UNTIL TempAssemblyLine.NEXT = 0;
Member of Lib.Library - Assembly


EditAssemblyLine@11 Method

The procedure EditAssemblyLine is available in codeunit 132207.

Syntax

EditAssemblyLine@11(
    ComponentType@1000 : Option ComponentType, //Input parameter of type Option
    NewComponentType@1007 : Option NewComponentType, //Input parameter of type Option
    NewComponentNo@1006 : Code[20] NewComponentNo, //Input parameter of type Code
    AssemblyHeaderNo@1005 : Code[20] AssemblyHeaderNo, //Input parameter of type Code
    Qty@1002 : Decimal Qty, //Input parameter of type Decimal
    UseBaseUnitOfMeasure@1003 : Boolean UseBaseUnitOfMeasure //Input parameter of type Boolean
);

Parameters

ComponentType
Input parameter of type Option
NewComponentType
Input parameter of type Option
NewComponentNo
Input parameter of type Code
AssemblyHeaderNo
Input parameter of type Code
Qty
Input parameter of type Decimal
UseBaseUnitOfMeasure
Input parameter of type Boolean

Remarks

The relevant search keywords are: Edit, Assembly, Line.

For a clarification about how this function works, refer to the code listed below.

      AssemblyLine.SETCURRENTKEY("Document Type","Document No.",Type);
      AssemblyLine.SETRANGE("Document Type",AssemblyLine."Document Type"::Order);
      AssemblyLine.SETRANGE("Document No.",AssemblyHeaderNo);
      AssemblyLine.SETRANGE(Type,ComponentType);
      IF NOT AssemblyLine.FINDSET THEN
        EXIT;
      AssemblyLine.NEXT(RANDOM(AssemblyLine.COUNT));

      IF AssemblyLine.Type = AssemblyLine.Type::Item THEN
        AssemblyLine.VALIDATE("Variant Code",LibraryInventory.GetVariant(AssemblyLine."No.",AssemblyLine."Variant Code"));
      AssemblyLine.VALIDATE(Description,
        LibraryUtility.GenerateRandomCode(AssemblyLine.FIELDNO(Description),DATABASE::"Assembly Line"));
      AssemblyLine.VALIDATE("Quantity per",Qty);

      IF NewComponentNo <> '' THEN BEGIN
        AssemblyLine.VALIDATE(Type,NewComponentType);
        AssemblyLine.VALIDATE("No.",NewComponentNo);
        AssemblyLine.VALIDATE("Unit of Measure Code",GetUnitOfMeasureCode(NewComponentType,NewComponentNo,UseBaseUnitOfMeasure));
      END ELSE
        AssemblyLine.VALIDATE("Unit of Measure Code",
          GetUnitOfMeasureCode(AssemblyLine.Type,AssemblyLine."No.",UseBaseUnitOfMeasure));

      AssemblyLine.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - Assembly


EditAssemblyLines@8 Method

The procedure EditAssemblyLines is available in codeunit 132207.

Syntax

EditAssemblyLines@8(
    ChangeType@1000 : Option ChangeType, //Input parameter of type Option
    ComponentType@1003 : Option ComponentType, //Input parameter of type Option
    NewComponentType@1001 : Option NewComponentType, //Input parameter of type Option
    NewComponentNo@1002 : Code[20] NewComponentNo, //Input parameter of type Code
    AssemblyHeaderNo@1004 : Code[20] AssemblyHeaderNo, //Input parameter of type Code
    UseBaseUnitOfMeasure@1005 : Boolean UseBaseUnitOfMeasure //Input parameter of type Boolean
);

Parameters

ChangeType
Input parameter of type Option
ComponentType
Input parameter of type Option
NewComponentType
Input parameter of type Option
NewComponentNo
Input parameter of type Code
AssemblyHeaderNo
Input parameter of type Code
UseBaseUnitOfMeasure
Input parameter of type Boolean

Remarks

The relevant search keywords are: Edit, Assembly, Lines.

For a clarification about how this function works, refer to the code listed below.

      AssemblyHeader.GET(AssemblyHeader."Document Type"::Order,AssemblyHeaderNo);
      CASE ChangeType OF
        ChangeType::Add:
          CreateAssemblyLine(AssemblyHeader,AssemblyLine,NewComponentType,NewComponentNo,
            GetUnitOfMeasureCode(NewComponentType,NewComponentNo,TRUE),AssemblyHeader.Quantity,1,'');
        ChangeType::Replace:
          EditAssemblyLine(
            ComponentType,NewComponentType,NewComponentNo,AssemblyHeaderNo,LibraryRandom.RandDec(20,2),
            UseBaseUnitOfMeasure);
        ChangeType::Delete:
          DeleteAssemblyLine(ComponentType,AssemblyHeaderNo);
        ChangeType::Edit:
          EditAssemblyLine(
            ComponentType,NewComponentType,'',AssemblyHeaderNo,LibraryRandom.RandDec(20,2),UseBaseUnitOfMeasure);
        ChangeType::"Delete all":
          DeleteAssemblyLines(AssemblyHeaderNo);
        ChangeType::"Edit cards":
          ModifyCostParams(AssemblyHeaderNo,FALSE,0,0);
        ChangeType::Usage:
          ChangeResourceUsage(AssemblyHeaderNo);
      END;
      COMMIT;

Example

The below example is extracted from the test automation codeunit 137091 to show one way of using this function.

      // Setup.
      Initialize;
      StdCostLevel := 1;
      LibraryAssembly.SetupAssemblyData(
        AssemblyHeader,WorkDate2,ParentCostingMethod,CompCostingMethod,Item."Replenishment System"::Assembly,
        '',TRUE);
      SaveInitialAssemblyList(TempBOMComponent,AssemblyHeader."Item No.");

      // Exercise.
      LibraryAssembly.ModifyItem(AssemblyHeader."Item No.",UpdateParent,IndirectCost,Overhead);
      LibraryAssembly.ModifyCostParams(AssemblyHeader."No.",UpdateComp,IndirectCost,Overhead);
      IF UpdateParent THEN BEGIN
        AssemblyHeader.VALIDATE("Indirect Cost %",IndirectCost);
        AssemblyHeader.VALIDATE("Overhead Rate",Overhead);
        AssemblyHeader.MODIFY(TRUE);
      END;

      LibraryAssembly.EditAssemblyLines(
        ChangeType::Edit,AssemblyLine.Type::Item,AssemblyLine.Type::Item,'',AssemblyHeader."No.",TRUE);
      LibraryAssembly.UpdateOrderCost(AssemblyHeader);

      // Validate.
      VerifyOrderHeader(AssemblyHeader."No.");
      VerifyInitialAssemblyList(TempBOMComponent,AssemblyHeader."Item No.");
Member of Lib.Library - Assembly


EditAssemblyList@79 Method

The procedure EditAssemblyList is available in codeunit 132207.

Syntax

EditAssemblyList@79(
    ChangeType@1000 : Option ChangeType, //Input parameter of type Option
    ComponentType@1003 : Option ComponentType, //Input parameter of type Option
    NewComponentType@1001 : Option NewComponentType, //Input parameter of type Option
    NewComponentNo@1002 : Code[20] NewComponentNo, //Input parameter of type Code
    ParentItemNo@1004 : Code[20] ParentItemNo //Input parameter of type Code
);

Parameters

ChangeType
Input parameter of type Option
ComponentType
Input parameter of type Option
NewComponentType
Input parameter of type Option
NewComponentNo
Input parameter of type Code
ParentItemNo
Input parameter of type Code

Remarks

The relevant search keywords are: Edit, Assembly, List.

For a clarification about how this function works, refer to the code listed below.

      CASE ChangeType OF
        ChangeType::Add:
          CreateAssemblyListComponent(
            NewComponentType,NewComponentNo,ParentItemNo,'',BOMComponent."Resource Usage Type"::Direct,
            LibraryRandom.RandDec(20,2),TRUE);
        ChangeType::Replace:
          EditAssemblyListComponent(
            ComponentType,NewComponentType,NewComponentNo,ParentItemNo,BOMComponent."Resource Usage Type"::Direct,
            LibraryRandom.RandDec(20,2),TRUE);
        ChangeType::Delete:
          DeleteAssemblyListComponent(ComponentType,ParentItemNo);
        ChangeType::Edit:
          EditAssemblyListComponent(
            ComponentType,NewComponentType,'',ParentItemNo,BOMComponent."Resource Usage Type"::Direct,
            LibraryRandom.RandDec(20,2),FALSE);
        ChangeType::"Delete all":
          DeleteAssemblyList(ParentItemNo);
        ChangeType::"Edit cards":
          ModifyCostParams(ParentItemNo,FALSE,0,0);
      END;

Example

The below example is extracted from the test automation codeunit 137090 to show one way of using this function.

      // Setup.
      Initialize;
      LibraryAssembly.CreateItem(Item,Item."Costing Method"::Standard,Item."Replenishment System"::Assembly,'','');
      LibraryAssembly.CreateAssemblyList(Item."Costing Method"::Standard,Item."No.",TRUE,2,2,1,1,'','');

      IF NewComponentType = BOMComponent.Type::Item THEN
        NewComponentNo := LibraryAssembly.CreateItem(Item1,Item."Costing Method"::Standard,Item."Replenishment System"::Purchase,'','')
      ELSE
        NewComponentNo := LibraryAssembly.CreateResource(Resource1,TRUE,'');
      LibraryAssembly.EditAssemblyList(ChangeType,ComponentType,NewComponentType,NewComponentNo,Item."No.");

      // Exercise.
      StdCostLevel := 1;
      CalculateStandardCost.CalcItem(Item."No.",TRUE);
      CalculateStandardCost.CalcAssemblyItemPrice(Item."No.");

      // Validate.
      Item.GET(Item."No.");
      Assert.AreNearlyEqual(LibraryAssembly.CalcExpectedStandardCost(MaterialCost,CapacityCost,CapOverhead,Item."No."),
        Item."Standard Cost",LibraryERM.GetAmountRoundingPrecision,'Wrong std. cost for:' + Item."No.");
      Assert.AreNearlyEqual(MaterialCost,Item."Single-Level Material Cost",LibraryERM.GetUnitAmountRoundingPrecision,'Material Cost');
      Assert.AreNearlyEqual(CapacityCost,Item."Single-Level Capacity Cost",LibraryERM.GetUnitAmountRoundingPrecision,'Capacity Cost');
      Assert.AreNearlyEqual(CapOverhead,Item."Single-Level Cap. Ovhd Cost",LibraryERM.GetUnitAmountRoundingPrecision,'Cap. Overhead');
      Assert.AreNearlyEqual(CapOverhead,Item."Rolled-up Cap. Overhead Cost",LibraryERM.GetUnitAmountRoundingPrecision,
        'Rolled up Cap Overhead');
      Assert.AreNearlyEqual(
        LibraryAssembly.CalcExpectedPrice(Item."No."),Item."Unit Price",LibraryERM.GetUnitAmountRoundingPrecision,
        'Wrong unit price for:' + Item."No.");
Member of Lib.Library - Assembly


EditAssemblyListComponent@23 Method

The procedure EditAssemblyListComponent is available in codeunit 132207.

Syntax

EditAssemblyListComponent@23(
    ComponentType@1000 : Option ComponentType, //Input parameter of type Option
    NewComponentType@1007 : Option NewComponentType, //Input parameter of type Option
    NewComponentNo@1006 : Code[20] NewComponentNo, //Input parameter of type Code
    ParentItemNo@1005 : Code[20] ParentItemNo, //Input parameter of type Code
    ResourceUsage@1008 : Option ResourceUsage, //Input parameter of type Option
    Qty@1002 : Decimal Qty, //Input parameter of type Decimal
    UseBaseUnitOfMeasure@1003 : Boolean UseBaseUnitOfMeasure //Input parameter of type Boolean
);

Parameters

ComponentType
Input parameter of type Option
NewComponentType
Input parameter of type Option
NewComponentNo
Input parameter of type Code
ParentItemNo
Input parameter of type Code
ResourceUsage
Input parameter of type Option
Qty
Input parameter of type Decimal
UseBaseUnitOfMeasure
Input parameter of type Boolean

Remarks

The relevant search keywords are: Edit, Assembly, List, Component.

For a clarification about how this function works, refer to the code listed below.

      BOMComponent.SETRANGE("Parent Item No.",ParentItemNo);
      BOMComponent.SETRANGE(Type,ComponentType);
      IF NOT BOMComponent.FINDSET THEN
        EXIT;

      BOMComponent.NEXT(RANDOM(BOMComponent.COUNT));
      IF NewComponentNo <> '' THEN BEGIN
        BOMComponent.VALIDATE(Type,NewComponentType);
        BOMComponent.VALIDATE("No.",NewComponentNo);
        BOMComponent.VALIDATE("Unit of Measure Code",GetUnitOfMeasureCode(NewComponentType,NewComponentNo,UseBaseUnitOfMeasure));
      END ELSE
        BOMComponent.VALIDATE("Unit of Measure Code",GetUnitOfMeasureCode(BOMComponent.Type,BOMComponent."No.",UseBaseUnitOfMeasure));
      IF ComponentType = BOMComponent.Type::Resource THEN
        BOMComponent.VALIDATE("Resource Usage Type",ResourceUsage);
      BOMComponent.VALIDATE("Quantity per",Qty);
      BOMComponent.VALIDATE(
        Description,LibraryUtility.GenerateRandomCode(BOMComponent.FIELDNO(Description),DATABASE::"BOM Component"));
      BOMComponent.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - Assembly


EditOrderDimensions@105 Method

The procedure EditOrderDimensions is available in codeunit 132207.

Syntax

EditOrderDimensions@105(
    AssemblyHeader@1000 : Record 900 AssemblyHeader //Input parameter of type Record
);

Parameters

AssemblyHeader
Input parameter of type Record

Remarks

The relevant search keywords are: Edit, Order, Dimensions.

For a clarification about how this function works, refer to the code listed below.

      CreateDimensionSetup(TempDimension,TempDimensionValue);
      AssemblyHeader.VALIDATE("Dimension Set ID",
        LibraryDimension.CreateDimSet(AssemblyHeader."Dimension Set ID",TempDimension.Code,TempDimensionValue.Code));

Example

The below example is extracted from the test automation codeunit 137092 to show one way of using this function.

      // Setup.
      Initialize;
      LibraryAssembly.UpdateAssemblySetup(AssemblySetup,'',DimensionsFrom,LibraryUtility.GetGlobalNoSeriesCode);
      LibraryAssembly.SetupAssemblyData(AssemblyHeader,WorkDate2,Item."Costing Method"::Standard,Item."Costing Method"::Average,
        Item."Replenishment System"::Assembly,'',TRUE);
      LibraryAssembly.AddCompInventory(AssemblyHeader,WorkDate2,0);

      // Exercise.
      LibraryAssembly.CheckOrderDimensions(AssemblyHeader,DimensionsFrom);
      IF OverrideDimensions THEN
        LibraryAssembly.EditOrderDimensions(AssemblyHeader);
      ExpectedError := LibraryAssembly.BlockOrderDimensions(AssemblyHeader,HeaderBlockType,CompBlockType);

      IF ExpectedError = '' THEN
        ExpectedError := AddAOItemDimension(AssemblyHeader,DefaultHeaderValuePosting,DefaultCompValuePosting);

      SetShortcutDimensions(AssemblyHeader,1);
      SetShortcutDimensions(AssemblyHeader,2);

      LibraryAssembly.PrepareOrderPosting(AssemblyHeader,TempAssemblyLine,100,100,TRUE,WorkDate2);
      LibraryAssembly.PostAssemblyHeader(AssemblyHeader,ExpectedError);

      // Verify.
      IF ExpectedError = '' THEN BEGIN
        LibraryAssembly.VerifyPostedAssemblyHeader(TempAssemblyLine,AssemblyHeader,AssemblyHeader.Quantity);
        LibraryAssembly.VerifyPostedComments(AssemblyHeader);
        LibraryAssembly.VerifyILEs(TempAssemblyLine,AssemblyHeader,AssemblyHeader."Quantity to Assemble");
        LibraryAssembly.VerifyValueEntries(TempAssemblyLine,AssemblyHeader,AssemblyHeader."Quantity to Assemble");
        LibraryAssembly.VerifyResEntries(TempAssemblyLine,AssemblyHeader);
        LibraryAssembly.VerifyCapEntries(TempAssemblyLine,AssemblyHeader);
        LibraryAssembly.VerifyItemRegister(AssemblyHeader);
      END;

      // Tear down.
Member of Lib.Library - Assembly


FindLinkedAssemblyOrder@95 Method

The procedure FindLinkedAssemblyOrder is available in codeunit 132207.

Syntax

FindLinkedAssemblyOrder@95(
    VAR AssemblyHeader@1000 : Record 900 AssemblyHeader, //Reference parameter of type Record
    DocumentType@1001 : Option DocumentType, //Input parameter of type Option
    DocumentNo@1002 : Code[20] DocumentNo, //Input parameter of type Code
    DocumentLineNo@1003 : Integer DocumentLineNo //Input parameter of type Integer
);

Parameters

AssemblyHeader
Reference parameter of type Record
DocumentType
Input parameter of type Option
DocumentNo
Input parameter of type Code
DocumentLineNo
Input parameter of type Integer

Remarks

The relevant search keywords are: Find, Linked, Assembly, Order.

For a clarification about how this function works, refer to the code listed below.

      AssembleToOrderLink.SETRANGE(Type,AssembleToOrderLink.Type::Sale);
      AssembleToOrderLink.SETRANGE("Document Type",DocumentType);
      AssembleToOrderLink.SETRANGE("Document No.",DocumentNo);
      AssembleToOrderLink.SETRANGE("Document Line No.",DocumentLineNo);
      AssembleToOrderLink.FINDFIRST;
      AssemblyHeader.GET(AssembleToOrderLink."Assembly Document Type",AssembleToOrderLink."Assembly Document No.");

Example

The below example is extracted from the test automation codeunit 137044 to show one way of using this function.

      // [FEATURE] [Sales] [Order] [Assemble-to-Order]
      // [SCENARIO 251877] Availability warning is raised on Assemble-to-Order line when you shift Due Date to an earlier date on which the component is lacking.
      Initialize;

      // [GIVEN] Enable stockout warnings.
      LibrarySales.SetStockoutWarning(TRUE);
      LibraryAssembly.SetStockoutWarning(TRUE);

      // [GIVEN] Assembled item "I" with a component "C".
      CreateAssembleToOrderItemWithComponent(AsmItem,CompItem);

      // [GIVEN] 2 pc of component "C" is in stock on WORKDATE, 1 pc is set to be purchased on WORKDATE + 10 days.
      // [GIVEN] Sales order "SO1" for 1 pc of assembled item "I" on WORKDATE + 20 days.
      CreateSupplyForBOMComponentAndDemandForAssembledItem(
        AsmItem."No.",CompItem."No.",2,1,1,WORKDATE,WORKDATE + 20,WORKDATE + 10);

      // [GIVEN] Another sales order "SO2" for 2 pcs of assembled item "I" on WORKDATE + 30 days.
      CreateSalesOrder(SalesHeader,WORKDATE + 30,'',AsmItem."No.",2);
      FindSalesline(SalesLine,SalesHeader,AsmItem."No.");

      // [GIVEN] Find Assembly Order linked to "SO2".
      LibraryAssembly.FindLinkedAssemblyOrder(
        AssemblyHeader,SalesLine."Document Type",SalesLine."Document No.",SalesLine."Line No.");
      FindAssemblyLine(AssemblyLine,AssemblyHeader,CompItem."No.");

      // [WHEN] Set "Due Date" on the assembly line to the date earlier than the purchase date (e.g. WORKDATE + 15 days) and check the availability.
      AssemblyLine."Due Date" := WORKDATE + 15;
      ItemCheckAvail.AssemblyLineCheck(AssemblyLine);

      // [THEN] Availability notification for the component "C" is raised.
      Assert.AreEqual(
        CompItem."No.",LibraryVariableStorage.DequeueText,
        'Availability notification for the component item is not raised');
Member of Lib.Library - Assembly


FindPostedAssemblyHeaders@40 Method

The procedure FindPostedAssemblyHeaders is available in codeunit 132207.

Syntax

FindPostedAssemblyHeaders@40(
    VAR PostedAssemblyHeader@1001 : Record 910 PostedAssemblyHeader, //Reference parameter of type Record
    AssemblyHeader@1000 : Record 900 AssemblyHeader //Input parameter of type Record
);

Parameters

PostedAssemblyHeader
Reference parameter of type Record
AssemblyHeader
Input parameter of type Record

Remarks

The relevant search keywords are: Find, Posted, Assembly, Headers.

For a clarification about how this function works, refer to the code listed below.

      PostedAssemblyHeader.RESET;
      PostedAssemblyHeader.SETRANGE("Order No.",AssemblyHeader."No.");
      PostedAssemblyHeader.SETRANGE("Item No.",AssemblyHeader."Item No.");

Example

The below example is extracted from the test automation codeunit 137099 to show one way of using this function.

      AssemblyHeader.VALIDATE("Quantity to Assemble",QtyToAssemble);
      AssemblyHeader.MODIFY(TRUE);

      LibraryAssembly.CreateWhsePick(AssemblyHeader,USERID,0,FALSE,TRUE,FALSE);
      UpdateQtyToHandleAndRegisterPick(AssemblyHeader."No.",QtyPicked);

      LibraryAssembly.PostAssemblyHeader(AssemblyHeader,'');
      AssemblyHeader.FIND;
      LibraryAssembly.FindPostedAssemblyHeaders(PostedAssemblyHeader,AssemblyHeader);
      PostedAssemblyHeader.FINDFIRST;
Member of Lib.Library - Assembly


FindPostedAssemblyLines@55 Method

The procedure FindPostedAssemblyLines is available in codeunit 132207.

Syntax

FindPostedAssemblyLines@55(
    VAR PostedAssemblyLine@1000 : Record 911 PostedAssemblyLine, //Reference parameter of type Record
    PostedAssemblyHeader@1001 : Record 910 PostedAssemblyHeader //Input parameter of type Record
);

Parameters

PostedAssemblyLine
Reference parameter of type Record
PostedAssemblyHeader
Input parameter of type Record

Remarks

The relevant search keywords are: Find, Posted, Assembly, Lines.

For a clarification about how this function works, refer to the code listed below.

      PostedAssemblyLine.RESET;
      PostedAssemblyLine.SETRANGE("Document No.",PostedAssemblyHeader."No.");
      PostedAssemblyLine.SETRANGE("Order No.",PostedAssemblyHeader."Order No.");
      PostedAssemblyLine.SETRANGE(Type,PostedAssemblyLine.Type::Item);

Example

There are no examples available.
Member of Lib.Library - Assembly


GetAdjAmounts@206 Method

The procedure GetAdjAmounts is available in codeunit 132207.

Syntax

GetAdjAmounts@206(
    VAR VarianceAmount@1002 : Decimal VarianceAmount, //Reference parameter of type Decimal
    VAR AdjAmount@1006 : Decimal AdjAmount, //Reference parameter of type Decimal
    PostedAssemblyHeader@1000 : Record 910 PostedAssemblyHeader //Input parameter of type Record
);

Parameters

VarianceAmount
Reference parameter of type Decimal
AdjAmount
Reference parameter of type Decimal
PostedAssemblyHeader
Input parameter of type Record

Remarks

The relevant search keywords are: Get, Adj, Amounts.

For a clarification about how this function works, refer to the code listed below.

      ValueEntry.RESET;
      ValueEntry.SETRANGE("Document No.",PostedAssemblyHeader."No.");
      ValueEntry.SETRANGE("Order Type",ValueEntry."Order Type"::Assembly);
      ValueEntry.SETRANGE("Order No.",PostedAssemblyHeader."Order No.");
      ValueEntry.SETRANGE("Entry Type",ValueEntry."Entry Type"::"Direct Cost");
      DirectCostAmount := 0;
      OutputNotAdjAmount := 0;

      IF ValueEntry.FINDSET THEN
        REPEAT
          CASE ValueEntry."Item Ledger Entry Type" OF
            ValueEntry."Item Ledger Entry Type"::" ":
              DirectCostAmount += -ValueEntry."Cost Amount (Actual)";
            ValueEntry."Item Ledger Entry Type"::"Assembly Consumption":
              DirectCostAmount += ValueEntry."Cost Amount (Actual)";
            ValueEntry."Item Ledger Entry Type"::"Assembly Output":
              IF NOT ValueEntry.Adjustment THEN
                OutputNotAdjAmount += ValueEntry."Cost Amount (Actual)";
          END;
        UNTIL ValueEntry.NEXT = 0;

      AdjAmount := DirectCostAmount + OutputNotAdjAmount;
      VarianceAmount := DirectCostAmount + PostedAssemblyHeader."Cost Amount";

Example

There are no examples available.
Member of Lib.Library - Assembly


GetBOMComponentLines@36 Method

The procedure GetBOMComponentLines is available in codeunit 132207.

Syntax

GetBOMComponentLines@36(
    VAR TempBOMComponent@1000 : TEMPORARY Record 90 TempBOMComponent, //Reference Temporary parameter of type Record
    ParentItemNo@1001 : Code[20] ParentItemNo //Input parameter of type Code
);

Parameters

TempBOMComponent
Reference Temporary parameter of type Record
ParentItemNo
Input parameter of type Code

Remarks

The relevant search keywords are: Get, BOM, Component, Lines.

For a clarification about how this function works, refer to the code listed below.

      BOMComponent.SETRANGE("Parent Item No.",ParentItemNo);
      BOMComponent.SETRANGE(Type,BOMComponent.Type::Item);
      IF BOMComponent.FINDSET THEN
        REPEAT
          Item.GET(BOMComponent."No.");
          IF Item."Assembly BOM" THEN
            GetBOMComponentLines(TempBOMComponent,Item."No.")
          ELSE BEGIN
            TempBOMComponent := BOMComponent;
            TempBOMComponent.INSERT;
          END;
        UNTIL BOMComponent.NEXT = 0;

      BOMComponent.SETRANGE(Type,BOMComponent.Type::Resource);
      IF BOMComponent.FINDSET THEN
        REPEAT
          TempBOMComponent := BOMComponent;
          TempBOMComponent.INSERT;
        UNTIL BOMComponent.NEXT = 0;

Example

The below example is extracted from the test automation codeunit 137091 to show one way of using this function.

      AssemblyHeader.GET(AssemblyHeader."Document Type"::Order,AssemblyHeaderNo);
      AssemblyLine.SETRANGE("Document Type",AssemblyHeader."Document Type");
      AssemblyLine.SETRANGE("Document No.",AssemblyHeader."No.");
      LibraryAssembly.GetBOMComponentLines(TempBOMComponent,AssemblyHeader."Item No.");
      IF AssemblyLine.FINDSET THEN
        REPEAT
          TempBOMComponent.SETRANGE("Parent Item No.",AssemblyHeader."Item No.");
          TempBOMComponent.SETRANGE(Type,AssemblyLine.Type);
          TempBOMComponent.SETRANGE("No.",AssemblyLine."No.");
          TempBOMComponent.SETRANGE("Variant Code",AssemblyLine."Variant Code");
          TempBOMComponent.SETRANGE("Unit of Measure Code",AssemblyLine."Unit of Measure Code");
          TempBOMComponent.FINDFIRST;
          Assert.AreEqual(1,TempBOMComponent.COUNT,'Too many order lines exploded.');
          TempAssemblyLine.SETRANGE(Type,TempAssemblyLine.Type::Item);
          TempAssemblyLine.SETRANGE("No.",TempBOMComponent."Parent Item No.");
          IF TempAssemblyLine.FINDFIRST THEN
            Assert.AreNearlyEqual(TempAssemblyLine."Quantity per" * TempBOMComponent."Quantity per",AssemblyLine."Quantity per",
              LibraryERM.GetAmountRoundingPrecision,'Wrong qty per in exploded line for ' + TempAssemblyLine."No.");
          VerifyOrderLine(AssemblyLine);
        UNTIL AssemblyLine.NEXT = 0
Member of Lib.Library - Assembly


GetCompsToAdjust@5 Method

The procedure GetCompsToAdjust is available in codeunit 132207.

Syntax

GetCompsToAdjust@5(
    VAR ItemNo@1001 : ARRAY [10] OF Code[20] ItemNo, //Reference Array parameter of type Code
    VAR ResourceNo@1005 : ARRAY [10] OF Code[20] ResourceNo, //Reference Array parameter of type Code
    AssemblyHeader@1000 : Record 900 AssemblyHeader //Input parameter of type Record
);

Parameters

ItemNo
Reference Array parameter of type Code
ResourceNo
Reference Array parameter of type Code
AssemblyHeader
Input parameter of type Record

Return Value

Text[250]

Remarks

The relevant search keywords are: Get, Comps, To, Adjust.

For a clarification about how this function works, refer to the code listed below.

      AssemblyLine.SETRANGE("Document Type",AssemblyHeader."Document Type");
      AssemblyLine.SETRANGE("Document No.",AssemblyHeader."No.");
      AssemblyLine.SETRANGE(Type,AssemblyLine.Type::Item);
      ItemFilter := AssemblyHeader."Item No.";
      i := 1;
      IF AssemblyLine.FINDSET THEN
        REPEAT
          ItemNo[i] := AssemblyLine."No.";
          ItemFilter += '|' + ItemNo[i];
          i += 1;
        UNTIL AssemblyLine.NEXT = 0;
      ItemFilter := DELCHR(ItemFilter,'>','|');

      i := 1;
      AssemblyLine.SETRANGE(Type,AssemblyLine.Type::Resource);
      IF AssemblyLine.FINDSET THEN
        REPEAT
          ResourceNo[i] := AssemblyLine."No.";
          i += 1;
        UNTIL AssemblyLine.NEXT = 0;

      EXIT(ItemFilter)

Example

The below example is extracted from the test automation codeunit 137092 to show one way of using this function.

      // [FEATURE] [Posting]
      // [SCENARIO] Verify an error on Assembly Order posting if insufficient Quantity of components on stock.

      // Setup.
      Initialize;
      LibraryAssembly.SetupAssemblyData(AssemblyHeader,WorkDate2,Item."Costing Method"::Standard,Item."Costing Method"::Average,
        Item."Replenishment System"::Assembly,'',TRUE);
      LibraryAssembly.GetCompsToAdjust(ItemNo,ResourceNo,AssemblyHeader);

      // Exercise.
      LibraryAssembly.PrepareOrderPosting(AssemblyHeader,TempAssemblyLine,100,100,TRUE,WorkDate2);

      // Verify.
      LibraryAssembly.PostAssemblyHeader(AssemblyHeader,STRSUBSTNO(AvailCheckErr,ItemNo[1]));
Member of Lib.Library - Assembly


GetCostInformation@61 Method

The procedure GetCostInformation is available in codeunit 132207.

Syntax

GetCostInformation@61(
    VAR UnitCost@1006 : Decimal UnitCost, //Reference parameter of type Decimal
    VAR Overhead@1005 : Decimal Overhead, //Reference parameter of type Decimal
    VAR IndirectCost@1004 : Decimal IndirectCost, //Reference parameter of type Decimal
    Type@1000 : Option Type, //Input parameter of type Option
    No@1001 : Code[20] No, //Input parameter of type Code
    VariantCode@1008 : Code[10] VariantCode, //Input parameter of type Code
    LocationCode@1009 : Code[10] LocationCode //Input parameter of type Code
);

Parameters

UnitCost
Reference parameter of type Decimal
Overhead
Reference parameter of type Decimal
IndirectCost
Reference parameter of type Decimal
Type
Input parameter of type Option
No
Input parameter of type Code
VariantCode
Input parameter of type Code
LocationCode
Input parameter of type Code

Return Value

Boolean

Remarks

The relevant search keywords are: Get, Cost, Information.

For a clarification about how this function works, refer to the code listed below.

      CASE Type OF
        AssemblyLine.Type::Item:
          BEGIN
            Item.GET(No);
            StockkeepingUnit.SETCURRENTKEY("Location Code","Item No.","Variant Code");
            IF StockkeepingUnit.GET(LocationCode,Item."No.",VariantCode) THEN
              UnitCost := StockkeepingUnit."Unit Cost"
            ELSE
              UnitCost := Item."Unit Cost";
            Overhead := Item."Overhead Rate";
            IndirectCost := Item."Indirect Cost %";
            EXIT(Item."Cost is Adjusted");
          END;
        AssemblyLine.Type::Resource:
          BEGIN
            Resource.GET(No);
            UnitCost := Resource."Unit Cost";
            Overhead := Resource."Unit Cost" - Resource."Direct Unit Cost";
            IndirectCost := Resource."Indirect Cost %";
            EXIT(FALSE);
          END;
      END;

Example

The below example is extracted from the test automation codeunit 137091 to show one way of using this function.

      AssemblyHeader.GET(AssemblyHeader."Document Type"::Order,AssemblyLine."Document No.");
      IF AssemblyLine.Type = AssemblyLine.Type::" " THEN
        EXIT;
      IF (AssemblyLine.Type = AssemblyLine.Type::Resource) AND
         (AssemblyHeader.Quantity > 0) AND (AssemblyLine."Resource Usage Type" = AssemblyLine."Resource Usage Type"::Fixed)
      THEN
        OrderQty := 1
      ELSE
        OrderQty := AssemblyHeader.Quantity;

      Assert.AreEqual(
        ROUND(OrderQty * AssemblyLine."Quantity per",LibraryERM.GetAmountRoundingPrecision),
        ROUND(AssemblyLine.Quantity,LibraryERM.GetAmountRoundingPrecision),'Wrong Quantity on Line.');
      Assert.AreEqual(
        ROUND(AssemblyLine.Quantity * AssemblyLine."Qty. per Unit of Measure",LibraryERM.GetUnitAmountRoundingPrecision),
        ROUND(AssemblyLine."Quantity (Base)",LibraryERM.GetUnitAmountRoundingPrecision),'Wrong Base Qty calculation.');
      Assert.AreEqual(AssemblyLine.Quantity,AssemblyLine."Remaining Quantity",'Wrong Remaining Qty.');
      Assert.AreEqual(AssemblyLine."Quantity (Base)",AssemblyLine."Remaining Quantity (Base)",'Wrong Remaining Qty (Base).');

      LibraryAssembly.GetCostInformation(UnitCost,Overhead,IndirectCost,AssemblyLine.Type,AssemblyLine."No.",'','');
      Assert.AreNearlyEqual(ROUND(UnitCost,LibraryERM.GetUnitAmountRoundingPrecision),
        ROUND(AssemblyLine."Unit Cost" / AssemblyLine."Qty. per Unit of Measure",LibraryERM.GetUnitAmountRoundingPrecision),
        LibraryERM.GetAmountRoundingPrecision,'Wrong line Unit Cost.');
      Assert.AreEqual(
        ROUND(AssemblyLine."Unit Cost" * AssemblyLine.Quantity,LibraryERM.GetAmountRoundingPrecision),
        AssemblyLine."Cost Amount",'Wrong line Cost Amount.');
Member of Lib.Library - Assembly


GetPostingSetup@68 Method

The procedure GetPostingSetup is available in codeunit 132207.

Syntax

GetPostingSetup@68(
    VAR GeneralPostingSetup@1001 : Record 252 GeneralPostingSetup, //Reference parameter of type Record
    VAR InventoryPostingSetup@1002 : Record 5813 InventoryPostingSetup, //Reference parameter of type Record
    GenProdPostingGr@1000 : Code[10] GenProdPostingGr, //Input parameter of type Code
    InvtPostingGroup@1004 : Code[10] InvtPostingGroup, //Input parameter of type Code
    LocationCode@1007 : Code[10] LocationCode //Input parameter of type Code
);

Parameters

GeneralPostingSetup
Reference parameter of type Record
InventoryPostingSetup
Reference parameter of type Record
GenProdPostingGr
Input parameter of type Code
InvtPostingGroup
Input parameter of type Code
LocationCode
Input parameter of type Code

Remarks

The relevant search keywords are: Get, Posting, Setup.

For a clarification about how this function works, refer to the code listed below.

      GeneralPostingSetup.GET('',GenProdPostingGr);
      InventoryPostingSetup.GET(LocationCode,InvtPostingGroup);

Example

There are no examples available.
Member of Lib.Library - Assembly


GetUnitOfMeasureCode@14 Method

The procedure GetUnitOfMeasureCode is available in codeunit 132207.

Syntax

GetUnitOfMeasureCode@14(
    ComponentType@1000 : Option ComponentType, //Input parameter of type Option
    ComponentNo@1001 : Code[20] ComponentNo, //Input parameter of type Code
    UseBaseUnitOfMeasure@1002 : Boolean UseBaseUnitOfMeasure //Input parameter of type Boolean
);

Parameters

ComponentType
Input parameter of type Option
ComponentNo
Input parameter of type Code
UseBaseUnitOfMeasure
Input parameter of type Boolean

Return Value

Code[10]

Remarks

The relevant search keywords are: Get, Unit, Of, Measure, Code.

For a clarification about how this function works, refer to the code listed below.

      CASE ComponentType OF
        BOMComponent.Type::Item:
          BEGIN
            Item.GET(ComponentNo);
            IF UseBaseUnitOfMeasure THEN
              EXIT(Item."Base Unit of Measure");
            ItemUnitOfMeasure.SETRANGE("Item No.",Item."No.");
            ItemUnitOfMeasure.SETFILTER(Code,'<>%1',Item."Base Unit of Measure");
            IF ItemUnitOfMeasure.FINDFIRST THEN
              EXIT(ItemUnitOfMeasure.Code);
          END;
        BOMComponent.Type::Resource:
          BEGIN
            Resource.GET(ComponentNo);
            IF UseBaseUnitOfMeasure THEN
              EXIT(Resource."Base Unit of Measure");
            ResourceUnitOfMeasure.SETRANGE("Resource No.",Resource."No.");
            ResourceUnitOfMeasure.SETFILTER(Code,'<>%1',Resource."Base Unit of Measure");
            IF ResourceUnitOfMeasure.FINDFIRST THEN
              EXIT(ResourceUnitOfMeasure.Code);
          END
      END;
      EXIT('');

Example

The below example is extracted from the test automation codeunit 137091 to show one way of using this function.

      // Setup.
      Initialize;
      StdCostLevel := 1;
      LibraryAssembly.SetupAssemblyData(AssemblyHeader,WorkDate2,CostingMethod,CostingMethod,
        Item."Replenishment System"::Assembly,'',TRUE);
      LibraryAssembly.CreateItem(Item,CostingMethod,Item."Replenishment System"::Purchase,'','');
      LibraryAssembly.CreateResource(Resource,TRUE,'');
      LibraryAssembly.EditAssemblyLines(
        ChangeType::Add,AssemblyLine.Type::Item,AssemblyLine.Type::Item,Item."No.",AssemblyHeader."No.",TRUE);
      LibraryAssembly.EditAssemblyLines(
        ChangeType::Add,AssemblyLine.Type::Resource,AssemblyLine.Type::Resource,Resource."No.",
        AssemblyHeader."No.",TRUE);

      // Exercise.
      AssemblyHeader.VALIDATE(Quantity,SignFactor * (AssemblyHeader.Quantity + LibraryRandom.RandDec(10,2)));
      AssemblyHeader.MODIFY(TRUE);
      AssemblyHeader.VALIDATE(
        "Unit of Measure Code",LibraryAssembly.GetUnitOfMeasureCode(AssemblyLine.Type::Item,AssemblyHeader."Item No.",BaseUoM));
      AssemblyHeader.MODIFY(TRUE);

      // Validate.
      VerifyOrderLines(AssemblyHeader."No.",TRUE);

      EXIT(AssemblyHeader."No.");
Member of Lib.Library - Assembly


LineCount@45 Method

The procedure LineCount is available in codeunit 132207.

Syntax

LineCount@45(
    AssemblyHeader@1000 : Record 900 AssemblyHeader //Input parameter of type Record
);

Parameters

AssemblyHeader
Input parameter of type Record

Return Value

Integer

Remarks

The relevant search keywords are: Line, Count.

For a clarification about how this function works, refer to the code listed below.

      SetLinkToLines(AssemblyHeader,AssemblyLine);
      EXIT(AssemblyLine.COUNT);

Example

The below example is extracted from the test automation codeunit 137907 to show one way of using this function.

      AssemblyHeader.GET(AssemblyHeader."Document Type"::Order,OrderNo);
      Assert.AreEqual(Count,LibraryAssembly.LineCount(AssemblyHeader),
        STRSUBSTNO(MSGAssertLineCount,OrderNo,Count,LibraryAssembly.LineCount(AssemblyHeader)));
Member of Lib.Library - Assembly


ModifyCostParams@15 Method

The procedure ModifyCostParams is available in codeunit 132207.

Syntax

ModifyCostParams@15(
    ParentItemNo@1000 : Code[20] ParentItemNo, //Input parameter of type Code
    CostAdjNeeded@1001 : Boolean CostAdjNeeded, //Input parameter of type Boolean
    IndirectCost@1002 : Decimal IndirectCost, //Input parameter of type Decimal
    Overhead@1003 : Decimal Overhead //Input parameter of type Decimal
);

Parameters

ParentItemNo
Input parameter of type Code
CostAdjNeeded
Input parameter of type Boolean
IndirectCost
Input parameter of type Decimal
Overhead
Input parameter of type Decimal

Remarks

The relevant search keywords are: Modify, Cost, Params.

For a clarification about how this function works, refer to the code listed below.

      BOMComponent.SETRANGE("Parent Item No.",ParentItemNo);
      IF BOMComponent.FINDSET THEN
        REPEAT
          CASE BOMComponent.Type OF
            BOMComponent.Type::Item:
              ModifyItem(BOMComponent."No.",CostAdjNeeded,IndirectCost,Overhead);
            BOMComponent.Type::Resource:
              BEGIN
                Resource.GET(BOMComponent."No.");
                Resource.VALIDATE("Unit Price",Resource."Unit Price" + LibraryRandom.RandDec(10,2));
                IF CostAdjNeeded THEN BEGIN
                  Resource.VALIDATE("Direct Unit Cost",Resource."Direct Unit Cost" + LibraryRandom.RandDec(10,2));
                  Resource.VALIDATE("Indirect Cost %",IndirectCost);
                END;
                Resource.MODIFY(TRUE);
              END
          END;
        UNTIL BOMComponent.NEXT = 0;

Example

The below example is extracted from the test automation codeunit 137090 to show one way of using this function.

      // Setup.
      Initialize;
      LibraryAssembly.CreateItem(Item,CostingMethod,Item."Replenishment System"::Assembly,'','');
      LibraryAssembly.CreateAssemblyList(CostingMethod,Item."No.",TRUE,1,1,1,1,'','');
      LibraryAssembly.ModifyCostParams(Item."No.",CostAdjNeeded,IndirectCost,Overhead);

      // Exercise.
      StdCostLevel := 1;
      CalculateStandardCost.CalcItem(Item."No.",TRUE);
      CalculateStandardCost.CalcAssemblyItemPrice(Item."No.");

      // Validate.
      Item.GET(Item."No.");
      IF CostingMethod <> Item."Costing Method"::Standard THEN
        Assert.AreEqual(0,Item."Unit Cost",'Unit cost should be 0:' + Item."No.");
      Assert.AreNearlyEqual(
        LibraryAssembly.CalcExpectedPrice(Item."No."),Item."Unit Price",LibraryERM.GetUnitAmountRoundingPrecision,
        'Wrong unit price for:' + Item."No.");
Member of Lib.Library - Assembly


ModifyItem@24 Method

The procedure ModifyItem is available in codeunit 132207.

Syntax

ModifyItem@24(
    ItemNo@1000 : Code[20] ItemNo, //Input parameter of type Code
    CostAdjNeeded@1001 : Boolean CostAdjNeeded, //Input parameter of type Boolean
    IndirectCost@1002 : Decimal IndirectCost, //Input parameter of type Decimal
    Overhead@1003 : Decimal Overhead //Input parameter of type Decimal
);

Parameters

ItemNo
Input parameter of type Code
CostAdjNeeded
Input parameter of type Boolean
IndirectCost
Input parameter of type Decimal
Overhead
Input parameter of type Decimal

Remarks

The relevant search keywords are: Modify, Item.

For a clarification about how this function works, refer to the code listed below.

      Item.GET(ItemNo);
      IF CostAdjNeeded THEN BEGIN
        Item.VALIDATE("Indirect Cost %",IndirectCost);
        Item.VALIDATE("Overhead Rate",Overhead);
        IF Item."Costing Method" = Item."Costing Method"::Standard THEN
          Item.VALIDATE("Standard Cost",Item."Standard Cost" + LibraryRandom.RandDec(10,2))
        ELSE
          Item.VALIDATE("Unit Cost",Item."Unit Cost" + LibraryRandom.RandDec(10,2));
      END;

      Item.VALIDATE("Unit Price",Item."Unit Price" + LibraryRandom.RandDec(10,2));
      Item.VALIDATE("Lot Size",Item."Lot Size" + LibraryRandom.RandInt(10));
      Item.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137090 to show one way of using this function.

      // Setup.
      Initialize;
      LibraryAssembly.CreateItem(Item,CostingMethod,Item."Replenishment System"::Assembly,'','');
      LibraryAssembly.CreateAssemblyList(Item."Costing Method"::Standard,Item."No.",TRUE,1,1,1,1,'','');
      LibraryAssembly.ModifyItem(Item."No.",CostAdjNeeded,IndirectCost,Overhead);
      Item.GET(Item."No.");
      InitialCost := Item."Unit Cost";

      // Exercise.
      StdCostLevel := 1;
      CalculateStandardCost.CalcItem(Item."No.",TRUE);
      CalculateStandardCost.CalcAssemblyItemPrice(Item."No.");

      // Validate.
      Item.GET(Item."No.");
      IF CostingMethod <> Item."Costing Method"::Standard THEN
        Assert.AreEqual(InitialCost,Item."Unit Cost",'Unit cost should not be updated:' + Item."No.");
      Assert.AreNearlyEqual(LibraryAssembly.CalcExpectedStandardCost(MaterialCost,CapacityCost,CapOverhead,Item."No."),
        Item."Standard Cost",LibraryERM.GetAmountRoundingPrecision,'Wrong std. cost for:' + Item."No.");
      Assert.AreNearlyEqual(MaterialCost,Item."Single-Level Material Cost",LibraryERM.GetUnitAmountRoundingPrecision,'Material Cost');
      Assert.AreNearlyEqual(CapacityCost,Item."Single-Level Capacity Cost",LibraryERM.GetUnitAmountRoundingPrecision,'Capacity Cost');
      Assert.AreNearlyEqual(CapOverhead,Item."Single-Level Cap. Ovhd Cost",LibraryERM.GetUnitAmountRoundingPrecision,'Cap. Overhead');
      Assert.AreNearlyEqual(CapOverhead,Item."Rolled-up Cap. Overhead Cost",LibraryERM.GetUnitAmountRoundingPrecision,
        'Rolled up Cap Overhead');
      Assert.AreNearlyEqual(
        LibraryAssembly.CalcExpectedPrice(Item."No."),Item."Unit Price",LibraryERM.GetUnitAmountRoundingPrecision,
        'Wrong unit price for:' + Item."No.");
Member of Lib.Library - Assembly


ModifyOrderCostParams@13 Method

The procedure ModifyOrderCostParams is available in codeunit 132207.

Syntax

ModifyOrderCostParams@13(
    AssemblyHeaderNo@1000 : Code[20] AssemblyHeaderNo, //Input parameter of type Code
    CostAdjNeeded@1001 : Boolean CostAdjNeeded, //Input parameter of type Boolean
    IndirectCost@1002 : Decimal IndirectCost, //Input parameter of type Decimal
    Overhead@1003 : Decimal Overhead //Input parameter of type Decimal
);

Parameters

AssemblyHeaderNo
Input parameter of type Code
CostAdjNeeded
Input parameter of type Boolean
IndirectCost
Input parameter of type Decimal
Overhead
Input parameter of type Decimal

Remarks

The relevant search keywords are: Modify, Order, Cost, Params.

For a clarification about how this function works, refer to the code listed below.

      AssemblyLine.SETRANGE("Document Type",AssemblyLine."Document Type"::Order);
      AssemblyLine.SETRANGE("Document No.",AssemblyHeaderNo);
      IF AssemblyLine.FINDSET THEN
        REPEAT
          CASE AssemblyLine.Type OF
            AssemblyLine.Type::Item:
              ModifyItem(AssemblyLine."No.",CostAdjNeeded,IndirectCost,Overhead);
            AssemblyLine.Type::Resource:
              BEGIN
                Resource.GET(AssemblyLine."No.");
                Resource.VALIDATE("Indirect Cost %",IndirectCost);
                Resource.VALIDATE("Unit Price",Resource."Unit Price" + LibraryRandom.RandDec(10,2));
                Resource.VALIDATE("Unit Cost",Resource."Unit Cost" + LibraryRandom.RandDec(10,2));
                Resource.MODIFY(TRUE);
              END
          END;
        UNTIL AssemblyLine.NEXT = 0;

Example

There are no examples available.
Member of Lib.Library - Assembly


NeedsAdjustment@20 Method

The procedure NeedsAdjustment is available in codeunit 132207.

Syntax

NeedsAdjustment@20(
    VAR AdjUnitCost@1002 : Decimal AdjUnitCost, //Reference parameter of type Decimal
    Item@1000 : Record 27 Item, //Input parameter of type Record
    PostedAssemblyLine@1001 : Record 911 PostedAssemblyLine, //Input parameter of type Record
    FinalAdjSource@1004 : Option FinalAdjSource, //Input parameter of type Option
    UnitCost@1006 : Decimal UnitCost //Input parameter of type Decimal
);

Parameters

AdjUnitCost
Reference parameter of type Decimal
Item
Input parameter of type Record
PostedAssemblyLine
Input parameter of type Record
FinalAdjSource
Input parameter of type Option
UnitCost
Input parameter of type Decimal

Return Value

Boolean

Remarks

The relevant search keywords are: Needs, Adjustment.

For a clarification about how this function works, refer to the code listed below.

      AdjUnitCost := UnitCost - PostedAssemblyLine."Unit Cost";

      ValueEntry.RESET;
      ValueEntry.SETRANGE("Item No.",Item."No.");
      ValueEntry.SETRANGE("Entry Type",ValueEntry."Entry Type"::Revaluation);
      IF ValueEntry.FINDFIRST AND (FinalAdjSource = AdjSource::Revaluation) THEN
        AdjUnitCost -= ValueEntry."Cost per Unit";

      EXIT(
        Item."Cost is Adjusted" AND
        (ABS(AdjUnitCost) > LibraryERM.GetAmountRoundingPrecision) AND
        (ABS(AdjUnitCost * PostedAssemblyLine.Quantity) >= LibraryERM.GetAmountRoundingPrecision)
        )

Example

There are no examples available.
Member of Lib.Library - Assembly


PostAssemblyHeader@172 Method

The procedure PostAssemblyHeader is available in codeunit 132207.

Syntax

PostAssemblyHeader@172(
    AssemblyHeader@1000 : Record 900 AssemblyHeader, //Input parameter of type Record
    ExpectedError@1002 : Text[1024] ExpectedError //Input parameter of type Text
);

Parameters

AssemblyHeader
Input parameter of type Record
ExpectedError
Input parameter of type Text

Remarks

The relevant search keywords are: Post, Assembly, Header.

For a clarification about how this function works, refer to the code listed below.

      IF ExpectedError = '' THEN
        AssemblyPost.RUN(AssemblyHeader)
      ELSE BEGIN
        ASSERTERROR AssemblyPost.RUN(AssemblyHeader);
        Assert.IsTrue(STRPOS(GETLASTERRORTEXT,ExpectedError) > 0,
          'Expected:' + ExpectedError + '. Actual:' + GETLASTERRORTEXT);
        CLEARLASTERROR;
      END;
      COMMIT;

Example

The below example is extracted from the test automation codeunit 136502 to show one way of using this function.

      Initialize;
      // create an assembly order with a resource line (Resource has property Use Time Sheet = TRUE), the time sheet of the resource exists
      LibraryTimeSheet.InitAssemblyBackwayScenario(TimeSheetHeader,AssemblyHeader,AssemblyLine,TRUE);

      // get values from assembly line (with type 'Resource') of the assembly order
      SavedAssemblyLine.COPY(AssemblyLine);

      LibraryAssembly.PostAssemblyHeader(AssemblyHeader,'');

      LibraryTimeSheet.CheckAssemblyTimeSheetLine(TimeSheetHeader,SavedAssemblyLine."Document No.",SavedAssemblyLine."Line No.",
        SavedAssemblyLine."Quantity to Consume");
Member of Lib.Library - Assembly


PostInvtCostToGL@1 Method

The procedure PostInvtCostToGL is available in codeunit 132207.

Syntax

PostInvtCostToGL@1(
    PerPostingGroup@1002 : Boolean PerPostingGroup, //Input parameter of type Boolean
    ItemNo@1005 : Code[20] ItemNo, //Input parameter of type Code
    DocNo@1001 : Code[20] DocNo, //Input parameter of type Code
    PreviewDumpFilePath@1003 : Text[1024] PreviewDumpFilePath //Input parameter of type Text
);

Parameters

PerPostingGroup
Input parameter of type Boolean
ItemNo
Input parameter of type Code
DocNo
Input parameter of type Code
PreviewDumpFilePath
Input parameter of type Text

Remarks

The relevant search keywords are: Post, Invt, Cost, To, General Ledger.

For a clarification about how this function works, refer to the code listed below.

      COMMIT;
      PostValueEntryToGL.SETFILTER("Item No.",'>=%1',ItemNo);

      IF PerPostingGroup THEN
        PostMethod := PostMethod::"per Posting Group"
      ELSE
        PostMethod := PostMethod::"per Entry";
      PostInventoryCostToGL.InitializeRequest(PostMethod,DocNo,TRUE);
      PostInventoryCostToGL.SETTABLEVIEW(PostValueEntryToGL);
      PostInventoryCostToGL.USEREQUESTPAGE(FALSE);
      PostInventoryCostToGL.SAVEASPDF(PreviewDumpFilePath);

Example

The below example is extracted from the test automation codeunit 137049 to show one way of using this function.

      // Create Item and Sales Order.
      CreateItemAndUpdateInventory(Item,ItemQty);
      CreateSalesOrder(SalesHeader,Item."No.",SalesQty);

      // Sales Line -> Function -> Reserve.
      ReservationFromSalesOrder(SalesHeader."No.");

      // Exercise: Run Adjust Cost and Post Inventory Cost to G/L.
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');
      LibraryCosting.PostInvtCostToGL(FALSE,WORKDATE,'');

      // Verify: Verify Total amount in G/L for Inventory Account.
      VerifyGLEntry(Item."No.");
Member of Lib.Library - Assembly


PrepareOrderPosting@31 Method

The procedure PrepareOrderPosting is available in codeunit 132207.

Syntax

PrepareOrderPosting@31(
    VAR AssemblyHeader@1000 : Record 900 AssemblyHeader, //Reference parameter of type Record
    VAR TempAssemblyLine@1006 : TEMPORARY Record 901 TempAssemblyLine, //Reference Temporary parameter of type Record
    HeaderQtyFactor@1005 : Integer HeaderQtyFactor, //Input parameter of type Integer
    CompQtyFactor@1001 : Integer CompQtyFactor, //Input parameter of type Integer
    UpdateAllComps@1002 : Boolean UpdateAllComps, //Input parameter of type Boolean
    PostingDate@1007 : Date PostingDate //Input parameter of type Date
);

Parameters

AssemblyHeader
Reference parameter of type Record
TempAssemblyLine
Reference Temporary parameter of type Record
HeaderQtyFactor
Input parameter of type Integer
CompQtyFactor
Input parameter of type Integer
UpdateAllComps
Input parameter of type Boolean
PostingDate
Input parameter of type Date

Remarks

The relevant search keywords are: Prepare, Order, Posting.

For a clarification about how this function works, refer to the code listed below.

      TempAssemblyLine.DELETEALL;
      AssemblyHeader.VALIDATE("Quantity to Assemble",AssemblyHeader."Quantity to Assemble" * HeaderQtyFactor / 100);
      AssemblyHeader.VALIDATE(Description,
        LibraryUtility.GenerateRandomCode(AssemblyHeader.FIELDNO(Description),DATABASE::"Assembly Header"));
      AssemblyHeader.VALIDATE("Posting Date",PostingDate);
      AddAssemblyHeaderComment(AssemblyHeader,0);
      AssemblyHeader.MODIFY(TRUE);

      AssemblyLine.SETRANGE("Document Type",AssemblyHeader."Document Type");
      AssemblyLine.SETRANGE("Document No.",AssemblyHeader."No.");
      IF AssemblyLine.FINDSET THEN
        REPEAT
          AssemblyLine.VALIDATE("Quantity to Consume",AssemblyLine.Quantity * CompQtyFactor / 100);
          AssemblyLine.VALIDATE(Description,
            LibraryUtility.GenerateRandomCode(AssemblyLine.FIELDNO(Description),DATABASE::"Assembly Line"));
          AddAssemblyHeaderComment(AssemblyHeader,AssemblyLine."Line No.");
          AssemblyLine.MODIFY(TRUE);
          IF AssemblyLine."Quantity to Consume" > 0 THEN BEGIN
            TempAssemblyLine := AssemblyLine;
            TempAssemblyLine.INSERT;
          END;
        UNTIL (AssemblyLine.NEXT = 0) OR (NOT UpdateAllComps);

Example

The below example is extracted from the test automation codeunit 137092 to show one way of using this function.

      // Setup.
      Initialize;
      LibraryAssembly.UpdateAssemblySetup(AssemblySetup,'',DimensionsFrom,LibraryUtility.GetGlobalNoSeriesCode);
      LibraryAssembly.SetupAssemblyData(AssemblyHeader,WorkDate2,Item."Costing Method"::Standard,Item."Costing Method"::Average,
        Item."Replenishment System"::Assembly,'',TRUE);
      LibraryAssembly.AddCompInventory(AssemblyHeader,WorkDate2,0);

      // Exercise.
      LibraryAssembly.CheckOrderDimensions(AssemblyHeader,DimensionsFrom);
      IF OverrideDimensions THEN
        LibraryAssembly.EditOrderDimensions(AssemblyHeader);
      ExpectedError := LibraryAssembly.BlockOrderDimensions(AssemblyHeader,HeaderBlockType,CompBlockType);

      IF ExpectedError = '' THEN
        ExpectedError := AddAOItemDimension(AssemblyHeader,DefaultHeaderValuePosting,DefaultCompValuePosting);

      SetShortcutDimensions(AssemblyHeader,1);
      SetShortcutDimensions(AssemblyHeader,2);

      LibraryAssembly.PrepareOrderPosting(AssemblyHeader,TempAssemblyLine,100,100,TRUE,WorkDate2);
      LibraryAssembly.PostAssemblyHeader(AssemblyHeader,ExpectedError);

      // Verify.
      IF ExpectedError = '' THEN BEGIN
        LibraryAssembly.VerifyPostedAssemblyHeader(TempAssemblyLine,AssemblyHeader,AssemblyHeader.Quantity);
        LibraryAssembly.VerifyPostedComments(AssemblyHeader);
        LibraryAssembly.VerifyILEs(TempAssemblyLine,AssemblyHeader,AssemblyHeader."Quantity to Assemble");
        LibraryAssembly.VerifyValueEntries(TempAssemblyLine,AssemblyHeader,AssemblyHeader."Quantity to Assemble");
        LibraryAssembly.VerifyResEntries(TempAssemblyLine,AssemblyHeader);
        LibraryAssembly.VerifyCapEntries(TempAssemblyLine,AssemblyHeader);
        LibraryAssembly.VerifyItemRegister(AssemblyHeader);
      END;

      // Tear down.
Member of Lib.Library - Assembly


ReleaseAO@84 Method

The procedure ReleaseAO is available in codeunit 132207.

Syntax

ReleaseAO@84(
    VAR AssemblyHeader@1000 : Record 900 AssemblyHeader //Reference parameter of type Record
);

Parameters

AssemblyHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Release, AO.

For a clarification about how this function works, refer to the code listed below.

      CODEUNIT.RUN(CODEUNIT::"Release Assembly Document",AssemblyHeader);

Example

The below example is extracted from the test automation codeunit 137097 to show one way of using this function.

      // Release and create whse pick
      LibraryAssembly.ReleaseAO(AssemblyHeader);
      LibraryAssembly.CreateWhsePick(AssemblyHeader,USERID,0,FALSE,FALSE,FALSE);

      // Find the whse pick
      FindWhseActivityLine(WarehouseActivityLine,AssemblyHeader);

      WarehouseActivityHeader.GET(WarehouseActivityLine."Activity Type",WarehouseActivityLine."No.");

      // Register pick
      LibraryWarehouse.RegisterWhseActivity(WarehouseActivityHeader);
Member of Lib.Library - Assembly


ReopenAO@75 Method

The procedure ReopenAO is available in codeunit 132207.

Syntax

ReopenAO@75(
    VAR AssemblyHeader@1000 : Record 900 AssemblyHeader //Reference parameter of type Record
);

Parameters

AssemblyHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Reopen, AO.

For a clarification about how this function works, refer to the code listed below.

      ReleaseAssemblyDoc.Reopen(AssemblyHeader);

Example

The below example is extracted from the test automation codeunit 137097 to show one way of using this function.

      // Get bins
      BinIndex := 1;
      IF LocationCode <> '' THEN BEGIN
        Location.GET(LocationCode);
        LibraryWarehouse.FindBin(HeaderBin,LocationCode,'',BinIndex + 2);
        LibraryWarehouse.FindBin(ComponentsBin,LocationCode,'',BinIndex);
      END;

      LibraryWarehouse.FindBin(BinSilver1,LocationSilver.Code,'',BinIndex + 2);
      LibraryWarehouse.FindBin(BinSilver2,LocationSilver.Code,'',BinIndex + 1);

      // Create AO item
      LibraryInventory.CreateItem(NewItem);
      CreateAssembledItem(Item,Item."Assembly Policy"::"Assemble-to-Stock",LibraryRandom.RandInt(10),
        LibraryRandom.RandInt(10),LibraryRandom.RandInt(10),LibraryRandom.RandDec(1000,2));
      OrderQty := LibraryRandom.RandDec(1000,2) + 1;
      DueDate := CALCDATE('<+' + FORMAT(LibraryRandom.RandInt(30)) + 'D>',WorkDate2);

      // Create AO and add enough inventory for comp
      IF (LocationCode <> '') AND Location."Bin Mandatory" THEN BEGIN
        CreateAssemblyOrder(AssemblyHeader,Item,LocationCode,HeaderBin.Code,'',DueDate,OrderQty);
        SetLocAndBinCodeOnAsmLines(AssemblyHeader,ComponentsBin);
        LibraryAssembly.AddCompInventoryToBin(AssemblyHeader,WORKDATE,0,LocationCode,ComponentsBin.Code);
      END ELSE BEGIN
        CreateAssemblyOrder(AssemblyHeader,Item,LocationCode,'','',DueDate,OrderQty);
        LibraryAssembly.AddCompInventoryToBin(AssemblyHeader,WORKDATE,0,LocationCode,'');
      END;

      // Post partial
      PostAssemblyOrderQty(AssemblyHeader,OrderQty / 2);
      FindPostedAssemblyHeaderNotReversed(PostedAssemblyHeader,AssemblyHeader."No.");
      LibraryAssembly.ReopenAO(AssemblyHeader);

      // Change the initial AO
      CASE ChangeOption OF
        ChangeOption::"New Line":
          LibraryAssembly.CreateAssemblyLine(
            AssemblyHeader,AssemblyLine,AssemblyLine.Type::Item,NewItem."No.",NewItem."Base Unit of Measure",
            LibraryRandom.RandDec(1000,2),0,NewItem.Description);
        ChangeOption::"Delete Line":
          LibraryAssembly.DeleteAssemblyLine(AssemblyLine.Type::Item,AssemblyHeader."No.");
        ChangeOption::"Change Location Lines": // Assumes current function is called with Location <> Location Silver as param
          SetLocAndBinCodeOnAsmLines(AssemblyHeader,BinSilver1);
        ChangeOption::"Change Bin Lines": // Assumes current function is called with Location Silver as param
          SetLocAndBinCodeOnAsmLines(AssemblyHeader,BinSilver1);
        ChangeOption::"Change Location": // Assumes current function is called with Location <> Location Silver as param
          BEGIN
            AssemblyHeader.VALIDATE("Location Code",LocationSilver.Code);
            AssemblyHeader.MODIFY(TRUE);
          END;
        ChangeOption::"Change Bin": // Assumes current function is called with Location Silver as param
          BEGIN
            AssemblyHeader.VALIDATE("Bin Code",BinSilver2.Code);
            AssemblyHeader.MODIFY(TRUE);
          END;
      END;

      // Undo - error
      IF ChangeOption IN [ChangeOption::"New Line",ChangeOption::"Delete Line"] THEN
        LibraryAssembly.UndoPostedAssembly(PostedAssemblyHeader,TRUE,MSG_CANNOT_RESTORE_2)
      ELSE
        LibraryAssembly.UndoPostedAssembly(PostedAssemblyHeader,TRUE,MSG_CANNOT_RESTORE);
Member of Lib.Library - Assembly


RevaluateItem@194 Method

The procedure RevaluateItem is available in codeunit 132207.

Syntax

RevaluateItem@194(
    VAR Item@1006 : Record 27 Item, //Reference parameter of type Record
    VAR ItemJournalLine@1010 : Record 83 ItemJournalLine, //Reference parameter of type Record
    OldUnitCost@1009 : Decimal OldUnitCost, //Input parameter of type Decimal
    PostingDate@1002 : Date PostingDate //Input parameter of type Date
);

Parameters

Item
Reference parameter of type Record
ItemJournalLine
Reference parameter of type Record
OldUnitCost
Input parameter of type Decimal
PostingDate
Input parameter of type Date

Remarks

The relevant search keywords are: Revaluate, Item.

For a clarification about how this function works, refer to the code listed below.

      LibraryInventory.SelectItemJournalTemplateName(ItemJournalTemplate,ItemJournalTemplate.Type::Revaluation);
      LibraryInventory.SelectItemJournalBatchName(ItemJournalBatch,ItemJournalTemplate.Type::Revaluation,ItemJournalTemplate.Name);
      LibraryInventory.CreateItemJournalLine(ItemJournalLine,ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name,
        ItemJournalLine."Entry Type"::Purchase,Item."No.",0);
      Item.SETRANGE("No.",Item."No.");
      LibraryCosting.CreateRevaluationJnlLines(Item,ItemJournalLine,ItemJournalLine."Document No.",CalculatePer::Item,
        CalculationBase::" ",TRUE,TRUE,TRUE,PostingDate);

      ItemJournalLine.RESET;
      ItemJournalLine.SETRANGE("Journal Template Name",ItemJournalLine."Journal Template Name");
      ItemJournalLine.SETRANGE("Journal Batch Name",ItemJournalLine."Journal Batch Name");
      ItemJournalLine.SETRANGE("Item No.",Item."No.");
      ItemJournalLine.FINDFIRST;
      ItemJournalLine.VALIDATE("Unit Cost (Revalued)",OldUnitCost + RANDOM(50));
      ItemJournalLine.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - Assembly


RollUpAsmCost@73 Method

The procedure RollUpAsmCost is available in codeunit 132207.

Syntax

RollUpAsmCost@73(
    VAR SalesLine@1000 : Record 37 SalesLine //Reference parameter of type Record
);

Parameters

SalesLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Roll, Up, Asm, Cost.

For a clarification about how this function works, refer to the code listed below.

      SalesLine.RollUpAsmCost;

Example

The below example is extracted from the test automation codeunit 137096 to show one way of using this function.

      // [FEATURE] [Sales Order]
      // [SCENARIO 379342] Unit Cost in Sales Order Line after the RollupCost function is run should be calculated on Assembly Lines only.
      Initialize;

      // [GIVEN] Assembled Item with Assembly Policy = Assemble-to-Order.
      // [GIVEN] List of BOM Components with costs.
      // [GIVEN] Sales Order Line with Quantity > "Qty. Assemble to Order".
      QtyToAssembleToOrder := LibraryRandom.RandInt(1000);
      OrderQty := QtyToAssembleToOrder + LibraryRandom.RandInt(1000);
      CreateAssembledItemAndBOMComponentsWithUnitCostAndUnitPrice(Item);
      TCRollupCost(Item,SalesLine,AssemblyHeader,'',SalesDocumentType::Order,QtyToAssembleToOrder,OrderQty);

      // [WHEN] Run Roll-up Cost function.
      LibraryAssembly.RollUpAsmCost(SalesLine);

      // [THEN] Unit Cost in Sales Line is nearly equal to Unit Cost of Assembled Item.
      Assert.AreNearlyEqual(
        SalesLine."Unit Cost",GetRollupCost(AssemblyHeader) / AssemblyHeader.Quantity,GLSetup."Unit-Amount Rounding Precision",
        STRSUBSTNO(WrongUnitValueMsg,SalesLine.FIELDCAPTION("Unit Cost")));
Member of Lib.Library - Assembly


RollUpAsmPrice@71 Method

The procedure RollUpAsmPrice is available in codeunit 132207.

Syntax

RollUpAsmPrice@71(
    VAR SalesLine@1000 : Record 37 SalesLine //Reference parameter of type Record
);

Parameters

SalesLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Roll, Up, Asm, Price.

For a clarification about how this function works, refer to the code listed below.

      SalesLine.RollupAsmPrice;

Example

The below example is extracted from the test automation codeunit 137096 to show one way of using this function.

      // [FEATURE] [Sales Order]
      // [SCENARIO 379342] Unit Price in Sales Order Line after the RollupPrice function is run should be calculated on Assembly Lines only.
      Initialize;

      // [GIVEN] Assembled Item with Assembly Policy = Assemble-to-Order.
      // [GIVEN] List of BOM Components with Sales and Resource prices.
      // [GIVEN] Sales Order Line with Quantity > "Qty. Assemble to Order".
      QtyToAssembleToOrder := LibraryRandom.RandInt(1000);
      OrderQty := QtyToAssembleToOrder + LibraryRandom.RandInt(1000);
      CreateAssembledItemAndBOMComponentsWithUnitCostAndUnitPrice(Item);
      CreateSalesAndResourcePricesOnCompList(Item."No.");
      TCRollupCost(Item,SalesLine,AssemblyHeader,'',SalesDocumentType::Order,QtyToAssembleToOrder,OrderQty);

      // [WHEN] Run Roll-up Price function.
      LibraryAssembly.RollUpAsmPrice(SalesLine);

      // [THEN] Unit Price in Sales Line is nearly equal to Unit Price of Assembled Item.
      Assert.AreNearlyEqual(
        SalesLine."Unit Price",GetRollupPrice(AssemblyHeader) / AssemblyHeader.Quantity,GLSetup."Unit-Amount Rounding Precision",
        STRSUBSTNO(WrongUnitValueMsg,SalesLine.FIELDCAPTION("Unit Price")));
Member of Lib.Library - Assembly


SetLinkToLines@182 Method

The procedure SetLinkToLines is available in codeunit 132207.

Syntax

SetLinkToLines@182(
    AsmHeader@1000 : Record 900 AsmHeader, //Input parameter of type Record
    VAR AsmLine@1001 : Record 901 AsmLine //Reference parameter of type Record
);

Parameters

AsmHeader
Input parameter of type Record
AsmLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Set, Link, To, Lines.

For a clarification about how this function works, refer to the code listed below.

      AsmLine.SETRANGE("Document Type",AsmHeader."Document Type");
      AsmLine.SETRANGE("Document No.",AsmHeader."No.");

Example

The below example is extracted from the test automation codeunit 137104 to show one way of using this function.

      // TC-BINPOST
      // There is enough item in inventory, but there is not enough item in ToBin.
      // Test checks that partial posting works fine after reducing Qty To Assemble to smallest avaliable
      Initialize;
      AssignBinCodesBM;

      NoOfItems := LibraryRandom.RandIntInRange(1,3);
      LibraryAssembly.CreateAssemblyOrder(AssemblyHeader,WorkDate2,LocationBM.Code,NoOfItems);

      NotEnoughNo := LibraryRandom.RandIntInRange(1,NoOfItems) - 1;
      AddCompInventoryNotEnough(AssemblyHeader,NotEnoughNo,NotEnoughItemNo,100,Qtys,FALSE,LocationToBinCode);

      LibraryAssembly.SetLinkToLines(AssemblyHeader,AssemblyLine);
      LibraryAssembly.EarliestAvailableDate(AssemblyHeader,AssemblyLine,AssembledQty,EarliestDate);
      UpdateQtysConsume(AssemblyHeader,TempAssemblyLine,AssembledQty,Qtys);
      AssembledQty := AssemblyHeader."Quantity to Assemble";

      LibraryAssembly.PostAssemblyHeader(AssemblyHeader,'');

      // Verify.
      LibraryAssembly.VerifyILEs(TempAssemblyLine,AssemblyHeader,AssembledQty);
      LibraryAssembly.VerifyItemRegister(AssemblyHeader);

      TempAssemblyLine.RESET;
      TempAssemblyLine.SETRANGE(Type,TempAssemblyLine.Type::Item);
      VerifyWarehouseEntries(
        AssemblyHeader,TempAssemblyLine,AssembledQty,TRUE,TempAssemblyLine.COUNT + 1,AssemblyHeader."Posting Date");

      // Veryfy bin content for header assembly item
      VerifyBinContent(AssemblyHeader."Location Code",AssemblyHeader."Bin Code",AssemblyHeader."Item No.",AssembledQty);

      // Verify bin contents for components
      Assert.AreEqual(NoOfItems,TempAssemblyLine.COUNT,'Too many component item ' + AssemblyHeader."Item No." + ' in a bin content');
      i := 1;
      TempAssemblyLine.FINDSET;
      REPEAT
        VerifyBinContent(TempAssemblyLine."Location Code",TempAssemblyLine."Bin Code",
          TempAssemblyLine."No.",Qtys[i] - TempAssemblyLine."Quantity to Consume");
        i += 1;
      UNTIL TempAssemblyLine.NEXT = 0;
Member of Lib.Library - Assembly


SetStockoutWarning@97 Method

The procedure SetStockoutWarning is available in codeunit 132207.

Syntax

SetStockoutWarning@97(
    StockoutWarning@1001 : Boolean StockoutWarning //Input parameter of type Boolean
);

Parameters

StockoutWarning
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, Stockout, Warning.

For a clarification about how this function works, refer to the code listed below.

      AssemblySetup.GET;
      AssemblySetup.VALIDATE("Stockout Warning",StockoutWarning);
      AssemblySetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134386 to show one way of using this function.

      LibrarySales.SetStockoutWarning(NewStockOutWarning);
      LibrarySales.SetCreditWarnings(CreditWarning);
Member of Lib.Library - Assembly


SetupAssemblyData@2 Method

The procedure SetupAssemblyData is available in codeunit 132207.

Syntax

SetupAssemblyData@2(
    VAR AssemblyHeader@1001 : Record 900 AssemblyHeader, //Reference parameter of type Record
    DueDate@1012 : Date DueDate, //Input parameter of type Date
    ParentCostingMethod@1003 : Option ParentCostingMethod, //Input parameter of type Option
    CompCostingMethod@1004 : Option CompCostingMethod, //Input parameter of type Option
    ReplenishmentSystem@1011 : Option ReplenishmentSystem, //Input parameter of type Option
    LocationCode@1008 : Code[10] LocationCode, //Input parameter of type Code
    UpdateUnitCost@1009 : Boolean UpdateUnitCost //Input parameter of type Boolean
);

Parameters

AssemblyHeader
Reference parameter of type Record
DueDate
Input parameter of type Date
ParentCostingMethod
Input parameter of type Option
CompCostingMethod
Input parameter of type Option
ReplenishmentSystem
Input parameter of type Option
LocationCode
Input parameter of type Code
UpdateUnitCost
Input parameter of type Boolean

Remarks

The relevant search keywords are: Setup, Assembly, Data.

For a clarification about how this function works, refer to the code listed below.

      SetupAssemblyItem(Item,ParentCostingMethod,CompCostingMethod,ReplenishmentSystem,LocationCode,UpdateUnitCost,1,1,1,1);

      CreateAssemblyHeader(AssemblyHeader,DueDate,Item."No.",LocationCode,LibraryRandom.RandDec(10,2),'');

Example

The below example is extracted from the test automation codeunit 137091 to show one way of using this function.

      // Setup.
      Initialize;
      StdCostLevel := 1;
      LibraryAssembly.SetupAssemblyData(AssemblyHeader,WorkDate2,Item."Costing Method"::Standard,Item."Costing Method"::Standard,
        Item."Replenishment System"::Assembly,'',FALSE);
      Item.GET(AssemblyHeader."Item No.");

      // Exercise.
      AssemblyHeader.VALIDATE("Item No.",Item."No.");
      AssemblyHeader.MODIFY(TRUE);
      COMMIT; // added as ASSERTERROR rolls back all changes made as yet- and therefore asm header cannot be verified.
      ASSERTERROR Item.DELETE(TRUE);

      // Validate.
      VerifyOrderLines(AssemblyHeader."No.",FALSE);
      Assert.AreEqual(STRSUBSTNO(ErrorDeleteItem,Item."No."),GETLASTERRORTEXT,'Unexpected error message when deleting item.');
      CLEARLASTERROR;
Member of Lib.Library - Assembly


SetupAssemblyItem@88 Method

The procedure SetupAssemblyItem is available in codeunit 132207.

Syntax

SetupAssemblyItem@88(
    VAR Item@1001 : Record 27 Item, //Reference parameter of type Record
    ParentCostingMethod@1003 : Option ParentCostingMethod, //Input parameter of type Option
    CompCostingMethod@1004 : Option CompCostingMethod, //Input parameter of type Option
    ReplenishmentSystem@1011 : Option ReplenishmentSystem, //Input parameter of type Option
    LocationCode@1008 : Code[10] LocationCode, //Input parameter of type Code
    UpdateUnitCost@1009 : Boolean UpdateUnitCost, //Input parameter of type Boolean
    NoOfItems@1014 : Integer NoOfItems, //Input parameter of type Integer
    NoOfResources@1013 : Integer NoOfResources, //Input parameter of type Integer
    NoOfTexts@1000 : Integer NoOfTexts, //Input parameter of type Integer
    QtyPerFactor@1015 : Integer QtyPerFactor //Input parameter of type Integer
);

Parameters

Item
Reference parameter of type Record
ParentCostingMethod
Input parameter of type Option
CompCostingMethod
Input parameter of type Option
ReplenishmentSystem
Input parameter of type Option
LocationCode
Input parameter of type Code
UpdateUnitCost
Input parameter of type Boolean
NoOfItems
Input parameter of type Integer
NoOfResources
Input parameter of type Integer
NoOfTexts
Input parameter of type Integer
QtyPerFactor
Input parameter of type Integer

Remarks

The relevant search keywords are: Setup, Assembly, Item.

For a clarification about how this function works, refer to the code listed below.

      SetupPostingToGL(GenProdPostingGr,AsmInvtPostingGr,CompInvtPostingGr,LocationCode);
      CreateItem(Item,ParentCostingMethod,ReplenishmentSystem,GenProdPostingGr,AsmInvtPostingGr);
      AddEntityDimensions(AssemblyLine.Type::Item,Item."No.");
      CreateAssemblyList(
        CompCostingMethod,Item."No.",TRUE,NoOfItems,NoOfResources,NoOfTexts,QtyPerFactor,GenProdPostingGr,CompInvtPostingGr);

      IF UpdateUnitCost THEN BEGIN
        CalculateStandardCost.CalcItem(Item."No.",TRUE);
        CalculateStandardCost.CalcAssemblyItemPrice(Item."No.");
      END;

Example

The below example is extracted from the test automation codeunit 134152 to show one way of using this function.

      WITH Item DO BEGIN
        LibraryAssembly.SetupAssemblyItem(
          Item,"Costing Method"::Standard,"Costing Method"::Standard,"Replenishment System"::Assembly,
          '',FALSE,LibraryRandom.RandInt(5),LibraryRandom.RandInt(5),
          LibraryRandom.RandInt(5),LibraryRandom.RandInt(5));
        VALIDATE("Assembly Policy","Assembly Policy"::"Assemble-to-Order");
        MODIFY(TRUE);
      END;
Member of Lib.Library - Assembly


SetupComponents@25 Method

The procedure SetupComponents is available in codeunit 132207.

Syntax

SetupComponents@25(
    VAR TempItem@1000 : TEMPORARY Record 27 TempItem, //Reference Temporary parameter of type Record
    VAR TempResource@1001 : TEMPORARY Record 156 TempResource, //Reference Temporary parameter of type Record
    CostingMethod@1004 : Option CostingMethod, //Input parameter of type Option
    NoOfItems@1002 : Integer NoOfItems, //Input parameter of type Integer
    NoOfResources@1003 : Integer NoOfResources, //Input parameter of type Integer
    GenProdPostingGroup@1008 : Code[10] GenProdPostingGroup, //Input parameter of type Code
    InventoryPostingGroup@1009 : Code[10] InventoryPostingGroup //Input parameter of type Code
);

Parameters

TempItem
Reference Temporary parameter of type Record
TempResource
Reference Temporary parameter of type Record
CostingMethod
Input parameter of type Option
NoOfItems
Input parameter of type Integer
NoOfResources
Input parameter of type Integer
GenProdPostingGroup
Input parameter of type Code
InventoryPostingGroup
Input parameter of type Code

Remarks

The relevant search keywords are: Setup, Components.

For a clarification about how this function works, refer to the code listed below.

      TempItem.DELETEALL;
      TempResource.DELETEALL;

      FOR CompCount := 1 TO NoOfItems DO BEGIN
        CLEAR(Item);
        CreateItem(Item,CostingMethod,Item."Replenishment System"::Purchase,GenProdPostingGroup,InventoryPostingGroup);
        AddEntityDimensions(AssemblyLine.Type::Item,Item."No.");
        TempItem := Item;
        TempItem.INSERT;
      END;

      FOR CompCount := 1 TO NoOfResources DO BEGIN
        CreateResource(Resource,TRUE,GenProdPostingGroup);
        AddEntityDimensions(AssemblyLine.Type::Resource,Resource."No.");
        TempResource := Resource;
        TempResource.INSERT;
      END;

Example

There are no examples available.
Member of Lib.Library - Assembly


SetupItemJournal@138 Method

The procedure SetupItemJournal is available in codeunit 132207.

Syntax

SetupItemJournal@138(
    VAR ItemJournalTemplate@1000 : Record 82 ItemJournalTemplate, //Reference parameter of type Record
    VAR ItemJournalBatch@1001 : Record 233 ItemJournalBatch //Reference parameter of type Record
);

Parameters

ItemJournalTemplate
Reference parameter of type Record
ItemJournalBatch
Reference parameter of type Record

Remarks

The relevant search keywords are: Setup, Item, Journal.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(ItemJournalTemplate);
      ItemJournalTemplate.INIT;
      LibraryInventory.SelectItemJournalTemplateName(ItemJournalTemplate,ItemJournalTemplate.Type::Item);

      CLEAR(ItemJournalBatch);
      ItemJournalBatch.INIT;
      LibraryInventory.SelectItemJournalBatchName(ItemJournalBatch,ItemJournalTemplate.Type,ItemJournalTemplate.Name);
      IF ItemJournalBatch."No. Series" = '' THEN BEGIN
        LibraryUtility.CreateNoSeries(NoSeries,TRUE,TRUE,TRUE);
        LibraryUtility.CreateNoSeriesLine(NoSeriesLine,NoSeries.Code,'','');
        ItemJournalBatch.VALIDATE("No. Series",NoSeries.Code);
        ItemJournalBatch.MODIFY(TRUE);
      END;

Example

The below example is extracted from the test automation codeunit 137089 to show one way of using this function.

      ItemJournalLine.DELETEALL;

      LibraryAssembly.SetupItemJournal(ItemJournalTemplate,ItemJournalBatch);
      LibraryInventory.CreateItemJournalLine(
        ItemJournalLine,ItemJournalTemplate.Name,
        ItemJournalBatch.Name,
        ItemJournalLine."Entry Type"::"Positive Adjmt.",
        Item."No.",
        Quantity);

      ItemJournalLine.VALIDATE(
        "Gen. Bus. Posting Group",FindGenBusPostingGroup(ItemJournalLine."Gen. Prod. Posting Group"));
      ItemJournalLine.VALIDATE("Location Code",LocationCode);
      ItemJournalLine.VALIDATE("Variant Code",VariantCode);
      ItemJournalLine.MODIFY(TRUE);

      LibraryInventory.PostItemJournalLine(ItemJournalLine."Journal Template Name",ItemJournalLine."Journal Batch Name");
Member of Lib.Library - Assembly


SetupPostingToGL@177 Method

The procedure SetupPostingToGL is available in codeunit 132207.

Syntax

SetupPostingToGL@177(
    VAR GenProdPostingGr@1008 : Code[10] GenProdPostingGr, //Reference parameter of type Code
    VAR AsmInvtPostingGr@1011 : Code[10] AsmInvtPostingGr, //Reference parameter of type Code
    VAR CompInvtPostingGr@1012 : Code[10] CompInvtPostingGr, //Reference parameter of type Code
    LocationCode@1006 : Code[10] LocationCode //Input parameter of type Code
);

Parameters

GenProdPostingGr
Reference parameter of type Code
AsmInvtPostingGr
Reference parameter of type Code
CompInvtPostingGr
Reference parameter of type Code
LocationCode
Input parameter of type Code

Remarks

The relevant search keywords are: Setup, Posting, To, General Ledger.

For a clarification about how this function works, refer to the code listed below.

      // Create Inventory posting setup accounts.
      // Assembly Item Inventory.
      CreateGLAccount(GLAccount,GLAccount."Income/Balance"::"Balance Sheet",'Output Inventory');
      // Material Variance.
      CreateGLAccount(GLAccount2,GLAccount."Income/Balance"::"Income Statement",'Material Variance');
      // Capacity Variance.
      CreateGLAccount(GLAccount3,GLAccount."Income/Balance"::"Income Statement",'Capacity Variance');
      // Capacity Overhead Variance.
      CreateGLAccount(GLAccount4,GLAccount."Income/Balance"::"Income Statement",'Capacity Overhead Variance');
      // Mfg. Overhead Variance.
      CreateGLAccount(GLAccount5,GLAccount."Income/Balance"::"Income Statement",'Mfg. Overhead Variance');
      // Inventory account (Interim)
      CreateGLAccount(GLAccount6,GLAccount."Income/Balance"::"Balance Sheet",'Inventory Account (Interim)');

      // Create Inventory Posting Group for Assembly Item.
      LibraryInventory.CreateInventoryPostingGroup(InventoryPostingGroup);
      AsmInvtPostingGr := InventoryPostingGroup.Code;

      // Create Inventory Posting Setup for Assembly Item.
      CreateInvtPostingSetup(InvtPostingSetup,LocationCode,InventoryPostingGroup.Code,GLAccount."No.",GLAccount2."No.",
        GLAccount3."No.",GLAccount4."No.",GLAccount5."No.",GLAccount6."No.");

      // Component Inventory Account.
      CreateGLAccount(GLAccount,GLAccount."Income/Balance"::"Balance Sheet",'Component Item Inventory');

      // Create Inventory Posting Group for Component.
      LibraryInventory.CreateInventoryPostingGroup(InventoryPostingGroup);
      CompInvtPostingGr := InventoryPostingGroup.Code;

      // Create Inventory Posting Setup for Assembly Item.
      CreateInvtPostingSetup(InvtPostingSetup,LocationCode,InventoryPostingGroup.Code,GLAccount."No.",GLAccount2."No.",
        GLAccount3."No.",GLAccount4."No.",GLAccount5."No.",GLAccount6."No.");

      LibraryERM.FindGeneralPostingSetupInvtToGL(GeneralPostingSetup);
      GenProdPostingGr := GeneralPostingSetup."Gen. Prod. Posting Group";

Example

The below example is extracted from the test automation codeunit 137092 to show one way of using this function.

      Initialize;

      LibraryAssembly.SetupPostingToGL(GenProdPostingGr,AsmInvtPostingGr,CompInvtPostingGr,'');
      LibraryAssembly.CreateItem(Item,Item."Costing Method"::Standard,Item."Replenishment System"::Assembly,'','');
      LibraryAssembly.CreateAssemblyList(Item."Costing Method"::Standard,Item."No.",TRUE,1,1,0,1,GenProdPostingGr,CompInvtPostingGr);

      ItemNo := Item."No.";
      Item.VALIDATE("Unit Cost",3);
      Item.VALIDATE("Indirect Cost %",100);
      Item.VALIDATE("Overhead Rate",5);
      Item.VALIDATE("Single-Level Capacity Cost",7);
      Item.VALIDATE("Single-Level Cap. Ovhd Cost",11);
      Item.MODIFY;

      BOMComponent.SETRANGE("Parent Item No.",Item."No.");
      IF BOMComponent.FINDSET THEN
        REPEAT
          CASE BOMComponent.Type OF
            BOMComponent.Type::Item:
              BEGIN
                Item.GET(BOMComponent."No.");
                Item.VALIDATE("Standard Cost",13);
                Item.VALIDATE("Unit Price",17);
                Item.MODIFY(TRUE);
              END;
            BOMComponent.Type::Resource:
              BEGIN
                Resource.GET(BOMComponent."No.");
                Resource.VALIDATE("Unit Price",19);
                Resource.VALIDATE("Direct Unit Cost",23);
                Resource.VALIDATE("Indirect Cost %",100);
                Resource.MODIFY(TRUE);
              END
          END;
        UNTIL BOMComponent.NEXT = 0;
      BOMComponent.MODIFYALL("Quantity per",1);

      LibraryAssembly.CreateAssemblyHeader(AssemblyHeader,WorkDate2,ItemNo,'',1,'');
      LibraryAssembly.AddCompInventory(AssemblyHeader,WorkDate2,0);
Member of Lib.Library - Assembly


SetupWarehouseJournal@35 Method

The procedure SetupWarehouseJournal is available in codeunit 132207.

Syntax

SetupWarehouseJournal@35(
    VAR WarehouseJournalTemplate@1000 : Record 7309 WarehouseJournalTemplate, //Reference parameter of type Record
    VAR WarehouseJournalBatch@1001 : Record 7310 WarehouseJournalBatch, //Reference parameter of type Record
    LocationCode@1002 : Code[10] LocationCode //Input parameter of type Code
);

Parameters

WarehouseJournalTemplate
Reference parameter of type Record
WarehouseJournalBatch
Reference parameter of type Record
LocationCode
Input parameter of type Code

Remarks

The relevant search keywords are: Setup, Warehouse, Journal.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(WarehouseJournalTemplate);
      WarehouseJournalTemplate.INIT;
      LibraryWarehouse.SelectWhseJournalTemplateName(WarehouseJournalTemplate,WarehouseJournalTemplate.Type::Item);
      WarehouseJournalTemplate.VALIDATE("No. Series",LibraryUtility.GetGlobalNoSeriesCode);
      WarehouseJournalTemplate.MODIFY(TRUE);

      CLEAR(WarehouseJournalBatch);
      WarehouseJournalBatch.INIT;
      LibraryWarehouse.SelectWhseJournalBatchName(WarehouseJournalBatch,WarehouseJournalTemplate.Type,WarehouseJournalTemplate.Name,
        LocationCode);
      WarehouseJournalBatch.VALIDATE("No. Series",LibraryUtility.GetGlobalNoSeriesCode);
      WarehouseJournalBatch.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137106 to show one way of using this function.

      // [FEATURE] [Pick]
      // [SCENARIO 207772] Pick line with Quantity = 0 is not created when first available bin content is assigned to the same warehouse pick

      Initialize;

      // [GIVEN] Item "C" is an assembly component for item "P", qty. required to assembly one item "I" is 200
      // [GIVEN] Component item "C" has an additional unit of measure "BOX", base UoM is "PCS", qty. per unit of measure is 200
      CreateItems(Tracking::Untracked);
      QtyPerUoM := LibraryRandom.RandIntInRange(100,200);
      QtyToConsume := LibraryRandom.RandInt(5);
      QtyToSell := LibraryRandom.RandIntInRange(6,10);
      LibraryInventory.CreateItemUnitOfMeasureCode(ItemUnitOfMeasure,CompItem."No.",QtyPerUoM);
      LibraryManufacturing.CreateBOMComponent(
        BOMComponent,KitItem."No.",BOMComponent.Type::Item,CompItem."No.",QtyPerUoM,CompItem."Base Unit of Measure");

      // [GIVEN] Purchase and put-away 1 box of component item "C" into a bin "B2"
      FindPutAwayPickZone(Zone,LocationWMS.Code);
      LibraryAssembly.SetupWarehouseJournal(WarehouseJournalTemplate,WarehouseJournalBatch,LocationWMS.Code);
      LibraryWarehouse.FindBin(Bin,LocationWMS.Code,Zone.Code,2);
      CreateWhseJournalLine(WarehouseJournalBatch,Bin,CompItem."No.",QtyToConsume,ItemUnitOfMeasure.Code);
      // [GIVEN] Purchase and put-away 3 boxes of component item "C" into a bin "B1"
      LibraryWarehouse.FindBin(Bin,LocationWMS.Code,Zone.Code,1);
      CreateWhseJournalLine(WarehouseJournalBatch,Bin,CompItem."No.",QtyToSell,ItemUnitOfMeasure.Code);

      LibraryWarehouse.RegisterWhseJournalLine(
        WarehouseJournalBatch."Journal Template Name",WarehouseJournalBatch.Name,LocationWMS.Code,TRUE);
      LibraryWarehouse.PostWhseAdjustment(CompItem);

      // [GIVEN] Create a sales order with 2 lines
      // [GIVEN] 1st line - 1 item "P" which requires 1 box of components to assemble
      // [GIVEN] 2nd line - 2 boxes of item "C"
      LibrarySales.CreateSalesDocumentWithItem(
        SalesHeader,SalesLine,SalesHeader."Document Type"::Order,LibrarySales.CreateCustomerNo,KitItem."No.",QtyToConsume,
        LocationWMS.Code,WorkDate2);
      SalesLine.VALIDATE("Qty. to Assemble to Order",SalesLine.Quantity);
      SalesLine.MODIFY(TRUE);

      LibrarySales.CreateSalesLine(SalesLine,SalesHeader,SalesLine.Type::Item,CompItem."No.",QtyToSell);
      SalesLine.VALIDATE("Unit of Measure Code",ItemUnitOfMeasure.Code);
      SalesLine.MODIFY(TRUE);

      LibrarySales.ReleaseSalesDocument(SalesHeader);
      LibraryWarehouse.CreateWhseShipmentFromSO(SalesHeader);

      // [WHEN] Create warehouse shipment and pick from the sales order
      CreatePickFromSalesOrder(SalesHeader);

      // [THEN] Total quantity to pick for item "C" is 4 boxes
      // [THEN] There are no pick lines with Quantity = 0
      WarehouseActivityLine.SETRANGE("Item No.",CompItem."No.");
      WarehouseActivityLine.SETRANGE("Action Type",WarehouseActivityLine."Action Type"::Take);
      WarehouseActivityLine.SETRANGE("Unit of Measure Code",ItemUnitOfMeasure.Code);
      WarehouseActivityLine.SETRANGE(Quantity,0);
      Assert.RecordIsEmpty(WarehouseActivityLine);

      WarehouseActivityLine.SETRANGE(Quantity);
      WarehouseActivityLine.CALCSUMS(Quantity);
      WarehouseActivityLine.TESTFIELD(Quantity,QtyToConsume + QtyToSell);
Member of Lib.Library - Assembly


UndoPostedAssembly@74 Method

The procedure UndoPostedAssembly is available in codeunit 132207.

Syntax

UndoPostedAssembly@74(
    VAR PostedAssemblyHeader@1000 : Record 910 PostedAssemblyHeader, //Reference parameter of type Record
    RestoreAO@1003 : Boolean RestoreAO, //Input parameter of type Boolean
    ExpectedError@1002 : Text[1024] ExpectedError //Input parameter of type Text
);

Parameters

PostedAssemblyHeader
Reference parameter of type Record
RestoreAO
Input parameter of type Boolean
ExpectedError
Input parameter of type Text

Remarks

The relevant search keywords are: Undo, Posted, Assembly.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(AsmPostCtrl);
      IF ExpectedError = '' THEN
        AsmPostCtrl.Undo(PostedAssemblyHeader,RestoreAO)
      ELSE BEGIN
        ASSERTERROR AsmPostCtrl.Undo(PostedAssemblyHeader,RestoreAO);
        Assert.IsTrue(STRPOS(GETLASTERRORTEXT,ExpectedError) > 0,'Actual:' + GETLASTERRORTEXT);
        CLEARLASTERROR;
      END;

Example

The below example is extracted from the test automation codeunit 137093 to show one way of using this function.

      // [FEATURE] [Undo Assembly Order]
      // [SCENARIO] "Able To Assemble" on page line is calculated correctly after Undo of posted Assembly Order
      Initialize;

      // [GIVEN] Create the assembled Item "X"
      LibraryInventory.CreateItem(Item);
      // [GIVEN] Add Component "C" , "Quantity per" = "Qp"
      AddComponent(Item,BOMComponent);
      SetRandComponentQuantityPer(BOMComponent);
      // [GIVEN] Add Component to inventory, enough to assemble "QA" psc, Quantity = ("QA" * "Qp")
      QtyOnAssemble := RandInt;
      AddInventory(BOMComponent."No.",'','',BOMComponent."Quantity per" * QtyOnAssemble);
      // [GIVEN] Create Assembly Order for Item "X", Quantity = "QA"
      CreateAssemblyOrder(AssemblyHeader,Item."No.",'','',WorkDate2,QtyOnAssemble);
      // [GIVEN] Post half Assembly Order
      PostAssemblyOrderQty(AssemblyHeader,QtyOnAssemble / 2);

      // [GIVEN] Undo Assembly Order and delete it
      FindPostedAssemblyHeaderNotReversed(PostedAssemblyHeader,AssemblyHeader."No.");
      LibraryAssembly.UndoPostedAssembly(PostedAssemblyHeader,TRUE,'');
      AssemblyHeader.GET(AssemblyHeader."Document Type",AssemblyHeader."No.");
      AssemblyHeader.DELETE(TRUE);

      // [WHEN] Create new Assembly Order for Item "X", Quantity = ("QA" + 1) to cause Availability page
      CreateAssemblyOrder(AssemblyHeader,Item."No.",'','',WorkDate2,QtyOnAssemble + 1);

      // [THEN] Assembly Availability page is shown: "Expected Inventory" = ("QA" * "Qp"), "Able To Assemble" = "QA"
      ExpAsmAvailTestBuf.INIT;
      ExpAsmAvailTestBuf."Document Line No." := 1;
      ExpAsmAvailTestBuf.VALIDATE("Expected Inventory",BOMComponent."Quantity per" * QtyOnAssemble);
      ExpAsmAvailTestBuf.VALIDATE("Able To Assemble",QtyOnAssemble);
      AssertAvailabilityLine(AssemblyHeader,ExpAsmAvailTestBuf);
Member of Lib.Library - Assembly


UpdateAssemblyHeader@91 Method

The procedure UpdateAssemblyHeader is available in codeunit 132207.

Syntax

UpdateAssemblyHeader@91(
    VAR AssemblyHeader@1000 : Record 900 AssemblyHeader, //Reference parameter of type Record
    FieldNo@1001 : Integer FieldNo, //Input parameter of type Integer
    Value@1004 : Variant Value //Input parameter of type Variant
);

Parameters

AssemblyHeader
Reference parameter of type Record
FieldNo
Input parameter of type Integer
Value
Input parameter of type Variant

Remarks

The relevant search keywords are: Update, Assembly, Header.

For a clarification about how this function works, refer to the code listed below.

      RecRef.GETTABLE(AssemblyHeader);
      FieldRef := RecRef.FIELD(FieldNo);
      FieldRef.VALIDATE(Value);
      RecRef.SETTABLE(AssemblyHeader);
      AssemblyHeader.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137107 to show one way of using this function.

      SetupAbleToMake(BOMBuffer,FALSE,FALSE,SupplyType::Purchase,BottleneckFactor,ShowTotalAvailability,'<0D>',1,1,DirectAvailFactor);
      EVALUATE(DueDateDelayDateFormula,DueDateDelay);

      IF DirectAvailFactor <> 0 THEN
        AssemblyQty := RANDOM(ROUND(BOMBuffer."Able to Make Top Item" * DirectAvailFactor,1,'<'))
      ELSE
        AssemblyQty := ROUND(BOMBuffer."Able to Make Top Item",1,'<') + AvailabilityCorrection;

      LibraryAssembly.CreateAssemblyHeader(
        AssemblyHeader,CALCDATE(DueDateDelayDateFormula,WORKDATE),BOMBuffer."No.",BOMBuffer."Location Code",
        AssemblyQty,BOMBuffer."Variant Code");
      FindAssemblyLine(AssemblyLine,AssemblyHeader);
      LibraryWarehouse.CreateLocation(Location);

      CASE AsmOrderFilterType OF
        FilterType::"Header Location":
          LibraryAssembly.UpdateAssemblyHeader(AssemblyHeader,AssemblyHeader.FIELDNO("Location Code"),Location.Code);
        FilterType::"Header Variant":
          LibraryAssembly.UpdateAssemblyHeader(AssemblyHeader,AssemblyHeader.FIELDNO("Variant Code"),'');
        FilterType::"Component Location":
          LibraryAssembly.UpdateAssemblyLine(AssemblyLine,AssemblyLine.FIELDNO("Location Code"),Location.Code);
        FilterType::"Component Variant":
          LibraryAssembly.UpdateAssemblyLine(AssemblyLine,AssemblyLine.FIELDNO("Variant Code"),'');
      END;

      AbleToMake := BOMBuffer."Able to Make Top Item" - AssemblyQty;
      InitialAbleToMake := BOMBuffer."Able to Make Top Item";
      IF AsmOrderFilterType = FilterType::"Component Location" THEN
        AbleToMake := 0;

      IF DueDateDelay <> '<0D>' THEN BEGIN
        InitialAbleToMake := 0;
        AbleToMake := 0;
      END;

      // Exercise.
      ItemFilter.SETFILTER("Location Filter",'%1',AssemblyHeader."Location Code");
      CalculateBOMTree.SetItemFilter(ItemFilter);
      CalculateBOMTree.SetShowTotalAvailability(ShowTotalAvailability);
      CalculateBOMTree.GenerateTreeForAsm(AssemblyHeader,BOMBuffer,TreeType::Availability);

      // Verify: Check the top item.
      VerifyTopItem(BOMBuffer,AssemblyHeader."Item No.",AssemblyQty,AbleToMake,ShowTotalAvailability);
      VerifyTreeAsmOrder(
        BOMBuffer,ShowTotalAvailability,BottleneckFactor,InitialAbleToMake / BottleneckFactor,1,DirectAvailFactor,AssemblyHeader,
        AsmOrderFilterType);
Member of Lib.Library - Assembly


UpdateAssemblyLine@92 Method

The procedure UpdateAssemblyLine is available in codeunit 132207.

Syntax

UpdateAssemblyLine@92(
    VAR AssemblyLine@1000 : Record 901 AssemblyLine, //Reference parameter of type Record
    FieldNo@1001 : Integer FieldNo, //Input parameter of type Integer
    Value@1004 : Variant Value //Input parameter of type Variant
);

Parameters

AssemblyLine
Reference parameter of type Record
FieldNo
Input parameter of type Integer
Value
Input parameter of type Variant

Remarks

The relevant search keywords are: Update, Assembly, Line.

For a clarification about how this function works, refer to the code listed below.

      RecRef.GETTABLE(AssemblyLine);
      FieldRef := RecRef.FIELD(FieldNo);
      FieldRef.VALIDATE(Value);
      RecRef.SETTABLE(AssemblyLine);
      AssemblyLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137107 to show one way of using this function.

      SetupAbleToMake(BOMBuffer,FALSE,FALSE,SupplyType::Purchase,BottleneckFactor,ShowTotalAvailability,'<0D>',1,1,DirectAvailFactor);
      EVALUATE(DueDateDelayDateFormula,DueDateDelay);

      IF DirectAvailFactor <> 0 THEN
        AssemblyQty := RANDOM(ROUND(BOMBuffer."Able to Make Top Item" * DirectAvailFactor,1,'<'))
      ELSE
        AssemblyQty := ROUND(BOMBuffer."Able to Make Top Item",1,'<') + AvailabilityCorrection;

      LibraryAssembly.CreateAssemblyHeader(
        AssemblyHeader,CALCDATE(DueDateDelayDateFormula,WORKDATE),BOMBuffer."No.",BOMBuffer."Location Code",
        AssemblyQty,BOMBuffer."Variant Code");
      FindAssemblyLine(AssemblyLine,AssemblyHeader);
      LibraryWarehouse.CreateLocation(Location);

      CASE AsmOrderFilterType OF
        FilterType::"Header Location":
          LibraryAssembly.UpdateAssemblyHeader(AssemblyHeader,AssemblyHeader.FIELDNO("Location Code"),Location.Code);
        FilterType::"Header Variant":
          LibraryAssembly.UpdateAssemblyHeader(AssemblyHeader,AssemblyHeader.FIELDNO("Variant Code"),'');
        FilterType::"Component Location":
          LibraryAssembly.UpdateAssemblyLine(AssemblyLine,AssemblyLine.FIELDNO("Location Code"),Location.Code);
        FilterType::"Component Variant":
          LibraryAssembly.UpdateAssemblyLine(AssemblyLine,AssemblyLine.FIELDNO("Variant Code"),'');
      END;

      AbleToMake := BOMBuffer."Able to Make Top Item" - AssemblyQty;
      InitialAbleToMake := BOMBuffer."Able to Make Top Item";
      IF AsmOrderFilterType = FilterType::"Component Location" THEN
        AbleToMake := 0;

      IF DueDateDelay <> '<0D>' THEN BEGIN
        InitialAbleToMake := 0;
        AbleToMake := 0;
      END;

      // Exercise.
      ItemFilter.SETFILTER("Location Filter",'%1',AssemblyHeader."Location Code");
      CalculateBOMTree.SetItemFilter(ItemFilter);
      CalculateBOMTree.SetShowTotalAvailability(ShowTotalAvailability);
      CalculateBOMTree.GenerateTreeForAsm(AssemblyHeader,BOMBuffer,TreeType::Availability);

      // Verify: Check the top item.
      VerifyTopItem(BOMBuffer,AssemblyHeader."Item No.",AssemblyQty,AbleToMake,ShowTotalAvailability);
      VerifyTreeAsmOrder(
        BOMBuffer,ShowTotalAvailability,BottleneckFactor,InitialAbleToMake / BottleneckFactor,1,DirectAvailFactor,AssemblyHeader,
        AsmOrderFilterType);
Member of Lib.Library - Assembly


UpdateAssemblySetup@18 Method

The procedure UpdateAssemblySetup is available in codeunit 132207.

Syntax

UpdateAssemblySetup@18(
    VAR AssemblySetup@1004 : Record 905 AssemblySetup, //Reference parameter of type Record
    LocationCode@1000 : Code[10] LocationCode, //Input parameter of type Code
    DimensionsFrom@1002 : Option DimensionsFrom, //Input parameter of type Option
    PostedOrdersNo@1003 : Code[10] PostedOrdersNo //Input parameter of type Code
);

Parameters

AssemblySetup
Reference parameter of type Record
LocationCode
Input parameter of type Code
DimensionsFrom
Input parameter of type Option
PostedOrdersNo
Input parameter of type Code

Remarks

The relevant search keywords are: Update, Assembly, Setup.

For a clarification about how this function works, refer to the code listed below.

      AssemblySetup.GET;
      IF AssemblySetup."Assembly Order Nos." = '' THEN
        AssemblySetup.VALIDATE("Assembly Order Nos.",
          LibraryUtility.GetGlobalNoSeriesCode);
      AssemblySetup.VALIDATE("Copy Component Dimensions from",DimensionsFrom);
      AssemblySetup.VALIDATE("Default Location for Orders",LocationCode);
      AssemblySetup.VALIDATE("Posted Assembly Order Nos.",PostedOrdersNo);
      AssemblySetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137091 to show one way of using this function.

      // Initialize setup.
      IF isInitialized THEN
        EXIT;

      // Setup Demonstration data.
      isInitialized := TRUE;
      LibraryERMCountryData.CreateVATData;
      LibraryERMCountryData.UpdateGeneralPostingSetup;

      MfgSetup.GET;
      WorkDate2 := CALCDATE(MfgSetup."Default Safety Lead Time",WORKDATE); // to avoid Due Date Before Work Date message.
      StdCostLevel := 2;
      LibraryAssembly.UpdateAssemblySetup(
        AssemblySetup,'',AssemblySetup."Copy Component Dimensions from"::"Order Header",LibraryUtility.GetGlobalNoSeriesCode);
      COMMIT;
Member of Lib.Library - Assembly


UpdateInventorySetup@49 Method

The procedure UpdateInventorySetup is available in codeunit 132207.

Syntax

UpdateInventorySetup@49(
    VAR InventorySetup@1001 : Record 313 InventorySetup, //Reference parameter of type Record
    AutomaticCostPosting@1000 : Boolean AutomaticCostPosting, //Input parameter of type Boolean
    ExpectedCostPostingtoGL@1002 : Boolean ExpectedCostPostingtoGL, //Input parameter of type Boolean
    AutomaticCostAdjustment@1003 : Option AutomaticCostAdjustment, //Input parameter of type Option
    AverageCostCalcType@1004 : Option AverageCostCalcType, //Input parameter of type Option
    AverageCostPeriod@1005 : Option AverageCostPeriod //Input parameter of type Option
);

Parameters

InventorySetup
Reference parameter of type Record
AutomaticCostPosting
Input parameter of type Boolean
ExpectedCostPostingtoGL
Input parameter of type Boolean
AutomaticCostAdjustment
Input parameter of type Option
AverageCostCalcType
Input parameter of type Option
AverageCostPeriod
Input parameter of type Option

Remarks

The relevant search keywords are: Update, Inventory, Setup.

For a clarification about how this function works, refer to the code listed below.

      InventorySetup.GET;
      InventorySetup."Automatic Cost Posting" := AutomaticCostPosting;
      InventorySetup."Expected Cost Posting to G/L" := ExpectedCostPostingtoGL;
      InventorySetup."Automatic Cost Adjustment" := AutomaticCostAdjustment;
      InventorySetup."Average Cost Calc. Type" := AverageCostCalcType;
      InventorySetup."Average Cost Period" := AverageCostPeriod;
      InventorySetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137092 to show one way of using this function.

      // Setup.
      Initialize;
      LibraryAssembly.UpdateInventorySetup(InventorySetup,FALSE,FALSE,InventorySetup."Automatic Cost Adjustment"::Never,
        InventorySetup."Average Cost Calc. Type"::"Item & Location & Variant",
        InventorySetup."Average Cost Period"::Day);
      LibraryAssembly.SetupAssemblyData(AssemblyHeader,WorkDate2,ParentCostingMethod,CompCostingMethod,
        Item."Replenishment System"::Assembly,'',TRUE);
      ItemFilter := LibraryAssembly.GetCompsToAdjust(ItemNo,ResourceNo,AssemblyHeader);
      LibraryAssembly.ModifyCostParams(AssemblyHeader."No.",FALSE,IndirectCost,0);
      LibraryAssembly.ModifyItem(AssemblyHeader."Item No.",FALSE,IndirectCost * LibraryRandom.RandDec(10,2),0);
      LibraryAssembly.AddCompInventory(AssemblyHeader,WorkDate2,0);

      // Exercise.
      LibraryAssembly.PrepareOrderPosting(AssemblyHeader,TempAssemblyLine,HeaderQtyFactor,PartialPostFactor,TRUE,WorkDate2);
      LibraryAssembly.CalcOrderCostAmount(GlobalMaterialCost,GlobalResourceCost,GlobalResourceOvhd,GlobalAsmOvhd,AssemblyHeader."No.");
      AssembledQty := AssemblyHeader."Quantity to Assemble";

      // Check statistics before posting: post factor is 0.
      GlobalPartialPostFactor := 0;
      CheckStatisticsPage(AssemblyHeader);

      LibraryAssembly.PostAssemblyHeader(AssemblyHeader,ExpectedError);
      IF NOT PostWithoutAdj THEN
        LibraryCosting.AdjustCostItemEntries(ItemFilter,'');

      // Verify.
      IF ExpectedError = '' THEN BEGIN
        IF PartialPostFactor < 100 THEN BEGIN
          // Check statistics after partial posting.
          GlobalPartialPostFactor := PartialPostFactor / 100;
          CheckStatisticsPage(AssemblyHeader);
        END;
        LibraryAssembly.VerifyPartialPosting(AssemblyHeader,HeaderQtyFactor);
        LibraryAssembly.VerifyPostedAssemblyHeader(TempAssemblyLine,AssemblyHeader,AssembledQty);
        LibraryAssembly.VerifyPostedComments(AssemblyHeader);
        LibraryAssembly.VerifyILEs(TempAssemblyLine,AssemblyHeader,AssembledQty);
        LibraryAssembly.VerifyValueEntries(TempAssemblyLine,AssemblyHeader,AssembledQty);
        LibraryAssembly.VerifyIndirectCostEntries(AssemblyHeader);
        LibraryAssembly.VerifyResEntries(TempAssemblyLine,AssemblyHeader);
        LibraryAssembly.VerifyCapEntries(TempAssemblyLine,AssemblyHeader);
        LibraryAssembly.VerifyItemRegister(AssemblyHeader);
      END;

      // Tear down.
      LibraryAssembly.UpdateInventorySetup(InventorySetup,FALSE,FALSE,InventorySetup."Automatic Cost Adjustment"::Never,
        InventorySetup."Average Cost Calc. Type"::Item,InventorySetup."Average Cost Period"::Day);

      EXIT(AssemblyHeader."No.");
Member of Lib.Library - Assembly


UpdateInvtPeriod@161 Method

The procedure UpdateInvtPeriod is available in codeunit 132207.

Syntax

UpdateInvtPeriod@161(
    VAR InventoryPeriod@1000 : Record 5814 InventoryPeriod, //Reference parameter of type Record
    ReOpen@1003 : Boolean ReOpen //Input parameter of type Boolean
);

Parameters

InventoryPeriod
Reference parameter of type Record
ReOpen
Input parameter of type Boolean

Remarks

The relevant search keywords are: Update, Invt, Period.

For a clarification about how this function works, refer to the code listed below.

      LibraryCosting.AdjustCostItemEntries('','');
      ItemLedgerEntry.SETRANGE(Open,TRUE);
      IF ItemLedgerEntry.FINDFIRST THEN
        ItemLedgerEntry.DELETE;

      CloseInventoryPeriod.SetReOpen(ReOpen);
      CloseInventoryPeriod.SetHideDialog(TRUE);
      CloseInventoryPeriod.RUN(InventoryPeriod);

      IF ReOpen THEN
        InventoryPeriod.DELETE;

Example

There are no examples available.
Member of Lib.Library - Assembly


UpdateOrderCost@137 Method

The procedure UpdateOrderCost is available in codeunit 132207.

Syntax

UpdateOrderCost@137(
    VAR AssemblyHeader@1000 : Record 900 AssemblyHeader //Reference parameter of type Record
);

Parameters

AssemblyHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Update, Order, Cost.

For a clarification about how this function works, refer to the code listed below.

      COMMIT;
      IF AssemblyHeader.Quantity = 0 THEN BEGIN
        ASSERTERROR AssemblyHeader.UpdateUnitCost;
        Assert.AreEqual(
          STRSUBSTNO(ErrorZeroQty,AssemblyHeader."No."),GETLASTERRORTEXT,
          'Actual:' + GETLASTERRORTEXT + '; Expected:' + STRSUBSTNO(ErrorZeroQty,AssemblyHeader."No."));
        CLEARLASTERROR;
        EXIT;
      END;

      Item.GET(AssemblyHeader."Item No.");
      IF Item."Costing Method" <> Item."Costing Method"::Standard THEN
        AssemblyHeader.UpdateUnitCost
      ELSE BEGIN
        ASSERTERROR AssemblyHeader.UpdateUnitCost;
        Assert.IsTrue(STRPOS(GETLASTERRORTEXT,ErrorStdCost) > 0,'Actual:' + GETLASTERRORTEXT + '; Expected:' + ErrorStdCost);
        CLEARLASTERROR;
      END;

      COMMIT;

Example

The below example is extracted from the test automation codeunit 137091 to show one way of using this function.

      // Setup.
      Initialize;
      StdCostLevel := 1;
      LibraryAssembly.SetupAssemblyData(
        AssemblyHeader,WorkDate2,ParentCostingMethod,CompCostingMethod,Item."Replenishment System"::Assembly,
        '',TRUE);
      SaveInitialAssemblyList(TempBOMComponent,AssemblyHeader."Item No.");

      // Exercise.
      LibraryAssembly.ModifyItem(AssemblyHeader."Item No.",UpdateParent,IndirectCost,Overhead);
      LibraryAssembly.ModifyCostParams(AssemblyHeader."No.",UpdateComp,IndirectCost,Overhead);
      IF UpdateParent THEN BEGIN
        AssemblyHeader.VALIDATE("Indirect Cost %",IndirectCost);
        AssemblyHeader.VALIDATE("Overhead Rate",Overhead);
        AssemblyHeader.MODIFY(TRUE);
      END;

      LibraryAssembly.EditAssemblyLines(
        ChangeType::Edit,AssemblyLine.Type::Item,AssemblyLine.Type::Item,'',AssemblyHeader."No.",TRUE);
      LibraryAssembly.UpdateOrderCost(AssemblyHeader);

      // Validate.
      VerifyOrderHeader(AssemblyHeader."No.");
      VerifyInitialAssemblyList(TempBOMComponent,AssemblyHeader."Item No.");
Member of Lib.Library - Assembly


UpdateSKUCards@171 Method

The procedure UpdateSKUCards is available in codeunit 132207.

Syntax

UpdateSKUCards@171(
    Item@1001 : Record 27 Item //Input parameter of type Record
);

Parameters

Item
Input parameter of type Record

Remarks

The relevant search keywords are: Update, SKU, Cards.

For a clarification about how this function works, refer to the code listed below.

      StockkeepingUnit.SETRANGE("Item No.",Item."No.");
      IF StockkeepingUnit.FINDSET THEN
        REPEAT
          IF Item."Costing Method" = Item."Costing Method"::Standard THEN
            StockkeepingUnit.VALIDATE("Standard Cost",Item."Standard Cost" + LibraryRandom.RandDec(10,2))
          ELSE
            StockkeepingUnit.VALIDATE("Unit Cost",Item."Unit Cost" + LibraryRandom.RandDec(10,2));
          StockkeepingUnit.MODIFY(TRUE);
        UNTIL StockkeepingUnit.NEXT = 0;

Example

There are no examples available.
Member of Lib.Library - Assembly


VerifyAdjustmentEntries@222 Method

The procedure VerifyAdjustmentEntries is available in codeunit 132207.

Syntax

VerifyAdjustmentEntries@222(
    AssemblyHeader@1000 : Record 900 AssemblyHeader, //Input parameter of type Record
    FinalAdjSource@1006 : Option FinalAdjSource //Input parameter of type Option
);

Parameters

AssemblyHeader
Input parameter of type Record
FinalAdjSource
Input parameter of type Option

Remarks

The relevant search keywords are: Verify, Adjustment, Entries.

For a clarification about how this function works, refer to the code listed below.

      COMMIT;
      PostedAssemblyHeader.RESET;
      PostedAssemblyHeader.SETRANGE("Order No.",AssemblyHeader."No.");
      PostedAssemblyHeader.SETRANGE("Item No.",AssemblyHeader."Item No.");
      PostedAssemblyHeader.SETRANGE("Variant Code",AssemblyHeader."Variant Code");
      PostedAssemblyHeader.FINDFIRST;

      PostedAssemblyLine.RESET;
      PostedAssemblyLine.SETRANGE("Document No.",PostedAssemblyHeader."No.");
      PostedAssemblyLine.SETRANGE("Order No.",AssemblyHeader."No.");
      PostedAssemblyLine.SETRANGE(Type,PostedAssemblyLine.Type::Item);
      PostedAssemblyLine.SETFILTER("No.",'<>%1',AssemblyHeader."Item No.");  // Skip validation for auto consumption.

      IF PostedAssemblyLine.FINDSET THEN
        REPEAT
          VerifyLineAdjustmentEntry(PostedAssemblyLine,FinalAdjSource);
        UNTIL PostedAssemblyLine.NEXT = 0;

      GetAdjAmounts(VarianceAmount,AdjAmount,PostedAssemblyHeader);
      VerifyHeaderAdjustmentEntry(PostedAssemblyHeader,AdjAmount);
      Item.GET(AssemblyHeader."Item No.");
      IF Item."Costing Method" = Item."Costing Method"::Standard THEN BEGIN
        IF StockkeepingUnit.GET(PostedAssemblyHeader."Location Code",Item."No.",PostedAssemblyHeader."Variant Code") THEN
          VarianceAmount := VarianceAmount - PostedAssemblyHeader."Cost Amount" + Item."Standard Cost" * PostedAssemblyHeader.Quantity;
        VerifyHeaderVarianceEntry(PostedAssemblyHeader,VarianceAmount);
      END;

Example

The below example is extracted from the test automation codeunit 137094 to show one way of using this function.

      // Setup.
      Initialize;
      LibraryAssembly.UpdateInventorySetup(InventorySetup,AutCostPosting,FALSE,AutCostAdj,
        InventorySetup."Average Cost Calc. Type"::"Item & Location & Variant",
        InventorySetup."Average Cost Period"::Day);

      // Create Assembly BOM structure.
      LibraryAssembly.SetupAssemblyData(AssemblyHeader,WorkDate2,ParentCostingMethod,CompCostingMethod,
        Item."Replenishment System"::Assembly,'',NOT AdjustHeader);
      ItemFilter := LibraryAssembly.GetCompsToAdjust(ItemNo,ResourceNo,AssemblyHeader);

      // Add inventory for components to allow posting.
      LibraryAssembly.AddCompInventory(AssemblyHeader,WorkDate2,LibraryRandom.RandDec(10,2));

      // Introduce a source of adjustment.
      LibraryAssembly.CreateAdjustmentSource(AssemblyHeader,WorkDate2,AdjustHeader,AdjSource1,ItemNo[1],ResourceNo[1]);
      LibraryAssembly.PrepareOrderPosting(AssemblyHeader,TempAssemblyLine,100,100,TRUE,WorkDate2);

      // Exercise.
      // Post Assembly Order, introduce a second source of adjustment and adjust.
      LibraryAssembly.PostAssemblyHeader(AssemblyHeader,'');
      LibraryAssembly.CreateAdjustmentSource(AssemblyHeader,WorkDate2,AdjustHeader,AdjSource2,ItemNo[1],ResourceNo[1]);
      LibraryCosting.AdjustCostItemEntries(ItemFilter,'');

      // Verify: Posted documents and entries.
      LibraryAssembly.VerifyPostedAssemblyHeader(TempAssemblyLine,AssemblyHeader,AssemblyHeader.Quantity);
      LibraryAssembly.VerifyILEs(TempAssemblyLine,AssemblyHeader,AssemblyHeader."Quantity to Assemble");
      LibraryAssembly.VerifyValueEntries(TempAssemblyLine,AssemblyHeader,AssemblyHeader."Quantity to Assemble");
      LibraryAssembly.VerifyPostedComments(AssemblyHeader);
      LibraryAssembly.VerifyResEntries(TempAssemblyLine,AssemblyHeader);
      LibraryAssembly.VerifyCapEntries(TempAssemblyLine,AssemblyHeader);
      LibraryAssembly.VerifyAdjustmentEntries(AssemblyHeader,AdjSource2);
      LibraryAssembly.VerifyItemRegister(AssemblyHeader);

      // Tear down.
      LibraryAssembly.UpdateInventorySetup(InventorySetup,FALSE,FALSE,InventorySetup."Automatic Cost Adjustment"::Never,
        InventorySetup."Average Cost Calc. Type"::Item,InventorySetup."Average Cost Period"::Day);

      EXIT(AssemblyHeader."No.");
Member of Lib.Library - Assembly


VerifyApplicationEntry@46 Method

The procedure VerifyApplicationEntry is available in codeunit 132207.

Syntax

VerifyApplicationEntry@46(
    ItemLedgerEntry@1000 : Record 32 ItemLedgerEntry //Input parameter of type Record
);

Parameters

ItemLedgerEntry
Input parameter of type Record

Remarks

The relevant search keywords are: Verify, Application, Entry.

For a clarification about how this function works, refer to the code listed below.

      ItemApplicationEntry.RESET;
      ItemApplicationEntry.SETRANGE("Item Ledger Entry No.",ItemLedgerEntry."Entry No.");
      ItemApplicationEntry.SETRANGE(Quantity,ItemLedgerEntry.Quantity);
      CASE ItemLedgerEntry."Entry Type" OF
        ItemLedgerEntry."Entry Type"::"Assembly Consumption":
          ItemApplicationEntry.SETRANGE("Outbound Item Entry No.",ItemLedgerEntry."Entry No.");
        ItemLedgerEntry."Entry Type"::"Assembly Output":
          BEGIN
            ItemApplicationEntry.SETRANGE("Inbound Item Entry No.",ItemLedgerEntry."Entry No.");
            ItemApplicationEntry.SETRANGE("Outbound Item Entry No.",0);
          END;
      END;
      ItemApplicationEntry.FINDFIRST;
      Assert.AreEqual(1,ItemApplicationEntry.COUNT,
        'Wrong no. of application entries for ILE no ' + FORMAT(ItemLedgerEntry."Entry No."));

Example

There are no examples available.
Member of Lib.Library - Assembly


VerifyApplicationEntryUndo@80 Method

The procedure VerifyApplicationEntryUndo is available in codeunit 132207.

Syntax

VerifyApplicationEntryUndo@80(
    ItemLedgerEntry@1000 : Record 32 ItemLedgerEntry //Input parameter of type Record
);

Parameters

ItemLedgerEntry
Input parameter of type Record

Remarks

The relevant search keywords are: Verify, Application, Entry, Undo.

For a clarification about how this function works, refer to the code listed below.

      ItemApplicationEntry.RESET;
      CASE ItemLedgerEntry."Entry Type" OF
        ItemLedgerEntry."Entry Type"::"Assembly Consumption":
          IF ItemLedgerEntry.Correction THEN BEGIN
            // Check reversed entry
            ItemApplicationEntry.SETRANGE("Item Ledger Entry No.",ItemLedgerEntry."Entry No.");
            ItemApplicationEntry.SETRANGE("Inbound Item Entry No.",ItemLedgerEntry."Entry No.");
            ItemApplicationEntry.SETRANGE(Quantity,ItemLedgerEntry.Quantity);
            ItemApplicationEntry.FINDFIRST;
            Assert.AreEqual(
              1,ItemApplicationEntry.COUNT,'Wrong no. of application entries for ILE no ' + FORMAT(ItemLedgerEntry."Entry No."));
          END ELSE BEGIN
            // Check initial posted entry
            ItemApplicationEntry.SETRANGE("Item Ledger Entry No.",ItemLedgerEntry."Entry No.");
            ItemApplicationEntry.SETRANGE("Outbound Item Entry No.",ItemLedgerEntry."Entry No.");
            ItemApplicationEntry.SETRANGE(Quantity,ItemLedgerEntry.Quantity);
            ItemApplicationEntry.FINDFIRST;
            Assert.AreEqual(
              1,ItemApplicationEntry.COUNT,'Wrong no. of application entries for ILE no ' + FORMAT(ItemLedgerEntry."Entry No."));
          END;
        ItemLedgerEntry."Entry Type"::"Assembly Output":
          IF ItemLedgerEntry.Correction THEN BEGIN
            // Check reversed entry
            ItemApplicationEntry.SETRANGE("Item Ledger Entry No.",ItemLedgerEntry."Entry No.");
            ItemApplicationEntry.SETRANGE("Outbound Item Entry No.",ItemLedgerEntry."Entry No.");
            ItemApplicationEntry.SETRANGE(Quantity,ItemLedgerEntry.Quantity);
            ItemApplicationEntry.FINDFIRST;
            Assert.AreEqual(
              1,ItemApplicationEntry.COUNT,'Wrong no. of application entries for ILE no ' + FORMAT(ItemLedgerEntry."Entry No."));
          END ELSE BEGIN
            // Check initial posted entry
            ItemApplicationEntry.SETRANGE("Item Ledger Entry No.",ItemLedgerEntry."Entry No.");
            ItemApplicationEntry.SETRANGE("Outbound Item Entry No.",0);
            ItemApplicationEntry.SETRANGE("Inbound Item Entry No.",ItemLedgerEntry."Entry No.");
            ItemApplicationEntry.SETRANGE(Quantity,ItemLedgerEntry.Quantity);
            Assert.AreEqual(
              1,ItemApplicationEntry.COUNT,'Wrong no. of application entries for ILE no ' + FORMAT(ItemLedgerEntry."Entry No."));
          END;
      END;

Example

There are no examples available.
Member of Lib.Library - Assembly


VerifyBinContent@101 Method

The procedure VerifyBinContent is available in codeunit 132207.

Syntax

VerifyBinContent@101(
    LocationCode@1003 : Code[20] LocationCode, //Input parameter of type Code
    BinCode@1000 : Code[20] BinCode, //Input parameter of type Code
    ItemNo@1002 : Code[20] ItemNo, //Input parameter of type Code
    VariantCode@1005 : Code[10] VariantCode, //Input parameter of type Code
    UOMCode@1006 : Code[10] UOMCode, //Input parameter of type Code
    Quantity@1001 : Decimal Quantity //Input parameter of type Decimal
);

Parameters

LocationCode
Input parameter of type Code
BinCode
Input parameter of type Code
ItemNo
Input parameter of type Code
VariantCode
Input parameter of type Code
UOMCode
Input parameter of type Code
Quantity
Input parameter of type Decimal

Remarks

The relevant search keywords are: Verify, Bin, Content.

For a clarification about how this function works, refer to the code listed below.

      BinContent.RESET;
      BinContent.SETRANGE("Location Code",LocationCode);
      BinContent.SETRANGE("Bin Code",BinCode);
      BinContent.SETRANGE("Item No.",ItemNo);
      BinContent.SETRANGE("Variant Code",VariantCode);
      BinContent.SETRANGE("Unit of Measure Code",UOMCode);
      IF BinContent.FINDFIRST THEN BEGIN
        BinContent.CALCFIELDS(Quantity);
        BinContent.TESTFIELD(Quantity,Quantity);
      END ELSE
        Assert.AreEqual(Quantity,0,'Incorrect Bin Code Qty for Item: ' + ItemNo + ' in Bin: ' + BinCode);

Example

There are no examples available.
Member of Lib.Library - Assembly


VerifyBinContents@86 Method

The procedure VerifyBinContents is available in codeunit 132207.

Syntax

VerifyBinContents@86(
    VAR TempAssemblyHeader@1000 : TEMPORARY Record 900 TempAssemblyHeader, //Reference Temporary parameter of type Record
    VAR TempAssemblyLine@1001 : TEMPORARY Record 901 TempAssemblyLine, //Reference Temporary parameter of type Record
    AdditionalQty@1002 : Decimal AdditionalQty //Input parameter of type Decimal
);

Parameters

TempAssemblyHeader
Reference Temporary parameter of type Record
TempAssemblyLine
Reference Temporary parameter of type Record
AdditionalQty
Input parameter of type Decimal

Remarks

The relevant search keywords are: Verify, Bin, Contents.

For a clarification about how this function works, refer to the code listed below.

      // This function has to be called after the AO has been posted and no other "output" qtities exist in inventory

      // Verify bin content for header assembly item does not exist
      VerifyBinContent(
        TempAssemblyHeader."Location Code",TempAssemblyHeader."Bin Code",TempAssemblyHeader."Item No.",
        TempAssemblyHeader."Variant Code",TempAssemblyHeader."Unit of Measure Code",0);

      // Verify bin contents for components
      TempAssemblyLine.RESET;
      TempAssemblyLine.SETRANGE(Type,TempAssemblyLine.Type::Item);
      TempAssemblyLine.FINDSET;
      REPEAT
        VerifyBinContent(
          TempAssemblyLine."Location Code",TempAssemblyLine."Bin Code",TempAssemblyLine."No.",TempAssemblyLine."Variant Code",
          TempAssemblyLine."Unit of Measure Code",
          AdditionalQty + TempAssemblyLine.Quantity);
      UNTIL TempAssemblyLine.NEXT = 0;

Example

The below example is extracted from the test automation codeunit 137097 to show one way of using this function.

      // Get Bin codes
      BinIndex := 1;

      IF NOT Location."Directed Put-away and Pick" THEN BEGIN// if not Full WMS
        LibraryWarehouse.FindBin(HeaderBin,Location.Code,'',BinIndex);
        LibraryWarehouse.FindBin(ComponentsBin,Location.Code,'',BinIndex + 1);
      END ELSE BEGIN
        HeaderBin.GET(Location.Code,Location."From-Production Bin Code");
        LibraryWarehouse.FindBin(ComponentsBin,Location.Code,'PICK',BinIndex);
      END;

      // Create AO
      OrderQty := LibraryRandom.RandDec(1000,2) + 1;
      CreateAssemblyOrderWithInventory(AssemblyHeader,Item,OrderQty,Location.Code,HeaderBin.Code,ComponentsBin.Code);

      // If Full WMS - process whse pick, else set bin on the lines to point where the inventory exists
      IF NOT Location."Directed Put-away and Pick" THEN
        SetLocAndBinCodeOnAsmLines(AssemblyHeader,ComponentsBin)
      ELSE
        ProcessWMSPick(AssemblyHeader);

      // Copy to temp & post AO
      IF FullPosting THEN BEGIN
        CopyAOToTemp(AssemblyHeader,TempAssemblyHeader,TempAssemblyLine);
        PostAssemblyOrderQty(AssemblyHeader,OrderQty);
      END ELSE BEGIN
        PostAssemblyOrderQty(AssemblyHeader,OrderQty / 2);
        CopyAOToTemp(AssemblyHeader,TempAssemblyHeader,TempAssemblyLine);
      END;

      FindPostedAssemblyHeaderNotReversed(PostedAssemblyHeader,AssemblyHeader."No.");

      // Exercise - undo
      LibraryAssembly.UndoPostedAssembly(PostedAssemblyHeader,FALSE,'');

      // Verify
      CASE AssertOption OF
        AssertOption::WhseEntries:
          BEGIN
            LibraryAssembly.VerifyWarehouseEntries(TempAssemblyHeader,TempAssemblyLine,FALSE);
            LibraryAssembly.VerifyWarehouseEntries(TempAssemblyHeader,TempAssemblyLine,TRUE);
          END;
        AssertOption::BinContents:
          LibraryAssembly.VerifyBinContents(TempAssemblyHeader,TempAssemblyLine,0);
      END;
Member of Lib.Library - Assembly


VerifyCapEntries@41 Method

The procedure VerifyCapEntries is available in codeunit 132207.

Syntax

VerifyCapEntries@41(
    VAR TempAssemblyLine@1003 : TEMPORARY Record 901 TempAssemblyLine, //Reference Temporary parameter of type Record
    AssemblyHeader@1000 : Record 900 AssemblyHeader //Input parameter of type Record
);

Parameters

TempAssemblyLine
Reference Temporary parameter of type Record
AssemblyHeader
Input parameter of type Record

Remarks

The relevant search keywords are: Verify, Cap, Entries.

For a clarification about how this function works, refer to the code listed below.

      VerifyCapEntriesGeneric(TempAssemblyLine,AssemblyHeader,FALSE);

Example

The below example is extracted from the test automation codeunit 137092 to show one way of using this function.

      // Setup.
      Initialize;
      LibraryAssembly.UpdateAssemblySetup(AssemblySetup,'',DimensionsFrom,LibraryUtility.GetGlobalNoSeriesCode);
      LibraryAssembly.SetupAssemblyData(AssemblyHeader,WorkDate2,Item."Costing Method"::Standard,Item."Costing Method"::Average,
        Item."Replenishment System"::Assembly,'',TRUE);
      LibraryAssembly.AddCompInventory(AssemblyHeader,WorkDate2,0);

      // Exercise.
      LibraryAssembly.CheckOrderDimensions(AssemblyHeader,DimensionsFrom);
      IF OverrideDimensions THEN
        LibraryAssembly.EditOrderDimensions(AssemblyHeader);
      ExpectedError := LibraryAssembly.BlockOrderDimensions(AssemblyHeader,HeaderBlockType,CompBlockType);

      IF ExpectedError = '' THEN
        ExpectedError := AddAOItemDimension(AssemblyHeader,DefaultHeaderValuePosting,DefaultCompValuePosting);

      SetShortcutDimensions(AssemblyHeader,1);
      SetShortcutDimensions(AssemblyHeader,2);

      LibraryAssembly.PrepareOrderPosting(AssemblyHeader,TempAssemblyLine,100,100,TRUE,WorkDate2);
      LibraryAssembly.PostAssemblyHeader(AssemblyHeader,ExpectedError);

      // Verify.
      IF ExpectedError = '' THEN BEGIN
        LibraryAssembly.VerifyPostedAssemblyHeader(TempAssemblyLine,AssemblyHeader,AssemblyHeader.Quantity);
        LibraryAssembly.VerifyPostedComments(AssemblyHeader);
        LibraryAssembly.VerifyILEs(TempAssemblyLine,AssemblyHeader,AssemblyHeader."Quantity to Assemble");
        LibraryAssembly.VerifyValueEntries(TempAssemblyLine,AssemblyHeader,AssemblyHeader."Quantity to Assemble");
        LibraryAssembly.VerifyResEntries(TempAssemblyLine,AssemblyHeader);
        LibraryAssembly.VerifyCapEntries(TempAssemblyLine,AssemblyHeader);
        LibraryAssembly.VerifyItemRegister(AssemblyHeader);
      END;

      // Tear down.
Member of Lib.Library - Assembly


VerifyCapEntriesATO@62 Method

The procedure VerifyCapEntriesATO is available in codeunit 132207.

Syntax

VerifyCapEntriesATO@62(
    VAR TempAssemblyLine@1003 : TEMPORARY Record 901 TempAssemblyLine, //Reference Temporary parameter of type Record
    AssemblyHeader@1000 : Record 900 AssemblyHeader //Input parameter of type Record
);

Parameters

TempAssemblyLine
Reference Temporary parameter of type Record
AssemblyHeader
Input parameter of type Record

Remarks

The relevant search keywords are: Verify, Cap, Entries, ATO.

For a clarification about how this function works, refer to the code listed below.

      VerifyCapEntriesGeneric(TempAssemblyLine,AssemblyHeader,TRUE);

Example

The below example is extracted from the test automation codeunit 137096 to show one way of using this function.

      CreateAssembledItem(Item,Item."Assembly Policy"::"Assemble-to-Order",LibraryRandom.RandInt(10),
        LibraryRandom.RandInt(10),LibraryRandom.RandInt(10),LibraryRandom.RandInt(1000),
        Item."Costing Method"::FIFO);

      // Exercise - create SOL with ATO item
      OrderQty := LibraryRandom.RandInt(1000);
      DueDate := CALCDATE('<+' + FORMAT(LibraryRandom.RandInt(30)) + 'D>',WorkDate2);
      CreateSalesOrder(SalesHeader,Item."No.",'',OrderQty,DueDate,LocationCode);
      FindSOL(SalesHeader,SalesLine,1);
      FindAssemblyHeader(AssemblyHeader,AssemblyHeader."Document Type"::Order,Item,'',LocationCode,
        DueDate,Item."Base Unit of Measure",OrderQty);
      CopyAsmLinesToTemp(AssemblyHeader,TempAssemblyLine);

      // Add enough inventory for comp
      AddInvNonDirectLocAllComponent(AssemblyHeader,100);

      // Exercise - post SOs
      LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      // Verify - entries
      LibraryAssembly.VerifyILEsForAsmOnATO(TempAssemblyLine,AssemblyHeader,AssemblyHeader.Quantity);
      LibraryAssembly.VerifyValueEntriesATO(TempAssemblyLine,SalesHeader,AssemblyHeader,AssemblyHeader.Quantity);
      LibraryAssembly.VerifyResEntriesATO(TempAssemblyLine,AssemblyHeader);
      LibraryAssembly.VerifyCapEntriesATO(TempAssemblyLine,AssemblyHeader);
Member of Lib.Library - Assembly


VerifyCapEntriesGeneric@65 Method

The procedure VerifyCapEntriesGeneric is available in codeunit 132207.

Syntax

VerifyCapEntriesGeneric@65(
    VAR TempAssemblyLine@1003 : TEMPORARY Record 901 TempAssemblyLine, //Reference Temporary parameter of type Record
    AssemblyHeader@1000 : Record 900 AssemblyHeader, //Input parameter of type Record
    IsATO@1002 : Boolean IsATO //Input parameter of type Boolean
);

Parameters

TempAssemblyLine
Reference Temporary parameter of type Record
AssemblyHeader
Input parameter of type Record
IsATO
Input parameter of type Boolean

Remarks

The relevant search keywords are: Verify, Cap, Entries, Generic.

For a clarification about how this function works, refer to the code listed below.

      CapacityLedgerEntry.RESET;
      // General filtering.
      CapacityLedgerEntry.SETRANGE("Posting Date",AssemblyHeader."Posting Date");
      CapacityLedgerEntry.SETRANGE(Type,CapacityLedgerEntry.Type::Resource);
      CapacityLedgerEntry.SETRANGE("Item No.",AssemblyHeader."Item No.");
      CapacityLedgerEntry.SETRANGE("Variant Code",AssemblyHeader."Variant Code");
      CapacityLedgerEntry.SETRANGE("Unit of Measure Code",AssemblyHeader."Unit of Measure Code");
      CapacityLedgerEntry.SETRANGE("Order Type",CapacityLedgerEntry."Order Type"::Assembly);
      CapacityLedgerEntry.SETRANGE("Order No.",AssemblyHeader."No.");

      // Usage entries.
      TempAssemblyLine.SETRANGE(Type,TempAssemblyLine.Type::Resource);
      IF TempAssemblyLine.FINDSET THEN
        REPEAT
          CapacityLedgerEntry.SETRANGE("No.",TempAssemblyLine."No.");
          CapacityLedgerEntry.SETRANGE(Description,TempAssemblyLine.Description);
          CapacityLedgerEntry.SETRANGE(Quantity,TempAssemblyLine."Quantity to Consume");
          CapacityLedgerEntry.SETRANGE("Invoiced Quantity",TempAssemblyLine."Quantity to Consume");
          CapacityLedgerEntry.SETRANGE("Cap. Unit of Measure Code",TempAssemblyLine."Unit of Measure Code");
          IF NOT IsATO THEN BEGIN // if ATO then dimensions can come from SOL also - skip checking them
            CapacityLedgerEntry.SETRANGE("Global Dimension 1 Code",TempAssemblyLine."Shortcut Dimension 1 Code");
            CapacityLedgerEntry.SETRANGE("Global Dimension 2 Code",TempAssemblyLine."Shortcut Dimension 2 Code");
            CapacityLedgerEntry.SETRANGE("Dimension Set ID",TempAssemblyLine."Dimension Set ID");
          END;
          Assert.AreEqual(1,CapacityLedgerEntry.COUNT,'Wrong no. of capacity ledger entries for res. ' + TempAssemblyLine."No.");
          CapacityLedgerEntry.FINDFIRST;
          CapacityLedgerEntry.CALCFIELDS("Direct Cost");
          Assert.AreNearlyEqual(TempAssemblyLine."Cost Amount" * TempAssemblyLine."Quantity to Consume" /
            TempAssemblyLine.Quantity,CapacityLedgerEntry."Direct Cost",
            LibraryERM.GetAmountRoundingPrecision,'Wrong Cap. Ledger Cost amount for res. ' + TempAssemblyLine."No.")
        UNTIL TempAssemblyLine.NEXT = 0;

Example

There are no examples available.
Member of Lib.Library - Assembly


VerifyCapEntriesUndo@77 Method

The procedure VerifyCapEntriesUndo is available in codeunit 132207.

Syntax

VerifyCapEntriesUndo@77(
    VAR TempPostedAssemblyHeader@1000 : TEMPORARY Record 910 TempPostedAssemblyHeader, //Reference Temporary parameter of type Record
    VAR TempPostedAssemblyLine@1003 : TEMPORARY Record 911 TempPostedAssemblyLine, //Reference Temporary parameter of type Record
    IsUndo@1002 : Boolean IsUndo //Input parameter of type Boolean
);

Parameters

TempPostedAssemblyHeader
Reference Temporary parameter of type Record
TempPostedAssemblyLine
Reference Temporary parameter of type Record
IsUndo
Input parameter of type Boolean

Remarks

The relevant search keywords are: Verify, Cap, Entries, Undo.

For a clarification about how this function works, refer to the code listed below.

      CapacityLedgerEntry.RESET;
      // General filtering.
      CapacityLedgerEntry.SETRANGE("Posting Date",TempPostedAssemblyHeader."Posting Date");
      CapacityLedgerEntry.SETRANGE(Type,CapacityLedgerEntry.Type::Resource);
      CapacityLedgerEntry.SETRANGE("Item No.",TempPostedAssemblyHeader."Item No.");
      CapacityLedgerEntry.SETRANGE("Variant Code",TempPostedAssemblyHeader."Variant Code");
      CapacityLedgerEntry.SETRANGE("Unit of Measure Code",TempPostedAssemblyHeader."Unit of Measure Code");
      CapacityLedgerEntry.SETRANGE("Order Type",CapacityLedgerEntry."Order Type"::Assembly);
      CapacityLedgerEntry.SETRANGE("Order No.",TempPostedAssemblyHeader."Order No.");

      // Usage entries.
      TempPostedAssemblyLine.SETRANGE(Type,TempPostedAssemblyLine.Type::Resource);
      IF TempPostedAssemblyLine.FINDSET THEN
        REPEAT
          CapacityLedgerEntry.SETRANGE("No.",TempPostedAssemblyLine."No.");
          CapacityLedgerEntry.SETRANGE(Description,TempPostedAssemblyLine.Description);
          CapacityLedgerEntry.SETRANGE("Cap. Unit of Measure Code",TempPostedAssemblyLine."Unit of Measure Code");
          CapacityLedgerEntry.SETRANGE("Global Dimension 1 Code",TempPostedAssemblyLine."Shortcut Dimension 1 Code");
          CapacityLedgerEntry.SETRANGE("Global Dimension 2 Code",TempPostedAssemblyLine."Shortcut Dimension 2 Code");
          CapacityLedgerEntry.SETRANGE("Dimension Set ID",TempPostedAssemblyLine."Dimension Set ID");
          IF IsUndo THEN BEGIN
            CapacityLedgerEntry.SETRANGE(Quantity,-TempPostedAssemblyLine."Quantity (Base)");
            CapacityLedgerEntry.SETRANGE("Invoiced Quantity",-TempPostedAssemblyLine."Quantity (Base)");
          END ELSE BEGIN
            CapacityLedgerEntry.SETRANGE(Quantity,TempPostedAssemblyLine."Quantity (Base)");
            CapacityLedgerEntry.SETRANGE("Invoiced Quantity",TempPostedAssemblyLine."Quantity (Base)");
          END;
          Assert.AreEqual(1,CapacityLedgerEntry.COUNT,'Wrong no. of capacity ledger entries for res. ' + TempPostedAssemblyLine."No.");
        UNTIL TempPostedAssemblyLine.NEXT = 0;

Example

The below example is extracted from the test automation codeunit 137097 to show one way of using this function.

      // Create AO
      CreateAssembledItem(Item,Item."Assembly Policy"::"Assemble-to-Order",LibraryRandom.RandInt(10),
        LibraryRandom.RandInt(10),LibraryRandom.RandInt(10),LibraryRandom.RandDec(1000,2));
      OrderQty := LibraryRandom.RandDec(1000,2) + 1;
      DueDate := CALCDATE('<+' + FORMAT(LibraryRandom.RandInt(30)) + 'D>',WorkDate2);

      IF IsATO THEN BEGIN
        CreateSalesOrder(SalesHeader,Item."No.",'',OrderQty,DueDate,LocationCode);
        FindSOL(SalesHeader,SalesLine,1);
        SalesLine.AsmToOrderExists(AssemblyHeader);
      END ELSE
        CreateAssemblyOrder(AssemblyHeader,Item,LocationCode,'','',DueDate,OrderQty);

      // Add enough inventory for comp and post
      LibraryAssembly.AddCompInventoryToBin(AssemblyHeader,WORKDATE,0,LocationCode,'');
      IF FullPosting THEN BEGIN
        IF IsATO THEN
          LibrarySales.PostSalesDocument(SalesHeader,TRUE,FALSE)
        ELSE
          PostAssemblyOrderQty(AssemblyHeader,OrderQty)
      END ELSE BEGIN
        IF IsATO THEN BEGIN
          SalesLine.FIND;
          SalesLine.VALIDATE("Qty. to Ship",ROUND(SalesLine."Qty. to Ship" / 2,0.00001));
          SalesLine.MODIFY(TRUE);
          LibrarySales.PostSalesDocument(SalesHeader,TRUE,FALSE);
          AssemblyHeader.FIND;
        END ELSE
          PostAssemblyOrderQty(AssemblyHeader,OrderQty / 2);
      END;

      // Copy docs to temp
      FindPostedAssemblyHeaderNotReversed(PostedAssemblyHeader,AssemblyHeader."No.");
      CopyPostedAOToTemp(PostedAssemblyHeader,TempPostedAssemblyHeader,TempPostedAssemblyLine);
      IF NOT FullPosting THEN
        CopyAOToTemp(AssemblyHeader,TempAssemblyHeader,TempAssemblyLine);

      // Exercise - undo
      IF IsATO THEN BEGIN
        FindSalesShptLine(SalesLine,SalesShptLine);
        UndoSalesShptLine.SetHideDialog(TRUE);
        UndoSalesShptLine.RUN(SalesShptLine);
      END ELSE
        LibraryAssembly.UndoPostedAssembly(PostedAssemblyHeader,TRUE,'');

      // Verify
      CASE AssertOption OF
        // Check reversed docs
        AssertOption::ReversedDocs:
          BEGIN
            AssertReversedDoc(PostedAssemblyHeader,TempPostedAssemblyHeader);
            IF FullPosting THEN
              AssertNewAOAfterUndo(TempPostedAssemblyHeader,TempPostedAssemblyLine)
            ELSE
              AssertMergedAOAfterUndo(TempAssemblyHeader,TempAssemblyLine,TempPostedAssemblyHeader,TempPostedAssemblyLine);
          END;
        AssertOption::ILEs:
          BEGIN
            // Verify ILEs
            LibraryAssembly.VerifyILEsUndo(TempPostedAssemblyHeader,TempPostedAssemblyLine,FALSE);
            LibraryAssembly.VerifyILEsUndo(TempPostedAssemblyHeader,TempPostedAssemblyLine,TRUE);
          END;
        AssertOption::CapacityEntries:
          BEGIN
            // Verify Cap Ledger
            LibraryAssembly.VerifyCapEntriesUndo(TempPostedAssemblyHeader,TempPostedAssemblyLine,FALSE);
            LibraryAssembly.VerifyCapEntriesUndo(TempPostedAssemblyHeader,TempPostedAssemblyLine,TRUE);
          END;
      END;
Member of Lib.Library - Assembly


VerifyComments@82 Method

The procedure VerifyComments is available in codeunit 132207.

Syntax

VerifyComments@82(
    AssemblyHeader@1000 : Record 900 AssemblyHeader //Input parameter of type Record
);

Parameters

AssemblyHeader
Input parameter of type Record

Remarks

The relevant search keywords are: Verify, Comments.

For a clarification about how this function works, refer to the code listed below.

      VerifyLineComment(AssemblyHeader,0);

      AssemblyLine.SETRANGE("Document Type",AssemblyHeader."Document Type");
      AssemblyLine.SETRANGE("Document No.",AssemblyHeader."No.");
      IF AssemblyLine.FINDSET THEN
        REPEAT
          VerifyLineComment(AssemblyHeader,AssemblyLine."Line No.");
        UNTIL AssemblyLine.NEXT = 0;

Example

The below example is extracted from the test automation codeunit 137097 to show one way of using this function.

      // Create AO
      CreateAssembledItem(Item,Item."Assembly Policy"::"Assemble-to-Stock",LibraryRandom.RandInt(10),
        LibraryRandom.RandInt(10),LibraryRandom.RandInt(10),LibraryRandom.RandDec(1000,2));
      OrderQty := LibraryRandom.RandDec(1000,2) + 1;
      DueDate := CALCDATE('<+' + FORMAT(LibraryRandom.RandInt(30)) + 'D>',WorkDate2);
      CreateAssemblyOrder(AssemblyHeader,Item,LocationCode,'','',DueDate,OrderQty);
      AddCommentsToOrder(AssemblyHeader);

      // Add enough inventory for comp and post
      LibraryAssembly.AddCompInventoryToBin(AssemblyHeader,WORKDATE,0,LocationCode,'');
      PostAssemblyOrderQty(AssemblyHeader,OrderQty);

      // Undo
      FindPostedAssemblyHeaderNotReversed(PostedAssemblyHeader,AssemblyHeader."No.");
      LibraryAssembly.UndoPostedAssembly(PostedAssemblyHeader,TRUE,'');

      // Exercise - verify comments
      LibraryAssembly.VerifyComments(AssemblyHeader);
Member of Lib.Library - Assembly


VerifyEntityDimensions@59 Method

The procedure VerifyEntityDimensions is available in codeunit 132207.

Syntax

VerifyEntityDimensions@59(
    TableID@1002 : Integer TableID, //Input parameter of type Integer
    EntityNo@1003 : Code[20] EntityNo, //Input parameter of type Code
    ParentItemNo@1005 : Code[20] ParentItemNo, //Input parameter of type Code
    CopyFromHeader@1006 : Boolean CopyFromHeader, //Input parameter of type Boolean
    DimensionSetID@1004 : Integer DimensionSetID //Input parameter of type Integer
);

Parameters

TableID
Input parameter of type Integer
EntityNo
Input parameter of type Code
ParentItemNo
Input parameter of type Code
CopyFromHeader
Input parameter of type Boolean
DimensionSetID
Input parameter of type Integer

Remarks

The relevant search keywords are: Verify, Entity, Dimensions.

For a clarification about how this function works, refer to the code listed below.

      IF (TableID <= 0) OR (DimensionSetID <= 0) THEN
        EXIT;
      LibraryDimension.FindDefaultDimension(DefaultDimension,TableID,EntityNo);
      IF CopyFromHeader THEN
        LibraryDimension.FindDefaultDimension(DefaultDimension,27,ParentItemNo);

      LibraryDimension.FindDimensionSetEntry(DimensionSetEntry,DimensionSetID);
      REPEAT
        DimensionSetEntry.SETRANGE("Dimension Code",DefaultDimension."Dimension Code");
        DimensionSetEntry.SETRANGE("Dimension Value Code",DefaultDimension."Dimension Value Code");
        Assert.AreEqual(
          1,DimensionSetEntry.COUNT,'Wrong no. of dimension set entries for dimension ' + FORMAT(DefaultDimension."Dimension Code"));
        DimensionSetEntry.FINDFIRST;
      UNTIL DefaultDimension.NEXT = 0;

Example

There are no examples available.
Member of Lib.Library - Assembly


VerifyGLEntries@66 Method

The procedure VerifyGLEntries is available in codeunit 132207.

Syntax

VerifyGLEntries@66(
    PostedAssemblyHeader@1000 : Record 910 PostedAssemblyHeader, //Input parameter of type Record
    PerPostingGroup@1017 : Boolean PerPostingGroup //Input parameter of type Boolean
);

Parameters

PostedAssemblyHeader
Input parameter of type Record
PerPostingGroup
Input parameter of type Boolean

Remarks

The relevant search keywords are: Verify, General Ledger, Entries.

For a clarification about how this function works, refer to the code listed below.

      // Get expected posting accounts for assembly item.
      GetPostingSetup(GeneralPostingSetup,InventoryPostingSetup,PostedAssemblyHeader."Gen. Prod. Posting Group",
        PostedAssemblyHeader."Inventory Posting Group",PostedAssemblyHeader."Location Code");

      // Get output costs.
      OutputDirectCost := GetValueEntriesAmount(PostedAssemblyHeader,ValueEntry."Item Ledger Entry Type"::"Assembly Output",
          ValueEntry."Entry Type"::"Direct Cost",ValueEntry."Variance Type"::" ",PostedAssemblyHeader."Item No.",TRUE);

      OutputIndirectCost := GetValueEntriesAmount(PostedAssemblyHeader,ValueEntry."Item Ledger Entry Type"::"Assembly Output",
          ValueEntry."Entry Type"::"Indirect Cost",ValueEntry."Variance Type"::" ",PostedAssemblyHeader."Item No.",TRUE);

      MaterialVariance := GetValueEntriesAmount(PostedAssemblyHeader,ValueEntry."Item Ledger Entry Type"::"Assembly Output",
          ValueEntry."Entry Type"::Variance,ValueEntry."Variance Type"::Material,PostedAssemblyHeader."Item No.",TRUE);

      CapacityVariance := GetValueEntriesAmount(PostedAssemblyHeader,ValueEntry."Item Ledger Entry Type"::"Assembly Output",
          ValueEntry."Entry Type"::Variance,ValueEntry."Variance Type"::Capacity,PostedAssemblyHeader."Item No.",TRUE);

      CapOverhead := GetValueEntriesAmount(PostedAssemblyHeader,ValueEntry."Item Ledger Entry Type"::"Assembly Output",
          ValueEntry."Entry Type"::Variance,ValueEntry."Variance Type"::"Capacity Overhead",PostedAssemblyHeader."Item No.",TRUE);

      ManufOverhead := GetValueEntriesAmount(PostedAssemblyHeader,ValueEntry."Item Ledger Entry Type"::"Assembly Output",
          ValueEntry."Entry Type"::Variance,ValueEntry."Variance Type"::"Manufacturing Overhead",PostedAssemblyHeader."Item No.",TRUE);

      // Get component costs.
      ResDirectCost :=
        GetValueEntriesAmount(PostedAssemblyHeader,ValueEntry."Item Ledger Entry Type"::" ",
          ValueEntry."Entry Type"::"Direct Cost",ValueEntry."Variance Type"::" ",'',TRUE);

      ItemDirectCost :=
        GetValueEntriesAmount(PostedAssemblyHeader,ValueEntry."Item Ledger Entry Type"::"Assembly Consumption",
          ValueEntry."Entry Type"::"Direct Cost",ValueEntry."Variance Type"::" ",'',TRUE);

      // Get consumption direct and indirect costs.
      CompDirectCost := -ItemDirectCost + ResDirectCost;

      CompIndirectCost :=
        GetValueEntriesAmount(PostedAssemblyHeader,ValueEntry."Item Ledger Entry Type"::"Assembly Consumption",
          ValueEntry."Entry Type"::"Indirect Cost",ValueEntry."Variance Type"::" ",'',TRUE) +
        GetValueEntriesAmount(PostedAssemblyHeader,ValueEntry."Item Ledger Entry Type"::" ",
          ValueEntry."Entry Type"::"Indirect Cost",ValueEntry."Variance Type"::" ",'',TRUE);

      // Verify GL entries.

      // Verify Inventory Account for output.
      VerifyGLEntry(PostedAssemblyHeader."No.",InventoryPostingSetup."Inventory Account",PostedAssemblyHeader."Posting Date",
        OutputDirectCost + OutputIndirectCost + MaterialVariance + CapacityVariance + CapOverhead + ManufOverhead,'<>');

      // Verify Material variance account for header.
      VerifyGLEntry(PostedAssemblyHeader."No.",InventoryPostingSetup."Material Variance Account",PostedAssemblyHeader."Posting Date",
        -MaterialVariance,'<>');

      // Verify Capacity variance account for header.
      VerifyGLEntry(PostedAssemblyHeader."No.",InventoryPostingSetup."Capacity Variance Account",PostedAssemblyHeader."Posting Date",
        -CapacityVariance,'<>');

      // Verify Capacity overhead variance account for header.
      VerifyGLEntry(PostedAssemblyHeader."No.",InventoryPostingSetup."Cap. Overhead Variance Account",PostedAssemblyHeader.
        "Posting Date",
        -CapOverhead,'<>');

      // Verify Mfg. overhead variance account for header.
      VerifyGLEntry(PostedAssemblyHeader."No.",InventoryPostingSetup."Mfg. Overhead Variance Account",PostedAssemblyHeader.
        "Posting Date",
        -ManufOverhead,'<>');

      // Verify Inventory Adjustment account, both header and component.
      VerifyGLEntry(PostedAssemblyHeader."No.",GeneralPostingSetup."Inventory Adjmt. Account",PostedAssemblyHeader."Posting Date",
        CompDirectCost + CompIndirectCost - OutputDirectCost,'<>');

      // Verify Overhead applied account, both header and component.
      VerifyGLEntry(PostedAssemblyHeader."No.",GeneralPostingSetup."Overhead Applied Account",PostedAssemblyHeader."Posting Date",
        -OutputIndirectCost - CompIndirectCost,'<>');

      // Verify consumption entries.
      PostedAssemblyLine.RESET;
      PostedAssemblyLine.SETRANGE("Document No.",PostedAssemblyHeader."No.");
      PostedAssemblyLine.SETRANGE("Order No.",PostedAssemblyHeader."Order No.");
      PostedAssemblyLine.SETRANGE(Type,PostedAssemblyLine.Type::Item);
      IF PostedAssemblyLine.FINDFIRST THEN
        GetPostingSetup(GeneralPostingSetup,InventoryPostingSetup,PostedAssemblyLine."Gen. Prod. Posting Group",
          PostedAssemblyLine."Inventory Posting Group",PostedAssemblyLine."Location Code");

      // Verify cost aggregation under the document no. for 'Per posting group' option in posting.
      ValueEntry.SETRANGE("Item No.",PostedAssemblyLine."No.");
      ValueEntry.SETRANGE("Variant Code",PostedAssemblyLine."Variant Code");
      ValueEntry.SETRANGE("Location Code",PostedAssemblyLine."Location Code");
      ValueEntry.SETRANGE("Item Ledger Entry Type",ValueEntry."Item Ledger Entry Type"::"Positive Adjmt.");
      ValueEntry.SETRANGE("Entry Type",ValueEntry."Entry Type"::"Direct Cost");
      IF ValueEntry.FINDFIRST AND PerPostingGroup THEN
        VerifyGLEntry(PostedAssemblyHeader."No.",GeneralPostingSetup."Inventory Adjmt. Account",ValueEntry."Posting Date",
          -ValueEntry."Cost Amount (Actual)",'<>');

      // Verify Inventory account for item consumption.
      VerifyGLEntry(PostedAssemblyHeader."No.",InventoryPostingSetup."Inventory Account",PostedAssemblyHeader."Posting Date",
        ItemDirectCost,'<>');

      // Verify Direct Cost account for resource consumption.
      VerifyGLEntry(PostedAssemblyHeader."No.",GeneralPostingSetup."Direct Cost Applied Account",PostedAssemblyHeader."Posting Date",
        -ResDirectCost,'<>');

      // Check G/L transaction is balanced.
      GLEntry.SETCURRENTKEY("Document No.","Posting Date");
      GLEntry.SETRANGE("Document No.",PostedAssemblyHeader."No.");
      GLEntry.SETRANGE("Posting Date",PostedAssemblyHeader."Posting Date");
      GLEntry.FINDSET;
      REPEAT
        TotalAmount += GLEntry.Amount;
      UNTIL GLEntry.NEXT = 0;

      Assert.AreEqual(0,TotalAmount,'Transaction must be balanced:' + PostedAssemblyHeader."No.");

Example

The below example is extracted from the test automation codeunit 137092 to show one way of using this function.

      // Setup.
      Initialize;
      AssemblyHeaderNo :=
        NormalPosting(ParentCostingMethod,CompCostingMethod,HeaderQtyFactor,PartialPostFactor,'',IndirectCost,PostWithoutAdj);
      LibraryAssembly.UpdateInventorySetup(InventorySetup,FALSE,FALSE,InventorySetup."Automatic Cost Adjustment"::Never,
        InventorySetup."Average Cost Calc. Type"::"Item & Location & Variant",
        InventorySetup."Average Cost Period"::Day);

      // Exercise.
      PostedAssemblyHeader.RESET;
      PostedAssemblyHeader.SETRANGE("Order No.",AssemblyHeaderNo);
      PostedAssemblyHeader.FINDFIRST;
      IF PerPostingGroup THEN
        DocNo := PostedAssemblyHeader."No."
      ELSE
        DocNo := '';
      LibraryAssembly.PostInvtCostToGL(PerPostingGroup,PostedAssemblyHeader."Item No.",DocNo,
        TEMPORARYPATH + PostedAssemblyHeader."No." + '.pdf');
      IF PostWithoutAdj THEN
        LibraryCosting.AdjustCostItemEntries(PostedAssemblyHeader."Item No.",'');

      // Verify.
      LibraryAssembly.VerifyGLEntries(PostedAssemblyHeader,PerPostingGroup);

      // Tear down.
      LibraryAssembly.UpdateInventorySetup(InventorySetup,FALSE,FALSE,InventorySetup."Automatic Cost Adjustment"::Never,
        InventorySetup."Average Cost Calc. Type"::Item,InventorySetup."Average Cost Period"::Day);
Member of Lib.Library - Assembly


VerifyGLEntry@124 Method

The procedure VerifyGLEntry is available in codeunit 132207.

Syntax

VerifyGLEntry@124(
    DocumentNo@1000 : Code[20] DocumentNo, //Input parameter of type Code
    AccountNo@1001 : Code[20] AccountNo, //Input parameter of type Code
    PostingDate@1006 : Date PostingDate, //Input parameter of type Date
    Amount@1003 : Decimal Amount, //Input parameter of type Decimal
    Sign@1005 : Text[30] Sign //Input parameter of type Text
);

Parameters

DocumentNo
Input parameter of type Code
AccountNo
Input parameter of type Code
PostingDate
Input parameter of type Date
Amount
Input parameter of type Decimal
Sign
Input parameter of type Text

Remarks

The relevant search keywords are: Verify, General Ledger, Entry.

For a clarification about how this function works, refer to the code listed below.

      ActualAmount := 0;
      GLEntry.RESET;
      GLEntry.SETRANGE("Document No.",DocumentNo);
      GLEntry.SETRANGE("G/L Account No.",AccountNo);
      GLEntry.SETRANGE("Posting Date",PostingDate);
      GLEntry.SETFILTER(Amount,Sign + '%1',0);
      IF GLEntry.FINDSET THEN
        REPEAT
          ActualAmount += GLEntry.Amount;
        UNTIL GLEntry.NEXT = 0;
      Assert.AreNearlyEqual(Amount,ActualAmount,LibraryERM.GetAmountRoundingPrecision,'Account:' + AccountNo);

Example

The below example is extracted from the test automation codeunit 137101 to show one way of using this function.

      InventoryPostingSetup.GET('',AssemblyItem."Inventory Posting Group");
      GeneralPostingSetup.GET('',AssemblyItem."Gen. Prod. Posting Group");
      FindPostedAssemblyHeader(PostedAssemblyHeader,AssemblyHeaderNo,AssemblyItem."No.");
      LibraryAssembly.VerifyGLEntry(
        PostedAssemblyHeader."No.",InventoryPostingSetup."Inventory Account",PostedAssemblyHeader."Due Date",
        PostedAssemblyHeader."Cost Amount",'>');
      LibraryAssembly.VerifyGLEntry(
        PostedAssemblyHeader."No.",GeneralPostingSetup."Inventory Adjmt. Account",PostedAssemblyHeader."Due Date",
        -PostedAssemblyHeader."Cost Amount",'<');
Member of Lib.Library - Assembly


VerifyHardLinkEntry@50 Method

The procedure VerifyHardLinkEntry is available in codeunit 132207.

Syntax

VerifyHardLinkEntry@50(
    SalesLine@1001 : Record 37 SalesLine, //Input parameter of type Record
    AssemblyHeader@1000 : Record 900 AssemblyHeader, //Input parameter of type Record
    NoOfEntries@1003 : Integer NoOfEntries //Input parameter of type Integer
);

Parameters

SalesLine
Input parameter of type Record
AssemblyHeader
Input parameter of type Record
NoOfEntries
Input parameter of type Integer

Remarks

The relevant search keywords are: Verify, Hard, Link, Entry.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(ATOLink);
      ATOLink.SETRANGE("Assembly Document Type",AssemblyHeader."Document Type");
      ATOLink.SETRANGE("Assembly Document No.",AssemblyHeader."No.");
      ATOLink.SETRANGE(Type,ATOLink.Type::Sale);
      ATOLink.SETRANGE("Document Type",SalesLine."Document Type");
      ATOLink.SETRANGE("Document No.",SalesLine."Document No.");
      ATOLink.SETRANGE("Document Line No.",SalesLine."Line No.");
      ATOLink.SETRANGE("Assembled Quantity",AssemblyHeader."Assembled Quantity");

      Assert.AreEqual(NoOfEntries,ATOLink.COUNT,'There are no ' + FORMAT(NoOfEntries) + ' entries within the filter ' +
        ATOLink.GETFILTERS);

Example

The below example is extracted from the test automation codeunit 137096 to show one way of using this function.

      // TC11, TC12, TC115 and TC124 from the TDS - see Documentation

      AsmDocumentType := GetAsmTypeForSalesType(SalesDocumentType);
      NoOfAssemblyOrders := CountAssemblyOrders(AsmDocumentType);

      // Exercise - create SOL with ATO item
      OrderQty := LibraryRandom.RandInt(1000);
      DueDate := CALCDATE('<+' + FORMAT(LibraryRandom.RandInt(30)) + 'D>',WorkDate2);
      CreateSaleLineWithShptDate(SalesHeader,SalesDocumentType,Item."No.",VariantCode,OrderQty,DueDate,LocationCode);
      FindSOL(SalesHeader,SalesLine,1);

      FindAssemblyHeader(AssemblyHeader,AsmDocumentType,Item,VariantCode,LocationCode,DueDate,Item."Base Unit of Measure",OrderQty);

      CASE AssertOption OF
        // Assert Assembly doc created
        AssertOption::Orders:
          BEGIN
            // Assert that 1 assembly doc is created for the ATO items placed on sales line
            Assert.AreEqual(NoOfAssemblyOrders + 1,CountAssemblyOrders(AsmDocumentType),OneAsmOrderCreateMsg);

            // Verify - assembly doc
            AssertAsmOrderForDefaultBOM(AssemblyHeader,AsmDocumentType,Item,VariantCode,LocationCode,DueDate,
              Item."Base Unit of Measure",OrderQty,1);
          END;
        // Assert reservation entries
        AssertOption::Reservation:
          AssertReservationEntries(SalesLine,AssemblyHeader);
        // Assert hard link entry
        AssertOption::"Hard link":
          LibraryAssembly.VerifyHardLinkEntry(SalesLine,AssemblyHeader,1);
      END;
Member of Lib.Library - Assembly


VerifyHeaderAdjustmentEntry@195 Method

The procedure VerifyHeaderAdjustmentEntry is available in codeunit 132207.

Syntax

VerifyHeaderAdjustmentEntry@195(
    PostedAssemblyHeader@1000 : Record 910 PostedAssemblyHeader, //Input parameter of type Record
    AdjAmount@1004 : Decimal AdjAmount //Input parameter of type Decimal
);

Parameters

PostedAssemblyHeader
Input parameter of type Record
AdjAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Verify, Header, Adjustment, Entry.

For a clarification about how this function works, refer to the code listed below.

      FindHeaderValueEntries(ValueEntry,PostedAssemblyHeader,ValueEntry."Entry Type"::"Direct Cost",
        ValueEntry."Item Ledger Entry Type"::"Assembly Output");
      ValueEntry.SETRANGE(Adjustment,TRUE);

      IF AdjAmount <> 0 THEN BEGIN
        ValueEntry.FINDFIRST;
        Assert.AreEqual(1,ValueEntry.COUNT,'Wrong no. of adjustment entries for header.');
        Assert.AreNearlyEqual(-AdjAmount,ValueEntry."Cost Amount (Actual)",
          LibraryERM.GetAmountRoundingPrecision,'Wrong header adj. entry cost amount.');
        Assert.AreNearlyEqual(ValueEntry."Cost Amount (Actual)",ValueEntry."Cost per Unit" * ValueEntry."Valued Quantity",
          LibraryERM.GetAmountRoundingPrecision,'Wrong header adj. entry cost per unit.');
      END ELSE
        Assert.IsTrue(ValueEntry.ISEMPTY,'Unexpected adj. entries for header ' + PostedAssemblyHeader."No.");

Example

There are no examples available.
Member of Lib.Library - Assembly


VerifyHeaderVarianceEntry@215 Method

The procedure VerifyHeaderVarianceEntry is available in codeunit 132207.

Syntax

VerifyHeaderVarianceEntry@215(
    PostedAssemblyHeader@1000 : Record 910 PostedAssemblyHeader, //Input parameter of type Record
    VarianceAmount@1005 : Decimal VarianceAmount //Input parameter of type Decimal
);

Parameters

PostedAssemblyHeader
Input parameter of type Record
VarianceAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Verify, Header, Variance, Entry.

For a clarification about how this function works, refer to the code listed below.

      FindHeaderValueEntries(ValueEntry,PostedAssemblyHeader,ValueEntry."Entry Type"::Variance,
        ValueEntry."Item Ledger Entry Type"::"Assembly Output");
      ValueEntry.SETRANGE(Adjustment,TRUE);
      IF VarianceAmount <> 0 THEN BEGIN
        ValueEntry.FINDSET;
        ActualVarianceAmount := 0;
        REPEAT
          ActualVarianceAmount += ValueEntry."Cost Amount (Actual)";
        UNTIL ValueEntry.NEXT = 0;
        Assert.AreNearlyEqual(VarianceAmount,ActualVarianceAmount,LibraryERM.GetAmountRoundingPrecision,
          'Wrong variance entry cost amount for header.');
      END ELSE
        Assert.IsTrue(ValueEntry.ISEMPTY,'Unexpected variance entry for ' + PostedAssemblyHeader."No.");

Example

There are no examples available.
Member of Lib.Library - Assembly


VerifyILEATOAndSale@89 Method

The procedure VerifyILEATOAndSale is available in codeunit 132207.

Syntax

VerifyILEATOAndSale@89(
    AssemblyHeader@1002 : Record 900 AssemblyHeader, //Input parameter of type Record
    SalesLine@1000 : Record 37 SalesLine, //Input parameter of type Record
    AssembledQty@1003 : Decimal AssembledQty, //Input parameter of type Decimal
    Invoiced@1004 : Boolean Invoiced, //Input parameter of type Boolean
    NoOfLines@1005 : Integer NoOfLines //Input parameter of type Integer
);

Parameters

AssemblyHeader
Input parameter of type Record
SalesLine
Input parameter of type Record
AssembledQty
Input parameter of type Decimal
Invoiced
Input parameter of type Boolean
NoOfLines
Input parameter of type Integer

Remarks

The relevant search keywords are: Verify, ILEATO, Sale.

For a clarification about how this function works, refer to the code listed below.

      // General filtering.
      ItemLedgerEntry.RESET;
      ItemLedgerEntry.SETRANGE("Posting Date",AssemblyHeader."Posting Date");
      ItemLedgerEntry.SETRANGE("Source No.",AssemblyHeader."Item No.");
      ItemLedgerEntry.SETRANGE("Source Type",ItemLedgerEntry."Source Type"::Item);
      ItemLedgerEntry.SETRANGE("Order Type",ItemLedgerEntry."Order Type"::Assembly);
      ItemLedgerEntry.SETRANGE("Order No.",AssemblyHeader."No.");
      ItemLedgerEntry.SETRANGE("Cost Amount (Expected)",0);

      // Output entry.
      ItemLedgerEntry.SETRANGE("Item No.",AssemblyHeader."Item No.");
      ItemLedgerEntry.SETRANGE("Variant Code",AssemblyHeader."Variant Code");
      ItemLedgerEntry.SETRANGE("Entry Type",ItemLedgerEntry."Entry Type"::"Assembly Output");
      ItemLedgerEntry.SETRANGE("Location Code",AssemblyHeader."Location Code");
      ItemLedgerEntry.SETRANGE(Quantity,AssembledQty);
      ItemLedgerEntry.SETRANGE("Invoiced Quantity",AssembledQty);
      ItemLedgerEntry.SETRANGE("Unit of Measure Code",AssemblyHeader."Unit of Measure Code");
      ItemLedgerEntry.SETRANGE("Document Line No.",0);
      ItemLedgerEntry.SETRANGE("Order Line No.",0);
      ItemLedgerEntry.SETRANGE("Dimension Set ID",AssemblyHeader."Dimension Set ID");
      ItemLedgerEntry.SETRANGE("Assemble to Order",FALSE);
      ItemLedgerEntry.SETRANGE("Remaining Quantity",0);
      ItemLedgerEntry.SETRANGE(Open,FALSE);
      Assert.AreEqual(NoOfLines,ItemLedgerEntry.COUNT,'Wrong no. of output entries for item ' + AssemblyHeader."Item No.");
      IF ItemLedgerEntry.FINDSET THEN
        REPEAT
          VerifyILESale(SalesLine,AssembledQty,ItemLedgerEntry."Entry No.",TRUE,Invoiced);
        UNTIL ItemLedgerEntry.NEXT = 0;

Example

The below example is extracted from the test automation codeunit 137096 to show one way of using this function.

      Initialize;
      CreateAssembledItem(Item,Item."Assembly Policy"::"Assemble-to-Order",LibraryRandom.RandInt(10),
        LibraryRandom.RandInt(10),LibraryRandom.RandInt(10),LibraryRandom.RandInt(1000),
        Item."Costing Method"::FIFO);

      // Exercise - create SOL with ATO item
      OrderQty := LibraryRandom.RandInt(1000);
      DueDate := CALCDATE('<+' + FORMAT(LibraryRandom.RandInt(30)) + 'D>',WorkDate2);
      CreateSalesOrder(SalesHeader,Item."No.",'',OrderQty,DueDate,'');
      FindSOL(SalesHeader,SalesLine,1);
      SalesLine.AsmToOrderExists(AssemblyHeader);
      CopyAsmLinesToTemp(AssemblyHeader,TempAssemblyLine);

      // Add enough inventory for comp
      AddInvNonDirectLocAllComponent(AssemblyHeader,100);

      // Exercise - post SOs
      LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      // Verify - fixed application AO and SOL
      LibraryAssembly.VerifyILEATOAndSale(AssemblyHeader,SalesLine,OrderQty,TRUE,1);
Member of Lib.Library - Assembly


VerifyILEs@32 Method

The procedure VerifyILEs is available in codeunit 132207.

Syntax

VerifyILEs@32(
    VAR TempAssemblyLine@1000 : TEMPORARY Record 901 TempAssemblyLine, //Reference Temporary parameter of type Record
    AssemblyHeader@1002 : Record 900 AssemblyHeader, //Input parameter of type Record
    AssembledQty@1003 : Decimal AssembledQty //Input parameter of type Decimal
);

Parameters

TempAssemblyLine
Reference Temporary parameter of type Record
AssemblyHeader
Input parameter of type Record
AssembledQty
Input parameter of type Decimal

Remarks

The relevant search keywords are: Verify, IL, Es.

For a clarification about how this function works, refer to the code listed below.

      VerifyILEsGeneric(TempAssemblyLine,AssemblyHeader,AssembledQty,FALSE);

Example

The below example is extracted from the test automation codeunit 137092 to show one way of using this function.

      // Setup.
      Initialize;
      LibraryAssembly.UpdateAssemblySetup(AssemblySetup,'',DimensionsFrom,LibraryUtility.GetGlobalNoSeriesCode);
      LibraryAssembly.SetupAssemblyData(AssemblyHeader,WorkDate2,Item."Costing Method"::Standard,Item."Costing Method"::Average,
        Item."Replenishment System"::Assembly,'',TRUE);
      LibraryAssembly.AddCompInventory(AssemblyHeader,WorkDate2,0);

      // Exercise.
      LibraryAssembly.CheckOrderDimensions(AssemblyHeader,DimensionsFrom);
      IF OverrideDimensions THEN
        LibraryAssembly.EditOrderDimensions(AssemblyHeader);
      ExpectedError := LibraryAssembly.BlockOrderDimensions(AssemblyHeader,HeaderBlockType,CompBlockType);

      IF ExpectedError = '' THEN
        ExpectedError := AddAOItemDimension(AssemblyHeader,DefaultHeaderValuePosting,DefaultCompValuePosting);

      SetShortcutDimensions(AssemblyHeader,1);
      SetShortcutDimensions(AssemblyHeader,2);

      LibraryAssembly.PrepareOrderPosting(AssemblyHeader,TempAssemblyLine,100,100,TRUE,WorkDate2);
      LibraryAssembly.PostAssemblyHeader(AssemblyHeader,ExpectedError);

      // Verify.
      IF ExpectedError = '' THEN BEGIN
        LibraryAssembly.VerifyPostedAssemblyHeader(TempAssemblyLine,AssemblyHeader,AssemblyHeader.Quantity);
        LibraryAssembly.VerifyPostedComments(AssemblyHeader);
        LibraryAssembly.VerifyILEs(TempAssemblyLine,AssemblyHeader,AssemblyHeader."Quantity to Assemble");
        LibraryAssembly.VerifyValueEntries(TempAssemblyLine,AssemblyHeader,AssemblyHeader."Quantity to Assemble");
        LibraryAssembly.VerifyResEntries(TempAssemblyLine,AssemblyHeader);
        LibraryAssembly.VerifyCapEntries(TempAssemblyLine,AssemblyHeader);
        LibraryAssembly.VerifyItemRegister(AssemblyHeader);
      END;

      // Tear down.
Member of Lib.Library - Assembly


VerifyILESale@90 Method

The procedure VerifyILESale is available in codeunit 132207.

Syntax

VerifyILESale@90(
    SalesLine@1001 : Record 37 SalesLine, //Input parameter of type Record
    AssembledQty@1002 : Decimal AssembledQty, //Input parameter of type Decimal
    EntryNo@1003 : Integer EntryNo, //Input parameter of type Integer
    IsAto@1005 : Boolean IsAto, //Input parameter of type Boolean
    Invoiced@1004 : Boolean Invoiced //Input parameter of type Boolean
);

Parameters

SalesLine
Input parameter of type Record
AssembledQty
Input parameter of type Decimal
EntryNo
Input parameter of type Integer
IsAto
Input parameter of type Boolean
Invoiced
Input parameter of type Boolean

Remarks

The relevant search keywords are: Verify, ILE, Sale.

For a clarification about how this function works, refer to the code listed below.

      // General filtering.
      ItemLedgerEntry.RESET;
      ItemLedgerEntry.SETRANGE("Source No.",SalesLine."Sell-to Customer No.");
      ItemLedgerEntry.SETRANGE("Source Type",ItemLedgerEntry."Source Type"::Customer);
      ItemLedgerEntry.SETRANGE("Order Type",ItemLedgerEntry."Order Type"::" ");
      ItemLedgerEntry.SETRANGE("Cost Amount (Expected)",0);

      // Output entry.
      ItemLedgerEntry.SETRANGE("Item No.",SalesLine."No.");
      ItemLedgerEntry.SETRANGE("Variant Code",SalesLine."Variant Code");
      ItemLedgerEntry.SETRANGE("Entry Type",ItemLedgerEntry."Entry Type"::Sale);
      ItemLedgerEntry.SETRANGE("Location Code",SalesLine."Location Code");
      ItemLedgerEntry.SETRANGE(Quantity,-AssembledQty);
      IF Invoiced THEN
        ItemLedgerEntry.SETRANGE("Invoiced Quantity",-AssembledQty)
      ELSE
        ItemLedgerEntry.SETRANGE("Invoiced Quantity",0);
      ItemLedgerEntry.SETRANGE("Unit of Measure Code",SalesLine."Unit of Measure Code");
      ItemLedgerEntry.SETRANGE("Document Line No.",SalesLine."Line No.");
      ItemLedgerEntry.SETRANGE("Order Line No.",0);
      ItemLedgerEntry.SETRANGE("Dimension Set ID",SalesLine."Dimension Set ID");
      ItemLedgerEntry.SETRANGE("Assemble to Order",IsAto);
      ItemLedgerEntry.SETRANGE(Open,NOT IsAto);
      IF IsAto THEN
        ItemLedgerEntry.SETRANGE("Remaining Quantity",0)
      ELSE
        ItemLedgerEntry.SETRANGE("Remaining Quantity",-AssembledQty);
      ItemLedgerEntry.SETRANGE("Applies-to Entry",EntryNo);
      Assert.AreEqual(1,ItemLedgerEntry.COUNT,'Wrong no. of sale entries for item ' + SalesLine."No.");

Example

The below example is extracted from the test automation codeunit 137096 to show one way of using this function.

      Initialize;
      CreateAssembledItem(Item,Item."Assembly Policy"::"Assemble-to-Order",LibraryRandom.RandInt(10),
        LibraryRandom.RandInt(10),LibraryRandom.RandInt(10),LibraryRandom.RandInt(1000),
        Item."Costing Method"::FIFO);

      // Exercise - create SOL with ATO item
      OrderQty := LibraryRandom.RandInt(1000);
      DueDate := CALCDATE('<+' + FORMAT(LibraryRandom.RandInt(30)) + 'D>',WorkDate2);
      CreateSalesOrder(SalesHeader,Item."No.",'',OrderQty,DueDate,'');
      FindSOL(SalesHeader,SalesLine,1);
      SalesLine.VALIDATE("Qty. to Assemble to Order",OrderQty / 2);
      SalesLine.VALIDATE("Qty. to Ship",OrderQty / 2);
      SalesLine.MODIFY(TRUE);
      SalesLine.AsmToOrderExists(AssemblyHeader);

      // Add enough inventory for comp
      AddInvNonDirectLocAllComponent(AssemblyHeader,100);

      // Exercise - post SOs - ATO first and ATS after
      LibrarySales.PostSalesDocument(SalesHeader,TRUE,FALSE);

      // Verify - fixed application AO and SOL
      LibraryAssembly.VerifyILEATOAndSale(AssemblyHeader,SalesLine,OrderQty / 2,FALSE,1);

      // post the rest - ATS
      SalesHeader.GET(SalesHeader."Document Type",SalesHeader."No.");
      FindSOL(SalesHeader,SalesLine,1);
      LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      // Verify - ATS sale
      LibraryCosting.CheckAdjustment(Item);
      LibraryAssembly.VerifyILESale(SalesLine,OrderQty / 2,0,FALSE,TRUE);
Member of Lib.Library - Assembly


VerifyILEsForAsmOnATO@54 Method

The procedure VerifyILEsForAsmOnATO is available in codeunit 132207.

Syntax

VerifyILEsForAsmOnATO@54(
    VAR TempAssemblyLine@1000 : TEMPORARY Record 901 TempAssemblyLine, //Reference Temporary parameter of type Record
    AssemblyHeader@1002 : Record 900 AssemblyHeader, //Input parameter of type Record
    AssembledQty@1003 : Decimal AssembledQty //Input parameter of type Decimal
);

Parameters

TempAssemblyLine
Reference Temporary parameter of type Record
AssemblyHeader
Input parameter of type Record
AssembledQty
Input parameter of type Decimal

Remarks

The relevant search keywords are: Verify, IL, Es, For, Asm, On, ATO.

For a clarification about how this function works, refer to the code listed below.

      VerifyILEsGeneric(TempAssemblyLine,AssemblyHeader,AssembledQty,TRUE);

Example

The below example is extracted from the test automation codeunit 137096 to show one way of using this function.

      CreateAssembledItem(Item,Item."Assembly Policy"::"Assemble-to-Order",LibraryRandom.RandInt(10),
        LibraryRandom.RandInt(10),LibraryRandom.RandInt(10),LibraryRandom.RandInt(1000),
        Item."Costing Method"::FIFO);

      // Exercise - create SOL with ATO item
      OrderQty := LibraryRandom.RandInt(1000);
      DueDate := CALCDATE('<+' + FORMAT(LibraryRandom.RandInt(30)) + 'D>',WorkDate2);
      CreateSalesOrder(SalesHeader,Item."No.",'',OrderQty,DueDate,LocationCode);
      FindSOL(SalesHeader,SalesLine,1);
      FindAssemblyHeader(AssemblyHeader,AssemblyHeader."Document Type"::Order,Item,'',LocationCode,
        DueDate,Item."Base Unit of Measure",OrderQty);
      CopyAsmLinesToTemp(AssemblyHeader,TempAssemblyLine);

      // Add enough inventory for comp
      AddInvNonDirectLocAllComponent(AssemblyHeader,100);

      // Exercise - post SOs
      LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      // Verify - entries
      LibraryAssembly.VerifyILEsForAsmOnATO(TempAssemblyLine,AssemblyHeader,AssemblyHeader.Quantity);
      LibraryAssembly.VerifyValueEntriesATO(TempAssemblyLine,SalesHeader,AssemblyHeader,AssemblyHeader.Quantity);
      LibraryAssembly.VerifyResEntriesATO(TempAssemblyLine,AssemblyHeader);
      LibraryAssembly.VerifyCapEntriesATO(TempAssemblyLine,AssemblyHeader);
Member of Lib.Library - Assembly


VerifyILEsGeneric@56 Method

The procedure VerifyILEsGeneric is available in codeunit 132207.

Syntax

VerifyILEsGeneric@56(
    VAR TempAssemblyLine@1000 : TEMPORARY Record 901 TempAssemblyLine, //Reference Temporary parameter of type Record
    AssemblyHeader@1002 : Record 900 AssemblyHeader, //Input parameter of type Record
    AssembledQty@1003 : Decimal AssembledQty, //Input parameter of type Decimal
    IsATO@1004 : Boolean IsATO //Input parameter of type Boolean
);

Parameters

TempAssemblyLine
Reference Temporary parameter of type Record
AssemblyHeader
Input parameter of type Record
AssembledQty
Input parameter of type Decimal
IsATO
Input parameter of type Boolean

Remarks

The relevant search keywords are: Verify, IL, Es, Generic.

For a clarification about how this function works, refer to the code listed below.

      // General filtering.
      ItemLedgerEntry.RESET;
      ItemLedgerEntry.SETRANGE("Posting Date",AssemblyHeader."Posting Date");
      ItemLedgerEntry.SETRANGE("Source No.",AssemblyHeader."Item No.");
      ItemLedgerEntry.SETRANGE("Source Type",ItemLedgerEntry."Source Type"::Item);
      ItemLedgerEntry.SETRANGE("Order Type",ItemLedgerEntry."Order Type"::Assembly);
      ItemLedgerEntry.SETRANGE("Order No.",AssemblyHeader."No.");
      ItemLedgerEntry.SETRANGE("Cost Amount (Expected)",0);

      // Output entry.
      ItemLedgerEntry.SETRANGE("Item No.",AssemblyHeader."Item No.");
      ItemLedgerEntry.SETRANGE("Variant Code",AssemblyHeader."Variant Code");
      ItemLedgerEntry.SETRANGE("Entry Type",ItemLedgerEntry."Entry Type"::"Assembly Output");
      ItemLedgerEntry.SETRANGE("Location Code",AssemblyHeader."Location Code");
      ItemLedgerEntry.SETRANGE(Quantity,AssembledQty);
      ItemLedgerEntry.SETRANGE("Invoiced Quantity",AssembledQty);
      ItemLedgerEntry.SETRANGE("Unit of Measure Code",AssemblyHeader."Unit of Measure Code");
      ItemLedgerEntry.SETRANGE("Document Line No.",0);
      ItemLedgerEntry.SETRANGE("Order Line No.",0);
      ItemLedgerEntry.SETRANGE("Dimension Set ID",AssemblyHeader."Dimension Set ID");
      ItemLedgerEntry.SETRANGE("Assemble to Order",FALSE);
      IF IsATO THEN BEGIN
        ItemLedgerEntry.SETRANGE("Remaining Quantity",0);
        ItemLedgerEntry.SETRANGE(Open,FALSE);
      END ELSE BEGIN
        ItemLedgerEntry.SETRANGE("Remaining Quantity",AssembledQty);
        ItemLedgerEntry.SETRANGE(Open,TRUE);
      END;
      Assert.AreEqual(1,ItemLedgerEntry.COUNT,'Wrong no. of output entries for item ' + AssemblyHeader."Item No.");
      ItemLedgerEntry.FINDFIRST;
      VerifyApplicationEntry(ItemLedgerEntry);

      // Consumption entries.
      // Find posted assembly lines.
      TempAssemblyLine.SETRANGE(Type,TempAssemblyLine.Type::Item);

      IF TempAssemblyLine.FINDSET THEN
        REPEAT
          CLEAR(ItemLedgerEntry);
          ItemLedgerEntry.SETRANGE("Item No.",TempAssemblyLine."No.");
          ItemLedgerEntry.SETRANGE("Variant Code",TempAssemblyLine."Variant Code");
          ItemLedgerEntry.SETRANGE("Entry Type",ItemLedgerEntry."Entry Type"::"Assembly Consumption");
          // ItemLedgerEntry.SETRANGE(Description,TempAssemblyLine.Description); - bug in ATO - description is not filled in
          ItemLedgerEntry.SETRANGE("Location Code",TempAssemblyLine."Location Code");
          ItemLedgerEntry.SETRANGE(Quantity,-TempAssemblyLine."Quantity to Consume (Base)");
          ItemLedgerEntry.SETRANGE("Remaining Quantity",0);
          ItemLedgerEntry.SETRANGE("Invoiced Quantity",-TempAssemblyLine."Quantity to Consume (Base)");
          ItemLedgerEntry.SETRANGE("Unit of Measure Code",TempAssemblyLine."Unit of Measure Code");
          ItemLedgerEntry.SETRANGE(Open,FALSE);
          ItemLedgerEntry.SETRANGE("Document Line No.",TempAssemblyLine."Line No.");
          ItemLedgerEntry.SETRANGE("Order Line No.",TempAssemblyLine."Line No.");
          ItemLedgerEntry.SETRANGE("Dimension Set ID",TempAssemblyLine."Dimension Set ID");
          ItemLedgerEntry.SETRANGE("Assemble to Order",FALSE);
          Assert.AreEqual(1,ItemLedgerEntry.COUNT,'Wrong no. of consumpt. ILEs for item ' + TempAssemblyLine."No.");
          ItemLedgerEntry.FINDFIRST;
          VerifyApplicationEntry(ItemLedgerEntry);
        UNTIL TempAssemblyLine.NEXT = 0;

Example

There are no examples available.
Member of Lib.Library - Assembly


VerifyILEsUndo@78 Method

The procedure VerifyILEsUndo is available in codeunit 132207.

Syntax

VerifyILEsUndo@78(
    VAR TempPostedAssemblyHeader@1000 : TEMPORARY Record 910 TempPostedAssemblyHeader, //Reference Temporary parameter of type Record
    VAR TempPostedAssemblyLine@1004 : TEMPORARY Record 911 TempPostedAssemblyLine, //Reference Temporary parameter of type Record
    UndoEntries@1002 : Boolean UndoEntries //Input parameter of type Boolean
);

Parameters

TempPostedAssemblyHeader
Reference Temporary parameter of type Record
TempPostedAssemblyLine
Reference Temporary parameter of type Record
UndoEntries
Input parameter of type Boolean

Remarks

The relevant search keywords are: Verify, IL, Es, Undo.

For a clarification about how this function works, refer to the code listed below.

      // General filtering.
      ItemLedgerEntry.RESET;
      ItemLedgerEntry.SETRANGE("Posting Date",TempPostedAssemblyHeader."Posting Date");
      ItemLedgerEntry.SETRANGE("Source No.",TempPostedAssemblyHeader."Item No.");
      ItemLedgerEntry.SETRANGE("Source Type",ItemLedgerEntry."Source Type"::Item);
      ItemLedgerEntry.SETRANGE("Order Type",ItemLedgerEntry."Order Type"::Assembly);
      ItemLedgerEntry.SETRANGE("Order No.",TempPostedAssemblyHeader."Order No.");
      ItemLedgerEntry.SETRANGE("Cost Amount (Expected)",0);

      // Output entry.
      ItemLedgerEntry.SETRANGE("Item No.",TempPostedAssemblyHeader."Item No.");
      ItemLedgerEntry.SETRANGE("Variant Code",TempPostedAssemblyHeader."Variant Code");
      ItemLedgerEntry.SETRANGE("Entry Type",ItemLedgerEntry."Entry Type"::"Assembly Output");
      ItemLedgerEntry.SETRANGE("Location Code",TempPostedAssemblyHeader."Location Code");
      IF UndoEntries THEN BEGIN
        ItemLedgerEntry.SETRANGE(Quantity,-TempPostedAssemblyHeader."Quantity (Base)");
        ItemLedgerEntry.SETRANGE("Invoiced Quantity",-TempPostedAssemblyHeader."Quantity (Base)");
      END ELSE BEGIN
        ItemLedgerEntry.SETRANGE(Quantity,TempPostedAssemblyHeader."Quantity (Base)");
        ItemLedgerEntry.SETRANGE("Invoiced Quantity",TempPostedAssemblyHeader."Quantity (Base)");
      END;

      ItemLedgerEntry.SETRANGE("Assemble to Order",FALSE);
      ItemLedgerEntry.SETRANGE("Unit of Measure Code",TempPostedAssemblyHeader."Unit of Measure Code");
      ItemLedgerEntry.SETRANGE("Document Line No.",0);
      ItemLedgerEntry.SETRANGE("Order Line No.",0);
      ItemLedgerEntry.SETRANGE("Dimension Set ID",TempPostedAssemblyHeader."Dimension Set ID");
      ItemLedgerEntry.SETRANGE("Remaining Quantity",0);
      ItemLedgerEntry.SETRANGE(Open,FALSE);
      ItemLedgerEntry.SETRANGE(Correction,UndoEntries);
      Assert.AreEqual(1,ItemLedgerEntry.COUNT,'Wrong no. of output entries for item ' + TempPostedAssemblyHeader."Item No.");

      // Verify application entries
      ItemLedgerEntry.FINDFIRST;
      VerifyApplicationEntryUndo(ItemLedgerEntry);

      // Consumption entries.
      // Find posted assembly lines.
      TempPostedAssemblyLine.SETRANGE(Type,TempPostedAssemblyLine.Type::Item);

      IF TempPostedAssemblyLine.FINDSET THEN
        REPEAT
          CLEAR(ItemLedgerEntry);
          ItemLedgerEntry.SETRANGE("Order Type",ItemLedgerEntry."Order Type"::Assembly);
          ItemLedgerEntry.SETRANGE("Order No.",TempPostedAssemblyHeader."Order No.");
          ItemLedgerEntry.SETRANGE("Item No.",TempPostedAssemblyLine."No.");
          ItemLedgerEntry.SETRANGE("Variant Code",TempPostedAssemblyLine."Variant Code");
          ItemLedgerEntry.SETRANGE("Entry Type",ItemLedgerEntry."Entry Type"::"Assembly Consumption");
          ItemLedgerEntry.SETRANGE("Location Code",TempPostedAssemblyLine."Location Code");
          IF UndoEntries THEN BEGIN
            ItemLedgerEntry.SETRANGE(Quantity,TempPostedAssemblyLine."Quantity (Base)");
            ItemLedgerEntry.SETRANGE("Remaining Quantity",TempPostedAssemblyLine."Quantity (Base)");
            ItemLedgerEntry.SETRANGE("Invoiced Quantity",TempPostedAssemblyLine."Quantity (Base)");
          END ELSE BEGIN
            ItemLedgerEntry.SETRANGE(Quantity,-TempPostedAssemblyLine."Quantity (Base)");
            ItemLedgerEntry.SETRANGE("Remaining Quantity",0);
            ItemLedgerEntry.SETRANGE("Invoiced Quantity",-TempPostedAssemblyLine."Quantity (Base)");
          END;
          ItemLedgerEntry.SETRANGE("Assemble to Order",FALSE);
          ItemLedgerEntry.SETRANGE("Unit of Measure Code",TempPostedAssemblyLine."Unit of Measure Code");
          ItemLedgerEntry.SETRANGE(Open,UndoEntries);
          ItemLedgerEntry.SETRANGE(Correction,UndoEntries);
          ItemLedgerEntry.SETRANGE("Document Line No.",TempPostedAssemblyLine."Line No.");
          ItemLedgerEntry.SETRANGE("Order Line No.",TempPostedAssemblyLine."Line No.");
          ItemLedgerEntry.SETRANGE("Dimension Set ID",TempPostedAssemblyLine."Dimension Set ID");
          Assert.AreEqual(1,ItemLedgerEntry.COUNT,'Wrong no. of consumpt. ILEs for item ' + TempPostedAssemblyLine."No.");
          ItemLedgerEntry.FINDFIRST;
          VerifyApplicationEntryUndo(ItemLedgerEntry);
        UNTIL TempPostedAssemblyLine.NEXT = 0;

Example

The below example is extracted from the test automation codeunit 137097 to show one way of using this function.

      // Create AO
      CreateAssembledItem(Item,Item."Assembly Policy"::"Assemble-to-Order",LibraryRandom.RandInt(10),
        LibraryRandom.RandInt(10),LibraryRandom.RandInt(10),LibraryRandom.RandDec(1000,2));
      OrderQty := LibraryRandom.RandDec(1000,2) + 1;
      DueDate := CALCDATE('<+' + FORMAT(LibraryRandom.RandInt(30)) + 'D>',WorkDate2);

      IF IsATO THEN BEGIN
        CreateSalesOrder(SalesHeader,Item."No.",'',OrderQty,DueDate,LocationCode);
        FindSOL(SalesHeader,SalesLine,1);
        SalesLine.AsmToOrderExists(AssemblyHeader);
      END ELSE
        CreateAssemblyOrder(AssemblyHeader,Item,LocationCode,'','',DueDate,OrderQty);

      // Add enough inventory for comp and post
      LibraryAssembly.AddCompInventoryToBin(AssemblyHeader,WORKDATE,0,LocationCode,'');
      IF FullPosting THEN BEGIN
        IF IsATO THEN
          LibrarySales.PostSalesDocument(SalesHeader,TRUE,FALSE)
        ELSE
          PostAssemblyOrderQty(AssemblyHeader,OrderQty)
      END ELSE BEGIN
        IF IsATO THEN BEGIN
          SalesLine.FIND;
          SalesLine.VALIDATE("Qty. to Ship",ROUND(SalesLine."Qty. to Ship" / 2,0.00001));
          SalesLine.MODIFY(TRUE);
          LibrarySales.PostSalesDocument(SalesHeader,TRUE,FALSE);
          AssemblyHeader.FIND;
        END ELSE
          PostAssemblyOrderQty(AssemblyHeader,OrderQty / 2);
      END;

      // Copy docs to temp
      FindPostedAssemblyHeaderNotReversed(PostedAssemblyHeader,AssemblyHeader."No.");
      CopyPostedAOToTemp(PostedAssemblyHeader,TempPostedAssemblyHeader,TempPostedAssemblyLine);
      IF NOT FullPosting THEN
        CopyAOToTemp(AssemblyHeader,TempAssemblyHeader,TempAssemblyLine);

      // Exercise - undo
      IF IsATO THEN BEGIN
        FindSalesShptLine(SalesLine,SalesShptLine);
        UndoSalesShptLine.SetHideDialog(TRUE);
        UndoSalesShptLine.RUN(SalesShptLine);
      END ELSE
        LibraryAssembly.UndoPostedAssembly(PostedAssemblyHeader,TRUE,'');

      // Verify
      CASE AssertOption OF
        // Check reversed docs
        AssertOption::ReversedDocs:
          BEGIN
            AssertReversedDoc(PostedAssemblyHeader,TempPostedAssemblyHeader);
            IF FullPosting THEN
              AssertNewAOAfterUndo(TempPostedAssemblyHeader,TempPostedAssemblyLine)
            ELSE
              AssertMergedAOAfterUndo(TempAssemblyHeader,TempAssemblyLine,TempPostedAssemblyHeader,TempPostedAssemblyLine);
          END;
        AssertOption::ILEs:
          BEGIN
            // Verify ILEs
            LibraryAssembly.VerifyILEsUndo(TempPostedAssemblyHeader,TempPostedAssemblyLine,FALSE);
            LibraryAssembly.VerifyILEsUndo(TempPostedAssemblyHeader,TempPostedAssemblyLine,TRUE);
          END;
        AssertOption::CapacityEntries:
          BEGIN
            // Verify Cap Ledger
            LibraryAssembly.VerifyCapEntriesUndo(TempPostedAssemblyHeader,TempPostedAssemblyLine,FALSE);
            LibraryAssembly.VerifyCapEntriesUndo(TempPostedAssemblyHeader,TempPostedAssemblyLine,TRUE);
          END;
      END;
Member of Lib.Library - Assembly


VerifyIndirectCostEntries@76 Method

The procedure VerifyIndirectCostEntries is available in codeunit 132207.

Syntax

VerifyIndirectCostEntries@76(
    AssemblyHeader@1000 : Record 900 AssemblyHeader //Input parameter of type Record
);

Parameters

AssemblyHeader
Input parameter of type Record

Remarks

The relevant search keywords are: Verify, Indirect, Cost, Entries.

For a clarification about how this function works, refer to the code listed below.

      GetCostInformation(UnitCost,Overhead,IndirectCost,PostedAssemblyLine.Type::Item,AssemblyHeader."Item No.",
        AssemblyHeader."Variant Code",AssemblyHeader."Location Code");
      PostedAssemblyHeader.RESET;
      PostedAssemblyHeader.SETRANGE("Order No.",AssemblyHeader."No.");
      PostedAssemblyHeader.FINDFIRST;

      // Output indirect cost.
      IndirectCostAmount :=
        GetValueEntriesAmount(PostedAssemblyHeader,ValueEntry."Item Ledger Entry Type"::"Assembly Output",
          ValueEntry."Entry Type"::"Direct Cost",ValueEntry."Variance Type"::" ",PostedAssemblyHeader."Item No.",FALSE) *
        IndirectCost / 100;

      ActualIndirectCostAmount :=
        GetValueEntriesAmount(PostedAssemblyHeader,ValueEntry."Item Ledger Entry Type"::"Assembly Output",
          ValueEntry."Entry Type"::"Indirect Cost",ValueEntry."Variance Type"::" ",PostedAssemblyHeader."Item No.",FALSE);

      Assert.AreNearlyEqual(IndirectCostAmount,ActualIndirectCostAmount,LibraryERM.GetAmountRoundingPrecision,
        'Wrong Output indirect cost');

      // Resource component indirect cost.
      PostedAssemblyLine.RESET;
      PostedAssemblyLine.SETRANGE("Document No.",PostedAssemblyHeader."No.");
      PostedAssemblyLine.SETRANGE("Order No.",PostedAssemblyHeader."Order No.");
      PostedAssemblyLine.SETRANGE(Type,PostedAssemblyLine.Type::Resource);
      IF PostedAssemblyLine.FINDSET THEN
        REPEAT
          FindLineValueEntries(ValueEntry,PostedAssemblyLine,ValueEntry."Entry Type"::"Direct Cost",
            ValueEntry."Item Ledger Entry Type"::" ");
          ValueEntry.FINDFIRST;
          Resource.GET(PostedAssemblyLine."No.");
          IndirectCostAmount := ValueEntry."Cost Amount (Actual)" * Resource."Indirect Cost %" / 100;
          FindLineValueEntries(ValueEntry,PostedAssemblyLine,ValueEntry."Entry Type"::"Indirect Cost",
            ValueEntry."Item Ledger Entry Type"::" ");
          IF ValueEntry.FINDFIRST THEN
            Assert.AreNearlyEqual(IndirectCostAmount,ValueEntry."Cost Amount (Actual)",LibraryERM.GetAmountRoundingPrecision,
              'Wrong component indirect cost');
        UNTIL PostedAssemblyLine.NEXT = 0;

Example

The below example is extracted from the test automation codeunit 137092 to show one way of using this function.

      // Setup.
      Initialize;
      LibraryAssembly.UpdateInventorySetup(InventorySetup,FALSE,FALSE,InventorySetup."Automatic Cost Adjustment"::Never,
        InventorySetup."Average Cost Calc. Type"::"Item & Location & Variant",
        InventorySetup."Average Cost Period"::Day);
      LibraryAssembly.SetupAssemblyData(AssemblyHeader,WorkDate2,ParentCostingMethod,CompCostingMethod,
        Item."Replenishment System"::Assembly,'',TRUE);
      ItemFilter := LibraryAssembly.GetCompsToAdjust(ItemNo,ResourceNo,AssemblyHeader);
      LibraryAssembly.ModifyCostParams(AssemblyHeader."No.",FALSE,IndirectCost,0);
      LibraryAssembly.ModifyItem(AssemblyHeader."Item No.",FALSE,IndirectCost * LibraryRandom.RandDec(10,2),0);
      LibraryAssembly.AddCompInventory(AssemblyHeader,WorkDate2,0);

      // Exercise.
      LibraryAssembly.PrepareOrderPosting(AssemblyHeader,TempAssemblyLine,HeaderQtyFactor,PartialPostFactor,TRUE,WorkDate2);
      LibraryAssembly.CalcOrderCostAmount(GlobalMaterialCost,GlobalResourceCost,GlobalResourceOvhd,GlobalAsmOvhd,AssemblyHeader."No.");
      AssembledQty := AssemblyHeader."Quantity to Assemble";

      // Check statistics before posting: post factor is 0.
      GlobalPartialPostFactor := 0;
      CheckStatisticsPage(AssemblyHeader);

      LibraryAssembly.PostAssemblyHeader(AssemblyHeader,ExpectedError);
      IF NOT PostWithoutAdj THEN
        LibraryCosting.AdjustCostItemEntries(ItemFilter,'');

      // Verify.
      IF ExpectedError = '' THEN BEGIN
        IF PartialPostFactor < 100 THEN BEGIN
          // Check statistics after partial posting.
          GlobalPartialPostFactor := PartialPostFactor / 100;
          CheckStatisticsPage(AssemblyHeader);
        END;
        LibraryAssembly.VerifyPartialPosting(AssemblyHeader,HeaderQtyFactor);
        LibraryAssembly.VerifyPostedAssemblyHeader(TempAssemblyLine,AssemblyHeader,AssembledQty);
        LibraryAssembly.VerifyPostedComments(AssemblyHeader);
        LibraryAssembly.VerifyILEs(TempAssemblyLine,AssemblyHeader,AssembledQty);
        LibraryAssembly.VerifyValueEntries(TempAssemblyLine,AssemblyHeader,AssembledQty);
        LibraryAssembly.VerifyIndirectCostEntries(AssemblyHeader);
        LibraryAssembly.VerifyResEntries(TempAssemblyLine,AssemblyHeader);
        LibraryAssembly.VerifyCapEntries(TempAssemblyLine,AssemblyHeader);
        LibraryAssembly.VerifyItemRegister(AssemblyHeader);
      END;

      // Tear down.
      LibraryAssembly.UpdateInventorySetup(InventorySetup,FALSE,FALSE,InventorySetup."Automatic Cost Adjustment"::Never,
        InventorySetup."Average Cost Calc. Type"::Item,InventorySetup."Average Cost Period"::Day);

      EXIT(AssemblyHeader."No.");
Member of Lib.Library - Assembly


VerifyItemRegister@37 Method

The procedure VerifyItemRegister is available in codeunit 132207.

Syntax

VerifyItemRegister@37(
    AssemblyHeader@1000 : Record 900 AssemblyHeader //Input parameter of type Record
);

Parameters

AssemblyHeader
Input parameter of type Record

Remarks

The relevant search keywords are: Verify, Item, Register.

For a clarification about how this function works, refer to the code listed below.

      SourceCodeSetup.GET;
      ItemLedgerEntry.RESET;
      ItemLedgerEntry.SETRANGE("Order Type",ItemLedgerEntry."Order Type"::Assembly);
      ItemLedgerEntry.SETRANGE("Order No.",AssemblyHeader."No.");
      ItemLedgerEntry.SETRANGE("Posting Date",AssemblyHeader."Posting Date");
      IF ItemLedgerEntry.FINDFIRST THEN
        ILEMin := ItemLedgerEntry."Entry No.";
      IF ItemLedgerEntry.FINDLAST THEN
        ILEMax := ItemLedgerEntry."Entry No.";

      ValueEntry.RESET;
      ValueEntry.SETRANGE("Order Type",ValueEntry."Order Type"::Assembly);
      ValueEntry.SETRANGE("Order No.",AssemblyHeader."No.");
      ValueEntry.SETRANGE("Posting Date",AssemblyHeader."Posting Date");
      ValueEntry.SETRANGE("Source Code",SourceCodeSetup.Assembly);
      IF ValueEntry.FINDFIRST THEN
        ValueEntryMin := ValueEntry."Entry No.";
      IF ValueEntry.FINDLAST THEN
        ValueEntryMax := ValueEntry."Entry No.";

      CapacityLedgerEntry.RESET;
      CapacityLedgerEntry.SETRANGE("Order Type",CapacityLedgerEntry."Order Type"::Assembly);
      CapacityLedgerEntry.SETRANGE("Order No.",AssemblyHeader."No.");
      CapacityLedgerEntry.SETRANGE("Posting Date",AssemblyHeader."Posting Date");
      IF CapacityLedgerEntry.FINDFIRST THEN
        CapEntryMin := CapacityLedgerEntry."Entry No.";
      IF CapacityLedgerEntry.FINDLAST THEN
        CapEntryMax := CapacityLedgerEntry."Entry No.";

      ItemRegister.RESET;
      ItemRegister.SETRANGE("From Entry No.",ILEMin);
      ItemRegister.SETRANGE("To Entry No.",ILEMax);
      ItemRegister.SETRANGE("From Value Entry No.",ValueEntryMin);
      ItemRegister.SETRANGE("To Value Entry No.",ValueEntryMax);
      ItemRegister.SETRANGE("From Capacity Entry No.",CapEntryMin);
      ItemRegister.SETRANGE("To Capacity Entry No.",CapEntryMax);
      ItemRegister.SETRANGE("Source Code",SourceCodeSetup.Assembly);
      ItemRegister.FINDFIRST;

Example

The below example is extracted from the test automation codeunit 137092 to show one way of using this function.

      // Setup.
      Initialize;
      LibraryAssembly.UpdateAssemblySetup(AssemblySetup,'',DimensionsFrom,LibraryUtility.GetGlobalNoSeriesCode);
      LibraryAssembly.SetupAssemblyData(AssemblyHeader,WorkDate2,Item."Costing Method"::Standard,Item."Costing Method"::Average,
        Item."Replenishment System"::Assembly,'',TRUE);
      LibraryAssembly.AddCompInventory(AssemblyHeader,WorkDate2,0);

      // Exercise.
      LibraryAssembly.CheckOrderDimensions(AssemblyHeader,DimensionsFrom);
      IF OverrideDimensions THEN
        LibraryAssembly.EditOrderDimensions(AssemblyHeader);
      ExpectedError := LibraryAssembly.BlockOrderDimensions(AssemblyHeader,HeaderBlockType,CompBlockType);

      IF ExpectedError = '' THEN
        ExpectedError := AddAOItemDimension(AssemblyHeader,DefaultHeaderValuePosting,DefaultCompValuePosting);

      SetShortcutDimensions(AssemblyHeader,1);
      SetShortcutDimensions(AssemblyHeader,2);

      LibraryAssembly.PrepareOrderPosting(AssemblyHeader,TempAssemblyLine,100,100,TRUE,WorkDate2);
      LibraryAssembly.PostAssemblyHeader(AssemblyHeader,ExpectedError);

      // Verify.
      IF ExpectedError = '' THEN BEGIN
        LibraryAssembly.VerifyPostedAssemblyHeader(TempAssemblyLine,AssemblyHeader,AssemblyHeader.Quantity);
        LibraryAssembly.VerifyPostedComments(AssemblyHeader);
        LibraryAssembly.VerifyILEs(TempAssemblyLine,AssemblyHeader,AssemblyHeader."Quantity to Assemble");
        LibraryAssembly.VerifyValueEntries(TempAssemblyLine,AssemblyHeader,AssemblyHeader."Quantity to Assemble");
        LibraryAssembly.VerifyResEntries(TempAssemblyLine,AssemblyHeader);
        LibraryAssembly.VerifyCapEntries(TempAssemblyLine,AssemblyHeader);
        LibraryAssembly.VerifyItemRegister(AssemblyHeader);
      END;

      // Tear down.
Member of Lib.Library - Assembly


VerifyLineAdjustmentEntry@218 Method

The procedure VerifyLineAdjustmentEntry is available in codeunit 132207.

Syntax

VerifyLineAdjustmentEntry@218(
    PostedAssemblyLine@1000 : Record 911 PostedAssemblyLine, //Input parameter of type Record
    FinalAdjSource@1002 : Option FinalAdjSource //Input parameter of type Option
);

Parameters

PostedAssemblyLine
Input parameter of type Record
FinalAdjSource
Input parameter of type Option

Remarks

The relevant search keywords are: Verify, Line, Adjustment, Entry.

For a clarification about how this function works, refer to the code listed below.

      Item.GET(PostedAssemblyLine."No.");
      GetCostInformation(UnitCost,Overhead,IndirectCost,PostedAssemblyLine.Type::Item,
        PostedAssemblyLine."No.",PostedAssemblyLine."Variant Code",PostedAssemblyLine."Location Code");
      FindLineValueEntries(ValueEntry,PostedAssemblyLine,ValueEntry."Entry Type"::"Direct Cost",
        ValueEntry."Item Ledger Entry Type"::"Assembly Consumption");
      ValueEntry.SETRANGE(Adjustment,TRUE);

      IF NeedsAdjustment(AdjUnitCost,Item,PostedAssemblyLine,FinalAdjSource,UnitCost)
      THEN BEGIN
        Assert.AreEqual(1,ValueEntry.COUNT,'Different than 1 entry for comp. item no. ' + PostedAssemblyLine."No.");
        ValueEntry.FINDFIRST;
        Assert.AreNearlyEqual(ABS(AdjUnitCost),ABS(ValueEntry."Cost per Unit"),
          LibraryERM.GetAmountRoundingPrecision,'Wrong unit cost for adj.');
        Assert.AreNearlyEqual(ValueEntry."Cost Amount (Actual)",ValueEntry."Cost per Unit" * ValueEntry."Valued Quantity",
          LibraryERM.GetAmountRoundingPrecision,'Wrong adj. entry cost amount.');
      END ELSE BEGIN
        // For differences in adj. amount less than 0.01, eliminate rounding adjustment entries.
        ValueEntry.SETFILTER("Cost Amount (Actual)",'>%1',LibraryERM.GetAmountRoundingPrecision);
        Assert.IsTrue(ValueEntry.ISEMPTY,'Unexpected adj. entries for comp item no. ' + PostedAssemblyLine."No.");
      END;

Example

There are no examples available.
Member of Lib.Library - Assembly


VerifyLineComment@83 Method

The procedure VerifyLineComment is available in codeunit 132207.

Syntax

VerifyLineComment@83(
    AssemblyHeader@1000 : Record 900 AssemblyHeader, //Input parameter of type Record
    AssemblyLineNo@1002 : Integer AssemblyLineNo //Input parameter of type Integer
);

Parameters

AssemblyHeader
Input parameter of type Record
AssemblyLineNo
Input parameter of type Integer

Remarks

The relevant search keywords are: Verify, Line, Comment.

For a clarification about how this function works, refer to the code listed below.

      AssemblyCommentLine.RESET;
      AssemblyCommentLine.SETRANGE("Document Type",AssemblyCommentLine."Document Type"::"Assembly Order");
      AssemblyCommentLine.SETRANGE("Document No.",AssemblyHeader."No.");
      AssemblyCommentLine.SETRANGE("Document Line No.",AssemblyLineNo);
      AssemblyCommentLine.SETRANGE(Comment,'Order:' + AssemblyHeader."No." + ', Line:' + FORMAT(AssemblyLineNo));
      AssemblyCommentLine.FINDFIRST;
      Assert.AreEqual(1,AssemblyCommentLine.COUNT,'Wrong no. of comment lines.');

Example

There are no examples available.
Member of Lib.Library - Assembly


VerifyPartialPosting@63 Method

The procedure VerifyPartialPosting is available in codeunit 132207.

Syntax

VerifyPartialPosting@63(
    AssemblyHeader@1000 : Record 900 AssemblyHeader, //Input parameter of type Record
    HeaderQtyFactor@1003 : Decimal HeaderQtyFactor //Input parameter of type Decimal
);

Parameters

AssemblyHeader
Input parameter of type Record
HeaderQtyFactor
Input parameter of type Decimal

Remarks

The relevant search keywords are: Verify, Partial, Posting.

For a clarification about how this function works, refer to the code listed below.

      IF HeaderQtyFactor <> 100 THEN BEGIN
        AssemblyHeader.GET(AssemblyHeader."Document Type",AssemblyHeader."No.");
        AssemblyHeader.TESTFIELD("Quantity to Assemble",AssemblyHeader.Quantity * (100 - HeaderQtyFactor) / 100);
        AssemblyHeader.TESTFIELD("Remaining Quantity",AssemblyHeader."Quantity to Assemble");
        AssemblyLine.SETRANGE("Document Type",AssemblyHeader."Document Type");
        AssemblyLine.SETRANGE("Document No.",AssemblyHeader."No.");
        AssemblyLine.FINDSET;
        REPEAT
          IF AssemblyLine."Resource Usage Type" <> AssemblyLine."Resource Usage Type"::Fixed THEN BEGIN
            Assert.AreNearlyEqual(AssemblyHeader.Quantity * AssemblyHeader."Qty. per Unit of Measure" *
              AssemblyLine."Quantity per",AssemblyLine.Quantity,
              LibraryERM.GetUnitAmountRoundingPrecision,'Wrong partial line quantity.');
            Assert.AreNearlyEqual(
              AssemblyHeader."Remaining Quantity" * AssemblyHeader."Qty. per Unit of Measure" * AssemblyLine."Quantity per",
              AssemblyLine."Quantity to Consume",
              LibraryERM.GetUnitAmountRoundingPrecision,'Wrong partial line qty. to consume.');
          END ELSE BEGIN
            Assert.AreNearlyEqual(AssemblyLine."Quantity per",AssemblyLine.Quantity,
              LibraryERM.GetUnitAmountRoundingPrecision,'Wrong partial line qty. - fixed.');
            Assert.AreNearlyEqual(
              AssemblyLine.Quantity - AssemblyLine."Consumed Quantity",AssemblyLine."Quantity to Consume",
              LibraryERM.GetUnitAmountRoundingPrecision,'Wrong partial line qty. to consume - fixed.');
          END;
        UNTIL AssemblyLine.NEXT = 0;
      END;

Example

The below example is extracted from the test automation codeunit 137092 to show one way of using this function.

      // Setup.
      Initialize;
      LibraryAssembly.UpdateInventorySetup(InventorySetup,FALSE,FALSE,InventorySetup."Automatic Cost Adjustment"::Never,
        InventorySetup."Average Cost Calc. Type"::"Item & Location & Variant",
        InventorySetup."Average Cost Period"::Day);
      LibraryAssembly.SetupAssemblyData(AssemblyHeader,WorkDate2,ParentCostingMethod,CompCostingMethod,
        Item."Replenishment System"::Assembly,'',TRUE);
      ItemFilter := LibraryAssembly.GetCompsToAdjust(ItemNo,ResourceNo,AssemblyHeader);
      LibraryAssembly.ModifyCostParams(AssemblyHeader."No.",FALSE,IndirectCost,0);
      LibraryAssembly.ModifyItem(AssemblyHeader."Item No.",FALSE,IndirectCost * LibraryRandom.RandDec(10,2),0);
      LibraryAssembly.AddCompInventory(AssemblyHeader,WorkDate2,0);

      // Exercise.
      LibraryAssembly.PrepareOrderPosting(AssemblyHeader,TempAssemblyLine,HeaderQtyFactor,PartialPostFactor,TRUE,WorkDate2);
      LibraryAssembly.CalcOrderCostAmount(GlobalMaterialCost,GlobalResourceCost,GlobalResourceOvhd,GlobalAsmOvhd,AssemblyHeader."No.");
      AssembledQty := AssemblyHeader."Quantity to Assemble";

      // Check statistics before posting: post factor is 0.
      GlobalPartialPostFactor := 0;
      CheckStatisticsPage(AssemblyHeader);

      LibraryAssembly.PostAssemblyHeader(AssemblyHeader,ExpectedError);
      IF NOT PostWithoutAdj THEN
        LibraryCosting.AdjustCostItemEntries(ItemFilter,'');

      // Verify.
      IF ExpectedError = '' THEN BEGIN
        IF PartialPostFactor < 100 THEN BEGIN
          // Check statistics after partial posting.
          GlobalPartialPostFactor := PartialPostFactor / 100;
          CheckStatisticsPage(AssemblyHeader);
        END;
        LibraryAssembly.VerifyPartialPosting(AssemblyHeader,HeaderQtyFactor);
        LibraryAssembly.VerifyPostedAssemblyHeader(TempAssemblyLine,AssemblyHeader,AssembledQty);
        LibraryAssembly.VerifyPostedComments(AssemblyHeader);
        LibraryAssembly.VerifyILEs(TempAssemblyLine,AssemblyHeader,AssembledQty);
        LibraryAssembly.VerifyValueEntries(TempAssemblyLine,AssemblyHeader,AssembledQty);
        LibraryAssembly.VerifyIndirectCostEntries(AssemblyHeader);
        LibraryAssembly.VerifyResEntries(TempAssemblyLine,AssemblyHeader);
        LibraryAssembly.VerifyCapEntries(TempAssemblyLine,AssemblyHeader);
        LibraryAssembly.VerifyItemRegister(AssemblyHeader);
      END;

      // Tear down.
      LibraryAssembly.UpdateInventorySetup(InventorySetup,FALSE,FALSE,InventorySetup."Automatic Cost Adjustment"::Never,
        InventorySetup."Average Cost Calc. Type"::Item,InventorySetup."Average Cost Period"::Day);

      EXIT(AssemblyHeader."No.");
Member of Lib.Library - Assembly


VerifyPostedAssemblyHeader@29 Method

The procedure VerifyPostedAssemblyHeader is available in codeunit 132207.

Syntax

VerifyPostedAssemblyHeader@29(
    VAR TempAssemblyLine@1003 : TEMPORARY Record 901 TempAssemblyLine, //Reference Temporary parameter of type Record
    AssemblyHeader@1000 : Record 900 AssemblyHeader, //Input parameter of type Record
    AssembledQty@1004 : Decimal AssembledQty //Input parameter of type Decimal
);

Parameters

TempAssemblyLine
Reference Temporary parameter of type Record
AssemblyHeader
Input parameter of type Record
AssembledQty
Input parameter of type Decimal

Remarks

The relevant search keywords are: Verify, Posted, Assembly, Header.

For a clarification about how this function works, refer to the code listed below.

      PostedAssemblyHeader.RESET;
      PostedAssemblyHeader.SETRANGE("Order No.",AssemblyHeader."No.");
      PostedAssemblyHeader.SETRANGE("Item No.",AssemblyHeader."Item No.");
      PostedAssemblyHeader.SETRANGE("Variant Code",AssemblyHeader."Variant Code");
      PostedAssemblyHeader.SETRANGE(Description,AssemblyHeader.Description);
      PostedAssemblyHeader.SETRANGE("Inventory Posting Group",AssemblyHeader."Inventory Posting Group");
      PostedAssemblyHeader.SETRANGE("Gen. Prod. Posting Group",AssemblyHeader."Gen. Prod. Posting Group");
      PostedAssemblyHeader.SETRANGE("Location Code",AssemblyHeader."Location Code");
      PostedAssemblyHeader.SETRANGE("Shortcut Dimension 1 Code",AssemblyHeader."Shortcut Dimension 1 Code");
      PostedAssemblyHeader.SETRANGE("Shortcut Dimension 2 Code",AssemblyHeader."Shortcut Dimension 2 Code");
      PostedAssemblyHeader.SETRANGE("Posting Date",AssemblyHeader."Posting Date");
      PostedAssemblyHeader.SETRANGE(Quantity,AssembledQty);
      PostedAssemblyHeader.SETRANGE("Unit Cost",AssemblyHeader."Unit Cost");
      PostedAssemblyHeader.SETRANGE("Unit of Measure Code",AssemblyHeader."Unit of Measure Code");
      PostedAssemblyHeader.SETRANGE("Dimension Set ID",AssemblyHeader."Dimension Set ID");
      Assert.AreEqual(1,PostedAssemblyHeader.COUNT,'Wrong no. of posted assembly order records!');
      PostedAssemblyHeader.FINDFIRST;
      Assert.AreNearlyEqual(AssemblyHeader."Cost Amount" * AssembledQty / AssemblyHeader.Quantity,PostedAssemblyHeader."Cost Amount",
        LibraryERM.GetAmountRoundingPrecision,'Wrong posted cost amount.');
      IF TempAssemblyLine.FINDSET THEN
        REPEAT
          PostedAssemblyLine.RESET;
          PostedAssemblyLine.SETRANGE("Document No.",PostedAssemblyHeader."No.");
          PostedAssemblyLine.SETRANGE("Order Line No.",TempAssemblyLine."Line No.");
          PostedAssemblyLine.SETRANGE(Type,TempAssemblyLine.Type);
          PostedAssemblyLine.SETRANGE("No.",TempAssemblyLine."No.");
          PostedAssemblyLine.SETRANGE("Variant Code",TempAssemblyLine."Variant Code");
          PostedAssemblyLine.SETRANGE(Description,TempAssemblyLine.Description);
          PostedAssemblyLine.SETRANGE("Resource Usage Type",TempAssemblyLine."Resource Usage Type");
          PostedAssemblyLine.SETRANGE("Location Code",TempAssemblyLine."Location Code");
          PostedAssemblyLine.SETRANGE("Shortcut Dimension 1 Code",TempAssemblyLine."Shortcut Dimension 1 Code");
          PostedAssemblyLine.SETRANGE("Shortcut Dimension 2 Code",TempAssemblyLine."Shortcut Dimension 2 Code");
          PostedAssemblyLine.SETRANGE(Quantity,TempAssemblyLine."Quantity to Consume");
          PostedAssemblyLine.SETRANGE("Unit of Measure Code",TempAssemblyLine."Unit of Measure Code");
          PostedAssemblyLine.SETRANGE("Dimension Set ID",TempAssemblyLine."Dimension Set ID");
          PostedAssemblyLine.SETRANGE("Unit Cost",TempAssemblyLine."Unit Cost");
          Assert.AreEqual(1,PostedAssemblyLine.COUNT,'Wrong no. of posted lines for ' + TempAssemblyLine."No.");
          PostedAssemblyLine.FINDFIRST;
          // Do not check cost amount for comment lines.
          IF TempAssemblyLine.Type <> TempAssemblyLine.Type::" " THEN
            Assert.AreNearlyEqual(
              TempAssemblyLine."Cost Amount" * TempAssemblyLine."Quantity to Consume" / TempAssemblyLine.Quantity,
              PostedAssemblyLine."Cost Amount",LibraryERM.GetAmountRoundingPrecision,'Wrong posted line cost amount.');
        UNTIL TempAssemblyLine.NEXT = 0;

Example

The below example is extracted from the test automation codeunit 137092 to show one way of using this function.

      // Setup.
      Initialize;
      LibraryAssembly.UpdateAssemblySetup(AssemblySetup,'',DimensionsFrom,LibraryUtility.GetGlobalNoSeriesCode);
      LibraryAssembly.SetupAssemblyData(AssemblyHeader,WorkDate2,Item."Costing Method"::Standard,Item."Costing Method"::Average,
        Item."Replenishment System"::Assembly,'',TRUE);
      LibraryAssembly.AddCompInventory(AssemblyHeader,WorkDate2,0);

      // Exercise.
      LibraryAssembly.CheckOrderDimensions(AssemblyHeader,DimensionsFrom);
      IF OverrideDimensions THEN
        LibraryAssembly.EditOrderDimensions(AssemblyHeader);
      ExpectedError := LibraryAssembly.BlockOrderDimensions(AssemblyHeader,HeaderBlockType,CompBlockType);

      IF ExpectedError = '' THEN
        ExpectedError := AddAOItemDimension(AssemblyHeader,DefaultHeaderValuePosting,DefaultCompValuePosting);

      SetShortcutDimensions(AssemblyHeader,1);
      SetShortcutDimensions(AssemblyHeader,2);

      LibraryAssembly.PrepareOrderPosting(AssemblyHeader,TempAssemblyLine,100,100,TRUE,WorkDate2);
      LibraryAssembly.PostAssemblyHeader(AssemblyHeader,ExpectedError);

      // Verify.
      IF ExpectedError = '' THEN BEGIN
        LibraryAssembly.VerifyPostedAssemblyHeader(TempAssemblyLine,AssemblyHeader,AssemblyHeader.Quantity);
        LibraryAssembly.VerifyPostedComments(AssemblyHeader);
        LibraryAssembly.VerifyILEs(TempAssemblyLine,AssemblyHeader,AssemblyHeader."Quantity to Assemble");
        LibraryAssembly.VerifyValueEntries(TempAssemblyLine,AssemblyHeader,AssemblyHeader."Quantity to Assemble");
        LibraryAssembly.VerifyResEntries(TempAssemblyLine,AssemblyHeader);
        LibraryAssembly.VerifyCapEntries(TempAssemblyLine,AssemblyHeader);
        LibraryAssembly.VerifyItemRegister(AssemblyHeader);
      END;

      // Tear down.
Member of Lib.Library - Assembly


VerifyPostedComments@42 Method

The procedure VerifyPostedComments is available in codeunit 132207.

Syntax

VerifyPostedComments@42(
    AssemblyHeader@1000 : Record 900 AssemblyHeader //Input parameter of type Record
);

Parameters

AssemblyHeader
Input parameter of type Record

Remarks

The relevant search keywords are: Verify, Posted, Comments.

For a clarification about how this function works, refer to the code listed below.

      FindPostedAssemblyHeaders(PostedAssemblyHeader,AssemblyHeader);
      PostedAssemblyHeader.FINDFIRST;
      VerifyPostedLineComment(PostedAssemblyHeader,0);

      FindPostedAssemblyLines(PostedAssemblyLine,PostedAssemblyHeader);
      IF PostedAssemblyLine.FINDSET THEN
        REPEAT
          VerifyPostedLineComment(PostedAssemblyHeader,PostedAssemblyLine."Line No.");
        UNTIL PostedAssemblyLine.NEXT = 0;

Example

The below example is extracted from the test automation codeunit 137092 to show one way of using this function.

      // Setup.
      Initialize;
      LibraryAssembly.UpdateAssemblySetup(AssemblySetup,'',DimensionsFrom,LibraryUtility.GetGlobalNoSeriesCode);
      LibraryAssembly.SetupAssemblyData(AssemblyHeader,WorkDate2,Item."Costing Method"::Standard,Item."Costing Method"::Average,
        Item."Replenishment System"::Assembly,'',TRUE);
      LibraryAssembly.AddCompInventory(AssemblyHeader,WorkDate2,0);

      // Exercise.
      LibraryAssembly.CheckOrderDimensions(AssemblyHeader,DimensionsFrom);
      IF OverrideDimensions THEN
        LibraryAssembly.EditOrderDimensions(AssemblyHeader);
      ExpectedError := LibraryAssembly.BlockOrderDimensions(AssemblyHeader,HeaderBlockType,CompBlockType);

      IF ExpectedError = '' THEN
        ExpectedError := AddAOItemDimension(AssemblyHeader,DefaultHeaderValuePosting,DefaultCompValuePosting);

      SetShortcutDimensions(AssemblyHeader,1);
      SetShortcutDimensions(AssemblyHeader,2);

      LibraryAssembly.PrepareOrderPosting(AssemblyHeader,TempAssemblyLine,100,100,TRUE,WorkDate2);
      LibraryAssembly.PostAssemblyHeader(AssemblyHeader,ExpectedError);

      // Verify.
      IF ExpectedError = '' THEN BEGIN
        LibraryAssembly.VerifyPostedAssemblyHeader(TempAssemblyLine,AssemblyHeader,AssemblyHeader.Quantity);
        LibraryAssembly.VerifyPostedComments(AssemblyHeader);
        LibraryAssembly.VerifyILEs(TempAssemblyLine,AssemblyHeader,AssemblyHeader."Quantity to Assemble");
        LibraryAssembly.VerifyValueEntries(TempAssemblyLine,AssemblyHeader,AssemblyHeader."Quantity to Assemble");
        LibraryAssembly.VerifyResEntries(TempAssemblyLine,AssemblyHeader);
        LibraryAssembly.VerifyCapEntries(TempAssemblyLine,AssemblyHeader);
        LibraryAssembly.VerifyItemRegister(AssemblyHeader);
      END;

      // Tear down.
Member of Lib.Library - Assembly


VerifyPostedLineComment@47 Method

The procedure VerifyPostedLineComment is available in codeunit 132207.

Syntax

VerifyPostedLineComment@47(
    PostedAssemblyHeader@1000 : Record 910 PostedAssemblyHeader, //Input parameter of type Record
    PostedAssemblyLineNo@1002 : Integer PostedAssemblyLineNo //Input parameter of type Integer
);

Parameters

PostedAssemblyHeader
Input parameter of type Record
PostedAssemblyLineNo
Input parameter of type Integer

Remarks

The relevant search keywords are: Verify, Posted, Line, Comment.

For a clarification about how this function works, refer to the code listed below.

      AssemblyCommentLine.RESET;
      AssemblyCommentLine.SETRANGE("Document Type",AssemblyCommentLine."Document Type"::"Posted Assembly");
      AssemblyCommentLine.SETRANGE("Document No.",PostedAssemblyHeader."No.");
      AssemblyCommentLine.SETRANGE("Document Line No.",PostedAssemblyLineNo);
      AssemblyCommentLine.SETRANGE(Comment,'Order:' + PostedAssemblyHeader."Order No." + ', Line:' + FORMAT(PostedAssemblyLineNo));
      AssemblyCommentLine.FINDFIRST;
      Assert.AreEqual(1,AssemblyCommentLine.COUNT,'Wrong no. of comment lines.');

Example

There are no examples available.
Member of Lib.Library - Assembly


VerifyResEntries@34 Method

The procedure VerifyResEntries is available in codeunit 132207.

Syntax

VerifyResEntries@34(
    VAR TempAssemblyLine@1003 : TEMPORARY Record 901 TempAssemblyLine, //Reference Temporary parameter of type Record
    AssemblyHeader@1002 : Record 900 AssemblyHeader //Input parameter of type Record
);

Parameters

TempAssemblyLine
Reference Temporary parameter of type Record
AssemblyHeader
Input parameter of type Record

Remarks

The relevant search keywords are: Verify, Resource, Entries.

For a clarification about how this function works, refer to the code listed below.

      VerifyResEntriesGeneric(TempAssemblyLine,AssemblyHeader,FALSE);

Example

The below example is extracted from the test automation codeunit 137092 to show one way of using this function.

      // Setup.
      Initialize;
      LibraryAssembly.UpdateAssemblySetup(AssemblySetup,'',DimensionsFrom,LibraryUtility.GetGlobalNoSeriesCode);
      LibraryAssembly.SetupAssemblyData(AssemblyHeader,WorkDate2,Item."Costing Method"::Standard,Item."Costing Method"::Average,
        Item."Replenishment System"::Assembly,'',TRUE);
      LibraryAssembly.AddCompInventory(AssemblyHeader,WorkDate2,0);

      // Exercise.
      LibraryAssembly.CheckOrderDimensions(AssemblyHeader,DimensionsFrom);
      IF OverrideDimensions THEN
        LibraryAssembly.EditOrderDimensions(AssemblyHeader);
      ExpectedError := LibraryAssembly.BlockOrderDimensions(AssemblyHeader,HeaderBlockType,CompBlockType);

      IF ExpectedError = '' THEN
        ExpectedError := AddAOItemDimension(AssemblyHeader,DefaultHeaderValuePosting,DefaultCompValuePosting);

      SetShortcutDimensions(AssemblyHeader,1);
      SetShortcutDimensions(AssemblyHeader,2);

      LibraryAssembly.PrepareOrderPosting(AssemblyHeader,TempAssemblyLine,100,100,TRUE,WorkDate2);
      LibraryAssembly.PostAssemblyHeader(AssemblyHeader,ExpectedError);

      // Verify.
      IF ExpectedError = '' THEN BEGIN
        LibraryAssembly.VerifyPostedAssemblyHeader(TempAssemblyLine,AssemblyHeader,AssemblyHeader.Quantity);
        LibraryAssembly.VerifyPostedComments(AssemblyHeader);
        LibraryAssembly.VerifyILEs(TempAssemblyLine,AssemblyHeader,AssemblyHeader."Quantity to Assemble");
        LibraryAssembly.VerifyValueEntries(TempAssemblyLine,AssemblyHeader,AssemblyHeader."Quantity to Assemble");
        LibraryAssembly.VerifyResEntries(TempAssemblyLine,AssemblyHeader);
        LibraryAssembly.VerifyCapEntries(TempAssemblyLine,AssemblyHeader);
        LibraryAssembly.VerifyItemRegister(AssemblyHeader);
      END;

      // Tear down.
Member of Lib.Library - Assembly


VerifyResEntriesATO@58 Method

The procedure VerifyResEntriesATO is available in codeunit 132207.

Syntax

VerifyResEntriesATO@58(
    VAR TempAssemblyLine@1003 : TEMPORARY Record 901 TempAssemblyLine, //Reference Temporary parameter of type Record
    AssemblyHeader@1002 : Record 900 AssemblyHeader //Input parameter of type Record
);

Parameters

TempAssemblyLine
Reference Temporary parameter of type Record
AssemblyHeader
Input parameter of type Record

Remarks

The relevant search keywords are: Verify, Resource, Entries, ATO.

For a clarification about how this function works, refer to the code listed below.

      VerifyResEntriesGeneric(TempAssemblyLine,AssemblyHeader,TRUE);

Example

The below example is extracted from the test automation codeunit 137096 to show one way of using this function.

      CreateAssembledItem(Item,Item."Assembly Policy"::"Assemble-to-Order",LibraryRandom.RandInt(10),
        LibraryRandom.RandInt(10),LibraryRandom.RandInt(10),LibraryRandom.RandInt(1000),
        Item."Costing Method"::FIFO);

      // Exercise - create SOL with ATO item
      OrderQty := LibraryRandom.RandInt(1000);
      DueDate := CALCDATE('<+' + FORMAT(LibraryRandom.RandInt(30)) + 'D>',WorkDate2);
      CreateSalesOrder(SalesHeader,Item."No.",'',OrderQty,DueDate,LocationCode);
      FindSOL(SalesHeader,SalesLine,1);
      FindAssemblyHeader(AssemblyHeader,AssemblyHeader."Document Type"::Order,Item,'',LocationCode,
        DueDate,Item."Base Unit of Measure",OrderQty);
      CopyAsmLinesToTemp(AssemblyHeader,TempAssemblyLine);

      // Add enough inventory for comp
      AddInvNonDirectLocAllComponent(AssemblyHeader,100);

      // Exercise - post SOs
      LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      // Verify - entries
      LibraryAssembly.VerifyILEsForAsmOnATO(TempAssemblyLine,AssemblyHeader,AssemblyHeader.Quantity);
      LibraryAssembly.VerifyValueEntriesATO(TempAssemblyLine,SalesHeader,AssemblyHeader,AssemblyHeader.Quantity);
      LibraryAssembly.VerifyResEntriesATO(TempAssemblyLine,AssemblyHeader);
      LibraryAssembly.VerifyCapEntriesATO(TempAssemblyLine,AssemblyHeader);
Member of Lib.Library - Assembly


VerifyResEntriesGeneric@57 Method

The procedure VerifyResEntriesGeneric is available in codeunit 132207.

Syntax

VerifyResEntriesGeneric@57(
    VAR TempAssemblyLine@1003 : TEMPORARY Record 901 TempAssemblyLine, //Reference Temporary parameter of type Record
    AssemblyHeader@1002 : Record 900 AssemblyHeader, //Input parameter of type Record
    IsATO@1000 : Boolean IsATO //Input parameter of type Boolean
);

Parameters

TempAssemblyLine
Reference Temporary parameter of type Record
AssemblyHeader
Input parameter of type Record
IsATO
Input parameter of type Boolean

Remarks

The relevant search keywords are: Verify, Resource, Entries, Generic.

For a clarification about how this function works, refer to the code listed below.

      SourceCodeSetup.GET;
      ResLedgerEntry.RESET;
      // General filtering.
      ResLedgerEntry.SETRANGE("Posting Date",AssemblyHeader."Posting Date");
      ResLedgerEntry.SETRANGE("Order Type",ResLedgerEntry."Order Type"::Assembly);
      ResLedgerEntry.SETRANGE("Order No.",AssemblyHeader."No.");
      ResLedgerEntry.SETRANGE("Entry Type",ResLedgerEntry."Entry Type"::Usage);
      IF IsATO THEN
        ResLedgerEntry.SETRANGE("Source Code",SourceCodeSetup.Sales)
      ELSE
        ResLedgerEntry.SETRANGE("Source Code",SourceCodeSetup.Assembly);

      // Usage entries.
      TempAssemblyLine.SETRANGE(Type,TempAssemblyLine.Type::Resource);
      IF TempAssemblyLine.FINDSET THEN
        REPEAT
          ResLedgerEntry.SETRANGE("Resource No.",TempAssemblyLine."No.");
          ResLedgerEntry.SETRANGE(Quantity,TempAssemblyLine."Quantity to Consume");
          ResLedgerEntry.SETRANGE("Unit of Measure Code",TempAssemblyLine."Unit of Measure Code");
          IF NOT IsATO THEN BEGIN // if ATO then dimensions can come from SOL also - skip checking them
            ResLedgerEntry.SETRANGE("Global Dimension 1 Code",TempAssemblyLine."Shortcut Dimension 1 Code");
            ResLedgerEntry.SETRANGE("Global Dimension 2 Code",TempAssemblyLine."Shortcut Dimension 2 Code");
            ResLedgerEntry.SETRANGE("Dimension Set ID",TempAssemblyLine."Dimension Set ID");
          END;
          ResLedgerEntry.SETRANGE("Order Line No.",TempAssemblyLine."Line No.");
          Assert.AreEqual(1,ResLedgerEntry.COUNT,'Wrong no. of res ledger entries for res. ' + TempAssemblyLine."No.");
          ResLedgerEntry.FINDFIRST;
          Assert.AreNearlyEqual(ROUND(TempAssemblyLine."Cost Amount" * TempAssemblyLine."Quantity to Consume" /
              TempAssemblyLine.Quantity,LibraryERM.GetAmountRoundingPrecision),ResLedgerEntry."Total Cost",
            LibraryERM.GetAmountRoundingPrecision,'Wrong Res. Ledger Cost amount for res. ' + TempAssemblyLine."No.")
        UNTIL TempAssemblyLine.NEXT = 0;

Example

There are no examples available.
Member of Lib.Library - Assembly


VerifySaleReservationEntryATO@39 Method

The procedure VerifySaleReservationEntryATO is available in codeunit 132207.

Syntax

VerifySaleReservationEntryATO@39(
    SalesLine@1001 : Record 37 SalesLine //Input parameter of type Record
);

Parameters

SalesLine
Input parameter of type Record

Return Value

Integer

Remarks

The relevant search keywords are: Verify, Sale, Reservation, Entry, ATO.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(ReservationEntry);
      ReservationEntry.SETRANGE(Positive,FALSE);
      ReservationEntry.SETRANGE("Item No.",SalesLine."No.");
      ReservationEntry.SETRANGE(Description,SalesLine.Description);
      ReservationEntry.SETRANGE("Location Code",SalesLine."Location Code");
      ReservationEntry.SETRANGE("Reservation Status",ReservationEntry."Reservation Status"::Reservation);
      ReservationEntry.SETRANGE("Source Type",DATABASE::"Sales Line");
      ReservationEntry.SETRANGE("Source Subtype",SalesLine."Document Type");
      ReservationEntry.SETRANGE("Source Ref. No.",SalesLine."Line No.");
      ReservationEntry.SETRANGE("Source ID",SalesLine."Document No.");
      ReservationEntry.SETRANGE(Quantity,-SalesLine."Qty. to Assemble to Order");
      ReservationEntry.SETRANGE(Binding,ReservationEntry.Binding::"Order-to-Order");
      ReservationEntry.SETRANGE("Planning Flexibility",ReservationEntry."Planning Flexibility"::None);
      ReservationEntry.SETRANGE("Shipment Date",SalesLine."Shipment Date");
      ReservationEntry.SETRANGE("Variant Code",SalesLine."Variant Code");
      ReservationEntry.SETRANGE("Disallow Cancellation",TRUE);

      Assert.AreEqual(1,ReservationEntry.COUNT,'Couldn''t find the SOL reservation entry with the filters: ' +
        ReservationEntry.GETFILTERS);

      EXIT(ReservationEntry."Entry No.");

Example

The below example is extracted from the test automation codeunit 137096 to show one way of using this function.

      EntryNo := LibraryAssembly.VerifySaleReservationEntryATO(SalesLine);
      Assert.AreEqual(EntryNo,LibraryAssembly.VerifytAsmReservationEntryATO(AssemblyHeader),DiffEntryNoInReservEntriesMsg);

      EXIT(EntryNo);
Member of Lib.Library - Assembly


VerifySKUCost@4 Method

The procedure VerifySKUCost is available in codeunit 132207.

Syntax

VerifySKUCost@4(
    VAR TempAssemblyLine@1006 : TEMPORARY Record 901 TempAssemblyLine, //Reference Temporary parameter of type Record
    AssemblyHeader@1000 : Record 900 AssemblyHeader //Input parameter of type Record
);

Parameters

TempAssemblyLine
Reference Temporary parameter of type Record
AssemblyHeader
Input parameter of type Record

Remarks

The relevant search keywords are: Verify, SKU, Cost.

For a clarification about how this function works, refer to the code listed below.

      // Check header item SKU cost.
      Item.GET(AssemblyHeader."Item No.");
      GetCostInformation(UnitCost,Overhead,IndirectCost,TempAssemblyLine.Type::Item,AssemblyHeader."Item No.",
        AssemblyHeader."Variant Code",AssemblyHeader."Location Code");
      IF Item."Costing Method" = Item."Costing Method"::Standard THEN
        AssemblyHeader.TESTFIELD("Unit Cost",UnitCost);

      // Check item components SKU cost.
      TempAssemblyLine.SETRANGE(Type,TempAssemblyLine.Type::Item);
      IF TempAssemblyLine.FINDSET THEN
        REPEAT
          GetCostInformation(UnitCost,Overhead,IndirectCost,TempAssemblyLine.Type::Item,TempAssemblyLine."No.",
            TempAssemblyLine."Variant Code",TempAssemblyLine."Location Code");
          TempAssemblyLine.TESTFIELD("Unit Cost",UnitCost);
        UNTIL TempAssemblyLine.NEXT = 0

Example

The below example is extracted from the test automation codeunit 137094 to show one way of using this function.

      // Setup.
      Initialize;
      LocationCode := '';
      LibraryAssembly.UpdateInventorySetup(InventorySetup,FALSE,FALSE,InventorySetup."Automatic Cost Adjustment"::Never,
        InventorySetup."Average Cost Calc. Type"::"Item & Location & Variant",InventorySetup."Average Cost Period"::Day);

      // Prepare setup for creating SKU per Location.
      IF CreatePer <> CreatePer::Variant THEN BEGIN
        LibraryWarehouse.CreateLocation(Location);
        LibraryAssembly.UpdateAssemblySetup(AssemblySetup,
          Location.Code,AssemblySetup."Copy Component Dimensions from"::"Order Header",LibraryUtility.GetGlobalNoSeriesCode);
        LocationCode := Location.Code;
      END;

      // Create Assembly BOM structure. Add inventory to allow posting.
      LibraryAssembly.SetupPostingToGL(GenProdPostingGr,AsmInvtPostingGr,CompInvtPostingGr,LocationCode);
      BlankLocation.INIT;
      LibraryInventory.UpdateInventoryPostingSetup(BlankLocation);
      LibraryAssembly.CreateItemWithSKU(
        Item,ParentCostingMethod,Item."Replenishment System"::Assembly,CreatePer,GenProdPostingGr,AsmInvtPostingGr,LocationCode);
      LibraryAssembly.CreateItemWithSKU(
        Item1,CompCostingMethod,Item."Replenishment System"::Purchase,CreatePer,GenProdPostingGr,CompInvtPostingGr,LocationCode);
      LibraryAssembly.CreateAssemblyListComponent(
        BOMComponent.Type::Item,Item1."No.",Item."No.",LibraryInventory.GetVariant(Item1."No.",''),
        BOMComponent."Resource Usage Type"::Direct,LibraryRandom.RandDec(20,5),TRUE);
      LibraryAssembly.CreateAssemblyHeader(AssemblyHeader,WorkDate2,Item."No.",'',LibraryRandom.RandDec(10,2),'');
      LibraryAssembly.AddCompInventory(AssemblyHeader,WorkDate2,0);

      // Verify: SKU cost is loaded correctly on the Assembly Order.
      LibraryAssembly.VerifySKUCost(TempAssemblyLine,AssemblyHeader);

      // Exercise. Post Assembly Order and adjust.
      LibraryAssembly.PrepareOrderPosting(AssemblyHeader,TempAssemblyLine,100,100,TRUE,WorkDate2);
      LibraryAssembly.PostAssemblyHeader(AssemblyHeader,'');
      LibraryCosting.AdjustCostItemEntries(Item."No." + '|' + Item1."No.",'');

      // Verify.
      LibraryAssembly.VerifyPostedAssemblyHeader(TempAssemblyLine,AssemblyHeader,AssemblyHeader.Quantity);
      LibraryAssembly.VerifyILEs(TempAssemblyLine,AssemblyHeader,AssemblyHeader."Quantity to Assemble");
      LibraryAssembly.VerifyValueEntries(TempAssemblyLine,AssemblyHeader,AssemblyHeader."Quantity to Assemble");
      LibraryAssembly.VerifyAdjustmentEntries(AssemblyHeader,AdjSource::None);
      LibraryAssembly.VerifyPostedComments(AssemblyHeader);

      // Tear down.
      LibraryAssembly.UpdateAssemblySetup(AssemblySetup,'',AssemblySetup."Copy Component Dimensions from"::"Order Header",
        LibraryUtility.GetGlobalNoSeriesCode);
      LibraryAssembly.UpdateInventorySetup(InventorySetup,FALSE,FALSE,InventorySetup."Automatic Cost Adjustment"::Never,
        InventorySetup."Average Cost Calc. Type"::Item,InventorySetup."Average Cost Period"::Day);
Member of Lib.Library - Assembly


VerifytAsmReservationEntryATO@60 Method

The procedure VerifytAsmReservationEntryATO is available in codeunit 132207.

Syntax

VerifytAsmReservationEntryATO@60(
    AssemblyHeader@1002 : Record 900 AssemblyHeader //Input parameter of type Record
);

Parameters

AssemblyHeader
Input parameter of type Record

Return Value

Integer

Remarks

The relevant search keywords are: Verifyt, Asm, Reservation, Entry, ATO.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(ReservationEntry);
      ReservationEntry.SETRANGE(Positive,TRUE);
      ReservationEntry.SETRANGE("Item No.",AssemblyHeader."Item No.");
      ReservationEntry.SETRANGE(Description,AssemblyHeader.Description);
      ReservationEntry.SETRANGE("Location Code",AssemblyHeader."Location Code");
      ReservationEntry.SETRANGE("Reservation Status",ReservationEntry."Reservation Status"::Reservation);
      ReservationEntry.SETRANGE("Source Type",DATABASE::"Assembly Header");
      ReservationEntry.SETRANGE("Source Subtype",AssemblyHeader."Document Type");
      ReservationEntry.SETRANGE("Source Ref. No.",0);
      ReservationEntry.SETRANGE("Source ID",AssemblyHeader."No.");
      ReservationEntry.SETRANGE(Quantity,AssemblyHeader.Quantity);
      ReservationEntry.SETRANGE(Binding,ReservationEntry.Binding::"Order-to-Order");
      ReservationEntry.SETRANGE("Planning Flexibility",ReservationEntry."Planning Flexibility"::None);
      ReservationEntry.SETRANGE("Shipment Date",AssemblyHeader."Due Date");
      ReservationEntry.SETRANGE("Variant Code",AssemblyHeader."Variant Code");
      ReservationEntry.SETRANGE("Disallow Cancellation",TRUE);
      Assert.AreEqual(1,ReservationEntry.COUNT,'Couldn''t find the AO reservation entry with the filters: ' +
        ReservationEntry.GETFILTERS);

      EXIT(ReservationEntry."Entry No.");

Example

The below example is extracted from the test automation codeunit 137096 to show one way of using this function.

      EntryNo := LibraryAssembly.VerifySaleReservationEntryATO(SalesLine);
      Assert.AreEqual(EntryNo,LibraryAssembly.VerifytAsmReservationEntryATO(AssemblyHeader),DiffEntryNoInReservEntriesMsg);

      EXIT(EntryNo);
Member of Lib.Library - Assembly


VerifyValueEntries@33 Method

The procedure VerifyValueEntries is available in codeunit 132207.

Syntax

VerifyValueEntries@33(
    VAR TempAssemblyLine@1003 : TEMPORARY Record 901 TempAssemblyLine, //Reference Temporary parameter of type Record
    AssemblyHeader@1000 : Record 900 AssemblyHeader, //Input parameter of type Record
    AssembledQty@1002 : Decimal AssembledQty //Input parameter of type Decimal
);

Parameters

TempAssemblyLine
Reference Temporary parameter of type Record
AssemblyHeader
Input parameter of type Record
AssembledQty
Input parameter of type Decimal

Remarks

The relevant search keywords are: Verify, Value, Entries.

For a clarification about how this function works, refer to the code listed below.

      VerifyValueEntriesAsm(TempAssemblyLine,AssemblyHeader,AssembledQty);

Example

The below example is extracted from the test automation codeunit 137092 to show one way of using this function.

      // Setup.
      Initialize;
      LibraryAssembly.UpdateAssemblySetup(AssemblySetup,'',DimensionsFrom,LibraryUtility.GetGlobalNoSeriesCode);
      LibraryAssembly.SetupAssemblyData(AssemblyHeader,WorkDate2,Item."Costing Method"::Standard,Item."Costing Method"::Average,
        Item."Replenishment System"::Assembly,'',TRUE);
      LibraryAssembly.AddCompInventory(AssemblyHeader,WorkDate2,0);

      // Exercise.
      LibraryAssembly.CheckOrderDimensions(AssemblyHeader,DimensionsFrom);
      IF OverrideDimensions THEN
        LibraryAssembly.EditOrderDimensions(AssemblyHeader);
      ExpectedError := LibraryAssembly.BlockOrderDimensions(AssemblyHeader,HeaderBlockType,CompBlockType);

      IF ExpectedError = '' THEN
        ExpectedError := AddAOItemDimension(AssemblyHeader,DefaultHeaderValuePosting,DefaultCompValuePosting);

      SetShortcutDimensions(AssemblyHeader,1);
      SetShortcutDimensions(AssemblyHeader,2);

      LibraryAssembly.PrepareOrderPosting(AssemblyHeader,TempAssemblyLine,100,100,TRUE,WorkDate2);
      LibraryAssembly.PostAssemblyHeader(AssemblyHeader,ExpectedError);

      // Verify.
      IF ExpectedError = '' THEN BEGIN
        LibraryAssembly.VerifyPostedAssemblyHeader(TempAssemblyLine,AssemblyHeader,AssemblyHeader.Quantity);
        LibraryAssembly.VerifyPostedComments(AssemblyHeader);
        LibraryAssembly.VerifyILEs(TempAssemblyLine,AssemblyHeader,AssemblyHeader."Quantity to Assemble");
        LibraryAssembly.VerifyValueEntries(TempAssemblyLine,AssemblyHeader,AssemblyHeader."Quantity to Assemble");
        LibraryAssembly.VerifyResEntries(TempAssemblyLine,AssemblyHeader);
        LibraryAssembly.VerifyCapEntries(TempAssemblyLine,AssemblyHeader);
        LibraryAssembly.VerifyItemRegister(AssemblyHeader);
      END;

      // Tear down.
Member of Lib.Library - Assembly


VerifyValueEntriesAsm@70 Method

The procedure VerifyValueEntriesAsm is available in codeunit 132207.

Syntax

VerifyValueEntriesAsm@70(
    VAR TempAssemblyLine@1003 : TEMPORARY Record 901 TempAssemblyLine, //Reference Temporary parameter of type Record
    AssemblyHeader@1000 : Record 900 AssemblyHeader, //Input parameter of type Record
    AssembledQty@1002 : Decimal AssembledQty //Input parameter of type Decimal
);

Parameters

TempAssemblyLine
Reference Temporary parameter of type Record
AssemblyHeader
Input parameter of type Record
AssembledQty
Input parameter of type Decimal

Remarks

The relevant search keywords are: Verify, Value, Entries, Asm.

For a clarification about how this function works, refer to the code listed below.

      ValueEntry.RESET;
      // General filtering.
      ValueEntry.SETRANGE("Posting Date",AssemblyHeader."Posting Date");
      ValueEntry.SETRANGE("Source No.",AssemblyHeader."Item No.");
      ValueEntry.SETRANGE("Source Type",ValueEntry."Source Type"::Item);
      ValueEntry.SETRANGE("Order Type",ValueEntry."Order Type"::Assembly);
      ValueEntry.SETRANGE("Order No.",AssemblyHeader."No.");
      ValueEntry.SETRANGE("Entry Type",ValueEntry."Entry Type"::"Direct Cost");

      // Output entry.
      ValueEntry.SETRANGE("Item No.",AssemblyHeader."Item No.");
      ValueEntry.SETRANGE("Variant Code",AssemblyHeader."Variant Code");
      ValueEntry.SETRANGE("Item Ledger Entry Type",ValueEntry."Item Ledger Entry Type"::"Assembly Output");
      ValueEntry.SETRANGE("Location Code",AssemblyHeader."Location Code");
      ValueEntry.SETRANGE("Valued Quantity",AssembledQty);
      ValueEntry.SETRANGE("Item Ledger Entry Quantity",AssembledQty);
      ValueEntry.SETRANGE("Invoiced Quantity",AssembledQty);
      ValueEntry.SETRANGE("Document Line No.",0);
      ValueEntry.SETRANGE("Order Line No.",0);
      ValueEntry.SETRANGE("Dimension Set ID",AssemblyHeader."Dimension Set ID");

      ValueEntry.SETRANGE(Adjustment,FALSE);
      Assert.AreEqual(1,ValueEntry.COUNT,'Wrong no. of output value entries for item' + AssemblyHeader."Item No.");
      ValueEntry.FINDFIRST;
      Assert.AreNearlyEqual(ROUND(AssemblyHeader."Cost Amount" * AssembledQty / AssemblyHeader.Quantity,
          LibraryERM.GetAmountRoundingPrecision),
        ValueEntry."Cost Amount (Actual)",LibraryERM.GetAmountRoundingPrecision,'Wrong value entry cost amount for header.');

      // Consumption value entries for items.
      TempAssemblyLine.SETRANGE(Type,TempAssemblyLine.Type::Item);
      IF TempAssemblyLine.FINDSET THEN
        REPEAT
          ValueEntry.SETRANGE("Item No.",TempAssemblyLine."No.");
          ValueEntry.SETRANGE("Variant Code",TempAssemblyLine."Variant Code");
          ValueEntry.SETRANGE("Item Ledger Entry Type",ValueEntry."Item Ledger Entry Type"::"Assembly Consumption");
          ValueEntry.SETRANGE("Location Code",TempAssemblyLine."Location Code");
          // ValueEntry.SETRANGE(Description,TempAssemblyLine.Description); - bug for ATO
          ValueEntry.SETRANGE("Valued Quantity",-TempAssemblyLine."Quantity to Consume (Base)");
          ValueEntry.SETRANGE("Item Ledger Entry Quantity",-TempAssemblyLine."Quantity to Consume (Base)");
          ValueEntry.SETRANGE("Invoiced Quantity",-TempAssemblyLine."Quantity to Consume (Base)");
          ValueEntry.SETRANGE("Document Line No.",TempAssemblyLine."Line No.");
          ValueEntry.SETRANGE("Order Line No.",TempAssemblyLine."Line No.");
          ValueEntry.SETRANGE("Dimension Set ID",TempAssemblyLine."Dimension Set ID");
          Assert.AreEqual(1,ValueEntry.COUNT,'Wrong no. of consumpt. value entries for item' + TempAssemblyLine."No.");
          ValueEntry.FINDFIRST;
          Assert.AreNearlyEqual(
            TempAssemblyLine."Cost Amount" * ROUND(TempAssemblyLine."Quantity to Consume" / TempAssemblyLine.Quantity),
            -ValueEntry."Cost Amount (Actual)",LibraryERM.GetAmountRoundingPrecision,
            'Wrong value entry cost amount for item ' + TempAssemblyLine."No.");
        UNTIL TempAssemblyLine.NEXT = 0;

      // Consumption value entries for resources.
      TempAssemblyLine.SETRANGE(Type,TempAssemblyLine.Type::Resource);
      IF TempAssemblyLine.FINDSET THEN
        REPEAT
          ValueEntry.SETRANGE("Item No.",'');
          ValueEntry.SETRANGE("Variant Code",TempAssemblyLine."Variant Code");
          ValueEntry.SETRANGE("Item Ledger Entry Type",ValueEntry."Item Ledger Entry Type"::" ");
          ValueEntry.SETRANGE("Location Code",TempAssemblyLine."Location Code");
          ValueEntry.SETRANGE(Description,TempAssemblyLine.Description);
          ValueEntry.SETRANGE("Valued Quantity",TempAssemblyLine."Quantity to Consume");
          ValueEntry.SETRANGE("Item Ledger Entry Quantity",0);
          ValueEntry.SETRANGE("Invoiced Quantity",TempAssemblyLine."Quantity to Consume");
          ValueEntry.SETRANGE("Document Line No.",TempAssemblyLine."Line No.");
          ValueEntry.SETRANGE("Order Line No.",TempAssemblyLine."Line No.");
          ValueEntry.SETRANGE("Dimension Set ID",TempAssemblyLine."Dimension Set ID");
          ValueEntry.SETRANGE(Type,ValueEntry.Type::Resource);
          ValueEntry.SETRANGE("No.",TempAssemblyLine."No.");
          Assert.AreEqual(1,ValueEntry.COUNT,'Wrong no. of res. consumpt. value entries for res. ' + TempAssemblyLine."No.");
          ValueEntry.FINDFIRST;
          Assert.AreNearlyEqual(TempAssemblyLine."Cost Amount" * TempAssemblyLine."Quantity to Consume" /
            TempAssemblyLine.Quantity,ValueEntry."Cost Amount (Actual)",
            LibraryERM.GetAmountRoundingPrecision,'Wrong value entry cost amount for res. ' + TempAssemblyLine."No.");
        UNTIL TempAssemblyLine.NEXT = 0;

Example

There are no examples available.
Member of Lib.Library - Assembly


VerifyValueEntriesATO@67 Method

The procedure VerifyValueEntriesATO is available in codeunit 132207.

Syntax

VerifyValueEntriesATO@67(
    VAR TempAssemblyLine@1003 : TEMPORARY Record 901 TempAssemblyLine, //Reference Temporary parameter of type Record
    SalesHeader@1004 : Record 36 SalesHeader, //Input parameter of type Record
    AssemblyHeader@1000 : Record 900 AssemblyHeader, //Input parameter of type Record
    AssembledQty@1002 : Decimal AssembledQty //Input parameter of type Decimal
);

Parameters

TempAssemblyLine
Reference Temporary parameter of type Record
SalesHeader
Input parameter of type Record
AssemblyHeader
Input parameter of type Record
AssembledQty
Input parameter of type Decimal

Remarks

The relevant search keywords are: Verify, Value, Entries, ATO.

For a clarification about how this function works, refer to the code listed below.

      VerifyValueEntriesAsm(TempAssemblyLine,AssemblyHeader,AssembledQty);
      VerifyValueEntriesSale(SalesHeader,AssemblyHeader,AssembledQty);

Example

The below example is extracted from the test automation codeunit 137096 to show one way of using this function.

      CreateAssembledItem(Item,Item."Assembly Policy"::"Assemble-to-Order",LibraryRandom.RandInt(10),
        LibraryRandom.RandInt(10),LibraryRandom.RandInt(10),LibraryRandom.RandInt(1000),
        Item."Costing Method"::FIFO);

      // Exercise - create SOL with ATO item
      OrderQty := LibraryRandom.RandInt(1000);
      DueDate := CALCDATE('<+' + FORMAT(LibraryRandom.RandInt(30)) + 'D>',WorkDate2);
      CreateSalesOrder(SalesHeader,Item."No.",'',OrderQty,DueDate,LocationCode);
      FindSOL(SalesHeader,SalesLine,1);
      FindAssemblyHeader(AssemblyHeader,AssemblyHeader."Document Type"::Order,Item,'',LocationCode,
        DueDate,Item."Base Unit of Measure",OrderQty);
      CopyAsmLinesToTemp(AssemblyHeader,TempAssemblyLine);

      // Add enough inventory for comp
      AddInvNonDirectLocAllComponent(AssemblyHeader,100);

      // Exercise - post SOs
      LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      // Verify - entries
      LibraryAssembly.VerifyILEsForAsmOnATO(TempAssemblyLine,AssemblyHeader,AssemblyHeader.Quantity);
      LibraryAssembly.VerifyValueEntriesATO(TempAssemblyLine,SalesHeader,AssemblyHeader,AssemblyHeader.Quantity);
      LibraryAssembly.VerifyResEntriesATO(TempAssemblyLine,AssemblyHeader);
      LibraryAssembly.VerifyCapEntriesATO(TempAssemblyLine,AssemblyHeader);
Member of Lib.Library - Assembly


VerifyValueEntriesSale@69 Method

The procedure VerifyValueEntriesSale is available in codeunit 132207.

Syntax

VerifyValueEntriesSale@69(
    SalesHeader@1005 : Record 36 SalesHeader, //Input parameter of type Record
    AssemblyHeader@1000 : Record 900 AssemblyHeader, //Input parameter of type Record
    AssembledQty@1002 : Decimal AssembledQty //Input parameter of type Decimal
);

Parameters

SalesHeader
Input parameter of type Record
AssemblyHeader
Input parameter of type Record
AssembledQty
Input parameter of type Decimal

Remarks

The relevant search keywords are: Verify, Value, Entries, Sale.

For a clarification about how this function works, refer to the code listed below.

      ValueEntry.RESET;
      ValueEntry.SETRANGE("Posting Date",AssemblyHeader."Posting Date");
      ValueEntry.SETRANGE("Source No.",SalesHeader."Sell-to Customer No.");
      ValueEntry.SETRANGE("Source Type",ValueEntry."Source Type"::Customer);
      ValueEntry.SETRANGE("Order Type",ValueEntry."Order Type"::" ");
      ValueEntry.SETRANGE("Order No.",'');
      ValueEntry.SETRANGE("Entry Type",ValueEntry."Entry Type"::"Direct Cost");
      ValueEntry.SETRANGE("Item No.",AssemblyHeader."Item No.");
      ValueEntry.SETRANGE("Variant Code",AssemblyHeader."Variant Code");
      ValueEntry.SETRANGE("Item Ledger Entry Type",ValueEntry."Item Ledger Entry Type"::Sale);
      ValueEntry.SETRANGE("Location Code",AssemblyHeader."Location Code");
      ValueEntry.SETRANGE("Valued Quantity",-AssembledQty);
      ValueEntry.SETRANGE("Item Ledger Entry Quantity",-AssembledQty);
      ValueEntry.SETRANGE("Invoiced Quantity",-AssembledQty);
      ValueEntry.SETRANGE(Adjustment,FALSE);

      Assert.AreEqual(1,ValueEntry.COUNT,'Wrong no. of sales value entries for item' + AssemblyHeader."Item No.");
      ValueEntry.FINDFIRST;

      Assert.AreNearlyEqual(ROUND(AssemblyHeader."Cost Amount" * AssembledQty / AssemblyHeader.Quantity,
          LibraryERM.GetAmountRoundingPrecision),
        ValueEntry."Cost Amount (Actual)",LibraryERM.GetAmountRoundingPrecision,'Wrong value entry cost amount for header.');

Example

There are no examples available.
Member of Lib.Library - Assembly


VerifyValueEntriesUndo@81 Method

The procedure VerifyValueEntriesUndo is available in codeunit 132207.

Syntax

VerifyValueEntriesUndo@81(
    VAR TempAssemblyLine@1003 : TEMPORARY Record 901 TempAssemblyLine, //Reference Temporary parameter of type Record
    AssemblyHeader@1000 : Record 900 AssemblyHeader, //Input parameter of type Record
    AssembledQty@1002 : Decimal AssembledQty //Input parameter of type Decimal
);

Parameters

TempAssemblyLine
Reference Temporary parameter of type Record
AssemblyHeader
Input parameter of type Record
AssembledQty
Input parameter of type Decimal

Remarks

The relevant search keywords are: Verify, Value, Entries, Undo.

For a clarification about how this function works, refer to the code listed below.

      ValueEntry.RESET;
      // General filtering.
      ValueEntry.SETRANGE("Posting Date",AssemblyHeader."Posting Date");
      ValueEntry.SETRANGE("Source No.",AssemblyHeader."Item No.");
      ValueEntry.SETRANGE("Source Type",ValueEntry."Source Type"::Item);
      ValueEntry.SETRANGE("Order Type",ValueEntry."Order Type"::Assembly);
      ValueEntry.SETRANGE("Order No.",AssemblyHeader."No.");
      ValueEntry.SETRANGE("Entry Type",ValueEntry."Entry Type"::"Direct Cost");

      // Output entry.
      ValueEntry.SETRANGE("Item No.",AssemblyHeader."Item No.");
      ValueEntry.SETRANGE("Variant Code",AssemblyHeader."Variant Code");
      ValueEntry.SETRANGE("Item Ledger Entry Type",ValueEntry."Item Ledger Entry Type"::"Assembly Output");
      ValueEntry.SETRANGE("Location Code",AssemblyHeader."Location Code");
      ValueEntry.SETRANGE("Valued Quantity",AssembledQty);
      ValueEntry.SETRANGE("Item Ledger Entry Quantity",AssembledQty);
      ValueEntry.SETRANGE("Invoiced Quantity",AssembledQty);
      ValueEntry.SETRANGE("Document Line No.",0);
      ValueEntry.SETRANGE("Order Line No.",0);
      ValueEntry.SETRANGE("Dimension Set ID",AssemblyHeader."Dimension Set ID");

      ValueEntry.SETRANGE(Adjustment,FALSE);
      Assert.AreEqual(1,ValueEntry.COUNT,'Wrong no. of output value entries for item' + AssemblyHeader."Item No.");
      ValueEntry.FINDFIRST;
      Assert.AreNearlyEqual(ROUND(AssemblyHeader."Cost Amount" * AssembledQty / AssemblyHeader.Quantity,
          LibraryERM.GetAmountRoundingPrecision),
        ValueEntry."Cost Amount (Actual)",LibraryERM.GetAmountRoundingPrecision,'Wrong value entry cost amount for header.');

      // Consumption value entries for items.
      TempAssemblyLine.SETRANGE(Type,TempAssemblyLine.Type::Item);
      IF TempAssemblyLine.FINDSET THEN
        REPEAT
          ValueEntry.SETRANGE("Item No.",TempAssemblyLine."No.");
          ValueEntry.SETRANGE("Variant Code",TempAssemblyLine."Variant Code");
          ValueEntry.SETRANGE("Item Ledger Entry Type",ValueEntry."Item Ledger Entry Type"::"Assembly Consumption");
          ValueEntry.SETRANGE("Location Code",TempAssemblyLine."Location Code");
          // ValueEntry.SETRANGE(Description,TempAssemblyLine.Description); - bug for ATO
          ValueEntry.SETRANGE("Valued Quantity",-TempAssemblyLine."Quantity to Consume (Base)");
          ValueEntry.SETRANGE("Item Ledger Entry Quantity",-TempAssemblyLine."Quantity to Consume (Base)");
          ValueEntry.SETRANGE("Invoiced Quantity",-TempAssemblyLine."Quantity to Consume (Base)");
          ValueEntry.SETRANGE("Document Line No.",TempAssemblyLine."Line No.");
          ValueEntry.SETRANGE("Order Line No.",TempAssemblyLine."Line No.");
          ValueEntry.SETRANGE("Dimension Set ID",TempAssemblyLine."Dimension Set ID");
          Assert.AreEqual(1,ValueEntry.COUNT,'Wrong no. of consumpt. value entries for item' + TempAssemblyLine."No.");
          ValueEntry.FINDFIRST;
          Assert.AreNearlyEqual(ROUND(TempAssemblyLine."Cost Amount" * TempAssemblyLine."Quantity to Consume" /
              TempAssemblyLine.Quantity,LibraryERM.GetAmountRoundingPrecision),
            -ValueEntry."Cost Amount (Actual)",LibraryERM.GetAmountRoundingPrecision,
            'Wrong value entry cost amount for item ' + TempAssemblyLine."No.");
        UNTIL TempAssemblyLine.NEXT = 0;

      // Consumption value entries for resources.
      TempAssemblyLine.SETRANGE(Type,TempAssemblyLine.Type::Resource);
      IF TempAssemblyLine.FINDSET THEN
        REPEAT
          ValueEntry.SETRANGE("Item No.",'');
          ValueEntry.SETRANGE("Variant Code",TempAssemblyLine."Variant Code");
          ValueEntry.SETRANGE("Item Ledger Entry Type",ValueEntry."Item Ledger Entry Type"::" ");
          ValueEntry.SETRANGE("Location Code",TempAssemblyLine."Location Code");
          ValueEntry.SETRANGE(Description,TempAssemblyLine.Description);
          ValueEntry.SETRANGE("Valued Quantity",TempAssemblyLine."Quantity to Consume");
          ValueEntry.SETRANGE("Item Ledger Entry Quantity",0);
          ValueEntry.SETRANGE("Invoiced Quantity",TempAssemblyLine."Quantity to Consume");
          ValueEntry.SETRANGE("Document Line No.",TempAssemblyLine."Line No.");
          ValueEntry.SETRANGE("Order Line No.",TempAssemblyLine."Line No.");
          ValueEntry.SETRANGE("Dimension Set ID",TempAssemblyLine."Dimension Set ID");
          ValueEntry.SETRANGE(Type,ValueEntry.Type::Resource);
          ValueEntry.SETRANGE("No.",TempAssemblyLine."No.");
          Assert.AreEqual(1,ValueEntry.COUNT,'Wrong no. of res. consumpt. value entries for res. ' + TempAssemblyLine."No.");
          ValueEntry.FINDFIRST;
          Assert.AreNearlyEqual(TempAssemblyLine."Cost Amount" * TempAssemblyLine."Quantity to Consume" /
            TempAssemblyLine.Quantity,ValueEntry."Cost Amount (Actual)",
            LibraryERM.GetAmountRoundingPrecision,'Wrong value entry cost amount for res. ' + TempAssemblyLine."No.");
        UNTIL TempAssemblyLine.NEXT = 0;

Example

There are no examples available.
Member of Lib.Library - Assembly


VerifyWarehouseEntries@125 Method

The procedure VerifyWarehouseEntries is available in codeunit 132207.

Syntax

VerifyWarehouseEntries@125(
    VAR TempAssemblyHeader@1001 : TEMPORARY Record 900 TempAssemblyHeader, //Reference Temporary parameter of type Record
    VAR TempAssemblyLine@1002 : TEMPORARY Record 901 TempAssemblyLine, //Reference Temporary parameter of type Record
    IsUndo@1005 : Boolean IsUndo //Input parameter of type Boolean
);

Parameters

TempAssemblyHeader
Reference Temporary parameter of type Record
TempAssemblyLine
Reference Temporary parameter of type Record
IsUndo
Input parameter of type Boolean

Remarks

The relevant search keywords are: Verify, Warehouse, Entries.

For a clarification about how this function works, refer to the code listed below.

      SourceCodeSetup.GET;
      WarehouseEntry.RESET;
      WarehouseEntry.SETRANGE("Source Code",SourceCodeSetup.Assembly);
      // TODO - bug as fields are not populated
      // WarehouseEntry.SETRANGE("Whse. Document Type",WarehouseEntry."Whse. Document Type"::Assembly);
      // WarehouseEntry.SETRANGE("Whse. Document No.",TempAssemblyHeader."No.");
      // WarehouseEntry.SETRANGE("Source Document",WarehouseEntry."Source Document"::"Assembly Order");
      // WarehouseEntry.SETRANGE("Source Line No.",0);
      WarehouseEntry.SETRANGE("Source No.",TempAssemblyHeader."No.");
      WarehouseEntry.SETRANGE("Registering Date",TempAssemblyHeader."Posting Date");
      WarehouseEntry.SETRANGE("User ID",USERID);
      WarehouseEntry.SETRANGE("Variant Code",TempAssemblyHeader."Variant Code");
      WarehouseEntry.SETRANGE("Unit of Measure Code",TempAssemblyHeader."Unit of Measure Code");
      IF IsUndo THEN BEGIN
        WarehouseEntry.SETRANGE(Quantity,-TempAssemblyHeader."Quantity to Assemble");
        WarehouseEntry.SETRANGE("Entry Type",WarehouseEntry."Entry Type"::"Negative Adjmt.")
      END ELSE BEGIN
        WarehouseEntry.SETRANGE("Entry Type",WarehouseEntry."Entry Type"::"Positive Adjmt.");
        WarehouseEntry.SETRANGE(Quantity,TempAssemblyHeader."Quantity to Assemble");
      END;
      WarehouseEntry.SETRANGE("Location Code",TempAssemblyHeader."Location Code");
      WarehouseEntry.SETRANGE("Bin Code",TempAssemblyHeader."Bin Code");
      WarehouseEntry.SETRANGE(
        "Zone Code",LibraryWarehouse.GetZoneForBin(TempAssemblyHeader."Location Code",TempAssemblyHeader."Bin Code"));
      WarehouseEntry.SETRANGE("Item No.",TempAssemblyHeader."Item No.");

      Assert.AreEqual(1,WarehouseEntry.COUNT,'Incorect number of warehouse entries for assembly ' + TempAssemblyHeader."No.");

      // Verify warehouse entries for components
      TempAssemblyLine.RESET;
      TempAssemblyLine.SETRANGE(Type,TempAssemblyLine.Type::Item);
      TempAssemblyLine.FINDSET;
      REPEAT
        WarehouseEntry.RESET;
        WarehouseEntry.SETRANGE("Source Code",SourceCodeSetup.Assembly);
        // TODO - bug as fields are not populated
        // WarehouseEntry.SETRANGE("Whse. Document Type",WarehouseEntry."Whse. Document Type"::Assembly);
        // WarehouseEntry.SETRANGE("Whse. Document No.",TempAssemblyHeader."No.");
        // WarehouseEntry.SETRANGE("Source Document",WarehouseEntry."Source Document"::"Assembly Consumption");
        // WarehouseEntry.SETRANGE("Source Line No.",0);
        WarehouseEntry.SETRANGE("Source No.",TempAssemblyHeader."No.");
        WarehouseEntry.SETRANGE("Registering Date",TempAssemblyHeader."Posting Date");
        WarehouseEntry.SETRANGE("User ID",USERID);
        WarehouseEntry.SETRANGE("Variant Code",TempAssemblyLine."Variant Code");
        WarehouseEntry.SETRANGE("Unit of Measure Code",TempAssemblyLine."Unit of Measure Code");
        IF IsUndo THEN BEGIN
          WarehouseEntry.SETRANGE(Quantity,TempAssemblyLine."Quantity to Consume");
          WarehouseEntry.SETRANGE("Entry Type",WarehouseEntry."Entry Type"::"Positive Adjmt.")
        END ELSE BEGIN
          WarehouseEntry.SETRANGE(Quantity,-TempAssemblyLine."Quantity to Consume");
          WarehouseEntry.SETRANGE("Entry Type",WarehouseEntry."Entry Type"::"Negative Adjmt.");
        END;
        WarehouseEntry.SETRANGE("Location Code",TempAssemblyLine."Location Code");
        WarehouseEntry.SETRANGE("Bin Code",TempAssemblyLine."Bin Code");
        WarehouseEntry.SETRANGE("Item No.",TempAssemblyLine."No.");
        Assert.AreEqual(1,WarehouseEntry.COUNT,'Incorrect number of warehouse entries for assembly line ' + TempAssemblyLine."No.");
      UNTIL TempAssemblyLine.NEXT = 0;

Example

The below example is extracted from the test automation codeunit 137097 to show one way of using this function.

      // Get Bin codes
      BinIndex := 1;

      IF NOT Location."Directed Put-away and Pick" THEN BEGIN// if not Full WMS
        LibraryWarehouse.FindBin(HeaderBin,Location.Code,'',BinIndex);
        LibraryWarehouse.FindBin(ComponentsBin,Location.Code,'',BinIndex + 1);
      END ELSE BEGIN
        HeaderBin.GET(Location.Code,Location."From-Production Bin Code");
        LibraryWarehouse.FindBin(ComponentsBin,Location.Code,'PICK',BinIndex);
      END;

      // Create AO
      OrderQty := LibraryRandom.RandDec(1000,2) + 1;
      CreateAssemblyOrderWithInventory(AssemblyHeader,Item,OrderQty,Location.Code,HeaderBin.Code,ComponentsBin.Code);

      // If Full WMS - process whse pick, else set bin on the lines to point where the inventory exists
      IF NOT Location."Directed Put-away and Pick" THEN
        SetLocAndBinCodeOnAsmLines(AssemblyHeader,ComponentsBin)
      ELSE
        ProcessWMSPick(AssemblyHeader);

      // Copy to temp & post AO
      IF FullPosting THEN BEGIN
        CopyAOToTemp(AssemblyHeader,TempAssemblyHeader,TempAssemblyLine);
        PostAssemblyOrderQty(AssemblyHeader,OrderQty);
      END ELSE BEGIN
        PostAssemblyOrderQty(AssemblyHeader,OrderQty / 2);
        CopyAOToTemp(AssemblyHeader,TempAssemblyHeader,TempAssemblyLine);
      END;

      FindPostedAssemblyHeaderNotReversed(PostedAssemblyHeader,AssemblyHeader."No.");

      // Exercise - undo
      LibraryAssembly.UndoPostedAssembly(PostedAssemblyHeader,FALSE,'');

      // Verify
      CASE AssertOption OF
        AssertOption::WhseEntries:
          BEGIN
            LibraryAssembly.VerifyWarehouseEntries(TempAssemblyHeader,TempAssemblyLine,FALSE);
            LibraryAssembly.VerifyWarehouseEntries(TempAssemblyHeader,TempAssemblyLine,TRUE);
          END;
        AssertOption::BinContents:
          LibraryAssembly.VerifyBinContents(TempAssemblyHeader,TempAssemblyLine,0);
      END;
Member of Lib.Library - Assembly


Library - Calc Complexity Class

Lib.Library - Calc Complexity

COD130010 applies to RES,ERM,SCM,COSTING,W1,All.

Methods

Name | Description
IsConstant@5 | The procedure IsConstant is available in codeunit 130010.
IsLinear@81 | The procedure IsLinear is available in codeunit 130010.
IsLogN@4 | The procedure IsLogN is available in codeunit 130010.
IsNLogN@2 | The procedure IsNLogN is available in codeunit 130010.
IsQuadratic@23 | The procedure IsQuadratic is available in codeunit 130010.

See Also

Lib


IsConstant@5 Method

The procedure IsConstant is available in codeunit 130010.

Syntax

IsConstant@5(
    f1@1000 : Integer f1, //Input parameter of type Integer
    f2@1001 : Integer f2 //Input parameter of type Integer
);

Parameters

f1
Input parameter of type Integer
f2
Input parameter of type Integer

Return Value

Boolean

Remarks

The relevant search keywords are: Is, Constant.

For a clarification about how this function works, refer to the code listed below.

      EXIT(f2 <= f1 * Noise);

Example

There are no examples available.
Member of Lib.Library - Calc Complexity


IsLinear@81 Method

The procedure IsLinear is available in codeunit 130010.

Syntax

IsLinear@81(
    x1@1000 : Decimal x1, //Input parameter of type Decimal
    x2@1001 : Decimal x2, //Input parameter of type Decimal
    x3@1002 : Decimal x3, //Input parameter of type Decimal
    f1@1003 : Decimal f1, //Input parameter of type Decimal
    f2@1004 : Decimal f2, //Input parameter of type Decimal
    f3@1005 : Decimal f3 //Input parameter of type Decimal
);

Parameters

x1
Input parameter of type Decimal
x2
Input parameter of type Decimal
x3
Input parameter of type Decimal
f1
Input parameter of type Decimal
f2
Input parameter of type Decimal
f3
Input parameter of type Decimal

Return Value

Boolean

Remarks

The relevant search keywords are: Is, Linear.

For a clarification about how this function works, refer to the code listed below.

      // x1, x2, and x3 are sizes of data input. fx1, fx2, and fx3 are the cost of processing that data
      // If the cost is linear: f(x) = a.x + b
      // Demonstrate that the computational cost is linear by finding a and b and checking that
      // an upper bound can be defined, so fx3 is actually under the bound

      IF x1 = x2 THEN
        ERROR(DivisionByZeroErr);

      a := (f1 - f2) / (x1 - x2);

      b := f1 - (a * x1);

      ExpectedF3 := (a * x3) + b;

      ExpectedUpperBound := ExpectedF3 * Noise;

      EXIT(f3 <= ExpectedUpperBound);

Example

The below example is extracted from the test automation codeunit 137082 to show one way of using this function.

      // [FEATURE] [Performance] [Parallel Routing]
      // [SCENARIO 221561] Calculation of routing operations sequence should have linear performance

      Initialize;

      // [GIVEN] Parallel routing with the following structure
      // [GIVEN]     1
      // [GIVEN]    / \
      // [GIVEN]   2   3
      // [GIVEN]    \ /
      // [GIVEN]     4
      // [GIVEN]    / \
      // [GIVEN]   5   6
      // [GIVEN]    \ /
      // [GIVEN]     7
      // [GIVEN]    / \
      // [GIVEN]    ...

      CodeCoverageMgt.StopApplicationCoverage;
      SmallNoOfOperations := 1;
      MediumNoOfOperations := 5;
      LargeNoOfOperations := 10;

      CodeCoverageMgt.StartApplicationCoverage;
      CreateAndCertifyRoutingWithCrossOperations(SmallNoOfOperations);
      CodeCoverageMgt.StopApplicationCoverage;
      SmallNoOfHits :=
        GetCodeCoverageForObject(CodeCoverage."Object Type"::Codeunit,CODEUNIT::"Check Routing Lines",'SetRtngLineSequenceBack') +
        GetCodeCoverageForObject(CodeCoverage."Object Type"::Codeunit,CODEUNIT::"Check Routing Lines",'SetRtngLineSequenceForward');

      CodeCoverageMgt.StartApplicationCoverage;
      CreateAndCertifyRoutingWithCrossOperations(MediumNoOfOperations);
      CodeCoverageMgt.StopApplicationCoverage;
      MediumNoOfHits :=
        GetCodeCoverageForObject(CodeCoverage."Object Type"::Codeunit,CODEUNIT::"Check Routing Lines",'SetRtngLineSequenceBack') +
        GetCodeCoverageForObject(CodeCoverage."Object Type"::Codeunit,CODEUNIT::"Check Routing Lines",'SetRtngLineSequenceForward');

      CodeCoverageMgt.StartApplicationCoverage;
      CreateAndCertifyRoutingWithCrossOperations(LargeNoOfOperations);
      CodeCoverageMgt.StopApplicationCoverage;
      LargeNoOfHits :=
        GetCodeCoverageForObject(CodeCoverage."Object Type"::Codeunit,CODEUNIT::"Check Routing Lines",'SetRtngLineSequenceBack') +
        GetCodeCoverageForObject(CodeCoverage."Object Type"::Codeunit,CODEUNIT::"Check Routing Lines",'SetRtngLineSequenceForward');

      // [WHEN] Certify the routing
      // [THEN] Performance should be linear
      Assert.IsTrue(
        LibraryCalcComplexity.IsLinear(
          SmallNoOfOperations,MediumNoOfOperations,LargeNoOfOperations,SmallNoOfHits,MediumNoOfHits,LargeNoOfHits),
        NotLinearCCErr);
Member of Lib.Library - Calc Complexity


IsLogN@4 Method

The procedure IsLogN is available in codeunit 130010.

Syntax

IsLogN@4(
    x1@1009 : Decimal x1, //Input parameter of type Decimal
    x2@1008 : Decimal x2, //Input parameter of type Decimal
    x3@1007 : Decimal x3, //Input parameter of type Decimal
    f1@1006 : Decimal f1, //Input parameter of type Decimal
    f2@1005 : Decimal f2, //Input parameter of type Decimal
    f3@1004 : Decimal f3 //Input parameter of type Decimal
);

Parameters

x1
Input parameter of type Decimal
x2
Input parameter of type Decimal
x3
Input parameter of type Decimal
f1
Input parameter of type Decimal
f2
Input parameter of type Decimal
f3
Input parameter of type Decimal

Return Value

Boolean

Remarks

The relevant search keywords are: Is, LogN.

For a clarification about how this function works, refer to the code listed below.

      // x1, x2 and x3 are sizes of data input. fx1, fx2 and fx3 are the cost of processing that data
      // If the cost is logarithmic: f(x) = a.log(x) + b
      // Demonstrate that the computational cost is logarithmic by finding a and b and checking that
      // an upper bound can be defined, so that fx3 is actually under the bound

      IF x1 = x2 THEN
        ERROR(DivisionByZeroErr);

      a := (f1 - f2) / (Log(x1) - Log(x2));
      b := f1 - a * Log(x1);

      ExpectedF3 := (a * Log(x3)) + b;

      ExpectedUpperBound := ExpectedF3 * Noise;

      EXIT(f3 <= ExpectedUpperBound);

Example

There are no examples available.
Member of Lib.Library - Calc Complexity


IsNLogN@2 Method

The procedure IsNLogN is available in codeunit 130010.

Syntax

IsNLogN@2(
    x1@1000 : Decimal x1, //Input parameter of type Decimal
    x2@1001 : Decimal x2, //Input parameter of type Decimal
    x3@1002 : Decimal x3, //Input parameter of type Decimal
    x4@1010 : Decimal x4, //Input parameter of type Decimal
    f1@1003 : Decimal f1, //Input parameter of type Decimal
    f2@1004 : Decimal f2, //Input parameter of type Decimal
    f3@1005 : Decimal f3, //Input parameter of type Decimal
    f4@1011 : Decimal f4 //Input parameter of type Decimal
);

Parameters

x1
Input parameter of type Decimal
x2
Input parameter of type Decimal
x3
Input parameter of type Decimal
x4
Input parameter of type Decimal
f1
Input parameter of type Decimal
f2
Input parameter of type Decimal
f3
Input parameter of type Decimal
f4
Input parameter of type Decimal

Return Value

Boolean

Remarks

The relevant search keywords are: Is, N, LogN.

For a clarification about how this function works, refer to the code listed below.

      // x1, x2, x3 and x4 are sizes of data input. fx1, fx2,fx3 and fx4 are the cost of processing that data
      // If the cost is quadratic: f(x) = a.x.log(x) + b.x + c
      // Demonstrate that the computational cost is quadratic by finding a and b and c and checking that
      // an upper bound can be defined, so fx4 is actually under the bound

      IF (x1 = x2) OR (x1 = x3) THEN
        ERROR(DivisionByZeroErr);

      b :=
        (((x1 * Log(x1) - x3 * Log(x3)) * (f1 - f2)) -
         ((x1 * Log(x1) - x2 * Log(x2)) * (f1 - f3))) /
        (((x1 - x2) * (x1 * Log(x1) - x3 * Log(x3))) -
         ((x1 - x3) * (x1 * Log(x1) - x2 * Log(x2))));

      a :=
        ((f1 - f2) - b * (x1 - x2)) /
        (x1 * Log(x1) - x2 * Log(x2));

      c := f1 - a * x1 * Log(x1) - b * x1;

      ExpectedF4 := (a * x4 * Log(x4)) + (b * x4) + c;

      ExpectedUpperBound := ExpectedF4 * Noise;

      EXIT(f4 <= ExpectedUpperBound);

Example

There are no examples available.
Member of Lib.Library - Calc Complexity


IsQuadratic@23 Method

The procedure IsQuadratic is available in codeunit 130010.

Syntax

IsQuadratic@23(
    x1@1000 : Decimal x1, //Input parameter of type Decimal
    x2@1001 : Decimal x2, //Input parameter of type Decimal
    x3@1002 : Decimal x3, //Input parameter of type Decimal
    x4@1010 : Decimal x4, //Input parameter of type Decimal
    f1@1003 : Decimal f1, //Input parameter of type Decimal
    f2@1004 : Decimal f2, //Input parameter of type Decimal
    f3@1005 : Decimal f3, //Input parameter of type Decimal
    f4@1011 : Decimal f4 //Input parameter of type Decimal
);

Parameters

x1
Input parameter of type Decimal
x2
Input parameter of type Decimal
x3
Input parameter of type Decimal
x4
Input parameter of type Decimal
f1
Input parameter of type Decimal
f2
Input parameter of type Decimal
f3
Input parameter of type Decimal
f4
Input parameter of type Decimal

Return Value

Boolean

Remarks

The relevant search keywords are: Is, Quadratic.

For a clarification about how this function works, refer to the code listed below.

      // x1, x2, x3 and x4 are sizes of data input. fx1, fx2,fx3 and fx4 are the cost of processing that data
      // If the cost is quadratic: f(x) = a.x.x + b.x + c
      // Demonstrate that the computational cost is quadratic by finding a and b and c and checking that
      // an upper bound can be defined, so fx4 is actually under the bound

      IF (x1 = x2) OR (x1 = x3) THEN
        ERROR(DivisionByZeroErr);

      b :=
        (((x1 * x1 - x3 * x3) * (f1 - f2)) -
         ((x1 * x1 - x2 * x2) * (f1 - f3))) /
        (((x1 - x2) * (x1 * x1 - x3 * x3)) -
         ((x1 - x3) * (x1 * x1 - x2 * x2)));

      a :=
        ((f1 - f2) - b * (x1 - x2)) /
        (x1 * x1 - x2 * x2);

      c := f1 - a * x1 * x1 - b * x1;

      ExpectedF4 := (a * x4 * x4) + (b * x4) + c;

      ExpectedUpperBound := ExpectedF4 * Noise;

      EXIT(f4 <= ExpectedUpperBound);

Example

There are no examples available.
Member of Lib.Library - Calc Complexity


Library - Cash Flow Class

Lib.Library - Cash Flow

COD131331 applies to ERM,W1,All.

Methods

Name | Description
ClearJournal@9 | The procedure ClearJournal is available in codeunit 131331.
CreateCashFlowAccount@19 | The procedure CreateCashFlowAccount is available in codeunit 131331.
CreateCashFlowCard@13 | The procedure CreateCashFlowCard is available in codeunit 131331.
CreateJournalLine@3 | The procedure CreateJournalLine is available in codeunit 131331.
CreateManualLinePayment@11 | The procedure CreateManualLinePayment is available in codeunit 131331.
CreateManualLineRevenue@20 | The procedure CreateManualLineRevenue is available in codeunit 131331.
DeleteJournalLine@4 | The procedure DeleteJournalLine is available in codeunit 131331.
DeleteManualLine@12 | The procedure DeleteManualLine is available in codeunit 131331.
FillBudgetJournal@16 | The procedure FillBudgetJournal is available in codeunit 131331.
FillJournal@7 | The procedure FillJournal is available in codeunit 131331.
FindCashFlowAccount@2 | The procedure FindCashFlowAccount is available in codeunit 131331.
FindCashFlowAnalysisView@14 | The procedure FindCashFlowAnalysisView is available in codeunit 131331.
FindCashFlowCard@1 | The procedure FindCashFlowCard is available in codeunit 131331.
PostJournal@10 | The procedure PostJournal is available in codeunit 131331.
PostJournalLines@15 | The procedure PostJournalLines is available in codeunit 131331.

See Also

Lib


ClearJournal@9 Method

The procedure ClearJournal is available in codeunit 131331.

Syntax

ClearJournal@9(
      //param element not supplied
);

Remarks

The relevant search keywords are: Clear, Journal.

For a clarification about how this function works, refer to the code listed below.

      CFWorksheetLine.DELETEALL(TRUE);

Example

The below example is extracted from the test automation codeunit 134553 to show one way of using this function.

      // Test filling a CF journal using Fill batch considering Pmt. Tol. Amount
      // The payment amount for the invoice should be within the tolerance amount, which leads to a closed
      // ledger entry and therefore there must not be a CF forecast consideration

      // Setup
      Initialize;
      GeneralLedgerSetup.GET; // keep current setup
      // max pmt tol amount should be 50% of the invoice amount
      LibraryCashFlowForecast.ClearJournal;
      CFHelper.SetupVendorPmtTolAmtTestCase(CashFlowForecast,Vendor,Amount,0.5,50);
      CFHelper.CreateAndApplyVendorInvPmt(GenJournalLine,Vendor."No.",-Amount,
        Amount - ROUND(Amount * 0.5 / 100),EmptyDateFormula,EmptyDateFormula,EmptyDateFormula);

      // Exercise
      ConsiderSource[SourceType::Payables] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      // No CF lines expected
      Assert.AreEqual(0,
        CFHelper.FilterSingleJournalLine(CFWorksheetLine,GenJournalLine."Document No.",SourceType::Payables,CashFlowForecast."No."),
        STRSUBSTNO(UnexpectedCFWorksheetLineCountErr,CashFlowForecast."No.",GenJournalLine."Document No."));

      // Tear down
      CFHelper.SetupPmtTolPercentage(GeneralLedgerSetup."Payment Tolerance %");
      CFHelper.SetupPmtTolAmount(GeneralLedgerSetup."Max. Payment Tolerance Amount");
Member of Lib.Library - Cash Flow


CreateCashFlowAccount@19 Method

The procedure CreateCashFlowAccount is available in codeunit 131331.

Syntax

CreateCashFlowAccount@19(
    VAR CashFlowAccount@1000 : Record 841 CashFlowAccount, //Reference parameter of type Record
    AccountType@1001 : Option AccountType //Input parameter of type Option
);

Parameters

CashFlowAccount
Reference parameter of type Record
AccountType
Input parameter of type Option

Remarks

The relevant search keywords are: Create, Cash, Flow, Account.

For a clarification about how this function works, refer to the code listed below.

      CashFlowAccount.INIT;
      CashFlowAccount.VALIDATE("No.",
        LibraryUtility.GenerateRandomCode(CashFlowAccount.FIELDNO("No."),DATABASE::"Cash Flow Account"));
      CashFlowAccount.VALIDATE("Account Type",AccountType);
      CashFlowAccount.VALIDATE(Name,
        LibraryUtility.GenerateRandomCode(CashFlowAccount.FIELDNO(Name),DATABASE::"Cash Flow Account"));
      CashFlowAccount.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134555 to show one way of using this function.

      // Setup: Generically modify CF Setup
      Initialize;
      LibraryCashFlow.CreateCashFlowAccount(CashFlowAccount,CashFlowAccount."Account Type"::Entry);
      RecRef.OPEN(DATABASE::"Cash Flow Setup");
      RecRef.FINDFIRST;
      FieldRef := RecRef.FIELD(FieldNo);
      FieldRef.VALIDATE(CashFlowAccount."No.");
      RecRef.MODIFY(TRUE);

      LibraryCashFlow.CreateCashFlowCard(CashFlowForecast);
      LibraryCashFlow.ClearJournal;

      // Exercise
      LibraryCashFlow.FillJournal(ConsiderSource,CashFlowForecast."No.",FALSE);
      LibraryCashFlow.PostJournal;

      // Verify
      VerifyLedgerEntryAccount(CashFlowForecast,CashFlowAccount);
Member of Lib.Library - Cash Flow


CreateCashFlowCard@13 Method

The procedure CreateCashFlowCard is available in codeunit 131331.

Syntax

CreateCashFlowCard@13(
    VAR CashFlowForecast@1000 : Record 840 CashFlowForecast //Reference parameter of type Record
);

Parameters

CashFlowForecast
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Cash, Flow, Card.

For a clarification about how this function works, refer to the code listed below.

      CashFlowForecast.INIT;
      CashFlowForecast.VALIDATE(
        "No.",LibraryUtility.GenerateRandomCode(CashFlowForecast.FIELDNO("No."),DATABASE::"Cash Flow Forecast"));
      CashFlowForecast.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134555 to show one way of using this function.

      // Setup: Generically modify CF Setup
      Initialize;
      LibraryCashFlow.CreateCashFlowAccount(CashFlowAccount,CashFlowAccount."Account Type"::Entry);
      RecRef.OPEN(DATABASE::"Cash Flow Setup");
      RecRef.FINDFIRST;
      FieldRef := RecRef.FIELD(FieldNo);
      FieldRef.VALIDATE(CashFlowAccount."No.");
      RecRef.MODIFY(TRUE);

      LibraryCashFlow.CreateCashFlowCard(CashFlowForecast);
      LibraryCashFlow.ClearJournal;

      // Exercise
      LibraryCashFlow.FillJournal(ConsiderSource,CashFlowForecast."No.",FALSE);
      LibraryCashFlow.PostJournal;

      // Verify
      VerifyLedgerEntryAccount(CashFlowForecast,CashFlowAccount);
Member of Lib.Library - Cash Flow


CreateJournalLine@3 Method

The procedure CreateJournalLine is available in codeunit 131331.

Syntax

CreateJournalLine@3(
    VAR CFWorksheetLine@1002 : Record 846 CFWorksheetLine, //Reference parameter of type Record
    CFNo@1004 : Code[20] CFNo, //Input parameter of type Code
    CFAccountNo@1005 : Code[20] CFAccountNo //Input parameter of type Code
);

Parameters

CFWorksheetLine
Reference parameter of type Record
CFNo
Input parameter of type Code
CFAccountNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      RecRef.GETTABLE(CFWorksheetLine);
      CFWorksheetLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,CFWorksheetLine.FIELDNO("Line No.")));
      CFWorksheetLine.INSERT(TRUE);
      CFWorksheetLine.VALIDATE("Cash Flow Forecast No.",CFNo);
      CFWorksheetLine.VALIDATE("Cash Flow Account No.",CFAccountNo);
      CFWorksheetLine.VALIDATE("Cash Flow Date",WORKDATE);  // Defaults to work date.
      CFWorksheetLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134558 to show one way of using this function.

      // Create Cash Flow Card
      LibraryCashFlowForecast.CreateCashFlowCard(CashFlowForecast);
      CashFlowForecast.VALIDATE(Description,CashFlowForecast."No.");
      CashFlowForecast.MODIFY(TRUE);

      // Create Cash Flow Acount
      LibraryCashFlowForecast.CreateCashFlowAccount(CashFlowAccount,CashFlowAccount."Account Type"::Entry);
      CashFlowAccount.VALIDATE(Name,CashFlowAccount."No.");
      CashFlowAccount.MODIFY(TRUE);

      LibraryCashFlowForecast.CreateJournalLine(CashFlowWorksheetLine,CashFlowForecast."No.",CashFlowAccount."No.");

      CashFlowJournalPage.OPENEDIT;
Member of Lib.Library - Cash Flow


CreateManualLinePayment@11 Method

The procedure CreateManualLinePayment is available in codeunit 131331.

Syntax

CreateManualLinePayment@11(
    VAR CFManualExpense@1000 : Record 850 CFManualExpense, //Reference parameter of type Record
    CFAccountNo@1002 : Code[20] CFAccountNo //Input parameter of type Code
);

Parameters

CFManualExpense
Reference parameter of type Record
CFAccountNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Manual, Line, Payment.

For a clarification about how this function works, refer to the code listed below.

      CFManualExpense.INIT;
      CFManualExpense.VALIDATE("Cash Flow Account No.",CFAccountNo);
      CFManualExpense.VALIDATE(Code,
        LibraryUtility.GenerateRandomCode(CFManualExpense.FIELDNO(Code),DATABASE::"Cash Flow Manual Expense"));
      CFManualExpense.VALIDATE("Starting Date",WORKDATE);  // Required field to post
      CFManualExpense.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // [SCENARIO 208630] Default dimension have to been exist after renaming record of "Cash Flow Manual Expense"
      Initialize;

      // [GIVEN] "Cash Flow Manual Expense" with Code = "NAME1"
      LibraryCF.CreateManualLinePayment(CashFlowManualExpense,'');

      // [GIVEN] Default dimension DIM1 with value DIMVALUE1
      CreateDefDimForRecord(DimensionValue[1],DATABASE::"Cash Flow Manual Expense",CashFlowManualExpense.Code);

      // [GIVEN] Default dimension DIM2 with value DIMVALUE2
      CreateDefDimForRecord(DimensionValue[2],DATABASE::"Cash Flow Manual Expense",CashFlowManualExpense.Code);

      // [WHEN] Rename "Cash Flow Manual Expense" to "NAME2"
      CashFlowManualExpense.RENAME(
        LibraryUtility.GenerateRandomCode(CashFlowManualExpense.FIELDNO(Code),DATABASE::"Cash Flow Manual Expense"));

      // [THEN] Renamed record has values:
      // [THEN] Global Dimension 1 Code = "DIM1" with value = "DIMVALUE1"
      VerifyDefaultDimension(DimensionValue[1],DATABASE::"Cash Flow Manual Expense",CashFlowManualExpense.Code);

      // [THEN] Global Dimension 2 Code = "DIM2" with value = "DIMVALUE2"
      VerifyDefaultDimension(DimensionValue[2],DATABASE::"Cash Flow Manual Expense",CashFlowManualExpense.Code);
Member of Lib.Library - Cash Flow


CreateManualLineRevenue@20 Method

The procedure CreateManualLineRevenue is available in codeunit 131331.

Syntax

CreateManualLineRevenue@20(
    VAR CFManualRevenue@1000 : Record 849 CFManualRevenue, //Reference parameter of type Record
    CFAccountNo@1002 : Code[20] CFAccountNo //Input parameter of type Code
);

Parameters

CFManualRevenue
Reference parameter of type Record
CFAccountNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Manual, Line, Revenue.

For a clarification about how this function works, refer to the code listed below.

      CFManualRevenue.INIT;
      CFManualRevenue.VALIDATE("Cash Flow Account No.",CFAccountNo);
      CFManualRevenue.VALIDATE(Code,
        LibraryUtility.GenerateRandomCode(CFManualRevenue.FIELDNO(Code),DATABASE::"Cash Flow Manual Revenue"));
      CFManualRevenue.VALIDATE("Starting Date",WORKDATE);  // Required field to post
      CFManualRevenue.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // [SCENARIO 208630] Default dimension have to been exist after renaming record of "Cash Flow Manual Revenue"
      Initialize;

      // [GIVEN] "Cash Flow Manual Revenue" with Code = "NAME1"
      LibraryCF.CreateManualLineRevenue(CashFlowManualRevenue,'');

      // [GIVEN] Default dimension DIM1 with value DIMVALUE1
      CreateDefDimForRecord(DimensionValue[1],DATABASE::"Cash Flow Manual Revenue",CashFlowManualRevenue.Code);

      // [GIVEN] Default dimension DIM2 with value DIMVALUE2
      CreateDefDimForRecord(DimensionValue[2],DATABASE::"Cash Flow Manual Revenue",CashFlowManualRevenue.Code);

      // [WHEN] Rename "Cash Flow Manual Revenue" to "NAME2"
      CashFlowManualRevenue.RENAME(
        LibraryUtility.GenerateRandomCode(CashFlowManualRevenue.FIELDNO(Code),DATABASE::"Cash Flow Manual Revenue"));

      // [THEN] Renamed record has values:
      // [THEN] Global Dimension 1 Code = "DIM1" with value = "DIMVALUE1"
      VerifyDefaultDimension(DimensionValue[1],DATABASE::"Cash Flow Manual Revenue",CashFlowManualRevenue.Code);

      // [THEN] Global Dimension 2 Code = "DIM2" with value = "DIMVALUE2"
      VerifyDefaultDimension(DimensionValue[2],DATABASE::"Cash Flow Manual Revenue",CashFlowManualRevenue.Code);
Member of Lib.Library - Cash Flow


DeleteJournalLine@4 Method

The procedure DeleteJournalLine is available in codeunit 131331.

Syntax

DeleteJournalLine@4(
      //param element not supplied
);

Remarks

The relevant search keywords are: Delete, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

Example
There are no examples available.

        Member of
        Lib.Library - Cash Flow


DeleteManualLine@12 Method

The procedure DeleteManualLine is available in codeunit 131331.

Syntax

DeleteManualLine@12(
      //param element not supplied
);

Remarks

The relevant search keywords are: Delete, Manual, Line.

For a clarification about how this function works, refer to the code listed below.

Example
There are no examples available.

        Member of
        Lib.Library - Cash Flow


FillBudgetJournal@16 Method

The procedure FillBudgetJournal is available in codeunit 131331.

Syntax

FillBudgetJournal@16(
    CFFunds@1002 : Boolean CFFunds, //Input parameter of type Boolean
    CFNo@1013 : Code[20] CFNo, //Input parameter of type Code
    GLBudgetName@1003 : Code[10] GLBudgetName //Input parameter of type Code
);

Parameters

CFFunds
Input parameter of type Boolean
CFNo
Input parameter of type Code
GLBudgetName
Input parameter of type Code

Remarks

The relevant search keywords are: Fill, Budget, Journal.

For a clarification about how this function works, refer to the code listed below.

      CFWorksheetLine.INIT;
      ConsiderSource[SourceType::"Liquid Funds"] := CFFunds;
      ConsiderSource[SourceType::"G/L Budget"] := TRUE;
      SuggestWorksheetLines.InitializeRequest(ConsiderSource,CFNo,GLBudgetName,FALSE);
      SuggestWorksheetLines.USEREQUESTPAGE := FALSE;
      SuggestWorksheetLines.RUN;

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // Suggest lines should set source type accordingly

      // Setup
      Initialize;
      CFHelper.CreateCashFlowForecastDefault(CashFlowForecast);
      CashFlowForecast.VALIDATE("G/L Budget From",WORKDATE);
      CashFlowForecast.VALIDATE("G/L Budget To",WORKDATE);
      CashFlowForecast.MODIFY(TRUE);
      CFHelper.CreateBudgetEntry(GLBudgetEntry,CashFlowForecast."G/L Budget To");

      // Exercise
      LibraryCF.FillBudgetJournal(FALSE,CashFlowForecast."No.",GLBudgetEntry."Budget Name");

      // Verify
      CFHelper.FilterSingleJournalLine(CFWorksheetLine,FORMAT(GLBudgetEntry."Entry No."),
        CFWorksheetLine."Source Type"::"G/L Budget",CashFlowForecast."No.");
      CFWorksheetLine.TESTFIELD("Source Type",CFWorksheetLine."Source Type"::"G/L Budget");
      CFWorksheetLine.TESTFIELD("G/L Budget Name",GLBudgetEntry."Budget Name");
      CFHelper.VerifyExpectedCFAmount(-GLBudgetEntry.Amount,CFWorksheetLine."Amount (LCY)");
Member of Lib.Library - Cash Flow


FillJournal@7 Method

The procedure FillJournal is available in codeunit 131331.

Syntax

FillJournal@7(
    ConsiderSource@1002 : ARRAY [11] OF Boolean ConsiderSource, //Input Array parameter of type Boolean
    CFNo@1013 : Code[20] CFNo, //Input parameter of type Code
    GroupByDocumentType@1003 : Boolean GroupByDocumentType //Input parameter of type Boolean
);

Parameters

ConsiderSource
Input Array parameter of type Boolean
CFNo
Input parameter of type Code
GroupByDocumentType
Input parameter of type Boolean

Remarks

The relevant search keywords are: Fill, Journal.

For a clarification about how this function works, refer to the code listed below.

      CFWorksheetLine.INIT;
      SuggestWorksheetLines.InitializeRequest(ConsiderSource,CFNo,'',GroupByDocumentType);
      SuggestWorksheetLines.USEREQUESTPAGE := FALSE;
      SuggestWorksheetLines.RUN;

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // Test filling a CF journal by using Fill batch with/without a discounted 3-line service order where vendor has
      // CF payment terms set. Verify computed due and cash flow date and discounted/full amount

      // Setup
      Initialize;
      LibraryERM.GetDiscountPaymentTerm(PaymentTerms);
      IF ConsiderDiscount THEN BEGIN
        CFHelper.GetDifferentDsctPaymentTerms(PaymentTerms2,PaymentTerms.Code);
        CFHelper.CreateCashFlowForecastConsiderDiscountAndCFPmtTerms(CashFlowForecast);
        PaymentTermsCode := PaymentTerms.Code;
        PaymentTermsCode2 := PaymentTerms2.Code;
      END ELSE BEGIN
        CFHelper.CreateCashFlowForecastConsiderCFPmtTerms(CashFlowForecast);
        PaymentTermsCode2 := PaymentTerms.Code;
      END;
      CFHelper.CreateSpecificServiceOrder(ServiceHeader,PaymentTermsCode,PaymentTermsCode2);

      CFHelper.SetExpectedDsctAPmtTermValues(DocumentType::Service,ServiceHeader."No.",ServiceHeader."Customer No.",
        ServiceHeader."Document Date",ConsiderDiscount,ExpectedCFDate,ExpectedAmount);

      // Exercise
      ConsiderSource[SourceType::"Service Orders"] := TRUE;
      CFHelper.FillJournal(ConsiderSource,CashFlowForecast."No.",GroupByDocumentType);

      // Verify
      CFHelper.VerifyCFDataOnSnglJnlLine(CFWorksheetLine,ServiceHeader."No.",SourceType::"Service Orders",
        CashFlowForecast."No.",ExpectedAmount,ExpectedCFDate);
Member of Lib.Library - Cash Flow


FindCashFlowAccount@2 Method

The procedure FindCashFlowAccount is available in codeunit 131331.

Syntax

FindCashFlowAccount@2(
    VAR CashFlowAccount@1000 : Record 841 CashFlowAccount //Reference parameter of type Record
);

Parameters

CashFlowAccount
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Cash, Flow, Account.

For a clarification about how this function works, refer to the code listed below.

      CashFlowAccount.SETRANGE("Account Type",CashFlowAccount."Account Type"::Entry);
      CashFlowAccount.FINDFIRST;

Example

The below example is extracted from the test automation codeunit 134556 to show one way of using this function.

      // Setup
      FromDate := DMY2DATE(1,1,DATE2DMY(WORKDATE,3));
      ToDate := DMY2DATE(31,12,DATE2DMY(WORKDATE,3));

      LibraryCashFlow.FindCashFlowAccount(CashFlowAccount);
      FindGLAccount(GLAccount,GLAccountType);
      LinkCFAccount(CashFlowAccount,GLAccount,Integration);
      // End-Total accounts posts to Begin-Total counterparts
      IF GLAccount."Account Type" = GLAccount."Account Type"::"End-Total" THEN
        FindBeginAccount(GLAccount);

      LibraryERM.CreateGLBudgetName(GLBudgetName);
      LibraryERM.CreateGLBudgetEntry(GLBudgetEntry,WORKDATE,GLAccount."No.",GLBudgetName.Name);
      GLBudgetEntry.VALIDATE("Dimension Set ID",CreateDimensionSetID);
      GLBudgetEntry.VALIDATE(Amount,LibraryRandom.RandDec(1000,2));
      GLBudgetEntry.MODIFY(TRUE);
      StoreCashFlowBudgetEntry(TempCashFlowForecastEntry,GLBudgetEntry);
      LibraryCashFlow.CreateCashFlowCard(CashFlowForecast);
      CashFlowForecast.VALIDATE("G/L Budget From",FromDate);
      CashFlowForecast.VALIDATE("G/L Budget To",ToDate);
      CashFlowForecast.MODIFY(TRUE);
      LibraryCashFlow.ClearJournal;

      // Exercise
      LibraryCashFlow.FillBudgetJournal(FALSE,CashFlowForecast."No.",GLBudgetName.Name);
      LibraryCashFlow.PostJournal;

      // Verify
      VerifyCashFlowLedgerEntries(TempCashFlowForecastEntry,CashFlowForecast);
Member of Lib.Library - Cash Flow


FindCashFlowAnalysisView@14 Method

The procedure FindCashFlowAnalysisView is available in codeunit 131331.

Syntax

FindCashFlowAnalysisView@14(
    VAR AnalysisView@1000 : Record 363 AnalysisView //Reference parameter of type Record
);

Parameters

AnalysisView
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Cash, Flow, Analysis, View.

For a clarification about how this function works, refer to the code listed below.

      WITH AnalysisView DO BEGIN
        RESET;
        SETRANGE("Account Source","Account Source"::"Cash Flow Account");
        FINDFIRST;
      END

Example

The below example is extracted from the test automation codeunit 134553 to show one way of using this function.

      // Verify Cash Flow Forcast show in Analysis by Dimesnion with view by Month.

      // Setup: Create Cash Flow Forecast, suggest Cash Flow Worksheet Line and Register, find Cash Flow Analysis by Dimension and Update.
      Initialize;
      CreateAndPostCashFlowForecast(CashFlowForecast);
      ExecuteUIHandler;
      LibraryCashFlowForecast.FindCashFlowAnalysisView(AnalysisView);
      LibraryVariableStorage.Enqueue(CashFlowForecast."No.");  // Enqueue AnalysisByDimensionsHandler.

      // Exercise.
      UpdateAnalysisViewList(AnalysisView.Code);

      // Verify: Verify Cash Flow Forcast show in Analysis by Dimesnion with view by Month, done by AnalysisByDimensionsMatrixHandler.
Member of Lib.Library - Cash Flow


FindCashFlowCard@1 Method

The procedure FindCashFlowCard is available in codeunit 131331.

Syntax

FindCashFlowCard@1(
    VAR CashFlowForecast@1000 : Record 840 CashFlowForecast //Reference parameter of type Record
);

Parameters

CashFlowForecast
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Cash, Flow, Card.

For a clarification about how this function works, refer to the code listed below.

      CashFlowForecast.FINDFIRST;

Example

The below example is extracted from the test automation codeunit 134559 to show one way of using this function.

      // Empty all journal lines
      CFWorksheetLine.DELETEALL;

      // Find data
      LibraryCashFlowForecast.FindCashFlowCard(CashFlowForecast);
      LibraryCashFlowForecast.FindCashFlowAccount(CashFlowAccount);
      LibraryCashFlowForecast.CreateJournalLine(CFWorksheetLine,CashFlowForecast."No.",CashFlowAccount."No.");

      // Insert into journal
      CFWorksheetLine.VALIDATE("Source Type",SourceType);
      CFWorksheetLine.VALIDATE("Source No.",SourceNo);
      IF CFWorksheetLine."Source Type" = CFWorksheetLine."Source Type"::"G/L Budget" THEN BEGIN
        GLBudgetName.FINDSET;
        GLBudgetName.NEXT(LibraryRandom.RandInt(GLBudgetName.COUNT));
        CFWorksheetLine."G/L Budget Name" := GLBudgetName.Name;
      END;
      CFWorksheetLine.MODIFY(TRUE);
Member of Lib.Library - Cash Flow


PostJournal@10 Method

The procedure PostJournal is available in codeunit 131331.

Syntax

PostJournal@10(
      //param element not supplied
);

Remarks

The relevant search keywords are: Post, Journal.

For a clarification about how this function works, refer to the code listed below.

      CODEUNIT.RUN(CODEUNIT::"Cash Flow Wksh.-Register Batch",CFWorksheetLine);

Example

The below example is extracted from the test automation codeunit 134555 to show one way of using this function.

      // Setup: Generically modify CF Setup
      Initialize;
      LibraryCashFlow.CreateCashFlowAccount(CashFlowAccount,CashFlowAccount."Account Type"::Entry);
      RecRef.OPEN(DATABASE::"Cash Flow Setup");
      RecRef.FINDFIRST;
      FieldRef := RecRef.FIELD(FieldNo);
      FieldRef.VALIDATE(CashFlowAccount."No.");
      RecRef.MODIFY(TRUE);

      LibraryCashFlow.CreateCashFlowCard(CashFlowForecast);
      LibraryCashFlow.ClearJournal;

      // Exercise
      LibraryCashFlow.FillJournal(ConsiderSource,CashFlowForecast."No.",FALSE);
      LibraryCashFlow.PostJournal;

      // Verify
      VerifyLedgerEntryAccount(CashFlowForecast,CashFlowAccount);
Member of Lib.Library - Cash Flow


PostJournalLines@15 Method

The procedure PostJournalLines is available in codeunit 131331.

Syntax

PostJournalLines@15(
    VAR CFWorksheetLine@1003 : Record 846 CFWorksheetLine //Reference parameter of type Record
);

Parameters

CFWorksheetLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Post, Journal, Lines.

For a clarification about how this function works, refer to the code listed below.

      CFWorksheetLine.FINDSET;
      CODEUNIT.RUN(CODEUNIT::"Cash Flow Wksh.-Register Batch",CFWorksheetLine);

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // Setup
      Initialize;
      CFHelper.CreateCashFlowForecastDefault(CashFlowForecast);
      CFHelper.CreateDefaultServiceOrder(ServiceHeader);

      // Exercise
      ConsiderSource[SourceType::"Service Orders"] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");
      CFHelper.FilterSingleJournalLine(CFWorksheetLine,ServiceHeader."No.",SourceType::"Service Orders",CashFlowForecast."No.");

      LibraryCF.PostJournalLines(CFWorksheetLine);

      // Verify
      CFForecastEntry.SETRANGE("Document No.",ServiceHeader."No.");
      CFForecastEntry.FINDFIRST;
      CFForecastEntry.TESTFIELD("Source Type",CFForecastEntry."Source Type"::"Service Orders");
Member of Lib.Library - Cash Flow


Library - Cash Flow Helper Class

Lib.Library - Cash Flow Helper

COD131332 applies to ERM,W1,All.
Feature: Cash Flow Area: Filling Cash Flow Journal Provides helper functions for codeunits in this area.

Methods

Name | Description
AddAndPostPOPrepaymentInvoice@38 | The procedure AddAndPostPOPrepaymentInvoice is available in codeunit 131332.
AddAndPostSOPrepaymentInvoice@35 | The procedure AddAndPostSOPrepaymentInvoice is available in codeunit 131332.
AddPOPrepayment@102 | The procedure AddPOPrepayment is available in codeunit 131332.
AddSOPrepayment@101 | The procedure AddSOPrepayment is available in codeunit 131332.
ApplyInvoicePayment@36 | The procedure ApplyInvoicePayment is available in codeunit 131332.
AssignCFPaymentTermToCustomer@73 | The procedure AssignCFPaymentTermToCustomer is available in codeunit 131332.
AssignCFPaymentTermToVendor@100 | The procedure AssignCFPaymentTermToVendor is available in codeunit 131332.
AssignPaymentTermToCustomer@4 | The procedure AssignPaymentTermToCustomer is available in codeunit 131332.
AssignPaymentTermToVendor@5 | The procedure AssignPaymentTermToVendor is available in codeunit 131332.
CalcCustDiscAmt@85 | The procedure CalcCustDiscAmt is available in codeunit 131332.
CalcCustDiscAmtLCY@82 | The procedure CalcCustDiscAmtLCY is available in codeunit 131332.
CalcDiscAmtFromGenJnlLine@81 | The procedure CalcDiscAmtFromGenJnlLine is available in codeunit 131332.
CalcPurchExpectedPrepmtAmounts@89 | The procedure CalcPurchExpectedPrepmtAmounts is available in codeunit 131332.
CalcSalesExpectedPrepmtAmounts@88 | The procedure CalcSalesExpectedPrepmtAmounts is available in codeunit 131332.
CalculateDiscountAmount@28 | The procedure CalculateDiscountAmount is available in codeunit 131332.
CalcVendDiscAmt@87 | The procedure CalcVendDiscAmt is available in codeunit 131332.
CalcVendDiscAmtLCY@83 | The procedure CalcVendDiscAmtLCY is available in codeunit 131332.
ChangeWorkdate@12 | The procedure ChangeWorkdate is available in codeunit 131332.
ChangeWorkdateByDateFormula@13 | The procedure ChangeWorkdateByDateFormula is available in codeunit 131332.
CreateAndApplySalesInvPayment@2 | The procedure CreateAndApplySalesInvPayment is available in codeunit 131332.
CreateAndApplyVendorInvPmt@6 | The procedure CreateAndApplyVendorInvPmt is available in codeunit 131332.
CreateBudgetEntry@49 | The procedure CreateBudgetEntry is available in codeunit 131332.
CreateCashFlowForecastConsiderCFPmtTerms@67 | The procedure CreateCashFlowForecastConsiderCFPmtTerms is available in codeunit 131332.
CreateCashFlowForecastConsiderDiscount@59 | The procedure CreateCashFlowForecastConsiderDiscount is available in codeunit 131332.
CreateCashFlowForecastConsiderDiscountAndCFPmtTerms@68 | The procedure CreateCashFlowForecastConsiderDiscountAndCFPmtTerms is available in codeunit 131332.
CreateCashFlowForecastDefault@99 | The procedure CreateCashFlowForecastDefault is available in codeunit 131332.
CreateCustWithCFDsctPmtTerm@17 | The procedure CreateCustWithCFDsctPmtTerm is available in codeunit 131332.
CreateDefaultPaymentTerms@29 | The procedure CreateDefaultPaymentTerms is available in codeunit 131332.
CreateDefaultPurchaseOrder@65 | The procedure CreateDefaultPurchaseOrder is available in codeunit 131332.
CreateDefaultSalesOrder@62 | The procedure CreateDefaultSalesOrder is available in codeunit 131332.
CreateDefaultServiceOrder@66 | The procedure CreateDefaultServiceOrder is available in codeunit 131332.
CreateFixedAssetForDisposal@3 | The procedure CreateFixedAssetForDisposal is available in codeunit 131332.
CreateFixedAssetForInvestment@1 | The procedure CreateFixedAssetForInvestment is available in codeunit 131332.
CreateLedgerEntry@11 | The procedure CreateLedgerEntry is available in codeunit 131332.
CreateManualPayment@30 | The procedure CreateManualPayment is available in codeunit 131332.
CreateManualRevenue@56 | The procedure CreateManualRevenue is available in codeunit 131332.
CreatePrepaymentAccount@27 | The procedure CreatePrepaymentAccount is available in codeunit 131332.
CreatePrepmtPurchaseOrder@91 | The procedure CreatePrepmtPurchaseOrder is available in codeunit 131332.
CreatePrepmtSalesOrder@90 | The procedure CreatePrepmtSalesOrder is available in codeunit 131332.
CreatePurchaseLine@58 | The procedure CreatePurchaseLine is available in codeunit 131332.
CreatePurchaseOrder@94 | The procedure CreatePurchaseOrder is available in codeunit 131332.
CreateRandomDateFormula@8 | The procedure CreateRandomDateFormula is available in codeunit 131332.
CreateSalesLine@57 | The procedure CreateSalesLine is available in codeunit 131332.
CreateSalesOrder@92 | The procedure CreateSalesOrder is available in codeunit 131332.
CreateServiceLines@63 | The procedure CreateServiceLines is available in codeunit 131332.
CreateSpecificCashFlowCard@53 | The procedure CreateSpecificCashFlowCard is available in codeunit 131332.
CreateSpecificPurchaseOrder@32 | The procedure CreateSpecificPurchaseOrder is available in codeunit 131332.
CreateSpecificSalesOrder@31 | The procedure CreateSpecificSalesOrder is available in codeunit 131332.
CreateSpecificServiceOrder@33 | The procedure CreateSpecificServiceOrder is available in codeunit 131332.
CreateVendorWithCFDsctPmtTerm@22 | The procedure CreateVendorWithCFDsctPmtTerm is available in codeunit 131332.
FillJnlOnCertDateFormulas@14 | The procedure FillJnlOnCertDateFormulas is available in codeunit 131332.
FillJournal@44 | The procedure FillJournal is available in codeunit 131332.
FillJournalOnCertainDate@19 | The procedure FillJournalOnCertainDate is available in codeunit 131332.
FilterSingleJournalLine@43 | The procedure FilterSingleJournalLine is available in codeunit 131332.
FindCFBudgetAccount@51 | The procedure FindCFBudgetAccount is available in codeunit 131332.
FindCFLiquidFundAccount@41 | The procedure FindCFLiquidFundAccount is available in codeunit 131332.
FindCustomerCFPaymentTerms@61 | The procedure FindCustomerCFPaymentTerms is available in codeunit 131332.
FindFirstCustLEFromSO@80 | The procedure FindFirstCustLEFromSO is available in codeunit 131332.
FindFirstGLAccFromCFAcc@54 | The procedure FindFirstGLAccFromCFAcc is available in codeunit 131332.
FindFirstVendorLEFromPO@42 | The procedure FindFirstVendorLEFromPO is available in codeunit 131332.
FindPurchaseLine@40 | The procedure FindPurchaseLine is available in codeunit 131332.
FindSalesLine@26 | The procedure FindSalesLine is available in codeunit 131332.
GenerateDateFromFormulaArray@16 | The procedure GenerateDateFromFormulaArray is available in codeunit 131332.
GenerateDateFromFormulas@20 | The procedure GenerateDateFromFormulas is available in codeunit 131332.
GetDifferentDsctPaymentTerms@37 | The procedure GetDifferentDsctPaymentTerms is available in codeunit 131332.
GetTotalAmountForPurchaseOrderWithCashFlowPaymentTermsDiscount@107 | The procedure GetTotalAmountForPurchaseOrderWithCashFlowPaymentTermsDiscount is available in codeunit 131332.
GetTotalAmountForSalesOrderWithCashFlowPaymentTermsDiscount@111 | The procedure GetTotalAmountForSalesOrderWithCashFlowPaymentTermsDiscount is available in codeunit 131332.
GetTotalAmountForServiceOrderWithCashFlowPaymentTermsDiscount@103 | The procedure GetTotalAmountForServiceOrderWithCashFlowPaymentTermsDiscount is available in codeunit 131332.
GetTotalPurchaseAmount@84 | The procedure GetTotalPurchaseAmount is available in codeunit 131332.
GetTotalSalesAmount@45 | The procedure GetTotalSalesAmount is available in codeunit 131332.
GetTotalServiceAmount@145 | The procedure GetTotalServiceAmount is available in codeunit 131332.
InsertCFLedgerEntry@69 | The procedure InsertCFLedgerEntry is available in codeunit 131332.
PostPOPrepaymentInvoice@79 | The procedure PostPOPrepaymentInvoice is available in codeunit 131332.
PostSOPrepaymentInvoice@78 | The procedure PostSOPrepaymentInvoice is available in codeunit 131332.
SelectAndClearGenJournalBatch@46 | The procedure SelectAndClearGenJournalBatch is available in codeunit 131332.
SetDefaultDepreciationBook@23 | The procedure SetDefaultDepreciationBook is available in codeunit 131332.
SetExpectedDsctAPmtTermValues@47 | The procedure SetExpectedDsctAPmtTermValues is available in codeunit 131332.
SetPmtToleranceOptionsOnCashFlowForecast@60 | The procedure SetPmtToleranceOptionsOnCashFlowForecast is available in codeunit 131332.
SetupCustomerPmtTolAmtTestCase@71 | The procedure SetupCustomerPmtTolAmtTestCase is available in codeunit 131332.
SetupDsctPmtTermsCustLETest@15 | The procedure SetupDsctPmtTermsCustLETest is available in codeunit 131332.
SetupPmtDsctGracePeriod@64 | The procedure SetupPmtDsctGracePeriod is available in codeunit 131332.
SetupPmtDsctTolCustLETest@76 | The procedure SetupPmtDsctTolCustLETest is available in codeunit 131332.
SetupPmtDsctTolVendorLETest@21 | The procedure SetupPmtDsctTolVendorLETest is available in codeunit 131332.
SetupPmtTolAmount@10 | The procedure SetupPmtTolAmount is available in codeunit 131332.
SetupPmtTolPercentage@9 | The procedure SetupPmtTolPercentage is available in codeunit 131332.
SetupVendorPmtTolAmtTestCase@18 | The procedure SetupVendorPmtTolAmtTestCase is available in codeunit 131332.
UpdateDueDateOnCustomerLedgerEntry@34 | The procedure UpdateDueDateOnCustomerLedgerEntry is available in codeunit 131332.
UpdateDueDateOnVendorLedgerEntry@72 | The procedure UpdateDueDateOnVendorLedgerEntry is available in codeunit 131332.
UpdatePmtDiscountDateOnCustomerLedgerEntry@70 | The procedure UpdatePmtDiscountDateOnCustomerLedgerEntry is available in codeunit 131332.
UpdatePmtDiscountDateOnVendorLedgerEntry@74 | The procedure UpdatePmtDiscountDateOnVendorLedgerEntry is available in codeunit 131332.
VerifyCFDataOnSnglJnlLine@112 | The procedure VerifyCFDataOnSnglJnlLine is available in codeunit 131332.
VerifyCFDateOnCFJnlLine@7 | The procedure VerifyCFDateOnCFJnlLine is available in codeunit 131332.
VerifyExpectedCFAmount@50 | The procedure VerifyExpectedCFAmount is available in codeunit 131332.
VerifyExpectedCFAmtNearlyEqual@52 | The procedure VerifyExpectedCFAmtNearlyEqual is available in codeunit 131332.

See Also

Lib


AddAndPostPOPrepaymentInvoice@38 Method

The procedure AddAndPostPOPrepaymentInvoice is available in codeunit 131332.

Syntax

AddAndPostPOPrepaymentInvoice@38(
    VAR PurchaseHeader@1000 : Record 38 PurchaseHeader, //Reference parameter of type Record
    PrepaymentPercentage@1002 : Decimal PrepaymentPercentage //Input parameter of type Decimal
);

Parameters

PurchaseHeader
Reference parameter of type Record
PrepaymentPercentage
Input parameter of type Decimal

Return Value

Code[20]

Remarks

The relevant search keywords are: Add, Post, Purchase Order, Prepayment, Invoice.

For a clarification about how this function works, refer to the code listed below.

      AddPOPrepayment(PurchaseHeader,PrepaymentPercentage);
      PrepmtInvNo := PostPOPrepaymentInvoice(PurchaseHeader);

Example

There are no examples available.
Member of Lib.Library - Cash Flow Helper


AddAndPostSOPrepaymentInvoice@35 Method

The procedure AddAndPostSOPrepaymentInvoice is available in codeunit 131332.

Syntax

AddAndPostSOPrepaymentInvoice@35(
    VAR SalesHeader@1000 : Record 36 SalesHeader, //Reference parameter of type Record
    PrepaymentPercentage@1001 : Decimal PrepaymentPercentage //Input parameter of type Decimal
);

Parameters

SalesHeader
Reference parameter of type Record
PrepaymentPercentage
Input parameter of type Decimal

Return Value

Code[20]

Remarks

The relevant search keywords are: Add, Post, Sales Order, Prepayment, Invoice.

For a clarification about how this function works, refer to the code listed below.

      AddSOPrepayment(SalesHeader,PrepaymentPercentage);
      PrepmtInvNo := PostSOPrepaymentInvoice(SalesHeader);

Example

There are no examples available.
Member of Lib.Library - Cash Flow Helper


AddPOPrepayment@102 Method

The procedure AddPOPrepayment is available in codeunit 131332.

Syntax

AddPOPrepayment@102(
    VAR PurchaseHeader@1000 : Record 38 PurchaseHeader, //Reference parameter of type Record
    PrepaymentPercentage@1001 : Decimal PrepaymentPercentage //Input parameter of type Decimal
);

Parameters

PurchaseHeader
Reference parameter of type Record
PrepaymentPercentage
Input parameter of type Decimal

Remarks

The relevant search keywords are: Add, Purchase Order, Prepayment.

For a clarification about how this function works, refer to the code listed below.

      PurchaseHeader.VALIDATE("Prepayment %",PrepaymentPercentage);
      PurchaseHeader.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - Cash Flow Helper


AddSOPrepayment@101 Method

The procedure AddSOPrepayment is available in codeunit 131332.

Syntax

AddSOPrepayment@101(
    VAR SalesHeader@1000 : Record 36 SalesHeader, //Reference parameter of type Record
    PrepaymentPercentage@1001 : Decimal PrepaymentPercentage //Input parameter of type Decimal
);

Parameters

SalesHeader
Reference parameter of type Record
PrepaymentPercentage
Input parameter of type Decimal

Remarks

The relevant search keywords are: Add, Sales Order, Prepayment.

For a clarification about how this function works, refer to the code listed below.

      SalesHeader.VALIDATE("Prepayment %",PrepaymentPercentage);
      SalesHeader.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - Cash Flow Helper


ApplyInvoicePayment@36 Method

The procedure ApplyInvoicePayment is available in codeunit 131332.

Syntax

ApplyInvoicePayment@36(
    VAR GenJournalLine@1000 : Record 81 GenJournalLine, //Reference parameter of type Record
    PartnerNo@1001 : Code[20] PartnerNo, //Input parameter of type Code
    PartnerAccountType@1005 : Option PartnerAccountType, //Input parameter of type Option
    InvoiceNoToApply@1003 : Code[20] InvoiceNoToApply, //Input parameter of type Code
    AmountToApply@1002 : Decimal AmountToApply //Input parameter of type Decimal
);

Parameters

GenJournalLine
Reference parameter of type Record
PartnerNo
Input parameter of type Code
PartnerAccountType
Input parameter of type Option
InvoiceNoToApply
Input parameter of type Code
AmountToApply
Input parameter of type Decimal

Remarks

The relevant search keywords are: Apply, Invoice, Payment.

For a clarification about how this function works, refer to the code listed below.

      SelectAndClearGenJournalBatch(GenJournalBatch);
      LibraryERM.CreateGeneralJnlLine(
        GenJournalLine,GenJournalBatch."Journal Template Name",GenJournalBatch.Name,GenJournalLine."Document Type"::Payment,
        PartnerAccountType,PartnerNo,AmountToApply);
      // GenJournalLine.VALIDATE("Posting Date",PaymentDate);
      // GenJournalLine.VALIDATE("Document Date",PaymentDate);
      GenJournalLine.VALIDATE("Applies-to Doc. Type",GenJournalLine."Applies-to Doc. Type"::Invoice);
      GenJournalLine.VALIDATE("Applies-to Doc. No.",InvoiceNoToApply);
      GenJournalLine.MODIFY(TRUE);
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

Example

There are no examples available.
Member of Lib.Library - Cash Flow Helper


AssignCFPaymentTermToCustomer@73 Method

The procedure AssignCFPaymentTermToCustomer is available in codeunit 131332.

Syntax

AssignCFPaymentTermToCustomer@73(
    VAR Customer@1000 : Record 18 Customer, //Reference parameter of type Record
    PaymentTermsCode@1001 : Code[10] PaymentTermsCode //Input parameter of type Code
);

Parameters

Customer
Reference parameter of type Record
PaymentTermsCode
Input parameter of type Code

Remarks

The relevant search keywords are: Assign, Cash Flow, Payment, Term, To, Customer.

For a clarification about how this function works, refer to the code listed below.

      // An empty payment terms code creates a default payment term code
      Customer.VALIDATE("Cash Flow Payment Terms Code",GetPaymentTermsCode(PaymentTermsCode));
      Customer.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // Setup
      Initialize;
      CFHelper.CreateSpecificCashFlowCard(CashFlowForecast,ConsiderDiscount,ConsiderCFPmtTerms);
      LibraryERM.GetDiscountPaymentTerm(PaymentTerms);
      LibrarySales.CreateCustomer(Customer);
      CFHelper.AssignPaymentTermToCustomer(Customer,PaymentTerms.Code);
      IF ConsiderCFPmtTerms THEN
        CFHelper.AssignCFPaymentTermToCustomer(Customer,PaymentTerms.Code);
      Amount := LibraryRandom.RandDec(100,2);
      CFHelper.CreateLedgerEntry(
        GenJournalLine,Customer."No.",Amount,GenJournalLine."Account Type"::Customer,GenJournalLine."Document Type"::Invoice);

      // Exercise
      ExpectedDate := UpdateCustLedgerEntry(GenJournalLine."Document No.",GenJournalLine."Document Type",DateField);
      ConsiderSource[SourceType::Receivables] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      // The expected behavior is that the CF Journal line must reflect the modified date if CF pmt terms are not considered,
      // otherwise the CF pmt terms should be reflected
      IF ConsiderCFPmtTerms THEN BEGIN
        RecRef.GETTABLE(PaymentTerms);
        FieldRef := RecRef.FIELD(CFPmtTermsDateCalculationFieldNo);
        EVALUATE(CFPmtTermsDateFormula,FORMAT(FieldRef.VALUE));
        ExpectedDate := CALCDATE(FORMAT(FieldRef.VALUE),GenJournalLine."Posting Date");
      END;

      CFHelper.FilterSingleJournalLine(CFWorksheetLine,GenJournalLine."Document No.",SourceType::Receivables,CashFlowForecast."No.");
      CFHelper.VerifyCFDateOnCFJnlLine(CFWorksheetLine,ExpectedDate);
Member of Lib.Library - Cash Flow Helper


AssignCFPaymentTermToVendor@100 Method

The procedure AssignCFPaymentTermToVendor is available in codeunit 131332.

Syntax

AssignCFPaymentTermToVendor@100(
    VAR Vendor@1000 : Record 23 Vendor, //Reference parameter of type Record
    PaymentTermsCode@1001 : Code[10] PaymentTermsCode //Input parameter of type Code
);

Parameters

Vendor
Reference parameter of type Record
PaymentTermsCode
Input parameter of type Code

Remarks

The relevant search keywords are: Assign, Cash Flow, Payment, Term, To, Vendor.

For a clarification about how this function works, refer to the code listed below.

      // An empty payment terms code creates a default payment term code
      Vendor.VALIDATE("Cash Flow Payment Terms Code",GetPaymentTermsCode(PaymentTermsCode));
      Vendor.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // Setup
      Initialize;
      CFHelper.CreateSpecificCashFlowCard(CashFlowForecast,ConsiderDiscount,ConsiderCFPmtTerms);
      LibraryERM.GetDiscountPaymentTerm(PaymentTerms);
      LibraryPurchase.CreateVendor(Vendor);
      CFHelper.AssignPaymentTermToVendor(Vendor,PaymentTerms.Code);
      IF ConsiderCFPmtTerms THEN
        CFHelper.AssignCFPaymentTermToVendor(Vendor,PaymentTerms.Code);
      Amount := -LibraryRandom.RandDec(100,2);
      CFHelper.CreateLedgerEntry(
        GenJournalLine,Vendor."No.",Amount,GenJournalLine."Account Type"::Vendor,GenJournalLine."Document Type"::Invoice);

      // Exercise
      ExpectedDate := UpdateVendLedgerEntry(GenJournalLine."Document No.",GenJournalLine."Document Type",DateField);
      ConsiderSource[SourceType::Payables] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      // The expected behavior is that the CF Journal line must reflect the modified date if CF pmt terms are not considered,
      // otherwise the CF pmt terms should be reflected
      IF ConsiderCFPmtTerms THEN BEGIN
        RecRef.GETTABLE(PaymentTerms);
        FieldRef := RecRef.FIELD(CFPmtTermsDateCalculationFieldNo);
        EVALUATE(CFPmtTermsDateFormula,FORMAT(FieldRef.VALUE));
        ExpectedDate := CALCDATE(FORMAT(FieldRef.VALUE),GenJournalLine."Posting Date");
      END;

      CFHelper.FilterSingleJournalLine(CFWorksheetLine,GenJournalLine."Document No.",SourceType::Payables,CashFlowForecast."No.");
      CFHelper.VerifyCFDateOnCFJnlLine(CFWorksheetLine,ExpectedDate);
Member of Lib.Library - Cash Flow Helper


AssignPaymentTermToCustomer@4 Method

The procedure AssignPaymentTermToCustomer is available in codeunit 131332.

Syntax

AssignPaymentTermToCustomer@4(
    VAR Customer@1000 : Record 18 Customer, //Reference parameter of type Record
    PaymentTermsCode@1001 : Code[10] PaymentTermsCode //Input parameter of type Code
);

Parameters

Customer
Reference parameter of type Record
PaymentTermsCode
Input parameter of type Code

Remarks

The relevant search keywords are: Assign, Payment, Term, To, Customer.

For a clarification about how this function works, refer to the code listed below.

      // An empty payment terms code creates a default payment term code
      Customer.VALIDATE("Payment Terms Code",GetPaymentTermsCode(PaymentTermsCode));
      Customer.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // Setup
      Initialize;
      CFHelper.CreateSpecificCashFlowCard(CashFlowForecast,ConsiderDiscount,ConsiderCFPmtTerms);
      LibraryERM.GetDiscountPaymentTerm(PaymentTerms);
      LibrarySales.CreateCustomer(Customer);
      CFHelper.AssignPaymentTermToCustomer(Customer,PaymentTerms.Code);
      IF ConsiderCFPmtTerms THEN
        CFHelper.AssignCFPaymentTermToCustomer(Customer,PaymentTerms.Code);
      Amount := LibraryRandom.RandDec(100,2);
      CFHelper.CreateLedgerEntry(
        GenJournalLine,Customer."No.",Amount,GenJournalLine."Account Type"::Customer,GenJournalLine."Document Type"::Invoice);

      // Exercise
      ExpectedDate := UpdateCustLedgerEntry(GenJournalLine."Document No.",GenJournalLine."Document Type",DateField);
      ConsiderSource[SourceType::Receivables] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      // The expected behavior is that the CF Journal line must reflect the modified date if CF pmt terms are not considered,
      // otherwise the CF pmt terms should be reflected
      IF ConsiderCFPmtTerms THEN BEGIN
        RecRef.GETTABLE(PaymentTerms);
        FieldRef := RecRef.FIELD(CFPmtTermsDateCalculationFieldNo);
        EVALUATE(CFPmtTermsDateFormula,FORMAT(FieldRef.VALUE));
        ExpectedDate := CALCDATE(FORMAT(FieldRef.VALUE),GenJournalLine."Posting Date");
      END;

      CFHelper.FilterSingleJournalLine(CFWorksheetLine,GenJournalLine."Document No.",SourceType::Receivables,CashFlowForecast."No.");
      CFHelper.VerifyCFDateOnCFJnlLine(CFWorksheetLine,ExpectedDate);
Member of Lib.Library - Cash Flow Helper


AssignPaymentTermToVendor@5 Method

The procedure AssignPaymentTermToVendor is available in codeunit 131332.

Syntax

AssignPaymentTermToVendor@5(
    VAR Vendor@1000 : Record 23 Vendor, //Reference parameter of type Record
    PaymentTermsCode@1001 : Code[10] PaymentTermsCode //Input parameter of type Code
);

Parameters

Vendor
Reference parameter of type Record
PaymentTermsCode
Input parameter of type Code

Remarks

The relevant search keywords are: Assign, Payment, Term, To, Vendor.

For a clarification about how this function works, refer to the code listed below.

      // An empty payment terms code creates a default payment term code
      Vendor.VALIDATE("Payment Terms Code",GetPaymentTermsCode(PaymentTermsCode));
      Vendor.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // Setup
      Initialize;
      CFHelper.CreateSpecificCashFlowCard(CashFlowForecast,ConsiderDiscount,ConsiderCFPmtTerms);
      LibraryERM.GetDiscountPaymentTerm(PaymentTerms);
      LibraryPurchase.CreateVendor(Vendor);
      CFHelper.AssignPaymentTermToVendor(Vendor,PaymentTerms.Code);
      IF ConsiderCFPmtTerms THEN
        CFHelper.AssignCFPaymentTermToVendor(Vendor,PaymentTerms.Code);
      Amount := -LibraryRandom.RandDec(100,2);
      CFHelper.CreateLedgerEntry(
        GenJournalLine,Vendor."No.",Amount,GenJournalLine."Account Type"::Vendor,GenJournalLine."Document Type"::Invoice);

      // Exercise
      ExpectedDate := UpdateVendLedgerEntry(GenJournalLine."Document No.",GenJournalLine."Document Type",DateField);
      ConsiderSource[SourceType::Payables] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      // The expected behavior is that the CF Journal line must reflect the modified date if CF pmt terms are not considered,
      // otherwise the CF pmt terms should be reflected
      IF ConsiderCFPmtTerms THEN BEGIN
        RecRef.GETTABLE(PaymentTerms);
        FieldRef := RecRef.FIELD(CFPmtTermsDateCalculationFieldNo);
        EVALUATE(CFPmtTermsDateFormula,FORMAT(FieldRef.VALUE));
        ExpectedDate := CALCDATE(FORMAT(FieldRef.VALUE),GenJournalLine."Posting Date");
      END;

      CFHelper.FilterSingleJournalLine(CFWorksheetLine,GenJournalLine."Document No.",SourceType::Payables,CashFlowForecast."No.");
      CFHelper.VerifyCFDateOnCFJnlLine(CFWorksheetLine,ExpectedDate);
Member of Lib.Library - Cash Flow Helper


CalcCustDiscAmt@85 Method

The procedure CalcCustDiscAmt is available in codeunit 131332.

Syntax

CalcCustDiscAmt@85(
    CustLedgEntry@1001 : Record 21 CustLedgEntry, //Input parameter of type Record
    DiscountPercentage@1000 : Decimal DiscountPercentage //Input parameter of type Decimal
);

Parameters

CustLedgEntry
Input parameter of type Record
DiscountPercentage
Input parameter of type Decimal

Return Value

Decimal

Remarks

The relevant search keywords are: Calc, Customer, Discount, Amt.

For a clarification about how this function works, refer to the code listed below.

      EXIT(
        ROUND(CustLedgEntry.Amount * DiscountPercentage / 100,LibraryERM.GetAmountRoundingPrecision));

Example

The below example is extracted from the test automation codeunit 134553 to show one way of using this function.

      // Setup
      Initialize;
      LibraryERM.CreatePaymentTermsDiscount(PaymentTerms,TRUE);
      CustomerNo := CreateCustomerWithPaymentTerms(PaymentTerms.Code);
      CFHelper.GetDifferentDsctPaymentTerms(PaymentTermsDifferent,PaymentTerms.Code);
      SalesInvoiceNo := CreateAndPostSalesOrderWithDiscountPercentage(CustomerNo,PaymentTermsDifferent.Code);
      CFHelper.CreateCashFlowForecastConsiderDiscountAndCFPmtTerms(CashFlowForecast);
      LibraryERM.FindCustomerLedgerEntry(CustLedgerEntry,CustLedgerEntry."Document Type"::Invoice,SalesInvoiceNo);
      CustLedgerEntry.CALCFIELDS(Amount);

      ExpectedAmount :=
        CustLedgerEntry.Amount - CFHelper.CalcCustDiscAmt(CustLedgerEntry,PaymentTermsDifferent."Discount %");

      // Exercise
      ConsiderSource[SourceType::Receivables] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      VerifyCFWorksheetLineAmount(CashFlowForecast."No.",SalesInvoiceNo,SourceType::Receivables,ExpectedAmount,
        'Forecast amount calculation is not using values from customer ledger entries');
Member of Lib.Library - Cash Flow Helper


CalcCustDiscAmtLCY@82 Method

The procedure CalcCustDiscAmtLCY is available in codeunit 131332.

Syntax

CalcCustDiscAmtLCY@82(
    CustLedgEntry@1002 : Record 21 CustLedgEntry, //Input parameter of type Record
    DiscountPercentage@1001 : Decimal DiscountPercentage, //Input parameter of type Decimal
    ExchRateAmount@1000 : Decimal ExchRateAmount //Input parameter of type Decimal
);

Parameters

CustLedgEntry
Input parameter of type Record
DiscountPercentage
Input parameter of type Decimal
ExchRateAmount
Input parameter of type Decimal

Return Value

Decimal

Remarks

The relevant search keywords are: Calc, Customer, Discount, Amt, LCY.

For a clarification about how this function works, refer to the code listed below.

      EXIT(
        ROUND(CalcCustDiscAmt(CustLedgEntry,DiscountPercentage) * ExchRateAmount,LibraryERM.GetAmountRoundingPrecision));

Example

The below example is extracted from the test automation codeunit 134553 to show one way of using this function.

      LibraryERM.CreatePaymentTermsDiscount(PaymentTerms,TRUE);
      RelationalExchangeRateAmount := 0.4379; // hard coded exchange rate for bug fix purpose #329266
      CustomerNo := CreateCustomerWithPaymentTerms(PaymentTerms.Code);
      ModifyCustomerWithCurrency(CustomerNo,CreateCurrencyWithExchangeRate(RelationalExchangeRateAmount));
      SalesInvoiceNo := CreateAndPostSalesOrderWithOneLine(SalesHeader,CustomerNo);
      LibraryERM.FindCustomerLedgerEntry(CustLedgerEntry,CustLedgerEntry."Document Type"::Invoice,SalesInvoiceNo);
      CustLedgerEntry.CALCFIELDS(Amount);

      AmountFCY := CustLedgerEntry.Amount;
      ExpectedAmount :=
        ROUND(AmountFCY * RelationalExchangeRateAmount,LibraryERM.GetAmountRoundingPrecision) -
        CFHelper.CalcCustDiscAmtLCY(CustLedgerEntry,PaymentTerms."Discount %",RelationalExchangeRateAmount);

      // Exercise
      ConsiderSource[SourceType::Receivables] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      CFWorksheetLine.SETRANGE("Document No.",SalesInvoiceNo);
      CFWorksheetLine.FINDFIRST;
      Assert.AreEqual(ExpectedAmount,CFWorksheetLine."Amount (LCY)",'Unexpected forecast amount when converting from FCY to LCY');
Member of Lib.Library - Cash Flow Helper


CalcDiscAmtFromGenJnlLine@81 Method

The procedure CalcDiscAmtFromGenJnlLine is available in codeunit 131332.

Syntax

CalcDiscAmtFromGenJnlLine@81(
    GenJnlLine@1000 : Record 81 GenJnlLine, //Input parameter of type Record
    DiscountPercentage@1001 : Decimal DiscountPercentage //Input parameter of type Decimal
);

Parameters

GenJnlLine
Input parameter of type Record
DiscountPercentage
Input parameter of type Decimal

Return Value

Decimal

Remarks

The relevant search keywords are: Calc, Discount, Amt, From, General, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      IF GenJnlLine."Account Type" = GenJnlLine."Account Type"::Vendor THEN
        GenJnlLine.Amount := -GenJnlLine.Amount;
      EXIT(CalculateDiscountAmount(GenJnlLine.Amount,DiscountPercentage));

Example

The below example is extracted from the test automation codeunit 134553 to show one way of using this function.

      // Test filling a CF journal using Fill batch considering discount, CF pmt terms and payment discount tolerance date
      // Covers an opened customer ledger entry w/o payment where the CF forecast is done within the tolerance period
      // The expected CF amount must be the discounted total amount,
      // the CF date must be the calculated discount date + tolerance, based on the ledger entries document date

      // Setup
      Initialize;
      GeneralLedgerSetup.GET; // keep current setup
      CFHelper.CreateRandomDateFormula(CustomDateFormula); // used as pmt discount grace period
      CFHelper.SetupPmtDsctTolCustLETest(CashFlowForecast,Customer,PaymentTerms,CustomDateFormula,Amount,DiscountedAmount);
      CFHelper.CreateLedgerEntry(GenJournalLine,Customer."No.",Amount,
        GenJournalLine."Account Type"::Customer,GenJournalLine."Document Type"::Invoice);

      // Exercise
      ConsiderSource[SourceType::Receivables] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      CFHelper.VerifyCFDataOnSnglJnlLine(CFWorksheetLine,GenJournalLine."Document No.",SourceType::Receivables,CashFlowForecast."No.",
        Amount - CFHelper.CalcDiscAmtFromGenJnlLine(GenJournalLine,PaymentTerms."Discount %"),
        CALCDATE(CustomDateFormula,
          CALCDATE(PaymentTerms."Discount Date Calculation",GenJournalLine."Document Date")));

      // Tear down
      CFHelper.SetupPmtDsctGracePeriod(GeneralLedgerSetup."Payment Discount Grace Period");
Member of Lib.Library - Cash Flow Helper


CalcPurchExpectedPrepmtAmounts@89 Method

The procedure CalcPurchExpectedPrepmtAmounts is available in codeunit 131332.

Syntax

CalcPurchExpectedPrepmtAmounts@89(
    PurchaseHeader@1000 : Record 38 PurchaseHeader, //Input parameter of type Record
    DiscountPercentage@1001 : Decimal DiscountPercentage, //Input parameter of type Decimal
    VAR ExpectedOrderAmount@1003 : Decimal ExpectedOrderAmount, //Reference parameter of type Decimal
    VAR ExpectedPrePmtAmount@1002 : Decimal ExpectedPrePmtAmount //Reference parameter of type Decimal
);

Parameters

PurchaseHeader
Input parameter of type Record
DiscountPercentage
Input parameter of type Decimal
ExpectedOrderAmount
Reference parameter of type Decimal
ExpectedPrePmtAmount
Reference parameter of type Decimal

Remarks

The relevant search keywords are: Calc, Purchase, Expected, Prepmt, Amounts.

For a clarification about how this function works, refer to the code listed below.

      TotalOrderAmount := GetTotalPurchaseAmount(PurchaseHeader,FALSE);
      ExpectedPrePmtAmount := ROUND(TotalOrderAmount / 100 * PurchaseHeader."Prepayment %");
      ExpectedOrderAmount := TotalOrderAmount - ExpectedPrePmtAmount;
      IF DiscountPercentage > 0 THEN BEGIN
        ExpectedOrderAmount -= CalculateDiscountAmount(ExpectedOrderAmount,DiscountPercentage);
        ExpectedPrePmtAmount -= CalculateDiscountAmount(ExpectedPrePmtAmount,DiscountPercentage);
      END;

Example

There are no examples available.
Member of Lib.Library - Cash Flow Helper


CalcSalesExpectedPrepmtAmounts@88 Method

The procedure CalcSalesExpectedPrepmtAmounts is available in codeunit 131332.

Syntax

CalcSalesExpectedPrepmtAmounts@88(
    SalesHeader@1000 : Record 36 SalesHeader, //Input parameter of type Record
    DiscountPercentage@1001 : Decimal DiscountPercentage, //Input parameter of type Decimal
    VAR ExpectedOrderAmount@1003 : Decimal ExpectedOrderAmount, //Reference parameter of type Decimal
    VAR ExpectedPrePmtAmount@1002 : Decimal ExpectedPrePmtAmount //Reference parameter of type Decimal
);

Parameters

SalesHeader
Input parameter of type Record
DiscountPercentage
Input parameter of type Decimal
ExpectedOrderAmount
Reference parameter of type Decimal
ExpectedPrePmtAmount
Reference parameter of type Decimal

Remarks

The relevant search keywords are: Calc, Sales, Expected, Prepmt, Amounts.

For a clarification about how this function works, refer to the code listed below.

      TotalOrderAmount := GetTotalSalesAmount(SalesHeader,FALSE);
      ExpectedPrePmtAmount := ROUND(TotalOrderAmount / 100 * SalesHeader."Prepayment %");
      ExpectedOrderAmount := TotalOrderAmount - ExpectedPrePmtAmount;
      IF DiscountPercentage > 0 THEN BEGIN
        ExpectedOrderAmount -= CalculateDiscountAmount(ExpectedOrderAmount,DiscountPercentage);
        ExpectedPrePmtAmount -= CalculateDiscountAmount(ExpectedPrePmtAmount,DiscountPercentage);
      END;

Example

There are no examples available.
Member of Lib.Library - Cash Flow Helper


CalculateDiscountAmount@28 Method

The procedure CalculateDiscountAmount is available in codeunit 131332.

Syntax

CalculateDiscountAmount@28(
    Amount@1000 : Decimal Amount, //Input parameter of type Decimal
    DiscountPercentage@1001 : Decimal DiscountPercentage //Input parameter of type Decimal
);

Parameters

Amount
Input parameter of type Decimal
DiscountPercentage
Input parameter of type Decimal

Return Value

Decimal

Remarks

The relevant search keywords are: Calculate, Discount, Amount.

For a clarification about how this function works, refer to the code listed below.

      EXIT(ROUND(Amount / 100 * DiscountPercentage,LibraryERM.GetAmountRoundingPrecision));

Example

There are no examples available.
Member of Lib.Library - Cash Flow Helper


CalcVendDiscAmt@87 Method

The procedure CalcVendDiscAmt is available in codeunit 131332.

Syntax

CalcVendDiscAmt@87(
    VendLedgEntry@1001 : Record 25 VendLedgEntry, //Input parameter of type Record
    DiscountPercentage@1000 : Decimal DiscountPercentage //Input parameter of type Decimal
);

Parameters

VendLedgEntry
Input parameter of type Record
DiscountPercentage
Input parameter of type Decimal

Return Value

Decimal

Remarks

The relevant search keywords are: Calc, Vendor, Discount, Amt.

For a clarification about how this function works, refer to the code listed below.

      EXIT(
        ROUND(VendLedgEntry.Amount * DiscountPercentage / 100,LibraryERM.GetAmountRoundingPrecision));

Example

The below example is extracted from the test automation codeunit 134553 to show one way of using this function.

      // Setup
      Initialize;
      LibraryERM.CreatePaymentTermsDiscount(PaymentTerms,TRUE);
      VendorNo := CreateVendorWithPaymentTerms(PaymentTerms.Code);
      CFHelper.GetDifferentDsctPaymentTerms(PaymentTermsDifferent,PaymentTerms.Code);
      PurchaseInvoiceNo := CreateAndPostPurchaseOrderWithDiscountPercentage(VendorNo,PaymentTermsDifferent.Code);
      CFHelper.CreateCashFlowForecastConsiderDiscountAndCFPmtTerms(CashFlowForecast);
      LibraryERM.FindVendorLedgerEntry(VendorLedgerEntry,VendorLedgerEntry."Document Type"::Invoice,PurchaseInvoiceNo);
      VendorLedgerEntry.CALCFIELDS(Amount);

      ExpectedAmount :=
        VendorLedgerEntry.Amount - CFHelper.CalcVendDiscAmt(VendorLedgerEntry,PaymentTermsDifferent."Discount %");

      // Exercise
      ConsiderSource[SourceType::Payables] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      VerifyCFWorksheetLineAmount(CashFlowForecast."No.",PurchaseInvoiceNo,SourceType::Payables,ExpectedAmount,
        'Forecast amount calculation is not using values from vendor ledger entries');
Member of Lib.Library - Cash Flow Helper


CalcVendDiscAmtLCY@83 Method

The procedure CalcVendDiscAmtLCY is available in codeunit 131332.

Syntax

CalcVendDiscAmtLCY@83(
    VendLedgEntry@1002 : Record 25 VendLedgEntry, //Input parameter of type Record
    DiscountPercentage@1001 : Decimal DiscountPercentage, //Input parameter of type Decimal
    ExchRateAmount@1000 : Decimal ExchRateAmount //Input parameter of type Decimal
);

Parameters

VendLedgEntry
Input parameter of type Record
DiscountPercentage
Input parameter of type Decimal
ExchRateAmount
Input parameter of type Decimal

Return Value

Decimal

Remarks

The relevant search keywords are: Calc, Vendor, Discount, Amt, LCY.

For a clarification about how this function works, refer to the code listed below.

      EXIT(
        ROUND(CalcVendDiscAmt(VendLedgEntry,DiscountPercentage) * ExchRateAmount,LibraryERM.GetAmountRoundingPrecision));

Example

The below example is extracted from the test automation codeunit 134553 to show one way of using this function.

      LibraryERM.CreatePaymentTermsDiscount(PaymentTerms,TRUE);
      RelationalExchangeRateAmount := 0.4379; // hard coded exchange rate for bug fix purpose #329266
      VendorNo := CreateVendorWithPaymentTerms(PaymentTerms.Code);
      ModifyVendorWithCurrency(VendorNo,CreateCurrencyWithExchangeRate(RelationalExchangeRateAmount));
      PurchaseInvoiceNo := CreateAndPostPurchaseOrderWithOneLine(PurchaseHeader,VendorNo);
      LibraryERM.FindVendorLedgerEntry(VendorLedgerEntry,VendorLedgerEntry."Document Type"::Invoice,PurchaseInvoiceNo);
      VendorLedgerEntry.CALCFIELDS(Amount);

      AmountFCY := VendorLedgerEntry.Amount;
      ExpectedAmount :=
        ROUND(AmountFCY * RelationalExchangeRateAmount,LibraryERM.GetAmountRoundingPrecision) -
        CFHelper.CalcVendDiscAmtLCY(VendorLedgerEntry,PaymentTerms."Discount %",RelationalExchangeRateAmount);

      // Exercise
      ConsiderSource[SourceType::Payables] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      CFWorksheetLine.SETRANGE("Document No.",PurchaseInvoiceNo);
      CFWorksheetLine.FINDFIRST;
      Assert.AreEqual(ExpectedAmount,CFWorksheetLine."Amount (LCY)",'Unexpected forecast amount when converting from FCY to LCY');
Member of Lib.Library - Cash Flow Helper


ChangeWorkdate@12 Method

The procedure ChangeWorkdate is available in codeunit 131332.

Syntax

ChangeWorkdate@12(
    NewWorkDate@1000 : Date NewWorkDate //Input parameter of type Date
);

Parameters

NewWorkDate
Input parameter of type Date

Return Value

Date

Remarks

The relevant search keywords are: Change, Workdate.

For a clarification about how this function works, refer to the code listed below.

      OldWorkDate := WORKDATE;
      WORKDATE := NewWorkDate;

Example

There are no examples available.
Member of Lib.Library - Cash Flow Helper


ChangeWorkdateByDateFormula@13 Method

The procedure ChangeWorkdateByDateFormula is available in codeunit 131332.

Syntax

ChangeWorkdateByDateFormula@13(
    BaseDateFormula@1000 : DateFormula BaseDateFormula, //Input parameter of type DateFormula
    CustomDateFormula@1001 : DateFormula CustomDateFormula, //Input parameter of type DateFormula
    AdditionalDateFormula@1002 : DateFormula AdditionalDateFormula //Input parameter of type DateFormula
);

Parameters

BaseDateFormula
Input parameter of type DateFormula
CustomDateFormula
Input parameter of type DateFormula
AdditionalDateFormula
Input parameter of type DateFormula

Return Value

Date

Remarks

The relevant search keywords are: Change, Workdate, By, Date, Formula.

For a clarification about how this function works, refer to the code listed below.

      OldWorkDate := ChangeWorkdate(GenerateDateFromFormulas(WORKDATE,BaseDateFormula,AdditionalDateFormula,CustomDateFormula));

Example

There are no examples available.
Member of Lib.Library - Cash Flow Helper


CreateAndApplySalesInvPayment@2 Method

The procedure CreateAndApplySalesInvPayment is available in codeunit 131332.

Syntax

CreateAndApplySalesInvPayment@2(
    VAR GenJournalLine@1000 : Record 81 GenJournalLine, //Reference parameter of type Record
    CustomerNo@1004 : Code[20] CustomerNo, //Input parameter of type Code
    SalesInvoiceAmount@1001 : Decimal SalesInvoiceAmount, //Input parameter of type Decimal
    AmountToApply@1002 : Decimal AmountToApply, //Input parameter of type Decimal
    DateFormula1@1003 : DateFormula DateFormula1, //Input parameter of type DateFormula
    DateFormula2@1006 : DateFormula DateFormula2, //Input parameter of type DateFormula
    DateFormula3@1007 : DateFormula DateFormula3 //Input parameter of type DateFormula
);

Parameters

GenJournalLine
Reference parameter of type Record
CustomerNo
Input parameter of type Code
SalesInvoiceAmount
Input parameter of type Decimal
AmountToApply
Input parameter of type Decimal
DateFormula1
Input parameter of type DateFormula
DateFormula2
Input parameter of type DateFormula
DateFormula3
Input parameter of type DateFormula

Remarks

The relevant search keywords are: Create, Apply, Sales, Invoice, Payment.

For a clarification about how this function works, refer to the code listed below.

      PaymentDate := GenerateDateFromFormulas(WORKDATE,DateFormula1,DateFormula2,DateFormula3);
      SelectAndClearGenJournalBatch(GenJournalBatch);
      LibraryERM.CreateGeneralJnlLine(
        GenJournalLine,GenJournalBatch."Journal Template Name",GenJournalBatch.Name,GenJournalLine."Document Type"::Invoice,
        GenJournalLine."Account Type"::Customer,CustomerNo,SalesInvoiceAmount);
      LibraryERM.CreateGeneralJnlLine(
        GenJournalLine,GenJournalBatch."Journal Template Name",GenJournalBatch.Name,GenJournalLine."Document Type"::Payment,
        GenJournalLine."Account Type"::Customer,CustomerNo,AmountToApply);
      GenJournalLine.VALIDATE("Posting Date",PaymentDate);
      GenJournalLine.VALIDATE("Document Date",PaymentDate);
      GenJournalLine.VALIDATE("Applies-to Doc. Type",GenJournalLine."Applies-to Doc. Type"::Invoice);
      GenJournalLine.VALIDATE("Applies-to Doc. No.",GenJournalLine."Document No.");
      GenJournalLine.MODIFY(TRUE);
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

Example

The below example is extracted from the test automation codeunit 134553 to show one way of using this function.

      // Test filling a CF journal by using Fill batch with single customer ledger entry
      // where only partial payment is applied
      // Verify computed cash flow date and discounted amount

      // Setup
      Initialize;
      CFHelper.CreateCashFlowForecastDefault(CashFlowForecast);
      LibrarySales.CreateCustomer(Customer);
      TotalAmount := LibraryRandom.RandInt(500);
      CFHelper.CreateAndApplySalesInvPayment(GenJournalLine,Customer."No.",TotalAmount,-(TotalAmount / 2),
        EmptyDateFormula,EmptyDateFormula,EmptyDateFormula);

      // Exercise
      ConsiderSource[SourceType::Receivables] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      CFHelper.FilterSingleJournalLine(CFWorksheetLine,GenJournalLine."Document No.",SourceType::Receivables,CashFlowForecast."No.");
      CFHelper.VerifyExpectedCFAmount(TotalAmount - (TotalAmount / 2),CFWorksheetLine."Amount (LCY)");
Member of Lib.Library - Cash Flow Helper


CreateAndApplyVendorInvPmt@6 Method

The procedure CreateAndApplyVendorInvPmt is available in codeunit 131332.

Syntax

CreateAndApplyVendorInvPmt@6(
    VAR GenJournalLine@1007 : Record 81 GenJournalLine, //Reference parameter of type Record
    VendorNo@1006 : Code[20] VendorNo, //Input parameter of type Code
    InvoiceAmount@1004 : Decimal InvoiceAmount, //Input parameter of type Decimal
    AmountToApply@1003 : Decimal AmountToApply, //Input parameter of type Decimal
    DateFormula1@1002 : DateFormula DateFormula1, //Input parameter of type DateFormula
    DateFormula2@1001 : DateFormula DateFormula2, //Input parameter of type DateFormula
    DateFormula3@1000 : DateFormula DateFormula3 //Input parameter of type DateFormula
);

Parameters

GenJournalLine
Reference parameter of type Record
VendorNo
Input parameter of type Code
InvoiceAmount
Input parameter of type Decimal
AmountToApply
Input parameter of type Decimal
DateFormula1
Input parameter of type DateFormula
DateFormula2
Input parameter of type DateFormula
DateFormula3
Input parameter of type DateFormula

Remarks

The relevant search keywords are: Create, Apply, Vendor, Invoice, Payment.

For a clarification about how this function works, refer to the code listed below.

      PaymentDate := GenerateDateFromFormulas(WORKDATE,DateFormula1,DateFormula2,DateFormula3);
      SelectAndClearGenJournalBatch(GenJournalBatch);
      LibraryERM.CreateGeneralJnlLine(
        GenJournalLine,GenJournalBatch."Journal Template Name",GenJournalBatch.Name,GenJournalLine."Document Type"::Invoice,
        GenJournalLine."Account Type"::Vendor,VendorNo,InvoiceAmount);
      LibraryERM.CreateGeneralJnlLine(
        GenJournalLine,GenJournalBatch."Journal Template Name",GenJournalBatch.Name,GenJournalLine."Document Type"::Payment,
        GenJournalLine."Account Type"::Vendor,VendorNo,AmountToApply);
      GenJournalLine.VALIDATE("Posting Date",PaymentDate);
      GenJournalLine.VALIDATE("Document Date",PaymentDate);
      GenJournalLine.VALIDATE("Applies-to Doc. Type",GenJournalLine."Applies-to Doc. Type"::Invoice);
      GenJournalLine.VALIDATE("Applies-to Doc. No.",GenJournalLine."Document No.");
      GenJournalLine.MODIFY(TRUE);
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

Example

The below example is extracted from the test automation codeunit 134553 to show one way of using this function.

      // Test filling a CF journal using Fill batch considering discount, CF pmt terms and payment discount tolerance date
      // Covers a total discounted sales invoice payment within payment discount tolerance date.
      // The payment has to close the open invoice, therefore no CF journal lines are expected

      // Setup
      Initialize;
      GeneralLedgerSetup.GET; // keep current setup
      CFHelper.CreateRandomDateFormula(PmtDiscountGracePeriod);
      CFHelper.SetupPmtDsctTolVendorLETest(CashFlowForecast,Vendor,PaymentTerms,PmtDiscountGracePeriod,Amount,DiscountedAmount);
      // make sure Vendor has discounted default payment terms as well, in order to close open entry
      Vendor.VALIDATE("Payment Terms Code",PaymentTerms.Code);
      Vendor.MODIFY(TRUE);
      // Payment should be done before pmt dsct tol date
      CFHelper.CreateAndApplyVendorInvPmt(GenJournalLine,Vendor."No.",-Amount,DiscountedAmount,
        PaymentTerms."Discount Date Calculation",PmtDiscountGracePeriod,MinusOneDayFormula);

      // Exercise
      // Forecast should be done after payment
      ConsiderSource[SourceType::Payables] := TRUE;
      CFHelper.FillJnlOnCertDateFormulas(ConsiderSource,CashFlowForecast."No.",PaymentTerms."Discount Date Calculation",
        PmtDiscountGracePeriod,EmptyDateFormula);

      // Verify
      // No CF lines expected
      Assert.AreEqual(0,
        CFHelper.FilterSingleJournalLine(CFWorksheetLine,GenJournalLine."Document No.",SourceType::Payables,CashFlowForecast."No."),
        STRSUBSTNO(UnexpectedCFWorksheetLineCountErr,CashFlowForecast."No.",GenJournalLine."Document No."));

      // Tear down
      CFHelper.SetupPmtDsctGracePeriod(GeneralLedgerSetup."Payment Discount Grace Period");
Member of Lib.Library - Cash Flow Helper


CreateBudgetEntry@49 Method

The procedure CreateBudgetEntry is available in codeunit 131332.

Syntax

CreateBudgetEntry@49(
    VAR GLBudgetEntry@1001 : Record 96 GLBudgetEntry, //Reference parameter of type Record
    BudgetDate@1003 : Date BudgetDate //Input parameter of type Date
);

Parameters

GLBudgetEntry
Reference parameter of type Record
BudgetDate
Input parameter of type Date

Remarks

The relevant search keywords are: Create, Budget, Entry.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.CreateGLBudgetName(GLBudgetName);
      FindCFBudgetAccount(CFAccount);
      FindFirstGLAccFromCFAcc(GLAccount,CFAccount);
      LibraryERM.CreateGLBudgetEntry(GLBudgetEntry,BudgetDate,GLAccount."No.",GLBudgetName.Name);
      GLBudgetEntry.VALIDATE(Amount,LibraryRandom.RandDec(100,2));
      GLBudgetEntry.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // Suggest lines should set source type accordingly

      // Setup
      Initialize;
      CFHelper.CreateCashFlowForecastDefault(CashFlowForecast);
      CashFlowForecast.VALIDATE("G/L Budget From",WORKDATE);
      CashFlowForecast.VALIDATE("G/L Budget To",WORKDATE);
      CashFlowForecast.MODIFY(TRUE);
      CFHelper.CreateBudgetEntry(GLBudgetEntry,CashFlowForecast."G/L Budget To");

      // Exercise
      LibraryCF.FillBudgetJournal(FALSE,CashFlowForecast."No.",GLBudgetEntry."Budget Name");

      // Verify
      CFHelper.FilterSingleJournalLine(CFWorksheetLine,FORMAT(GLBudgetEntry."Entry No."),
        CFWorksheetLine."Source Type"::"G/L Budget",CashFlowForecast."No.");
      CFWorksheetLine.TESTFIELD("Source Type",CFWorksheetLine."Source Type"::"G/L Budget");
      CFWorksheetLine.TESTFIELD("G/L Budget Name",GLBudgetEntry."Budget Name");
      CFHelper.VerifyExpectedCFAmount(-GLBudgetEntry.Amount,CFWorksheetLine."Amount (LCY)");
Member of Lib.Library - Cash Flow Helper


CreateCashFlowForecastConsiderCFPmtTerms@67 Method

The procedure CreateCashFlowForecastConsiderCFPmtTerms is available in codeunit 131332.

Syntax

CreateCashFlowForecastConsiderCFPmtTerms@67(
    VAR CashFlowForecast@1001 : Record 840 CashFlowForecast //Reference parameter of type Record
);

Parameters

CashFlowForecast
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Cash, Flow, Forecast, Consider, Cash Flow, Payment, Terms.

For a clarification about how this function works, refer to the code listed below.

      CreateSpecificCashFlowCard(CashFlowForecast,FALSE,TRUE);

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // Test filling a CF journal by using Fill batch with a 3-line sales order where customer has
      // CF payment terms set. Verify computed due and cash flow date and discounted amount

      // Setup
      Initialize;
      CFHelper.CreateCashFlowForecastConsiderCFPmtTerms(CashFlowForecast);
      LibraryERM.GetDiscountPaymentTerm(PaymentTerms);
      CFHelper.CreateSpecificSalesOrder(SalesHeader,'',PaymentTerms.Code);
      // set expected values considering only CF payment terms
      CFHelper.SetExpectedDsctAPmtTermValues(DocumentType::Sale,SalesHeader."No.",
        SalesHeader."Sell-to Customer No.",SalesHeader."Document Date",FALSE,
        ExpectedCFDate,ExpectedAmount);

      // Exercise
      ConsiderSource[SourceType::"Sales Orders"] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify - passing 0 as expected discount amount since discount is not considered on the CF card
      CFHelper.VerifyCFDataOnSnglJnlLine(CFWorksheetLine,SalesHeader."No.",SourceType::"Sales Orders",
        CashFlowForecast."No.",ExpectedAmount,ExpectedCFDate);
Member of Lib.Library - Cash Flow Helper


CreateCashFlowForecastConsiderDiscount@59 Method

The procedure CreateCashFlowForecastConsiderDiscount is available in codeunit 131332.

Syntax

CreateCashFlowForecastConsiderDiscount@59(
    VAR CashFlowForecast@1001 : Record 840 CashFlowForecast //Reference parameter of type Record
);

Parameters

CashFlowForecast
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Cash, Flow, Forecast, Consider, Discount.

For a clarification about how this function works, refer to the code listed below.

      CreateSpecificCashFlowCard(CashFlowForecast,TRUE,FALSE);

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // Test filling a CF journal by using Fill batch with a discounted 3-line sales order
      // Verify computed due and cash flow date, discounted amount and discount percentage

      // Setup
      Initialize;
      CFHelper.CreateCashFlowForecastConsiderDiscount(CashFlowForecast);
      LibraryERM.GetDiscountPaymentTerm(PaymentTerms);
      CFHelper.CreateSpecificSalesOrder(SalesHeader,PaymentTerms.Code,'');
      ExpectedAmount := CFHelper.GetTotalSalesAmount(SalesHeader,TRUE);

      // Exercise
      ConsiderSource[SourceType::"Sales Orders"] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      CFHelper.VerifyCFDataOnSnglJnlLine(CFWorksheetLine,SalesHeader."No.",SourceType::"Sales Orders",
        CashFlowForecast."No.",ExpectedAmount,CALCDATE(PaymentTerms."Discount Date Calculation",SalesHeader."Document Date"));
Member of Lib.Library - Cash Flow Helper


CreateCashFlowForecastConsiderDiscountAndCFPmtTerms@68 Method

The procedure CreateCashFlowForecastConsiderDiscountAndCFPmtTerms is available in codeunit 131332.

Syntax

CreateCashFlowForecastConsiderDiscountAndCFPmtTerms@68(
    VAR CashFlowForecast@1001 : Record 840 CashFlowForecast //Reference parameter of type Record
);

Parameters

CashFlowForecast
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Cash, Flow, Forecast, Consider, Discount, Cash Flow, Payment, Terms.

For a clarification about how this function works, refer to the code listed below.

      CreateSpecificCashFlowCard(CashFlowForecast,TRUE,TRUE);

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // Test filling a CF journal by using Fill batch with a discounted 3-line sales order
      // where customer has CF payment terms set. Verify computed due and cash flow date and discounted amount

      // Setup
      Initialize;
      CFHelper.CreateCashFlowForecastConsiderDiscountAndCFPmtTerms(CashFlowForecast);
      LibraryERM.GetDiscountPaymentTerm(PaymentTerms); // default pmt terms
      CFHelper.GetDifferentDsctPaymentTerms(PaymentTerms2,PaymentTerms.Code); // cf pmt terms
      CFHelper.CreateSpecificSalesOrder(SalesHeader,PaymentTerms.Code,PaymentTerms2.Code);
      // set expected vales considering CF payment terms and line discount
      CFHelper.SetExpectedDsctAPmtTermValues(DocumentType::Sale,SalesHeader."No.",
        SalesHeader."Sell-to Customer No.",SalesHeader."Document Date",TRUE,
        ExpectedCFDate,ExpectedAmount);

      // Exercise
      ConsiderSource[SourceType::"Sales Orders"] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      CFHelper.VerifyCFDataOnSnglJnlLine(CFWorksheetLine,SalesHeader."No.",SourceType::"Sales Orders",
        CashFlowForecast."No.",ExpectedAmount,ExpectedCFDate);
Member of Lib.Library - Cash Flow Helper


CreateCashFlowForecastDefault@99 Method

The procedure CreateCashFlowForecastDefault is available in codeunit 131332.

Syntax

CreateCashFlowForecastDefault@99(
    VAR CashFlowForecast@1001 : Record 840 CashFlowForecast //Reference parameter of type Record
);

Parameters

CashFlowForecast
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Cash, Flow, Forecast, Default.

For a clarification about how this function works, refer to the code listed below.

      CreateSpecificCashFlowCard(CashFlowForecast,FALSE,FALSE);

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // Test filling a CF journal using Fill batch with a manual revenue
      // and verify computed due and cash flow date

      // Setup
      Initialize;
      CFHelper.CreateCashFlowForecastDefault(CashFlowForecast);
      CFHelper.CreateManualRevenue(CFManualRevenue);

      // Exercise
      ConsiderSource[SourceType::"Cash Flow Manual Revenue"] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      CFHelper.VerifyCFDataOnSnglJnlLine(CFWorksheetLine,CFManualRevenue.Code,SourceType::"Cash Flow Manual Revenue",
        CashFlowForecast."No.",CFManualRevenue.Amount,CFManualRevenue."Starting Date");
Member of Lib.Library - Cash Flow Helper


CreateCustWithCFDsctPmtTerm@17 Method

The procedure CreateCustWithCFDsctPmtTerm is available in codeunit 131332.

Syntax

CreateCustWithCFDsctPmtTerm@17(
    VAR Customer@1000 : Record 18 Customer, //Reference parameter of type Record
    VAR PaymentTerms@1001 : Record 3 PaymentTerms //Reference parameter of type Record
);

Parameters

Customer
Reference parameter of type Record
PaymentTerms
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Customer, Cash Flow, Dsct, Payment, Term.

For a clarification about how this function works, refer to the code listed below.

      LibrarySales.CreateCustomer(Customer);
      LibraryERM.GetDiscountPaymentTerm(PaymentTerms);
      AssignCFPaymentTermToCustomer(Customer,PaymentTerms.Code);

Example

There are no examples available.
Member of Lib.Library - Cash Flow Helper


CreateDefaultPaymentTerms@29 Method

The procedure CreateDefaultPaymentTerms is available in codeunit 131332.

Syntax

CreateDefaultPaymentTerms@29(
    VAR PaymentTerms@1000 : Record 3 PaymentTerms //Reference parameter of type Record
);

Parameters

PaymentTerms
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Default, Payment, Terms.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.CreatePaymentTerms(PaymentTerms);
      EVALUATE(PaymentTerms."Due Date Calculation",'<0D>');
      EVALUATE(PaymentTerms."Discount Date Calculation",'<0D>');
      PaymentTerms.VALIDATE("Discount %",0);
      PaymentTerms.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134987 to show one way of using this function.

      LibraryCFHelper.CreateDefaultPaymentTerms(PaymentTerms);
      VendorNo := CreateVendorWithPaymentTerms(PaymentTerms.Code);

      InvoiceAmount := LibraryRandom.RandDecInDecimalRange(50,100,Precision) * 2;
      CrMemoAmount := LibraryRandom.RandDecInDecimalRange(10,50,Precision) * 2; // credit memo amount should be less then invoice's

      WITH GenJournalLine DO BEGIN
        CreateGenJournalLine(GenJournalLine,"Document Type"::Invoice,VendorNo,-InvoiceAmount,"Bank Payment Type"::" ");
        LibraryERM.PostGeneralJnlLine(GenJournalLine);

        CreateGenJournalLine(GenJournalLine,"Document Type"::"Credit Memo",VendorNo,CrMemoAmount,"Bank Payment Type"::" ");
        LibraryERM.PostGeneralJnlLine(GenJournalLine);
      END;

      BankAccount.GET(CreateBankAccount);
      CreatePaymentGeneralBatch(GenJournalBatch);
      SuggestVendorPayment(GenJournalLine,GenJournalBatch,VendorNo,BankAccount."No.",FALSE);
      BatchName := GenJournalLine."Journal Batch Name";
Member of Lib.Library - Cash Flow Helper


CreateDefaultPurchaseOrder@65 Method

The procedure CreateDefaultPurchaseOrder is available in codeunit 131332.

Syntax

CreateDefaultPurchaseOrder@65(
    VAR PurchaseHeader@1000 : Record 38 PurchaseHeader //Reference parameter of type Record
);

Parameters

PurchaseHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Default, Purchase, Order.

For a clarification about how this function works, refer to the code listed below.

      CreateSpecificPurchaseOrder(PurchaseHeader,'','');

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // Test filling a CF journal by using Fill batch with a 3-line purchase order
      // and verify computed due and cash flow date

      // Setup
      Initialize;
      CFHelper.CreateCashFlowForecastDefault(CashFlowForecast);
      CFHelper.CreateDefaultPurchaseOrder(PurchaseHeader);

      // Exercise
      ConsiderSource[SourceType::"Purchase Orders"] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      CFHelper.VerifyCFDataOnSnglJnlLine(CFWorksheetLine,PurchaseHeader."No.",SourceType::"Purchase Orders",
        CashFlowForecast."No.",-CFHelper.GetTotalPurchaseAmount(PurchaseHeader,FALSE),PurchaseHeader."Due Date");
Member of Lib.Library - Cash Flow Helper


CreateDefaultSalesOrder@62 Method

The procedure CreateDefaultSalesOrder is available in codeunit 131332.

Syntax

CreateDefaultSalesOrder@62(
    VAR SalesHeader@1000 : Record 36 SalesHeader //Reference parameter of type Record
);

Parameters

SalesHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Default, Sales, Order.

For a clarification about how this function works, refer to the code listed below.

      CreateSpecificSalesOrder(SalesHeader,'','');

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // Test filling a CF journal by using Fill batch with a 3-line sales order
      // and verify computed due and cash flow date

      // Setup
      Initialize;
      CFHelper.CreateCashFlowForecastDefault(CashFlowForecast);
      CFHelper.CreateDefaultSalesOrder(SalesHeader);

      // Exercise
      ConsiderSource[SourceType::"Sales Orders"] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      CFHelper.VerifyCFDataOnSnglJnlLine(CFWorksheetLine,SalesHeader."No.",SourceType::"Sales Orders",
        CashFlowForecast."No.",CFHelper.GetTotalSalesAmount(SalesHeader,FALSE),SalesHeader."Due Date");
Member of Lib.Library - Cash Flow Helper


CreateDefaultServiceOrder@66 Method

The procedure CreateDefaultServiceOrder is available in codeunit 131332.

Syntax

CreateDefaultServiceOrder@66(
    VAR ServiceHeader@1000 : Record 5900 ServiceHeader //Reference parameter of type Record
);

Parameters

ServiceHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Default, Service, Order.

For a clarification about how this function works, refer to the code listed below.

      CreateSpecificServiceOrder(ServiceHeader,'','');

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // Test filling a CF journal by using Fill batch with a 3-line service order
      // and verify computed due and cash flow date

      // Setup
      Initialize;
      CFHelper.CreateCashFlowForecastDefault(CashFlowForecast);
      CFHelper.CreateDefaultServiceOrder(ServiceHeader);

      // Exercise
      ConsiderSource[SourceType::"Service Orders"] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      CFHelper.VerifyCFDataOnSnglJnlLine(CFWorksheetLine,ServiceHeader."No.",SourceType::"Service Orders",
        CashFlowForecast."No.",CFHelper.GetTotalServiceAmount(ServiceHeader,FALSE),ServiceHeader."Document Date");
Member of Lib.Library - Cash Flow Helper


CreateFixedAssetForDisposal@3 Method

The procedure CreateFixedAssetForDisposal is available in codeunit 131332.

Syntax

CreateFixedAssetForDisposal@3(
    VAR FixedAsset@1000 : Record 5600 FixedAsset, //Reference parameter of type Record
    DepreciationBookCode@1007 : Code[10] DepreciationBookCode, //Input parameter of type Code
    DepreciationStartDateFormula@1001 : DateFormula DepreciationStartDateFormula, //Input parameter of type DateFormula
    DepreciationEndDateFormula@1002 : DateFormula DepreciationEndDateFormula, //Input parameter of type DateFormula
    DisposalDateFormula@1003 : DateFormula DisposalDateFormula, //Input parameter of type DateFormula
    ExpDisposalAmount@1006 : Decimal ExpDisposalAmount //Input parameter of type Decimal
);

Parameters

FixedAsset
Reference parameter of type Record
DepreciationBookCode
Input parameter of type Code
DepreciationStartDateFormula
Input parameter of type DateFormula
DepreciationEndDateFormula
Input parameter of type DateFormula
DisposalDateFormula
Input parameter of type DateFormula
ExpDisposalAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Fixed, Asset, For, Disposal.

For a clarification about how this function works, refer to the code listed below.

      LibraryFA.CreateFixedAsset(FixedAsset);
      LibraryFA.CreateFADepreciationBook(FADepreciationBook,FixedAsset."No.",DepreciationBookCode);
      FADepreciationBook."Depreciation Starting Date" := CALCDATE(DepreciationStartDateFormula,WORKDATE);
      FADepreciationBook."Depreciation Ending Date" := CALCDATE(DepreciationEndDateFormula,WORKDATE);
      FADepreciationBook."Projected Disposal Date" := CALCDATE(DisposalDateFormula,WORKDATE);
      FADepreciationBook."Projected Proceeds on Disposal" := ExpDisposalAmount;
      FADepreciationBook.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // Test filling a CF journal by using Fill batch with planned sale of fixed asset
      // Verify due and CF date match the planned disposal date

      // Setup
      CFHelper.CreateCashFlowForecastDefault(CashFlowForecast);
      EVALUATE(DeprecStartDateFormula,'<-2Y>');
      EVALUATE(DeprecEndDateFormula,'<1M-D5>');
      EVALUATE(ExpectedDisposalDateFormula,'<1M+1W-WD1>');
      ExpectedDisposalAmount := LibraryRandom.RandDec(2000,2);
      FASetup.GET;
      CFHelper.CreateFixedAssetForDisposal(FixedAsset,FASetup."Default Depr. Book",DeprecStartDateFormula,DeprecEndDateFormula,
        ExpectedDisposalDateFormula,ExpectedDisposalAmount);
      ExpectedDueAndCFDate := CALCDATE(ExpectedDisposalDateFormula,WORKDATE);

      // Exercise
      ConsiderSource[SourceType::"Fixed Assets Disposal"] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      CFHelper.VerifyCFDataOnSnglJnlLine(CFWorksheetLine,FixedAsset."No.",SourceType::"Fixed Assets Disposal",
        CashFlowForecast."No.",ExpectedDisposalAmount,ExpectedDueAndCFDate);
Member of Lib.Library - Cash Flow Helper


CreateFixedAssetForInvestment@1 Method

The procedure CreateFixedAssetForInvestment is available in codeunit 131332.

Syntax

CreateFixedAssetForInvestment@1(
    VAR FixedAsset@1000 : Record 5600 FixedAsset, //Reference parameter of type Record
    DepreciationBookCode@1010 : Code[10] DepreciationBookCode, //Input parameter of type Code
    FAPostingDateFormula@1006 : DateFormula FAPostingDateFormula, //Input parameter of type DateFormula
    InvestmentAmount@1007 : Decimal InvestmentAmount //Input parameter of type Decimal
);

Parameters

FixedAsset
Reference parameter of type Record
DepreciationBookCode
Input parameter of type Code
FAPostingDateFormula
Input parameter of type DateFormula
InvestmentAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Fixed, Asset, For, Investment.

For a clarification about how this function works, refer to the code listed below.

      LibraryFA.CreateFixedAsset(FixedAsset);
      FixedAsset.VALIDATE("Budgeted Asset",TRUE);
      FixedAsset.MODIFY(TRUE);
      LibraryFA.CreateFADepreciationBook(FADepreciationBook,FixedAsset."No.",DepreciationBookCode);
      FAJournalTemplate.SETRANGE(Recurring,FALSE);
      LibraryFA.FindFAJournalTemplate(FAJournalTemplate);
      LibraryFA.CreateFAJournalBatch(FAJournalBatch,FAJournalTemplate.Name);
      FAJournalBatch.VALIDATE("No. Series",LibraryUtility.GetGlobalNoSeriesCode);
      FAJournalBatch.MODIFY(TRUE);
      LibraryFA.CreateFAJournalLine(FAJournalLine,FAJournalTemplate.Name,FAJournalBatch.Name);
      FAJournalLine."Document Type" := FAJournalLine."Document Type"::Invoice;
      NoSeries.GET(FAJournalBatch."No. Series");
      FAJournalLine.VALIDATE("Document No.",NoSeriesManagement.GetNextNo(FAJournalBatch."No. Series",WORKDATE,FALSE));
      FAJournalLine.VALIDATE("FA No.",FixedAsset."No.");
      FAJournalLine.VALIDATE("Depreciation Book Code",FADepreciationBook."Depreciation Book Code");
      FAJournalLine.VALIDATE(Amount,InvestmentAmount);
      FAJournalLine.VALIDATE("FA Posting Date",CALCDATE(FAPostingDateFormula,WORKDATE));
      FAJournalLine.MODIFY(TRUE);
      LibraryFA.PostFAJournalLine(FAJournalLine);

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // Test filling a CF journal by using Fill batch with budgeted fixed asset acquisition costs (planned FA investment)
      // Verify due and CF date match the posting date of the FA acquisition journal

      // Setup
      CFHelper.CreateCashFlowForecastDefault(CashFlowForecast);
      InvestmentAmount := LibraryRandom.RandDec(2000,2);
      EVALUATE(FAPostingDateFormula,'<1M>');
      FASetup.GET;
      CFHelper.CreateFixedAssetForInvestment(FixedAsset,FASetup."Default Depr. Book",FAPostingDateFormula,InvestmentAmount);
      ExpectedDueAndCFDate := CALCDATE(FAPostingDateFormula,WORKDATE);

      // Exercise
      ConsiderSource[SourceType::"Fixed Assets Budget"] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      CFHelper.VerifyCFDataOnSnglJnlLine(CFWorksheetLine,FixedAsset."No.",SourceType::"Fixed Assets Budget",
        CashFlowForecast."No.",-InvestmentAmount,ExpectedDueAndCFDate);
Member of Lib.Library - Cash Flow Helper


CreateLedgerEntry@11 Method

The procedure CreateLedgerEntry is available in codeunit 131332.

Syntax

CreateLedgerEntry@11(
    VAR GenJournalLine@1000 : Record 81 GenJournalLine, //Reference parameter of type Record
    PartnerNo@1004 : Code[20] PartnerNo, //Input parameter of type Code
    Amount@1001 : Decimal Amount, //Input parameter of type Decimal
    AccountType@1002 : Option AccountType, //Input parameter of type Option
    DocumentType@1003 : Option DocumentType //Input parameter of type Option
);

Parameters

GenJournalLine
Reference parameter of type Record
PartnerNo
Input parameter of type Code
Amount
Input parameter of type Decimal
AccountType
Input parameter of type Option
DocumentType
Input parameter of type Option

Remarks

The relevant search keywords are: Create, Ledger, Entry.

For a clarification about how this function works, refer to the code listed below.

      SelectAndClearGenJournalBatch(GenJournalBatch);
      LibraryERM.CreateGeneralJnlLine(
        GenJournalLine,GenJournalBatch."Journal Template Name",GenJournalBatch.Name,DocumentType,
        AccountType,PartnerNo,Amount);
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // Setup
      Initialize;
      CFHelper.CreateSpecificCashFlowCard(CashFlowForecast,ConsiderDiscount,ConsiderCFPmtTerms);
      LibraryERM.GetDiscountPaymentTerm(PaymentTerms);
      LibrarySales.CreateCustomer(Customer);
      CFHelper.AssignPaymentTermToCustomer(Customer,PaymentTerms.Code);
      IF ConsiderCFPmtTerms THEN
        CFHelper.AssignCFPaymentTermToCustomer(Customer,PaymentTerms.Code);
      Amount := LibraryRandom.RandDec(100,2);
      CFHelper.CreateLedgerEntry(
        GenJournalLine,Customer."No.",Amount,GenJournalLine."Account Type"::Customer,GenJournalLine."Document Type"::Invoice);

      // Exercise
      ExpectedDate := UpdateCustLedgerEntry(GenJournalLine."Document No.",GenJournalLine."Document Type",DateField);
      ConsiderSource[SourceType::Receivables] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      // The expected behavior is that the CF Journal line must reflect the modified date if CF pmt terms are not considered,
      // otherwise the CF pmt terms should be reflected
      IF ConsiderCFPmtTerms THEN BEGIN
        RecRef.GETTABLE(PaymentTerms);
        FieldRef := RecRef.FIELD(CFPmtTermsDateCalculationFieldNo);
        EVALUATE(CFPmtTermsDateFormula,FORMAT(FieldRef.VALUE));
        ExpectedDate := CALCDATE(FORMAT(FieldRef.VALUE),GenJournalLine."Posting Date");
      END;

      CFHelper.FilterSingleJournalLine(CFWorksheetLine,GenJournalLine."Document No.",SourceType::Receivables,CashFlowForecast."No.");
      CFHelper.VerifyCFDateOnCFJnlLine(CFWorksheetLine,ExpectedDate);
Member of Lib.Library - Cash Flow Helper


CreateManualPayment@30 Method

The procedure CreateManualPayment is available in codeunit 131332.

Syntax

CreateManualPayment@30(
    VAR CFManualExpense@1000 : Record 850 CFManualExpense //Reference parameter of type Record
);

Parameters

CFManualExpense
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Manual, Payment.

For a clarification about how this function works, refer to the code listed below.

      LibraryCashFlowForecast.CreateCashFlowAccount(CashFlowAccount,CashFlowAccount."Account Type"::Entry);
      LibraryCashFlowForecast.CreateManualLinePayment(CFManualExpense,CashFlowAccount."No.");

      // HACK - as long as test is running on current NAV6 Liquidity feature, recurring frequency is required
      EVALUATE(CFManualExpense."Recurring Frequency",'<1D>');

      CFManualExpense.VALIDATE(Amount,LibraryRandom.RandInt(500));
      CFManualExpense.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // Test filling a CF journal using Fill batch with a manual expense
      // and verify computed due and cash flow date

      // Setup
      Initialize;
      CFHelper.CreateCashFlowForecastDefault(CashFlowForecast);
      CFHelper.CreateManualPayment(CFManualExpense);

      // Exercise
      ConsiderSource[SourceType::"Cash Flow Manual Expense"] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      CFHelper.VerifyCFDataOnSnglJnlLine(CFWorksheetLine,CFManualExpense.Code,SourceType::"Cash Flow Manual Expense",
        CashFlowForecast."No.",-CFManualExpense.Amount,CFManualExpense."Starting Date");
Member of Lib.Library - Cash Flow Helper


CreateManualRevenue@56 Method

The procedure CreateManualRevenue is available in codeunit 131332.

Syntax

CreateManualRevenue@56(
    VAR CFManualRevenue@1000 : Record 849 CFManualRevenue //Reference parameter of type Record
);

Parameters

CFManualRevenue
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Manual, Revenue.

For a clarification about how this function works, refer to the code listed below.

      LibraryCashFlowForecast.CreateCashFlowAccount(CashFlowAccount,CashFlowAccount."Account Type"::Entry);
      LibraryCashFlowForecast.CreateManualLineRevenue(CFManualRevenue,CashFlowAccount."No.");

      // HACK - as long as test is running on current NAV6 Liquidity feature, recurring frequency is required
      EVALUATE(CFManualRevenue."Recurring Frequency",'<1D>');

      CFManualRevenue.VALIDATE(Amount,LibraryRandom.RandInt(500));
      CFManualRevenue.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // Test filling a CF journal using Fill batch with a manual revenue
      // and verify computed due and cash flow date

      // Setup
      Initialize;
      CFHelper.CreateCashFlowForecastDefault(CashFlowForecast);
      CFHelper.CreateManualRevenue(CFManualRevenue);

      // Exercise
      ConsiderSource[SourceType::"Cash Flow Manual Revenue"] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      CFHelper.VerifyCFDataOnSnglJnlLine(CFWorksheetLine,CFManualRevenue.Code,SourceType::"Cash Flow Manual Revenue",
        CashFlowForecast."No.",CFManualRevenue.Amount,CFManualRevenue."Starting Date");
Member of Lib.Library - Cash Flow Helper


CreatePrepaymentAccount@27 Method

The procedure CreatePrepaymentAccount is available in codeunit 131332.

Syntax

CreatePrepaymentAccount@27(
    GeneralPostingSetup@1000 : Record 252 GeneralPostingSetup, //Input parameter of type Record
    VATBusPostingGroup@1001 : Code[10] VATBusPostingGroup, //Input parameter of type Code
    VATProdPostingGroup@1003 : Code[10] VATProdPostingGroup //Input parameter of type Code
);

Parameters

GeneralPostingSetup
Input parameter of type Record
VATBusPostingGroup
Input parameter of type Code
VATProdPostingGroup
Input parameter of type Code

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Prepayment, Account.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.CreateGLAccount(GLAccount);
      GLAccount.VALIDATE("Gen. Bus. Posting Group",GeneralPostingSetup."Gen. Bus. Posting Group");
      GLAccount.VALIDATE("Gen. Prod. Posting Group",GeneralPostingSetup."Gen. Prod. Posting Group");
      GLAccount.VALIDATE("VAT Bus. Posting Group",VATBusPostingGroup);
      GLAccount.VALIDATE("VAT Prod. Posting Group",VATProdPostingGroup);
      GLAccount.MODIFY(TRUE);
      EXIT(GLAccount."No.");

Example

There are no examples available.
Member of Lib.Library - Cash Flow Helper


CreatePrepmtPurchaseOrder@91 Method

The procedure CreatePrepmtPurchaseOrder is available in codeunit 131332.

Syntax

CreatePrepmtPurchaseOrder@91(
    VAR PurchaseHeader@1000 : Record 38 PurchaseHeader, //Reference parameter of type Record
    PaymentTermsCode@1004 : Code[10] PaymentTermsCode, //Input parameter of type Code
    CFPaymentTermsCode@1003 : Code[10] CFPaymentTermsCode //Input parameter of type Code
);

Parameters

PurchaseHeader
Reference parameter of type Record
PaymentTermsCode
Input parameter of type Code
CFPaymentTermsCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Prepmt, Purchase, Order.

For a clarification about how this function works, refer to the code listed below.

      LibraryPurchase.CreatePrepaymentVATSetup(GLAccount,VATPostingSetup."VAT Calculation Type"::"Normal VAT");
      CreatePurchaseOrder(PurchaseHeader,GLAccount,PaymentTermsCode,CFPaymentTermsCode);

Example

There are no examples available.
Member of Lib.Library - Cash Flow Helper


CreatePrepmtSalesOrder@90 Method

The procedure CreatePrepmtSalesOrder is available in codeunit 131332.

Syntax

CreatePrepmtSalesOrder@90(
    VAR SalesHeader@1000 : Record 36 SalesHeader, //Reference parameter of type Record
    PaymentTermsCode@1004 : Code[10] PaymentTermsCode, //Input parameter of type Code
    CFPaymentTermsCode@1003 : Code[10] CFPaymentTermsCode //Input parameter of type Code
);

Parameters

SalesHeader
Reference parameter of type Record
PaymentTermsCode
Input parameter of type Code
CFPaymentTermsCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Prepmt, Sales, Order.

For a clarification about how this function works, refer to the code listed below.

      LibrarySales.CreatePrepaymentVATSetup(GLAccount,VATPostingSetup."VAT Calculation Type"::"Normal VAT");
      CreateSalesOrder(SalesHeader,GLAccount,PaymentTermsCode,CFPaymentTermsCode);

Example

There are no examples available.
Member of Lib.Library - Cash Flow Helper


CreatePurchaseLine@58 Method

The procedure CreatePurchaseLine is available in codeunit 131332.

Syntax

CreatePurchaseLine@58(
    PurchaseHeader@1002 : Record 38 PurchaseHeader, //Input parameter of type Record
    GLAccount@1000 : Record 15 GLAccount //Input parameter of type Record
);

Parameters

PurchaseHeader
Input parameter of type Record
GLAccount
Input parameter of type Record

Remarks

The relevant search keywords are: Create, Purchase, Line.

For a clarification about how this function works, refer to the code listed below.

      GLAccountNo := GLAccount."No.";
      IF GLAccountNo = '' THEN BEGIN
        VATPostingSetup.SETRANGE("VAT Bus. Posting Group",PurchaseHeader."VAT Bus. Posting Group");
        VATPostingSetup.SETFILTER("VAT Calculation Type",'<>%1',VATPostingSetup."VAT Calculation Type"::"Full VAT");
        VATPostingSetup.FINDFIRST;
        GLAccountNo := LibraryERM.CreateGLAccountWithVATPostingSetup(VATPostingSetup,GLAccount."Gen. Posting Type"::Purchase);
      END;
      LibraryPurchase.CreatePurchaseLine(
        PurchaseLine,PurchaseHeader,PurchaseLine.Type::"G/L Account",GLAccountNo,LibraryRandom.RandInt(10));
      PurchaseLine.VALIDATE("Direct Unit Cost",LibraryRandom.RandInt(100));
      PurchaseLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      FOR Index := 1 TO 2 DO BEGIN
        LibraryPurchase.CreatePurchaseLine(
          PurchaseLine,PurchaseHeader,PurchaseLine.Type::Item,LibraryInventory.CreateItem(Item),
          LibraryRandom.RandDec(10,2));
        PurchaseLine.VALIDATE("Direct Unit Cost",LibraryRandom.RandDecInRange(10,100,2));
        PurchaseLine.MODIFY(TRUE);
      END;
Member of Lib.Library - Cash Flow Helper


CreatePurchaseOrder@94 Method

The procedure CreatePurchaseOrder is available in codeunit 131332.

Syntax

CreatePurchaseOrder@94(
    VAR PurchaseHeader@1000 : Record 38 PurchaseHeader, //Reference parameter of type Record
    GLAccount@1001 : Record 15 GLAccount, //Input parameter of type Record
    PaymentTermsCode@1007 : Code[10] PaymentTermsCode, //Input parameter of type Code
    CFPaymentTermsCode@1002 : Code[10] CFPaymentTermsCode //Input parameter of type Code
);

Parameters

PurchaseHeader
Reference parameter of type Record
GLAccount
Input parameter of type Record
PaymentTermsCode
Input parameter of type Code
CFPaymentTermsCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Purchase, Order.

For a clarification about how this function works, refer to the code listed below.

      Vendor.GET(
        LibraryPurchase.CreateVendorWithBusPostingGroups(
          GLAccount."Gen. Bus. Posting Group",GLAccount."VAT Bus. Posting Group"));
      AssignPaymentTermToVendor(Vendor,PaymentTermsCode);
      AssignCFPaymentTermToVendor(Vendor,CFPaymentTermsCode);

      LibraryPurchase.CreatePurchHeader(PurchaseHeader,PurchaseHeader."Document Type"::Order,Vendor."No.");

      CreatePurchaseLine(PurchaseHeader,GLAccount);
      CreatePurchaseLine(PurchaseHeader,GLAccount);
      CreatePurchaseLine(PurchaseHeader,GLAccount);

Example

There are no examples available.
Member of Lib.Library - Cash Flow Helper


CreateRandomDateFormula@8 Method

The procedure CreateRandomDateFormula is available in codeunit 131332.

Syntax

CreateRandomDateFormula@8(
    VAR ResultDateFormula@1000 : DateFormula ResultDateFormula //Reference parameter of type DateFormula
);

Parameters

ResultDateFormula
Reference parameter of type DateFormula

Remarks

The relevant search keywords are: Create, Random, Date, Formula.

For a clarification about how this function works, refer to the code listed below.

      EVALUATE(ResultDateFormula,STRSUBSTNO('<%1D>',LibraryRandom.RandInt(5)));

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // Test filling a CF journal by using Fill batch with a 3-line sales order
      // and a payment discount grace period set. Verify computed due and cash flow date and discounted amount

      // Setup
      Initialize;
      CFHelper.CreateCashFlowForecastConsiderDiscount(CashFlowForecast);
      CFHelper.SetPmtToleranceOptionsOnCashFlowForecast(CashFlowForecast,TRUE,FALSE);
      GeneralLedgerSetup.GET;
      CFHelper.CreateRandomDateFormula(PmtDiscountGracePeriod);
      CFHelper.SetupPmtDsctGracePeriod(PmtDiscountGracePeriod);
      LibraryERM.GetDiscountPaymentTerm(PaymentTerms);
      CFHelper.CreateSpecificSalesOrder(SalesHeader,PaymentTerms.Code,'');
      ExpectedCFDate :=
        CALCDATE(PaymentTerms."Discount Date Calculation",
          CALCDATE(PmtDiscountGracePeriod,SalesHeader."Document Date"));

      // Exercise
      ConsiderSource[SourceType::"Sales Orders"] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      CFHelper.FilterSingleJournalLine(CFWorksheetLine,SalesHeader."No.",SourceType::"Sales Orders",CashFlowForecast."No.");
      CFHelper.VerifyCFDateOnCFJnlLine(CFWorksheetLine,ExpectedCFDate);

      // Tear down
      CFHelper.SetupPmtDsctGracePeriod(GeneralLedgerSetup."Payment Discount Grace Period");
Member of Lib.Library - Cash Flow Helper


CreateSalesLine@57 Method

The procedure CreateSalesLine is available in codeunit 131332.

Syntax

CreateSalesLine@57(
    SalesHeader@1001 : Record 36 SalesHeader, //Input parameter of type Record
    GLAccount@1000 : Record 15 GLAccount //Input parameter of type Record
);

Parameters

SalesHeader
Input parameter of type Record
GLAccount
Input parameter of type Record

Remarks

The relevant search keywords are: Create, Sales, Line.

For a clarification about how this function works, refer to the code listed below.

      GLAccountNo := GLAccount."No.";
      IF GLAccountNo = '' THEN BEGIN
        VATPostingSetup.SETRANGE("VAT Bus. Posting Group",SalesHeader."VAT Bus. Posting Group");
        VATPostingSetup.SETFILTER("VAT Calculation Type",'<>%1',VATPostingSetup."VAT Calculation Type"::"Full VAT");
        VATPostingSetup.FINDFIRST;
        GLAccountNo := LibraryERM.CreateGLAccountWithVATPostingSetup(VATPostingSetup,GLAccount."Gen. Posting Type"::Purchase);
      END;
      LibrarySales.CreateSalesLine(
        SalesLine,SalesHeader,SalesLine.Type::"G/L Account",GLAccountNo,LibraryRandom.RandInt(10));
      SalesLine.VALIDATE("Unit Price",LibraryRandom.RandInt(100));
      SalesLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      FOR Index := 1 TO 2 DO BEGIN
        LibrarySales.CreateSalesLine(
          SalesLine,SalesHeader,SalesLine.Type::Item,LibraryInventory.CreateItem(Item),LibraryRandom.RandDec(10,2));
        SalesLine.VALIDATE("Unit Price",LibraryRandom.RandDecInRange(10,100,2));
        SalesLine.MODIFY(TRUE);
      END;
Member of Lib.Library - Cash Flow Helper


CreateSalesOrder@92 Method

The procedure CreateSalesOrder is available in codeunit 131332.

Syntax

CreateSalesOrder@92(
    VAR SalesHeader@1000 : Record 36 SalesHeader, //Reference parameter of type Record
    GLAccount@1001 : Record 15 GLAccount, //Input parameter of type Record
    PaymentTermsCode@1007 : Code[10] PaymentTermsCode, //Input parameter of type Code
    CFPaymentTermsCode@1002 : Code[10] CFPaymentTermsCode //Input parameter of type Code
);

Parameters

SalesHeader
Reference parameter of type Record
GLAccount
Input parameter of type Record
PaymentTermsCode
Input parameter of type Code
CFPaymentTermsCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Sales, Order.

For a clarification about how this function works, refer to the code listed below.

      Customer.GET(
        LibrarySales.CreateCustomerWithBusPostingGroups(
          GLAccount."Gen. Bus. Posting Group",GLAccount."VAT Bus. Posting Group"));
      AssignPaymentTermToCustomer(Customer,PaymentTermsCode);
      AssignCFPaymentTermToCustomer(Customer,CFPaymentTermsCode);

      LibrarySales.CreateSalesHeader(SalesHeader,SalesHeader."Document Type"::Order,Customer."No.");

      CreateSalesLine(SalesHeader,GLAccount);
      CreateSalesLine(SalesHeader,GLAccount);
      CreateSalesLine(SalesHeader,GLAccount);

Example

There are no examples available.
Member of Lib.Library - Cash Flow Helper


CreateServiceLines@63 Method

The procedure CreateServiceLines is available in codeunit 131332.

Syntax

CreateServiceLines@63(
    ServiceHeader@1004 : Record 5900 ServiceHeader //Input parameter of type Record
);

Parameters

ServiceHeader
Input parameter of type Record

Remarks

The relevant search keywords are: Create, Service, Lines.

For a clarification about how this function works, refer to the code listed below.

      // simple wrapper for LibraryPurchase.CreateServiceLine
      LibrarySales.FindItem(Item);
      LibraryService.CreateServiceItemLine(ServiceItemLine,ServiceHeader,'');
      LibraryService.CreateServiceLine(ServiceLine,ServiceHeader,ServiceLine.Type::Item,Item."No.");
      ServiceLine.VALIDATE("Service Item Line No.",ServiceItemLine."Line No.");
      ServiceLine.VALIDATE(Quantity,LibraryRandom.RandInt(50));
      ServiceLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134553 to show one way of using this function.

      LibraryService.CreateServiceHeader(ServiceHeader,ServiceHeader."Document Type"::Order,CustomerNo);
      FOR Count := 1 TO LineCount DO
        CFHelper.CreateServiceLines(ServiceHeader);
Member of Lib.Library - Cash Flow Helper


CreateSpecificCashFlowCard@53 Method

The procedure CreateSpecificCashFlowCard is available in codeunit 131332.

Syntax

CreateSpecificCashFlowCard@53(
    VAR CashFlowForecast@1000 : Record 840 CashFlowForecast, //Reference parameter of type Record
    ConsiderDiscount@1001 : Boolean ConsiderDiscount, //Input parameter of type Boolean
    ConsiderPmtTerms@1002 : Boolean ConsiderPmtTerms //Input parameter of type Boolean
);

Parameters

CashFlowForecast
Reference parameter of type Record
ConsiderDiscount
Input parameter of type Boolean
ConsiderPmtTerms
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, Specific, Cash, Flow, Card.

For a clarification about how this function works, refer to the code listed below.

      LibraryCashFlowForecast.CreateCashFlowCard(CashFlowForecast);
      CashFlowForecast."Manual Payments To" := CashFlowForecast."Manual Payments From";
      CashFlowForecast.VALIDATE("Consider Discount",ConsiderDiscount);
      CashFlowForecast.VALIDATE("Consider CF Payment Terms",ConsiderPmtTerms);
      CashFlowForecast.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // Setup
      Initialize;
      CFHelper.CreateSpecificCashFlowCard(CashFlowForecast,ConsiderDiscount,ConsiderCFPmtTerms);
      LibraryERM.GetDiscountPaymentTerm(PaymentTerms);
      LibrarySales.CreateCustomer(Customer);
      CFHelper.AssignPaymentTermToCustomer(Customer,PaymentTerms.Code);
      IF ConsiderCFPmtTerms THEN
        CFHelper.AssignCFPaymentTermToCustomer(Customer,PaymentTerms.Code);
      Amount := LibraryRandom.RandDec(100,2);
      CFHelper.CreateLedgerEntry(
        GenJournalLine,Customer."No.",Amount,GenJournalLine."Account Type"::Customer,GenJournalLine."Document Type"::Invoice);

      // Exercise
      ExpectedDate := UpdateCustLedgerEntry(GenJournalLine."Document No.",GenJournalLine."Document Type",DateField);
      ConsiderSource[SourceType::Receivables] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      // The expected behavior is that the CF Journal line must reflect the modified date if CF pmt terms are not considered,
      // otherwise the CF pmt terms should be reflected
      IF ConsiderCFPmtTerms THEN BEGIN
        RecRef.GETTABLE(PaymentTerms);
        FieldRef := RecRef.FIELD(CFPmtTermsDateCalculationFieldNo);
        EVALUATE(CFPmtTermsDateFormula,FORMAT(FieldRef.VALUE));
        ExpectedDate := CALCDATE(FORMAT(FieldRef.VALUE),GenJournalLine."Posting Date");
      END;

      CFHelper.FilterSingleJournalLine(CFWorksheetLine,GenJournalLine."Document No.",SourceType::Receivables,CashFlowForecast."No.");
      CFHelper.VerifyCFDateOnCFJnlLine(CFWorksheetLine,ExpectedDate);
Member of Lib.Library - Cash Flow Helper


CreateSpecificPurchaseOrder@32 Method

The procedure CreateSpecificPurchaseOrder is available in codeunit 131332.

Syntax

CreateSpecificPurchaseOrder@32(
    VAR PurchaseHeader@1000 : Record 38 PurchaseHeader, //Reference parameter of type Record
    PaymentTermsCode@1007 : Code[10] PaymentTermsCode, //Input parameter of type Code
    CFPaymentTermsCode@1002 : Code[10] CFPaymentTermsCode //Input parameter of type Code
);

Parameters

PurchaseHeader
Reference parameter of type Record
PaymentTermsCode
Input parameter of type Code
CFPaymentTermsCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Specific, Purchase, Order.

For a clarification about how this function works, refer to the code listed below.

      GLAccount.GET(LibraryERM.CreateGLAccountWithPurchSetup);
      CreatePurchaseOrder(PurchaseHeader,GLAccount,PaymentTermsCode,CFPaymentTermsCode);

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // Test filling a CF journal by using Fill batch with a discounted single vendor ledger entry
      // Verify computed due and cash flow date, discounted amount and discount percentage

      // Setup
      Initialize;
      CFHelper.CreateCashFlowForecastConsiderDiscount(CashFlowForecast);
      LibraryERM.GetDiscountPaymentTerm(PaymentTerms);
      CFHelper.CreateSpecificPurchaseOrder(PurchaseHeader,PaymentTerms.Code,'');
      ExpectedAmount := -CFHelper.GetTotalPurchaseAmount(PurchaseHeader,TRUE);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);
      CFHelper.FindFirstVendorLEFromPO(VendorLedgerEntry,PurchaseHeader."No.");

      // Exercise
      ConsiderSource[SourceType::Payables] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      CFHelper.VerifyCFDataOnSnglJnlLine(CFWorksheetLine,VendorLedgerEntry."Document No.",SourceType::Payables,
        CashFlowForecast."No.",ExpectedAmount,VendorLedgerEntry."Pmt. Discount Date");
Member of Lib.Library - Cash Flow Helper


CreateSpecificSalesOrder@31 Method

The procedure CreateSpecificSalesOrder is available in codeunit 131332.

Syntax

CreateSpecificSalesOrder@31(
    VAR SalesHeader@1000 : Record 36 SalesHeader, //Reference parameter of type Record
    PaymentTermsCode@1007 : Code[10] PaymentTermsCode, //Input parameter of type Code
    CFPaymentTermsCode@1002 : Code[10] CFPaymentTermsCode //Input parameter of type Code
);

Parameters

SalesHeader
Reference parameter of type Record
PaymentTermsCode
Input parameter of type Code
CFPaymentTermsCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Specific, Sales, Order.

For a clarification about how this function works, refer to the code listed below.

      GLAccount.GET(LibraryERM.CreateGLAccountWithSalesSetup);
      CreateSalesOrder(SalesHeader,GLAccount,PaymentTermsCode,CFPaymentTermsCode);

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // Test filling a CF journal by using Fill batch with a discounted 3-line sales order
      // Verify computed due and cash flow date, discounted amount and discount percentage

      // Setup
      Initialize;
      CFHelper.CreateCashFlowForecastConsiderDiscount(CashFlowForecast);
      LibraryERM.GetDiscountPaymentTerm(PaymentTerms);
      CFHelper.CreateSpecificSalesOrder(SalesHeader,PaymentTerms.Code,'');
      ExpectedAmount := CFHelper.GetTotalSalesAmount(SalesHeader,TRUE);

      // Exercise
      ConsiderSource[SourceType::"Sales Orders"] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      CFHelper.VerifyCFDataOnSnglJnlLine(CFWorksheetLine,SalesHeader."No.",SourceType::"Sales Orders",
        CashFlowForecast."No.",ExpectedAmount,CALCDATE(PaymentTerms."Discount Date Calculation",SalesHeader."Document Date"));
Member of Lib.Library - Cash Flow Helper


CreateSpecificServiceOrder@33 Method

The procedure CreateSpecificServiceOrder is available in codeunit 131332.

Syntax

CreateSpecificServiceOrder@33(
    VAR ServiceHeader@1000 : Record 5900 ServiceHeader, //Reference parameter of type Record
    PaymentTermsCode@1007 : Code[10] PaymentTermsCode, //Input parameter of type Code
    CFPaymentTermsCode@1001 : Code[10] CFPaymentTermsCode //Input parameter of type Code
);

Parameters

ServiceHeader
Reference parameter of type Record
PaymentTermsCode
Input parameter of type Code
CFPaymentTermsCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Specific, Service, Order.

For a clarification about how this function works, refer to the code listed below.

      LibrarySales.CreateCustomer(Customer);
      AssignCFPaymentTermToCustomer(Customer,PaymentTermsCode);
      AssignCFPaymentTermToCustomer(Customer,CFPaymentTermsCode);

      LibraryService.CreateServiceHeader(ServiceHeader,ServiceHeader."Document Type"::Order,Customer."No.");

      CreateServiceLines(ServiceHeader);
      CreateServiceLines(ServiceHeader);
      CreateServiceLines(ServiceHeader);

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // Test filling a CF journal by using Fill batch with a discounted 3-line service order
      // Verify computed due and cash flow date, discounted amount and order discount percentage

      // Setup
      Initialize;
      CFHelper.CreateCashFlowForecastConsiderDiscount(CashFlowForecast);
      LibraryERM.GetDiscountPaymentTerm(PaymentTerms);
      CFHelper.CreateSpecificServiceOrder(ServiceHeader,PaymentTerms.Code,'');
      ExpectedAmount := CFHelper.GetTotalServiceAmount(ServiceHeader,TRUE);
      ExpectedCFDate := ServiceHeader."Pmt. Discount Date";

      // Exercise
      ConsiderSource[SourceType::"Service Orders"] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      CFHelper.VerifyCFDataOnSnglJnlLine(CFWorksheetLine,ServiceHeader."No.",SourceType::"Service Orders",
        CashFlowForecast."No.",ExpectedAmount,ExpectedCFDate);
Member of Lib.Library - Cash Flow Helper


CreateVendorWithCFDsctPmtTerm@22 Method

The procedure CreateVendorWithCFDsctPmtTerm is available in codeunit 131332.

Syntax

CreateVendorWithCFDsctPmtTerm@22(
    VAR Vendor@1000 : Record 23 Vendor, //Reference parameter of type Record
    VAR PaymentTerms@1001 : Record 3 PaymentTerms //Reference parameter of type Record
);

Parameters

Vendor
Reference parameter of type Record
PaymentTerms
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Vendor, Cash Flow, Dsct, Payment, Term.

For a clarification about how this function works, refer to the code listed below.

      LibraryPurchase.CreateVendor(Vendor);
      LibraryERM.GetDiscountPaymentTerm(PaymentTerms);
      AssignCFPaymentTermToVendor(Vendor,PaymentTerms.Code);

Example

There are no examples available.
Member of Lib.Library - Cash Flow Helper


FillJnlOnCertDateFormulas@14 Method

The procedure FillJnlOnCertDateFormulas is available in codeunit 131332.

Syntax

FillJnlOnCertDateFormulas@14(
    ConsiderSource@1015 : ARRAY [11] OF Boolean ConsiderSource, //Input Array parameter of type Boolean
    CFNo@1000 : Code[20] CFNo, //Input parameter of type Code
    BaseDateFormula@1012 : DateFormula BaseDateFormula, //Input parameter of type DateFormula
    CustomDateFormula@1013 : DateFormula CustomDateFormula, //Input parameter of type DateFormula
    AdditionalDateFormula@1014 : DateFormula AdditionalDateFormula //Input parameter of type DateFormula
);

Parameters

ConsiderSource
Input Array parameter of type Boolean
CFNo
Input parameter of type Code
BaseDateFormula
Input parameter of type DateFormula
CustomDateFormula
Input parameter of type DateFormula
AdditionalDateFormula
Input parameter of type DateFormula

Remarks

The relevant search keywords are: Fill, Journal, On, Cert, Date, Formulas.

For a clarification about how this function works, refer to the code listed below.

      ForecastDate := GenerateDateFromFormulas(WORKDATE,BaseDateFormula,AdditionalDateFormula,CustomDateFormula);
      FillJournalOnCertainDate(ConsiderSource,CFNo,ForecastDate);

Example

The below example is extracted from the test automation codeunit 134553 to show one way of using this function.

      // Test filling a CF journal using Fill batch considering discount CF Payment Terms
      // This scenario covers a discounted payment AFTER the payment discount date,
      // therefore the expected CF amount is the remaining amount (total amount - discounted amount)
      // the CF date should be the due date

      // Setup
      Initialize;
      CFHelper.SetupDsctPmtTermsCustLETest(CashFlowForecast,Customer,PaymentTerms,Amount,DiscountedAmount);
      // payment is done 1 day after discount date in order to be overdue
      CustomDateFormula := PlusOneDayFormula;
      CFHelper.CreateAndApplySalesInvPayment(GenJournalLine,Customer."No.",Amount,-DiscountedAmount,
        PaymentTerms."Discount Date Calculation",EmptyDateFormula,CustomDateFormula);
      LibraryERM.FindCustomerLedgerEntry(CustLedgerEntry,GenJournalLine."Document Type"::Invoice,GenJournalLine."Document No.");

      // Exercise
      // forecast is calculated after the discount date, payment already done
      ConsiderSource[SourceType::Receivables] := TRUE;
      CFHelper.FillJnlOnCertDateFormulas(ConsiderSource,CashFlowForecast."No.",PaymentTerms."Discount Date Calculation",
        EmptyDateFormula,CustomDateFormula);

      // Verify
      CFHelper.VerifyCFDataOnSnglJnlLine(CFWorksheetLine,GenJournalLine."Document No.",SourceType::Receivables,
        CashFlowForecast."No.",Amount - DiscountedAmount,CALCDATE(PaymentTerms."Due Date Calculation",CustLedgerEntry."Document Date"));
Member of Lib.Library - Cash Flow Helper


FillJournal@44 Method

The procedure FillJournal is available in codeunit 131332.

Syntax

FillJournal@44(
    ConsiderSource@1012 : ARRAY [11] OF Boolean ConsiderSource, //Input Array parameter of type Boolean
    CFNo@1001 : Code[20] CFNo, //Input parameter of type Code
    GroupByDocumentType@1000 : Boolean GroupByDocumentType //Input parameter of type Boolean
);

Parameters

ConsiderSource
Input Array parameter of type Boolean
CFNo
Input parameter of type Code
GroupByDocumentType
Input parameter of type Boolean

Remarks

The relevant search keywords are: Fill, Journal.

For a clarification about how this function works, refer to the code listed below.

      LibraryCashFlowForecast.ClearJournal;
      LibraryCashFlowForecast.FillJournal(ConsiderSource,CFNo,GroupByDocumentType);

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // Test filling a CF journal by using Fill batch with/without a discounted 3-line service order where vendor has
      // CF payment terms set. Verify computed due and cash flow date and discounted/full amount

      // Setup
      Initialize;
      LibraryERM.GetDiscountPaymentTerm(PaymentTerms);
      IF ConsiderDiscount THEN BEGIN
        CFHelper.GetDifferentDsctPaymentTerms(PaymentTerms2,PaymentTerms.Code);
        CFHelper.CreateCashFlowForecastConsiderDiscountAndCFPmtTerms(CashFlowForecast);
        PaymentTermsCode := PaymentTerms.Code;
        PaymentTermsCode2 := PaymentTerms2.Code;
      END ELSE BEGIN
        CFHelper.CreateCashFlowForecastConsiderCFPmtTerms(CashFlowForecast);
        PaymentTermsCode2 := PaymentTerms.Code;
      END;
      CFHelper.CreateSpecificServiceOrder(ServiceHeader,PaymentTermsCode,PaymentTermsCode2);

      CFHelper.SetExpectedDsctAPmtTermValues(DocumentType::Service,ServiceHeader."No.",ServiceHeader."Customer No.",
        ServiceHeader."Document Date",ConsiderDiscount,ExpectedCFDate,ExpectedAmount);

      // Exercise
      ConsiderSource[SourceType::"Service Orders"] := TRUE;
      CFHelper.FillJournal(ConsiderSource,CashFlowForecast."No.",GroupByDocumentType);

      // Verify
      CFHelper.VerifyCFDataOnSnglJnlLine(CFWorksheetLine,ServiceHeader."No.",SourceType::"Service Orders",
        CashFlowForecast."No.",ExpectedAmount,ExpectedCFDate);
Member of Lib.Library - Cash Flow Helper


FillJournalOnCertainDate@19 Method

The procedure FillJournalOnCertainDate is available in codeunit 131332.

Syntax

FillJournalOnCertainDate@19(
    ConsiderSource@1013 : ARRAY [11] OF Boolean ConsiderSource, //Input Array parameter of type Boolean
    CFNo@1000 : Code[20] CFNo, //Input parameter of type Code
    ForecastDate@1012 : Date ForecastDate //Input parameter of type Date
);

Parameters

ConsiderSource
Input Array parameter of type Boolean
CFNo
Input parameter of type Code
ForecastDate
Input parameter of type Date

Remarks

The relevant search keywords are: Fill, Journal, On, Certain, Date.

For a clarification about how this function works, refer to the code listed below.

      OldWorkDate := ChangeWorkdate(ForecastDate);
      FillJournal(ConsiderSource,CFNo,FALSE);
      WORKDATE := OldWorkDate;

Example

There are no examples available.
Member of Lib.Library - Cash Flow Helper


FilterSingleJournalLine@43 Method

The procedure FilterSingleJournalLine is available in codeunit 131332.

Syntax

FilterSingleJournalLine@43(
    VAR CFWorksheetLine@1000 : Record 846 CFWorksheetLine, //Reference parameter of type Record
    DocumentNo@1001 : Code[20] DocumentNo, //Input parameter of type Code
    SourceType@1003 : Option SourceType, //Input parameter of type Option
    CashFlowNo@1002 : Code[20] CashFlowNo //Input parameter of type Code
);

Parameters

CFWorksheetLine
Reference parameter of type Record
DocumentNo
Input parameter of type Code
SourceType
Input parameter of type Option
CashFlowNo
Input parameter of type Code

Return Value

Integer

Remarks

The relevant search keywords are: Filter, Single, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      // Filters cash flow journal lines based on the given parameters
      // Returns the number of lines found based on the filter

      CFWorksheetLine.SETRANGE("Cash Flow Forecast No.",CashFlowNo);
      CFWorksheetLine.SETRANGE("Document No.",DocumentNo);
      CFWorksheetLine.SETRANGE("Source Type",SourceType);
      IF CFWorksheetLine.FINDFIRST THEN;
      EXIT(CFWorksheetLine.COUNT);

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // Test filling a CF journal using Fill batch with a manual revenue out of forecast date
      // and verify that it does not exist in journal

      // Setup
      Initialize;
      CreateCashFlowForecastDefaultWithManualPmtDates(CashFlowForecast,WORKDATE,CALCDATE('<1M>',WORKDATE));
      CreateManualRevenueWithStartingDate(CFManualRevenue[1],CALCDATE('<-1D>',CashFlowForecast."Manual Payments From"));
      CreateManualRevenueWithStartingDate(CFManualRevenue[2],CALCDATE('<+1D>',CashFlowForecast."Manual Payments To"));

      // Exercise
      ConsiderSource[SourceType::"Cash Flow Manual Revenue"] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      FOR i := 1 TO ARRAYLEN(CFManualRevenue) DO
        Assert.AreEqual(
          0,
          CFHelper.FilterSingleJournalLine(
            CFWorksheetLine,CFManualRevenue[i].Code,SourceType::"Cash Flow Manual Revenue",CashFlowForecast."No."),
          STRSUBSTNO(CFSourceExistsInJnlErr,SourceType::"Cash Flow Manual Revenue"));
Member of Lib.Library - Cash Flow Helper


FindCFBudgetAccount@51 Method

The procedure FindCFBudgetAccount is available in codeunit 131332.

Syntax

FindCFBudgetAccount@51(
    VAR CFAccount@1000 : Record 841 CFAccount //Reference parameter of type Record
);

Parameters

CFAccount
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Cash Flow, Budget, Account.

For a clarification about how this function works, refer to the code listed below.

      FindFirstCFAccWithGLIntegration(CFAccount,CFAccount."G/L Integration"::Budget);

Example

The below example is extracted from the test automation codeunit 134554 to show one way of using this function.

      CFHelper.FindCFBudgetAccount(CFAccount);
      CFHelper.FindFirstGLAccFromCFAcc(GLAccount,CFAccount);
      LibraryERM.CreateGLBudgetName(GLBudgetName);
      LibraryERM.CreateGLBudgetEntry(GLBudgetEntry,CashFlowForecast."G/L Budget From",GLAccount."No.",GLBudgetName.Name);
      GLBudgetEntry.VALIDATE(Amount,LibraryRandom.RandDec(100,2));
      GLBudgetEntry.MODIFY(TRUE);

      WITH CFWorksheetLine DO BEGIN
        INIT;
        "Cash Flow Date" := WORKDATE;
        "Document No." := FORMAT(LibraryRandom.RandInt(50));
        "Cash Flow Forecast No." := CashFlowForecast."No.";
        Description := "Document No.";
        "Cash Flow Account No." := CFAccount."No.";
        "Amount (LCY)" := CashFlowAmount;
        "Source Type" := "Source Type"::"G/L Budget";
        "Source No." := GLAccount."No.";
        "G/L Budget Name" := GLBudgetName.Name;
        INSERT(TRUE);
      END;
Member of Lib.Library - Cash Flow Helper


FindCFLiquidFundAccount@41 Method

The procedure FindCFLiquidFundAccount is available in codeunit 131332.

Syntax

FindCFLiquidFundAccount@41(
    VAR CFAccount@1000 : Record 841 CFAccount //Reference parameter of type Record
);

Parameters

CFAccount
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Cash Flow, Liquid, Fund, Account.

For a clarification about how this function works, refer to the code listed below.

      FindFirstCFAccWithGLIntegration(CFAccount,CFAccount."G/L Integration"::Balance);

Example

The below example is extracted from the test automation codeunit 134559 to show one way of using this function.

      Initialize;

      CFHelper.FindCFLiquidFundAccount(CFAccount);
      CFHelper.FindFirstGLAccFromCFAcc(GLAccount,CFAccount);
      GLAccount.NEXT(LibraryRandom.RandInt(GLAccount.COUNT));
      ExpectedNo := GLAccount."No.";

      InsertJournalLine(CFWorksheetLine,CFWorksheetLine."Source Type"::"Liquid Funds",GLAccount."No.");

      // Navigate
      CashFlowJournal.OPENEDIT;
      CashFlowJournal.ShowSource.INVOKE;
      CashFlowJournal.CLOSE;
      // Verification is done in modal handler function
Member of Lib.Library - Cash Flow Helper


FindCustomerCFPaymentTerms@61 Method

The procedure FindCustomerCFPaymentTerms is available in codeunit 131332.

Syntax

FindCustomerCFPaymentTerms@61(
    VAR PaymentTerms@1001 : Record 3 PaymentTerms, //Reference parameter of type Record
    CustomerNo@1000 : Code[20] CustomerNo //Input parameter of type Code
);

Parameters

PaymentTerms
Reference parameter of type Record
CustomerNo
Input parameter of type Code

Remarks

The relevant search keywords are: Find, Customer, Cash Flow, Payment, Terms.

For a clarification about how this function works, refer to the code listed below.

      Customer.GET(CustomerNo);
      PaymentTerms.GET(Customer."Cash Flow Payment Terms Code");

Example

There are no examples available.
Member of Lib.Library - Cash Flow Helper


FindFirstCustLEFromSO@80 Method

The procedure FindFirstCustLEFromSO is available in codeunit 131332.

Syntax

FindFirstCustLEFromSO@80(
    VAR CustLedgerEntry@1000 : Record 21 CustLedgerEntry, //Reference parameter of type Record
    SalesOrderNo@1002 : Code[20] SalesOrderNo //Input parameter of type Code
);

Parameters

CustLedgerEntry
Reference parameter of type Record
SalesOrderNo
Input parameter of type Code

Remarks

The relevant search keywords are: Find, First, Customer, LE, From, Sales Order.

For a clarification about how this function works, refer to the code listed below.

      SalesInvoiceHeader.SETRANGE("Order No.",SalesOrderNo);
      SalesInvoiceHeader.FINDFIRST;
      CustLedgerEntry.SETRANGE("Document No.",SalesInvoiceHeader."No.");
      CustLedgerEntry.FINDFIRST;

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // Test filling a CF journal by using Fill batch with a single customer ledger entry
      // Verify computed due and cash flow date

      // Setup
      Initialize;
      CFHelper.CreateCashFlowForecastDefault(CashFlowForecast);
      CFHelper.CreateDefaultSalesOrder(SalesHeader);
      LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);
      CFHelper.FindFirstCustLEFromSO(CustLedgerEntry,SalesHeader."No.");

      // Exercise
      ConsiderSource[SourceType::Receivables] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      CustLedgerEntry.CALCFIELDS("Amount (LCY)");
      CFHelper.VerifyCFDataOnSnglJnlLine(CFWorksheetLine,CustLedgerEntry."Document No.",SourceType::Receivables,
        CashFlowForecast."No.",CustLedgerEntry."Amount (LCY)",CustLedgerEntry."Due Date");
Member of Lib.Library - Cash Flow Helper


FindFirstGLAccFromCFAcc@54 Method

The procedure FindFirstGLAccFromCFAcc is available in codeunit 131332.

Syntax

FindFirstGLAccFromCFAcc@54(
    VAR GLAccount@1000 : Record 15 GLAccount, //Reference parameter of type Record
    CFAccount@1001 : Record 841 CFAccount //Input parameter of type Record
);

Parameters

GLAccount
Reference parameter of type Record
CFAccount
Input parameter of type Record

Remarks

The relevant search keywords are: Find, First, General Ledger, Accountount, From, Cash Flow, Accountount.

For a clarification about how this function works, refer to the code listed below.

      GLAccount.SETFILTER("No.",CFAccount."G/L Account Filter");
      GLAccount.FINDFIRST;

Example

The below example is extracted from the test automation codeunit 134554 to show one way of using this function.

      CFHelper.FindCFBudgetAccount(CFAccount);
      CFHelper.FindFirstGLAccFromCFAcc(GLAccount,CFAccount);
      LibraryERM.CreateGLBudgetName(GLBudgetName);
      LibraryERM.CreateGLBudgetEntry(GLBudgetEntry,CashFlowForecast."G/L Budget From",GLAccount."No.",GLBudgetName.Name);
      GLBudgetEntry.VALIDATE(Amount,LibraryRandom.RandDec(100,2));
      GLBudgetEntry.MODIFY(TRUE);

      WITH CFWorksheetLine DO BEGIN
        INIT;
        "Cash Flow Date" := WORKDATE;
        "Document No." := FORMAT(LibraryRandom.RandInt(50));
        "Cash Flow Forecast No." := CashFlowForecast."No.";
        Description := "Document No.";
        "Cash Flow Account No." := CFAccount."No.";
        "Amount (LCY)" := CashFlowAmount;
        "Source Type" := "Source Type"::"G/L Budget";
        "Source No." := GLAccount."No.";
        "G/L Budget Name" := GLBudgetName.Name;
        INSERT(TRUE);
      END;
Member of Lib.Library - Cash Flow Helper


FindFirstVendorLEFromPO@42 Method

The procedure FindFirstVendorLEFromPO is available in codeunit 131332.

Syntax

FindFirstVendorLEFromPO@42(
    VAR VendorLedgerEntry@1000 : Record 25 VendorLedgerEntry, //Reference parameter of type Record
    PurchaseOrderNo@1002 : Code[20] PurchaseOrderNo //Input parameter of type Code
);

Parameters

VendorLedgerEntry
Reference parameter of type Record
PurchaseOrderNo
Input parameter of type Code

Remarks

The relevant search keywords are: Find, First, Vendor, LE, From, Purchase Order.

For a clarification about how this function works, refer to the code listed below.

      PurchInvHeader.SETRANGE("Order No.",PurchaseOrderNo);
      PurchInvHeader.FINDFIRST;
      VendorLedgerEntry.SETRANGE("Document No.",PurchInvHeader."No.");
      VendorLedgerEntry.FINDFIRST;

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // Test filling a CF journal by using Fill batch with a single vendor ledger entry
      // Verify computed due and cash flow date

      // Setup
      Initialize;
      CFHelper.CreateCashFlowForecastDefault(CashFlowForecast);
      CFHelper.CreateDefaultPurchaseOrder(PurchaseHeader);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);
      CFHelper.FindFirstVendorLEFromPO(VendorLedgerEntry,PurchaseHeader."No.");

      // Exercise
      ConsiderSource[SourceType::Payables] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      VendorLedgerEntry.CALCFIELDS("Amount (LCY)");
      CFHelper.VerifyCFDataOnSnglJnlLine(CFWorksheetLine,VendorLedgerEntry."Document No.",SourceType::Payables,
        CashFlowForecast."No.",VendorLedgerEntry."Amount (LCY)",VendorLedgerEntry."Due Date");
Member of Lib.Library - Cash Flow Helper


FindPurchaseLine@40 Method

The procedure FindPurchaseLine is available in codeunit 131332.

Syntax

FindPurchaseLine@40(
    VAR PurchaseLine@1000 : Record 39 PurchaseLine, //Reference parameter of type Record
    PurchaseHeader@1001 : Record 38 PurchaseHeader //Input parameter of type Record
);

Parameters

PurchaseLine
Reference parameter of type Record
PurchaseHeader
Input parameter of type Record

Remarks

The relevant search keywords are: Find, Purchase, Line.

For a clarification about how this function works, refer to the code listed below.

      PurchaseLine.SETRANGE("Document Type",PurchaseHeader."Document Type");
      PurchaseLine.SETRANGE("Document No.",PurchaseHeader."No.");
      PurchaseLine.FINDSET;

Example

There are no examples available.
Member of Lib.Library - Cash Flow Helper


FindSalesLine@26 Method

The procedure FindSalesLine is available in codeunit 131332.

Syntax

FindSalesLine@26(
    VAR SalesLine@1000 : Record 37 SalesLine, //Reference parameter of type Record
    SalesHeader@1001 : Record 36 SalesHeader //Input parameter of type Record
);

Parameters

SalesLine
Reference parameter of type Record
SalesHeader
Input parameter of type Record

Remarks

The relevant search keywords are: Find, Sales, Line.

For a clarification about how this function works, refer to the code listed below.

      SalesLine.SETRANGE("Document Type",SalesHeader."Document Type");
      SalesLine.SETRANGE("Document No.",SalesHeader."No.");
      SalesLine.FINDSET;

Example

There are no examples available.
Member of Lib.Library - Cash Flow Helper


GenerateDateFromFormulaArray@16 Method

The procedure GenerateDateFromFormulaArray is available in codeunit 131332.

Syntax

GenerateDateFromFormulaArray@16(
    BaseDate@1002 : Date BaseDate, //Input parameter of type Date
    DateFormulas@1005 : ARRAY [3] OF DateFormula DateFormulas //Input Array parameter of type DateFormula
);

Parameters

BaseDate
Input parameter of type Date
DateFormulas
Input Array parameter of type DateFormula

Return Value

Date

Remarks

The relevant search keywords are: Generate, Date, From, Formula, Array.

For a clarification about how this function works, refer to the code listed below.

      TempDate := BaseDate;
      FOR I := 1 TO ARRAYLEN(DateFormulas) DO
        TempDate := CALCDATE(DateFormulas[I],TempDate);
      EXIT(TempDate);

Example

There are no examples available.
Member of Lib.Library - Cash Flow Helper


GenerateDateFromFormulas@20 Method

The procedure GenerateDateFromFormulas is available in codeunit 131332.

Syntax

GenerateDateFromFormulas@20(
    BaseDate@1002 : Date BaseDate, //Input parameter of type Date
    DateFormula1@1005 : DateFormula DateFormula1, //Input parameter of type DateFormula
    DateFormula2@1003 : DateFormula DateFormula2, //Input parameter of type DateFormula
    DateFormula3@1004 : DateFormula DateFormula3 //Input parameter of type DateFormula
);

Parameters

BaseDate
Input parameter of type Date
DateFormula1
Input parameter of type DateFormula
DateFormula2
Input parameter of type DateFormula
DateFormula3
Input parameter of type DateFormula

Return Value

Date

Remarks

The relevant search keywords are: Generate, Date, From, Formulas.

For a clarification about how this function works, refer to the code listed below.

      TempDate := BaseDate;
      TempDate := CALCDATE(DateFormula1,TempDate);
      TempDate := CALCDATE(DateFormula2,TempDate);
      TempDate := CALCDATE(DateFormula3,TempDate);
      EXIT(TempDate);

Example

There are no examples available.
Member of Lib.Library - Cash Flow Helper


GetDifferentDsctPaymentTerms@37 Method

The procedure GetDifferentDsctPaymentTerms is available in codeunit 131332.

Syntax

GetDifferentDsctPaymentTerms@37(
    VAR PaymentTerms@1000 : Record 3 PaymentTerms, //Reference parameter of type Record
    PmtTermsCodeToDifferFrom@1001 : Code[20] PmtTermsCodeToDifferFrom //Input parameter of type Code
);

Parameters

PaymentTerms
Reference parameter of type Record
PmtTermsCodeToDifferFrom
Input parameter of type Code

Remarks

The relevant search keywords are: Get, Different, Dsct, Payment, Terms.

For a clarification about how this function works, refer to the code listed below.

      PaymentTerms2.GET(PmtTermsCodeToDifferFrom);
      LibraryERM.CreatePaymentTerms(PaymentTerms);
      EVALUATE(PaymentTerms."Due Date Calculation",FORMAT(PaymentTerms2."Due Date Calculation") + '+<1M>');
      EVALUATE(PaymentTerms."Discount Date Calculation",FORMAT(PaymentTerms2."Discount Date Calculation") + '+<1D>');
      PaymentTerms.VALIDATE("Discount %",PaymentTerms2."Discount %" + 1);
      PaymentTerms.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // Test filling a CF journal by using Fill batch with a discounted 3-line sales order
      // where customer has CF payment terms set. Verify computed due and cash flow date and discounted amount

      // Setup
      Initialize;
      CFHelper.CreateCashFlowForecastConsiderDiscountAndCFPmtTerms(CashFlowForecast);
      LibraryERM.GetDiscountPaymentTerm(PaymentTerms); // default pmt terms
      CFHelper.GetDifferentDsctPaymentTerms(PaymentTerms2,PaymentTerms.Code); // cf pmt terms
      CFHelper.CreateSpecificSalesOrder(SalesHeader,PaymentTerms.Code,PaymentTerms2.Code);
      // set expected vales considering CF payment terms and line discount
      CFHelper.SetExpectedDsctAPmtTermValues(DocumentType::Sale,SalesHeader."No.",
        SalesHeader."Sell-to Customer No.",SalesHeader."Document Date",TRUE,
        ExpectedCFDate,ExpectedAmount);

      // Exercise
      ConsiderSource[SourceType::"Sales Orders"] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      CFHelper.VerifyCFDataOnSnglJnlLine(CFWorksheetLine,SalesHeader."No.",SourceType::"Sales Orders",
        CashFlowForecast."No.",ExpectedAmount,ExpectedCFDate);
Member of Lib.Library - Cash Flow Helper


GetTotalAmountForPurchaseOrderWithCashFlowPaymentTermsDiscount@107 Method

The procedure GetTotalAmountForPurchaseOrderWithCashFlowPaymentTermsDiscount is available in codeunit 131332.

Syntax

GetTotalAmountForPurchaseOrderWithCashFlowPaymentTermsDiscount@107(
    PurchaseHeader@1000 : Record 38 PurchaseHeader //Input parameter of type Record
);

Parameters

PurchaseHeader
Input parameter of type Record

Return Value

Decimal

Remarks

The relevant search keywords are: Get, Total, Amount, For, Purchase, Order, Cash, Flow, Payment, Terms, Discount.

For a clarification about how this function works, refer to the code listed below.

      Vendor.GET(PurchaseHeader."Buy-from Vendor No.");
      PaymentTermsCashFlow.GET(Vendor."Cash Flow Payment Terms Code");
      TotalAmount := 0;
      TotalDiscountAmount := 0;
      PurchaseLine.SETRANGE("Document No.",PurchaseHeader."No.");
      PurchaseLine.SETRANGE("Document Type",PurchaseHeader."Document Type");
      IF PurchaseLine.FINDSET THEN BEGIN
        REPEAT
          LineAmount := PurchaseLine."Outstanding Amount (LCY)";
          TotalAmount += LineAmount;
          TotalDiscountAmount += CalculateDiscountAmount(LineAmount,PaymentTermsCashFlow."Discount %");
        UNTIL PurchaseLine.NEXT = 0;
      END;
      EXIT(TotalAmount - TotalDiscountAmount);

Example

The below example is extracted from the test automation codeunit 134553 to show one way of using this function.

      // Setup
      Initialize;
      LibraryERM.CreatePaymentTermsDiscount(PaymentTerms,TRUE);
      CFHelper.GetDifferentDsctPaymentTerms(PaymentTermsCashFlow,PaymentTerms.Code);
      CFHelper.CreateCashFlowForecastConsiderDiscountAndCFPmtTerms(CashFlowForecast);
      RelationalExchangeRateAmount := LibraryRandom.RandDec(10,4);
      VendorNo := CreateVendorWithPaymentTerms(PaymentTerms.Code);
      ModifyVendorWithCashFlowPaymentTerms(VendorNo,PaymentTermsCashFlow.Code);
      ModifyVendorWithCurrency(VendorNo,CreateCurrencyWithExchangeRate(RelationalExchangeRateAmount));
      CreatePurchaseOrderWithLineCount(PurchaseHeader,VendorNo,2);
      ExpectedAmountLCY := -CFHelper.GetTotalAmountForPurchaseOrderWithCashFlowPaymentTermsDiscount(PurchaseHeader);

      // Excercise
      ConsiderSource[SourceType::"Purchase Orders"] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      VerifyExpectedCFAmount(ExpectedAmountLCY,PurchaseHeader."No.",SourceType::"Purchase Orders",CashFlowForecast."No.");
Member of Lib.Library - Cash Flow Helper


GetTotalAmountForSalesOrderWithCashFlowPaymentTermsDiscount@111 Method

The procedure GetTotalAmountForSalesOrderWithCashFlowPaymentTermsDiscount is available in codeunit 131332.

Syntax

GetTotalAmountForSalesOrderWithCashFlowPaymentTermsDiscount@111(
    SalesHeader@1000 : Record 36 SalesHeader //Input parameter of type Record
);

Parameters

SalesHeader
Input parameter of type Record

Return Value

Decimal

Remarks

The relevant search keywords are: Get, Total, Amount, For, Sales, Order, Cash, Flow, Payment, Terms, Discount.

For a clarification about how this function works, refer to the code listed below.

      Customer.GET(SalesHeader."Sell-to Customer No.");
      PaymentTermsCashFlow.GET(Customer."Cash Flow Payment Terms Code");
      TotalAmount := 0;
      TotalDiscountAmount := 0;
      SalesLine.SETRANGE("Document No.",SalesHeader."No.");
      SalesLine.SETRANGE("Document Type",SalesHeader."Document Type");
      IF SalesLine.FINDSET THEN BEGIN
        REPEAT
          LineAmount := SalesLine."Outstanding Amount (LCY)";
          TotalAmount += LineAmount;
          TotalDiscountAmount += CalculateDiscountAmount(LineAmount,PaymentTermsCashFlow."Discount %");
        UNTIL SalesLine.NEXT = 0;
      END;
      EXIT(TotalAmount - TotalDiscountAmount);

Example

The below example is extracted from the test automation codeunit 134553 to show one way of using this function.

      // Setup
      Initialize;
      LibraryERM.CreatePaymentTermsDiscount(PaymentTerms,TRUE);
      CFHelper.GetDifferentDsctPaymentTerms(PaymentTermsCashFlow,PaymentTerms.Code);
      CFHelper.CreateCashFlowForecastConsiderDiscountAndCFPmtTerms(CashFlowForecast);
      RelationalExchangeRateAmount := LibraryRandom.RandDec(10,4);
      CustomerNo := CreateCustomerWithPaymentTerms(PaymentTerms.Code);
      ModifyCustomerWithCashFlowPaymentTerms(CustomerNo,PaymentTermsCashFlow.Code);
      ModifyCustomerWithCurrency(CustomerNo,CreateCurrencyWithExchangeRate(RelationalExchangeRateAmount));
      CreateSalesOrderWithLineCount(SalesHeader,CustomerNo,2);
      ExpectedAmountLCY := CFHelper.GetTotalAmountForSalesOrderWithCashFlowPaymentTermsDiscount(SalesHeader);

      // Excercise
      ConsiderSource[SourceType::"Sales Orders"] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      VerifyExpectedCFAmount(ExpectedAmountLCY,SalesHeader."No.",SourceType::"Sales Orders",CashFlowForecast."No.");
Member of Lib.Library - Cash Flow Helper


GetTotalAmountForServiceOrderWithCashFlowPaymentTermsDiscount@103 Method

The procedure GetTotalAmountForServiceOrderWithCashFlowPaymentTermsDiscount is available in codeunit 131332.

Syntax

GetTotalAmountForServiceOrderWithCashFlowPaymentTermsDiscount@103(
    ServiceHeader@1000 : Record 5900 ServiceHeader //Input parameter of type Record
);

Parameters

ServiceHeader
Input parameter of type Record

Return Value

Decimal

Remarks

The relevant search keywords are: Get, Total, Amount, For, Service, Order, Cash, Flow, Payment, Terms, Discount.

For a clarification about how this function works, refer to the code listed below.

      Customer.GET(ServiceHeader."Bill-to Customer No.");
      PaymentTermsCashFlow.GET(Customer."Cash Flow Payment Terms Code");
      TotalAmount := 0;
      TotalDiscountAmount := 0;
      ServiceLine.SETRANGE("Document No.",ServiceHeader."No.");
      ServiceLine.SETRANGE("Document Type",ServiceHeader."Document Type");
      IF ServiceLine.FINDSET THEN BEGIN
        REPEAT
          LineAmount := ServiceLine."Outstanding Amount (LCY)";
          TotalAmount += LineAmount;
          TotalDiscountAmount += CalculateDiscountAmount(LineAmount,PaymentTermsCashFlow."Discount %");
        UNTIL ServiceLine.NEXT = 0;
      END;
      EXIT(TotalAmount - TotalDiscountAmount);

Example

The below example is extracted from the test automation codeunit 134553 to show one way of using this function.

      // Setup
      Initialize;
      LibraryERM.CreatePaymentTermsDiscount(PaymentTerms,TRUE);
      CFHelper.GetDifferentDsctPaymentTerms(PaymentTermsCashFlow,PaymentTerms.Code);
      CFHelper.CreateCashFlowForecastConsiderDiscountAndCFPmtTerms(CashFlowForecast);
      RelationalExchangeRateAmount := LibraryRandom.RandDec(10,4);
      CustomerNo := CreateCustomerWithPaymentTerms(PaymentTerms.Code);
      ModifyCustomerWithCashFlowPaymentTerms(CustomerNo,PaymentTermsCashFlow.Code);
      ModifyCustomerWithCurrency(CustomerNo,CreateCurrencyWithExchangeRate(RelationalExchangeRateAmount));
      CreateServiceOrderWithLineCount(ServiceHeader,CustomerNo,2);
      ExpectedAmountLCY := CFHelper.GetTotalAmountForServiceOrderWithCashFlowPaymentTermsDiscount(ServiceHeader);

      // Excercise
      ConsiderSource[SourceType::"Service Orders"] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      VerifyExpectedCFAmount(ExpectedAmountLCY,ServiceHeader."No.",SourceType::"Service Orders",CashFlowForecast."No.");
Member of Lib.Library - Cash Flow Helper


GetTotalPurchaseAmount@84 Method

The procedure GetTotalPurchaseAmount is available in codeunit 131332.

Syntax

GetTotalPurchaseAmount@84(
    PurchaseHeader@1000 : Record 38 PurchaseHeader, //Input parameter of type Record
    ConsiderDefaultPmtDiscount@1004 : Boolean ConsiderDefaultPmtDiscount //Input parameter of type Boolean
);

Parameters

PurchaseHeader
Input parameter of type Record
ConsiderDefaultPmtDiscount
Input parameter of type Boolean

Return Value

Decimal

Remarks

The relevant search keywords are: Get, Total, Purchase, Amount.

For a clarification about how this function works, refer to the code listed below.

      TotalAmount := 0;
      TotalDiscountAmount := 0;
      PurchaseLine.SETRANGE("Document No.",PurchaseHeader."No.");
      PurchaseLine.SETRANGE("Document Type",PurchaseHeader."Document Type");
      PurchaseLine.FINDSET;
      REPEAT
        LineAmount := PurchaseLine."Outstanding Amount (LCY)";
        TotalAmount += LineAmount;
        IF ConsiderDefaultPmtDiscount THEN
          TotalDiscountAmount += CalculateDiscountAmount(LineAmount,PurchaseHeader."Payment Discount %");
      UNTIL PurchaseLine.NEXT = 0;
      EXIT(TotalAmount - TotalDiscountAmount);

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // Test filling a CF journal by using Fill batch with a 3-line purchase order
      // and verify computed due and cash flow date

      // Setup
      Initialize;
      CFHelper.CreateCashFlowForecastDefault(CashFlowForecast);
      CFHelper.CreateDefaultPurchaseOrder(PurchaseHeader);

      // Exercise
      ConsiderSource[SourceType::"Purchase Orders"] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      CFHelper.VerifyCFDataOnSnglJnlLine(CFWorksheetLine,PurchaseHeader."No.",SourceType::"Purchase Orders",
        CashFlowForecast."No.",-CFHelper.GetTotalPurchaseAmount(PurchaseHeader,FALSE),PurchaseHeader."Due Date");
Member of Lib.Library - Cash Flow Helper


GetTotalSalesAmount@45 Method

The procedure GetTotalSalesAmount is available in codeunit 131332.

Syntax

GetTotalSalesAmount@45(
    SalesHeader@1000 : Record 36 SalesHeader, //Input parameter of type Record
    ConsiderDefaultPmtDiscount@1004 : Boolean ConsiderDefaultPmtDiscount //Input parameter of type Boolean
);

Parameters

SalesHeader
Input parameter of type Record
ConsiderDefaultPmtDiscount
Input parameter of type Boolean

Return Value

Decimal

Remarks

The relevant search keywords are: Get, Total, Sales, Amount.

For a clarification about how this function works, refer to the code listed below.

      TotalAmount := 0;
      TotalDiscountAmount := 0;
      SalesLine.SETRANGE("Document No.",SalesHeader."No.");
      SalesLine.SETRANGE("Document Type",SalesHeader."Document Type");
      SalesLine.FINDSET;
      REPEAT
        LineAmount := SalesLine."Outstanding Amount (LCY)";
        TotalAmount += LineAmount;
        IF ConsiderDefaultPmtDiscount THEN
          TotalDiscountAmount +=
            CalculateDiscountAmount(LineAmount,SalesHeader."Payment Discount %");
      UNTIL SalesLine.NEXT = 0;
      EXIT(TotalAmount - TotalDiscountAmount);

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // Test filling a CF journal by using Fill batch with a 3-line sales order
      // and verify computed due and cash flow date

      // Setup
      Initialize;
      CFHelper.CreateCashFlowForecastDefault(CashFlowForecast);
      CFHelper.CreateDefaultSalesOrder(SalesHeader);

      // Exercise
      ConsiderSource[SourceType::"Sales Orders"] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      CFHelper.VerifyCFDataOnSnglJnlLine(CFWorksheetLine,SalesHeader."No.",SourceType::"Sales Orders",
        CashFlowForecast."No.",CFHelper.GetTotalSalesAmount(SalesHeader,FALSE),SalesHeader."Due Date");
Member of Lib.Library - Cash Flow Helper


GetTotalServiceAmount@145 Method

The procedure GetTotalServiceAmount is available in codeunit 131332.

Syntax

GetTotalServiceAmount@145(
    ServiceHeader@1000 : Record 5900 ServiceHeader, //Input parameter of type Record
    ConsiderDefaultPmtDiscount@1004 : Boolean ConsiderDefaultPmtDiscount //Input parameter of type Boolean
);

Parameters

ServiceHeader
Input parameter of type Record
ConsiderDefaultPmtDiscount
Input parameter of type Boolean

Return Value

Decimal

Remarks

The relevant search keywords are: Get, Total, Service, Amount.

For a clarification about how this function works, refer to the code listed below.

      TotalAmount := 0;
      TotalDiscountAmount := 0;
      ServiceLine.SETRANGE("Document No.",ServiceHeader."No.");
      ServiceLine.SETRANGE("Document Type",ServiceHeader."Document Type");
      ServiceLine.FINDSET;
      REPEAT
        LineAmount := ServiceLine."Outstanding Amount (LCY)";
        TotalAmount += LineAmount;
        IF ConsiderDefaultPmtDiscount THEN
          TotalDiscountAmount +=
            CalculateDiscountAmount(LineAmount,ServiceHeader."Payment Discount %");
      UNTIL ServiceLine.NEXT = 0;

      EXIT(TotalAmount - TotalDiscountAmount);

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // Test filling a CF journal by using Fill batch with a 3-line service order
      // and verify computed due and cash flow date

      // Setup
      Initialize;
      CFHelper.CreateCashFlowForecastDefault(CashFlowForecast);
      CFHelper.CreateDefaultServiceOrder(ServiceHeader);

      // Exercise
      ConsiderSource[SourceType::"Service Orders"] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      CFHelper.VerifyCFDataOnSnglJnlLine(CFWorksheetLine,ServiceHeader."No.",SourceType::"Service Orders",
        CashFlowForecast."No.",CFHelper.GetTotalServiceAmount(ServiceHeader,FALSE),ServiceHeader."Document Date");
Member of Lib.Library - Cash Flow Helper


InsertCFLedgerEntry@69 Method

The procedure InsertCFLedgerEntry is available in codeunit 131332.

Syntax

InsertCFLedgerEntry@69(
    CFNo@1002 : Code[20] CFNo, //Input parameter of type Code
    AccountNo@1006 : Code[20] AccountNo, //Input parameter of type Code
    SourceType@1003 : Integer SourceType, //Input parameter of type Integer
    CFDate@1004 : Date CFDate, //Input parameter of type Date
    Amount@1005 : Decimal Amount //Input parameter of type Decimal
);

Parameters

CFNo
Input parameter of type Code
AccountNo
Input parameter of type Code
SourceType
Input parameter of type Integer
CFDate
Input parameter of type Date
Amount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Insert, Cash Flow, Ledger, Entry.

For a clarification about how this function works, refer to the code listed below.

      WITH CFForecastEntry DO BEGIN
        IF FINDLAST THEN
          EntryNo := "Entry No.";

        INIT;
        "Entry No." := EntryNo + 1;
        "Cash Flow Forecast No." := CFNo;
        "Source Type" := SourceType;
        IF AccountNo <> '' THEN
          "Cash Flow Account No." := AccountNo
        ELSE
          "Cash Flow Account No." := GetCFAccountNo(SourceType);
        "Cash Flow Date" := CFDate;
        VALIDATE("Amount (LCY)",Amount);
        INSERT;
      END;

Example

The below example is extracted from the test automation codeunit 134557 to show one way of using this function.

      Count := LibraryRandom.RandIntInRange(1,3);
      TotalAmount := 0;
      FOR i := 1 TO Count DO BEGIN
        Amount := LibraryRandom.RandDec(100,2);
        IF SourceType IN
           [CFForecastEntry."Source Type"::"Purchase Order",
            CFForecastEntry."Source Type"::"Cash Flow Manual Expense",
            CFForecastEntry."Source Type"::"Fixed Assets Budget",
            CFForecastEntry."Source Type"::Payables]
        THEN
          Amount := -Amount;

        LibraryCFHelper.InsertCFLedgerEntry(CashFlowNo,'',SourceType,CashFlowDate,Amount);
        TotalAmount += Amount;
      END;
Member of Lib.Library - Cash Flow Helper


PostPOPrepaymentInvoice@79 Method

The procedure PostPOPrepaymentInvoice is available in codeunit 131332.

Syntax

PostPOPrepaymentInvoice@79(
    VAR PurchaseHeader@1000 : Record 38 PurchaseHeader //Reference parameter of type Record
);

Parameters

PurchaseHeader
Reference parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Post, Purchase Order, Prepayment, Invoice.

For a clarification about how this function works, refer to the code listed below.

      PurchasePostPrepayments.Invoice(PurchaseHeader);
      EXIT(PurchaseHeader."Last Prepayment No.");

Example

There are no examples available.
Member of Lib.Library - Cash Flow Helper


PostSOPrepaymentInvoice@78 Method

The procedure PostSOPrepaymentInvoice is available in codeunit 131332.

Syntax

PostSOPrepaymentInvoice@78(
    VAR SalesHeader@1000 : Record 36 SalesHeader //Reference parameter of type Record
);

Parameters

SalesHeader
Reference parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Post, Sales Order, Prepayment, Invoice.

For a clarification about how this function works, refer to the code listed below.

      SalesPostPrepayments.Invoice(SalesHeader);
      EXIT(SalesHeader."Last Prepayment No.");

Example

There are no examples available.
Member of Lib.Library - Cash Flow Helper


SelectAndClearGenJournalBatch@46 Method

The procedure SelectAndClearGenJournalBatch is available in codeunit 131332.

Syntax

SelectAndClearGenJournalBatch@46(
    VAR GenJournalBatch@1000 : Record 232 GenJournalBatch //Reference parameter of type Record
);

Parameters

GenJournalBatch
Reference parameter of type Record

Remarks

The relevant search keywords are: Select, Clear, General, Journal, Batch.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.SelectGenJnlBatch(GenJournalBatch);
      LibraryERM.ClearGenJournalLines(GenJournalBatch)

Example

There are no examples available.
Member of Lib.Library - Cash Flow Helper


SetDefaultDepreciationBook@23 Method

The procedure SetDefaultDepreciationBook is available in codeunit 131332.

Syntax

SetDefaultDepreciationBook@23(
    DepreciationBookCode@1000 : Code[10] DepreciationBookCode //Input parameter of type Code
);

Parameters

DepreciationBookCode
Input parameter of type Code

Remarks

The relevant search keywords are: Set, Default, Depreciation, Book.

For a clarification about how this function works, refer to the code listed below.

      FASetup.GET;

      FASetup.VALIDATE("Default Depr. Book",DepreciationBookCode);
      FASetup.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - Cash Flow Helper


SetExpectedDsctAPmtTermValues@47 Method

The procedure SetExpectedDsctAPmtTermValues is available in codeunit 131332.

Syntax

SetExpectedDsctAPmtTermValues@47(
    DocType@1004 : Option DocType, //Input parameter of type Option
    DocumentNo@1008 : Code[20] DocumentNo, //Input parameter of type Code
    PartnerNo@1009 : Code[20] PartnerNo, //Input parameter of type Code
    CFSourceDate@1010 : Date CFSourceDate, //Input parameter of type Date
    ConsiderDsctAndCFPmtTerms@1003 : Boolean ConsiderDsctAndCFPmtTerms, //Input parameter of type Boolean
    VAR ExpectedCFDate@1001 : Date ExpectedCFDate, //Reference parameter of type Date
    VAR ExpectedAmount@1000 : Decimal ExpectedAmount //Reference parameter of type Decimal
);

Parameters

DocType
Input parameter of type Option
DocumentNo
Input parameter of type Code
PartnerNo
Input parameter of type Code
CFSourceDate
Input parameter of type Date
ConsiderDsctAndCFPmtTerms
Input parameter of type Boolean
ExpectedCFDate
Reference parameter of type Date
ExpectedAmount
Reference parameter of type Decimal

Remarks

The relevant search keywords are: Set, Expected, Dsct, A, Payment, Term, Values.

For a clarification about how this function works, refer to the code listed below.

      CASE DocType OF
        DocumentType::Sale:
          BEGIN
            SalesHeader.GET(SalesHeader."Document Type"::Order,DocumentNo);
            FindCustomerCFPaymentTerms(PaymentTerms,PartnerNo);
            TotalAmount := GetTotalSalesAmount(SalesHeader,FALSE);
          END;
        DocumentType::Service:
          BEGIN
            ServiceHeader.GET(ServiceHeader."Document Type"::Order,DocumentNo);
            FindCustomerCFPaymentTerms(PaymentTerms,PartnerNo);
            TotalAmount := GetTotalServiceAmount(ServiceHeader,FALSE);
          END;
        DocumentType::Purchase:
          BEGIN
            Vendor.GET(PartnerNo);
            PaymentTerms.GET(Vendor."Cash Flow Payment Terms Code");
            PurchaseHeader.GET(PurchaseHeader."Document Type"::Order,DocumentNo);
            TotalAmount := GetTotalPurchaseAmount(PurchaseHeader,FALSE);
          END;
        ELSE
          ERROR(UnhandledDocumentType);
      END;

      IF ConsiderDsctAndCFPmtTerms THEN BEGIN
        ExpectedCFDate := CALCDATE(PaymentTerms."Discount Date Calculation",CFSourceDate);
        ExpectedAmount := TotalAmount - CalculateDiscountAmount(TotalAmount,PaymentTerms."Discount %");
      END ELSE BEGIN
        ExpectedCFDate := CALCDATE(PaymentTerms."Due Date Calculation",CFSourceDate);
        ExpectedAmount := TotalAmount;
      END;

      IF DocType = DocumentType::Purchase THEN
        ExpectedAmount *= -1;

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // Test filling a CF journal by using Fill batch with a 3-line sales order where customer has
      // CF payment terms set. Verify computed due and cash flow date and discounted amount

      // Setup
      Initialize;
      CFHelper.CreateCashFlowForecastConsiderCFPmtTerms(CashFlowForecast);
      LibraryERM.GetDiscountPaymentTerm(PaymentTerms);
      CFHelper.CreateSpecificSalesOrder(SalesHeader,'',PaymentTerms.Code);
      // set expected values considering only CF payment terms
      CFHelper.SetExpectedDsctAPmtTermValues(DocumentType::Sale,SalesHeader."No.",
        SalesHeader."Sell-to Customer No.",SalesHeader."Document Date",FALSE,
        ExpectedCFDate,ExpectedAmount);

      // Exercise
      ConsiderSource[SourceType::"Sales Orders"] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify - passing 0 as expected discount amount since discount is not considered on the CF card
      CFHelper.VerifyCFDataOnSnglJnlLine(CFWorksheetLine,SalesHeader."No.",SourceType::"Sales Orders",
        CashFlowForecast."No.",ExpectedAmount,ExpectedCFDate);
Member of Lib.Library - Cash Flow Helper


SetPmtToleranceOptionsOnCashFlowForecast@60 Method

The procedure SetPmtToleranceOptionsOnCashFlowForecast is available in codeunit 131332.

Syntax

SetPmtToleranceOptionsOnCashFlowForecast@60(
    VAR CashFlowForecast@1000 : Record 840 CashFlowForecast, //Reference parameter of type Record
    ConsiderPmtDiscTolDate@1001 : Boolean ConsiderPmtDiscTolDate, //Input parameter of type Boolean
    ConsiderPmtTolAmount@1002 : Boolean ConsiderPmtTolAmount //Input parameter of type Boolean
);

Parameters

CashFlowForecast
Reference parameter of type Record
ConsiderPmtDiscTolDate
Input parameter of type Boolean
ConsiderPmtTolAmount
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, Payment, Tolerance, Options, On, Cash, Flow, Forecast.

For a clarification about how this function works, refer to the code listed below.

      CashFlowForecast.VALIDATE("Consider Pmt. Disc. Tol. Date",ConsiderPmtDiscTolDate);
      CashFlowForecast.VALIDATE("Consider Pmt. Tol. Amount",ConsiderPmtTolAmount);
      CashFlowForecast.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // Test filling a CF journal by using Fill batch with a 3-line sales order
      // and a payment discount grace period set. Verify computed due and cash flow date and discounted amount

      // Setup
      Initialize;
      CFHelper.CreateCashFlowForecastConsiderDiscount(CashFlowForecast);
      CFHelper.SetPmtToleranceOptionsOnCashFlowForecast(CashFlowForecast,TRUE,FALSE);
      GeneralLedgerSetup.GET;
      CFHelper.CreateRandomDateFormula(PmtDiscountGracePeriod);
      CFHelper.SetupPmtDsctGracePeriod(PmtDiscountGracePeriod);
      LibraryERM.GetDiscountPaymentTerm(PaymentTerms);
      CFHelper.CreateSpecificSalesOrder(SalesHeader,PaymentTerms.Code,'');
      ExpectedCFDate :=
        CALCDATE(PaymentTerms."Discount Date Calculation",
          CALCDATE(PmtDiscountGracePeriod,SalesHeader."Document Date"));

      // Exercise
      ConsiderSource[SourceType::"Sales Orders"] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      CFHelper.FilterSingleJournalLine(CFWorksheetLine,SalesHeader."No.",SourceType::"Sales Orders",CashFlowForecast."No.");
      CFHelper.VerifyCFDateOnCFJnlLine(CFWorksheetLine,ExpectedCFDate);

      // Tear down
      CFHelper.SetupPmtDsctGracePeriod(GeneralLedgerSetup."Payment Discount Grace Period");
Member of Lib.Library - Cash Flow Helper


SetupCustomerPmtTolAmtTestCase@71 Method

The procedure SetupCustomerPmtTolAmtTestCase is available in codeunit 131332.

Syntax

SetupCustomerPmtTolAmtTestCase@71(
    VAR CashFlowForecast@1000 : Record 840 CashFlowForecast, //Reference parameter of type Record
    VAR Customer@1002 : Record 18 Customer, //Reference parameter of type Record
    VAR Amount@1003 : Decimal Amount, //Reference parameter of type Decimal
    PmtTolAmtPercentMultiplier@1004 : Decimal PmtTolAmtPercentMultiplier, //Input parameter of type Decimal
    PmtTolPercentage@1005 : Decimal PmtTolPercentage //Input parameter of type Decimal
);

Parameters

CashFlowForecast
Reference parameter of type Record
Customer
Reference parameter of type Record
Amount
Reference parameter of type Decimal
PmtTolAmtPercentMultiplier
Input parameter of type Decimal
PmtTolPercentage
Input parameter of type Decimal

Remarks

The relevant search keywords are: Setup, Customer, Payment, Tolerance, Amt, Test, Case.

For a clarification about how this function works, refer to the code listed below.

      LibrarySales.CreateCustomer(Customer);
      SetupPmtTolAmtTestCase(CashFlowForecast,Amount,PmtTolAmtPercentMultiplier,PmtTolPercentage);

Example

The below example is extracted from the test automation codeunit 134553 to show one way of using this function.

      // Test filling a CF journal using Fill batch considering Pmt. Tol. Amount
      // The payment amount for the invoice should be within the tolerance amount, which leads to a closed
      // ledger entry and therefore there must not be a CF forecast consideration

      // Setup
      Initialize;
      GeneralLedgerSetup.GET; // keep current setup
      // max pmt tol amount should be 50% of the invoice amount
      CFHelper.SetupCustomerPmtTolAmtTestCase(CashFlowForecast,Customer,Amount,0.5,50);
      CFHelper.CreateAndApplySalesInvPayment(GenJournalLine,Customer."No.",Amount,
        -(Amount - ROUND(Amount * 0.5)),EmptyDateFormula,EmptyDateFormula,EmptyDateFormula);

      // Exercise
      ConsiderSource[SourceType::Receivables] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      // No CF lines expected
      Assert.AreEqual(0,
        CFHelper.FilterSingleJournalLine(CFWorksheetLine,GenJournalLine."Document No.",SourceType::Receivables,CashFlowForecast."No."),
        STRSUBSTNO(UnexpectedCFWorksheetLineCountErr,CashFlowForecast."No.",GenJournalLine."Document No."));

      // Tear down
      CFHelper.SetupPmtTolPercentage(GeneralLedgerSetup."Payment Tolerance %");
      CFHelper.SetupPmtTolAmount(GeneralLedgerSetup."Max. Payment Tolerance Amount");
Member of Lib.Library - Cash Flow Helper


SetupDsctPmtTermsCustLETest@15 Method

The procedure SetupDsctPmtTermsCustLETest is available in codeunit 131332.

Syntax

SetupDsctPmtTermsCustLETest@15(
    VAR CashFlowForecast@1006 : Record 840 CashFlowForecast, //Reference parameter of type Record
    VAR Customer@1005 : Record 18 Customer, //Reference parameter of type Record
    VAR PaymentTerms@1003 : Record 3 PaymentTerms, //Reference parameter of type Record
    VAR Amount@1001 : Decimal Amount, //Reference parameter of type Decimal
    VAR DiscountedAmount@1000 : Decimal DiscountedAmount //Reference parameter of type Decimal
);

Parameters

CashFlowForecast
Reference parameter of type Record
Customer
Reference parameter of type Record
PaymentTerms
Reference parameter of type Record
Amount
Reference parameter of type Decimal
DiscountedAmount
Reference parameter of type Decimal

Remarks

The relevant search keywords are: Setup, Dsct, Payment, Terms, Customer, LE, Test.

For a clarification about how this function works, refer to the code listed below.

      CreateCashFlowForecastConsiderDiscountAndCFPmtTerms(CashFlowForecast);
      CreateCustWithCFDsctPmtTerm(Customer,PaymentTerms);
      Amount := LibraryRandom.RandDec(2000,2);
      DiscountedAmount := Amount - CalculateDiscountAmount(Amount,PaymentTerms."Discount %");

Example

The below example is extracted from the test automation codeunit 134553 to show one way of using this function.

      // Test filling a CF journal using Fill batch considering discount CF Payment Terms
      // This scenario covers a discounted payment AFTER the payment discount date,
      // therefore the expected CF amount is the remaining amount (total amount - discounted amount)
      // the CF date should be the due date

      // Setup
      Initialize;
      CFHelper.SetupDsctPmtTermsCustLETest(CashFlowForecast,Customer,PaymentTerms,Amount,DiscountedAmount);
      // payment is done 1 day after discount date in order to be overdue
      CustomDateFormula := PlusOneDayFormula;
      CFHelper.CreateAndApplySalesInvPayment(GenJournalLine,Customer."No.",Amount,-DiscountedAmount,
        PaymentTerms."Discount Date Calculation",EmptyDateFormula,CustomDateFormula);
      LibraryERM.FindCustomerLedgerEntry(CustLedgerEntry,GenJournalLine."Document Type"::Invoice,GenJournalLine."Document No.");

      // Exercise
      // forecast is calculated after the discount date, payment already done
      ConsiderSource[SourceType::Receivables] := TRUE;
      CFHelper.FillJnlOnCertDateFormulas(ConsiderSource,CashFlowForecast."No.",PaymentTerms."Discount Date Calculation",
        EmptyDateFormula,CustomDateFormula);

      // Verify
      CFHelper.VerifyCFDataOnSnglJnlLine(CFWorksheetLine,GenJournalLine."Document No.",SourceType::Receivables,
        CashFlowForecast."No.",Amount - DiscountedAmount,CALCDATE(PaymentTerms."Due Date Calculation",CustLedgerEntry."Document Date"));
Member of Lib.Library - Cash Flow Helper


SetupPmtDsctGracePeriod@64 Method

The procedure SetupPmtDsctGracePeriod is available in codeunit 131332.

Syntax

SetupPmtDsctGracePeriod@64(
    NewDscGracePeriodFormula@1002 : DateFormula NewDscGracePeriodFormula //Input parameter of type DateFormula
);

Parameters

NewDscGracePeriodFormula
Input parameter of type DateFormula

Remarks

The relevant search keywords are: Setup, Payment, Dsct, Grace, Period.

For a clarification about how this function works, refer to the code listed below.

      GeneralLedgerSetup.GET;
      GeneralLedgerSetup.VALIDATE("Payment Discount Grace Period",NewDscGracePeriodFormula);
      GeneralLedgerSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // Test filling a CF journal by using Fill batch with a 3-line sales order
      // and a payment discount grace period set. Verify computed due and cash flow date and discounted amount

      // Setup
      Initialize;
      CFHelper.CreateCashFlowForecastConsiderDiscount(CashFlowForecast);
      CFHelper.SetPmtToleranceOptionsOnCashFlowForecast(CashFlowForecast,TRUE,FALSE);
      GeneralLedgerSetup.GET;
      CFHelper.CreateRandomDateFormula(PmtDiscountGracePeriod);
      CFHelper.SetupPmtDsctGracePeriod(PmtDiscountGracePeriod);
      LibraryERM.GetDiscountPaymentTerm(PaymentTerms);
      CFHelper.CreateSpecificSalesOrder(SalesHeader,PaymentTerms.Code,'');
      ExpectedCFDate :=
        CALCDATE(PaymentTerms."Discount Date Calculation",
          CALCDATE(PmtDiscountGracePeriod,SalesHeader."Document Date"));

      // Exercise
      ConsiderSource[SourceType::"Sales Orders"] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      CFHelper.FilterSingleJournalLine(CFWorksheetLine,SalesHeader."No.",SourceType::"Sales Orders",CashFlowForecast."No.");
      CFHelper.VerifyCFDateOnCFJnlLine(CFWorksheetLine,ExpectedCFDate);

      // Tear down
      CFHelper.SetupPmtDsctGracePeriod(GeneralLedgerSetup."Payment Discount Grace Period");
Member of Lib.Library - Cash Flow Helper


SetupPmtDsctTolCustLETest@76 Method

The procedure SetupPmtDsctTolCustLETest is available in codeunit 131332.

Syntax

SetupPmtDsctTolCustLETest@76(
    VAR CashFlowForecast@1000 : Record 840 CashFlowForecast, //Reference parameter of type Record
    VAR Customer@1001 : Record 18 Customer, //Reference parameter of type Record
    VAR PaymentTerms@1003 : Record 3 PaymentTerms, //Reference parameter of type Record
    NewPmtDiscountGracePeriod@1002 : DateFormula NewPmtDiscountGracePeriod, //Input parameter of type DateFormula
    VAR Amount@1005 : Decimal Amount, //Reference parameter of type Decimal
    VAR DiscountedAmount@1006 : Decimal DiscountedAmount //Reference parameter of type Decimal
);

Parameters

CashFlowForecast
Reference parameter of type Record
Customer
Reference parameter of type Record
PaymentTerms
Reference parameter of type Record
NewPmtDiscountGracePeriod
Input parameter of type DateFormula
Amount
Reference parameter of type Decimal
DiscountedAmount
Reference parameter of type Decimal

Remarks

The relevant search keywords are: Setup, Payment, Dsct, Tolerance, Customer, LE, Test.

For a clarification about how this function works, refer to the code listed below.

      CreateCashFlowForecastConsiderDiscountAndCFPmtTerms(CashFlowForecast);
      SetPmtToleranceOptionsOnCashFlowForecast(CashFlowForecast,TRUE,FALSE);
      SetupPmtDsctGracePeriod(NewPmtDiscountGracePeriod);
      CreateCustWithCFDsctPmtTerm(Customer,PaymentTerms);
      Amount := LibraryRandom.RandDec(2000,2);
      DiscountedAmount := Amount - CalculateDiscountAmount(Amount,PaymentTerms."Discount %");

Example

The below example is extracted from the test automation codeunit 134553 to show one way of using this function.

      // Test filling a CF journal using Fill batch considering discount, CF pmt terms and payment discount tolerance date
      // Covers an opened customer ledger entry w/o payment where the CF forecast is done within the tolerance period
      // The expected CF amount must be the discounted total amount,
      // the CF date must be the calculated discount date + tolerance, based on the ledger entries document date

      // Setup
      Initialize;
      GeneralLedgerSetup.GET; // keep current setup
      CFHelper.CreateRandomDateFormula(CustomDateFormula); // used as pmt discount grace period
      CFHelper.SetupPmtDsctTolCustLETest(CashFlowForecast,Customer,PaymentTerms,CustomDateFormula,Amount,DiscountedAmount);
      CFHelper.CreateLedgerEntry(GenJournalLine,Customer."No.",Amount,
        GenJournalLine."Account Type"::Customer,GenJournalLine."Document Type"::Invoice);

      // Exercise
      ConsiderSource[SourceType::Receivables] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      CFHelper.VerifyCFDataOnSnglJnlLine(CFWorksheetLine,GenJournalLine."Document No.",SourceType::Receivables,CashFlowForecast."No.",
        Amount - CFHelper.CalcDiscAmtFromGenJnlLine(GenJournalLine,PaymentTerms."Discount %"),
        CALCDATE(CustomDateFormula,
          CALCDATE(PaymentTerms."Discount Date Calculation",GenJournalLine."Document Date")));

      // Tear down
      CFHelper.SetupPmtDsctGracePeriod(GeneralLedgerSetup."Payment Discount Grace Period");
Member of Lib.Library - Cash Flow Helper


SetupPmtDsctTolVendorLETest@21 Method

The procedure SetupPmtDsctTolVendorLETest is available in codeunit 131332.

Syntax

SetupPmtDsctTolVendorLETest@21(
    VAR CashFlowForecast@1000 : Record 840 CashFlowForecast, //Reference parameter of type Record
    VAR Vendor@1001 : Record 23 Vendor, //Reference parameter of type Record
    VAR PaymentTerms@1003 : Record 3 PaymentTerms, //Reference parameter of type Record
    NewPmtDiscountGracePeriod@1002 : DateFormula NewPmtDiscountGracePeriod, //Input parameter of type DateFormula
    VAR Amount@1005 : Decimal Amount, //Reference parameter of type Decimal
    VAR DiscountedAmount@1006 : Decimal DiscountedAmount //Reference parameter of type Decimal
);

Parameters

CashFlowForecast
Reference parameter of type Record
Vendor
Reference parameter of type Record
PaymentTerms
Reference parameter of type Record
NewPmtDiscountGracePeriod
Input parameter of type DateFormula
Amount
Reference parameter of type Decimal
DiscountedAmount
Reference parameter of type Decimal

Remarks

The relevant search keywords are: Setup, Payment, Dsct, Tolerance, Vendor, LE, Test.

For a clarification about how this function works, refer to the code listed below.

      CreateCashFlowForecastConsiderDiscountAndCFPmtTerms(CashFlowForecast);
      SetPmtToleranceOptionsOnCashFlowForecast(CashFlowForecast,TRUE,FALSE);
      SetupPmtDsctGracePeriod(NewPmtDiscountGracePeriod);
      CreateVendorWithCFDsctPmtTerm(Vendor,PaymentTerms);
      Amount := LibraryRandom.RandDec(2000,2);
      DiscountedAmount := Amount - CalculateDiscountAmount(Amount,PaymentTerms."Discount %");

Example

The below example is extracted from the test automation codeunit 134553 to show one way of using this function.

      // Test filling a CF journal using Fill batch considering discount, CF pmt terms and payment discount tolerance date
      // Covers an opened vendor ledger entry w/o payment where the CF forecast is done within the discount period
      // The expected CF amount must be the discounted total amount,
      // the CF date must be the calculated discount date + tolerance, based on the ledger entries document date

      // Setup
      Initialize;
      GeneralLedgerSetup.GET; // keep current setup
      CFHelper.CreateRandomDateFormula(PmtDiscountGracePeriod);
      CFHelper.SetupPmtDsctTolVendorLETest(CashFlowForecast,Vendor,PaymentTerms,PmtDiscountGracePeriod,Amount,DiscountedAmount);
      CFHelper.CreateLedgerEntry(GenJournalLine,Vendor."No.",-Amount,
        GenJournalLine."Account Type"::Vendor,GenJournalLine."Document Type"::Invoice);

      // Exercise
      ConsiderSource[SourceType::Payables] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      CFHelper.VerifyCFDataOnSnglJnlLine(CFWorksheetLine,GenJournalLine."Document No.",SourceType::Payables,CashFlowForecast."No.",
        -(Amount - CFHelper.CalcDiscAmtFromGenJnlLine(GenJournalLine,PaymentTerms."Discount %")),
        CALCDATE(PmtDiscountGracePeriod,
          CALCDATE(PaymentTerms."Discount Date Calculation",GenJournalLine."Document Date")));

      // Tear down
      CFHelper.SetupPmtDsctGracePeriod(GeneralLedgerSetup."Payment Discount Grace Period");
Member of Lib.Library - Cash Flow Helper


SetupPmtTolAmount@10 Method

The procedure SetupPmtTolAmount is available in codeunit 131332.

Syntax

SetupPmtTolAmount@10(
    NewPmtTolAmount@1004 : Decimal NewPmtTolAmount //Input parameter of type Decimal
);

Parameters

NewPmtTolAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Setup, Payment, Tolerance, Amount.

For a clarification about how this function works, refer to the code listed below.

      GeneralLedgerSetup.GET;
      GeneralLedgerSetup.VALIDATE("Max. Payment Tolerance Amount",NewPmtTolAmount);
      GeneralLedgerSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134553 to show one way of using this function.

      // Test filling a CF journal using Fill batch considering Pmt. Tol. Amount
      // The payment amount for the invoice should be within the tolerance amount, which leads to a closed
      // ledger entry and therefore there must not be a CF forecast consideration

      // Setup
      Initialize;
      GeneralLedgerSetup.GET; // keep current setup
      // max pmt tol amount should be 50% of the invoice amount
      CFHelper.SetupCustomerPmtTolAmtTestCase(CashFlowForecast,Customer,Amount,0.5,50);
      CFHelper.CreateAndApplySalesInvPayment(GenJournalLine,Customer."No.",Amount,
        -(Amount - ROUND(Amount * 0.5)),EmptyDateFormula,EmptyDateFormula,EmptyDateFormula);

      // Exercise
      ConsiderSource[SourceType::Receivables] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      // No CF lines expected
      Assert.AreEqual(0,
        CFHelper.FilterSingleJournalLine(CFWorksheetLine,GenJournalLine."Document No.",SourceType::Receivables,CashFlowForecast."No."),
        STRSUBSTNO(UnexpectedCFWorksheetLineCountErr,CashFlowForecast."No.",GenJournalLine."Document No."));

      // Tear down
      CFHelper.SetupPmtTolPercentage(GeneralLedgerSetup."Payment Tolerance %");
      CFHelper.SetupPmtTolAmount(GeneralLedgerSetup."Max. Payment Tolerance Amount");
Member of Lib.Library - Cash Flow Helper


SetupPmtTolPercentage@9 Method

The procedure SetupPmtTolPercentage is available in codeunit 131332.

Syntax

SetupPmtTolPercentage@9(
    NewPmtTolPercentage@1003 : Decimal NewPmtTolPercentage //Input parameter of type Decimal
);

Parameters

NewPmtTolPercentage
Input parameter of type Decimal

Remarks

The relevant search keywords are: Setup, Payment, Tolerance, Percentage.

For a clarification about how this function works, refer to the code listed below.

      GeneralLedgerSetup.GET;
      GeneralLedgerSetup.VALIDATE("Payment Tolerance %",NewPmtTolPercentage);
      GeneralLedgerSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134553 to show one way of using this function.

      // Test filling a CF journal using Fill batch considering Pmt. Tol. Amount
      // The payment amount for the invoice should be within the tolerance amount, which leads to a closed
      // ledger entry and therefore there must not be a CF forecast consideration

      // Setup
      Initialize;
      GeneralLedgerSetup.GET; // keep current setup
      // max pmt tol amount should be 50% of the invoice amount
      CFHelper.SetupCustomerPmtTolAmtTestCase(CashFlowForecast,Customer,Amount,0.5,50);
      CFHelper.CreateAndApplySalesInvPayment(GenJournalLine,Customer."No.",Amount,
        -(Amount - ROUND(Amount * 0.5)),EmptyDateFormula,EmptyDateFormula,EmptyDateFormula);

      // Exercise
      ConsiderSource[SourceType::Receivables] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      // No CF lines expected
      Assert.AreEqual(0,
        CFHelper.FilterSingleJournalLine(CFWorksheetLine,GenJournalLine."Document No.",SourceType::Receivables,CashFlowForecast."No."),
        STRSUBSTNO(UnexpectedCFWorksheetLineCountErr,CashFlowForecast."No.",GenJournalLine."Document No."));

      // Tear down
      CFHelper.SetupPmtTolPercentage(GeneralLedgerSetup."Payment Tolerance %");
      CFHelper.SetupPmtTolAmount(GeneralLedgerSetup."Max. Payment Tolerance Amount");
Member of Lib.Library - Cash Flow Helper


SetupVendorPmtTolAmtTestCase@18 Method

The procedure SetupVendorPmtTolAmtTestCase is available in codeunit 131332.

Syntax

SetupVendorPmtTolAmtTestCase@18(
    VAR CashFlowForecast@1000 : Record 840 CashFlowForecast, //Reference parameter of type Record
    VAR Vendor@1002 : Record 23 Vendor, //Reference parameter of type Record
    VAR Amount@1003 : Decimal Amount, //Reference parameter of type Decimal
    PmtTolAmtPercentMultiplier@1004 : Decimal PmtTolAmtPercentMultiplier, //Input parameter of type Decimal
    PmtTolPercentage@1005 : Decimal PmtTolPercentage //Input parameter of type Decimal
);

Parameters

CashFlowForecast
Reference parameter of type Record
Vendor
Reference parameter of type Record
Amount
Reference parameter of type Decimal
PmtTolAmtPercentMultiplier
Input parameter of type Decimal
PmtTolPercentage
Input parameter of type Decimal

Remarks

The relevant search keywords are: Setup, Vendor, Payment, Tolerance, Amt, Test, Case.

For a clarification about how this function works, refer to the code listed below.

      LibraryPurchase.CreateVendor(Vendor);
      SetupPmtTolAmtTestCase(CashFlowForecast,Amount,PmtTolAmtPercentMultiplier,PmtTolPercentage);

Example

The below example is extracted from the test automation codeunit 134553 to show one way of using this function.

      // Test filling a CF journal using Fill batch considering Pmt. Tol. Amount
      // The payment amount for the invoice should be within the tolerance amount, which leads to a closed
      // ledger entry and therefore there must not be a CF forecast consideration

      // Setup
      Initialize;
      GeneralLedgerSetup.GET; // keep current setup
      // max pmt tol amount should be 50% of the invoice amount
      LibraryCashFlowForecast.ClearJournal;
      CFHelper.SetupVendorPmtTolAmtTestCase(CashFlowForecast,Vendor,Amount,0.5,50);
      CFHelper.CreateAndApplyVendorInvPmt(GenJournalLine,Vendor."No.",-Amount,
        Amount - ROUND(Amount * 0.5 / 100),EmptyDateFormula,EmptyDateFormula,EmptyDateFormula);

      // Exercise
      ConsiderSource[SourceType::Payables] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      // No CF lines expected
      Assert.AreEqual(0,
        CFHelper.FilterSingleJournalLine(CFWorksheetLine,GenJournalLine."Document No.",SourceType::Payables,CashFlowForecast."No."),
        STRSUBSTNO(UnexpectedCFWorksheetLineCountErr,CashFlowForecast."No.",GenJournalLine."Document No."));

      // Tear down
      CFHelper.SetupPmtTolPercentage(GeneralLedgerSetup."Payment Tolerance %");
      CFHelper.SetupPmtTolAmount(GeneralLedgerSetup."Max. Payment Tolerance Amount");
Member of Lib.Library - Cash Flow Helper


UpdateDueDateOnCustomerLedgerEntry@34 Method

The procedure UpdateDueDateOnCustomerLedgerEntry is available in codeunit 131332.

Syntax

UpdateDueDateOnCustomerLedgerEntry@34(
    VAR CustLedgerEntry@1000 : Record 21 CustLedgerEntry //Reference parameter of type Record
);

Parameters

CustLedgerEntry
Reference parameter of type Record

Remarks

The relevant search keywords are: Update, Due, Date, On, Customer, Ledger, Entry.

For a clarification about how this function works, refer to the code listed below.

      CustLedgerEntry.VALIDATE("Due Date",GetAnyDateAfter(CustLedgerEntry."Due Date"));
      CustLedgerEntry.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      LibraryERM.FindCustomerLedgerEntry(CustLedgerEntry,DocumentType,DocumentNo);
      IF DateField = DateFieldOption::DueDate THEN BEGIN
        CFHelper.UpdateDueDateOnCustomerLedgerEntry(CustLedgerEntry);
        ExpectedDate := CustLedgerEntry."Due Date";
      END ELSE BEGIN
        IF DateField = DateFieldOption::DiscountDate THEN BEGIN
          CFHelper.UpdatePmtDiscountDateOnCustomerLedgerEntry(CustLedgerEntry);
          ExpectedDate := CustLedgerEntry."Pmt. Discount Date";
        END ELSE
          ERROR(STRSUBSTNO(UnsupportedDateField,DateField));
      END;
Member of Lib.Library - Cash Flow Helper


UpdateDueDateOnVendorLedgerEntry@72 Method

The procedure UpdateDueDateOnVendorLedgerEntry is available in codeunit 131332.

Syntax

UpdateDueDateOnVendorLedgerEntry@72(
    VAR VendorLedgerEntry@1000 : Record 25 VendorLedgerEntry //Reference parameter of type Record
);

Parameters

VendorLedgerEntry
Reference parameter of type Record

Remarks

The relevant search keywords are: Update, Due, Date, On, Vendor, Ledger, Entry.

For a clarification about how this function works, refer to the code listed below.

      VendorLedgerEntry.VALIDATE("Due Date",GetAnyDateAfter(VendorLedgerEntry."Due Date"));
      VendorLedgerEntry.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      LibraryERM.FindVendorLedgerEntry(VendorLedgerEntry,DocumentType,DocumentNo);
      IF DateField = DateFieldOption::DueDate THEN BEGIN
        CFHelper.UpdateDueDateOnVendorLedgerEntry(VendorLedgerEntry);
        ExpectedDate := VendorLedgerEntry."Due Date";
      END ELSE BEGIN
        IF DateField = DateFieldOption::DiscountDate THEN BEGIN
          CFHelper.UpdatePmtDiscountDateOnVendorLedgerEntry(VendorLedgerEntry);
          ExpectedDate := VendorLedgerEntry."Pmt. Discount Date";
        END ELSE
          ERROR(STRSUBSTNO(UnsupportedDateField,DateField));
      END;
Member of Lib.Library - Cash Flow Helper


UpdatePmtDiscountDateOnCustomerLedgerEntry@70 Method

The procedure UpdatePmtDiscountDateOnCustomerLedgerEntry is available in codeunit 131332.

Syntax

UpdatePmtDiscountDateOnCustomerLedgerEntry@70(
    VAR CustLedgerEntry@1000 : Record 21 CustLedgerEntry //Reference parameter of type Record
);

Parameters

CustLedgerEntry
Reference parameter of type Record

Remarks

The relevant search keywords are: Update, Payment, Discount, Date, On, Customer, Ledger, Entry.

For a clarification about how this function works, refer to the code listed below.

      CustLedgerEntry.VALIDATE("Pmt. Discount Date",GetAnyDateAfter(CustLedgerEntry."Pmt. Discount Date"));
      CustLedgerEntry.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      LibraryERM.FindCustomerLedgerEntry(CustLedgerEntry,DocumentType,DocumentNo);
      IF DateField = DateFieldOption::DueDate THEN BEGIN
        CFHelper.UpdateDueDateOnCustomerLedgerEntry(CustLedgerEntry);
        ExpectedDate := CustLedgerEntry."Due Date";
      END ELSE BEGIN
        IF DateField = DateFieldOption::DiscountDate THEN BEGIN
          CFHelper.UpdatePmtDiscountDateOnCustomerLedgerEntry(CustLedgerEntry);
          ExpectedDate := CustLedgerEntry."Pmt. Discount Date";
        END ELSE
          ERROR(STRSUBSTNO(UnsupportedDateField,DateField));
      END;
Member of Lib.Library - Cash Flow Helper


UpdatePmtDiscountDateOnVendorLedgerEntry@74 Method

The procedure UpdatePmtDiscountDateOnVendorLedgerEntry is available in codeunit 131332.

Syntax

UpdatePmtDiscountDateOnVendorLedgerEntry@74(
    VAR VendorLedgerEntry@1000 : Record 25 VendorLedgerEntry //Reference parameter of type Record
);

Parameters

VendorLedgerEntry
Reference parameter of type Record

Remarks

The relevant search keywords are: Update, Payment, Discount, Date, On, Vendor, Ledger, Entry.

For a clarification about how this function works, refer to the code listed below.

      VendorLedgerEntry.VALIDATE("Pmt. Discount Date",GetAnyDateAfter(VendorLedgerEntry."Pmt. Discount Date"));
      VendorLedgerEntry.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      LibraryERM.FindVendorLedgerEntry(VendorLedgerEntry,DocumentType,DocumentNo);
      IF DateField = DateFieldOption::DueDate THEN BEGIN
        CFHelper.UpdateDueDateOnVendorLedgerEntry(VendorLedgerEntry);
        ExpectedDate := VendorLedgerEntry."Due Date";
      END ELSE BEGIN
        IF DateField = DateFieldOption::DiscountDate THEN BEGIN
          CFHelper.UpdatePmtDiscountDateOnVendorLedgerEntry(VendorLedgerEntry);
          ExpectedDate := VendorLedgerEntry."Pmt. Discount Date";
        END ELSE
          ERROR(STRSUBSTNO(UnsupportedDateField,DateField));
      END;
Member of Lib.Library - Cash Flow Helper


VerifyCFDataOnSnglJnlLine@112 Method

The procedure VerifyCFDataOnSnglJnlLine is available in codeunit 131332.

Syntax

VerifyCFDataOnSnglJnlLine@112(
    VAR CFWorksheetLine@1004 : Record 846 CFWorksheetLine, //Reference parameter of type Record
    DocumentNo@1003 : Code[20] DocumentNo, //Input parameter of type Code
    SourceType@1005 : Option SourceType, //Input parameter of type Option
    CFNo@1002 : Code[20] CFNo, //Input parameter of type Code
    ExpectedCFAmount@1001 : Decimal ExpectedCFAmount, //Input parameter of type Decimal
    ExpectedCFDate@1000 : Date ExpectedCFDate //Input parameter of type Date
);

Parameters

CFWorksheetLine
Reference parameter of type Record
DocumentNo
Input parameter of type Code
SourceType
Input parameter of type Option
CFNo
Input parameter of type Code
ExpectedCFAmount
Input parameter of type Decimal
ExpectedCFDate
Input parameter of type Date

Remarks

The relevant search keywords are: Verify, Cash Flow, Data, On, Sngl, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      FilterSingleJournalLine(CFWorksheetLine,DocumentNo,SourceType,CFNo);
      CFWorksheetLine.CALCSUMS("Amount (LCY)");
      VerifyExpectedCFAmtNearlyEqual(ExpectedCFAmount,CFWorksheetLine."Amount (LCY)",LibraryERM.GetAmountRoundingPrecision);
      VerifyCFDateOnCFJnlLine(CFWorksheetLine,ExpectedCFDate);

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // Test filling a CF journal using Fill batch with a manual revenue
      // and verify computed due and cash flow date

      // Setup
      Initialize;
      CFHelper.CreateCashFlowForecastDefault(CashFlowForecast);
      CFHelper.CreateManualRevenue(CFManualRevenue);

      // Exercise
      ConsiderSource[SourceType::"Cash Flow Manual Revenue"] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      CFHelper.VerifyCFDataOnSnglJnlLine(CFWorksheetLine,CFManualRevenue.Code,SourceType::"Cash Flow Manual Revenue",
        CashFlowForecast."No.",CFManualRevenue.Amount,CFManualRevenue."Starting Date");
Member of Lib.Library - Cash Flow Helper


VerifyCFDateOnCFJnlLine@7 Method

The procedure VerifyCFDateOnCFJnlLine is available in codeunit 131332.

Syntax

VerifyCFDateOnCFJnlLine@7(
    CFWorksheetLine@1002 : Record 846 CFWorksheetLine, //Input parameter of type Record
    ExpectedCFDate@1000 : Date ExpectedCFDate //Input parameter of type Date
);

Parameters

CFWorksheetLine
Input parameter of type Record
ExpectedCFDate
Input parameter of type Date

Remarks

The relevant search keywords are: Verify, Cash Flow, Date, On, Cash Flow, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      Assert.AreEqual(ExpectedCFDate,CFWorksheetLine."Cash Flow Date",STRSUBSTNO(UnexpectedCFDate,CFWorksheetLine."Document No."));

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // Test filling a CF journal by using Fill batch with a 3-line sales order
      // and a payment discount grace period set. Verify computed due and cash flow date and discounted amount

      // Setup
      Initialize;
      CFHelper.CreateCashFlowForecastConsiderDiscount(CashFlowForecast);
      CFHelper.SetPmtToleranceOptionsOnCashFlowForecast(CashFlowForecast,TRUE,FALSE);
      GeneralLedgerSetup.GET;
      CFHelper.CreateRandomDateFormula(PmtDiscountGracePeriod);
      CFHelper.SetupPmtDsctGracePeriod(PmtDiscountGracePeriod);
      LibraryERM.GetDiscountPaymentTerm(PaymentTerms);
      CFHelper.CreateSpecificSalesOrder(SalesHeader,PaymentTerms.Code,'');
      ExpectedCFDate :=
        CALCDATE(PaymentTerms."Discount Date Calculation",
          CALCDATE(PmtDiscountGracePeriod,SalesHeader."Document Date"));

      // Exercise
      ConsiderSource[SourceType::"Sales Orders"] := TRUE;
      FillJournalWithoutGroupBy(ConsiderSource,CashFlowForecast."No.");

      // Verify
      CFHelper.FilterSingleJournalLine(CFWorksheetLine,SalesHeader."No.",SourceType::"Sales Orders",CashFlowForecast."No.");
      CFHelper.VerifyCFDateOnCFJnlLine(CFWorksheetLine,ExpectedCFDate);

      // Tear down
      CFHelper.SetupPmtDsctGracePeriod(GeneralLedgerSetup."Payment Discount Grace Period");
Member of Lib.Library - Cash Flow Helper


VerifyExpectedCFAmount@50 Method

The procedure VerifyExpectedCFAmount is available in codeunit 131332.

Syntax

VerifyExpectedCFAmount@50(
    ExpectedAmount@1000 : Decimal ExpectedAmount, //Input parameter of type Decimal
    ActualAmount@1001 : Decimal ActualAmount //Input parameter of type Decimal
);

Parameters

ExpectedAmount
Input parameter of type Decimal
ActualAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Verify, Expected, Cash Flow, Amount.

For a clarification about how this function works, refer to the code listed below.

      Assert.AreEqual(ExpectedAmount,ActualAmount,UnexpectedCFAmount);

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      // Suggest lines should set source type accordingly

      // Setup
      Initialize;
      CFHelper.CreateCashFlowForecastDefault(CashFlowForecast);
      CashFlowForecast.VALIDATE("G/L Budget From",WORKDATE);
      CashFlowForecast.VALIDATE("G/L Budget To",WORKDATE);
      CashFlowForecast.MODIFY(TRUE);
      CFHelper.CreateBudgetEntry(GLBudgetEntry,CashFlowForecast."G/L Budget To");

      // Exercise
      LibraryCF.FillBudgetJournal(FALSE,CashFlowForecast."No.",GLBudgetEntry."Budget Name");

      // Verify
      CFHelper.FilterSingleJournalLine(CFWorksheetLine,FORMAT(GLBudgetEntry."Entry No."),
        CFWorksheetLine."Source Type"::"G/L Budget",CashFlowForecast."No.");
      CFWorksheetLine.TESTFIELD("Source Type",CFWorksheetLine."Source Type"::"G/L Budget");
      CFWorksheetLine.TESTFIELD("G/L Budget Name",GLBudgetEntry."Budget Name");
      CFHelper.VerifyExpectedCFAmount(-GLBudgetEntry.Amount,CFWorksheetLine."Amount (LCY)");
Member of Lib.Library - Cash Flow Helper


VerifyExpectedCFAmtNearlyEqual@52 Method

The procedure VerifyExpectedCFAmtNearlyEqual is available in codeunit 131332.

Syntax

VerifyExpectedCFAmtNearlyEqual@52(
    ExpectedAmount@1001 : Decimal ExpectedAmount, //Input parameter of type Decimal
    ActualAmount@1000 : Decimal ActualAmount, //Input parameter of type Decimal
    Delta@1002 : Decimal Delta //Input parameter of type Decimal
);

Parameters

ExpectedAmount
Input parameter of type Decimal
ActualAmount
Input parameter of type Decimal
Delta
Input parameter of type Decimal

Remarks

The relevant search keywords are: Verify, Expected, Cash Flow, Amt, Nearly, Equal.

For a clarification about how this function works, refer to the code listed below.

      Assert.AreNearlyEqual(ExpectedAmount,ActualAmount,Delta,UnexpectedCFAmount);

Example

There are no examples available.
Member of Lib.Library - Cash Flow Helper


Library - Cost Accounting Class

Lib.Library - Cost Accounting

COD131340 applies to ERM,W1,All.
Feature: 92842 - Cost Accounting. Test Brief: http://vstfnav/Sites/DynamicsNAV7/Document Repository/Test Briefs and TDS/92842 - TDS - Cost Accounting.docx

Methods

Name | Description
AllocateCostsFromTo@43 | The procedure AllocateCostsFromTo is available in codeunit 131340.
CheckAllocTargetSharePercent@147 | The procedure CheckAllocTargetSharePercent is available in codeunit 131340.
CheckBlockedDimCombination@74 | The procedure CheckBlockedDimCombination is available in codeunit 131340.
CheckBlockedDimensionValues@73 | The procedure CheckBlockedDimensionValues is available in codeunit 131340.
CheckCostJnlLineConsistency@58 | The procedure CheckCostJnlLineConsistency is available in codeunit 131340.
ClearCostJournalLines@33 | The procedure ClearCostJournalLines is available in codeunit 131340.
CopyCABudgetToCABudget@47 | The procedure CopyCABudgetToCABudget is available in codeunit 131340.
CopyCABudgetToGLBudget@48 | The procedure CopyCABudgetToGLBudget is available in codeunit 131340.
CopyGLBudgetToCABudget@51 | The procedure CopyGLBudgetToCABudget is available in codeunit 131340.
CostCenterDimension@72 | The procedure CostCenterDimension is available in codeunit 131340.
CostObjectDimension@71 | The procedure CostObjectDimension is available in codeunit 131340.
CreateAllocSource@41 | The procedure CreateAllocSource is available in codeunit 131340.
CreateAllocSourceWithCCenter@40 | The procedure CreateAllocSourceWithCCenter is available in codeunit 131340.
CreateAllocSourceWithCObject@39 | The procedure CreateAllocSourceWithCObject is available in codeunit 131340.
CreateAllocTarget@38 | The procedure CreateAllocTarget is available in codeunit 131340.
CreateAllocTargetWithCCenter@137 | The procedure CreateAllocTargetWithCCenter is available in codeunit 131340.
CreateAllocTargetWithCObject@37 | The procedure CreateAllocTargetWithCObject is available in codeunit 131340.
CreateBalanceSheetGLAccount@24 | The procedure CreateBalanceSheetGLAccount is available in codeunit 131340.
CreateCostBudgetEntry@44 | The procedure CreateCostBudgetEntry is available in codeunit 131340.
CreateCostBudgetName@53 | The procedure CreateCostBudgetName is available in codeunit 131340.
CreateCostCenter@22 | The procedure CreateCostCenter is available in codeunit 131340.
CreateCostCenterFromDimension@25 | The procedure CreateCostCenterFromDimension is available in codeunit 131340.
CreateCostJnlBatchWithDelOpt@57 | The procedure CreateCostJnlBatchWithDelOpt is available in codeunit 131340.
CreateCostJournalBatch@55 | The procedure CreateCostJournalBatch is available in codeunit 131340.
CreateCostJournalLine@5 | The procedure CreateCostJournalLine is available in codeunit 131340.
CreateCostJournalLineBasic@42 | The procedure CreateCostJournalLineBasic is available in codeunit 131340.
CreateCostJournalTemplate@60 | The procedure CreateCostJournalTemplate is available in codeunit 131340.
CreateCostObject@12 | The procedure CreateCostObject is available in codeunit 131340.
CreateCostObjectFromDimension@15 | The procedure CreateCostObjectFromDimension is available in codeunit 131340.
CreateCostType@10 | The procedure CreateCostType is available in codeunit 131340.
CreateCostTypeNoGLRange@29 | The procedure CreateCostTypeNoGLRange is available in codeunit 131340.
CreateCostTypeWithCombine@19 | The procedure CreateCostTypeWithCombine is available in codeunit 131340.
CreateCostTypeWithGLRange@11 | The procedure CreateCostTypeWithGLRange is available in codeunit 131340.
CreateIncomeStmtGLAccount@27 | The procedure CreateIncomeStmtGLAccount is available in codeunit 131340.
CreateJnlLine@70 | The procedure CreateJnlLine is available in codeunit 131340.
DeleteAllCostTypeEntries@14 | The procedure DeleteAllCostTypeEntries is available in codeunit 131340.
DeleteBlockedDimCombinations@68 | The procedure DeleteBlockedDimCombinations is available in codeunit 131340.
DeleteCostBudgetRegEntries@45 | The procedure DeleteCostBudgetRegEntries is available in codeunit 131340.
DeleteCostBudgetRegEntriesFrom@52 | The procedure DeleteCostBudgetRegEntriesFrom is available in codeunit 131340.
DeleteCostRegisterEntries@13 | The procedure DeleteCostRegisterEntries is available in codeunit 131340.
DeleteCostRegisterEntriesFrom@17 | The procedure DeleteCostRegisterEntriesFrom is available in codeunit 131340.
FindAllocSource@36 | The procedure FindAllocSource is available in codeunit 131340.
FindCostCenter@2 | The procedure FindCostCenter is available in codeunit 131340.
FindCostJnlBatchWithDelOption@56 | The procedure FindCostJnlBatchWithDelOption is available in codeunit 131340.
FindCostJournalBatch@6 | The procedure FindCostJournalBatch is available in codeunit 131340.
FindCostJournalTemplate@21 | The procedure FindCostJournalTemplate is available in codeunit 131340.
FindCostObject@4 | The procedure FindCostObject is available in codeunit 131340.
FindCostType@8 | The procedure FindCostType is available in codeunit 131340.
FindCostTypeLinkedToGLAcc@49 | The procedure FindCostTypeLinkedToGLAcc is available in codeunit 131340.
FindCostTypeWithCostCenter@16 | The procedure FindCostTypeWithCostCenter is available in codeunit 131340.
FindGLAccLinkedToCostType@30 | The procedure FindGLAccLinkedToCostType is available in codeunit 131340.
FindGLAccountsByCostType@7 | The procedure FindGLAccountsByCostType is available in codeunit 131340.
FindIncomeStmtGLAccount@18 | The procedure FindIncomeStmtGLAccount is available in codeunit 131340.
GetAllCostTypes@9 | The procedure GetAllCostTypes is available in codeunit 131340.
GetAllIncomeStmtGLAccounts@23 | The procedure GetAllIncomeStmtGLAccounts is available in codeunit 131340.
GetAllocTargetEntryAmount@46 | The procedure GetAllocTargetEntryAmount is available in codeunit 131340.
InitializeCASetup@54 | The procedure InitializeCASetup is available in codeunit 131340.
InitializeCASourceCodes@59 | The procedure InitializeCASourceCodes is available in codeunit 131340.
LastAllocSourceID@50 | The procedure LastAllocSourceID is available in codeunit 131340.
LastAllocTargetID@35 | The procedure LastAllocTargetID is available in codeunit 131340.
PostCostJournalLine@20 | The procedure PostCostJournalLine is available in codeunit 131340.
PostGenJournalLine@67 | The procedure PostGenJournalLine is available in codeunit 131340.
SetAlignment@26 | The procedure SetAlignment is available in codeunit 131340.
SetAutotransferFromGL@32 | The procedure SetAutotransferFromGL is available in codeunit 131340.
SetDefaultDimension@66 | The procedure SetDefaultDimension is available in codeunit 131340.
SetupGeneralJnlBatch@78 | The procedure SetupGeneralJnlBatch is available in codeunit 131340.
SetupGLAccount@65 | The procedure SetupGLAccount is available in codeunit 131340.
TransferBudgetToActual@148 | The procedure TransferBudgetToActual is available in codeunit 131340.
TransferGLEntries@28 | The procedure TransferGLEntries is available in codeunit 131340.
UpdateAllocSourceWithCCenter@34 | The procedure UpdateAllocSourceWithCCenter is available in codeunit 131340.
UpdateAllocSourceWithCObject@31 | The procedure UpdateAllocSourceWithCObject is available in codeunit 131340.
UpdateAllocTargetWithCCenter@131 | The procedure UpdateAllocTargetWithCCenter is available in codeunit 131340.
UpdateAllocTargetWithCObject@132 | The procedure UpdateAllocTargetWithCObject is available in codeunit 131340.
UpdateCostTypeWithCostCenter@1 | The procedure UpdateCostTypeWithCostCenter is available in codeunit 131340.
UpdateCostTypeWithCostObject@3 | The procedure UpdateCostTypeWithCostObject is available in codeunit 131340.
ValidateEntriesTransfered@64 | The procedure ValidateEntriesTransfered is available in codeunit 131340.
ValidateGLAccountCostTypeRef@63 | The procedure ValidateGLAccountCostTypeRef is available in codeunit 131340.
ValidateGLAccountIsIncomeStmt@62 | The procedure ValidateGLAccountIsIncomeStmt is available in codeunit 131340.
VerifyCostTypeIntegrity@69 | The procedure VerifyCostTypeIntegrity is available in codeunit 131340.

See Also

Lib


AllocateCostsFromTo@43 Method

The procedure AllocateCostsFromTo is available in codeunit 131340.

Syntax

AllocateCostsFromTo@43(
    VAR CostAllocation@1006 : TestRequestPage 1131 CostAllocation, //Reference parameter of type TestRequestPage
    FromLevel@1001 : Integer FromLevel, //Input parameter of type Integer
    ToLevel@1002 : Integer ToLevel, //Input parameter of type Integer
    AllocDate@1003 : Date AllocDate, //Input parameter of type Date
    AllocGroup@1005 : Code[10] AllocGroup, //Input parameter of type Code
    CostBudgetName@1004 : Code[10] CostBudgetName //Input parameter of type Code
);

Parameters

CostAllocation
Reference parameter of type TestRequestPage
FromLevel
Input parameter of type Integer
ToLevel
Input parameter of type Integer
AllocDate
Input parameter of type Date
AllocGroup
Input parameter of type Code
CostBudgetName
Input parameter of type Code

Remarks

The relevant search keywords are: Allocate, Costs, From, To.

For a clarification about how this function works, refer to the code listed below.

      CostAllocation."From Alloc. Level".SETVALUE(FromLevel);
      CostAllocation."To Alloc. Level".SETVALUE(ToLevel);
      CostAllocation."Allocation Date".SETVALUE(AllocDate);
      CostAllocation.Group.SETVALUE(AllocGroup);
      CostAllocation."Budget Name".SETVALUE(CostBudgetName);

Example

The below example is extracted from the test automation codeunit 134813 to show one way of using this function.

      LibraryCostAccounting.AllocateCostsFromTo(CostAllocation,MaxLevel,MaxLevel,WORKDATE,'',SelectedCostBudget);
      CostAllocation.OK.INVOKE;
Member of Lib.Library - Cost Accounting


CheckAllocTargetSharePercent@147 Method

The procedure CheckAllocTargetSharePercent is available in codeunit 131340.

Syntax

CheckAllocTargetSharePercent@147(
    CostAllocationSource@1000 : Record 1106 CostAllocationSource //Input parameter of type Record
);

Parameters

CostAllocationSource
Input parameter of type Record

Remarks

The relevant search keywords are: Check, Allocation, Target, Share, Percent.

For a clarification about how this function works, refer to the code listed below.

      CostAllocationSource.CALCFIELDS("Total Share");
      CostAllocationTarget.SETFILTER(ID,'%1',CostAllocationSource.ID);
      IF CostAllocationTarget.FINDSET THEN BEGIN
        REPEAT
          CurrentValue := ROUND(CostAllocationTarget.Percent,0.1,'=');
          ExpectedValue := ROUND(100 * CostAllocationTarget.Share / CostAllocationSource."Total Share",0.1,'=');
          Assert.AreEqual(
            CurrentValue,ExpectedValue,
            STRSUBSTNO(IncorrectPercentValueErr,CostAllocationSource.ID,CostAllocationTarget."Line No.",CurrentValue,ExpectedValue));
        UNTIL CostAllocationTarget.NEXT = 0;
      END ELSE
        ERROR(STRSUBSTNO(NoRecordsInFilterErr,CostAllocationTarget.TABLECAPTION,CostAllocationTarget.GETFILTERS));

Example

The below example is extracted from the test automation codeunit 134813 to show one way of using this function.

      // Setup.
      Initialize;

      // Exercise.
      LibraryCostAccounting.CreateAllocSourceWithCCenter(CostAllocationSource,TypeOfID::"Auto Generated");

      FOR Index := 1 TO LibraryRandom.RandInt(4) DO
        LibraryCostAccounting.CreateAllocTargetWithCCenter(
          CostAllocationTarget,CostAllocationSource,Index * 10,
          CostAllocationTarget.Base::Static,CostAllocationTarget."Allocation Target Type"::"All Costs");

      // Verify.
      LibraryCostAccounting.CheckAllocTargetSharePercent(CostAllocationSource);
Member of Lib.Library - Cost Accounting


CheckBlockedDimCombination@74 Method

The procedure CheckBlockedDimCombination is available in codeunit 131340.

Syntax

CheckBlockedDimCombination@74(
      //param element not supplied
);

Remarks

The relevant search keywords are: Check, Blocked, Dimension, Combination.

For a clarification about how this function works, refer to the code listed below.

      DimensionCombination.SETFILTER("Dimension 1 Code",'%1|%2',CostCenterDimension,CostObjectDimension);
      DeleteBlockedDimCombinations(DimensionCombination);

      CLEAR(DimensionCombination);
      DimensionCombination.SETFILTER("Dimension 2 Code",'%1|%2',CostCenterDimension,CostObjectDimension);
      DeleteBlockedDimCombinations(DimensionCombination);

Example

There are no examples available.
Member of Lib.Library - Cost Accounting


CheckBlockedDimensionValues@73 Method

The procedure CheckBlockedDimensionValues is available in codeunit 131340.

Syntax

CheckBlockedDimensionValues@73(
    AccountNo@1000 : Code[20] AccountNo //Input parameter of type Code
);

Parameters

AccountNo
Input parameter of type Code

Remarks

The relevant search keywords are: Check, Blocked, Dimension, Values.

For a clarification about how this function works, refer to the code listed below.

      // Un-block any blocked default dimension values for an account

      LibraryDimension.FindDefaultDimension(DefaultDimension,DATABASE::"G/L Account",AccountNo);
      IF DefaultDimension.FINDSET THEN
        REPEAT
          DimensionValue.GET(DefaultDimension."Dimension Code",DefaultDimension."Dimension Value Code");
          IF DimensionValue.Blocked THEN BEGIN
            DimensionValue.VALIDATE(Blocked,FALSE);
            DimensionValue.MODIFY(TRUE);
          END;
        UNTIL DefaultDimension.NEXT = 0;

Example

There are no examples available.
Member of Lib.Library - Cost Accounting


CheckCostJnlLineConsistency@58 Method

The procedure CheckCostJnlLineConsistency is available in codeunit 131340.

Syntax

CheckCostJnlLineConsistency@58(
    VAR CostJournalLine@1000 : Record 1101 CostJournalLine //Reference parameter of type Record
);

Parameters

CostJournalLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Check, Cost, Journal, Line, Consistency.

For a clarification about how this function works, refer to the code listed below.

      IF (CostJournalLine."Cost Center Code" = '') AND (CostJournalLine."Cost Object Code" = '') THEN BEGIN
        // either Cost Center or Cost Object must be set in order to post
        CreateCostCenter(CostCenter);
        CostJournalLine.VALIDATE("Cost Center Code",CostCenter.Code);
      END;

      IF (CostJournalLine."Bal. Cost Center Code" = '') AND (CostJournalLine."Bal. Cost Object Code" = '') THEN BEGIN
        // either Bal. Cost Center or Bal. Cost Object must be set in order to post
        CreateCostCenter(CostCenter);
        CostJournalLine.VALIDATE("Bal. Cost Center Code",CostCenter.Code);
      END;

      IF (CostJournalLine."Cost Center Code" <> '') AND (CostJournalLine."Cost Object Code" <> '') THEN
        // only one of Cost Center or Cost Object must be set in order to post
        CostJournalLine.VALIDATE("Cost Object Code",'');

      IF (CostJournalLine."Bal. Cost Center Code" <> '') AND (CostJournalLine."Bal. Cost Object Code" <> '') THEN
        // only one of Bal. Cost Center or Bal. Cost Object fields must be set in order to post
        CostJournalLine.VALIDATE("Bal. Cost Object Code",'');

      CostJournalLine.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - Cost Accounting


ClearCostJournalLines@33 Method

The procedure ClearCostJournalLines is available in codeunit 131340.

Syntax

ClearCostJournalLines@33(
    CostJournalBatch@1000 : Record 1102 CostJournalBatch //Input parameter of type Record
);

Parameters

CostJournalBatch
Input parameter of type Record

Remarks

The relevant search keywords are: Clear, Cost, Journal, Lines.

For a clarification about how this function works, refer to the code listed below.

      CostJournalLine.SETRANGE("Journal Template Name",CostJournalBatch."Journal Template Name");
      CostJournalLine.SETRANGE("Journal Batch Name",CostJournalBatch.Name);
      CostJournalLine.DELETEALL(TRUE);

Example

The below example is extracted from the test automation codeunit 134811 to show one way of using this function.

      LibraryCostAccounting.FindCostJournalTemplate(CostJournalTemplate);
      LibraryCostAccounting.FindCostJournalBatch(CostJournalBatch,CostJournalTemplate.Name);
      LibraryCostAccounting.ClearCostJournalLines(CostJournalBatch);
Member of Lib.Library - Cost Accounting


CopyCABudgetToCABudget@47 Method

The procedure CopyCABudgetToCABudget is available in codeunit 131340.

Syntax

CopyCABudgetToCABudget@47(
    VAR CopyCAToCARP@1000 : TestRequestPage 1134 CopyCAToCARP, //Reference parameter of type TestRequestPage
    SourceCostBudget@1001 : Code[10] SourceCostBudget, //Input parameter of type Code
    TargetCostBudget@1002 : Code[10] TargetCostBudget, //Input parameter of type Code
    AmtMultiplicationRatio@1003 : Decimal AmtMultiplicationRatio, //Input parameter of type Decimal
    DateFormula@1004 : Text[30] DateFormula, //Input parameter of type Text
    NoOfCopies@1005 : Integer NoOfCopies //Input parameter of type Integer
);

Parameters

CopyCAToCARP
Reference parameter of type TestRequestPage
SourceCostBudget
Input parameter of type Code
TargetCostBudget
Input parameter of type Code
AmtMultiplicationRatio
Input parameter of type Decimal
DateFormula
Input parameter of type Text
NoOfCopies
Input parameter of type Integer

Remarks

The relevant search keywords are: Copy, Cost Accounting, Budget, To, Cost Accounting, Budget.

For a clarification about how this function works, refer to the code listed below.

      CopyCAToCARP."Budget Name".SETVALUE(TargetCostBudget);
      CopyCAToCARP."Amount multiplication factor".SETVALUE(AmtMultiplicationRatio);
      CopyCAToCARP."Date Change Formula".SETVALUE(DateFormula);
      CopyCAToCARP."No. of Copies".SETVALUE(NoOfCopies);
      CopyCAToCARP."Cost Budget Entry".SETFILTER("Budget Name",SourceCostBudget);

Example

The below example is extracted from the test automation codeunit 134814 to show one way of using this function.

      GetSharedVars(SourceBudget,TargetBudget,DateFormula,AmtMultiplyRatio,NoOfCopies);
      LibraryCostAccounting.CopyCABudgetToCABudget(CopyCAToCARP,SourceBudget,TargetBudget,AmtMultiplyRatio,DateFormula,NoOfCopies);
      CopyCAToCARP.OK.INVOKE;
Member of Lib.Library - Cost Accounting


CopyCABudgetToGLBudget@48 Method

The procedure CopyCABudgetToGLBudget is available in codeunit 131340.

Syntax

CopyCABudgetToGLBudget@48(
    VAR CopyCAToGLRP@1000 : TestRequestPage 1136 CopyCAToGLRP, //Reference parameter of type TestRequestPage
    SourceCostBudget@1001 : Code[10] SourceCostBudget, //Input parameter of type Code
    TargetCostBudget@1002 : Code[10] TargetCostBudget, //Input parameter of type Code
    AmtMultiplicationRatio@1003 : Decimal AmtMultiplicationRatio, //Input parameter of type Decimal
    DateFormula@1004 : Text[30] DateFormula, //Input parameter of type Text
    NoOfCopies@1005 : Integer NoOfCopies //Input parameter of type Integer
);

Parameters

CopyCAToGLRP
Reference parameter of type TestRequestPage
SourceCostBudget
Input parameter of type Code
TargetCostBudget
Input parameter of type Code
AmtMultiplicationRatio
Input parameter of type Decimal
DateFormula
Input parameter of type Text
NoOfCopies
Input parameter of type Integer

Remarks

The relevant search keywords are: Copy, Cost Accounting, Budget, To, General Ledger, Budget.

For a clarification about how this function works, refer to the code listed below.

      CopyCAToGLRP."Allocation Target Budget Name".SETVALUE(TargetCostBudget);
      CopyCAToGLRP."Amount multiplication factor".SETVALUE(AmtMultiplicationRatio);
      CopyCAToGLRP."Date Change Formula".SETVALUE(DateFormula);
      CopyCAToGLRP."No. of Copies".SETVALUE(NoOfCopies);
      CopyCAToGLRP."Cost Budget Entry".SETFILTER("Budget Name",SourceCostBudget);

Example

The below example is extracted from the test automation codeunit 134814 to show one way of using this function.

      GetSharedVars(SourceBudget,TargetBudget,DateFormula,AmtMultiplyRatio,NoOfCopies);
      LibraryCostAccounting.CopyCABudgetToGLBudget(
        CopyCAToGLReqPage,SourceBudget,TargetBudget,AmtMultiplyRatio,DateFormula,NoOfCopies);

      CopyCAToGLReqPage.OK.INVOKE;
Member of Lib.Library - Cost Accounting


CopyGLBudgetToCABudget@51 Method

The procedure CopyGLBudgetToCABudget is available in codeunit 131340.

Syntax

CopyGLBudgetToCABudget@51(
    VAR CopyGLToCARP@1002 : TestRequestPage 1135 CopyGLToCARP, //Reference parameter of type TestRequestPage
    SourceGLBudget@1001 : Code[10] SourceGLBudget, //Input parameter of type Code
    TargetCostBudget@1000 : Code[10] TargetCostBudget //Input parameter of type Code
);

Parameters

CopyGLToCARP
Reference parameter of type TestRequestPage
SourceGLBudget
Input parameter of type Code
TargetCostBudget
Input parameter of type Code

Remarks

The relevant search keywords are: Copy, General Ledger, Budget, To, Cost Accounting, Budget.

For a clarification about how this function works, refer to the code listed below.

      CopyGLToCARP."Budget Name".SETVALUE(TargetCostBudget);
      CopyGLToCARP."G/L Budget Entry".SETFILTER("Budget Name",SourceGLBudget);

Example

The below example is extracted from the test automation codeunit 134814 to show one way of using this function.

      LibraryVariableStorage.Dequeue(SourceBudget);
      LibraryVariableStorage.Dequeue(TargetBudget);
      LibraryCostAccounting.CopyGLBudgetToCABudget(CopyGLToCAReqPage,SourceBudget,TargetBudget);
      CopyGLToCAReqPage.OK.INVOKE;
Member of Lib.Library - Cost Accounting


CostCenterDimension@72 Method

The procedure CostCenterDimension is available in codeunit 131340.

Syntax

CostCenterDimension@72(
      //param element not supplied
);

Return Value

Code[20]

Remarks

The relevant search keywords are: Cost, Center, Dimension.

For a clarification about how this function works, refer to the code listed below.

      CostAccountingSetup.GET;
      EXIT(CostAccountingSetup."Cost Center Dimension");

Example

There are no examples available.
Member of Lib.Library - Cost Accounting


CostObjectDimension@71 Method

The procedure CostObjectDimension is available in codeunit 131340.

Syntax

CostObjectDimension@71(
      //param element not supplied
);

Return Value

Code[20]

Remarks

The relevant search keywords are: Cost, Object, Dimension.

For a clarification about how this function works, refer to the code listed below.

      CostAccountingSetup.GET;
      EXIT(CostAccountingSetup."Cost Object Dimension");

Example

There are no examples available.
Member of Lib.Library - Cost Accounting


CreateAllocSource@41 Method

The procedure CreateAllocSource is available in codeunit 131340.

Syntax

CreateAllocSource@41(
    VAR CostAllocationSource@1000 : Record 1106 CostAllocationSource, //Reference parameter of type Record
    TypeOfID@1003 : Option TypeOfID //Input parameter of type Option
);

Parameters

CostAllocationSource
Reference parameter of type Record
TypeOfID
Input parameter of type Option

Remarks

The relevant search keywords are: Create, Allocation, Source.

For a clarification about how this function works, refer to the code listed below.

      FindCostType(CostType);

      CostAllocationSource.INIT;
      IF TypeOfID = TypeOfID::Custom THEN
        CostAllocationSource.VALIDATE(ID,(LastAllocSourceID + STRSUBSTNO(AllocSourceID,CostAllocationSource.COUNT)));
      CostAllocationSource.VALIDATE(Level,LibraryRandom.RandInt(10));
      CostAllocationSource.VALIDATE("Credit to Cost Type",CostType."No.");
      CostAllocationSource.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134392 to show one way of using this function.

      // Verify that Cost Allocations Report does not shows details when PrintOnlyIfDetails is true and Cost Allocation Target is blank.
      Initialize;

      // Setup.
      LibraryCostAccounting.CreateAllocSource(CostAllocationSource,TypeOfID::"Auto Generated");
      LibraryVariableStorage.Enqueue(TRUE);  // Used in CostAllocationsReportHandler.

      // Exercise: Run report Cost Allocation with Target Cost Type.
      RunCostAllocationsReport(CostAllocationSource);

      // Verify: Verify Target Cost Type and Target Cost Center.
      LibraryReportDataset.LoadDataSetFile;
      Assert.IsFalse(LibraryReportDataset.GetNextRow,RowMustNotExist);
Member of Lib.Library - Cost Accounting


CreateAllocSourceWithCCenter@40 Method

The procedure CreateAllocSourceWithCCenter is available in codeunit 131340.

Syntax

CreateAllocSourceWithCCenter@40(
    VAR CostAllocationSource@1001 : Record 1106 CostAllocationSource, //Reference parameter of type Record
    TypeOfID@1000 : Option TypeOfID //Input parameter of type Option
);

Parameters

CostAllocationSource
Reference parameter of type Record
TypeOfID
Input parameter of type Option

Remarks

The relevant search keywords are: Create, Allocation, Source, C, Center.

For a clarification about how this function works, refer to the code listed below.

      CreateAllocSource(CostAllocationSource,TypeOfID);
      UpdateAllocSourceWithCCenter(CostAllocationSource);

Example

The below example is extracted from the test automation codeunit 134813 to show one way of using this function.

      // Setup.
      Initialize;

      // Exercise.
      LibraryCostAccounting.CreateAllocSourceWithCCenter(CostAllocationSource,TypeOfID::"Auto Generated");

      FOR Index := 1 TO LibraryRandom.RandInt(4) DO
        LibraryCostAccounting.CreateAllocTargetWithCCenter(
          CostAllocationTarget,CostAllocationSource,Index * 10,
          CostAllocationTarget.Base::Static,CostAllocationTarget."Allocation Target Type"::"All Costs");

      // Verify.
      LibraryCostAccounting.CheckAllocTargetSharePercent(CostAllocationSource);
Member of Lib.Library - Cost Accounting


CreateAllocSourceWithCObject@39 Method

The procedure CreateAllocSourceWithCObject is available in codeunit 131340.

Syntax

CreateAllocSourceWithCObject@39(
    VAR CostAllocationSource@1001 : Record 1106 CostAllocationSource, //Reference parameter of type Record
    TypeOfID@1000 : Option TypeOfID //Input parameter of type Option
);

Parameters

CostAllocationSource
Reference parameter of type Record
TypeOfID
Input parameter of type Option

Remarks

The relevant search keywords are: Create, Allocation, Source, C, Object.

For a clarification about how this function works, refer to the code listed below.

      CreateAllocSource(CostAllocationSource,TypeOfID);
      UpdateAllocSourceWithCObject(CostAllocationSource);

Example

There are no examples available.
Member of Lib.Library - Cost Accounting


CreateAllocTarget@38 Method

The procedure CreateAllocTarget is available in codeunit 131340.

Syntax

CreateAllocTarget@38(
    VAR CostAllocationTarget@1000 : Record 1107 CostAllocationTarget, //Reference parameter of type Record
    CostAllocationSource@1003 : Record 1106 CostAllocationSource, //Input parameter of type Record
    Share@1005 : Decimal Share, //Input parameter of type Decimal
    Base@1004 : Option Base, //Input parameter of type Option
    AllocationType@1001 : Option AllocationType //Input parameter of type Option
);

Parameters

CostAllocationTarget
Reference parameter of type Record
CostAllocationSource
Input parameter of type Record
Share
Input parameter of type Decimal
Base
Input parameter of type Option
AllocationType
Input parameter of type Option

Remarks

The relevant search keywords are: Create, Allocation, Target.

For a clarification about how this function works, refer to the code listed below.

      LineNo := LastAllocTargetID(CostAllocationSource) + 1;

      CostAllocationTarget.INIT;
      CostAllocationTarget.VALIDATE(ID,CostAllocationSource.ID);
      CostAllocationTarget.VALIDATE("Line No.",LineNo);
      CostAllocationTarget.VALIDATE("Target Cost Type",CostAllocationSource."Credit to Cost Type");
      CostAllocationTarget.VALIDATE(Base,Base);
      CostAllocationTarget.VALIDATE("Allocation Target Type",AllocationType);
      CostAllocationTarget.INSERT(TRUE);

      // The Share field cannot be updated unless the Allocation Target exists.
      CLEAR(CostAllocationTarget);
      CostAllocationTarget.GET(CostAllocationSource.ID,LineNo);
      CostAllocationTarget.VALIDATE(Share,Share);
      CostAllocationTarget.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134392 to show one way of using this function.

      // Setup.
      LibraryCostAccounting.CreateCostCenter(CostCenter);
      LibraryCostAccounting.CreateAllocSource(CostAllocationSource,TypeOfID::"Auto Generated");
      LibraryCostAccounting.CreateAllocTarget(
        CostAllocationTarget,CostAllocationSource,LibraryRandom.RandDec(10,1),Base,AllocationType);
      CostAllocationTarget."Target Cost Center" := CostCenter.Code;
      CostAllocationTarget.MODIFY(TRUE);
      LibraryVariableStorage.Enqueue(SkipalocSourceswithoutaloctgt);

      // Exercise: Run report Cost Allocation with Target Cost Type.
      RunCostAllocationsReport(CostAllocationSource);

      // Verify: Verify Target Cost Type and "Target Cost Center".
      VerifyCostAllocationTarget(CostAllocationTarget);
Member of Lib.Library - Cost Accounting


CreateAllocTargetWithCCenter@137 Method

The procedure CreateAllocTargetWithCCenter is available in codeunit 131340.

Syntax

CreateAllocTargetWithCCenter@137(
    VAR CostAllocationTarget@1004 : Record 1107 CostAllocationTarget, //Reference parameter of type Record
    CostAllocationSource@1002 : Record 1106 CostAllocationSource, //Input parameter of type Record
    Share@1003 : Decimal Share, //Input parameter of type Decimal
    Base@1001 : Option Base, //Input parameter of type Option
    AllocationType@1000 : Option AllocationType //Input parameter of type Option
);

Parameters

CostAllocationTarget
Reference parameter of type Record
CostAllocationSource
Input parameter of type Record
Share
Input parameter of type Decimal
Base
Input parameter of type Option
AllocationType
Input parameter of type Option

Remarks

The relevant search keywords are: Create, Allocation, Target, C, Center.

For a clarification about how this function works, refer to the code listed below.

      CreateAllocTarget(CostAllocationTarget,CostAllocationSource,Share,Base,AllocationType);
      UpdateAllocTargetWithCCenter(CostAllocationTarget);

Example

The below example is extracted from the test automation codeunit 134813 to show one way of using this function.

      // Setup.
      Initialize;

      // Exercise.
      LibraryCostAccounting.CreateAllocSourceWithCCenter(CostAllocationSource,TypeOfID::"Auto Generated");

      FOR Index := 1 TO LibraryRandom.RandInt(4) DO
        LibraryCostAccounting.CreateAllocTargetWithCCenter(
          CostAllocationTarget,CostAllocationSource,Index * 10,
          CostAllocationTarget.Base::Static,CostAllocationTarget."Allocation Target Type"::"All Costs");

      // Verify.
      LibraryCostAccounting.CheckAllocTargetSharePercent(CostAllocationSource);
Member of Lib.Library - Cost Accounting


CreateAllocTargetWithCObject@37 Method

The procedure CreateAllocTargetWithCObject is available in codeunit 131340.

Syntax

CreateAllocTargetWithCObject@37(
    VAR CostAllocationTarget@1004 : Record 1107 CostAllocationTarget, //Reference parameter of type Record
    CostAllocationSource@1002 : Record 1106 CostAllocationSource, //Input parameter of type Record
    Share@1003 : Decimal Share, //Input parameter of type Decimal
    Base@1001 : Option Base, //Input parameter of type Option
    AllocationType@1000 : Option AllocationType //Input parameter of type Option
);

Parameters

CostAllocationTarget
Reference parameter of type Record
CostAllocationSource
Input parameter of type Record
Share
Input parameter of type Decimal
Base
Input parameter of type Option
AllocationType
Input parameter of type Option

Remarks

The relevant search keywords are: Create, Allocation, Target, C, Object.

For a clarification about how this function works, refer to the code listed below.

      CreateAllocTarget(CostAllocationTarget,CostAllocationSource,Share,Base,AllocationType);
      UpdateAllocTargetWithCObject(CostAllocationTarget);

Example

The below example is extracted from the test automation codeunit 134813 to show one way of using this function.

      // Setup.
      Initialize;
      LibraryCostAccounting.CreateAllocSourceWithCCenter(CostAllocationSource,TypeOfID::"Auto Generated");
      LibraryCostAccounting.CreateAllocTargetWithCObject(
        CostAllocationTarget,CostAllocationSource,LibraryRandom.RandInt(10),
        CostAllocationTarget.Base::Static,CostAllocationTarget."Allocation Target Type"::"All Costs");
      AllocSourceID := CostAllocationSource.ID;

      // Exercise.
      DeleteAllocSource(AllocSourceID);

      // Verify.
      CheckAllocSourceStatus(AllocSourceID,Status::Deleted);
      CheckAllocTargetStatus(AllocSourceID,Status::Deleted);
Member of Lib.Library - Cost Accounting


CreateBalanceSheetGLAccount@24 Method

The procedure CreateBalanceSheetGLAccount is available in codeunit 131340.

Syntax

CreateBalanceSheetGLAccount@24(
    VAR GLAccount@1000 : Record 15 GLAccount //Reference parameter of type Record
);

Parameters

GLAccount
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Balance, Sheet, General Ledger, Account.

For a clarification about how this function works, refer to the code listed below.

      CostAccountingSetup.GET;
      AlignGLAccount := CostAccountingSetup."Align G/L Account";
      CostAccountingSetup.VALIDATE("Align G/L Account",CostAccountingSetup."Align G/L Account"::"No Alignment");
      CostAccountingSetup.MODIFY(TRUE);

      LibraryERM.CreateGLAccount(GLAccount);
      GLAccount.TESTFIELD("Cost Type No.",'');
      GLAccount.VALIDATE("Income/Balance",GLAccount."Income/Balance"::"Balance Sheet");
      GLAccount.MODIFY(TRUE);

      CostAccountingSetup.GET;
      CostAccountingSetup.VALIDATE("Align G/L Account",AlignGLAccount);
      CostAccountingSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134810 to show one way of using this function.

      Initialize;

      // Setup:
      LibraryCostAccounting.SetAlignment(CostAccountingSetup.FIELDNO("Align G/L Account"),AlignGLAccount);

      // Exercise:
      LibraryCostAccounting.CreateBalanceSheetGLAccount(GLAccount);

      // Verify:
      GLAccount.TESTFIELD("Cost Type No.",'');
Member of Lib.Library - Cost Accounting


CreateCostBudgetEntry@44 Method

The procedure CreateCostBudgetEntry is available in codeunit 131340.

Syntax

CreateCostBudgetEntry@44(
    VAR CostBudgetEntry@1004 : Record 1109 CostBudgetEntry, //Reference parameter of type Record
    CostBudgetName@1000 : Code[10] CostBudgetName //Input parameter of type Code
);

Parameters

CostBudgetEntry
Reference parameter of type Record
CostBudgetName
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Cost, Budget, Entry.

For a clarification about how this function works, refer to the code listed below.

      FindCostType(CostType);
      FindCostCenter(CostCenter);

      CostBudgetEntry.INIT;
      CostBudgetEntry.VALIDATE(Date,WORKDATE);
      CostBudgetEntry.VALIDATE("Budget Name",CostBudgetName);
      CostBudgetEntry.VALIDATE("Cost Type No.",CostType."No.");
      CostBudgetEntry.VALIDATE("Cost Center Code",CostCenter.Code);
      CostBudgetEntry.VALIDATE(Amount,LibraryRandom.RandDec(100,2));
      CostBudgetEntry.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134392 to show one way of using this function.

      // Post entries for a cost type in a specific period and then Run the report for for that period. (Make sure you also set the Budget Filter.)
      // Check the values for each report column for the row containing the Cost Type used.
      Initialize;

      // Setup
      LibraryCostAccounting.CreateCostBudgetName(CostBudgetName);
      LibraryCostAccounting.CreateCostBudgetEntry(CostBudgetEntry,CostBudgetName.Name);

      // Post-Setup
      EnqueueCostAcctgBalanceBudget(CostBudgetEntry.Date,CostBudgetEntry.Date,CostBudgetEntry."Cost Type No.");

      // Exercise
      RunCostAcctgBalanceBudgetReport(
        CostBudgetEntry."Cost Type No.",CostBudgetEntry."Budget Name",CostBudgetEntry."Cost Center Code");

      // Verify
      VerifyCostAcctgBalanceBudgetReport(CostBudgetEntry.Amount,CostBudgetEntry."Cost Type No.");
Member of Lib.Library - Cost Accounting


CreateCostBudgetName@53 Method

The procedure CreateCostBudgetName is available in codeunit 131340.

Syntax

CreateCostBudgetName@53(
    VAR CostBudgetName@1000 : Record 1110 CostBudgetName //Reference parameter of type Record
);

Parameters

CostBudgetName
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Cost, Budget, Name.

For a clarification about how this function works, refer to the code listed below.

      CostBudgetName.INIT;
      CostBudgetName.VALIDATE(
        Name,LibraryUtility.GenerateRandomCode(CostBudgetName.FIELDNO(Description),DATABASE::"Cost Budget Name"));
      CostBudgetName.VALIDATE(Description,CostBudgetName.Name);
      CostBudgetName.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134392 to show one way of using this function.

      // Post entries for a cost type in a specific period and then Run the report for for that period. (Make sure you also set the Budget Filter.)
      // Check the values for each report column for the row containing the Cost Type used.
      Initialize;

      // Setup
      LibraryCostAccounting.CreateCostBudgetName(CostBudgetName);
      LibraryCostAccounting.CreateCostBudgetEntry(CostBudgetEntry,CostBudgetName.Name);

      // Post-Setup
      EnqueueCostAcctgBalanceBudget(CostBudgetEntry.Date,CostBudgetEntry.Date,CostBudgetEntry."Cost Type No.");

      // Exercise
      RunCostAcctgBalanceBudgetReport(
        CostBudgetEntry."Cost Type No.",CostBudgetEntry."Budget Name",CostBudgetEntry."Cost Center Code");

      // Verify
      VerifyCostAcctgBalanceBudgetReport(CostBudgetEntry.Amount,CostBudgetEntry."Cost Type No.");
Member of Lib.Library - Cost Accounting


CreateCostCenter@22 Method

The procedure CreateCostCenter is available in codeunit 131340.

Syntax

CreateCostCenter@22(
    VAR CostCenter@1000 : Record 1112 CostCenter //Reference parameter of type Record
);

Parameters

CostCenter
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Cost, Center.

For a clarification about how this function works, refer to the code listed below.

      CostCenter.INIT;
      CostCenter.VALIDATE(Code,LibraryUtility.GenerateRandomCode(CostCenter.FIELDNO(Code),DATABASE::"Cost Center"));
      CostCenter.VALIDATE("Line Type",CostCenter."Line Type"::"Cost Center");
      CostCenter.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134392 to show one way of using this function.

      // Setup.
      LibraryCostAccounting.CreateCostCenter(CostCenter);
      LibraryCostAccounting.CreateAllocSource(CostAllocationSource,TypeOfID::"Auto Generated");
      LibraryCostAccounting.CreateAllocTarget(
        CostAllocationTarget,CostAllocationSource,LibraryRandom.RandDec(10,1),Base,AllocationType);
      CostAllocationTarget."Target Cost Center" := CostCenter.Code;
      CostAllocationTarget.MODIFY(TRUE);
      LibraryVariableStorage.Enqueue(SkipalocSourceswithoutaloctgt);

      // Exercise: Run report Cost Allocation with Target Cost Type.
      RunCostAllocationsReport(CostAllocationSource);

      // Verify: Verify Target Cost Type and "Target Cost Center".
      VerifyCostAllocationTarget(CostAllocationTarget);
Member of Lib.Library - Cost Accounting


CreateCostCenterFromDimension@25 Method

The procedure CreateCostCenterFromDimension is available in codeunit 131340.

Syntax

CreateCostCenterFromDimension@25(
    VAR CostCenter@1000 : Record 1112 CostCenter //Reference parameter of type Record
);

Parameters

CostCenter
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Cost, Center, From, Dimension.

For a clarification about how this function works, refer to the code listed below.

      CostAccountingSetup.GET;
      SetAlignment(
        CostAccountingSetup.FIELDNO("Align Cost Center Dimension"),CostAccountingSetup."Align Cost Center Dimension"::Automatic);
      LibraryDimension.CreateDimensionValue(DimensionValue,CostAccountingSetup."Cost Center Dimension");
      CostCenter.GET(DimensionValue.Code);

Example

The below example is extracted from the test automation codeunit 134814 to show one way of using this function.

      Initialize;

      // Setup budgets
      LibraryERM.CreateGLBudgetName(TargetGLBudgetName);
      LibraryCostAccounting.CreateCostBudgetName(SourceCostBudgetName);

      LibraryCostAccounting.CreateCostCenterFromDimension(CostCenter);
      CreateCostBudgetEntry(CostBudgetEntry,SourceCostBudgetName.Name,CostCenter.Code,'');

      // Exercise:
      COMMIT;
      SetSharedVars(SourceCostBudgetName.Name,TargetGLBudgetName.Name,'1M',1,1);
      REPORT.RUN(REPORT::"Copy Cost Acctg. Budget to G/L");

      // Verify:
      ValidateCopyCAToGL(SourceCostBudgetName.Name,TargetGLBudgetName.Name,
        ROUND(CostBudgetEntry.Amount,0.01),CALCDATE(STRSUBSTNO(DateFilter,'1M'),CostBudgetEntry.Date));
Member of Lib.Library - Cost Accounting


CreateCostJnlBatchWithDelOpt@57 Method

The procedure CreateCostJnlBatchWithDelOpt is available in codeunit 131340.

Syntax

CreateCostJnlBatchWithDelOpt@57(
    VAR CostJournalBatch@1001 : Record 1102 CostJournalBatch, //Reference parameter of type Record
    CostJournalTemplateName@1000 : Code[10] CostJournalTemplateName, //Input parameter of type Code
    DeleteAfterPosting@1002 : Boolean DeleteAfterPosting //Input parameter of type Boolean
);

Parameters

CostJournalBatch
Reference parameter of type Record
CostJournalTemplateName
Input parameter of type Code
DeleteAfterPosting
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, Cost, Journal, Batch, Del, Opt.

For a clarification about how this function works, refer to the code listed below.

      CostJournalBatch.INIT;
      CostJournalBatch.VALIDATE("Journal Template Name",CostJournalTemplateName);
      CostJournalBatch.VALIDATE("Delete after Posting",DeleteAfterPosting);
      CostJournalBatch.VALIDATE(Name,LibraryUtility.GenerateRandomCode(CostJournalBatch.FIELDNO(Name),DATABASE::"Cost Journal Batch"));
      CostJournalBatch.VALIDATE(Description,CostJournalBatch.Name);  // Validating Name as Description because value is not important.
      IF CostJournalBatch.INSERT(TRUE) THEN ;

Example

There are no examples available.
Member of Lib.Library - Cost Accounting


CreateCostJournalBatch@55 Method

The procedure CreateCostJournalBatch is available in codeunit 131340.

Syntax

CreateCostJournalBatch@55(
    VAR CostJournalBatch@1000 : Record 1102 CostJournalBatch, //Reference parameter of type Record
    CostJournalTemplateName@1001 : Code[10] CostJournalTemplateName //Input parameter of type Code
);

Parameters

CostJournalBatch
Reference parameter of type Record
CostJournalTemplateName
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Cost, Journal, Batch.

For a clarification about how this function works, refer to the code listed below.

      CreateCostJnlBatchWithDelOpt(CostJournalBatch,CostJournalTemplateName,TRUE);

Example

The below example is extracted from the test automation codeunit 134392 to show one way of using this function.

      LibraryCostAccounting.CreateCostJournalTemplate(CostJournalTemplate);
      LibraryCostAccounting.CreateCostJournalBatch(CostJournalBatch,CostJournalTemplate.Name);
Member of Lib.Library - Cost Accounting


CreateCostJournalLine@5 Method

The procedure CreateCostJournalLine is available in codeunit 131340.

Syntax

CreateCostJournalLine@5(
    VAR CostJournalLine@1000 : Record 1101 CostJournalLine, //Reference parameter of type Record
    CostJournalTemplateName@1004 : Code[10] CostJournalTemplateName, //Input parameter of type Code
    CostJournalBatchName@1005 : Code[10] CostJournalBatchName //Input parameter of type Code
);

Parameters

CostJournalLine
Reference parameter of type Record
CostJournalTemplateName
Input parameter of type Code
CostJournalBatchName
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Cost, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      FindCostType(CostType);
      FindCostType(BalCostType);

      CreateCostJournalLineBasic(
        CostJournalLine,CostJournalTemplateName,CostJournalBatchName,WORKDATE,CostType."No.",BalCostType."No.");

      CheckCostJnlLineConsistency(CostJournalLine);

Example

The below example is extracted from the test automation codeunit 134811 to show one way of using this function.

      Initialize;

      // Setup:
      FindCostJnlBatchAndTemplate(CostJournalBatch);

      // Exercise:
      LibraryCostAccounting.CreateCostJournalLine(CostJournalLine,CostJournalBatch."Journal Template Name",CostJournalBatch.Name);
      CostJournalLine.VALIDATE("Bal. Cost Type No.",'');
      CostJournalLine.MODIFY(TRUE);

      // Verify:
      ASSERTERROR LibraryCostAccounting.PostCostJournalLine(CostJournalLine);
      Assert.IsTrue(STRPOS(GETLASTERRORTEXT,STRSUBSTNO(CostJnlBatchNotBalancedError,CostJournalLine.Amount)) > 0,
        UnexpectedErrorMessage);

      // Teardown.
      CLEARLASTERROR;
      ClearCostAccountingSetup;
Member of Lib.Library - Cost Accounting


CreateCostJournalLineBasic@42 Method

The procedure CreateCostJournalLineBasic is available in codeunit 131340.

Syntax

CreateCostJournalLineBasic@42(
    VAR CostJournalLine@1000 : Record 1101 CostJournalLine, //Reference parameter of type Record
    CostJournalTemplateName@1004 : Code[10] CostJournalTemplateName, //Input parameter of type Code
    CostJournalBatchName@1005 : Code[10] CostJournalBatchName, //Input parameter of type Code
    PostingDate@1007 : Date PostingDate, //Input parameter of type Date
    CostTypeNo@1006 : Code[20] CostTypeNo, //Input parameter of type Code
    BalCostTypeNo@1008 : Code[20] BalCostTypeNo //Input parameter of type Code
);

Parameters

CostJournalLine
Reference parameter of type Record
CostJournalTemplateName
Input parameter of type Code
CostJournalBatchName
Input parameter of type Code
PostingDate
Input parameter of type Date
CostTypeNo
Input parameter of type Code
BalCostTypeNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Cost, Journal, Line, Basic.

For a clarification about how this function works, refer to the code listed below.

      CostJournalLine.INIT;
      CostJournalLine.VALIDATE("Journal Template Name",CostJournalTemplateName);
      CostJournalLine.VALIDATE("Journal Batch Name",CostJournalBatchName);
      RecRef.GETTABLE(CostJournalLine);
      CostJournalLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,CostJournalLine.FIELDNO("Line No.")));
      CostJournalLine.INSERT(TRUE);

      CostJournalLine.VALIDATE("Posting Date",PostingDate);
      CostJournalLine.VALIDATE("Document No.",CostTypeNo);
      CostJournalLine.VALIDATE("Cost Type No.",CostTypeNo);
      CostJournalLine.VALIDATE("Bal. Cost Type No.",BalCostTypeNo);
      CostJournalLine.VALIDATE(Amount,LibraryRandom.RandInt(1000));
      CostJournalLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134392 to show one way of using this function.

      // To verify amount for all 7 Control Cost Center with respect to Cost Type No.

      // Setup : Create Multiple Cost Journal Line with New Cost Center.
      Initialize;
      CreateCostJournalBatch(CostJournalBatch);
      CreateCostTypeWithCC(BalCostType);
      FOR Count := 1 TO 7 DO BEGIN // As on Request page there is 7 Control.
        CreateCostTypeWithCC(CostType);
        LibraryCostAccounting.CreateCostJournalLineBasic(
          CostJournalLine[Count],CostJournalBatch."Journal Template Name",CostJournalBatch.Name,WORKDATE,CostType."No.",
          BalCostType."No.");
        LibraryVariableStorage.Enqueue(CostJournalLine[Count]."Cost Center Code");
      END;

      // Post-Setup : Post multiple Cost Journal Lines.
      PostCostJournalLines(CostJournalBatch."Journal Template Name",CostJournalBatch.Name);

      // Exercise : Run the Report with Filters Cost Center Code.
      RunCostAcctgAnalysisReport;

      // Verify : To check correct amount is displayed on report.
      LibraryReportDataset.LoadDataSetFile;
      FOR Count := 1 TO 7 DO
        VerifyCostAcctgAnalysisReportValue(
          CostJournalLine[Count].Amount,'Col' + FORMAT(Count),CostJournalLine[Count]."Cost Type No.");
Member of Lib.Library - Cost Accounting


CreateCostJournalTemplate@60 Method

The procedure CreateCostJournalTemplate is available in codeunit 131340.

Syntax

CreateCostJournalTemplate@60(
    VAR CostJournalTemplate@1000 : Record 1100 CostJournalTemplate //Reference parameter of type Record
);

Parameters

CostJournalTemplate
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Cost, Journal, Template.

For a clarification about how this function works, refer to the code listed below.

      CostJournalTemplate.INIT;
      CostJournalTemplate.VALIDATE(
        Name,LibraryUtility.GenerateRandomCode(CostJournalTemplate.FIELDNO(Name),DATABASE::"Cost Journal Template"));
      CostJournalTemplate.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134392 to show one way of using this function.

      LibraryCostAccounting.CreateCostJournalTemplate(CostJournalTemplate);
      LibraryCostAccounting.CreateCostJournalBatch(CostJournalBatch,CostJournalTemplate.Name);
Member of Lib.Library - Cost Accounting


CreateCostObject@12 Method

The procedure CreateCostObject is available in codeunit 131340.

Syntax

CreateCostObject@12(
    VAR CostObject@1000 : Record 1113 CostObject //Reference parameter of type Record
);

Parameters

CostObject
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Cost, Object.

For a clarification about how this function works, refer to the code listed below.

      CostObject.INIT;
      CostObject.VALIDATE(Code,LibraryUtility.GenerateRandomCode(CostObject.FIELDNO(Code),DATABASE::"Cost Object"));
      CostObject.VALIDATE("Line Type",CostObject."Line Type"::"Cost Object");
      CostObject.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134392 to show one way of using this function.

      LibraryCostAccounting.CreateCostCenter(CostCenter);
      LibraryCostAccounting.CreateCostObject(CostObject);
Member of Lib.Library - Cost Accounting


CreateCostObjectFromDimension@15 Method

The procedure CreateCostObjectFromDimension is available in codeunit 131340.

Syntax

CreateCostObjectFromDimension@15(
    VAR CostObject@1003 : Record 1113 CostObject //Reference parameter of type Record
);

Parameters

CostObject
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Cost, Object, From, Dimension.

For a clarification about how this function works, refer to the code listed below.

      CostAccountingSetup.GET;
      SetAlignment(
        CostAccountingSetup.FIELDNO("Align Cost Object Dimension"),CostAccountingSetup."Align Cost Object Dimension"::Automatic);
      LibraryDimension.CreateDimensionValue(DimensionValue,CostAccountingSetup."Cost Object Dimension");
      CostObject.GET(DimensionValue.Code);

Example

The below example is extracted from the test automation codeunit 134814 to show one way of using this function.

      Initialize;

      // Setup budgets
      LibraryERM.CreateGLBudgetName(TargetGLBudgetName);
      LibraryCostAccounting.CreateCostBudgetName(SourceCostBudgetName);

      LibraryCostAccounting.CreateCostObjectFromDimension(CostObject);
      CreateCostBudgetEntry(CostBudgetEntry,SourceCostBudgetName.Name,'',CostObject.Code);

      // Exercise:
      COMMIT;
      SetSharedVars(SourceCostBudgetName.Name,TargetGLBudgetName.Name,'1M',1,1);
      REPORT.RUN(REPORT::"Copy Cost Acctg. Budget to G/L");

      // Verify:
      ValidateCopyCAToGL(SourceCostBudgetName.Name,TargetGLBudgetName.Name,
        ROUND(CostBudgetEntry.Amount,0.01),CALCDATE(STRSUBSTNO(DateFilter,'1M'),CostBudgetEntry.Date));
Member of Lib.Library - Cost Accounting


CreateCostType@10 Method

The procedure CreateCostType is available in codeunit 131340.

Syntax

CreateCostType@10(
    VAR CostType@1000 : Record 1103 CostType //Reference parameter of type Record
);

Parameters

CostType
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Cost, Type.

For a clarification about how this function works, refer to the code listed below.

      CreateCostTypeWithGLRange(CostType,FALSE);

Example

The below example is extracted from the test automation codeunit 134810 to show one way of using this function.

      // Setup:
      Initialize;
      LibraryCostAccounting.CreateCostType(CostType);

      // Exercise:
      NewName := CostType.Name + FORMAT(LibraryRandom.RandInt(100));
      CostType.VALIDATE(Name,NewName);
      CostType.MODIFY(TRUE);

      // Verify:
      CostType.TESTFIELD(Name,NewName);
      GLAccount.GET(CostType."G/L Account Range");
      Assert.AreNotEqual(GLAccount.Name,NewName,STRSUBSTNO(ExpectedValueIsDifferentError,GLAccount.FIELDNAME(Name)));
Member of Lib.Library - Cost Accounting


CreateCostTypeNoGLRange@29 Method

The procedure CreateCostTypeNoGLRange is available in codeunit 131340.

Syntax

CreateCostTypeNoGLRange@29(
    VAR CostType@1000 : Record 1103 CostType //Reference parameter of type Record
);

Parameters

CostType
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Cost, Type, No, General Ledger, Range.

For a clarification about how this function works, refer to the code listed below.

      CostType.INIT;
      CostType.VALIDATE("No.",LibraryUtility.GenerateRandomCode(CostType.FIELDNO("No."),DATABASE::"Cost Type"));
      CostType.VALIDATE(Type,CostType.Type::"Cost Type");
      CostType.VALIDATE("Combine Entries",CostType."Combine Entries"::None);
      CostType.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134392 to show one way of using this function.

      LibraryCostAccounting.CreateCostTypeNoGLRange(CostType);
      LibraryCostAccounting.CreateCostCenter(CostCenter);
      CostType.VALIDATE("Cost Center Code",CostCenter.Code);
      CostType.MODIFY(TRUE);
Member of Lib.Library - Cost Accounting


CreateCostTypeWithCombine@19 Method

The procedure CreateCostTypeWithCombine is available in codeunit 131340.

Syntax

CreateCostTypeWithCombine@19(
    VAR CostType@1000 : Record 1103 CostType, //Reference parameter of type Record
    CombineEntries@1001 : Option CombineEntries //Input parameter of type Option
);

Parameters

CostType
Reference parameter of type Record
CombineEntries
Input parameter of type Option

Remarks

The relevant search keywords are: Create, Cost, Type, Combine.

For a clarification about how this function works, refer to the code listed below.

      CreateCostTypeWithGLRange(CostType,TRUE);
      CostType.VALIDATE("Combine Entries",CombineEntries);
      CostType.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - Cost Accounting


CreateCostTypeWithGLRange@11 Method

The procedure CreateCostTypeWithGLRange is available in codeunit 131340.

Syntax

CreateCostTypeWithGLRange@11(
    VAR CostType@1000 : Record 1103 CostType, //Reference parameter of type Record
    MultipleGLAccounts@1004 : Boolean MultipleGLAccounts //Input parameter of type Boolean
);

Parameters

CostType
Reference parameter of type Record
MultipleGLAccounts
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, Cost, Type, General Ledger, Range.

For a clarification about how this function works, refer to the code listed below.

      SetAlignment(CostAccountingSetup.FIELDNO("Align G/L Account"),CostAccountingSetup."Align G/L Account"::Automatic);
      CreateIncomeStmtGLAccount(GLAccount);
      CostType.GET(GLAccount."Cost Type No.");
      CostType.TESTFIELD("G/L Account Range",GLAccount."No.");
      GLAccount.TESTFIELD("Cost Type No.",CostType."No.");

      IF MultipleGLAccounts THEN BEGIN
        SetAlignment(CostAccountingSetup.FIELDNO("Align G/L Account"),CostAccountingSetup."Align G/L Account"::"No Alignment");

        FOR Index := 1 TO LibraryRandom.RandInt(5) DO BEGIN
          CLEAR(GLAccount);
          CreateIncomeStmtGLAccount(GLAccount);
        END;

        GLAccountFilter := STRSUBSTNO(GLAccountFilterDefinition,CostType."G/L Account Range",GLAccount."No.");
        Assert.AreEqual(MAXSTRLEN(CostType."G/L Account Range"),MAXSTRLEN(GLAccountFilter),'Passing filter must fit field length');
        CostType.VALIDATE("G/L Account Range",GLAccountFilter);
        CostType.MODIFY(TRUE);
      END;

Example

The below example is extracted from the test automation codeunit 134820 to show one way of using this function.

      // Cod1100 existent GLAcc without valid CC and CO is modified, cost type is also existed so test will update it
      Initialize;

      LibraryCostAccounting.CreateCostTypeWithGLRange(CostType,FALSE);
      GLAccount.GET(CostType."No.");

      RandomSearchName :=
        COPYSTR(LibraryUtility.GenerateRandomCode(GLAccount.FIELDNO("Search Name"),DATABASE::"G/L Account"),
          1,LibraryUtility.GetFieldLength(DATABASE::"G/L Account",GLAccount.FIELDNO("Search Name")));

      GLAccount.VALIDATE("Search Name",RandomSearchName);
      GLAccount.MODIFY; // Code under trigger should not run.

      CostAccountMgt.UpdateCostTypeFromGLAcc(GLAccount,xGLAccount,CallingTrigger::OnModify);

      CostType.GET(GLAccount."No.");
      GLAccount.TESTFIELD("No.",CostType."No.");
      CostType.TESTFIELD("Cost Center Code",'');
      CostType.TESTFIELD("Cost Object Code",'');
      CostType.TESTFIELD("Search Name",RandomSearchName);

      LibraryCostAccounting.SetAlignment(
        CostAccountingSetup.FIELDNO("Align G/L Account"),CostAccountingSetup."Align G/L Account"::"No Alignment");
Member of Lib.Library - Cost Accounting


CreateIncomeStmtGLAccount@27 Method

The procedure CreateIncomeStmtGLAccount is available in codeunit 131340.

Syntax

CreateIncomeStmtGLAccount@27(
    VAR GLAccount@1000 : Record 15 GLAccount //Reference parameter of type Record
);

Parameters

GLAccount
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Income, Statement, General Ledger, Account.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.CreateGLAccount(GLAccount);
      GLAccount.VALIDATE("Income/Balance",GLAccount."Income/Balance"::"Income Statement");
      GLAccount.MODIFY(TRUE);

      IF CostType.GET(GLAccount."Cost Type No.") THEN
        IF CostType."G/L Account Range" <> GLAccount."No." THEN BEGIN
          IF CostType."G/L Account Range" = '' THEN BEGIN
            CostType.VALIDATE("G/L Account Range",GLAccount."No.");
            CostType.MODIFY(TRUE);
          END ELSE
            ERROR(STRSUBSTNO(IncorrectGLAccountNo,CostType."G/L Account Range",CostType."No.",GLAccount."No."));
        END;

Example

The below example is extracted from the test automation codeunit 134810 to show one way of using this function.

      Initialize;

      // Setup:
      LibraryCostAccounting.CreateIncomeStmtGLAccount(GLAccount);
      GLAccount.TESTFIELD("Cost Type No.",GLAccount."No.");

      // Exercise:
      GLAccount.VALIDATE("Income/Balance",GLAccount."Income/Balance"::"Balance Sheet");
      GLAccount.MODIFY(TRUE);

      // Verify:
      GLAccount.TESTFIELD("Cost Type No.",'');
      CostType.GET(GLAccount."No.");
      CostType.TESTFIELD("G/L Account Range",'');
Member of Lib.Library - Cost Accounting


CreateJnlLine@70 Method

The procedure CreateJnlLine is available in codeunit 131340.

Syntax

CreateJnlLine@70(
    VAR GenJournalLine@1000 : Record 81 GenJournalLine, //Reference parameter of type Record
    AccountNo@1002 : Code[20] AccountNo //Input parameter of type Code
);

Parameters

GenJournalLine
Reference parameter of type Record
AccountNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      SetupGeneralJnlBatch(GenJournalBatch);

      // Create General Journal Line.
      LibraryERM.CreateGeneralJnlLine(
        GenJournalLine,GenJournalBatch."Journal Template Name",GenJournalBatch.Name,GenJournalLine."Document Type"::Payment,
        GenJournalLine."Account Type"::"G/L Account",AccountNo,LibraryRandom.RandDec(1000,2));

      // Update journal line to avoid Posting errors
      GenJournalLine.VALIDATE("Gen. Posting Type",GenJournalLine."Gen. Posting Type"::" ");
      GenJournalLine.VALIDATE("Gen. Bus. Posting Group",'');
      GenJournalLine.VALIDATE("Gen. Prod. Posting Group",'');
      GenJournalLine.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - Cost Accounting


DeleteAllCostTypeEntries@14 Method

The procedure DeleteAllCostTypeEntries is available in codeunit 131340.

Syntax

DeleteAllCostTypeEntries@14(
      //param element not supplied
);

Remarks

The relevant search keywords are: Delete, All, Cost, Type, Entries.

For a clarification about how this function works, refer to the code listed below.

      IF CostType.ISEMPTY THEN
        EXIT;

      CostType.DELETEALL(TRUE);

Example

There are no examples available.
Member of Lib.Library - Cost Accounting


DeleteBlockedDimCombinations@68 Method

The procedure DeleteBlockedDimCombinations is available in codeunit 131340.

Syntax

DeleteBlockedDimCombinations@68(
    VAR DimensionCombination@1001 : Record 350 DimensionCombination //Reference parameter of type Record
);

Parameters

DimensionCombination
Reference parameter of type Record

Remarks

The relevant search keywords are: Delete, Blocked, Dimension, Combinations.

For a clarification about how this function works, refer to the code listed below.

      IF DimensionCombination.FINDSET THEN
        REPEAT
          IF DimensionCombination."Combination Restriction" = DimensionCombination."Combination Restriction"::Blocked THEN
            DimensionCombination.DELETE(TRUE);
        UNTIL DimensionCombination.NEXT = 0;

Example

There are no examples available.
Member of Lib.Library - Cost Accounting


DeleteCostBudgetRegEntries@45 Method

The procedure DeleteCostBudgetRegEntries is available in codeunit 131340.

Syntax

DeleteCostBudgetRegEntries@45(
      //param element not supplied
);

Remarks

The relevant search keywords are: Delete, Cost, Budget, Reg, Entries.

For a clarification about how this function works, refer to the code listed below.

      IF CostBudgetRegister.FINDFIRST THEN
        DeleteCostBudgetRegEntriesFrom(CostBudgetRegister."No.");

Example

There are no examples available.
Member of Lib.Library - Cost Accounting


DeleteCostBudgetRegEntriesFrom@52 Method

The procedure DeleteCostBudgetRegEntriesFrom is available in codeunit 131340.

Syntax

DeleteCostBudgetRegEntriesFrom@52(
    StartEntry@1001 : Integer StartEntry //Input parameter of type Integer
);

Parameters

StartEntry
Input parameter of type Integer

Remarks

The relevant search keywords are: Delete, Cost, Budget, Reg, Entries, From.

For a clarification about how this function works, refer to the code listed below.

      IF CostBudgetRegister.FINDLAST THEN BEGIN
        DeleteCostBudgetEntries.InitializeRequest(StartEntry,CostBudgetRegister."No.");
        DeleteCostBudgetEntries.USEREQUESTPAGE := FALSE;
        DeleteCostBudgetEntries.RUNMODAL;
      END;

Example

The below example is extracted from the test automation codeunit 134816 to show one way of using this function.

      Initialize;

      // Setup:
      LibraryCostAccounting.CreateCostBudgetName(CostBudgetName);
      NoOfRegisterEntriesBefore := CostBudgetRegister.COUNT;

      COMMIT;
      GlobalCostBudget := CostBudgetName.Name;
      REPORT.RUN(REPORT::"Cost Allocation");

      NoOfCostBudgetRegEntries := CostBudgetRegister.COUNT - NoOfRegisterEntriesBefore;
      LastClosedEntryNo := CloseCostBudgetRegEntries(NoOfCostBudgetRegEntries);

      // Exercise and Verify:
      ASSERTERROR LibraryCostAccounting.DeleteCostBudgetRegEntriesFrom(LastClosedEntryNo);
      Assert.AreEqual(
        STRSUBSTNO(DeleteClosedEntryError,LastClosedEntryNo),GETLASTERRORTEXT,STRSUBSTNO(UnexpectedErrorMessage,GETLASTERRORTEXT));
      CLEARLASTERROR;
Member of Lib.Library - Cost Accounting


DeleteCostRegisterEntries@13 Method

The procedure DeleteCostRegisterEntries is available in codeunit 131340.

Syntax

DeleteCostRegisterEntries@13(
      //param element not supplied
);

Remarks

The relevant search keywords are: Delete, Cost, Register, Entries.

For a clarification about how this function works, refer to the code listed below.

      IF CostRegister.FINDFIRST THEN
        DeleteCostRegisterEntriesFrom(CostRegister."No.");

Example

There are no examples available.
Member of Lib.Library - Cost Accounting


DeleteCostRegisterEntriesFrom@17 Method

The procedure DeleteCostRegisterEntriesFrom is available in codeunit 131340.

Syntax

DeleteCostRegisterEntriesFrom@17(
    StartEntry@1000 : Integer StartEntry //Input parameter of type Integer
);

Parameters

StartEntry
Input parameter of type Integer

Remarks

The relevant search keywords are: Delete, Cost, Register, Entries, From.

For a clarification about how this function works, refer to the code listed below.

      IF CostRegister.FINDLAST THEN BEGIN
        DeleteCostEntries.InitializeRequest(StartEntry,CostRegister."No.");
        DeleteCostEntries.USEREQUESTPAGE := FALSE;
        DeleteCostEntries.RUNMODAL;
      END;

Example

The below example is extracted from the test automation codeunit 134816 to show one way of using this function.

      Initialize;

      // Setup:
      COMMIT;
      REPORT.RUN(REPORT::"Cost Allocation");

      CostRegister.SETRANGE(Source,CostRegister.Source::Allocation);
      CostRegister.FINDLAST;
      LastAllocatedJnlNo := CostRegister."No.";
      ReversedCostAllocEntriesCount := AllocatedWithJnlNo(LastAllocatedJnlNo) + AllocatedInJnlNo(LastAllocatedJnlNo);
      TotalAllocatedEntriesCountOld := TotalAllocatedCostEntries;

      // Exercise:
      LibraryCostAccounting.DeleteCostRegisterEntriesFrom(LastAllocatedJnlNo);

      // Verify:
      Assert.AreEqual(0,AllocatedWithJnlNo(LastAllocatedJnlNo),IncorrectAllocEntriesCount);
      Assert.AreEqual(
        TotalAllocatedEntriesCountOld - ReversedCostAllocEntriesCount,TotalAllocatedCostEntries,IncorrectAllocEntriesCount);

      // Verify Last Alloc Doc No. field from Cost Accounting Setup
      CostEntry.SETRANGE(Allocated,TRUE);
      CostEntry.FINDLAST;
      VerifyLastAllocationDocNo(CostEntry."Document No.");
Member of Lib.Library - Cost Accounting


FindAllocSource@36 Method

The procedure FindAllocSource is available in codeunit 131340.

Syntax

FindAllocSource@36(
    VAR CostAllocationSource@1000 : Record 1106 CostAllocationSource //Reference parameter of type Record
);

Parameters

CostAllocationSource
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Allocation, Source.

For a clarification about how this function works, refer to the code listed below.

      CostAllocationSource.SETFILTER("Credit to Cost Type",'<>%1','');
      CostAllocationSource.SETFILTER("Cost Center Code",'<>%1','');

      IF CostAllocationSource.ISEMPTY THEN BEGIN
        CostAllocationSource.SETRANGE("Cost Center Code");
        CostAllocationSource.SETFILTER("Cost Object Code",'<>%1','');
      END;

      IF CostAllocationSource.ISEMPTY THEN
        ERROR(STRSUBSTNO(NoRecordsInFilterErr,CostAllocationSource.TABLECAPTION,CostAllocationSource.GETFILTERS));

      CostAllocationSource.NEXT(LibraryRandom.RandInt(CostAllocationSource.COUNT));

Example

There are no examples available.
Member of Lib.Library - Cost Accounting


FindCostCenter@2 Method

The procedure FindCostCenter is available in codeunit 131340.

Syntax

FindCostCenter@2(
    VAR CostCenter@1000 : Record 1112 CostCenter //Reference parameter of type Record
);

Parameters

CostCenter
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Cost, Center.

For a clarification about how this function works, refer to the code listed below.

      CostCenter.SETFILTER("Line Type",FORMAT(CostCenter."Line Type"::"Cost Center"));
      CostCenter.SETFILTER(Blocked,'%1',FALSE);
      CostCenter.SETFILTER("Net Change",'<>%1',0);
      CostCenter.SETFILTER("Balance at Date",'<>%1',0);
      IF CostCenter.ISEMPTY THEN
        ERROR(STRSUBSTNO(NoRecordsInFilterErr,CostCenter.TABLECAPTION,CostCenter.GETFILTERS));

      CostCenter.NEXT(LibraryRandom.RandInt(CostCenter.COUNT));

Example

The below example is extracted from the test automation codeunit 134814 to show one way of using this function.

      LibraryCostAccounting.FindCostType(CostType);
      LibraryCostAccounting.FindCostCenter(CostCenter);
      FindCostJnlBatchAndTemplate(CostJournalBatch);
      LibraryCostAccounting.CreateCostJournalLineBasic(
        CostJournalLine,CostJournalBatch."Journal Template Name",CostJournalBatch.Name,PostingDate,CostTypeNo,CostType."No.");
      CostJournalLine.VALIDATE("Cost Center Code",CostCenterCode);
      CostJournalLine.VALIDATE("Cost Object Code",'');
      CostJournalLine.VALIDATE("Bal. Cost Center Code",CostCenter.Code);
      CostJournalLine.VALIDATE("Bal. Cost Object Code",'');
      CostJournalLine.VALIDATE(Amount,Amount);
      CostJournalLine.MODIFY(TRUE);
      LibraryCostAccounting.PostCostJournalLine(CostJournalLine);
Member of Lib.Library - Cost Accounting


FindCostJnlBatchWithDelOption@56 Method

The procedure FindCostJnlBatchWithDelOption is available in codeunit 131340.

Syntax

FindCostJnlBatchWithDelOption@56(
    VAR CostJournalBatch@1000 : Record 1102 CostJournalBatch, //Reference parameter of type Record
    CostJournalTemplateName@1002 : Code[10] CostJournalTemplateName, //Input parameter of type Code
    DeleteAfterPosting@1001 : Boolean DeleteAfterPosting //Input parameter of type Boolean
);

Parameters

CostJournalBatch
Reference parameter of type Record
CostJournalTemplateName
Input parameter of type Code
DeleteAfterPosting
Input parameter of type Boolean

Remarks

The relevant search keywords are: Find, Cost, Journal, Batch, Del, Option.

For a clarification about how this function works, refer to the code listed below.

      CostJournalBatch.SETRANGE("Journal Template Name",CostJournalTemplateName);
      CostJournalBatch.SETRANGE("Delete after Posting",DeleteAfterPosting);
      IF CostJournalBatch.ISEMPTY THEN
        CreateCostJournalBatch(CostJournalBatch,CostJournalTemplateName)
      ELSE
        CostJournalBatch.FINDFIRST;

Example

There are no examples available.
Member of Lib.Library - Cost Accounting


FindCostJournalBatch@6 Method

The procedure FindCostJournalBatch is available in codeunit 131340.

Syntax

FindCostJournalBatch@6(
    VAR CostJournalBatch@1000 : Record 1102 CostJournalBatch, //Reference parameter of type Record
    CostJournalTemplateName@1002 : Code[10] CostJournalTemplateName //Input parameter of type Code
);

Parameters

CostJournalBatch
Reference parameter of type Record
CostJournalTemplateName
Input parameter of type Code

Remarks

The relevant search keywords are: Find, Cost, Journal, Batch.

For a clarification about how this function works, refer to the code listed below.

      FindCostJnlBatchWithDelOption(CostJournalBatch,CostJournalTemplateName,TRUE);

Example

The below example is extracted from the test automation codeunit 134811 to show one way of using this function.

      LibraryCostAccounting.FindCostJournalTemplate(CostJournalTemplate);
      LibraryCostAccounting.FindCostJournalBatch(CostJournalBatch,CostJournalTemplate.Name);
      LibraryCostAccounting.ClearCostJournalLines(CostJournalBatch);
Member of Lib.Library - Cost Accounting


FindCostJournalTemplate@21 Method

The procedure FindCostJournalTemplate is available in codeunit 131340.

Syntax

FindCostJournalTemplate@21(
    VAR CostJournalTemplate@1000 : Record 1100 CostJournalTemplate //Reference parameter of type Record
);

Parameters

CostJournalTemplate
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Cost, Journal, Template.

For a clarification about how this function works, refer to the code listed below.

      CostJournalTemplate.FINDFIRST;

Example

The below example is extracted from the test automation codeunit 134811 to show one way of using this function.

      LibraryCostAccounting.FindCostJournalTemplate(CostJournalTemplate);
      LibraryCostAccounting.FindCostJournalBatch(CostJournalBatch,CostJournalTemplate.Name);
      LibraryCostAccounting.ClearCostJournalLines(CostJournalBatch);
Member of Lib.Library - Cost Accounting


FindCostObject@4 Method

The procedure FindCostObject is available in codeunit 131340.

Syntax

FindCostObject@4(
    VAR CostObject@1000 : Record 1113 CostObject //Reference parameter of type Record
);

Parameters

CostObject
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Cost, Object.

For a clarification about how this function works, refer to the code listed below.

      CostObject.SETFILTER("Line Type",FORMAT(CostObject."Line Type"::"Cost Object"));
      CostObject.SETFILTER(Blocked,'%1',FALSE);
      CostObject.SETFILTER("Net Change",'<>%1',0);
      CostObject.SETFILTER("Balance at Date",'<>%1',0);
      IF CostObject.ISEMPTY THEN
        ERROR(STRSUBSTNO(NoRecordsInFilterErr,CostObject.TABLECAPTION,CostObject.GETFILTERS));

      CostObject.NEXT(LibraryRandom.RandInt(CostObject.COUNT));

Example

There are no examples available.
Member of Lib.Library - Cost Accounting


FindCostType@8 Method

The procedure FindCostType is available in codeunit 131340.

Syntax

FindCostType@8(
    VAR CostType@1000 : Record 1103 CostType //Reference parameter of type Record
);

Parameters

CostType
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Cost, Type.

For a clarification about how this function works, refer to the code listed below.

      GetAllCostTypes(CostType);
      IF CostType.ISEMPTY THEN
        ERROR(STRSUBSTNO(NoRecordsInFilterErr,CostType.TABLECAPTION,CostType.GETFILTERS));

      CostType.NEXT(LibraryRandom.RandInt(CostType.COUNT));

Example

The below example is extracted from the test automation codeunit 134814 to show one way of using this function.

      LibraryCostAccounting.FindCostType(CostType);
      LibraryCostAccounting.FindCostCenter(CostCenter);
      FindCostJnlBatchAndTemplate(CostJournalBatch);
      LibraryCostAccounting.CreateCostJournalLineBasic(
        CostJournalLine,CostJournalBatch."Journal Template Name",CostJournalBatch.Name,PostingDate,CostTypeNo,CostType."No.");
      CostJournalLine.VALIDATE("Cost Center Code",CostCenterCode);
      CostJournalLine.VALIDATE("Cost Object Code",'');
      CostJournalLine.VALIDATE("Bal. Cost Center Code",CostCenter.Code);
      CostJournalLine.VALIDATE("Bal. Cost Object Code",'');
      CostJournalLine.VALIDATE(Amount,Amount);
      CostJournalLine.MODIFY(TRUE);
      LibraryCostAccounting.PostCostJournalLine(CostJournalLine);
Member of Lib.Library - Cost Accounting


FindCostTypeLinkedToGLAcc@49 Method

The procedure FindCostTypeLinkedToGLAcc is available in codeunit 131340.

Syntax

FindCostTypeLinkedToGLAcc@49(
    VAR CostType@1000 : Record 1103 CostType //Reference parameter of type Record
);

Parameters

CostType
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Cost, Type, Linked, To, General Ledger, Account.

For a clarification about how this function works, refer to the code listed below.

      GLAccount.SETFILTER("Cost Type No.",'<>%1','');
      IF GLAccount.ISEMPTY THEN
        ERROR(STRSUBSTNO(NoRecordsInFilterErr,GLAccount.TABLECAPTION,GLAccount.GETFILTERS));

      GLAccount.FINDSET;
      GLAccount.NEXT(LibraryRandom.RandInt(GLAccount.COUNT));
      CostType.GET(GLAccount."Cost Type No.");

Example

The below example is extracted from the test automation codeunit 134814 to show one way of using this function.

      LibraryCostAccounting.CreateCostBudgetEntry(CostBudgetEntry,CostBudgetName);
      LibraryCostAccounting.FindCostTypeLinkedToGLAcc(CostType);

      CostBudgetEntry.VALIDATE("Cost Center Code",CostCenterCode);
      CostBudgetEntry.VALIDATE("Cost Object Code",CostObjectCode);
      CostBudgetEntry.VALIDATE("Cost Type No.",CostType."No.");
      CostBudgetEntry.MODIFY(TRUE);
Member of Lib.Library - Cost Accounting


FindCostTypeWithCostCenter@16 Method

The procedure FindCostTypeWithCostCenter is available in codeunit 131340.

Syntax

FindCostTypeWithCostCenter@16(
    VAR CostType@1000 : Record 1103 CostType //Reference parameter of type Record
);

Parameters

CostType
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Cost, Type, Cost, Center.

For a clarification about how this function works, refer to the code listed below.

      GetAllCostTypes(CostType);
      CostType.SETFILTER("Cost Center Code",'<>%1','');
      CostType.SETFILTER("Cost Object Code",'%1','');
      IF CostType.ISEMPTY THEN
        ERROR(STRSUBSTNO(NoRecordsInFilterErr,CostType.TABLECAPTION,CostType.GETFILTERS));

      CostType.NEXT(LibraryRandom.RandInt(CostType.COUNT));

Example

The below example is extracted from the test automation codeunit 134813 to show one way of using this function.

      LibraryCostAccounting.FindCostTypeWithCostCenter(CostType);
      FindCostTypeWithCostCenter(BalCostType,CostCenterCode);
      LibraryCostAccounting.CreateCostJournalLineBasic(
        CostJournalLine,CostJournalBatch."Journal Template Name",CostJournalBatch.Name,PostingDate,CostType."No.",BalCostType."No.");

      CostJournalLine.VALIDATE("Cost Center Code",CostCenterCode);
      CostJournalLine.MODIFY(TRUE);
Member of Lib.Library - Cost Accounting


FindGLAccLinkedToCostType@30 Method

The procedure FindGLAccLinkedToCostType is available in codeunit 131340.

Syntax

FindGLAccLinkedToCostType@30(
    VAR GLAccount@1000 : Record 15 GLAccount //Reference parameter of type Record
);

Parameters

GLAccount
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, General Ledger, Account, Linked, To, Cost, Type.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.FindGLAccount(GLAccount);
      GLAccount.SETFILTER("Cost Type No.",'<>%1','');
      IF GLAccount.ISEMPTY THEN
        ERROR(STRSUBSTNO(NoRecordsInFilterErr,GLAccount.TABLECAPTION,GLAccount.GETFILTERS));

      GLAccount.NEXT(LibraryRandom.RandInt(GLAccount.COUNT));

Example

The below example is extracted from the test automation codeunit 134819 to show one way of using this function.

      LibraryCostAccounting.FindGLAccLinkedToCostType(GLAccount);
      WITH GLEntry DO BEGIN
        IF FINDLAST THEN
          INIT;
        "Entry No." += 1;
        "G/L Account No." := GLAccount."No.";
        "Dimension Set ID" := DimSetID;
        "Document No." := GLAccount."No."; // Document No just needs to have a value, so it can be the same as G/L Account No.
        Amount := LibraryRandom.RandDec(100,2);
        "Posting Date" := WORKDATE;
        INSERT;
        EXIT("Entry No.");
      END;
Member of Lib.Library - Cost Accounting


FindGLAccountsByCostType@7 Method

The procedure FindGLAccountsByCostType is available in codeunit 131340.

Syntax

FindGLAccountsByCostType@7(
    VAR GLAccount@1001 : Record 15 GLAccount, //Reference parameter of type Record
    GLAccountRange@1000 : Text[50] GLAccountRange //Input parameter of type Text
);

Parameters

GLAccount
Reference parameter of type Record
GLAccountRange
Input parameter of type Text

Remarks

The relevant search keywords are: Find, General Ledger, Accounts, By, Cost, Type.

For a clarification about how this function works, refer to the code listed below.

      GLAccount.SETFILTER("No.",GLAccountRange);
      IF GLAccount.ISEMPTY THEN
        ERROR(STRSUBSTNO(NoRecordsInFilterErr,GLAccount.TABLECAPTION,GLAccount.GETFILTERS));

      GLAccount.FINDSET;

Example

The below example is extracted from the test automation codeunit 134810 to show one way of using this function.

      // The Cost Type has the G/L Account Range filled in.
      CostType.GET(CostTypeNo);
      CostType.TESTFIELD("G/L Account Range");

      // The G/L Accounts have the Cost Type No. filled in.
      LibraryCostAccounting.FindGLAccountsByCostType(GLAccount,CostType."G/L Account Range");
      REPEAT
        GLAccount.TESTFIELD("Cost Type No.",CostType."No.");
      UNTIL GLAccount.NEXT = 0;
Member of Lib.Library - Cost Accounting


FindIncomeStmtGLAccount@18 Method

The procedure FindIncomeStmtGLAccount is available in codeunit 131340.

Syntax

FindIncomeStmtGLAccount@18(
    VAR GLAccount@1000 : Record 15 GLAccount //Reference parameter of type Record
);

Parameters

GLAccount
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Income, Statement, General Ledger, Account.

For a clarification about how this function works, refer to the code listed below.

      GetAllIncomeStmtGLAccounts(GLAccount);
      GLAccount.NEXT(LibraryRandom.RandInt(GLAccount.COUNT));

Example

There are no examples available.
Member of Lib.Library - Cost Accounting


GetAllCostTypes@9 Method

The procedure GetAllCostTypes is available in codeunit 131340.

Syntax

GetAllCostTypes@9(
    VAR CostType@1000 : Record 1103 CostType //Reference parameter of type Record
);

Parameters

CostType
Reference parameter of type Record

Remarks

The relevant search keywords are: Get, All, Cost, Types.

For a clarification about how this function works, refer to the code listed below.

      CostType.INIT;
      CostType.SETFILTER(Type,FORMAT(CostType.Type::"Cost Type"));
      CostType.SETFILTER("G/L Account Range",'<>%1','');
      IF CostType.ISEMPTY THEN
        ERROR(STRSUBSTNO(NoRecordsInFilterErr,CostType.TABLECAPTION,CostType.GETFILTERS));
      CostType.FINDSET;

Example

The below example is extracted from the test automation codeunit 134810 to show one way of using this function.

      Initialize;
      LibraryCostAccounting.VerifyCostTypeIntegrity;

      // Setup:
      CostType.SETFILTER("G/L Account Range",'<>%1','');
      CostType.SETFILTER("Balance at Date",'%1',0);
      CostType.SETFILTER("Balance to Allocate",'%1',0);
      IF NOT CostType.FINDFIRST THEN
        ERROR(STRSUBSTNO(NoRecordsInFilterError,CostType.TABLECAPTION,CostType.GETFILTERS));
      CostType.DELETE(TRUE);

      // Exercise:
      CostAccountMgt.GetCostTypesFromChartOfAccount;

      // Verify:
      CLEAR(CostType);
      LibraryCostAccounting.GetAllCostTypes(CostType);
      ValidateGLAccountIsIncomeStmt(CostType);
      LibraryCostAccounting.VerifyCostTypeIntegrity;
Member of Lib.Library - Cost Accounting


GetAllIncomeStmtGLAccounts@23 Method

The procedure GetAllIncomeStmtGLAccounts is available in codeunit 131340.

Syntax

GetAllIncomeStmtGLAccounts@23(
    VAR GLAccount@1000 : Record 15 GLAccount //Reference parameter of type Record
);

Parameters

GLAccount
Reference parameter of type Record

Remarks

The relevant search keywords are: Get, All, Income, Statement, General Ledger, Accounts.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.FindGLAccount(GLAccount);
      GLAccount.SETFILTER("Income/Balance",FORMAT(GLAccount."Income/Balance"::"Income Statement"));
      IF GLAccount.ISEMPTY THEN
        ERROR(STRSUBSTNO(NoRecordsInFilterErr,GLAccount.TABLECAPTION,GLAccount.GETFILTERS));
      GLAccount.FINDSET;

Example

There are no examples available.
Member of Lib.Library - Cost Accounting


GetAllocTargetEntryAmount@46 Method

The procedure GetAllocTargetEntryAmount is available in codeunit 131340.

Syntax

GetAllocTargetEntryAmount@46(
    VAR CostAllocationTarget@1004 : Record 1107 CostAllocationTarget, //Reference parameter of type Record
    TotalAmount@1003 : Decimal TotalAmount, //Input parameter of type Decimal
    TableNumber@1005 : Integer TableNumber, //Input parameter of type Integer
    KeyFieldNumber@1002 : Integer KeyFieldNumber, //Input parameter of type Integer
    AmountFieldNumber@1010 : Integer AmountFieldNumber, //Input parameter of type Integer
    FromValue@1008 : Integer FromValue, //Input parameter of type Integer
    ToValue@1009 : Integer ToValue //Input parameter of type Integer
);

Parameters

CostAllocationTarget
Reference parameter of type Record
TotalAmount
Input parameter of type Decimal
TableNumber
Input parameter of type Integer
KeyFieldNumber
Input parameter of type Integer
AmountFieldNumber
Input parameter of type Integer
FromValue
Input parameter of type Integer
ToValue
Input parameter of type Integer

Return Value

Decimal

Remarks

The relevant search keywords are: Get, Allocation, Target, Entry, Amount.

For a clarification about how this function works, refer to the code listed below.

      RecordRef.OPEN(TableNumber);
      KeyFieldRef := RecordRef.FIELD(KeyFieldNumber);
      KeyFieldRef.SETRANGE(FromValue,(ToValue - 1));
      RecordRef.FINDSET;

      IF RecordRef.ISEMPTY THEN
        ERROR(STRSUBSTNO(NoRecordsInFilterErr,RecordRef.NAME,RecordRef.GETFILTERS));

      IF RecordRef.COUNT <> CostAllocationTarget.COUNT THEN
        ERROR(
          STRSUBSTNO(
            NumberOfRecordsNotMatchingErr,RecordRef.COUNT,RecordRef.NAME,CostAllocationTarget.COUNT,CostAllocationTarget.TABLECAPTION));

      AmountFieldRef := RecordRef.FIELD(AmountFieldNumber);

      REPEAT
        // To avoid the rounding errors, approximate the decimal numbers by cutting out the fractional part.
        FieldRefAmount := AmountFieldRef.VALUE;
        EntryAmount := ROUND(FieldRefAmount,1);
        AllocatedCost := ROUND(TotalAmount * (CostAllocationTarget.Percent / 100),1);

        IF EntryAmount <> AllocatedCost THEN
          IF -EntryAmount <> AllocatedCost THEN
            ERROR(
              STRSUBSTNO(
                AllocValuesNotMatchingErr,FieldRefAmount,EntryAmount,CostAllocationTarget.Percent,
                TotalAmount,AllocatedCost,(CostAllocationTarget.Percent * TotalAmount)));

        TotalDebitValue := TotalDebitValue + FieldRefAmount;
        CostAllocationTarget.NEXT;
      UNTIL RecordRef.NEXT = 0;

      EXIT(TotalDebitValue);

Example

The below example is extracted from the test automation codeunit 134813 to show one way of using this function.

      GetAllocTargets(CostAllocationTarget,AllocSourceID);

      TotalDebitValue :=
        LibraryCostAccounting.GetAllocTargetEntryAmount(
          CostAllocationTarget,TotalAmount,TableNumber,KeyFieldNumber,AmountFieldNumber,FromEntryNo,ToEntryNo);

      Assert.AreEqual(-TotalAmount,TotalDebitValue,TotalValuesNotEqualErr);
Member of Lib.Library - Cost Accounting


InitializeCASetup@54 Method

The procedure InitializeCASetup is available in codeunit 131340.

Syntax

InitializeCASetup@54(
      //param element not supplied
);

Remarks

The relevant search keywords are: Initialize, Cost Accounting, Setup.

For a clarification about how this function works, refer to the code listed below.

      CostAccountingSetup.GET;
      CostAccountingSetup.VALIDATE("Align G/L Account",CostAccountingSetup."Align G/L Account"::Automatic);
      CostAccountingSetup.VALIDATE("Align Cost Center Dimension",CostAccountingSetup."Align Cost Center Dimension"::Automatic);
      CostAccountingSetup.VALIDATE("Align Cost Object Dimension",CostAccountingSetup."Align Cost Object Dimension"::Automatic);
      CostAccountingSetup.VALIDATE("Auto Transfer from G/L",FALSE);
      IF CostAccountingSetup."Last Allocation ID" = '' THEN
        CostAccountingSetup.VALIDATE("Last Allocation ID",'A0');
      IF CostAccountingSetup."Last Allocation Doc. No." = '' THEN
        CostAccountingSetup.VALIDATE("Last Allocation Doc. No.",'ALLOC0');
      CostAccountingSetup.MODIFY(TRUE);

      InitializeCASourceCodes;

Example

The below example is extracted from the test automation codeunit 134810 to show one way of using this function.

      LibraryCostAccounting.InitializeCASetup;
Member of Lib.Library - Cost Accounting


InitializeCASourceCodes@59 Method

The procedure InitializeCASourceCodes is available in codeunit 131340.

Syntax

InitializeCASourceCodes@59(
      //param element not supplied
);

Remarks

The relevant search keywords are: Initialize, Cost Accounting, Source, Codes.

For a clarification about how this function works, refer to the code listed below.

      SourceCodeSetup.GET;

      IF SourceCodeSetup."G/L Entry to CA" = '' THEN BEGIN
        LibraryERM.CreateSourceCode(SourceCode);
        SourceCodeSetup.VALIDATE("G/L Entry to CA",SourceCode.Code);
        Modified := TRUE;
      END;
      IF SourceCodeSetup."Cost Journal" = '' THEN BEGIN
        LibraryERM.CreateSourceCode(SourceCode);
        SourceCodeSetup.VALIDATE("Cost Journal",SourceCode.Code);
        Modified := TRUE;
      END;
      IF SourceCodeSetup."Cost Allocation" = '' THEN BEGIN
        LibraryERM.CreateSourceCode(SourceCode);
        SourceCodeSetup.VALIDATE("Cost Allocation",SourceCode.Code);
        Modified := TRUE;
      END;

      IF Modified THEN
        SourceCodeSetup.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - Cost Accounting


LastAllocSourceID@50 Method

The procedure LastAllocSourceID is available in codeunit 131340.

Syntax

LastAllocSourceID@50(
      //param element not supplied
);

Return Value

Code[10]

Remarks

The relevant search keywords are: Last, Allocation, Source, ID.

For a clarification about how this function works, refer to the code listed below.

      CostAccountingSetup.GET;
      EXIT(CostAccountingSetup."Last Allocation ID");

Example

The below example is extracted from the test automation codeunit 134813 to show one way of using this function.

      // Setup.
      Initialize;
      LastAllocationID := LibraryCostAccounting.LastAllocSourceID;

      // Exercise.
      LibraryCostAccounting.CreateAllocSourceWithCCenter(CostAllocationSource,ID);

      // Verify.
      IF ID = TypeOfID::"Auto Generated" THEN BEGIN
        CostAllocationSource.TESTFIELD(ID,LibraryCostAccounting.LastAllocSourceID);
        Assert.AreEqual(
          LibraryCostAccounting.LastAllocSourceID,INCSTR(LastAllocationID),
          STRSUBSTNO(LastAllocIDNotUpdatedErr,CostAllocationSource.ID));
      END ELSE
        IF ID = TypeOfID::Custom THEN
          Assert.AreNotEqual(
            LibraryCostAccounting.LastAllocSourceID,CostAllocationSource.ID,
            STRSUBSTNO(LastAllocIDWrongUpdateErr,CostAllocationSource.ID))
        ELSE
          ERROR(STRSUBSTNO(UnexpectedOptionValueErr,FORMAT(ID)));
Member of Lib.Library - Cost Accounting


LastAllocTargetID@35 Method

The procedure LastAllocTargetID is available in codeunit 131340.

Syntax

LastAllocTargetID@35(
    CostAllocationSource@1000 : Record 1106 CostAllocationSource //Input parameter of type Record
);

Parameters

CostAllocationSource
Input parameter of type Record

Return Value

Integer

Remarks

The relevant search keywords are: Last, Allocation, Target, ID.

For a clarification about how this function works, refer to the code listed below.

      CostAllocationTarget.SETFILTER(ID,'%1',CostAllocationSource.ID);
      IF CostAllocationTarget.FINDLAST THEN
        EXIT(CostAllocationTarget."Line No.");

      EXIT(0);

Example

There are no examples available.
Member of Lib.Library - Cost Accounting


PostCostJournalLine@20 Method

The procedure PostCostJournalLine is available in codeunit 131340.

Syntax

PostCostJournalLine@20(
    CostJournalLine@1000 : Record 1101 CostJournalLine //Input parameter of type Record
);

Parameters

CostJournalLine
Input parameter of type Record

Remarks

The relevant search keywords are: Post, Cost, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      CODEUNIT.RUN(CODEUNIT::"CA Jnl.-Post Batch",CostJournalLine);

Example

The below example is extracted from the test automation codeunit 134392 to show one way of using this function.

      // Test Cost Acctg. Statement Report.
      Initialize;

      // Setup
      CreateCostJournalLine(CostJournalLine,WORKDATE);
      LibraryCostAccounting.PostCostJournalLine(CostJournalLine);

      // Post-Setup
      EnqueueCostAcctgStmtRepNewPage(FALSE,CostJournalLine."Cost Type No.");

      // Exercise
      RunCostAcctgStmtReport(CostJournalLine."Cost Type No.");

      // Verify
      VerifyCostAcctgStmtReport(CostJournalLine.Amount,CostJournalLine."Cost Type No.",'NetChange_CostType');
Member of Lib.Library - Cost Accounting


PostGenJournalLine@67 Method

The procedure PostGenJournalLine is available in codeunit 131340.

Syntax

PostGenJournalLine@67(
    AccountNo@1000 : Code[20] AccountNo //Input parameter of type Code
);

Parameters

AccountNo
Input parameter of type Code

Remarks

The relevant search keywords are: Post, General, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      CreateJnlLine(GenJournalLine,AccountNo);
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

Example

The below example is extracted from the test automation codeunit 134818 to show one way of using this function.

      // Setup:
      Initialize;
      LibraryCostAccounting.SetAutotransferFromGL(Autotransfer);
      LibraryCostAccounting.SetupGLAccount(GLAccount);

      // Excercise:
      LibraryCostAccounting.PostGenJournalLine(GLAccount."No.");
Member of Lib.Library - Cost Accounting


SetAlignment@26 Method

The procedure SetAlignment is available in codeunit 131340.

Syntax

SetAlignment@26(
    FieldNo@1000 : Integer FieldNo, //Input parameter of type Integer
    FieldOptionValue@1001 : Option FieldOptionValue //Input parameter of type Option
);

Parameters

FieldNo
Input parameter of type Integer
FieldOptionValue
Input parameter of type Option

Remarks

The relevant search keywords are: Set, Alignment.

For a clarification about how this function works, refer to the code listed below.

      CostAccountingSetup.GET;
      RecordRef.GETTABLE(CostAccountingSetup);
      FieldRef := RecordRef.FIELD(FieldNo);
      Field.GET(RecordRef.NUMBER,FieldRef.NUMBER);
      IF Field.Type = Field.Type::Option THEN BEGIN
        FieldRef.VALIDATE(FieldOptionValue);
        RecordRef.MODIFY(TRUE);
      END;

Example

The below example is extracted from the test automation codeunit 134810 to show one way of using this function.

      Initialize;

      // Setup:
      CostAccountingSetup.GET;
      LibraryCostAccounting.SetAlignment(CostAccountingSetup.FIELDNO("Align Cost Center Dimension"),
        CostAccountingSetup."Align Cost Center Dimension"::"No Alignment");
      LibraryDimension.CreateDimensionValue(DimensionValue,CostAccountingSetup."Cost Center Dimension");

      // Exercise:
      CostAccountMgt.CreateCostCenters;

      // Verify:
      Assert.IsTrue(CostCenter.GET(DimensionValue.Code),STRSUBSTNO(CostCenterNotFoundError,DimensionValue.Code));
Member of Lib.Library - Cost Accounting


SetAutotransferFromGL@32 Method

The procedure SetAutotransferFromGL is available in codeunit 131340.

Syntax

SetAutotransferFromGL@32(
    Autotransfer@1000 : Boolean Autotransfer //Input parameter of type Boolean
);

Parameters

Autotransfer
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, Autotransfer, From, General Ledger.

For a clarification about how this function works, refer to the code listed below.

      CostAccountingSetup.GET;
      CostAccountingSetup.VALIDATE("Auto Transfer from G/L",Autotransfer);
      CostAccountingSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134812 to show one way of using this function.

      LibraryCostAccounting.SetAlignment(CostAccountingSetup.FIELDNO("Align G/L Account"),
        CostAccountingSetup."Align G/L Account"::Automatic);
      LibraryCostAccounting.SetAutotransferFromGL(Autotransfer);
Member of Lib.Library - Cost Accounting


SetDefaultDimension@66 Method

The procedure SetDefaultDimension is available in codeunit 131340.

Syntax

SetDefaultDimension@66(
    GLAccountNo@1000 : Code[20] GLAccountNo //Input parameter of type Code
);

Parameters

GLAccountNo
Input parameter of type Code

Remarks

The relevant search keywords are: Set, Default, Dimension.

For a clarification about how this function works, refer to the code listed below.

      IF NOT DefaultDimension.GET(DATABASE::"G/L Account",GLAccountNo,CostCenterDimension) THEN BEGIN
        LibraryDimension.FindDimensionValue(DimValue,CostCenterDimension);
        LibraryDimension.CreateDefaultDimensionGLAcc(DefaultDimension,GLAccountNo,DimValue."Dimension Code",DimValue.Code);
      END;

      // Make sure corresponding cost center exists
      IF NOT CostCenter.GET(DefaultDimension."Dimension Value Code") THEN BEGIN
        CostCenter.INIT;
        CostCenter.VALIDATE(Code,DefaultDimension."Dimension Value Code");
        CostCenter.VALIDATE("Line Type",CostCenter."Line Type"::"Cost Center");
        CostCenter.INSERT(TRUE);
      END;

      CheckBlockedDimensionValues(GLAccountNo); // check for blocked default dimension values, which prevent posting
      CheckBlockedDimCombination; // check for blocked dimension combinations, which prevent posting

Example

There are no examples available.
Member of Lib.Library - Cost Accounting


SetupGeneralJnlBatch@78 Method

The procedure SetupGeneralJnlBatch is available in codeunit 131340.

Syntax

SetupGeneralJnlBatch@78(
    VAR GenJournalBatch@1000 : Record 232 GenJournalBatch //Reference parameter of type Record
);

Parameters

GenJournalBatch
Reference parameter of type Record

Remarks

The relevant search keywords are: Setup, General, Journal, Batch.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.SelectGenJnlBatch(GenJournalBatch);
      CreateBalanceSheetGLAccount(GLAccount);
      GenJournalBatch.VALIDATE("Bal. Account No.",GLAccount."No.");
      GenJournalBatch.MODIFY(TRUE);

      LibraryERM.ClearGenJournalLines(GenJournalBatch);

Example

There are no examples available.
Member of Lib.Library - Cost Accounting


SetupGLAccount@65 Method

The procedure SetupGLAccount is available in codeunit 131340.

Syntax

SetupGLAccount@65(
    VAR GLAccount@1000 : Record 15 GLAccount //Reference parameter of type Record
);

Parameters

GLAccount
Reference parameter of type Record

Remarks

The relevant search keywords are: Setup, General Ledger, Account.

For a clarification about how this function works, refer to the code listed below.

      FindGLAccLinkedToCostType(GLAccount);
      SetDefaultDimension(GLAccount."No.");

Example

The below example is extracted from the test automation codeunit 134818 to show one way of using this function.

      // Setup:
      Initialize;
      LibraryCostAccounting.SetAutotransferFromGL(Autotransfer);
      LibraryCostAccounting.SetupGLAccount(GLAccount);

      // Excercise:
      LibraryCostAccounting.PostGenJournalLine(GLAccount."No.");
Member of Lib.Library - Cost Accounting


TransferBudgetToActual@148 Method

The procedure TransferBudgetToActual is available in codeunit 131340.

Syntax

TransferBudgetToActual@148(
    VAR TransferToActual@1000 : TestRequestPage 1137 TransferToActual, //Reference parameter of type TestRequestPage
    BudgetName@1001 : Code[10] BudgetName, //Input parameter of type Code
    DateRange@1002 : Text[30] DateRange //Input parameter of type Text
);

Parameters

TransferToActual
Reference parameter of type TestRequestPage
BudgetName
Input parameter of type Code
DateRange
Input parameter of type Text

Remarks

The relevant search keywords are: Transfer, Budget, To, Actual.

For a clarification about how this function works, refer to the code listed below.

      TransferToActual."Cost Budget Entry".SETFILTER("Budget Name",BudgetName);
      TransferToActual."Cost Budget Entry".SETFILTER(Date,DateRange);

Example

The below example is extracted from the test automation codeunit 134814 to show one way of using this function.

      LibraryVariableStorage.Dequeue(SourceBudget);
      LibraryVariableStorage.Dequeue(DateRange);
      LibraryCostAccounting.TransferBudgetToActual(TransferToActualReqPage,SourceBudget,DateRange);
      TransferToActualReqPage.OK.INVOKE;
Member of Lib.Library - Cost Accounting


TransferGLEntries@28 Method

The procedure TransferGLEntries is available in codeunit 131340.

Syntax

TransferGLEntries@28(
      //param element not supplied
);

Remarks

The relevant search keywords are: Transfer, General Ledger, Entries.

For a clarification about how this function works, refer to the code listed below.

      CODEUNIT.RUN(CODEUNIT::"Transfer GL Entries to CA");

Example

The below example is extracted from the test automation codeunit 134812 to show one way of using this function.

      // Post a Gen. Journal Line and delete the corresponding account afterwards
      // Run the Transfer G/L Entries batch job and verify that the G/L entries whose G/L account got deleted do not get transferred

      Initialize;

      // Setup:
      CostAccountingSetup(FALSE);
      LibraryCostAccounting.CreateIncomeStmtGLAccount(GLAccount);
      SetAccWithDefaultDimensions(GLAccount."No.",TRUE,FALSE);

      PostJournalLines(GLAccount."No.");

      // Delete GL Account
      GLAccount.FIND;
      GLAccount.DELETE(TRUE);
      ExpectedCostRegisterEntries := CostRegister.COUNT;

      // Exercise:
      ASSERTERROR LibraryCostAccounting.TransferGLEntries;

      // Verify:
      LastErrorText := GETLASTERRORTEXT;
      Assert.IsTrue(STRPOS(LastErrorText,NoEntriesToTransferError) > 0,STRSUBSTNO(UnexpectedErrorMessage,LastErrorText));
      Assert.AreEqual(ExpectedCostRegisterEntries,CostRegister.COUNT,CostRegisterEntriesError);
Member of Lib.Library - Cost Accounting


UpdateAllocSourceWithCCenter@34 Method

The procedure UpdateAllocSourceWithCCenter is available in codeunit 131340.

Syntax

UpdateAllocSourceWithCCenter@34(
    VAR CostAllocationSource@1000 : Record 1106 CostAllocationSource //Reference parameter of type Record
);

Parameters

CostAllocationSource
Reference parameter of type Record

Remarks

The relevant search keywords are: Update, Allocation, Source, C, Center.

For a clarification about how this function works, refer to the code listed below.

      FindCostCenter(CostCenter);
      CostAllocationSource.VALIDATE("Cost Center Code",CostCenter.Code);
      CostAllocationSource.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - Cost Accounting


UpdateAllocSourceWithCObject@31 Method

The procedure UpdateAllocSourceWithCObject is available in codeunit 131340.

Syntax

UpdateAllocSourceWithCObject@31(
    VAR CostAllocationSource@1000 : Record 1106 CostAllocationSource //Reference parameter of type Record
);

Parameters

CostAllocationSource
Reference parameter of type Record

Remarks

The relevant search keywords are: Update, Allocation, Source, C, Object.

For a clarification about how this function works, refer to the code listed below.

      FindCostObject(CostObject);
      CostAllocationSource.VALIDATE("Cost Object Code",CostObject.Code);
      CostAllocationSource.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134813 to show one way of using this function.

      // Setup.
      Initialize;

      // Exercise.
      LibraryCostAccounting.CreateAllocSourceWithCCenter(CostAllocationSource,TypeOfID::"Auto Generated");

      // Verify.
      ASSERTERROR LibraryCostAccounting.UpdateAllocSourceWithCObject(CostAllocationSource);
      Assert.IsTrue(STRPOS(AllocSourceHasCCAndCOMsg,GETLASTERRORTEXT) > 0,
        STRSUBSTNO(UnexpectedMessageErr,GETLASTERRORTEXT,AllocSourceHasCCAndCOMsg));
      CLEARLASTERROR;
Member of Lib.Library - Cost Accounting


UpdateAllocTargetWithCCenter@131 Method

The procedure UpdateAllocTargetWithCCenter is available in codeunit 131340.

Syntax

UpdateAllocTargetWithCCenter@131(
    VAR CostAllocationTarget@1005 : Record 1107 CostAllocationTarget //Reference parameter of type Record
);

Parameters

CostAllocationTarget
Reference parameter of type Record

Remarks

The relevant search keywords are: Update, Allocation, Target, C, Center.

For a clarification about how this function works, refer to the code listed below.

      FindCostCenter(CostCenter);
      CostAllocationTarget.VALIDATE("Target Cost Center",CostCenter.Code);
      CostAllocationTarget.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - Cost Accounting


UpdateAllocTargetWithCObject@132 Method

The procedure UpdateAllocTargetWithCObject is available in codeunit 131340.

Syntax

UpdateAllocTargetWithCObject@132(
    VAR CostAllocationTarget@1005 : Record 1107 CostAllocationTarget //Reference parameter of type Record
);

Parameters

CostAllocationTarget
Reference parameter of type Record

Remarks

The relevant search keywords are: Update, Allocation, Target, C, Object.

For a clarification about how this function works, refer to the code listed below.

      FindCostObject(CostObject);
      CostAllocationTarget.VALIDATE("Target Cost Object",CostObject.Code);
      CostAllocationTarget.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134813 to show one way of using this function.

      // Setup.
      Initialize;

      // Exercise.
      LibraryCostAccounting.CreateAllocSourceWithCCenter(CostAllocationSource,TypeOfID::"Auto Generated");
      LibraryCostAccounting.CreateAllocTargetWithCCenter(
        CostAllocationTarget,CostAllocationSource,LibraryRandom.RandInt(10),
        CostAllocationTarget.Base::Static,CostAllocationTarget."Allocation Target Type"::"All Costs");

      // Verify.
      ASSERTERROR LibraryCostAccounting.UpdateAllocTargetWithCObject(CostAllocationTarget);
      Assert.IsTrue(STRPOS(AllocTargetHasCCAndCOMsg,GETLASTERRORTEXT) > 0,
        STRSUBSTNO(UnexpectedMessageErr,GETLASTERRORTEXT,AllocTargetHasCCAndCOMsg));
      CLEARLASTERROR;
Member of Lib.Library - Cost Accounting


UpdateCostTypeWithCostCenter@1 Method

The procedure UpdateCostTypeWithCostCenter is available in codeunit 131340.

Syntax

UpdateCostTypeWithCostCenter@1(
    VAR CostType@1000 : Record 1103 CostType //Reference parameter of type Record
);

Parameters

CostType
Reference parameter of type Record

Remarks

The relevant search keywords are: Update, Cost, Type, Cost, Center.

For a clarification about how this function works, refer to the code listed below.

      FindCostCenter(CostCenter);
      CostType.VALIDATE("Cost Center Code",CostCenter.Code);
      CostType.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - Cost Accounting


UpdateCostTypeWithCostObject@3 Method

The procedure UpdateCostTypeWithCostObject is available in codeunit 131340.

Syntax

UpdateCostTypeWithCostObject@3(
    VAR CostType@1000 : Record 1103 CostType //Reference parameter of type Record
);

Parameters

CostType
Reference parameter of type Record

Remarks

The relevant search keywords are: Update, Cost, Type, Cost, Object.

For a clarification about how this function works, refer to the code listed below.

      FindCostObject(CostObject);
      CostType.VALIDATE("Cost Object Code",CostObject.Code);
      CostType.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - Cost Accounting


ValidateEntriesTransfered@64 Method

The procedure ValidateEntriesTransfered is available in codeunit 131340.

Syntax

ValidateEntriesTransfered@64(
      //param element not supplied
);

Remarks

The relevant search keywords are: Validate, Entries, Transfered.

For a clarification about how this function works, refer to the code listed below.

      GLRegister.FINDLAST;
      GLEntry.GET(GLRegister."From Entry No.");
      CostRegister.SETFILTER(Source,FORMAT(CostRegister.Source::"Transfer from G/L"));
      CostRegister.FINDLAST;
      CostEntry.GET(CostRegister."From Cost Entry No.");
      GLAccount.GET(CostEntry."G/L Account");

      // Validate Cost Register Entry
      Assert.AreEqual(1,CostRegister."No. of Entries",
        STRSUBSTNO(ExpectedValueIsDifferentErr,CostRegister.FIELDNAME("No. of Entries")));
      Assert.AreEqual(0,CostRegister."To Cost Entry No." - CostRegister."From Cost Entry No.",CostEntriesCountErr);
      Assert.AreEqual(GLEntry.Amount,CostRegister."Debit Amount",
        STRSUBSTNO(ExpectedValueIsDifferentErr,CostRegister.FIELDNAME("Debit Amount")));

      // Validate Cost Entry
      Assert.AreEqual(GLEntry.Amount,CostEntry.Amount,STRSUBSTNO(ExpectedValueIsDifferentErr,CostEntry.FIELDNAME(Amount)));
      Assert.AreEqual(GLEntry."Entry No.",CostEntry."G/L Entry No.",
        STRSUBSTNO(ExpectedValueIsDifferentErr,CostEntry.FIELDNAME("G/L Entry No.")));
      Assert.AreEqual(GLAccount."Cost Type No.",CostEntry."Cost Type No.",
        STRSUBSTNO(ExpectedValueIsDifferentErr,CostEntry.FIELDNAME("Cost Type No.")));
      Assert.AreEqual(GLEntry."G/L Account No.",CostEntry."G/L Account",
        STRSUBSTNO(ExpectedValueIsDifferentErr,CostEntry.FIELDNAME("G/L Account")));
      Assert.AreEqual(GLEntry."Document No.",CostEntry."Document No.",
        STRSUBSTNO(ExpectedValueIsDifferentErr,CostEntry.FIELDNAME("Document No.")));
      Assert.AreEqual(FALSE,CostEntry.Allocated,STRSUBSTNO(ExpectedValueIsDifferentErr,CostEntry.FIELDNAME(Allocated)));

Example

The below example is extracted from the test automation codeunit 134818 to show one way of using this function.

      // Check "Autotransfer" option in Cost Accounting Setup and verify that GL entries are transfered to Cost Accounting.

      AutotransferFromGL(TRUE);

      // Verify:
      LibraryCostAccounting.ValidateEntriesTransfered;
Member of Lib.Library - Cost Accounting


ValidateGLAccountCostTypeRef@63 Method

The procedure ValidateGLAccountCostTypeRef is available in codeunit 131340.

Syntax

ValidateGLAccountCostTypeRef@63(
    CostTypeNo@1001 : Code[20] CostTypeNo //Input parameter of type Code
);

Parameters

CostTypeNo
Input parameter of type Code

Remarks

The relevant search keywords are: Validate, General Ledger, Account, Cost, Type, Ref.

For a clarification about how this function works, refer to the code listed below.

      // The Cost Type has the G/L Account Range filled in.
      CostType.GET(CostTypeNo);
      CostType.TESTFIELD("G/L Account Range");

      // The G/L Accounts have the Cost Type No. filled in.
      FindGLAccountsByCostType(GLAccount,CostType."G/L Account Range");
      REPEAT
        GLAccount.TESTFIELD("Cost Type No.",CostType."No.");
      UNTIL GLAccount.NEXT = 0;

Example

There are no examples available.
Member of Lib.Library - Cost Accounting


ValidateGLAccountIsIncomeStmt@62 Method

The procedure ValidateGLAccountIsIncomeStmt is available in codeunit 131340.

Syntax

ValidateGLAccountIsIncomeStmt@62(
    VAR CostType@1000 : Record 1103 CostType //Reference parameter of type Record
);

Parameters

CostType
Reference parameter of type Record

Remarks

The relevant search keywords are: Validate, General Ledger, Account, Is, Income, Statement.

For a clarification about how this function works, refer to the code listed below.

      REPEAT
        FindGLAccountsByCostType(GLAccount,CostType."G/L Account Range");
        REPEAT
          GLAccount.TESTFIELD("Income/Balance",GLAccount."Income/Balance"::"Income Statement");
        UNTIL GLAccount.NEXT = 0;
      UNTIL CostType.NEXT = 0;

Example

There are no examples available.
Member of Lib.Library - Cost Accounting


VerifyCostTypeIntegrity@69 Method

The procedure VerifyCostTypeIntegrity is available in codeunit 131340.

Syntax

VerifyCostTypeIntegrity@69(
      //param element not supplied
);

Remarks

The relevant search keywords are: Verify, Cost, Type, Integrity.

For a clarification about how this function works, refer to the code listed below.

      GetAllCostTypes(CostType);
      REPEAT
        GLAccount.SETFILTER("No.",CostType."G/L Account Range");
        IF GLAccount.COUNT > 1 THEN BEGIN
          GLAccount.FINDSET;
          REPEAT
            IF GLAccount."Cost Type No." <> CostType."No." THEN
              ERROR(GetCostTypesFromGLErr);
          UNTIL GLAccount.NEXT = 0;
        END;
      UNTIL CostType.NEXT = 0;

Example

The below example is extracted from the test automation codeunit 134810 to show one way of using this function.

      Initialize;
      LibraryCostAccounting.VerifyCostTypeIntegrity;

      // Setup:
      CostType.SETFILTER("G/L Account Range",'<>%1','');
      CostType.SETFILTER("Balance at Date",'%1',0);
      CostType.SETFILTER("Balance to Allocate",'%1',0);
      IF NOT CostType.FINDFIRST THEN
        ERROR(STRSUBSTNO(NoRecordsInFilterError,CostType.TABLECAPTION,CostType.GETFILTERS));
      CostType.DELETE(TRUE);

      // Exercise:
      CostAccountMgt.GetCostTypesFromChartOfAccount;

      // Verify:
      CLEAR(CostType);
      LibraryCostAccounting.GetAllCostTypes(CostType);
      ValidateGLAccountIsIncomeStmt(CostType);
      LibraryCostAccounting.VerifyCostTypeIntegrity;
Member of Lib.Library - Cost Accounting


Library - Costing Class

Lib.Library - Costing

COD132200 applies to SCM,COSTING,W1,All.
Unsupported version tags:
Contains all utility functions related to Costing.

Methods

Name | Description
AdjustCostItemEntries@41 | The procedure AdjustCostItemEntries is available in codeunit 132200.
CalculateInventoryValue@164 | The procedure CalculateInventoryValue is available in codeunit 132200.
CheckAdjustment@34 | The procedure CheckAdjustment is available in codeunit 132200.
CheckInboundEntriesCost@664 | The procedure CheckInboundEntriesCost is available in codeunit 132200.
CheckProductionOrderCost@63 | The procedure CheckProductionOrderCost is available in codeunit 132200.
CopyStandardCostWorksheet@85 | The procedure CopyStandardCostWorksheet is available in codeunit 132200.
CreatePurchasePrice@134 | The procedure CreatePurchasePrice is available in codeunit 132200.
CreateRevaluationJnlLines@33 | The procedure CreateRevaluationJnlLines is available in codeunit 132200.
CreateRevaluationJournal@123 | The procedure CreateRevaluationJournal is available in codeunit 132200.
CreateSalesPrice@133 | The procedure CreateSalesPrice is available in codeunit 132200.
ImplementPriceChange@135 | The procedure ImplementPriceChange is available in codeunit 132200.
PostInvtCostToGL@37 | The procedure PostInvtCostToGL is available in codeunit 132200.
PostInvtCostToGLTest@2 | The procedure PostInvtCostToGLTest is available in codeunit 132200.
SuggestCapacityStandardCost@32 | The procedure SuggestCapacityStandardCost is available in codeunit 132200.
SuggestItemPriceWorksheet@136 | The procedure SuggestItemPriceWorksheet is available in codeunit 132200.
SuggestItemPriceWorksheet2@1 | The procedure SuggestItemPriceWorksheet2 is available in codeunit 132200.
SuggestItemStandardCost@28 | The procedure SuggestItemStandardCost is available in codeunit 132200.
SuggestSalesPriceWorksheet@137 | The procedure SuggestSalesPriceWorksheet is available in codeunit 132200.
UpdateUnitCost@71 | The procedure UpdateUnitCost is available in codeunit 132200.

See Also

Lib


AdjustCostItemEntries@41 Method

The procedure AdjustCostItemEntries is available in codeunit 132200.

Syntax

AdjustCostItemEntries@41(
    ItemNoFilter@1002 : Text[250] ItemNoFilter, //Input parameter of type Text
    ItemCategoryFilter@1003 : Text[250] ItemCategoryFilter //Input parameter of type Text
);

Parameters

ItemNoFilter
Input parameter of type Text
ItemCategoryFilter
Input parameter of type Text

Remarks

The relevant search keywords are: Adjust, Cost, Item, Entries.

For a clarification about how this function works, refer to the code listed below.

      COMMIT;
      AdjustCostItemEntries.InitializeRequest(ItemNoFilter,ItemCategoryFilter);
      AdjustCostItemEntries.USEREQUESTPAGE(FALSE);
      AdjustCostItemEntries.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 136302 to show one way of using this function.

      // [FEATURE] [Update Job Item Cost]
      // [SCENARIO] Update Job Item Cost job updates Planning Line "Posted Total Cost" after setting a different Item Cost in Purchase Order

      // 1. Setup: Create an Item, a Job, a Job Task, a Job Planning Line, a Purchase Header and a Purchase Line. In Purchase Line make sure that the "Direct Unit Cost" is
      // different form Item's Unit Cost.
      Initialize;

      // Create Item
      LibraryInventory.CreateItem(Item);
      Item.VALIDATE("Unit Cost",LibraryRandom.RandDecInRange(1,1000,2));
      Item.VALIDATE("Costing Method",Item."Costing Method"::FIFO);
      Item.MODIFY(TRUE);

      CreateJobTaskWithApplyUsageLink(JobTask);

      // Create JobPlanningLine:
      LibraryJob.CreateJobPlanningLine(JobPlanningLine."Line Type"::"Both Schedule and Contract",
        JobPlanningLine.Type::Item,JobTask,JobPlanningLine);
      JobPlanningLine.VALIDATE("No.",Item."No.");
      JobPlanningLine.VALIDATE(Quantity,LibraryRandom.RandInt(10));
      JobPlanningLine.MODIFY(TRUE);

      LibraryJob.CreateJobJournalLineForPlan(JobPlanningLine,LibraryJob.UsageLineTypeBlank,
        LibraryRandom.RandDecInRange(10,20,2),JobJournalLine);
      LibraryJob.PostJobJournal(JobJournalLine);

      // Create PurchaseHeader
      LibraryPurchase.CreatePurchHeader(PurchaseHeader,PurchaseHeader."Document Type"::Order,'');

      // Create PurchaseLine
      LibraryPurchase.CreatePurchaseLine(
        PurchaseLine,PurchaseHeader,LibraryJob.Job2PurchaseConsumableType(JobPlanningLine.Type),
        Item."No.",LibraryRandom.RandInt(10));

      WITH PurchaseLine DO BEGIN
        VALIDATE(Description,LibraryUtility.GenerateGUID);
        VALIDATE("Unit of Measure Code",JobPlanningLine."Unit of Measure Code");
        // give a different unit cost:
        VALIDATE("Direct Unit Cost",LibraryRandom.RandDecInRange(1000,2000,2));
        MODIFY(TRUE)
      END;

      // 2. Exercise: Post Purchase and then run Adjust Cost - Item Entries and Update Job Item Cost jobs.
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

      JobPlanningLine.GET(JobPlanningLine."Job No.",JobPlanningLine."Job Task No.",JobPlanningLine."Line No.");
      PlanningLineDirectUnitCostBeforeJobs := JobPlanningLine."Posted Total Cost";

      // Run the first job: AdjustCostItemEntries. Item."Unit Cost" should be updated after this
      // since unit cost is changed in PurchaseLine above:
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');

      // Run the second job: RunUpdateJobItemCost. PlanningLine."Direct Unit Cost" should be updated:
      LibraryJob.RunUpdateJobItemCost(JobTask."Job No.");

      JobPlanningLine.GET(JobPlanningLine."Job No.",JobPlanningLine."Job Task No.",JobPlanningLine."Line No.");
      PlanningLineDirectUnitCostAfterJobs := JobPlanningLine."Posted Total Cost";

      // 3. Verify: Ensure that the Planning Line's Direct Unit Cost has changed after running jobs
      Assert.AreNotEqual(
        PlanningLineDirectUnitCostBeforeJobs,
        PlanningLineDirectUnitCostAfterJobs,
        'PlanningLine."Direct Unit Cost" must be changed after running AdjustCostItemEntries and UpdateJobItemCost');
Member of Lib.Library - Costing


CalculateInventoryValue@164 Method

The procedure CalculateInventoryValue is available in codeunit 132200.

Syntax

CalculateInventoryValue@164(
    VAR ItemJournalLine@1009 : Record 83 ItemJournalLine, //Reference parameter of type Record
    VAR Item@1008 : Record 27 Item, //Reference parameter of type Record
    NewPostingDate@1007 : Date NewPostingDate, //Input parameter of type Date
    NewDocNo@1006 : Code[20] NewDocNo, //Input parameter of type Code
    NewCalculatePer@1005 : Option NewCalculatePer, //Input parameter of type Option
    NewByLocation@1004 : Boolean NewByLocation, //Input parameter of type Boolean
    NewByVariant@1003 : Boolean NewByVariant, //Input parameter of type Boolean
    NewUpdStdCost@1002 : Boolean NewUpdStdCost, //Input parameter of type Boolean
    NewCalcBase@1001 : Option NewCalcBase, //Input parameter of type Option
    NewShowDialog@1000 : Boolean NewShowDialog //Input parameter of type Boolean
);

Parameters

ItemJournalLine
Reference parameter of type Record
Item
Reference parameter of type Record
NewPostingDate
Input parameter of type Date
NewDocNo
Input parameter of type Code
NewCalculatePer
Input parameter of type Option
NewByLocation
Input parameter of type Boolean
NewByVariant
Input parameter of type Boolean
NewUpdStdCost
Input parameter of type Boolean
NewCalcBase
Input parameter of type Option
NewShowDialog
Input parameter of type Boolean

Remarks

The relevant search keywords are: Calculate, Inventory, Value.

For a clarification about how this function works, refer to the code listed below.

      CalculateInventoryValue.InitializeRequest(
        NewPostingDate,NewDocNo,TRUE,NewCalculatePer,NewByLocation,NewByVariant,NewUpdStdCost,NewCalcBase,NewShowDialog);
      COMMIT;
      CalculateInventoryValue.USEREQUESTPAGE(FALSE);
      CalculateInventoryValue.SetItemJnlLine(ItemJournalLine);
      CalculateInventoryValue.SETTABLEVIEW(Item);
      CalculateInventoryValue.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 137011 to show one way of using this function.

      Item.SETRECFILTER;
      LibraryCosting.CalculateInventoryValue(
        ItemJournalLine,Item,PostingDate,ItemJournalLine."Document No.",CalculatePer::Item,
        ByLocation,ByVariant,TRUE,CalculationBase::" ",FALSE);
Member of Lib.Library - Costing


CheckAdjustment@34 Method

The procedure CheckAdjustment is available in codeunit 132200.

Syntax

CheckAdjustment@34(
    Item@1000 : Record 27 Item //Input parameter of type Record
);

Parameters

Item
Input parameter of type Record

Remarks

The relevant search keywords are: Check, Adjustment.

For a clarification about how this function works, refer to the code listed below.

      PrepareBufferforRoundingCheck(Item,TempItemJournalBuffer);
      IF Item."Costing Method" = Item."Costing Method"::Average THEN
        CheckAverageCosting(Item,TempItemJournalBuffer)
      ELSE
        CheckNonAverageCosting(Item,TempItemJournalBuffer);

      VerifyInboundEntriesRounding(TempItemJournalBuffer);

Example

The below example is extracted from the test automation codeunit 137053 to show one way of using this function.

      // [SCENARIO] Verify ILE "Cost Amount (Actual)" after posting: purchase (full receive, part invoice) - sales - adjust cost - revaluation - adjust cost - sales - purchase (remaining invoice) - sales - adjust cost.

      CreateItemWithAvg(Item);

      PostingDate := WORKDATE;

      // Purchase Receive 3, Invoice 1
      LibraryPatterns.MAKEPurchaseOrder(PurchaseHeader,PurchaseLine,Item,'','',3,PostingDate,10);
      PurchaseLine.VALIDATE("Qty. to Invoice",2);
      PurchaseLine.MODIFY;
      PurchaseHeader.VALIDATE("Vendor Invoice No.",LibraryUtility.GenerateGUID);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

      // Sell 1
      LibraryPatterns.POSTSalesOrder(SalesHeader,Item,'','',1,PostingDate,0,TRUE,TRUE);
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');

      // Revalue
      LibraryPatterns.CalculateInventoryValueRun(ItemJnlBatch,Item,PostingDate,1,FALSE,FALSE,FALSE,0,FALSE,'','');
      LibraryPatterns.ModifyPostRevaluation(ItemJnlBatch,2);
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');

      PostingDate += 1;

      // Sell 1
      LibraryPatterns.POSTSalesOrder(SalesHeader,Item,'','',1,PostingDate,0,TRUE,TRUE);

      PostingDate += 1;
      // Purchase Invoice Remaining 2
      PurchaseHeader.FIND;
      PurchaseHeader.VALIDATE("Posting Date",PostingDate);
      PurchaseHeader.MODIFY;
      PurchaseLine.FIND;
      PurchaseLine.VALIDATE("Direct Unit Cost",12);
      PurchaseLine.MODIFY;
      PurchaseHeader.VALIDATE("Vendor Invoice No.",LibraryUtility.GenerateGUID);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

      PostingDate += 1;
      // Sell 1
      LibraryPatterns.POSTSalesOrder(SalesHeader,Item,'','',1,PostingDate,0,TRUE,TRUE);

      LibraryCosting.AdjustCostItemEntries(Item."No.",'');
      LibraryCosting.CheckAdjustment(Item);
Member of Lib.Library - Costing


CheckInboundEntriesCost@664 Method

The procedure CheckInboundEntriesCost is available in codeunit 132200.

Syntax

CheckInboundEntriesCost@664(
    VAR TempItemLedgerEntry@1000 : TEMPORARY Record 32 TempItemLedgerEntry //Reference Temporary parameter of type Record
);

Parameters

TempItemLedgerEntry
Reference Temporary parameter of type Record

Remarks

The relevant search keywords are: Check, Inbound, Entries, Cost.

For a clarification about how this function works, refer to the code listed below.

      TempItemLedgerEntry.FINDFIRST;
      TempItemLedgerEntry.CALCFIELDS("Cost Amount (Expected)","Cost Amount (Actual)");
      RefCostPerUnit :=
        (TempItemLedgerEntry."Cost Amount (Expected)" + TempItemLedgerEntry."Cost Amount (Actual)") / TempItemLedgerEntry.Quantity;

      // Check if the subsequent inbound entries have the same cost as the original inbound entry - to make sure the cost modification has been propagated
      WHILE TempItemLedgerEntry.NEXT <> 0 DO BEGIN
        TempItemLedgerEntry.CALCFIELDS("Cost Amount (Expected)","Cost Amount (Actual)");
        ActualCost := TempItemLedgerEntry."Cost Amount (Expected)" + TempItemLedgerEntry."Cost Amount (Actual)";
        RefCost := ROUND(RefCostPerUnit * TempItemLedgerEntry.Quantity,LibraryERM.GetAmountRoundingPrecision);
        Assert.AreEqual(RefCost,ActualCost,STRSUBSTNO(IncorrectCostTxt,TempItemLedgerEntry."Entry No."));
      END;

Example

The below example is extracted from the test automation codeunit 137603 to show one way of using this function.

      LibraryPatterns.MAKEItem(Item,CostingMethod,StandardCost,0,0,'');
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location);
      CreateSetupEntriesCircularTransfer(Item,TempItemLedgerEntry,Location.Code,WORKDATE);
      ExecuteRevalueExistingInventory(Item,ItemJnlBatch,WORKDATE,CalculatePer::Item,FALSE,FALSE,FALSE,CalculationBase::" ",'','');
      ModifyPostRevaluation(ItemJnlBatch,Item."No.",1.1);
      LibraryCosting.CheckAdjustment(Item);

      TempItemLedgerEntry.SETRANGE(Positive,TRUE);
      LibraryCosting.CheckInboundEntriesCost(TempItemLedgerEntry);
Member of Lib.Library - Costing


CheckProductionOrderCost@63 Method

The procedure CheckProductionOrderCost is available in codeunit 132200.

Syntax

CheckProductionOrderCost@63(
    ProdOrder@1000 : Record 5405 ProdOrder, //Input parameter of type Record
    VerifyVarianceinOutput@1008 : Boolean VerifyVarianceinOutput //Input parameter of type Boolean
);

Parameters

ProdOrder
Input parameter of type Record
VerifyVarianceinOutput
Input parameter of type Boolean

Remarks

The relevant search keywords are: Check, Production, Order, Cost.

For a clarification about how this function works, refer to the code listed below.

      ProdOrderLine.SETRANGE(Status,ProdOrder.Status);
      ProdOrderLine.SETRANGE("Prod. Order No.",ProdOrder."No.");
      ItemLedgerEntry.SETRANGE("Order Type",ItemLedgerEntry."Order Type"::Production);
      ItemLedgerEntry.SETRANGE("Order No.",ProdOrder."No.");
      IF ProdOrderLine.FINDSET THEN BEGIN
        OutpuCostwithoutVariance := 0;
        ConsumptionCost := 0;
        REPEAT
          ItemLedgerEntry.SETRANGE("Order Line No.",ProdOrderLine."Line No.");
          IF ItemLedgerEntry.FINDSET THEN
            REPEAT
              ItemLedgerEntry.CALCFIELDS("Cost Amount (Expected)","Cost Amount (Actual)");
              IF ItemLedgerEntry."Entry Type" = ItemLedgerEntry."Entry Type"::Consumption THEN
                ConsumptionCost += ItemLedgerEntry."Cost Amount (Expected)" + ItemLedgerEntry."Cost Amount (Actual)"
              ELSE
                IF ItemLedgerEntry."Entry Type" = ItemLedgerEntry."Entry Type"::Output THEN BEGIN
                  ValueEntry.SETCURRENTKEY("Item Ledger Entry No.","Entry Type");
                  IF VerifyVarianceinOutput THEN BEGIN
                    ValueEntry.SETRANGE("Item Ledger Entry No.",ItemLedgerEntry."Entry No.");
                    ValueEntry.CALCSUMS("Cost Amount (Actual)");
                    OutputCostinclVariance := ROUND(ValueEntry."Cost Amount (Actual)",LibraryERM.GetAmountRoundingPrecision);
                  END;
                  ValueEntry.SETFILTER("Entry Type",'<>%1',ValueEntry."Entry Type"::Variance);
                  ValueEntry.CALCSUMS("Cost Amount (Actual)");
                  OutpuCostwithoutVariance += ValueEntry."Cost Amount (Actual)";
                END;
            UNTIL ItemLedgerEntry.NEXT = 0;
          Assert.AreEqual(
            -ConsumptionCost,OutpuCostwithoutVariance,
            STRSUBSTNO(OutputConsumpMismatchTxt,ProdOrderLine."Prod. Order No.",ProdOrderLine."Line No."));
          IF VerifyVarianceinOutput THEN BEGIN
            RefOutputCostinclVariance :=
              ROUND(ProdOrderLine."Unit Cost" * ProdOrderLine.Quantity,LibraryERM.GetAmountRoundingPrecision);
            Assert.AreEqual(
              -RefOutputCostinclVariance,OutputCostinclVariance,
              STRSUBSTNO(OutputVarianceMismatchTxt,ProdOrderLine."Prod. Order No.",ProdOrderLine."Line No."));
          END;
        UNTIL ProdOrderLine.NEXT = 0;
      END;

Example

The below example is extracted from the test automation codeunit 137606 to show one way of using this function.

      QtyCompInProdItem := LibraryRandom.RandDecInDecimalRange(0.1,1,2);
      ProdOrderQty := LibraryRandom.RandDecInDecimalRange(100,200,2);

      SetupItems1Comp1ProdItem(
        ComponentItem,ProducedItem,ComponentItem."Costing Method"::Average,ProducedItemCostingMethod,QtyCompInProdItem);

      LibraryPatterns.MAKEProductionOrder(
        ProductionOrder,ProductionOrder.Status::Released,ProducedItem,'','',ProdOrderQty,StartDate + 30);

      QtyCompInProdOrder := ROUND(QtyCompInProdItem * ProdOrderQty,ComponentItem."Rounding Precision",'>');

      PurchaseQty1 := ROUND(QtyCompInProdOrder / 2,ComponentItem."Rounding Precision");
      PurchaseQty2 := QtyCompInProdOrder - PurchaseQty1;

      Cost1 := LibraryPatterns.RandCost(ComponentItem);
      Cost2 := LibraryPatterns.RandCost(ComponentItem);
      Cost3 := LibraryPatterns.RandCost(ComponentItem);

      LibraryInventory.CreateItemJournalBatchByType(ItemJnlBatch,ItemJnlBatch."Template Type"::Item);
      LibraryPatterns.MAKEItemJournalLine(
        ItemJnlLine,ItemJnlBatch,ComponentItem,'','',StartDate,ItemJnlLine."Entry Type"::Purchase,PurchaseQty1,Cost1);
      LibraryPatterns.MAKEItemJournalLine(
        ItemJnlLine,ItemJnlBatch,ComponentItem,'','',StartDate + 1,ItemJnlLine."Entry Type"::Purchase,PurchaseQty2,Cost2);
      LibraryInventory.PostItemJournalBatch(ItemJnlBatch);

      ProdOrderLine.SETRANGE("Prod. Order No.",ProductionOrder."No.");
      ProdOrderLine.FINDFIRST;
      LibraryPatterns.POSTConsumption(ProdOrderLine,ComponentItem,'','',QtyCompInProdOrder,StartDate + 2,ComponentItem."Unit Cost");

      LibraryInventory.CreateItemJournalBatchByType(ItemJnlBatch,ItemJnlBatch."Template Type"::Item);
      LibraryPatterns.MAKEItemJournalLine(
        ItemJnlLine,ItemJnlBatch,ComponentItem,'','',StartDate + 2,ItemJnlLine."Entry Type"::Purchase,PurchaseQty2,Cost3);
      LibraryInventory.PostItemJournalBatch(ItemJnlBatch);

      LibraryPatterns.POSTOutput(ProdOrderLine,ProdOrderQty,StartDate + 9,ProducedItem."Unit Cost");

      // Finish
      LibraryManufacturing.ChangeProdOrderStatus(ProductionOrder,ProductionOrder.Status::Finished,StartDate + 10,FALSE);

      LibraryCosting.AdjustCostItemEntries(STRSUBSTNO('%1|%2',ComponentItem."No.",ProducedItem."No."),'');

      // Verify
      VerifyVariance := ProducedItemCostingMethod = ProducedItem."Costing Method"::Standard;
      LibraryCosting.CheckAdjustment(ComponentItem);
      LibraryCosting.CheckProductionOrderCost(ProductionOrder,VerifyVariance);
Member of Lib.Library - Costing


CopyStandardCostWorksheet@85 Method

The procedure CopyStandardCostWorksheet is available in codeunit 132200.

Syntax

CopyStandardCostWorksheet@85(
    FromStandardCostWorksheetName@1000 : Code[10] FromStandardCostWorksheetName, //Input parameter of type Code
    ToStandardCostWorksheetName@1001 : Code[10] ToStandardCostWorksheetName //Input parameter of type Code
);

Parameters

FromStandardCostWorksheetName
Input parameter of type Code
ToStandardCostWorksheetName
Input parameter of type Code

Remarks

The relevant search keywords are: Copy, Standard, Cost, Worksheet.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(CopyStandardCostWorksheet);
      CopyStandardCostWorksheet.Initialize(FromStandardCostWorksheetName,ToStandardCostWorksheetName,TRUE);
      CopyStandardCostWorksheet.USEREQUESTPAGE(FALSE);
      CopyStandardCostWorksheet.RUN

Example

The below example is extracted from the test automation codeunit 137402 to show one way of using this function.

      // Setup: Create Work Center, Machine Center, Standard Cost Worksheet Name and Run Suggest Work And Machine Center Standard Cost Report.
      CreateWorkCenter(WorkCenter);
      CreateMachineCenter(MachineCenter);
      StandardCostWorksheetName := CreateStandardCostWorksheetName;
      LibraryCosting.SuggestCapacityStandardCost(
        WorkCenter,MachineCenter,StandardCostWorksheetName,LibraryRandom.RandInt(5),StandardCostRoundingMethod);  // Use random value for Standard Cost Adjustment Factor.
      StandardCostWorksheetName2 := CreateStandardCostWorksheetName;  // Create new Worksheet Name.

      // Exercise: Run Copy Standard Cost Worksheet Report.
      LibraryCosting.CopyStandardCostWorksheet(StandardCostWorksheetName,StandardCostWorksheetName2);

      // Verify: Verify Lines are copied from Old Worksheet to New Worksheet.
      VerifyCopyStandardCostWorkSheet(StandardCostWorksheetName2,StandardCostWorksheet.Type::"Work Center",WorkCenter."No.");
      VerifyCopyStandardCostWorkSheet(StandardCostWorksheetName2,StandardCostWorksheet.Type::"Machine Center",MachineCenter."No.");
Member of Lib.Library - Costing


CreatePurchasePrice@134 Method

The procedure CreatePurchasePrice is available in codeunit 132200.

Syntax

CreatePurchasePrice@134(
    VAR PurchasePrice@1001 : Record 7012 PurchasePrice, //Reference parameter of type Record
    VendorNo@1000 : Code[20] VendorNo, //Input parameter of type Code
    ItemNo@1002 : Code[20] ItemNo, //Input parameter of type Code
    StartingDate@1003 : Date StartingDate, //Input parameter of type Date
    CurrencyCode@1004 : Code[10] CurrencyCode, //Input parameter of type Code
    VariantCode@1005 : Code[10] VariantCode, //Input parameter of type Code
    UnitOfMeasureCode@1006 : Code[10] UnitOfMeasureCode, //Input parameter of type Code
    MinimumQuantity@1007 : Decimal MinimumQuantity //Input parameter of type Decimal
);

Parameters

PurchasePrice
Reference parameter of type Record
VendorNo
Input parameter of type Code
ItemNo
Input parameter of type Code
StartingDate
Input parameter of type Date
CurrencyCode
Input parameter of type Code
VariantCode
Input parameter of type Code
UnitOfMeasureCode
Input parameter of type Code
MinimumQuantity
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Purchase, Price.

For a clarification about how this function works, refer to the code listed below.

      PurchasePrice.INIT;
      PurchasePrice.VALIDATE("Vendor No.",VendorNo);
      PurchasePrice.VALIDATE("Item No.",ItemNo);
      PurchasePrice.VALIDATE("Starting Date",StartingDate);
      PurchasePrice.VALIDATE("Currency Code",CurrencyCode);
      PurchasePrice.VALIDATE("Variant Code",VariantCode);
      PurchasePrice.VALIDATE("Unit of Measure Code",UnitOfMeasureCode);
      PurchasePrice.VALIDATE("Minimum Quantity",MinimumQuantity);
      PurchasePrice.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134328 to show one way of using this function.

      // [FEATURE] [Purchase Price] [UT]
      // [SCENARIO 375443] Direct Unit Cost should be updated when change Buy-From Vendor No. with Purchase Prices defined

      Initialize;
      // [GIVEN] Purchase Invoice with Vendor "A", Item "X" and "Direct Unit Cost" = 100
      CreatePurchaseHeader(PurchHeader,LibraryPurchase.CreateVendorNo,PurchHeader."Document Type"::Invoice);
      LibraryPurchase.CreatePurchaseLine(
        PurchLine,PurchHeader,PurchLine.Type::Item,LibraryInventory.CreateItemNo,LibraryRandom.RandInt(10));
      PurchLine.VALIDATE("Direct Unit Cost",LibraryRandom.RandDec(100,2));
      PurchLine.MODIFY(TRUE);

      // [GIVEN] Vendor "B" with Purchase Price defined: Item "X", "Direct Unit Cost" = 150
      LibraryCosting.CreatePurchasePrice(
        PurchPrice,LibraryPurchase.CreateVendorNo,PurchLine."No.",0D,'','','',0);
      PurchPrice.VALIDATE("Direct Unit Cost",LibraryRandom.RandDec(100,2));
      PurchPrice.MODIFY(TRUE);
      PurchHeader.SetHideValidationDialog(TRUE);

      // [WHEN] Change "Buy From Vendor No." from "A" to "B" in Purchase Invoice
      PurchHeader.VALIDATE("Buy-from Vendor No.",PurchPrice."Vendor No.");

      // [THEN] "Direct Unit Cost" in Purchase Line is 150
      PurchLine.FIND;
      PurchLine.TESTFIELD("Direct Unit Cost",PurchPrice."Direct Unit Cost");
Member of Lib.Library - Costing


CreateRevaluationJnlLines@33 Method

The procedure CreateRevaluationJnlLines is available in codeunit 132200.

Syntax

CreateRevaluationJnlLines@33(
    VAR Item@1000 : Record 27 Item, //Reference parameter of type Record
    ItemJournalLine@1010 : Record 83 ItemJournalLine, //Input parameter of type Record
    DocNo@1008 : Code[20] DocNo, //Input parameter of type Code
    CalculatePer@1007 : Option CalculatePer, //Input parameter of type Option
    ReCalcStdCost@1002 : Option ReCalcStdCost, //Input parameter of type Option
    ByLocation@1006 : Boolean ByLocation, //Input parameter of type Boolean
    ByVariant@1005 : Boolean ByVariant, //Input parameter of type Boolean
    UpdStdCost@1004 : Boolean UpdStdCost, //Input parameter of type Boolean
    PostingDate@1003 : Date PostingDate //Input parameter of type Date
);

Parameters

Item
Reference parameter of type Record
ItemJournalLine
Input parameter of type Record
DocNo
Input parameter of type Code
CalculatePer
Input parameter of type Option
ReCalcStdCost
Input parameter of type Option
ByLocation
Input parameter of type Boolean
ByVariant
Input parameter of type Boolean
UpdStdCost
Input parameter of type Boolean
PostingDate
Input parameter of type Date

Remarks

The relevant search keywords are: Create, Revaluation, Journal, Lines.

For a clarification about how this function works, refer to the code listed below.

      ItemJournalLine.DELETEALL;
      CalcInvtValue.SetItemJnlLine(ItemJournalLine);
      IF Item.HASFILTER THEN
        TmpItem.COPYFILTERS(Item)
      ELSE BEGIN
        Item.GET(Item."No.");
        TmpItem.SETRANGE("No.",Item."No.");
      END;
      CalcInvtValue.SETTABLEVIEW(TmpItem);
      CalcInvtValue.InitializeRequest(PostingDate,DocNo,TRUE,CalculatePer,ByLocation,ByVariant,UpdStdCost,ReCalcStdCost,TRUE);
      CalcInvtValue.USEREQUESTPAGE(FALSE);
      CalcInvtValue.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 137001 to show one way of using this function.

      LibraryInventory.SelectItemJournalTemplateName(ItemJournalTemplate,ItemJournalTemplate.Type::Revaluation);
      LibraryInventory.CreateItemJournalLine(
        ItemJournalLine1,ItemJournalTemplate.Name,FORMAT(RANDOM(10000)),ItemJournalBatch."Template Type"::Revaluation,Item."No.",0);

      ItemJournalBatch.SETRANGE("Journal Template Name",ItemJournalLine1."Journal Template Name");
      ItemJournalBatch.SETRANGE(Name,ItemJournalLine1."Journal Batch Name");
      ItemJournalBatch.FINDFIRST;
      ItemJournalBatch.VALIDATE("No. Series",'');
      ItemJournalBatch.MODIFY(TRUE);

      // Calculate inventory value for selected item.
      Item1.SETRANGE("No.",Item."No.");
      LibraryCosting.CreateRevaluationJnlLines(Item1,ItemJournalLine1,COPYSTR(Item."No.",1,5),1,0,TRUE,TRUE,FALSE,WORKDATE);

      // Collect and post the resulted Item Journal Line.
      ItemJournalLine1.SETRANGE("Journal Template Name",ItemJournalBatch."Journal Template Name");
      ItemJournalLine1.SETRANGE("Journal Batch Name",ItemJournalBatch.Name);
      ItemJournalLine1.SETRANGE("Item No.",Item."No.");
      ItemJournalLine1.FINDFIRST;

      // Revalue item cost.
      CalculatedValue := ItemJournalLine1."Unit Cost (Calculated)";
      ItemJournalLine1.VALIDATE("Unit Cost (Revalued)",CalculatedValue + RevalDirection * RANDOM(10));
      ItemJournalLine1.VALIDATE("Inventory Value (Revalued)",
        ItemJournalLine1."Unit Cost (Revalued)" * ItemJournalLine1."Invoiced Quantity");
      ItemJournalLine1.MODIFY(TRUE);

      // Save in temporary table.
      TempItemJournalLine := ItemJournalLine1;
      TempItemJournalLine.INSERT;

      // Post revaluation.
      LibraryInventory.PostItemJournalLine(ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name);
Member of Lib.Library - Costing


CreateRevaluationJournal@123 Method

The procedure CreateRevaluationJournal is available in codeunit 132200.

Syntax

CreateRevaluationJournal@123(
    VAR ItemJournalBatch@1006 : Record 233 ItemJournalBatch, //Reference parameter of type Record
    VAR Item@1000 : Record 27 Item, //Reference parameter of type Record
    NewPostingDate@1013 : Date NewPostingDate, //Input parameter of type Date
    NewDocNo@1012 : Code[20] NewDocNo, //Input parameter of type Code
    NewCalculatePer@1011 : Option NewCalculatePer, //Input parameter of type Option
    NewByLocation@1010 : Boolean NewByLocation, //Input parameter of type Boolean
    NewByVariant@1009 : Boolean NewByVariant, //Input parameter of type Boolean
    NewUpdStdCost@1008 : Boolean NewUpdStdCost, //Input parameter of type Boolean
    NewCalcBase@1007 : Option NewCalcBase, //Input parameter of type Option
    NewShowDialog@1005 : Boolean NewShowDialog //Input parameter of type Boolean
);

Parameters

ItemJournalBatch
Reference parameter of type Record
Item
Reference parameter of type Record
NewPostingDate
Input parameter of type Date
NewDocNo
Input parameter of type Code
NewCalculatePer
Input parameter of type Option
NewByLocation
Input parameter of type Boolean
NewByVariant
Input parameter of type Boolean
NewUpdStdCost
Input parameter of type Boolean
NewCalcBase
Input parameter of type Option
NewShowDialog
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, Revaluation, Journal.

For a clarification about how this function works, refer to the code listed below.

      ItemJournalLine.VALIDATE("Journal Template Name",ItemJournalBatch."Journal Template Name");
      ItemJournalLine.VALIDATE("Journal Batch Name",ItemJournalBatch.Name);
      CalculateInventoryValue(
        ItemJournalLine,Item,NewPostingDate,NewDocNo,NewCalculatePer,NewByLocation,
        NewByVariant,NewUpdStdCost,NewCalcBase,NewShowDialog);

Example

The below example is extracted from the test automation codeunit 137035 to show one way of using this function.

      // 1. Setup : Update Sales Setup.Create Item and Update Inventory.Random values used are not important for test.
      Initialize;

      CreateItem(
        Item,Item."Costing Method"::Average,'','',Item."Manufacturing Policy",Item."Reordering Policy",Item."Replenishment System");
      Item.VALIDATE("Unit Price",LibraryRandom.RandDec(50,1));
      Item.MODIFY(TRUE);
      CreateAndPostItemJrnl(ItemJournalLine."Entry Type"::"Positive Adjmt.",Item."No.",LibraryRandom.RandInt(100) + 10);

      // Create Purchase Order and Post receipt.Create Sale Order and Post it.Update Direct unit Cost and Post Invoice.
      CreatePurchaseOrder(PurchaseHeader,Item."No.",LibraryRandom.RandInt(100),LibraryRandom.RandDec(50,2));
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,FALSE);
      Item.CALCFIELDS(Inventory);
      CreateSalesOrder(SalesHeader,Item."No.",Item.Inventory - 5); // Value used is important for test.
      LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);
      UpdatePurchaseOrderDirectCost(PurchaseHeader);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

      // 2. Execute : Run Adjust cost and create Revaluation Journal.
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');
      Item.GET(Item."No.");
      CreateItemJournalBatch(ItemJournalBatch);
      Item.SETRANGE("No.",Item."No.");
      LibraryCosting.CreateRevaluationJournal(
        ItemJournalBatch,Item,WORKDATE,ItemJournalLine."Document No.",CalculatePer::Item,FALSE,FALSE,FALSE,CalculationBase::" ",FALSE);

      // 3. Verify : Inventory Value (Calculated) in Revaluation Journal with Inventory Value at Item card.
      InventoryValueCalculated := GetInventoryValue(Item."No.");
      Item.CALCFIELDS(Inventory);
      GeneralLedgerSetup.GET;
      Assert.AreNearlyEqual(
        InventoryValueCalculated,Item."Unit Cost" * Item.Inventory,GeneralLedgerSetup."Amount Rounding Precision",
        ErrInventoryValueCalculated);
Member of Lib.Library - Costing


CreateSalesPrice@133 Method

The procedure CreateSalesPrice is available in codeunit 132200.

Syntax

CreateSalesPrice@133(
    VAR SalesPrice@1000 : Record 7002 SalesPrice, //Reference parameter of type Record
    SalesType@1003 : Option SalesType, //Input parameter of type Option
    SalesCode@1001 : Code[20] SalesCode, //Input parameter of type Code
    ItemNo@1002 : Code[20] ItemNo, //Input parameter of type Code
    StartingDate@1004 : Date StartingDate, //Input parameter of type Date
    CurrencyCode@1005 : Code[10] CurrencyCode, //Input parameter of type Code
    VariantCode@1006 : Code[10] VariantCode, //Input parameter of type Code
    UnitOfMeasureCode@1007 : Code[10] UnitOfMeasureCode, //Input parameter of type Code
    MinimumQuantity@1008 : Decimal MinimumQuantity //Input parameter of type Decimal
);

Parameters

SalesPrice
Reference parameter of type Record
SalesType
Input parameter of type Option
SalesCode
Input parameter of type Code
ItemNo
Input parameter of type Code
StartingDate
Input parameter of type Date
CurrencyCode
Input parameter of type Code
VariantCode
Input parameter of type Code
UnitOfMeasureCode
Input parameter of type Code
MinimumQuantity
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Sales, Price.

For a clarification about how this function works, refer to the code listed below.

      SalesPrice.INIT;
      SalesPrice.VALIDATE("Sales Type",SalesType);
      SalesPrice.VALIDATE("Sales Code",SalesCode);
      SalesPrice.VALIDATE("Item No.",ItemNo);
      SalesPrice.VALIDATE("Starting Date",StartingDate);
      SalesPrice.VALIDATE("Currency Code",CurrencyCode);
      SalesPrice.VALIDATE("Variant Code",VariantCode);
      SalesPrice.VALIDATE("Unit of Measure Code",UnitOfMeasureCode);
      SalesPrice.VALIDATE("Minimum Quantity",MinimumQuantity);
      SalesPrice.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134386 to show one way of using this function.

      // [FEATURE] [UT] [Customer Price Group] [Sales Price]
      // [SCENARIO 364564] Delete related "Sales Price" when "Customer Price Group" is deleted

      // [GIVEN] Customer Price Group = "X"
      // [GIVEN] Sales Price with "Sales Type" = "Customer Price Group" and "Sales Code" = "X"
      Initialize;
      LibrarySales.CreateCustomerPriceGroup(CustomerPriceGroup);
      LibraryCosting.CreateSalesPrice(
        SalesPrice,SalesPrice."Sales Type"::"Customer Price Group",CustomerPriceGroup.Code,
        LibraryInventory.CreateItemNo,WORKDATE,'','','',LibraryRandom.RandInt(100));

      // [WHEN] Delete Customer Price Group
      CustomerPriceGroup.DELETE(TRUE);

      // [THEN] Sales Price is removed
      SalesPrice.SETRANGE("Sales Type",SalesPrice."Sales Type"::"Customer Price Group");
      SalesPrice.SETRANGE("Sales Code",CustomerPriceGroup.Code);
      Assert.RecordIsEmpty(SalesPrice);
Member of Lib.Library - Costing


ImplementPriceChange@135 Method

The procedure ImplementPriceChange is available in codeunit 132200.

Syntax

ImplementPriceChange@135(
    SalesPriceWorksheet@1000 : Record 7023 SalesPriceWorksheet //Input parameter of type Record
);

Parameters

SalesPriceWorksheet
Input parameter of type Record

Remarks

The relevant search keywords are: Implement, Price, Change.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(ImplementPriceChange);
      ImplementPriceChange.InitializeRequest(TRUE);
      ImplementPriceChange.USEREQUESTPAGE(FALSE);
      ImplementPriceChange.SETTABLEVIEW(SalesPriceWorksheet);
      ImplementPriceChange.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 137201 to show one way of using this function.

      // Setup: Create Sales Price Setup.
      Initialize;
      SalesPriceWorksheet.DELETEALL;

      // Create different Sales Prices for Customer, Customer Price Group and All Customer. Unit Prices and Quantities important for test.
      CreateSalesPriceSetup(SalesReceivablesSetup,Item,Customer);
      MinimumQty := LibraryRandom.RandDec(5,2) + 10;  // Random values not important.
      CreateSalesPrice(
        Item,SalesPrice."Sales Type"::Customer,Customer."No.",Item."Unit Price" - LibraryRandom.RandInt(5),MinimumQty);
      LibrarySales.CreateCustomerPriceGroup(CustomerPriceGroup);
      UpdateCustomer(Customer,CustomerPriceGroup.Code);
      CreateSalesPrice(
        Item,SalesPrice."Sales Type"::"Customer Price Group",CustomerPriceGroup.Code,
        Item."Unit Price" - LibraryRandom.RandInt(5),MinimumQty + 10);
      CreateSalesPrice(
        Item,SalesPrice."Sales Type"::"All Customers",'',
        Item."Unit Price" - LibraryRandom.RandInt(5),MinimumQty + 100);
      LibraryCosting.SuggestSalesPriceWorksheet(Item,Customer."No.",SalesType::Customer,0,1);  // Values important for test.
      NoOfSalesLines := UpdateSalesPriceWorksheet(SalesPriceWorksheet,NewUnitPrice,Quantity);
      LibraryCosting.ImplementPriceChange(SalesPriceWorksheet);

      // Exercise: Create Sales Order with three different Sales line for different Quantities.
      LibrarySales.CreateSalesHeader(SalesHeader,SalesHeader."Document Type"::Order,Customer."No.");
      FOR Count := 1 TO NoOfSalesLines DO
        LibrarySales.CreateSalesLine(SalesLine,SalesHeader,SalesLine.Type::Item,Item."No.",Quantity[Count]);

      // Verify: Verify Line Amounts on Sales Lines.
      FOR Count := 1 TO NoOfSalesLines DO BEGIN
        SelectSalesLine(SalesLine,SalesHeader,Quantity[Count]);
        SalesLine.TESTFIELD(
          "Line Amount",
          ROUND(NewUnitPrice[Count] * Quantity[Count],GeneralLedgerSetup."Inv. Rounding Precision (LCY)"));
      END;
Member of Lib.Library - Costing


PostInvtCostToGL@37 Method

The procedure PostInvtCostToGL is available in codeunit 132200.

Syntax

PostInvtCostToGL@37(
    PerPostingGroup@1002 : Boolean PerPostingGroup, //Input parameter of type Boolean
    PostingDate@1102 : Date PostingDate, //Input parameter of type Date
    DocNo@1001 : Code[20] DocNo //Input parameter of type Code
);

Parameters

PerPostingGroup
Input parameter of type Boolean
PostingDate
Input parameter of type Date
DocNo
Input parameter of type Code

Remarks

The relevant search keywords are: Post, Invt, Cost, To, General Ledger.

For a clarification about how this function works, refer to the code listed below.

      COMMIT;

      PostValueEntryToGL.SETFILTER("Posting Date",'=%1',PostingDate);
      IF PerPostingGroup THEN BEGIN
        PostMethod := PostMethod::"per Posting Group";
        PostInventoryCosttoGL.InitializeRequest(PostMethod,DocNo,TRUE);
      END ELSE BEGIN
        PostMethod := PostMethod::"per Entry";
        PostInventoryCosttoGL.InitializeRequest(PostMethod,'',TRUE);
      END;
      PostInventoryCosttoGL.SETTABLEVIEW(PostValueEntryToGL);
      PostInventoryCosttoGL.USEREQUESTPAGE(FALSE);
      PostInventoryCosttoGL.SAVEASPDF(STRSUBSTNO(TempPathTxt,TEMPORARYPATH,DocNo));

Example

The below example is extracted from the test automation codeunit 137003 to show one way of using this function.

      // 1. Setup: Required Costing Setups.
      // Create, Calculate and Post Consumption Journal and Explode Routing and Post Output Journal.
      CreateCostingSetup(
        PurchaseHeader,ProductionOrderNo,ItemNo,ItemNo2,AutoCostPosting,FlushingMethod,CostingMethod,
        TRUE,TRUE,FALSE,FALSE,FALSE,FALSE,FALSE);
      IF FlushingMethod = FlushingMethod::Manual THEN BEGIN
        LibraryInventory.CreateItemJournal(ItemJournalBatch,ItemNo2,ItemJournalBatch."Template Type"::Consumption,ProductionOrderNo);
        LibraryInventory.PostItemJournalLine(ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name);
        LibraryInventory.CreateItemJournal(ItemJournalBatch,ItemNo2,ItemJournalBatch."Template Type"::Output,ProductionOrderNo);
        LibraryInventory.PostItemJournalLine(ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name);
      END;
      ProductionOrder.GET(ProductionOrder.Status::Released,ProductionOrderNo);

      // 2. Exercise: Change Status of Production Order to Finished.
      // Run Adjust Cost Item Entries report and Post Inventory Cost to G/L report.
      LibraryManufacturing.ChangeStatusReleasedToFinished(ProductionOrderNo);
      LibraryCosting.AdjustCostItemEntries(ItemNo + '..' + ItemNo2,'');
      LibraryCosting.PostInvtCostToGL(FALSE,WORKDATE,'');

      // 3. Verify: Verify WIP Account General Ledger Entries for Total amount and Positive amount entries.
      VerifyWIPAmountGLEntry(ProductionOrder,ItemNo,TRUE);
Member of Lib.Library - Costing


PostInvtCostToGLTest@2 Method

The procedure PostInvtCostToGLTest is available in codeunit 132200.

Syntax

PostInvtCostToGLTest@2(
    PostMethod@1004 : Option PostMethod, //Input parameter of type Option
    ItemNo@1102 : Code[20] ItemNo, //Input parameter of type Code
    DocumentNo@1001 : Code[20] DocumentNo, //Input parameter of type Code
    ShowDim@1005 : Boolean ShowDim, //Input parameter of type Boolean
    ShowOnlyWarnings@1006 : Boolean ShowOnlyWarnings //Input parameter of type Boolean
);

Parameters

PostMethod
Input parameter of type Option
ItemNo
Input parameter of type Code
DocumentNo
Input parameter of type Code
ShowDim
Input parameter of type Boolean
ShowOnlyWarnings
Input parameter of type Boolean

Remarks

The relevant search keywords are: Post, Invt, Cost, To, General Ledger, Test.

For a clarification about how this function works, refer to the code listed below.

      COMMIT;
      PostValueEntryToGL.SETRANGE("Item No.",ItemNo);
      PostInvtCostToGLTest.InitializeRequest(PostMethod,DocumentNo,ShowDim,ShowOnlyWarnings);
      PostInvtCostToGLTest.SETTABLEVIEW(PostValueEntryToGL);
      PostInvtCostToGLTest.USEREQUESTPAGE(FALSE);

Example

The below example is extracted from the test automation codeunit 137285 to show one way of using this function.

      // Verify Value Entry after running Post Inventory Cost To G/L - Test batch job using Post Method 'Per Entry'.

      // Setup: Update Sales and Receivables Setup, Ship a Service Order, Receive a Purchase Order and Receive and Invoice another Purchase Order.
      Initialize;
      LibrarySales.SetCreditWarningsToNoWarnings;
      LibrarySales.SetStockoutWarning(FALSE);
      CreateServiceAndPurchaseOrder(PurchaseLine);
      PostPurchaseDocument(PurchaseLine,TRUE);

      // Exercise: Run Post Invt. Cost To G/L - Test batch job.
      LibraryCosting.PostInvtCostToGLTest(PostMethod::"per Entry",PurchaseLine."No.",'',FALSE,FALSE);

      // Verify: Verify Item Ledger Entry after running Adjust Cost Item Entries.
      VerifyValueEntryCost(PurchaseLine."No.");
Member of Lib.Library - Costing


SuggestCapacityStandardCost@32 Method

The procedure SuggestCapacityStandardCost is available in codeunit 132200.

Syntax

SuggestCapacityStandardCost@32(
    VAR WorkCenter@1001 : Record 99000754 WorkCenter, //Reference parameter of type Record
    VAR MachineCenter@1000 : Record 99000758 MachineCenter, //Reference parameter of type Record
    StandardCostWorksheetName@1003 : Code[10] StandardCostWorksheetName, //Input parameter of type Code
    StandardCostAdjustmentFactor@1006 : Integer StandardCostAdjustmentFactor, //Input parameter of type Integer
    StandardCostRoundingMethod@1007 : Code[10] StandardCostRoundingMethod //Input parameter of type Code
);

Parameters

WorkCenter
Reference parameter of type Record
MachineCenter
Reference parameter of type Record
StandardCostWorksheetName
Input parameter of type Code
StandardCostAdjustmentFactor
Input parameter of type Integer
StandardCostRoundingMethod
Input parameter of type Code

Remarks

The relevant search keywords are: Suggest, Capacity, Standard, Cost.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(SuggestCapacityStandardCost);
      SuggestCapacityStandardCost.Initialize(
        StandardCostWorksheetName,StandardCostAdjustmentFactor,0,0,StandardCostRoundingMethod,'','');
      IF WorkCenter.HASFILTER THEN
        TmpWorkCenter.COPYFILTERS(WorkCenter)
      ELSE BEGIN
        WorkCenter.GET(WorkCenter."No.");
        TmpWorkCenter.SETRANGE("No.",WorkCenter."No.");
      END;
      SuggestCapacityStandardCost.SETTABLEVIEW(TmpWorkCenter);

      IF MachineCenter.HASFILTER THEN
        TmpMachineCenter.COPYFILTERS(MachineCenter)
      ELSE BEGIN
        MachineCenter.GET(MachineCenter."No.");
        TmpMachineCenter.SETRANGE("No.",MachineCenter."No.");
      END;
      SuggestCapacityStandardCost.SETTABLEVIEW(TmpMachineCenter);
      SuggestCapacityStandardCost.USEREQUESTPAGE(FALSE);
      SuggestCapacityStandardCost.RUN;

Example

The below example is extracted from the test automation codeunit 137402 to show one way of using this function.

      // Test functionality of Implement Standard Cost Change report.

      // Setup: Create Item, Work Center, Machine Center and Standard Cost Worksheet Name. Run Suggest Item Standard Cost and Suggest Work and Machine Center Standard Cost report.
      Initialize;
      CreateItem(Item);
      CreateWorkCenter(WorkCenter);
      CreateMachineCenter(MachineCenter);
      StandardCostWorksheetName := CreateStandardCostWorksheetName;
      LibraryCosting.SuggestItemStandardCost(Item,StandardCostWorksheetName,LibraryRandom.RandInt(5),'');  // Use random value for Standard Cost Adjustment Factor.
      LibraryCosting.SuggestCapacityStandardCost(
        WorkCenter,MachineCenter,StandardCostWorksheetName,LibraryRandom.RandInt(5),'');  // Use random value for Standard Cost Adjustment Factor.

      // Exercise: Run Implement Standard Cost Change.
      RunImplementStandardCostChange(StandardCostWorksheetName,StandardCostWorksheet.Type::Item,Item."No.");
      RunImplementStandardCostChange(StandardCostWorksheetName,StandardCostWorksheet.Type::"Work Center",WorkCenter."No.");
      RunImplementStandardCostChange(StandardCostWorksheetName,StandardCostWorksheet.Type::"Machine Center",MachineCenter."No.");

      // Verify: Verify Standard Cost must be implemented.
      VerifyStandardCostWorksheet(StandardCostWorksheetName,StandardCostWorksheet.Type::Item,Item."No.");
      VerifyStandardCostWorksheet(StandardCostWorksheetName,StandardCostWorksheet.Type::"Work Center",WorkCenter."No.");
      VerifyStandardCostWorksheet(StandardCostWorksheetName,StandardCostWorksheet.Type::"Machine Center",MachineCenter."No.");
Member of Lib.Library - Costing


SuggestItemPriceWorksheet@136 Method

The procedure SuggestItemPriceWorksheet is available in codeunit 132200.

Syntax

SuggestItemPriceWorksheet@136(
    Item@1001 : Record 27 Item, //Input parameter of type Record
    SalesCode@1000 : Code[20] SalesCode, //Input parameter of type Code
    SalesType@1004 : Option SalesType, //Input parameter of type Option
    PriceLowerLimit@1003 : Decimal PriceLowerLimit, //Input parameter of type Decimal
    UnitPriceFactor@1005 : Decimal UnitPriceFactor //Input parameter of type Decimal
);

Parameters

Item
Input parameter of type Record
SalesCode
Input parameter of type Code
SalesType
Input parameter of type Option
PriceLowerLimit
Input parameter of type Decimal
UnitPriceFactor
Input parameter of type Decimal

Remarks

The relevant search keywords are: Suggest, Item, Price, Worksheet.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(SuggestItemPriceOnWksh);
      SuggestItemPriceOnWksh.InitializeRequest2(
        SalesType,SalesCode,WORKDATE,WORKDATE,'',Item."Base Unit of Measure",PriceLowerLimit,UnitPriceFactor,'',TRUE);
      SuggestItemPriceOnWksh.USEREQUESTPAGE(FALSE);
      Item.SETRANGE("No.",Item."No.");
      SuggestItemPriceOnWksh.SETTABLEVIEW(Item);
      SuggestItemPriceOnWksh.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 137201 to show one way of using this function.

      // Setup: Create Sales Price Setup. Suggest Item Price and implement new price.
      Initialize;
      SalesPriceWorksheet.DELETEALL;
      CreateSalesPriceSetup(SalesReceivablesSetup,Item,Customer);
      MinimumQty := LibraryRandom.RandDec(5,2) + 10;  // Random values not important.
      CreateSalesPrice(
        Item,SalesPrice."Sales Type"::Customer,Customer."No.",Item."Unit Price" - LibraryRandom.RandInt(5),MinimumQty);
      LibraryCosting.SuggestItemPriceWorksheet(Item,Customer."No.",SalesType::Customer,0,1);  // Values important for test.
      NewUnitPrice := ImplementNewSalesPrice;

      // Exercise: Create Sales Order.
      CreateSalesOrder(SalesLine,Customer."No.",Item."No.",MinimumQty);

      // Verify: Verify Line Amount on Sales Line.
      SalesLine.TESTFIELD(
        "Line Amount",ROUND(NewUnitPrice * MinimumQty,GeneralLedgerSetup."Inv. Rounding Precision (LCY)"));
Member of Lib.Library - Costing


SuggestItemPriceWorksheet2@1 Method

The procedure SuggestItemPriceWorksheet2 is available in codeunit 132200.

Syntax

SuggestItemPriceWorksheet2@1(
    Item@1001 : Record 27 Item, //Input parameter of type Record
    SalesCode@1000 : Code[20] SalesCode, //Input parameter of type Code
    SalesType@1004 : Option SalesType, //Input parameter of type Option
    PriceLowerLimit@1003 : Decimal PriceLowerLimit, //Input parameter of type Decimal
    UnitPriceFactor@1005 : Decimal UnitPriceFactor, //Input parameter of type Decimal
    CurrencyCode@1006 : Code[10] CurrencyCode //Input parameter of type Code
);

Parameters

Item
Input parameter of type Record
SalesCode
Input parameter of type Code
SalesType
Input parameter of type Option
PriceLowerLimit
Input parameter of type Decimal
UnitPriceFactor
Input parameter of type Decimal
CurrencyCode
Input parameter of type Code

Remarks

The relevant search keywords are: Suggest, Item, Price, Worksheet2.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(SuggestItemPriceOnWksh);
      SuggestItemPriceOnWksh.InitializeRequest2(
        SalesType,SalesCode,WORKDATE,WORKDATE,CurrencyCode,Item."Base Unit of Measure",PriceLowerLimit,UnitPriceFactor,'',TRUE);
      IF Item.HASFILTER THEN
        TmpItem.COPYFILTERS(Item)
      ELSE BEGIN
        Item.GET(Item."No.");
        TmpItem.SETRANGE("No.",Item."No.");
      END;
      SuggestItemPriceOnWksh.SETTABLEVIEW(TmpItem);
      SuggestItemPriceOnWksh.USEREQUESTPAGE(FALSE);
      SuggestItemPriceOnWksh.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 137402 to show one way of using this function.

      // Setup.
      CreateItem(Item);

      // Exercise: Run Suggest Item Price on Worksheet.
      LibraryCosting.SuggestItemPriceWorksheet2(Item,SalesCode,SalesType,0,LibraryRandom.RandInt(10),CurrencyCode);  // Use random Unit Price Factor and zero Price Lower Limit.

      // Verify: Verify Sales Price Worksheet must exist.
      VerifySalesPriceWorksheet(SalesType,SalesCode,CurrencyCode,Item."No.");
Member of Lib.Library - Costing


SuggestItemStandardCost@28 Method

The procedure SuggestItemStandardCost is available in codeunit 132200.

Syntax

SuggestItemStandardCost@28(
    VAR Item@1000 : Record 27 Item, //Reference parameter of type Record
    StandardCostWorksheetName@1002 : Code[10] StandardCostWorksheetName, //Input parameter of type Code
    StandardCostAdjustmentFactor@1004 : Integer StandardCostAdjustmentFactor, //Input parameter of type Integer
    StandardCostRoundingMethod@1005 : Code[10] StandardCostRoundingMethod //Input parameter of type Code
);

Parameters

Item
Reference parameter of type Record
StandardCostWorksheetName
Input parameter of type Code
StandardCostAdjustmentFactor
Input parameter of type Integer
StandardCostRoundingMethod
Input parameter of type Code

Remarks

The relevant search keywords are: Suggest, Item, Standard, Cost.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(SuggestItemStandardCost);
      SuggestItemStandardCost.Initialize(StandardCostWorksheetName,StandardCostAdjustmentFactor,0,0,StandardCostRoundingMethod,'','');
      IF Item.HASFILTER THEN
        TmpItem.COPYFILTERS(Item)
      ELSE BEGIN
        Item.GET(Item."No.");
        TmpItem.SETRANGE("No.",Item."No.");
      END;
      SuggestItemStandardCost.SETTABLEVIEW(TmpItem);
      SuggestItemStandardCost.USEREQUESTPAGE(FALSE);
      SuggestItemStandardCost.RUN;

Example

The below example is extracted from the test automation codeunit 137007 to show one way of using this function.

      // [FEATURE] [Standard Cost Worksheet] [Suggest Item Standard Cost]
      // [SCENARIO 377601] "Suggest Item Standard Cost" should copy manufacturing costs from item card if item's replenishment system is "Prod. Order"

      // [GIVEN] Create item with replenishment system = "Prod. Order"
      MockItemWithManufacturingCosts(Item,Item."Replenishment System"::"Prod. Order");

      // [WHEN] Open standard cost worksheet and run "Suggest Item Standard Cost"
      StandardCostWkshName := CreateAndUpdateStandardCostWorksheet(Item);
      LibraryCosting.SuggestItemStandardCost(Item,StandardCostWkshName,1,'');

      // [THEN] Manufacturing cost components are copied from item card
      VerifyStdCostWorksheetMfgItem(StandardCostWkshName,Item);
Member of Lib.Library - Costing


SuggestSalesPriceWorksheet@137 Method

The procedure SuggestSalesPriceWorksheet is available in codeunit 132200.

Syntax

SuggestSalesPriceWorksheet@137(
    Item@1000 : Record 27 Item, //Input parameter of type Record
    SalesCode@1001 : Code[20] SalesCode, //Input parameter of type Code
    SalesType@1005 : Option SalesType, //Input parameter of type Option
    PriceLowerLimit@1003 : Decimal PriceLowerLimit, //Input parameter of type Decimal
    UnitPriceFactor@1006 : Decimal UnitPriceFactor //Input parameter of type Decimal
);

Parameters

Item
Input parameter of type Record
SalesCode
Input parameter of type Code
SalesType
Input parameter of type Option
PriceLowerLimit
Input parameter of type Decimal
UnitPriceFactor
Input parameter of type Decimal

Remarks

The relevant search keywords are: Suggest, Sales, Price, Worksheet.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(SuggestSalesPriceOnWksh);
      SuggestSalesPriceOnWksh.InitializeRequest2(
        SalesType,SalesCode,WORKDATE,WORKDATE,'',Item."Base Unit of Measure",FALSE,PriceLowerLimit,UnitPriceFactor,'');
      SuggestSalesPriceOnWksh.USEREQUESTPAGE(FALSE);
      SalesPrice.SETRANGE("Item No.",Item."No.");
      SuggestSalesPriceOnWksh.SETTABLEVIEW(SalesPrice);
      SuggestSalesPriceOnWksh.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 137201 to show one way of using this function.

      // Setup: Create Sales Price Setup with Line Discount and suggest new Sales Price.
      Initialize;
      SalesPriceWorksheet.DELETEALL;
      CreateSalesPriceSetup(SalesReceivablesSetup,Item,Customer);
      MinimumQty := LibraryRandom.RandDec(5,2) + 10;  // Random values not important.
      CreateSalesPrice(
        Item,SalesPrice."Sales Type"::Customer,Customer."No.",Item."Unit Price" - LibraryRandom.RandInt(5),MinimumQty);
      CreateSalesLineDiscount(Item,Customer."No.",MinimumQty);
      LibraryCosting.SuggestSalesPriceWorksheet(Item,Customer."No.",SalesType::Customer,0,1);  // Values important for test.
      NewUnitPrice := ImplementNewSalesPrice;

      // Exercise: Create Sales Order.
      CreateSalesOrder(SalesLine,Customer."No.",Item."No.",MinimumQty);

      // Verify: Verify Line Amount on Sales Line.
      VerifySalesLine(SalesLine,NewUnitPrice,MinimumQty,GeneralLedgerSetup."Inv. Rounding Precision (LCY)");
Member of Lib.Library - Costing


UpdateUnitCost@71 Method

The procedure UpdateUnitCost is available in codeunit 132200.

Syntax

UpdateUnitCost@71(
    VAR ProductionOrder@1000 : Record 5405 ProductionOrder, //Reference parameter of type Record
    CalcMethod@1002 : Option CalcMethod, //Input parameter of type Option
    UpdateReservations@1003 : Boolean UpdateReservations //Input parameter of type Boolean
);

Parameters

ProductionOrder
Reference parameter of type Record
CalcMethod
Input parameter of type Option
UpdateReservations
Input parameter of type Boolean

Remarks

The relevant search keywords are: Update, Unit, Cost.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(UpdateUnitCost);
      UpdateUnitCost.InitializeRequest(CalcMethod,UpdateReservations);
      IF ProductionOrder.HASFILTER THEN
        TmpProductionOrder.COPYFILTERS(ProductionOrder)
      ELSE BEGIN
        ProductionOrder.GET(ProductionOrder.Status,ProductionOrder."No.");
        TmpProductionOrder.SETRANGE(Status,ProductionOrder.Status);
        TmpProductionOrder.SETRANGE("No.",ProductionOrder."No.");
      END;
      UpdateUnitCost.SETTABLEVIEW(TmpProductionOrder);
      UpdateUnitCost.USEREQUESTPAGE(FALSE);
      UpdateUnitCost.RUN;

Example

The below example is extracted from the test automation codeunit 137007 to show one way of using this function.

      // Setup: Create Parent and Child Items in a Production BOM and certify it. Create Released Production Order and Refresh it. Create and Post Item Journal line with Unit Amount.
      Initialize;
      CreateItemsSetup(Item,ChildItem);
      CreateAndRefreshReleasedProductionOrder(ProductionOrder,Item."No.");
      UnitAmount := CreateAndPostItemJournalLine(ChildItem."No.",ProductionOrder.Quantity,'');

      // Exercise: Run Update Unit Cost batch Report.
      LibraryCosting.UpdateUnitCost(ProductionOrder,CalcMethod::"One Level",FALSE);

      // Verify: Verify that Unit Cost on Prod. Order Line is updated from Child Item Unit Amount.
      VerifyUnitCostInProductionOrderLine(ProductionOrder,UnitAmount);
Member of Lib.Library - Costing


Library - Dimension Class

Lib.Library - Dimension

COD131001 applies to RES,ERM,SCM,COSTING,W1,All.
Contains all utility functions related to Dimensions.

Methods

Name | Description
BlockDimension@13 | The procedure BlockDimension is available in codeunit 131001.
BlockDimensionValue@14 | The procedure BlockDimensionValue is available in codeunit 131001.
ChangeGlobalDimensions@30 | The procedure ChangeGlobalDimensions is available in codeunit 131001.
CreateAccTypeDefaultDimension@9 | The procedure CreateAccTypeDefaultDimension is available in codeunit 131001.
CreateAndMapICDimFromDim@27 | The procedure CreateAndMapICDimFromDim is available in codeunit 131001.
CreateAndMapICDimValueFromDimValue@32 | The procedure CreateAndMapICDimValueFromDimValue is available in codeunit 131001.
CreateDefaultDimension@1 | The procedure CreateDefaultDimension is available in codeunit 131001.
CreateDefaultDimensionCustomer@21 | The procedure CreateDefaultDimensionCustomer is available in codeunit 131001.
CreateDefaultDimensionGLAcc@16 | The procedure CreateDefaultDimensionGLAcc is available in codeunit 131001.
CreateDefaultDimensionItem@12 | The procedure CreateDefaultDimensionItem is available in codeunit 131001.
CreateDefaultDimensionPriority@5 | The procedure CreateDefaultDimensionPriority is available in codeunit 131001.
CreateDefaultDimensionResource@19 | The procedure CreateDefaultDimensionResource is available in codeunit 131001.
CreateDefaultDimensionVendor@10 | The procedure CreateDefaultDimensionVendor is available in codeunit 131001.
CreateDimension@7 | The procedure CreateDimension is available in codeunit 131001.
CreateDimensionCombination@53 | The procedure CreateDimensionCombination is available in codeunit 131001.
CreateDimensionValue@8 | The procedure CreateDimensionValue is available in codeunit 131001.
CreateDimensionValueWithCode@26 | The procedure CreateDimensionValueWithCode is available in codeunit 131001.
CreateDimSet@6 | The procedure CreateDimSet is available in codeunit 131001.
CreateDimValueCombination@11 | The procedure CreateDimValueCombination is available in codeunit 131001.
CreateDimWithDimValue@22 | The procedure CreateDimWithDimValue is available in codeunit 131001.
CreateICDimension@18 | The procedure CreateICDimension is available in codeunit 131001.
CreateICDimensionValue@17 | The procedure CreateICDimensionValue is available in codeunit 131001.
CreateSelectedDimension@46 | The procedure CreateSelectedDimension is available in codeunit 131001.
CreateServiceContractDimension@4 | The procedure CreateServiceContractDimension is available in codeunit 131001.
DeleteDimSet@3 | The procedure DeleteDimSet is available in codeunit 131001.
EditDimSet@2 | The procedure EditDimSet is available in codeunit 131001.
FindDefaultDimension@219 | The procedure FindDefaultDimension is available in codeunit 131001.
FindDifferentDimensionValue@126 | The procedure FindDifferentDimensionValue is available in codeunit 131001.
FindDimension@15 | The procedure FindDimension is available in codeunit 131001.
FindDimensionSetEntry@117 | The procedure FindDimensionSetEntry is available in codeunit 131001.
FindDimensionValue@78 | The procedure FindDimensionValue is available in codeunit 131001.
GetNextDimensionValue@20 | The procedure GetNextDimensionValue is available in codeunit 131001.
ResetDefaultDimensions@166 | The procedure ResetDefaultDimensions is available in codeunit 131001.

See Also

Lib


BlockDimension@13 Method

The procedure BlockDimension is available in codeunit 131001.

Syntax

BlockDimension@13(
    VAR Dimension@1000 : Record 348 Dimension //Reference parameter of type Record
);

Parameters

Dimension
Reference parameter of type Record

Remarks

The relevant search keywords are: Block, Dimension.

For a clarification about how this function works, refer to the code listed below.

      Dimension.VALIDATE(Blocked,TRUE);
      Dimension.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134380 to show one way of using this function.

      // [FEATURE] [UT]
      // [SCENARIO 221094] Not possible to assign blocked dimension to "Shortcut Dimension Code" field

      Initialize;
      LibraryDim.CreateDimension(Dimension);
      LibraryDim.BlockDimension(Dimension);
      LibraryDim.CreateDimensionValue(DimensionValue,Dimension.Code);

      VerifyDimValueCodeCannotBeAssignedToField(
        GenJournalLine,GenJournalLine.FIELDNO("Shortcut Dimension 1 Code"),DimensionValue.Code);
      VerifyDimValueCodeCannotBeAssignedToField(
        GenJournalLine,GenJournalLine.FIELDNO("Shortcut Dimension 2 Code"),DimensionValue.Code);
      VerifyDimValueCodeCannotBeAssignedToField(
        ServiceLine,ServiceLine.FIELDNO("Shortcut Dimension 1 Code"),DimensionValue.Code);
      VerifyDimValueCodeCannotBeAssignedToField(
        ServiceLine,ServiceLine.FIELDNO("Shortcut Dimension 2 Code"),DimensionValue.Code);
      VerifyDimValueCodeCannotBeAssignedToField(
        ServiceItemLine,ServiceItemLine.FIELDNO("Shortcut Dimension 1 Code"),DimensionValue.Code);
      VerifyDimValueCodeCannotBeAssignedToField(
        ServiceItemLine,ServiceItemLine.FIELDNO("Shortcut Dimension 2 Code"),DimensionValue.Code);
      VerifyDimValueCodeCannotBeAssignedToField(
        ServiceHeader,ServiceHeader.FIELDNO("Shortcut Dimension 1 Code"),DimensionValue.Code);
      VerifyDimValueCodeCannotBeAssignedToField(
        ServiceHeader,ServiceHeader.FIELDNO("Shortcut Dimension 2 Code"),DimensionValue.Code);
      VerifyDimValueCodeCannotBeAssignedToField(
        PurchaseLine,PurchaseLine.FIELDNO("Shortcut Dimension 1 Code"),DimensionValue.Code);
      VerifyDimValueCodeCannotBeAssignedToField(
        PurchaseLine,PurchaseLine.FIELDNO("Shortcut Dimension 2 Code"),DimensionValue.Code);
      VerifyDimValueCodeCannotBeAssignedToField(
        SalesLine,SalesLine.FIELDNO("Shortcut Dimension 1 Code"),DimensionValue.Code);
      VerifyDimValueCodeCannotBeAssignedToField(
        SalesLine,SalesLine.FIELDNO("Shortcut Dimension 2 Code"),DimensionValue.Code);
      VerifyDimValueCodeCannotBeAssignedToField(
        SalesHeader,SalesHeader.FIELDNO("Shortcut Dimension 1 Code"),DimensionValue.Code);
      VerifyDimValueCodeCannotBeAssignedToField(
        SalesHeader,SalesHeader.FIELDNO("Shortcut Dimension 2 Code"),DimensionValue.Code);
Member of Lib.Library - Dimension


BlockDimensionValue@14 Method

The procedure BlockDimensionValue is available in codeunit 131001.

Syntax

BlockDimensionValue@14(
    VAR DimensionValue@1000 : Record 349 DimensionValue //Reference parameter of type Record
);

Parameters

DimensionValue
Reference parameter of type Record

Remarks

The relevant search keywords are: Block, Dimension, Value.

For a clarification about how this function works, refer to the code listed below.

      DimensionValue.VALIDATE(Blocked,TRUE);
      DimensionValue.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134477 to show one way of using this function.

      DimensionValue.VALIDATE("Dimension Value Type",DimensionValueType);
      LibraryDimension.BlockDimensionValue(DimensionValue);
Member of Lib.Library - Dimension


ChangeGlobalDimensions@30 Method

The procedure ChangeGlobalDimensions is available in codeunit 131001.

Syntax

ChangeGlobalDimensions@30(
    GlobalDimension1Code@1001 : Code[20] GlobalDimension1Code, //Input parameter of type Code
    GlobalDimension2Code@1002 : Code[20] GlobalDimension2Code //Input parameter of type Code
);

Parameters

GlobalDimension1Code
Input parameter of type Code
GlobalDimension2Code
Input parameter of type Code

Remarks

The relevant search keywords are: Change, Global, Dimensions.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(ChangeGlobalDimensions);
      ChangeGlobalDimensions.InitializeRequest(GlobalDimension1Code,GlobalDimension2Code);
      ChangeGlobalDimensions.USEREQUESTPAGE(FALSE);
      ChangeGlobalDimensions.RUN;

Example

The below example is extracted from the test automation codeunit 134328 to show one way of using this function.

      IF (LibraryERM.GetGlobalDimensionCode(1) = '') OR (LibraryERM.GetGlobalDimensionCode(2) = '') THEN BEGIN
        LibraryDimension.CreateDimension(Dimension[1]);
        LibraryDimension.CreateDimension(Dimension[2]);
        LibraryDimension.ChangeGlobalDimensions(Dimension[1].Code,Dimension[2].Code);
      END;
Member of Lib.Library - Dimension


CreateAccTypeDefaultDimension@9 Method

The procedure CreateAccTypeDefaultDimension is available in codeunit 131001.

Syntax

CreateAccTypeDefaultDimension@9(
    VAR DefaultDimension@1003 : Record 352 DefaultDimension, //Reference parameter of type Record
    TableID@1001 : Integer TableID, //Input parameter of type Integer
    DimensionCode@1000 : Code[20] DimensionCode, //Input parameter of type Code
    DimensionValueCode@1002 : Code[20] DimensionValueCode, //Input parameter of type Code
    ValuePosting@1004 : Option ValuePosting //Input parameter of type Option
);

Parameters

DefaultDimension
Reference parameter of type Record
TableID
Input parameter of type Integer
DimensionCode
Input parameter of type Code
DimensionValueCode
Input parameter of type Code
ValuePosting
Input parameter of type Option

Remarks

The relevant search keywords are: Create, Account, Type, Default, Dimension.

For a clarification about how this function works, refer to the code listed below.

      CreateDefaultDimension(DefaultDimension,TableID,' ',DimensionCode,DimensionValueCode);
      DefaultDimension.VALIDATE("Value Posting",ValuePosting);
      DefaultDimension.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134380 to show one way of using this function.

      // Test codeunit 408, function CheckDimValueposting.
      // Parameters: Code mandatory/Specific account value posting + same code/Entir Account type value posting
      // replace 140767,140768,140769,140771,140772,140773,140774,140775,140776,140777,140778

      Initialize;
      // Setup entir account type value posting
      LibraryDim.CreateAccTypeDefaultDimension(DefaultDimension,DATABASE::Customer,TestDim,TestDimValue,
        DefaultDimension."Value Posting"::"Same Code");

      ValPosting_Setup(GLAccount,Customer,DefaultDimension,GenJnlLine,DefaultDimension."Value Posting"::"Code Mandatory");
      DimSetID := GenJnlLine."Dimension Set ID";
      NewDimSetID := LibraryDim.EditDimSet(DimSetID,TestDim,TestDimValue2);
      ModifyJnlDimSetID(GenJnlLine,NewDimSetID);
      // Necessary to be able to run possitive test after negative test.
      COMMIT;

      ErrorText := STRSUBSTNO(CombinationError,JournalTemplate,JournalBatch,GenJnlLine."Line No.",TestDimValue,TestDim);

      NegativeTest(GenJnlLine,ErrorText);
      PossitiveTest(GenJnlLine,DimSetID);

      // Test cleanup
      DefaultDimension.RESET;
      DefaultDimension.SETRANGE("Table ID",DATABASE::Customer);
      DefaultDimension.SETRANGE("No.",' ');
      DefaultDimension.SETRANGE("Dimension Code",TestDim);
      DefaultDimension.FINDFIRST;
      DefaultDimension.DELETE(TRUE);
Member of Lib.Library - Dimension


CreateAndMapICDimFromDim@27 Method

The procedure CreateAndMapICDimFromDim is available in codeunit 131001.

Syntax

CreateAndMapICDimFromDim@27(
    VAR ICDimension@1001 : Record 411 ICDimension, //Reference parameter of type Record
    DimensionCode@1002 : Code[20] DimensionCode //Input parameter of type Code
);

Parameters

ICDimension
Reference parameter of type Record
DimensionCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Map, Inter-Company, Dimensionension, From, Dimensionension.

For a clarification about how this function works, refer to the code listed below.

      ICDimension.INIT;
      ICDimension.VALIDATE(Code,DimensionCode);
      ICDimension.VALIDATE("Map-to Dimension Code",DimensionCode);
      ICDimension.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134154 to show one way of using this function.

      LibraryDimension.CreateAndMapICDimFromDim(ICDimension,DimensionValue."Dimension Code");
      LibraryDimension.CreateAndMapICDimValueFromDimValue(ICDimensionValue,DimensionValue.Code,DimensionValue."Dimension Code");
      ICDocumentDimension.INIT;
      ICDocumentDimension."IC Partner Code" := ICPartnerCode;
      ICDocumentDimension."Transaction No." := TransactionNo;
      ICDocumentDimension."Table ID" := TableID;
      ICDocumentDimension."Dimension Code" := ICDimensionValue."Dimension Code";
      ICDocumentDimension."Dimension Value Code" := ICDimensionValue.Code;
      ICDocumentDimension."Line No." := LineNo;
      ICDocumentDimension.INSERT;
Member of Lib.Library - Dimension


CreateAndMapICDimValueFromDimValue@32 Method

The procedure CreateAndMapICDimValueFromDimValue is available in codeunit 131001.

Syntax

CreateAndMapICDimValueFromDimValue@32(
    VAR ICDimensionValue@1000 : Record 412 ICDimensionValue, //Reference parameter of type Record
    DimensionValueCode@1001 : Code[20] DimensionValueCode, //Input parameter of type Code
    DimensionCode@1002 : Code[20] DimensionCode //Input parameter of type Code
);

Parameters

ICDimensionValue
Reference parameter of type Record
DimensionValueCode
Input parameter of type Code
DimensionCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Map, Inter-Company, Dimensionension, Value, From, Dimensionension, Value.

For a clarification about how this function works, refer to the code listed below.

      ICDimensionValue.INIT;
      ICDimensionValue.VALIDATE("Dimension Code",DimensionCode);
      ICDimensionValue.VALIDATE(Code,DimensionValueCode);
      ICDimensionValue.VALIDATE("Map-to Dimension Code",DimensionCode);
      ICDimensionValue.VALIDATE("Map-to Dimension Value Code",DimensionValueCode);
      ICDimensionValue.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134154 to show one way of using this function.

      LibraryDimension.CreateAndMapICDimFromDim(ICDimension,DimensionValue."Dimension Code");
      LibraryDimension.CreateAndMapICDimValueFromDimValue(ICDimensionValue,DimensionValue.Code,DimensionValue."Dimension Code");
      ICDocumentDimension.INIT;
      ICDocumentDimension."IC Partner Code" := ICPartnerCode;
      ICDocumentDimension."Transaction No." := TransactionNo;
      ICDocumentDimension."Table ID" := TableID;
      ICDocumentDimension."Dimension Code" := ICDimensionValue."Dimension Code";
      ICDocumentDimension."Dimension Value Code" := ICDimensionValue.Code;
      ICDocumentDimension."Line No." := LineNo;
      ICDocumentDimension.INSERT;
Member of Lib.Library - Dimension


CreateDefaultDimension@1 Method

The procedure CreateDefaultDimension is available in codeunit 131001.

Syntax

CreateDefaultDimension@1(
    VAR DefaultDimension@1000 : Record 352 DefaultDimension, //Reference parameter of type Record
    TableID@1001 : Integer TableID, //Input parameter of type Integer
    No@1002 : Code[20] No, //Input parameter of type Code
    DimensionCode@1003 : Code[20] DimensionCode, //Input parameter of type Code
    DimensionValueCode@1004 : Code[20] DimensionValueCode //Input parameter of type Code
);

Parameters

DefaultDimension
Reference parameter of type Record
TableID
Input parameter of type Integer
No
Input parameter of type Code
DimensionCode
Input parameter of type Code
DimensionValueCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Default, Dimension.

For a clarification about how this function works, refer to the code listed below.

      DefaultDimension.INIT;
      DefaultDimension.VALIDATE("Table ID",TableID);
      DefaultDimension.VALIDATE("No.",No);
      DefaultDimension.VALIDATE("Dimension Code",DimensionCode);
      DefaultDimension.VALIDATE("Dimension Value Code",DimensionValueCode);
      DefaultDimension.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134049 to show one way of using this function.

      FindDimensionValue(DimensionValue);
      LibraryDimension.CreateDefaultDimension(
        DefaultDimension,DATABASE::"Fixed Asset",FANo,DimensionValue."Dimension Code",DimensionValue.Code);
Member of Lib.Library - Dimension


CreateDefaultDimensionCustomer@21 Method

The procedure CreateDefaultDimensionCustomer is available in codeunit 131001.

Syntax

CreateDefaultDimensionCustomer@21(
    VAR DefaultDimension@1003 : Record 352 DefaultDimension, //Reference parameter of type Record
    CustomerNo@1001 : Code[20] CustomerNo, //Input parameter of type Code
    DimensionCode@1000 : Code[20] DimensionCode, //Input parameter of type Code
    DimensionValueCode@1002 : Code[20] DimensionValueCode //Input parameter of type Code
);

Parameters

DefaultDimension
Reference parameter of type Record
CustomerNo
Input parameter of type Code
DimensionCode
Input parameter of type Code
DimensionValueCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Default, Dimension, Customer.

For a clarification about how this function works, refer to the code listed below.

      CreateDefaultDimension(DefaultDimension,DATABASE::Customer,CustomerNo,DimensionCode,DimensionValueCode);

Example

The below example is extracted from the test automation codeunit 134154 to show one way of using this function.

      CustomerNo := LibrarySales.CreateCustomerNo;
      LibraryDimension.CreateDefaultDimensionCustomer(
        DefaultDimension,CustomerNo,DimensionValue[1]."Dimension Code",DimensionValue[1].Code);
      LibraryDimension.CreateDefaultDimensionCustomer(
        DefaultDimension,CustomerNo,DimensionValue[2]."Dimension Code",DimensionValue[2].Code);
Member of Lib.Library - Dimension


CreateDefaultDimensionGLAcc@16 Method

The procedure CreateDefaultDimensionGLAcc is available in codeunit 131001.

Syntax

CreateDefaultDimensionGLAcc@16(
    VAR DefaultDimension@1003 : Record 352 DefaultDimension, //Reference parameter of type Record
    GLAccountNo@1001 : Code[20] GLAccountNo, //Input parameter of type Code
    DimensionCode@1000 : Code[20] DimensionCode, //Input parameter of type Code
    DimensionValueCode@1002 : Code[20] DimensionValueCode //Input parameter of type Code
);

Parameters

DefaultDimension
Reference parameter of type Record
GLAccountNo
Input parameter of type Code
DimensionCode
Input parameter of type Code
DimensionValueCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Default, Dimension, General Ledger, Account.

For a clarification about how this function works, refer to the code listed below.

      CreateDefaultDimension(DefaultDimension,DATABASE::"G/L Account",GLAccountNo,DimensionCode,DimensionValueCode);

Example

The below example is extracted from the test automation codeunit 134000 to show one way of using this function.

      LibraryDimension.CreateDimWithDimValue(DimensionValue);
      LibraryDimension.CreateDefaultDimensionGLAcc(DefaultDimension,GLAccountNo,DimensionValue."Dimension Code",DimensionValue.Code);
      DefaultDimension.VALIDATE("Value Posting",DefaultDimension."Value Posting"::"Same Code");
      DefaultDimension.MODIFY;
Member of Lib.Library - Dimension


CreateDefaultDimensionItem@12 Method

The procedure CreateDefaultDimensionItem is available in codeunit 131001.

Syntax

CreateDefaultDimensionItem@12(
    VAR DefaultDimension@1003 : Record 352 DefaultDimension, //Reference parameter of type Record
    ItemNo@1001 : Code[20] ItemNo, //Input parameter of type Code
    DimensionCode@1000 : Code[20] DimensionCode, //Input parameter of type Code
    DimensionValueCode@1002 : Code[20] DimensionValueCode //Input parameter of type Code
);

Parameters

DefaultDimension
Reference parameter of type Record
ItemNo
Input parameter of type Code
DimensionCode
Input parameter of type Code
DimensionValueCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Default, Dimension, Item.

For a clarification about how this function works, refer to the code listed below.

      CreateDefaultDimension(DefaultDimension,DATABASE::Item,ItemNo,DimensionCode,DimensionValueCode);

Example

The below example is extracted from the test automation codeunit 134327 to show one way of using this function.

      GeneralLedgerSetup.GET;
      LibraryDimension.CreateDimensionValue(DimensionValue1,GeneralLedgerSetup."Shortcut Dimension 1 Code");
      LibraryDimension.CreateDimensionValue(DimensionValue2,GeneralLedgerSetup."Shortcut Dimension 2 Code");
      LibraryDimension.CreateDefaultDimensionGLAcc(DefaultDimension,GLAccountNo,DimensionValue1."Dimension Code",DimensionValue1.Code);
      LibraryDimension.CreateDefaultDimensionItem(DefaultDimension,ItemNo,DimensionValue2."Dimension Code",DimensionValue2.Code);
Member of Lib.Library - Dimension


CreateDefaultDimensionPriority@5 Method

The procedure CreateDefaultDimensionPriority is available in codeunit 131001.

Syntax

CreateDefaultDimensionPriority@5(
    VAR DefaultDimensionPriority@1000 : Record 354 DefaultDimensionPriority, //Reference parameter of type Record
    SourceCode@1001 : Code[10] SourceCode, //Input parameter of type Code
    TableID@1002 : Integer TableID //Input parameter of type Integer
);

Parameters

DefaultDimensionPriority
Reference parameter of type Record
SourceCode
Input parameter of type Code
TableID
Input parameter of type Integer

Remarks

The relevant search keywords are: Create, Default, Dimension, Priority.

For a clarification about how this function works, refer to the code listed below.

      DefaultDimensionPriority.INIT;
      DefaultDimensionPriority.VALIDATE("Source Code",SourceCode);
      DefaultDimensionPriority.VALIDATE("Table ID",TableID);
      DefaultDimensionPriority.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134381 to show one way of using this function.

      LibraryDimension.CreateDefaultDimensionPriority(DefaultDimensionPriority,SourceCode,TableID);
      DefaultDimensionPriority.VALIDATE(Priority,Priority);
      DefaultDimensionPriority.MODIFY(TRUE);
Member of Lib.Library - Dimension


CreateDefaultDimensionResource@19 Method

The procedure CreateDefaultDimensionResource is available in codeunit 131001.

Syntax

CreateDefaultDimensionResource@19(
    VAR DefaultDimension@1003 : Record 352 DefaultDimension, //Reference parameter of type Record
    ResourceNo@1001 : Code[20] ResourceNo, //Input parameter of type Code
    DimensionCode@1000 : Code[20] DimensionCode, //Input parameter of type Code
    DimensionValueCode@1002 : Code[20] DimensionValueCode //Input parameter of type Code
);

Parameters

DefaultDimension
Reference parameter of type Record
ResourceNo
Input parameter of type Code
DimensionCode
Input parameter of type Code
DimensionValueCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Default, Dimension, Resource.

For a clarification about how this function works, refer to the code listed below.

      CreateDefaultDimension(DefaultDimension,DATABASE::Resource,ResourceNo,DimensionCode,DimensionValueCode);

Example

The below example is extracted from the test automation codeunit 136118 to show one way of using this function.

      // 1. Setup: Create Customer, Create Resource, Create Default Dimension for Resource.
      Initialize;
      LibrarySales.CreateCustomer(Customer);
      LibraryDimension.FindDimension(Dimension);
      LibraryDimension.CreateDefaultDimensionResource(
        DefaultDimension,CreateResource,Dimension.Code,FindDimensionValue(Dimension.Code));

      // 2. Exercise: Create Service Header, Service Item Line and Service Line of Type Resource.
      CreateServiceOrder(ServiceLine,ServiceLine.Type::Resource,DefaultDimension."No.",Customer."No.",QtyToConsume);
Member of Lib.Library - Dimension


CreateDefaultDimensionVendor@10 Method

The procedure CreateDefaultDimensionVendor is available in codeunit 131001.

Syntax

CreateDefaultDimensionVendor@10(
    VAR DefaultDimension@1003 : Record 352 DefaultDimension, //Reference parameter of type Record
    VendorNo@1001 : Code[20] VendorNo, //Input parameter of type Code
    DimensionCode@1000 : Code[20] DimensionCode, //Input parameter of type Code
    DimensionValueCode@1002 : Code[20] DimensionValueCode //Input parameter of type Code
);

Parameters

DefaultDimension
Reference parameter of type Record
VendorNo
Input parameter of type Code
DimensionCode
Input parameter of type Code
DimensionValueCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Default, Dimension, Vendor.

For a clarification about how this function works, refer to the code listed below.

      CreateDefaultDimension(DefaultDimension,DATABASE::Vendor,VendorNo,DimensionCode,DimensionValueCode);

Example

The below example is extracted from the test automation codeunit 134154 to show one way of using this function.

      VendorNo := LibraryPurchase.CreateVendorNo;
      LibraryDimension.CreateDefaultDimensionVendor(
        DefaultDimension,VendorNo,DimensionValue[1]."Dimension Code",DimensionValue[1].Code);
      LibraryDimension.CreateDefaultDimensionVendor(
        DefaultDimension,VendorNo,DimensionValue[2]."Dimension Code",DimensionValue[2].Code);
Member of Lib.Library - Dimension


CreateDimension@7 Method

The procedure CreateDimension is available in codeunit 131001.

Syntax

CreateDimension@7(
    VAR Dimension@1002 : Record 348 Dimension //Reference parameter of type Record
);

Parameters

Dimension
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Dimension.

For a clarification about how this function works, refer to the code listed below.

      Dimension.INIT;
      Dimension.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(Dimension.FIELDNO(Code),DATABASE::Dimension),
          1,
          LibraryUtility.GetFieldLength(DATABASE::Dimension,Dimension.FIELDNO(Code))));
      Dimension.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134066 to show one way of using this function.

      LibraryDimension.CreateDimension(Dimension);
      EXIT(Dimension.Code);
Member of Lib.Library - Dimension


CreateDimensionCombination@53 Method

The procedure CreateDimensionCombination is available in codeunit 131001.

Syntax

CreateDimensionCombination@53(
    VAR DimensionCombination@1000 : Record 350 DimensionCombination, //Reference parameter of type Record
    Dimension1Code@1001 : Code[20] Dimension1Code, //Input parameter of type Code
    Dimension2Code@1002 : Code[20] Dimension2Code //Input parameter of type Code
);

Parameters

DimensionCombination
Reference parameter of type Record
Dimension1Code
Input parameter of type Code
Dimension2Code
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Dimension, Combination.

For a clarification about how this function works, refer to the code listed below.

      DimensionCombination.INIT;
      DimensionCombination.VALIDATE("Dimension 1 Code",Dimension1Code);
      DimensionCombination.VALIDATE("Dimension 2 Code",Dimension2Code);
      DimensionCombination.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134479 to show one way of using this function.

      CreateDimensionWithValue(DimensionValue);
      LibraryDimension.CreateDimensionCombination(DimensionCombination,DimensionCode,DimensionValue."Dimension Code");
Member of Lib.Library - Dimension


CreateDimensionValue@8 Method

The procedure CreateDimensionValue is available in codeunit 131001.

Syntax

CreateDimensionValue@8(
    VAR DimensionValue@1002 : Record 349 DimensionValue, //Reference parameter of type Record
    DimensionCode@1001 : Code[20] DimensionCode //Input parameter of type Code
);

Parameters

DimensionValue
Reference parameter of type Record
DimensionCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Dimension, Value.

For a clarification about how this function works, refer to the code listed below.

      DimensionValue.INIT;
      DimensionValue.VALIDATE("Dimension Code",DimensionCode);
      DimensionValue.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(DimensionValue.FIELDNO(Code),DATABASE::"Dimension Value"),
          1,
          LibraryUtility.GetFieldLength(DATABASE::"Dimension Value",DimensionValue.FIELDNO(Code))));
      DimensionValue.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134092 to show one way of using this function.

      LibraryDimension.CreateDimWithDimValue(DimensionValue);
      LibraryDimension.CreateDefaultDimension(DefaultDimension,
        DATABASE::"G/L Account",GLAccountCode,DimensionValue."Dimension Code",DimensionValue.Code);
      DefaultDimension.VALIDATE("Value Posting",DefaultDimension."Value Posting"::"Same Code");
      DefaultDimension.MODIFY(TRUE);
      LibraryDimension.CreateDimensionValue(DimensionValue,DefaultDimension."Dimension Code");
      DimSetID := CreateNewDimSetID(DimensionValue."Dimension Code",DimensionValue.Code);
      SelectedDimension.INIT;
      LibraryDimension.CreateSelectedDimension(SelectedDimension,3,
        REPORT::"Consolidation - Test Database",'',DefaultDimension."Dimension Code");
      DimensionSelectionBuffer.INIT;
      DimensionSelectionBuffer.Code := SelectedDimension."Dimension Code";
      DimensionSelectionBuffer.Selected := TRUE;
      DimensionSelectionBuffer.INSERT;
Member of Lib.Library - Dimension


CreateDimensionValueWithCode@26 Method

The procedure CreateDimensionValueWithCode is available in codeunit 131001.

Syntax

CreateDimensionValueWithCode@26(
    VAR DimensionValue@1002 : Record 349 DimensionValue, //Reference parameter of type Record
    DimensionValueCode@1000 : Code[20] DimensionValueCode, //Input parameter of type Code
    DimensionCode@1001 : Code[20] DimensionCode //Input parameter of type Code
);

Parameters

DimensionValue
Reference parameter of type Record
DimensionValueCode
Input parameter of type Code
DimensionCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Dimension, Value, Code.

For a clarification about how this function works, refer to the code listed below.

      DimensionValue.INIT;
      DimensionValue.VALIDATE("Dimension Code",DimensionCode);
      DimensionValue.VALIDATE(Code,
        COPYSTR(DimensionValueCode,1,LibraryUtility.GetFieldLength(DATABASE::"Dimension Value",DimensionValue.FIELDNO(Code))));
      DimensionValue.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134902 to show one way of using this function.

      LibraryDimension.CreateDimensionValueWithCode(TotalDimValue,TotalDimValueCode,LibraryERM.GetGlobalDimensionCode(1));
      TotalDimValue.VALIDATE("Dimension Value Type",TotalDimValue."Dimension Value Type"::Total);
      TotalDimValue.VALIDATE(Totaling,STRSUBSTNO('%1..%2',FromDimValueCode,ToDimValueCode));
      TotalDimValue.MODIFY;
Member of Lib.Library - Dimension


CreateDimSet@6 Method

The procedure CreateDimSet is available in codeunit 131001.

Syntax

CreateDimSet@6(
    DimSetID@1002 : Integer DimSetID, //Input parameter of type Integer
    DimCode@1000 : Code[20] DimCode, //Input parameter of type Code
    DimValCode@1001 : Code[20] DimValCode //Input parameter of type Code
);

Parameters

DimSetID
Input parameter of type Integer
DimCode
Input parameter of type Code
DimValCode
Input parameter of type Code

Return Value

Integer

Remarks

The relevant search keywords are: Create, Dimension, Set.

For a clarification about how this function works, refer to the code listed below.

      // Insert new dimension and dimension value on document, document line and journal
      // DimSetID: existing dimension set ID on document, document line and journal
      // Return new Dimension Set ID.

      DimMgt.GetDimensionSet(TempDimSetEntry,DimSetID);
      DimVal.GET(DimCode,DimValCode);

      TempDimSetEntry.VALIDATE("Dimension Code",DimVal."Dimension Code");
      TempDimSetEntry.VALIDATE("Dimension Value Code",DimValCode);
      TempDimSetEntry.VALIDATE("Dimension Value ID",DimVal."Dimension Value ID");
      TempDimSetEntry.INSERT(TRUE);

      NewDimSetID := DimMgt.GetDimensionSetID(TempDimSetEntry);
      TempDimSetEntry.DELETEALL;
      EXIT(NewDimSetID);

Example

The below example is extracted from the test automation codeunit 134000 to show one way of using this function.

      // [FEATURE] [Dimension] [Payment Discount]
      // [SCENARIO 376797] Sales payment journal with dimension applied to posted Invoice can be posted in case of Discount, "Payment Disc. Debit Acc." with default dimension with "Value Posting" = "Same Code"
      Initialize;

      // [GIVEN] Customer with "Payment Disc. Debit Acc." = "A"
      // [GIVEN] Default Dimension "D" with "Value Posting" = "Same Code" is set for G/L Account "A"
      CustomerNo := CreateCustomer;
      GLAccountNo := CreateCustPostingGrPmtDiscDebitAccNo(CustomerNo);
      CreateDefaultDimensionGLAccSameValue(DimensionValue,GLAccountNo);

      // [GIVEN] Posted Sales Invoice with Amount Including VAT = 10000 and possible Discount = 2%. No dimension is set.
      CreateAndPostGenJnlLine(
        GenJournalLine,WORKDATE,GenJournalLine."Document Type"::Invoice,LibraryRandom.RandIntInRange(1000,2000),CustomerNo,'');
      PaymentAmount := -GenJournalLine.Amount + GenJournalLine.Amount * GetPmtTermsDiscountPct / 100;

      // [GIVEN] Sales Journal with Payment Amount = 9800 and applied to posted Invoice. Dimension "D" is set.
      CreateGenJnlLineWithAppliesToDocNo(
        GenJournalLine,GenJournalLine."Account Type"::Customer,CustomerNo,GenJournalLine."Document No.");
      GenJournalLine.VALIDATE("Dimension Set ID",LibraryDimension.CreateDimSet(0,DimensionValue."Dimension Code",DimensionValue.Code));
      GenJournalLine.VALIDATE(Amount,PaymentAmount);
      GenJournalLine.MODIFY;

      // [WHEN] Post Sales Journal
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // [THEN] Posted G/L Entry with "G/L Account No." = "A" has Dimension "D"
      FindGLEntry(GLEntry,GenJournalLine."Document No.",GLAccountNo);
      Assert.AreEqual(GenJournalLine."Dimension Set ID",GLEntry."Dimension Set ID",GLEntry.FIELDCAPTION("Dimension Set ID"))
Member of Lib.Library - Dimension


CreateDimValueCombination@11 Method

The procedure CreateDimValueCombination is available in codeunit 131001.

Syntax

CreateDimValueCombination@11(
    VAR DimensionValueCombination@1000 : Record 351 DimensionValueCombination, //Reference parameter of type Record
    Dimension1Code@1001 : Code[20] Dimension1Code, //Input parameter of type Code
    Dimension2Code@1002 : Code[20] Dimension2Code, //Input parameter of type Code
    Dimension1ValueCode@1004 : Code[20] Dimension1ValueCode, //Input parameter of type Code
    Dimension2ValueCode@1003 : Code[20] Dimension2ValueCode //Input parameter of type Code
);

Parameters

DimensionValueCombination
Reference parameter of type Record
Dimension1Code
Input parameter of type Code
Dimension2Code
Input parameter of type Code
Dimension1ValueCode
Input parameter of type Code
Dimension2ValueCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Dimension, Value, Combination.

For a clarification about how this function works, refer to the code listed below.

      DimensionValueCombination.INIT;
      DimensionValueCombination.VALIDATE("Dimension 1 Code",Dimension1Code);
      DimensionValueCombination.VALIDATE("Dimension 1 Value Code",Dimension1ValueCode);
      DimensionValueCombination.VALIDATE("Dimension 2 Code",Dimension2Code);
      DimensionValueCombination.VALIDATE("Dimension 2 Value Code",Dimension2ValueCode);
      DimensionValueCombination.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134479 to show one way of using this function.

      // Test Dimension on Customer Ledger Entry after Posting General Journal with Limited Dimension Combination.

      // 1. Setup: Create Dimension, Dimension Value, Customer with Default Dimension, Dimension Combination for Combination
      // Restriction Limited and General Journal with Dimension.
      Initialize;
      CreateCustomerWithDimension(DefaultDimension);
      CreateDimensionCombination(DimensionCombination,DimensionValue,DefaultDimension."Dimension Code");
      UpdateCombinationRestriction(DimensionCombination,DimensionCombination."Combination Restriction"::Limited);
      LibraryDimension.CreateDimValueCombination(
        DimensionValueCombination,DefaultDimension."Dimension Code",DimensionValue."Dimension Code",
        DefaultDimension."Dimension Value Code",DimensionValue.Code);
      LibraryDimension.CreateDimensionValue(DimensionValue,DimensionValue."Dimension Code");
      CreateJournalLineWithDimension(GenJournalLine,DimensionValue,DefaultDimension."No.");
      DimensionSetID := GenJournalLine."Dimension Set ID";

      // 2. Exercise: Post the General Journal.
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // 3. Verify: Verify Dimension on Customer Ledger Entry.
      VerifyCustomerLedgerDimension(DefaultDimension."No.",DimensionSetID);
      VerifyDimensionSetEntry(DefaultDimension."Dimension Code",DefaultDimension."Dimension Value Code",DimensionSetID);
      VerifyDimensionSetEntry(DimensionValue."Dimension Code",DimensionValue.Code,DimensionSetID);
Member of Lib.Library - Dimension


CreateDimWithDimValue@22 Method

The procedure CreateDimWithDimValue is available in codeunit 131001.

Syntax

CreateDimWithDimValue@22(
    VAR DimensionValue@1000 : Record 349 DimensionValue //Reference parameter of type Record
);

Parameters

DimensionValue
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Dimensionension, Dimensionension, Value.

For a clarification about how this function works, refer to the code listed below.

      CreateDimension(Dimension);
      CreateDimensionValue(DimensionValue,Dimension.Code);

Example

The below example is extracted from the test automation codeunit 134000 to show one way of using this function.

      LibraryDimension.CreateDimWithDimValue(DimensionValue);
      LibraryDimension.CreateDefaultDimensionGLAcc(DefaultDimension,GLAccountNo,DimensionValue."Dimension Code",DimensionValue.Code);
      DefaultDimension.VALIDATE("Value Posting",DefaultDimension."Value Posting"::"Same Code");
      DefaultDimension.MODIFY;
Member of Lib.Library - Dimension


CreateICDimension@18 Method

The procedure CreateICDimension is available in codeunit 131001.

Syntax

CreateICDimension@18(
    VAR ICDimension@1002 : Record 411 ICDimension //Reference parameter of type Record
);

Parameters

ICDimension
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Inter-Company, Dimension.

For a clarification about how this function works, refer to the code listed below.

      ICDimension.INIT;
      ICDimension.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(ICDimension.FIELDNO(Code),DATABASE::"IC Dimension"),1,
          LibraryUtility.GetFieldLength(DATABASE::"IC Dimension",ICDimension.FIELDNO(Code))));
      ICDimension.INSERT(TRUE);

Example

There are no examples available.
Member of Lib.Library - Dimension


CreateICDimensionValue@17 Method

The procedure CreateICDimensionValue is available in codeunit 131001.

Syntax

CreateICDimensionValue@17(
    VAR ICDimensionValue@1002 : Record 412 ICDimensionValue, //Reference parameter of type Record
    ICDimensionCode@1001 : Code[20] ICDimensionCode //Input parameter of type Code
);

Parameters

ICDimensionValue
Reference parameter of type Record
ICDimensionCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Inter-Company, Dimension, Value.

For a clarification about how this function works, refer to the code listed below.

      ICDimensionValue.INIT;
      ICDimensionValue.VALIDATE("Dimension Code",ICDimensionCode);
      ICDimensionValue.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(ICDimensionValue.FIELDNO(Code),DATABASE::"IC Dimension Value"),1,
          LibraryUtility.GetFieldLength(DATABASE::"IC Dimension Value",ICDimensionValue.FIELDNO(Code))));
      ICDimensionValue.INSERT(TRUE);

Example

There are no examples available.
Member of Lib.Library - Dimension


CreateSelectedDimension@46 Method

The procedure CreateSelectedDimension is available in codeunit 131001.

Syntax

CreateSelectedDimension@46(
    VAR SelectedDimension@1000 : Record 369 SelectedDimension, //Reference parameter of type Record
    ObjectType@1001 : Option ObjectType, //Input parameter of type Option
    ObjectID@1002 : Integer ObjectID, //Input parameter of type Integer
    AnalysisViewCode@1003 : Code[10] AnalysisViewCode, //Input parameter of type Code
    DimensionCode@1004 : Text[30] DimensionCode //Input parameter of type Text
);

Parameters

SelectedDimension
Reference parameter of type Record
ObjectType
Input parameter of type Option
ObjectID
Input parameter of type Integer
AnalysisViewCode
Input parameter of type Code
DimensionCode
Input parameter of type Text

Remarks

The relevant search keywords are: Create, Selected, Dimension.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(SelectedDimension);
      SelectedDimension."User ID" := USERID;
      SelectedDimension.VALIDATE("Object Type",ObjectType);
      SelectedDimension.VALIDATE("Object ID",ObjectID);
      SelectedDimension.VALIDATE("Analysis View Code",AnalysisViewCode);
      SelectedDimension.VALIDATE("Dimension Code",DimensionCode);
      SelectedDimension.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134092 to show one way of using this function.

      LibraryDimension.CreateDimWithDimValue(DimensionValue);
      LibraryDimension.CreateDefaultDimension(DefaultDimension,
        DATABASE::"G/L Account",GLAccountCode,DimensionValue."Dimension Code",DimensionValue.Code);
      DefaultDimension.VALIDATE("Value Posting",DefaultDimension."Value Posting"::"Same Code");
      DefaultDimension.MODIFY(TRUE);
      LibraryDimension.CreateDimensionValue(DimensionValue,DefaultDimension."Dimension Code");
      DimSetID := CreateNewDimSetID(DimensionValue."Dimension Code",DimensionValue.Code);
      SelectedDimension.INIT;
      LibraryDimension.CreateSelectedDimension(SelectedDimension,3,
        REPORT::"Consolidation - Test Database",'',DefaultDimension."Dimension Code");
      DimensionSelectionBuffer.INIT;
      DimensionSelectionBuffer.Code := SelectedDimension."Dimension Code";
      DimensionSelectionBuffer.Selected := TRUE;
      DimensionSelectionBuffer.INSERT;
Member of Lib.Library - Dimension


CreateServiceContractDimension@4 Method

The procedure CreateServiceContractDimension is available in codeunit 131001.

Syntax

CreateServiceContractDimension@4(
    VAR ServiceContractHeader@1000 : Record 5965 ServiceContractHeader, //Reference parameter of type Record
    DimensionCode@1005 : Code[20] DimensionCode, //Input parameter of type Code
    DimensionValueCode@1006 : Code[20] DimensionValueCode //Input parameter of type Code
);

Parameters

ServiceContractHeader
Reference parameter of type Record
DimensionCode
Input parameter of type Code
DimensionValueCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Service, Contract, Dimension.

For a clarification about how this function works, refer to the code listed below.

      DimSetID := CreateDimSet(ServiceContractHeader."Dimension Set ID",DimensionCode,DimensionValueCode);
      ServiceContractHeader.VALIDATE("Dimension Set ID",DimSetID);
      ServiceContractHeader.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 136118 to show one way of using this function.

      LibraryService.CreateServiceContractHeader(ServiceContractHeader,ServiceContractHeader."Contract Type"::Contract,CustomerNo);

      CreateDimensionAndDimensionValue(Dimension,DimensionValue);

      LibraryDimension.CreateServiceContractDimension(ServiceContractHeader,Dimension.Code,DimensionValue.Code);

      LibraryService.CreateServiceItem(ServiceItem,CustomerNo);
      LibraryService.CreateServiceContractLine(ServiceContractLine,ServiceContractHeader,ServiceItem."No.");
      ServiceContractLine.VALIDATE("Line Value",RANDOM(100));  // Use Random because value is not important.
      ServiceContractLine.MODIFY(TRUE);
      UpdateServiceContract(ServiceContractHeader);
      UpdateServiceContractLineDate(ServiceContractLine,ServiceContractHeader);
      SignServContractDoc.SignContract(ServiceContractHeader);
      EXIT(ServiceContractHeader."Contract No.");
Member of Lib.Library - Dimension


DeleteDimSet@3 Method

The procedure DeleteDimSet is available in codeunit 131001.

Syntax

DeleteDimSet@3(
    DimSetID@1002 : Integer DimSetID, //Input parameter of type Integer
    DimCode@1000 : Code[20] DimCode //Input parameter of type Code
);

Parameters

DimSetID
Input parameter of type Integer
DimCode
Input parameter of type Code

Return Value

Integer

Remarks

The relevant search keywords are: Delete, Dimension, Set.

For a clarification about how this function works, refer to the code listed below.

      // Delete existing dimension and dimension value on document, document line and journal
      // DimSetID: existing dimension set ID on document, document line and journal
      // Return new Dimension Set ID.

      DimMgt.GetDimensionSet(TempDimSetEntry,DimSetID);

      TempDimSetEntry.SETRANGE("Dimension Code",DimCode);
      TempDimSetEntry.FINDFIRST;
      TempDimSetEntry.DELETE(TRUE);

      TempDimSetEntry.RESET;
      NewDimSetID := DimMgt.GetDimensionSetID(TempDimSetEntry);
      TempDimSetEntry.DELETEALL;
      EXIT(NewDimSetID);

Example

The below example is extracted from the test automation codeunit 134382 to show one way of using this function.

      Initialize;

      PrepareGeneralJournal(GenJournalBatch);
      ShortcutDimCode := FindShortcutDimension;
      ShortcutDimValueCode := FindDimensionValueCode(ShortcutDimCode);

      LibraryERM.CreateGeneralJnlLine(
        GenJournalLine,GenJournalBatch."Journal Template Name",GenJournalBatch.Name,GenJournalLine."Document Type"::Payment,
        GenJournalLine."Account Type"::Customer,CreateCustomer,-LibraryRandom.RandInt(1000));

      // Change shortcut dimension on the general journal line
      ShortcutDimValueCode := EvaluateShortcutDimCode(ShortcutDimCode,GenJournalLine."Shortcut Dimension 1 Code",ShortcutDimValueCode);
      GenJournalLine.VALIDATE("Shortcut Dimension 1 Code",ShortcutDimValueCode);
      GenJournalLine.MODIFY(TRUE);
      // Verify dimension on journal line dimension is updated
      DimensionSetID := GenJournalLine."Dimension Set ID";
      VerifyDimInJournalDimSet(ShortcutDimCode,ShortcutDimValueCode,DimensionSetID);

      // Change shortcut dimension on the general journal line dimension.
      DimensionSetID := LibraryDimension.DeleteDimSet(DimensionSetID,ShortcutDimCode);
      GenJournalLine.VALIDATE("Dimension Set ID",DimensionSetID);
      GenJournalLine.MODIFY(TRUE);
      GenJournalLine.ShowDimensions;
      // Verify shortcut dimension on the general journal is updated.
      ShortcutDimValueCode := GenJournalLine."Shortcut Dimension 1 Code";
      VerifyShortcutDim(ShortcutDimValueCode);
Member of Lib.Library - Dimension


EditDimSet@2 Method

The procedure EditDimSet is available in codeunit 131001.

Syntax

EditDimSet@2(
    DimSetID@1002 : Integer DimSetID, //Input parameter of type Integer
    DimCode@1000 : Code[20] DimCode, //Input parameter of type Code
    DimValCode@1001 : Code[20] DimValCode //Input parameter of type Code
);

Parameters

DimSetID
Input parameter of type Integer
DimCode
Input parameter of type Code
DimValCode
Input parameter of type Code

Return Value

Integer

Remarks

The relevant search keywords are: Edit, Dimension, Set.

For a clarification about how this function works, refer to the code listed below.

      // Edit existing dimension value for the given dimension on document, document line and journal
      // DimSetID: existing dimension set ID on document, document line and journal
      // Return new Dimension Set ID.

      DimMgt.GetDimensionSet(TempDimSetEntry,DimSetID);

      DimVal.GET(DimCode,DimValCode);
      TempDimSetEntry.SETRANGE("Dimension Code",DimVal."Dimension Code");
      TempDimSetEntry.FINDFIRST;
      TempDimSetEntry.VALIDATE("Dimension Value Code",DimVal.Code);
      TempDimSetEntry.VALIDATE("Dimension Value ID",DimVal."Dimension Value ID");
      TempDimSetEntry.MODIFY(TRUE);

      TempDimSetEntry.RESET;
      NewDimSetID := DimMgt.GetDimensionSetID(TempDimSetEntry);
      TempDimSetEntry.DELETEALL;
      EXIT(NewDimSetID);

Example

The below example is extracted from the test automation codeunit 134380 to show one way of using this function.

      // Test codeunit 408, function CheckDimValueposting.
      // Parameters: Same Code + specific account value posting
      // replace 140762,140765,140756,140759

      Initialize;
      ValPosting_Setup(GLAccount,Customer,DefaultDimension,GenJnlLine,DefaultDimension."Value Posting"::"Same Code");
      DimSetID := GenJnlLine."Dimension Set ID";
      NewDimSetID := LibraryDim.EditDimSet(DimSetID,TestDim,TestDimValue2);
      ModifyJnlDimSetID(GenJnlLine,NewDimSetID);
      // Necessary to be able to run possitive test after negative test.
      COMMIT;

      ErrorText := STRSUBSTNO(SameCodeError,JournalTemplate,JournalBatch,GenJnlLine."Line No.",TestDimValue,TestDim,Customer."No.");

      NegativeTest(GenJnlLine,ErrorText);
      PossitiveTest(GenJnlLine,DimSetID);
Member of Lib.Library - Dimension


FindDefaultDimension@219 Method

The procedure FindDefaultDimension is available in codeunit 131001.

Syntax

FindDefaultDimension@219(
    VAR DefaultDimension@1000 : Record 352 DefaultDimension, //Reference parameter of type Record
    TableID@1001 : Integer TableID, //Input parameter of type Integer
    No@1002 : Code[20] No //Input parameter of type Code
);

Parameters

DefaultDimension
Reference parameter of type Record
TableID
Input parameter of type Integer
No
Input parameter of type Code

Return Value

Boolean

Remarks

The relevant search keywords are: Find, Default, Dimension.

For a clarification about how this function works, refer to the code listed below.

      DefaultDimension.SETRANGE("Table ID",TableID);
      DefaultDimension.SETRANGE("No.",No);
      EXIT(DefaultDimension.FINDSET);

Example

The below example is extracted from the test automation codeunit 134475 to show one way of using this function.

      // Test error occurs on Posting Sales Invoice with Invalid Dimension On Sales Header.

      // 1. Setup: Create Customer with Default Dimension, Item, Sales Header and Update value of Dimension on Sales Header.
      Initialize;
      LibraryDimension.FindDimension(Dimension);
      CreateSalesOrder(
        SalesHeader,SalesLine,Dimension.Code,'',DefaultDimension."Value Posting"::"Same Code",SalesHeader."Document Type"::Invoice);
      UpdateDimensionOnSalesHeader(SalesHeader);
      LibraryDimension.FindDefaultDimension(DefaultDimension,DATABASE::Customer,SalesHeader."Sell-to Customer No.");

      // 2. Exercise: Post Sales Invoice.
      SalesHeader.GET(SalesHeader."Document Type",SalesHeader."No.");
      ASSERTERROR LibrarySales.PostSalesDocument(SalesHeader,FALSE,FALSE);

      // 3. Verify: Verify error occurs "Invalid Dimension" on Posting Sales Invoice.
      Assert.AreEqual(
        STRSUBSTNO(
          DimensionHeaderError,SalesHeader."Document Type",SalesHeader."No.",DefaultDimension.FIELDCAPTION("Dimension Value Code"),
          DefaultDimension."Dimension Value Code",DefaultDimension.FIELDCAPTION("Dimension Code"),DefaultDimension."Dimension Code",
          Customer.TABLECAPTION,DefaultDimension."No."),
        GETLASTERRORTEXT,UnknownError);
Member of Lib.Library - Dimension


FindDifferentDimensionValue@126 Method

The procedure FindDifferentDimensionValue is available in codeunit 131001.

Syntax

FindDifferentDimensionValue@126(
    DimensionCode@1001 : Code[20] DimensionCode, //Input parameter of type Code
    DimensionValueCode@1002 : Code[20] DimensionValueCode //Input parameter of type Code
);

Parameters

DimensionCode
Input parameter of type Code
DimensionValueCode
Input parameter of type Code

Return Value

Code[20]

Remarks

The relevant search keywords are: Find, Different, Dimension, Value.

For a clarification about how this function works, refer to the code listed below.

      DimensionValue.SETFILTER(Code,'<>%1',DimensionValueCode);
      FindDimensionValue(DimensionValue,DimensionCode);
      EXIT(DimensionValue.Code);

Example

The below example is extracted from the test automation codeunit 134076 to show one way of using this function.

      WITH GeneralLedgerSetup DO BEGIN
        GET;
        LibraryDimension.CreateDefaultDimension(
          DefaultDimension,DATABASE::Vendor,VendorNo,"Shortcut Dimension 1 Code",
          LibraryDimension.FindDifferentDimensionValue("Shortcut Dimension 1 Code",GlobalDimValueCode1));
        LibraryDimension.CreateDefaultDimension(
          DefaultDimension,DATABASE::Vendor,VendorNo,"Shortcut Dimension 2 Code",
          LibraryDimension.FindDifferentDimensionValue("Shortcut Dimension 2 Code",GlobalDimValueCode2));
      END;
Member of Lib.Library - Dimension


FindDimension@15 Method

The procedure FindDimension is available in codeunit 131001.

Syntax

FindDimension@15(
    VAR Dimension@1000 : Record 348 Dimension //Reference parameter of type Record
);

Parameters

Dimension
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Dimension.

For a clarification about how this function works, refer to the code listed below.

      Dimension.SETRANGE(Blocked,FALSE);
      Dimension.FINDSET;

Example

The below example is extracted from the test automation codeunit 134049 to show one way of using this function.

      LibraryDimension.FindDimension(Dimension);
      LibraryDimension.FindDimensionValue(DimensionValue,Dimension.Code);
Member of Lib.Library - Dimension


FindDimensionSetEntry@117 Method

The procedure FindDimensionSetEntry is available in codeunit 131001.

Syntax

FindDimensionSetEntry@117(
    VAR DimensionSetEntry@1000 : Record 480 DimensionSetEntry, //Reference parameter of type Record
    DimensionSetID@1001 : Integer DimensionSetID //Input parameter of type Integer
);

Parameters

DimensionSetEntry
Reference parameter of type Record
DimensionSetID
Input parameter of type Integer

Remarks

The relevant search keywords are: Find, Dimension, Set, Entry.

For a clarification about how this function works, refer to the code listed below.

      DimensionSetEntry.SETRANGE("Dimension Set ID",DimensionSetID);
      DimensionSetEntry.FINDSET;

Example

The below example is extracted from the test automation codeunit 134141 to show one way of using this function.

      DimensionSetEntry.SETRANGE("Dimension Code",ShortcutDimensionCode);
      LibraryDimension.FindDimensionSetEntry(DimensionSetEntry,DimensionSetID);
      EXIT(DimensionSetEntry."Dimension Value Code");
Member of Lib.Library - Dimension


FindDimensionValue@78 Method

The procedure FindDimensionValue is available in codeunit 131001.

Syntax

FindDimensionValue@78(
    VAR DimensionValue@1000 : Record 349 DimensionValue, //Reference parameter of type Record
    DimensionCode@1001 : Code[20] DimensionCode //Input parameter of type Code
);

Parameters

DimensionValue
Reference parameter of type Record
DimensionCode
Input parameter of type Code

Remarks

The relevant search keywords are: Find, Dimension, Value.

For a clarification about how this function works, refer to the code listed below.

      DimensionValue.SETRANGE("Dimension Code",DimensionCode);
      DimensionValue.SETRANGE(Blocked,FALSE);
      DimensionValue.SETRANGE("Dimension Value Type",DimensionValue."Dimension Value Type"::Standard);
      DimensionValue.FINDSET;

Example

The below example is extracted from the test automation codeunit 134049 to show one way of using this function.

      LibraryDimension.FindDimension(Dimension);
      LibraryDimension.FindDimensionValue(DimensionValue,Dimension.Code);
Member of Lib.Library - Dimension


GetNextDimensionValue@20 Method

The procedure GetNextDimensionValue is available in codeunit 131001.

Syntax

GetNextDimensionValue@20(
    VAR DimensionValue@1000 : Record 349 DimensionValue //Reference parameter of type Record
);

Parameters

DimensionValue
Reference parameter of type Record

Remarks

The relevant search keywords are: Get, Next, Dimension, Value.

For a clarification about how this function works, refer to the code listed below.

      DimensionValue.NEXT;

Example

There are no examples available.
Member of Lib.Library - Dimension


ResetDefaultDimensions@166 Method

The procedure ResetDefaultDimensions is available in codeunit 131001.

Syntax

ResetDefaultDimensions@166(
    TableID@1000 : Integer TableID, //Input parameter of type Integer
    No@1001 : Code[20] No //Input parameter of type Code
);

Parameters

TableID
Input parameter of type Integer
No
Input parameter of type Code

Remarks

The relevant search keywords are: Reset, Default, Dimensions.

For a clarification about how this function works, refer to the code listed below.

      DefaultDimension.SETRANGE("Table ID",TableID);
      DefaultDimension.SETRANGE("No.",No);
      DefaultDimension.DELETEALL;

Example

The below example is extracted from the test automation codeunit 134902 to show one way of using this function.

      LibraryDimension.ResetDefaultDimensions(DATABASE::"G/L Account",GLAccountNo);
      LibraryDimension.CreateDimensionValue(DimensionValue,LibraryERM.GetGlobalDimensionCode(1));
      LibraryDimension.CreateDefaultDimensionGLAcc(
        DefaultDimension,GLAccountNo,LibraryERM.GetGlobalDimensionCode(1),DimensionValue.Code);
      EXIT(DimensionValue.Code);
Member of Lib.Library - Dimension


Library - Document Approvals Class

Lib.Library - Document Approvals

COD131352 applies to ERM,W1,All.

Methods

Name | Description
CreateMockupUserSetup@6 | The procedure CreateMockupUserSetup is available in codeunit 131352.
CreateNonWindowsUser@8 | The procedure CreateNonWindowsUser is available in codeunit 131352.
CreateOrFindUserSetup@46 | The procedure CreateOrFindUserSetup is available in codeunit 131352.
CreateUser@26 | The procedure CreateUser is available in codeunit 131352.
CreateUserSetup@57 | The procedure CreateUserSetup is available in codeunit 131352.
CreateUserSetupsAndGroupOfApproversForWorkflow@17 | The procedure CreateUserSetupsAndGroupOfApproversForWorkflow is available in codeunit 131352.
CreateWorkflowUserGroupMember@19 | The procedure CreateWorkflowUserGroupMember is available in codeunit 131352.
DeleteUserSetup@12 | The procedure DeleteUserSetup is available in codeunit 131352.
GetApprovalEntries@53 | The procedure GetApprovalEntries is available in codeunit 131352.
GetNonWindowsUser@9 | The procedure GetNonWindowsUser is available in codeunit 131352.
GetPostedApprovalComments@14 | The procedure GetPostedApprovalComments is available in codeunit 131352.
GetPostedApprovalEntries@13 | The procedure GetPostedApprovalEntries is available in codeunit 131352.
GetUser@10 | The procedure GetUser is available in codeunit 131352.
GetUserSetup@7 | The procedure GetUserSetup is available in codeunit 131352.
SetApprover@45 | The procedure SetApprover is available in codeunit 131352.
SetSubstitute@34 | The procedure SetSubstitute is available in codeunit 131352.
SetupUsersForApprovals@18 | The procedure SetupUsersForApprovals is available in codeunit 131352.
SetupUsersForApprovalsWithLimits@42 | The procedure SetupUsersForApprovalsWithLimits is available in codeunit 131352.
SetupUserWithApprover@16 | The procedure SetupUserWithApprover is available in codeunit 131352.
SetWorkflowApproverType@20 | The procedure SetWorkflowApproverType is available in codeunit 131352.
UpdateApprovalEntryWithCurrUser@65 | The procedure UpdateApprovalEntryWithCurrUser is available in codeunit 131352.
UpdateApprovalLimits@2 | The procedure UpdateApprovalLimits is available in codeunit 131352.
UserExists@1 | The procedure UserExists is available in codeunit 131352.
UserSetupExists@3 | The procedure UserSetupExists is available in codeunit 131352.

See Also

Lib


CreateMockupUserSetup@6 Method

The procedure CreateMockupUserSetup is available in codeunit 131352.

Syntax

CreateMockupUserSetup@6(
    VAR UserSetup@1000 : Record 91 UserSetup //Reference parameter of type Record
);

Parameters

UserSetup
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Mockup, User, Setup.

For a clarification about how this function works, refer to the code listed below.

      LibrarySales.CreateSalesperson(SalespersonPurchaser);
      UserSetup."Salespers./Purch. Code" := SalespersonPurchaser.Code;
      UserSetup."User ID" :=
        COPYSTR(LibraryUtility.GenerateRandomCode(User.FIELDNO("User Name"),DATABASE::User),
          1,LibraryUtility.GetFieldLength(DATABASE::User,User.FIELDNO("User Name")));
      UserSetup."Approver ID" := '';
      UserSetup."Unlimited Sales Approval" := TRUE;
      UserSetup."Unlimited Purchase Approval" := TRUE;
      UserSetup."Unlimited Request Approval" := TRUE;
      UserSetup."Sales Amount Approval Limit" := 0;
      UserSetup."Purchase Amount Approval Limit" := 0;
      UserSetup."Request Amount Approval Limit" := 0;
      UserSetup."E-Mail" := 'someone@example.com';
      UserSetup.INSERT;

Example

The below example is extracted from the test automation codeunit 134170 to show one way of using this function.

      // [SCENARIO] This test that an user cannot post a Sales Invoice after it was sent for approval.
      // [GIVEN] Sales Invoice Approval Workflow that has Approver code as the approver and Direct Approver as the limit type.
      // [WHEN] Sales Invoice is sent for approval.
      // [THEN] Approval Request is created for the Approver.
      // [WHEN] The user wants to post the Sales Invoice.
      // [THEN] An error is showned to the user and the Sales Invoice is not posted.

      Initialize;

      LibraryWorkflow.CopyWorkflowTemplate(Workflow,WorkflowSetup.SalesInvoiceApprovalWorkflowCode);
      WorkflowStep.SETRANGE("Function Name",WorkflowResponseHandling.CreateApprovalRequestsCode);
      WorkflowStep.SETRANGE("Workflow Code",Workflow.Code);
      IF WorkflowStep.FINDFIRST THEN BEGIN
        WorkflowStepArgument.GET(WorkflowStep.Argument);
        WorkflowStepArgument."Approver Limit Type" := WorkflowStepArgument."Approver Limit Type"::"Direct Approver";
        WorkflowStepArgument.MODIFY(TRUE);
      END;

      LibraryWorkflow.EnableWorkflow(Workflow);

      // Setup - Create 2 usersetups
      LibraryDocumentApprovals.CreateOrFindUserSetup(CurrentUserSetup,USERID);
      LibraryDocumentApprovals.CreateMockupUserSetup(ApproverUserSetup);

      // Setup - Direct approver
      LibraryDocumentApprovals.SetApprover(CurrentUserSetup,ApproverUserSetup);

      // Setup - Create Sales invoice
      CreateSalesInvWithLine(SalesHeader,LibraryRandom.RandInt(5000));

      // Setup - Update Salesperson Code
      SetSalesDocSalespersonCode(SalesHeader,ApproverUserSetup."Salespers./Purch. Code");

      // Excercise - Open Sales invoice card and sent it for approval
      SendSalesInvoiceForApproval(SalesHeader);

      // Verify - Sales invoice status is set to Pending Approval
      VerifySalesInvIsPendingApproval(SalesHeader);

      // Verify - Approval requests and their data
      LibraryDocumentApprovals.GetApprovalEntries(ApprovalEntry,SalesHeader.RECORDID);
      Assert.AreEqual(1,ApprovalEntry.COUNT,UnexpectedNoOfApprovalEntriesErr);

      VerifyApprovalEntryIsOpen(ApprovalEntry);
      VerifyApprovalEntrySenderID(ApprovalEntry,CurrentUserSetup."User ID");
      VerifyApprovalEntryApproverID(ApprovalEntry,ApproverUserSetup."User ID");

      // Exercise - Try to post the Sales Document
      COMMIT;
      ASSERTERROR PostSalesInvoice(SalesHeader);

      // Verify - Sales Document cannot be posted
      Assert.ExpectedError(STRSUBSTNO(PostRestrictionErr,FORMAT(SalesHeader.RECORDID,0,1)));
Member of Lib.Library - Document Approvals


CreateNonWindowsUser@8 Method

The procedure CreateNonWindowsUser is available in codeunit 131352.

Syntax

CreateNonWindowsUser@8(
    UserName@1001 : Code[50] UserName //Input parameter of type Code
);

Parameters

UserName
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Non, Windows, User.

For a clarification about how this function works, refer to the code listed below.

      UserCard.OPENNEW;
      UserCard."User Name".SETVALUE(UserName);
      UserCard.Permissions.NEW;
      UserCard.Permissions."<Permission Set>".SETVALUE('SUPER');
      UserCard.OK.INVOKE;

Example

There are no examples available.
Member of Lib.Library - Document Approvals


CreateOrFindUserSetup@46 Method

The procedure CreateOrFindUserSetup is available in codeunit 131352.

Syntax

CreateOrFindUserSetup@46(
    VAR UserSetup@1000 : Record 91 UserSetup, //Reference parameter of type Record
    UserName@1001 : Text[208] UserName //Input parameter of type Text
);

Parameters

UserSetup
Reference parameter of type Record
UserName
Input parameter of type Text

Remarks

The relevant search keywords are: Create, Or, Find, User, Setup.

For a clarification about how this function works, refer to the code listed below.

      IF NOT GetUserSetup(UserSetup,COPYSTR(UserName,1,50)) THEN
        CreateUserSetup(UserSetup,COPYSTR(UserName,1,50),'');

Example

The below example is extracted from the test automation codeunit 134170 to show one way of using this function.

      // [SCENARIO] This test that an user cannot post a Sales Invoice after it was sent for approval.
      // [GIVEN] Sales Invoice Approval Workflow that has Approver code as the approver and Direct Approver as the limit type.
      // [WHEN] Sales Invoice is sent for approval.
      // [THEN] Approval Request is created for the Approver.
      // [WHEN] The user wants to post the Sales Invoice.
      // [THEN] An error is showned to the user and the Sales Invoice is not posted.

      Initialize;

      LibraryWorkflow.CopyWorkflowTemplate(Workflow,WorkflowSetup.SalesInvoiceApprovalWorkflowCode);
      WorkflowStep.SETRANGE("Function Name",WorkflowResponseHandling.CreateApprovalRequestsCode);
      WorkflowStep.SETRANGE("Workflow Code",Workflow.Code);
      IF WorkflowStep.FINDFIRST THEN BEGIN
        WorkflowStepArgument.GET(WorkflowStep.Argument);
        WorkflowStepArgument."Approver Limit Type" := WorkflowStepArgument."Approver Limit Type"::"Direct Approver";
        WorkflowStepArgument.MODIFY(TRUE);
      END;

      LibraryWorkflow.EnableWorkflow(Workflow);

      // Setup - Create 2 usersetups
      LibraryDocumentApprovals.CreateOrFindUserSetup(CurrentUserSetup,USERID);
      LibraryDocumentApprovals.CreateMockupUserSetup(ApproverUserSetup);

      // Setup - Direct approver
      LibraryDocumentApprovals.SetApprover(CurrentUserSetup,ApproverUserSetup);

      // Setup - Create Sales invoice
      CreateSalesInvWithLine(SalesHeader,LibraryRandom.RandInt(5000));

      // Setup - Update Salesperson Code
      SetSalesDocSalespersonCode(SalesHeader,ApproverUserSetup."Salespers./Purch. Code");

      // Excercise - Open Sales invoice card and sent it for approval
      SendSalesInvoiceForApproval(SalesHeader);

      // Verify - Sales invoice status is set to Pending Approval
      VerifySalesInvIsPendingApproval(SalesHeader);

      // Verify - Approval requests and their data
      LibraryDocumentApprovals.GetApprovalEntries(ApprovalEntry,SalesHeader.RECORDID);
      Assert.AreEqual(1,ApprovalEntry.COUNT,UnexpectedNoOfApprovalEntriesErr);

      VerifyApprovalEntryIsOpen(ApprovalEntry);
      VerifyApprovalEntrySenderID(ApprovalEntry,CurrentUserSetup."User ID");
      VerifyApprovalEntryApproverID(ApprovalEntry,ApproverUserSetup."User ID");

      // Exercise - Try to post the Sales Document
      COMMIT;
      ASSERTERROR PostSalesInvoice(SalesHeader);

      // Verify - Sales Document cannot be posted
      Assert.ExpectedError(STRSUBSTNO(PostRestrictionErr,FORMAT(SalesHeader.RECORDID,0,1)));
Member of Lib.Library - Document Approvals


CreateUser@26 Method

The procedure CreateUser is available in codeunit 131352.

Syntax

CreateUser@26(
    UserName@1001 : Code[50] UserName, //Input parameter of type Code
    WindowsUserName@1003 : Text[208] WindowsUserName //Input parameter of type Text
);

Parameters

UserName
Input parameter of type Code
WindowsUserName
Input parameter of type Text

Remarks

The relevant search keywords are: Create, User.

For a clarification about how this function works, refer to the code listed below.

      UserCard.OPENNEW;
      UserCard."User Name".SETVALUE(UserName);
      UserCard."Windows User Name".SETVALUE(WindowsUserName);
      UserCard.Permissions.NEW;
      UserCard.Permissions."<Permission Set>".SETVALUE('SUPER');
      UserCard.OK.INVOKE;

Example

There are no examples available.
Member of Lib.Library - Document Approvals


CreateUserSetup@57 Method

The procedure CreateUserSetup is available in codeunit 131352.

Syntax

CreateUserSetup@57(
    VAR UserSetup@1000 : Record 91 UserSetup, //Reference parameter of type Record
    UserID@1001 : Code[50] UserID, //Input parameter of type Code
    ApproverID@1002 : Code[50] ApproverID //Input parameter of type Code
);

Parameters

UserSetup
Reference parameter of type Record
UserID
Input parameter of type Code
ApproverID
Input parameter of type Code

Remarks

The relevant search keywords are: Create, User, Setup.

For a clarification about how this function works, refer to the code listed below.

      LibrarySales.CreateSalesperson(SalespersonPurchaser);
      UserSetup.VALIDATE("Salespers./Purch. Code",SalespersonPurchaser.Code);
      UserSetup."User ID" := UserID;
      UserSetup."Approver ID" := ApproverID;
      UserSetup.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134186 to show one way of using this function.

      IF NOT LibraryDocumentApprovals.GetUserSetup(UserSetup,COPYSTR(UserName,1,50)) THEN
        LibraryDocumentApprovals.CreateUserSetup(UserSetup,COPYSTR(UserName,1,50),'');
Member of Lib.Library - Document Approvals


CreateUserSetupsAndGroupOfApproversForWorkflow@17 Method

The procedure CreateUserSetupsAndGroupOfApproversForWorkflow is available in codeunit 131352.

Syntax

CreateUserSetupsAndGroupOfApproversForWorkflow@17(
    Workflow@1008 : Record 1501 Workflow, //Input parameter of type Record
    VAR CurrentUserSetup@1002 : Record 91 CurrentUserSetup, //Reference parameter of type Record
    VAR IntermediateApproverUserSetup@1001 : Record 91 IntermediateApproverUserSetup, //Reference parameter of type Record
    VAR FinalApproverUserSetup@1000 : Record 91 FinalApproverUserSetup //Reference parameter of type Record
);

Parameters

Workflow
Input parameter of type Record
CurrentUserSetup
Reference parameter of type Record
IntermediateApproverUserSetup
Reference parameter of type Record
FinalApproverUserSetup
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, User, Setups, Group, Of, Approvers, For, Workflow.

For a clarification about how this function works, refer to the code listed below.

      CreateOrFindUserSetup(CurrentUserSetup,USERID);
      CreateMockupUserSetup(IntermediateApproverUserSetup);
      CreateMockupUserSetup(FinalApproverUserSetup);

      WorkflowUserGroup.Code := LibraryUtility.GenerateRandomCode(WorkflowUserGroup.FIELDNO(Code),DATABASE::"Workflow User Group");
      WorkflowUserGroup.Description := COPYSTR(LibraryUtility.GenerateRandomText(50),1,50);
      WorkflowUserGroup.INSERT(TRUE);

      CreateWorkflowUserGroupMember(WorkflowUserGroup.Code,CurrentUserSetup."User ID");
      CreateWorkflowUserGroupMember(WorkflowUserGroup.Code,IntermediateApproverUserSetup."User ID");
      CreateWorkflowUserGroupMember(WorkflowUserGroup.Code,FinalApproverUserSetup."User ID");

      WorkflowStep.SETRANGE("Workflow Code",Workflow.Code);
      WorkflowStep.SETRANGE("Function Name",WorkflowResponseHandling.CreateApprovalRequestsCode);
      WorkflowStep.FINDFIRST;

      WorkflowStepArgument.GET(WorkflowStep.Argument);
      WorkflowStepArgument."Workflow User Group Code" := WorkflowUserGroup.Code;
      WorkflowStepArgument.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - Document Approvals


CreateWorkflowUserGroupMember@19 Method

The procedure CreateWorkflowUserGroupMember is available in codeunit 131352.

Syntax

CreateWorkflowUserGroupMember@19(
    WorkflowUserGroupCode@1000 : Code[20] WorkflowUserGroupCode, //Input parameter of type Code
    UserID@1002 : Code[50] UserID //Input parameter of type Code
);

Parameters

WorkflowUserGroupCode
Input parameter of type Code
UserID
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Workflow, User, Group, Member.

For a clarification about how this function works, refer to the code listed below.

      WorkflowUserGroupMember.SETRANGE("Workflow User Group Code",WorkflowUserGroupCode);
      IF WorkflowUserGroupMember.FINDLAST THEN;

      SeqNo := WorkflowUserGroupMember."Sequence No.";

      WorkflowUserGroupMember."Workflow User Group Code" := WorkflowUserGroupCode;
      WorkflowUserGroupMember."User Name" := UserID;
      WorkflowUserGroupMember."Sequence No." := SeqNo + 1;
      WorkflowUserGroupMember.INSERT(TRUE);

Example

There are no examples available.
Member of Lib.Library - Document Approvals


DeleteUserSetup@12 Method

The procedure DeleteUserSetup is available in codeunit 131352.

Syntax

DeleteUserSetup@12(
    VAR UserSetup@1001 : Record 91 UserSetup, //Reference parameter of type Record
    WindowsUserName@1002 : Text[208] WindowsUserName //Input parameter of type Text
);

Parameters

UserSetup
Reference parameter of type Record
WindowsUserName
Input parameter of type Text

Remarks

The relevant search keywords are: Delete, User, Setup.

For a clarification about how this function works, refer to the code listed below.

      GetUser(User,WindowsUserName);
      UserSetup.SETRANGE("User ID",User."User Name");
      UserSetup.DELETEALL;

Example

There are no examples available.
Member of Lib.Library - Document Approvals


GetApprovalEntries@53 Method

The procedure GetApprovalEntries is available in codeunit 131352.

Syntax

GetApprovalEntries@53(
    VAR ApprovalEntry@1003 : Record 454 ApprovalEntry, //Reference parameter of type Record
    RecordID@1000 : RecordID RecordID //Input parameter of type RecordID
);

Parameters

ApprovalEntry
Reference parameter of type Record
RecordID
Input parameter of type RecordID

Remarks

The relevant search keywords are: Get, Approval, Entries.

For a clarification about how this function works, refer to the code listed below.

      ApprovalEntry.SETRANGE("Record ID to Approve",RecordID);
      ApprovalEntry.FINDSET;

Example

The below example is extracted from the test automation codeunit 134170 to show one way of using this function.

      // [SCENARIO] This test that an user cannot post a Sales Invoice after it was sent for approval.
      // [GIVEN] Sales Invoice Approval Workflow that has Approver code as the approver and Direct Approver as the limit type.
      // [WHEN] Sales Invoice is sent for approval.
      // [THEN] Approval Request is created for the Approver.
      // [WHEN] The user wants to post the Sales Invoice.
      // [THEN] An error is showned to the user and the Sales Invoice is not posted.

      Initialize;

      LibraryWorkflow.CopyWorkflowTemplate(Workflow,WorkflowSetup.SalesInvoiceApprovalWorkflowCode);
      WorkflowStep.SETRANGE("Function Name",WorkflowResponseHandling.CreateApprovalRequestsCode);
      WorkflowStep.SETRANGE("Workflow Code",Workflow.Code);
      IF WorkflowStep.FINDFIRST THEN BEGIN
        WorkflowStepArgument.GET(WorkflowStep.Argument);
        WorkflowStepArgument."Approver Limit Type" := WorkflowStepArgument."Approver Limit Type"::"Direct Approver";
        WorkflowStepArgument.MODIFY(TRUE);
      END;

      LibraryWorkflow.EnableWorkflow(Workflow);

      // Setup - Create 2 usersetups
      LibraryDocumentApprovals.CreateOrFindUserSetup(CurrentUserSetup,USERID);
      LibraryDocumentApprovals.CreateMockupUserSetup(ApproverUserSetup);

      // Setup - Direct approver
      LibraryDocumentApprovals.SetApprover(CurrentUserSetup,ApproverUserSetup);

      // Setup - Create Sales invoice
      CreateSalesInvWithLine(SalesHeader,LibraryRandom.RandInt(5000));

      // Setup - Update Salesperson Code
      SetSalesDocSalespersonCode(SalesHeader,ApproverUserSetup."Salespers./Purch. Code");

      // Excercise - Open Sales invoice card and sent it for approval
      SendSalesInvoiceForApproval(SalesHeader);

      // Verify - Sales invoice status is set to Pending Approval
      VerifySalesInvIsPendingApproval(SalesHeader);

      // Verify - Approval requests and their data
      LibraryDocumentApprovals.GetApprovalEntries(ApprovalEntry,SalesHeader.RECORDID);
      Assert.AreEqual(1,ApprovalEntry.COUNT,UnexpectedNoOfApprovalEntriesErr);

      VerifyApprovalEntryIsOpen(ApprovalEntry);
      VerifyApprovalEntrySenderID(ApprovalEntry,CurrentUserSetup."User ID");
      VerifyApprovalEntryApproverID(ApprovalEntry,ApproverUserSetup."User ID");

      // Exercise - Try to post the Sales Document
      COMMIT;
      ASSERTERROR PostSalesInvoice(SalesHeader);

      // Verify - Sales Document cannot be posted
      Assert.ExpectedError(STRSUBSTNO(PostRestrictionErr,FORMAT(SalesHeader.RECORDID,0,1)));
Member of Lib.Library - Document Approvals


GetNonWindowsUser@9 Method

The procedure GetNonWindowsUser is available in codeunit 131352.

Syntax

GetNonWindowsUser@9(
    VAR User@1000 : Record 2000000120 User, //Reference parameter of type Record
    UserName@1001 : Text[208] UserName //Input parameter of type Text
);

Parameters

User
Reference parameter of type Record
UserName
Input parameter of type Text

Return Value

Boolean

Remarks

The relevant search keywords are: Get, Non, Windows, User.

For a clarification about how this function works, refer to the code listed below.

      User.SETRANGE("User Name",UserName);
      EXIT(User.FINDSET);

Example

There are no examples available.
Member of Lib.Library - Document Approvals


GetPostedApprovalComments@14 Method

The procedure GetPostedApprovalComments is available in codeunit 131352.

Syntax

GetPostedApprovalComments@14(
    VAR PostedApprovalCommentLine@1003 : Record 457 PostedApprovalCommentLine, //Reference parameter of type Record
    RecordID@1000 : RecordID RecordID //Input parameter of type RecordID
);

Parameters

PostedApprovalCommentLine
Reference parameter of type Record
RecordID
Input parameter of type RecordID

Remarks

The relevant search keywords are: Get, Posted, Approval, Comments.

For a clarification about how this function works, refer to the code listed below.

      PostedApprovalCommentLine.SETRANGE("Posted Record ID",RecordID);
      PostedApprovalCommentLine.FINDSET;

Example

There are no examples available.
Member of Lib.Library - Document Approvals


GetPostedApprovalEntries@13 Method

The procedure GetPostedApprovalEntries is available in codeunit 131352.

Syntax

GetPostedApprovalEntries@13(
    VAR PostedApprovalEntry@1003 : Record 456 PostedApprovalEntry, //Reference parameter of type Record
    RecordID@1000 : RecordID RecordID //Input parameter of type RecordID
);

Parameters

PostedApprovalEntry
Reference parameter of type Record
RecordID
Input parameter of type RecordID

Remarks

The relevant search keywords are: Get, Posted, Approval, Entries.

For a clarification about how this function works, refer to the code listed below.

      PostedApprovalEntry.SETRANGE("Posted Record ID",RecordID);
      PostedApprovalEntry.FINDSET;

Example

There are no examples available.
Member of Lib.Library - Document Approvals


GetUser@10 Method

The procedure GetUser is available in codeunit 131352.

Syntax

GetUser@10(
    VAR User@1000 : Record 2000000120 User, //Reference parameter of type Record
    WindowsUserName@1001 : Text[208] WindowsUserName //Input parameter of type Text
);

Parameters

User
Reference parameter of type Record
WindowsUserName
Input parameter of type Text

Return Value

Boolean

Remarks

The relevant search keywords are: Get, User.

For a clarification about how this function works, refer to the code listed below.

      User.SETRANGE("Windows Security ID",SID(WindowsUserName));
      EXIT(User.FINDFIRST);

Example

There are no examples available.
Member of Lib.Library - Document Approvals


GetUserSetup@7 Method

The procedure GetUserSetup is available in codeunit 131352.

Syntax

GetUserSetup@7(
    VAR UserSetup@1001 : Record 91 UserSetup, //Reference parameter of type Record
    WindowsUserName@1002 : Text[208] WindowsUserName //Input parameter of type Text
);

Parameters

UserSetup
Reference parameter of type Record
WindowsUserName
Input parameter of type Text

Return Value

Boolean

Remarks

The relevant search keywords are: Get, User, Setup.

For a clarification about how this function works, refer to the code listed below.

      IF GetUser(User,WindowsUserName) THEN
        UserSetup.SETRANGE("User ID",User."User Name")
      ELSE
        UserSetup.SETRANGE("User ID",WindowsUserName);
      EXIT(UserSetup.FINDFIRST);

Example

The below example is extracted from the test automation codeunit 134186 to show one way of using this function.

      IF NOT LibraryDocumentApprovals.GetUserSetup(UserSetup,COPYSTR(UserName,1,50)) THEN
        LibraryDocumentApprovals.CreateUserSetup(UserSetup,COPYSTR(UserName,1,50),'');
Member of Lib.Library - Document Approvals


SetApprover@45 Method

The procedure SetApprover is available in codeunit 131352.

Syntax

SetApprover@45(
    VAR UserSetup@1000 : Record 91 UserSetup, //Reference parameter of type Record
    ApproverUserSetup@1001 : Record 91 ApproverUserSetup //Input parameter of type Record
);

Parameters

UserSetup
Reference parameter of type Record
ApproverUserSetup
Input parameter of type Record

Remarks

The relevant search keywords are: Set, Approver.

For a clarification about how this function works, refer to the code listed below.

      UserSetup."Approver ID" := ApproverUserSetup."User ID";
      UserSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134170 to show one way of using this function.

      // [SCENARIO] This test that an user cannot post a Sales Invoice after it was sent for approval.
      // [GIVEN] Sales Invoice Approval Workflow that has Approver code as the approver and Direct Approver as the limit type.
      // [WHEN] Sales Invoice is sent for approval.
      // [THEN] Approval Request is created for the Approver.
      // [WHEN] The user wants to post the Sales Invoice.
      // [THEN] An error is showned to the user and the Sales Invoice is not posted.

      Initialize;

      LibraryWorkflow.CopyWorkflowTemplate(Workflow,WorkflowSetup.SalesInvoiceApprovalWorkflowCode);
      WorkflowStep.SETRANGE("Function Name",WorkflowResponseHandling.CreateApprovalRequestsCode);
      WorkflowStep.SETRANGE("Workflow Code",Workflow.Code);
      IF WorkflowStep.FINDFIRST THEN BEGIN
        WorkflowStepArgument.GET(WorkflowStep.Argument);
        WorkflowStepArgument."Approver Limit Type" := WorkflowStepArgument."Approver Limit Type"::"Direct Approver";
        WorkflowStepArgument.MODIFY(TRUE);
      END;

      LibraryWorkflow.EnableWorkflow(Workflow);

      // Setup - Create 2 usersetups
      LibraryDocumentApprovals.CreateOrFindUserSetup(CurrentUserSetup,USERID);
      LibraryDocumentApprovals.CreateMockupUserSetup(ApproverUserSetup);

      // Setup - Direct approver
      LibraryDocumentApprovals.SetApprover(CurrentUserSetup,ApproverUserSetup);

      // Setup - Create Sales invoice
      CreateSalesInvWithLine(SalesHeader,LibraryRandom.RandInt(5000));

      // Setup - Update Salesperson Code
      SetSalesDocSalespersonCode(SalesHeader,ApproverUserSetup."Salespers./Purch. Code");

      // Excercise - Open Sales invoice card and sent it for approval
      SendSalesInvoiceForApproval(SalesHeader);

      // Verify - Sales invoice status is set to Pending Approval
      VerifySalesInvIsPendingApproval(SalesHeader);

      // Verify - Approval requests and their data
      LibraryDocumentApprovals.GetApprovalEntries(ApprovalEntry,SalesHeader.RECORDID);
      Assert.AreEqual(1,ApprovalEntry.COUNT,UnexpectedNoOfApprovalEntriesErr);

      VerifyApprovalEntryIsOpen(ApprovalEntry);
      VerifyApprovalEntrySenderID(ApprovalEntry,CurrentUserSetup."User ID");
      VerifyApprovalEntryApproverID(ApprovalEntry,ApproverUserSetup."User ID");

      // Exercise - Try to post the Sales Document
      COMMIT;
      ASSERTERROR PostSalesInvoice(SalesHeader);

      // Verify - Sales Document cannot be posted
      Assert.ExpectedError(STRSUBSTNO(PostRestrictionErr,FORMAT(SalesHeader.RECORDID,0,1)));
Member of Lib.Library - Document Approvals


SetSubstitute@34 Method

The procedure SetSubstitute is available in codeunit 131352.

Syntax

SetSubstitute@34(
    VAR UserSetup@1000 : Record 91 UserSetup, //Reference parameter of type Record
    VAR SubstituteUserSetup@1001 : Record 91 SubstituteUserSetup //Reference parameter of type Record
);

Parameters

UserSetup
Reference parameter of type Record
SubstituteUserSetup
Reference parameter of type Record

Remarks

The relevant search keywords are: Set, Substitute.

For a clarification about how this function works, refer to the code listed below.

      UserSetup.Substitute := SubstituteUserSetup."User ID";
      UserSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134170 to show one way of using this function.

      // [SCENARIO] This test verifies E2E scenario for the Sales invoice approval workflow on delegation path.
      // [GIVEN] Sales Invoice Approval Workflow that has Salesperson as the approver and No Limit as the limit type.
      // [WHEN] Sales Invoice is sent for approval.
      // [THEN] Approval Request is created for the Salesperson.
      // [WHEN] Salesperson delegates the approval request.
      // [THEN] Approval request is assigned to the substitute.
      // [WHEN] Approval Request is approved.
      // [THEN] Sales Invoice is released.

      Initialize;

      LibraryWorkflow.CreateEnabledWorkflow(Workflow,WorkflowSetup.SalesInvoiceApprovalWorkflowCode);

      // Setup - Create 3 usersetups
      LibraryDocumentApprovals.CreateOrFindUserSetup(CurrentUserSetup,USERID);
      LibraryDocumentApprovals.CreateMockupUserSetup(IntermediateApproverUserSetup);
      LibraryDocumentApprovals.CreateMockupUserSetup(FinalApproverUserSetup);

      // Setup - Chain of approvers
      LibraryDocumentApprovals.SetApprover(CurrentUserSetup,IntermediateApproverUserSetup);
      LibraryDocumentApprovals.SetApprover(IntermediateApproverUserSetup,FinalApproverUserSetup);
      LibraryDocumentApprovals.SetSubstitute(CurrentUserSetup,FinalApproverUserSetup);

      // Setup - Create Sales invoice
      CreateSalesInvWithLine(SalesHeader,LibraryRandom.RandInt(5000));

      // Setup - Update Salesperson Code
      SetSalesDocSalespersonCode(SalesHeader,IntermediateApproverUserSetup."Salespers./Purch. Code");

      // Excercise - Open Sales invoice card and sent it for approval
      SendSalesInvoiceForApproval(SalesHeader);

      // Verify - Sales invoice status is set to Pending Approval
      VerifySalesInvIsPendingApproval(SalesHeader);

      // Verify - Approval requests and their data
      LibraryDocumentApprovals.GetApprovalEntries(ApprovalEntry,SalesHeader.RECORDID);
      Assert.AreEqual(1,ApprovalEntry.COUNT,UnexpectedNoOfApprovalEntriesErr);

      VerifyApprovalEntryIsOpen(ApprovalEntry);
      VerifyApprovalEntrySenderID(ApprovalEntry,CurrentUserSetup."User ID");
      VerifyApprovalEntryApproverID(ApprovalEntry,IntermediateApproverUserSetup."User ID");

      // Assign the approval entry to current user so that it can be approved
      LibraryDocumentApprovals.UpdateApprovalEntryWithCurrUser(SalesHeader.RECORDID);

      // Excercise - Open Sales invoice card and delgate the approval request
      DelegateSalesInvoice(SalesHeader);

      // Verify - Approval requests and their data
      VerifySalesInvIsPendingApproval(SalesHeader);
      ApprovalEntry.RESET;
      LibraryDocumentApprovals.GetApprovalEntries(ApprovalEntry,SalesHeader.RECORDID);
      VerifyApprovalEntryIsOpen(ApprovalEntry);
      VerifyApprovalEntryApproverID(ApprovalEntry,FinalApproverUserSetup."User ID");

      // Assign the approval entry to current user so that it can be approved
      LibraryDocumentApprovals.UpdateApprovalEntryWithCurrUser(SalesHeader.RECORDID);

      // Excercise - Open Sales invoice card and approve the approval request
      ApproveSalesInvoice(SalesHeader);

      // Verify - Approval requests and their data
      VerifySalesInvIsReleased(SalesHeader);
      ApprovalEntry.RESET;
      LibraryDocumentApprovals.GetApprovalEntries(ApprovalEntry,SalesHeader.RECORDID);
      VerifyApprovalEntryIsApproved(ApprovalEntry);
Member of Lib.Library - Document Approvals


SetupUsersForApprovals@18 Method

The procedure SetupUsersForApprovals is available in codeunit 131352.

Syntax

SetupUsersForApprovals@18(
    VAR IntermediateApproverUserSetup@1003 : Record 91 IntermediateApproverUserSetup //Reference parameter of type Record
);

Parameters

IntermediateApproverUserSetup
Reference parameter of type Record

Remarks

The relevant search keywords are: Setup, Users, For, Approvals.

For a clarification about how this function works, refer to the code listed below.

      CreateOrFindUserSetup(CurrentUserSetup,USERID);
      CreateMockupUserSetup(IntermediateApproverUserSetup);
      CreateMockupUserSetup(FinalApproverUserSetup);

      SetApprover(CurrentUserSetup,IntermediateApproverUserSetup);
      SetApprover(IntermediateApproverUserSetup,FinalApproverUserSetup);
      SetSubstitute(CurrentUserSetup,FinalApproverUserSetup);

Example

The below example is extracted from the test automation codeunit 134170 to show one way of using this function.

      // [SCENARIO] The user cannot release a sales invoice when the approval workflow is enabled and the sales invoice is pending approval.
      // [GIVEN] There is a sales invoice that is sent for approval.
      // [GIVEN] The approval workflow for sales invoices is enabled.
      // [WHEN] The user wants to Release the sales invoice.
      // [THEN] The user will get an error that he cannot release the sales invoice that is not approved.

      // Setup
      Initialize;
      LibraryWorkflow.CreateEnabledWorkflow(Workflow,WorkflowSetup.SalesInvoiceApprovalWorkflowCode);

      // Setup - Create 3 approval usersetups
      LibraryDocumentApprovals.SetupUsersForApprovals(IntermediateApproverUserSetup);

      // Setup - Create Sales Person code for sales invoice
      CreateSalesInvWithLine(SalesHeader,LibraryRandom.RandInt(5000));

      // Setup - Update  Code
      SetSalesDocSalespersonCode(SalesHeader,IntermediateApproverUserSetup."Salespers./Purch. Code");

      // Excercise - Open sales invoice card and sent it for approval
      SendSalesInvoiceForApproval(SalesHeader);

      // Verify - Sales invoice status is set to Pending Approval
      VerifySalesInvIsPendingApproval(SalesHeader);

      // Exercise
      COMMIT;
      SalesInvoice.OPENVIEW;
      SalesInvoice.GOTORECORD(SalesHeader);
      ASSERTERROR SalesInvoice.Release.INVOKE;

      // Verify
      Assert.ExpectedError(STRSUBSTNO(RecordIsRestrictedErr,FORMAT(SalesHeader.RECORDID,0,1)));
Member of Lib.Library - Document Approvals


SetupUsersForApprovalsWithLimits@42 Method

The procedure SetupUsersForApprovalsWithLimits is available in codeunit 131352.

Syntax

SetupUsersForApprovalsWithLimits@42(
    VAR CurrentUserSetup@1002 : Record 91 CurrentUserSetup, //Reference parameter of type Record
    VAR IntermediateApproverUserSetup@1001 : Record 91 IntermediateApproverUserSetup, //Reference parameter of type Record
    VAR FinalApproverUserSetup@1000 : Record 91 FinalApproverUserSetup //Reference parameter of type Record
);

Parameters

CurrentUserSetup
Reference parameter of type Record
IntermediateApproverUserSetup
Reference parameter of type Record
FinalApproverUserSetup
Reference parameter of type Record

Remarks

The relevant search keywords are: Setup, Users, For, Approvals, Limits.

For a clarification about how this function works, refer to the code listed below.

      SetupUsersForApprovals(IntermediateApproverUserSetup);

      CurrentUserSetup.GET(USERID);
      SetSalesAmountApprovalLimits(CurrentUserSetup,LibraryRandom.RandIntInRange(1,100));
      SetLimitedSalesApprovalLimits(CurrentUserSetup);
      SetPurchaseAmountApprovalLimits(CurrentUserSetup,LibraryRandom.RandIntInRange(1,100));
      SetLimitedPurchaseApprovalLimits(CurrentUserSetup);

      SetSalesAmountApprovalLimits(IntermediateApproverUserSetup,LibraryRandom.RandIntInRange(101,1000));
      SetLimitedSalesApprovalLimits(IntermediateApproverUserSetup);
      SetPurchaseAmountApprovalLimits(IntermediateApproverUserSetup,LibraryRandom.RandIntInRange(101,1000));
      SetLimitedPurchaseApprovalLimits(IntermediateApproverUserSetup);

      FinalApproverUserSetup.GET(IntermediateApproverUserSetup."Approver ID");
      SetUnlimitedSalesApprovalLimits(FinalApproverUserSetup);
      SetUnlimitedPurchaseApprovalLimits(FinalApproverUserSetup);

Example

The below example is extracted from the test automation codeunit 134175 to show one way of using this function.

      // [SCENARIO 1] Test that the Sales Order Approval Workflow approval path works with a chain of approvers of 3 users.
      // [GIVEN] The Sales Order Approval Workflow is enabled.
      // [WHEN] A user sends the Sales order for approval and all users in the chain of approvals approve the document.
      // [THEN] The Sales order is approved and released.

      Initialize;

      LibraryWorkflow.CreateEnabledWorkflow(Workflow,WorkflowSetup.SalesOrderApprovalWorkflowCode);

      // Setup - Create 3 user setups, chain the users for approval, set Sales amount limits
      LibraryDocumentApprovals.SetupUsersForApprovalsWithLimits(CurrentUserSetup,IntermediateApproverUserSetup,FinalApproverUserSetup);

      // Setup - Create Sales order where amount will lead to 3 approval requests
      CreateSalesDocument(SalesHeader,SalesHeader."Document Type"::Order,LibraryRandom.RandIntInRange(5000,10000));

      // Setup - Update Salesperson Code
      SetSalesDocSalespersonCode(SalesHeader,IntermediateApproverUserSetup."Salespers./Purch. Code");

      // Excercise - Open Sales order card and sent it for approval
      SendSalesOrderForApproval(SalesHeader);

      // Verify - Sales order status is set to Pending Approval
      VerifySalesDocumentStatus(SalesHeader."Document Type",SalesHeader."No.",SalesHeader.Status::"Pending Approval");

      // Verify - Approval requests and their data
      VerifyApprovalRequests(SalesHeader,2,CurrentUserSetup."User ID",IntermediateApproverUserSetup."User ID",
        FinalApproverUserSetup."User ID",ApprovalEntry.Status::Open,ApprovalEntry.Status::Created);

      // Excercise - Set the approverid to USERID so that it can be approved
      LibraryDocumentApprovals.UpdateApprovalEntryWithCurrUser(SalesHeader.RECORDID);

      // Excercise - Open Sales order card and approve the approval request
      ApproveSalesOrder(SalesHeader);

      // Verify - Approval requests and their data
      VerifyApprovalRequests(SalesHeader,2,CurrentUserSetup."Approver ID",CurrentUserSetup."User ID",
        CurrentUserSetup."User ID",ApprovalEntry.Status::Approved,ApprovalEntry.Status::Open);

      // Excercise - Set the approverid to USERID so that it can be approved
      ApproveSalesOrder(SalesHeader);

      // Verify - Sales order is approved and released
      VerifySalesDocumentStatus(SalesHeader."Document Type",SalesHeader."No.",SalesHeader.Status::Released);

      // Verify - Approval requests and their data
      VerifyApprovalRequests(SalesHeader,2,CurrentUserSetup."Approver ID",CurrentUserSetup."User ID",
        CurrentUserSetup."User ID",ApprovalEntry.Status::Approved,ApprovalEntry.Status::Approved);
Member of Lib.Library - Document Approvals


SetupUserWithApprover@16 Method

The procedure SetupUserWithApprover is available in codeunit 131352.

Syntax

SetupUserWithApprover@16(
    VAR CurrentUserSetup@1000 : Record 91 CurrentUserSetup //Reference parameter of type Record
);

Parameters

CurrentUserSetup
Reference parameter of type Record

Remarks

The relevant search keywords are: Setup, User, Approver.

For a clarification about how this function works, refer to the code listed below.

      CreateMockupUserSetup(ApproverUserSetup);
      CreateOrFindUserSetup(CurrentUserSetup,USERID);
      SetApprover(CurrentUserSetup,ApproverUserSetup);

Example

The below example is extracted from the test automation codeunit 134170 to show one way of using this function.

      LibraryDocumentApprovals.SetupUserWithApprover(UserSetup);

      LibraryWorkflow.CopyWorkflowTemplate(Workflow,WorkflowSetup.SalesInvoiceCreditLimitApprovalWorkflowCode);
      WorkflowStep.SETRANGE("Function Name",WorkflowResponseHandling.CreateApprovalRequestsCode);
      WorkflowStep.SETRANGE("Workflow Code",Workflow.Code);
      WorkflowStep.FINDFIRST;
      WorkflowStepArgument.GET(WorkflowStep.Argument);
      WorkflowStepArgument.VALIDATE("Approver Type",WorkflowStepArgument."Approver Type"::Approver);
      WorkflowStepArgument.VALIDATE("Approver Limit Type",WorkflowStepArgument."Approver Limit Type"::"Direct Approver");
      WorkflowStepArgument.MODIFY(TRUE);

      LibraryWorkflow.EnableWorkflow(Workflow);
Member of Lib.Library - Document Approvals


SetWorkflowApproverType@20 Method

The procedure SetWorkflowApproverType is available in codeunit 131352.

Syntax

SetWorkflowApproverType@20(
    Workflow@1000 : Record 1501 Workflow, //Input parameter of type Record
    ApproverType@1004 : Option ApproverType //Input parameter of type Option
);

Parameters

Workflow
Input parameter of type Record
ApproverType
Input parameter of type Option

Remarks

The relevant search keywords are: Set, Workflow, Approver, Type.

For a clarification about how this function works, refer to the code listed below.

      WorkflowStep.SETRANGE("Workflow Code",Workflow.Code);
      WorkflowStep.SETRANGE("Function Name",WorkflowResponseHandling.CreateApprovalRequestsCode);
      WorkflowStep.FINDFIRST;

      WorkflowStepArgument.GET(WorkflowStep.Argument);
      WorkflowStepArgument."Approver Type" := ApproverType;
      WorkflowStepArgument.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - Document Approvals


UpdateApprovalEntryWithCurrUser@65 Method

The procedure UpdateApprovalEntryWithCurrUser is available in codeunit 131352.

Syntax

UpdateApprovalEntryWithCurrUser@65(
    RecordID@1001 : RecordID RecordID //Input parameter of type RecordID
);

Parameters

RecordID
Input parameter of type RecordID

Remarks

The relevant search keywords are: Update, Approval, Entry, Currency, User.

For a clarification about how this function works, refer to the code listed below.

      GetApprovalEntries(ApprovalEntry,RecordID);
      UserSetup.GET(USERID);
      ApprovalEntry.MODIFYALL("Sender ID",UserSetup."Approver ID",TRUE);
      ApprovalEntry.MODIFYALL("Approver ID",UserSetup."User ID",TRUE);

Example

The below example is extracted from the test automation codeunit 134170 to show one way of using this function.

      // [SCENARIO] This test verifies E2E scenario for the Sales invoice approval workflow on approval path.
      // [GIVEN] Sales Invoice Approval Workflow that has Salesperson as the approver and No Limit as the limit type.
      // [WHEN] Sales Invoice is sent for approval.
      // [THEN] Approval Request is created for the Salesperson.
      // [WHEN] Salesperson approves the approval request.
      // [THEN] Sales Invoice is released.

      Initialize;

      LibraryWorkflow.CreateEnabledWorkflow(Workflow,WorkflowSetup.SalesInvoiceApprovalWorkflowCode);

      // Setup - Create 3 approval usersetups
      LibraryDocumentApprovals.SetupUsersForApprovals(IntermediateApproverUserSetup);

      // Setup - Create Sales invoice
      CreateSalesInvWithLine(SalesHeader,LibraryRandom.RandInt(5000));

      // Setup - Update Salesperson Code
      SetSalesDocSalespersonCode(SalesHeader,IntermediateApproverUserSetup."Salespers./Purch. Code");

      // Excercise - Open Sales invoice card and sent it for approval
      SendSalesInvoiceForApproval(SalesHeader);

      // Verify - Sales invoice status is set to Pending Approval
      VerifySalesInvIsPendingApproval(SalesHeader);

      // Verify - Approval requests and their data
      LibraryDocumentApprovals.GetApprovalEntries(ApprovalEntry,SalesHeader.RECORDID);
      Assert.AreEqual(1,ApprovalEntry.COUNT,UnexpectedNoOfApprovalEntriesErr);

      VerifyApprovalEntryIsOpen(ApprovalEntry);
      VerifyApprovalEntrySenderID(ApprovalEntry,USERID);
      VerifyApprovalEntryApproverID(ApprovalEntry,IntermediateApproverUserSetup."User ID");

      // Setup - Assign the approval entry to current user so that it can be approved
      LibraryDocumentApprovals.UpdateApprovalEntryWithCurrUser(SalesHeader.RECORDID);

      // Excercise - Open Sales invoice card and approve the approval request
      ApproveSalesInvoice(SalesHeader);

      // Verify - Approval requests and their data
      VerifySalesInvIsReleased(SalesHeader);
      ApprovalEntry.RESET;
      LibraryDocumentApprovals.GetApprovalEntries(ApprovalEntry,SalesHeader.RECORDID);
      VerifyApprovalEntryIsApproved(ApprovalEntry);
Member of Lib.Library - Document Approvals


UpdateApprovalLimits@2 Method

The procedure UpdateApprovalLimits is available in codeunit 131352.

Syntax

UpdateApprovalLimits@2(
    VAR UserSetup@1000 : Record 91 UserSetup, //Reference parameter of type Record
    UnlimitedSalesApproval@1001 : Boolean UnlimitedSalesApproval, //Input parameter of type Boolean
    UnlimitedPurchaseApproval@1002 : Boolean UnlimitedPurchaseApproval, //Input parameter of type Boolean
    UnlimitedRequestApproval@1003 : Boolean UnlimitedRequestApproval, //Input parameter of type Boolean
    SalesAmountApprovalLimit@1004 : Integer SalesAmountApprovalLimit, //Input parameter of type Integer
    PurchaseAmountApprovalLimit@1005 : Integer PurchaseAmountApprovalLimit, //Input parameter of type Integer
    RequestAmountApprovalLimit@1006 : Integer RequestAmountApprovalLimit //Input parameter of type Integer
);

Parameters

UserSetup
Reference parameter of type Record
UnlimitedSalesApproval
Input parameter of type Boolean
UnlimitedPurchaseApproval
Input parameter of type Boolean
UnlimitedRequestApproval
Input parameter of type Boolean
SalesAmountApprovalLimit
Input parameter of type Integer
PurchaseAmountApprovalLimit
Input parameter of type Integer
RequestAmountApprovalLimit
Input parameter of type Integer

Remarks

The relevant search keywords are: Update, Approval, Limits.

For a clarification about how this function works, refer to the code listed below.

      UserSetup.VALIDATE("Unlimited Sales Approval",UnlimitedSalesApproval);
      UserSetup.VALIDATE("Unlimited Purchase Approval",UnlimitedPurchaseApproval);
      UserSetup.VALIDATE("Unlimited Request Approval",UnlimitedRequestApproval);

      UserSetup.VALIDATE("Sales Amount Approval Limit",SalesAmountApprovalLimit);
      UserSetup.VALIDATE("Purchase Amount Approval Limit",PurchaseAmountApprovalLimit);
      UserSetup.VALIDATE("Request Amount Approval Limit",RequestAmountApprovalLimit);

      UserSetup.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - Document Approvals


UserExists@1 Method

The procedure UserExists is available in codeunit 131352.

Syntax

UserExists@1(
    WindowsUserName@1001 : Text[208] WindowsUserName //Input parameter of type Text
);

Parameters

WindowsUserName
Input parameter of type Text

Return Value

Boolean

Remarks

The relevant search keywords are: User, Exists.

For a clarification about how this function works, refer to the code listed below.

      User.SETRANGE("Windows Security ID",SID(WindowsUserName));
      EXIT(NOT User.ISEMPTY);

Example

There are no examples available.
Member of Lib.Library - Document Approvals


UserSetupExists@3 Method

The procedure UserSetupExists is available in codeunit 131352.

Syntax

UserSetupExists@3(
    WindowsUserName@1002 : Text[208] WindowsUserName //Input parameter of type Text
);

Parameters

WindowsUserName
Input parameter of type Text

Return Value

Boolean

Remarks

The relevant search keywords are: User, Setup, Exists.

For a clarification about how this function works, refer to the code listed below.

      GetUser(User,WindowsUserName);
      UserSetup.SETRANGE("User ID",User."User Name");
      EXIT(NOT UserSetup.ISEMPTY);

Example

There are no examples available.
Member of Lib.Library - Document Approvals


Library - ERM Class

Lib.Library - ERM

COD131300 applies to RES,ERM,SCM,W1,IN.
All utility functions related to ERM.

Methods

Name | Description
AdjustGenJournalBalance@215 | The procedure AdjustGenJournalBalance is available in codeunit 131300.
ApplicationAmountRounding@3 | The procedure ApplicationAmountRounding is available in codeunit 131300.
ApplyCustomerLedgerEntries@245 | The procedure ApplyCustomerLedgerEntries is available in codeunit 131300.
ApplyVendorLedgerEntries@258 | The procedure ApplyVendorLedgerEntries is available in codeunit 131300.
CheckPreview@175 | The procedure CheckPreview is available in codeunit 131300.
ClearAdjustPmtDiscInVATSetup@261 | The procedure ClearAdjustPmtDiscInVATSetup is available in codeunit 131300.
ClearGenJournalLines@87 | The procedure ClearGenJournalLines is available in codeunit 131300.
ClearIntrastatJnlLines@113 | The procedure ClearIntrastatJnlLines is available in codeunit 131300.
ConvertCurrency@13 | The procedure ConvertCurrency is available in codeunit 131300.
CreateAccountMapping@140 | The procedure CreateAccountMapping is available in codeunit 131300.
CreateAccountMappingCustomer@146 | The procedure CreateAccountMappingCustomer is available in codeunit 131300.
CreateAccountMappingGLAccount@148 | The procedure CreateAccountMappingGLAccount is available in codeunit 131300.
CreateAccountMappingVendor@147 | The procedure CreateAccountMappingVendor is available in codeunit 131300.
CreateAccScheduleLine@39 | The procedure CreateAccScheduleLine is available in codeunit 131300.
CreateAccScheduleName@32 | The procedure CreateAccScheduleName is available in codeunit 131300.
CreateAnalysisColumn@122 | The procedure CreateAnalysisColumn is available in codeunit 131300.
CreateAnalysisView@80 | The procedure CreateAnalysisView is available in codeunit 131300.
CreateAssesseeCode@1500009 | The procedure CreateAssesseeCode is available in codeunit 131300.
CreateBankAccAndLCCrLimit@1500020 | The procedure CreateBankAccAndLCCrLimit is available in codeunit 131300.
CreateBankAccount@1 | The procedure CreateBankAccount is available in codeunit 131300.
CreateBankAccountNo@250 | The procedure CreateBankAccountNo is available in codeunit 131300.
CreateBankAccountPostingGroup@152 | The procedure CreateBankAccountPostingGroup is available in codeunit 131300.
CreateBankAccReconciliation@44 | The procedure CreateBankAccReconciliation is available in codeunit 131300.
CreateBankAccReconciliationLn@76 | The procedure CreateBankAccReconciliationLn is available in codeunit 131300.
CreateBusinessUnit@178 | The procedure CreateBusinessUnit is available in codeunit 131300.
CreateChangeLogField@125 | The procedure CreateChangeLogField is available in codeunit 131300.
CreateChangeLogTable@105 | The procedure CreateChangeLogTable is available in codeunit 131300.
CreateColumnLayout@38 | The procedure CreateColumnLayout is available in codeunit 131300.
CreateColumnLayoutName@36 | The procedure CreateColumnLayoutName is available in codeunit 131300.
CreateCountryRegion@82 | The procedure CreateCountryRegion is available in codeunit 131300.
CreateCountryRegionWithIntrastatCode@226 | The procedure CreateCountryRegionWithIntrastatCode is available in codeunit 131300.
CreateCurrency@8 | The procedure CreateCurrency is available in codeunit 131300.
CreateCurrencyForReminderLevel@64 | The procedure CreateCurrencyForReminderLevel is available in codeunit 131300.
CreateCurrencyWithExchangeRate@156 | The procedure CreateCurrencyWithExchangeRate is available in codeunit 131300.
CreateCurrencyWithGLAccountSetup@155 | The procedure CreateCurrencyWithGLAccountSetup is available in codeunit 131300.
CreateCurrencyWithRandomExchRates@159 | The procedure CreateCurrencyWithRandomExchRates is available in codeunit 131300.
CreateCurrencyWithRounding@142 | The procedure CreateCurrencyWithRounding is available in codeunit 131300.
CreateCustomerDiscountGroup@124 | The procedure CreateCustomerDiscountGroup is available in codeunit 131300.
CreateDeductorCategory@1500002 | The procedure CreateDeductorCategory is available in codeunit 131300.
CreateDeferralTemplate@203 | The procedure CreateDeferralTemplate is available in codeunit 131300.
CreateDeferralTemplateCode@204 | The procedure CreateDeferralTemplateCode is available in codeunit 131300.
CreateExchangeRate@154 | The procedure CreateExchangeRate is available in codeunit 131300.
CreateExchRate@16 | The procedure CreateExchRate is available in codeunit 131300.
CreateExciseBusPostingGroup@1500001 | The procedure CreateExciseBusPostingGroup is available in codeunit 131300.
CreateExcisePostingSetup@1500000 | The procedure CreateExcisePostingSetup is available in codeunit 131300.
CreateExciseProdPostingGroup@1500007 | The procedure CreateExciseProdPostingGroup is available in codeunit 131300.
CreateFADepreciationBook@353 | The procedure CreateFADepreciationBook is available in codeunit 131300.
CreateFAJournalLine@49 | The procedure CreateFAJournalLine is available in codeunit 131300.
CreateFinanceChargeMemoHeader@72 | The procedure CreateFinanceChargeMemoHeader is available in codeunit 131300.
CreateFinanceChargeMemoLine@71 | The procedure CreateFinanceChargeMemoLine is available in codeunit 131300.
CreateFinanceChargeTerms@77 | The procedure CreateFinanceChargeTerms is available in codeunit 131300.
CreateFinanceChargeText@73 | The procedure CreateFinanceChargeText is available in codeunit 131300.
CreateFixedAsset@348 | The procedure CreateFixedAsset is available in codeunit 131300.
CreateGenBusPostingGroup@43 | The procedure CreateGenBusPostingGroup is available in codeunit 131300.
CreateGeneralJnlLine@15 | The procedure CreateGeneralJnlLine is available in codeunit 131300.
CreateGeneralJnlLine2@136 | The procedure CreateGeneralJnlLine2 is available in codeunit 131300.
CreateGeneralJnlLine2WithBalAcc@135 | The procedure CreateGeneralJnlLine2WithBalAcc is available in codeunit 131300.
CreateGeneralJnlLineWithBalAcc@134 | The procedure CreateGeneralJnlLineWithBalAcc is available in codeunit 131300.
CreateGeneralPostingSetup@47 | The procedure CreateGeneralPostingSetup is available in codeunit 131300.
CreateGeneralPostingSetupInvt@163 | The procedure CreateGeneralPostingSetupInvt is available in codeunit 131300.
CreateGenJnlAllocation@63 | The procedure CreateGenJnlAllocation is available in codeunit 131300.
CreateGenJournalBatch@75 | The procedure CreateGenJournalBatch is available in codeunit 131300.
CreateGenJournalTemplate@68 | The procedure CreateGenJournalTemplate is available in codeunit 131300.
CreateGenPostSetup@1500014 | The procedure CreateGenPostSetup is available in codeunit 131300.
CreateGenProdPostingGroup@42 | The procedure CreateGenProdPostingGroup is available in codeunit 131300.
CreateGLAccount@14 | The procedure CreateGLAccount is available in codeunit 131300.
CreateGLAccountNo@149 | The procedure CreateGLAccountNo is available in codeunit 131300.
CreateGLAccountNoWithDirectPosting@151 | The procedure CreateGLAccountNoWithDirectPosting is available in codeunit 131300.
CreateGLAccountWithPurchSetup@150 | The procedure CreateGLAccountWithPurchSetup is available in codeunit 131300.
CreateGLAccountWithSalesSetup@157 | The procedure CreateGLAccountWithSalesSetup is available in codeunit 131300.
CreateGLAccountWithVATPostingSetup@143 | The procedure CreateGLAccountWithVATPostingSetup is available in codeunit 131300.
CreateGLBudgetEntry@91 | The procedure CreateGLBudgetEntry is available in codeunit 131300.
CreateGLBudgetName@79 | The procedure CreateGLBudgetName is available in codeunit 131300.
CreateICGLAccount@111 | The procedure CreateICGLAccount is available in codeunit 131300.
CreateICPartner@108 | The procedure CreateICPartner is available in codeunit 131300.
CreateIncomeTaxAccountingPeriod@1500003 | The procedure CreateIncomeTaxAccountingPeriod is available in codeunit 131300.
CreateIncomeTaxPeriod@1500004 | The procedure CreateIncomeTaxPeriod is available in codeunit 131300.
CreateInsurance@46 | The procedure CreateInsurance is available in codeunit 131300.
CreateIntrastatContact@227 | The procedure CreateIntrastatContact is available in codeunit 131300.
CreateIntrastatJnlBatch@97 | The procedure CreateIntrastatJnlBatch is available in codeunit 131300.
CreateIntrastatJnlLine@96 | The procedure CreateIntrastatJnlLine is available in codeunit 131300.
CreateIntrastatJnlTemplate@98 | The procedure CreateIntrastatJnlTemplate is available in codeunit 131300.
CreateIntrastatJnlTemplateAndBatch@187 | The procedure CreateIntrastatJnlTemplateAndBatch is available in codeunit 131300.
CreateInvDiscForCustomer@17 | The procedure CreateInvDiscForCustomer is available in codeunit 131300.
CreateInvDiscForVendor@9 | The procedure CreateInvDiscForVendor is available in codeunit 131300.
CreateItemAnalysisView@88 | The procedure CreateItemAnalysisView is available in codeunit 131300.
CreateItemBudgetName@230 | The procedure CreateItemBudgetName is available in codeunit 131300.
CreateItemDiscountGroup@205 | The procedure CreateItemDiscountGroup is available in codeunit 131300.
CreateLineDiscForCustomer@23 | The procedure CreateLineDiscForCustomer is available in codeunit 131300.
CreateLineDiscForVendor@29 | The procedure CreateLineDiscForVendor is available in codeunit 131300.
CreateNODNOCHeader@1500011 | The procedure CreateNODNOCHeader is available in codeunit 131300.
CreateNODNOCLines@1500012 | The procedure CreateNODNOCLines is available in codeunit 131300.
CreateNoSeriesCode@18 | The procedure CreateNoSeriesCode is available in codeunit 131300.
CreatePaymentMethod@127 | The procedure CreatePaymentMethod is available in codeunit 131300.
CreatePaymentTerms@41 | The procedure CreatePaymentTerms is available in codeunit 131300.
CreatePaymentTermsDiscount@1043 | The procedure CreatePaymentTermsDiscount is available in codeunit 131300.
CreatePostCode@186 | The procedure CreatePostCode is available in codeunit 131300.
CreatePrepaymentVATSetup@190 | The procedure CreatePrepaymentVATSetup is available in codeunit 131300.
CreateRandomExchangeRate@25 | The procedure CreateRandomExchangeRate is available in codeunit 131300.
CreateRandomVATIdentifierAndGetCode@133 | The procedure CreateRandomVATIdentifierAndGetCode is available in codeunit 131300.
CreateReasonCode@85 | The procedure CreateReasonCode is available in codeunit 131300.
CreateRecurringBatchName@61 | The procedure CreateRecurringBatchName is available in codeunit 131300.
CreateRecurringTemplateName@60 | The procedure CreateRecurringTemplateName is available in codeunit 131300.
CreateRelatedVATPostingSetup@189 | The procedure CreateRelatedVATPostingSetup is available in codeunit 131300.
CreateReminderHeader@12 | The procedure CreateReminderHeader is available in codeunit 131300.
CreateReminderLevel@10 | The procedure CreateReminderLevel is available in codeunit 131300.
CreateReminderLine@69 | The procedure CreateReminderLine is available in codeunit 131300.
CreateReminderTerms@4 | The procedure CreateReminderTerms is available in codeunit 131300.
CreateReminderText@110 | The procedure CreateReminderText is available in codeunit 131300.
CreateReturnReasonCode@126 | The procedure CreateReturnReasonCode is available in codeunit 131300.
CreateSourceCode@58 | The procedure CreateSourceCode is available in codeunit 131300.
CreateStandardGeneralJournal@90 | The procedure CreateStandardGeneralJournal is available in codeunit 131300.
CreateStandardItemJournal@93 | The procedure CreateStandardItemJournal is available in codeunit 131300.
CreateState@1500025 | The procedure CreateState is available in codeunit 131300.
CreateStructureDetails@1500005 | The procedure CreateStructureDetails is available in codeunit 131300.
CreateStructureHeader@1500006 | The procedure CreateStructureHeader is available in codeunit 131300.
CreateTaxArea@116 | The procedure CreateTaxArea is available in codeunit 131300.
CreateTaxAreaAndTaxAreaLine@1500041 | The procedure CreateTaxAreaAndTaxAreaLine is available in codeunit 131300.
CreateTaxAreaLine@117 | The procedure CreateTaxAreaLine is available in codeunit 131300.
CreateTaxComponent@1500043 | The procedure CreateTaxComponent is available in codeunit 131300.
CreateTaxDetail@115 | The procedure CreateTaxDetail is available in codeunit 131300.
CreateTaxDetails@1500038 | The procedure CreateTaxDetails is available in codeunit 131300.
CreateTaxGroup@112 | The procedure CreateTaxGroup is available in codeunit 131300.
CreateTaxJurisdiction@114 | The procedure CreateTaxJurisdiction is available in codeunit 131300.
CreateTDSNatureDeduction@1500008 | The procedure CreateTDSNatureDeduction is available in codeunit 131300.
CreateTDSSetup@1500010 | The procedure CreateTDSSetup is available in codeunit 131300.
CreateTerritory@209 | The procedure CreateTerritory is available in codeunit 131300.
CreateTINNo@1500026 | The procedure CreateTINNo is available in codeunit 131300.
CreateVATBusinessPostingGroup@109 | The procedure CreateVATBusinessPostingGroup is available in codeunit 131300.
CreateVATBusinessPostingGroups@1500019 | The procedure CreateVATBusinessPostingGroups is available in codeunit 131300.
CreateVATClause@222 | The procedure CreateVATClause is available in codeunit 131300.
CreateVATPostingSetup@106 | The procedure CreateVATPostingSetup is available in codeunit 131300.
CreateVATPostingSetups@1500013 | The procedure CreateVATPostingSetups is available in codeunit 131300.
CreateVATPostingSetupWithAccounts@172 | The procedure CreateVATPostingSetupWithAccounts is available in codeunit 131300.
CreateVATProductPostingGroup@107 | The procedure CreateVATProductPostingGroup is available in codeunit 131300.
CreateVATProductPostingGroups@1500018 | The procedure CreateVATProductPostingGroups is available in codeunit 131300.
CreateVATRegistrationNoFormat@81 | The procedure CreateVATRegistrationNoFormat is available in codeunit 131300.
CreateVATStatementLine@119 | The procedure CreateVATStatementLine is available in codeunit 131300.
CreateVATStatementName@120 | The procedure CreateVATStatementName is available in codeunit 131300.
CreateVATStatementNameWithTemplate@219 | The procedure CreateVATStatementNameWithTemplate is available in codeunit 131300.
CreateVATStatementTemplate@118 | The procedure CreateVATStatementTemplate is available in codeunit 131300.
FindBankAccount@57 | The procedure FindBankAccount is available in codeunit 131300.
FindBankAccountPostingGroup@95 | The procedure FindBankAccountPostingGroup is available in codeunit 131300.
FindCountryRegion@137 | The procedure FindCountryRegion is available in codeunit 131300.
FindCurrency@56 | The procedure FindCurrency is available in codeunit 131300.
FindCustomerLedgerEntry@20 | The procedure FindCustomerLedgerEntry is available in codeunit 131300.
FindDeferralLine@214 | The procedure FindDeferralLine is available in codeunit 131300.
FindDirectPostingGLAccount@139 | The procedure FindDirectPostingGLAccount is available in codeunit 131300.
FindEarliestDateForExhRate@201 | The procedure FindEarliestDateForExhRate is available in codeunit 131300.
FindExchRate@22 | The procedure FindExchRate is available in codeunit 131300.
FindExcisePostingSetup@1500015 | The procedure FindExcisePostingSetup is available in codeunit 131300.
FindGenBusinessPostingGroup@65 | The procedure FindGenBusinessPostingGroup is available in codeunit 131300.
FindGeneralJournalSourceCode@86 | The procedure FindGeneralJournalSourceCode is available in codeunit 131300.
FindGeneralPostingSetup@99 | The procedure FindGeneralPostingSetup is available in codeunit 131300.
FindGeneralPostingSetupInvtBase@161 | The procedure FindGeneralPostingSetupInvtBase is available in codeunit 131300.
FindGeneralPostingSetupInvtFull@173 | The procedure FindGeneralPostingSetupInvtFull is available in codeunit 131300.
FindGeneralPostingSetupInvtToGL@197 | The procedure FindGeneralPostingSetupInvtToGL is available in codeunit 131300.
FindGenJournalBatch@78 | The procedure FindGenJournalBatch is available in codeunit 131300.
FindGenJournalTemplate@66 | The procedure FindGenJournalTemplate is available in codeunit 131300.
FindGenPostingSetupWithDefVAT@174 | The procedure FindGenPostingSetupWithDefVAT is available in codeunit 131300.
FindGenProductPostingGroup@70 | The procedure FindGenProductPostingGroup is available in codeunit 131300.
FindGLAccount@59 | The procedure FindGLAccount is available in codeunit 131300.
FindGLAccountDataSet@141 | The procedure FindGLAccountDataSet is available in codeunit 131300.
FindPaymentMethod@83 | The procedure FindPaymentMethod is available in codeunit 131300.
FindPaymentTerms@84 | The procedure FindPaymentTerms is available in codeunit 131300.
FindPaymentTermsCode@48 | The procedure FindPaymentTermsCode is available in codeunit 131300.
FindPostCode@89 | The procedure FindPostCode is available in codeunit 131300.
FindRecurringTemplateName@62 | The procedure FindRecurringTemplateName is available in codeunit 131300.
FindUnrealVATPostingSetup@162 | The procedure FindUnrealVATPostingSetup is available in codeunit 131300.
FindVATBusinessPostingGroup@67 | The procedure FindVATBusinessPostingGroup is available in codeunit 131300.
FindVATPostingSetup@19 | The procedure FindVATPostingSetup is available in codeunit 131300.
FindVATPostingSetupInvt@171 | The procedure FindVATPostingSetupInvt is available in codeunit 131300.
FindVATProductPostingGroup@74 | The procedure FindVATProductPostingGroup is available in codeunit 131300.
FindVATSetupForCust@1500016 | The procedure FindVATSetupForCust is available in codeunit 131300.
FindVendorLedgerEntry@24 | The procedure FindVendorLedgerEntry is available in codeunit 131300.
FindZeroVATPostingSetup@158 | The procedure FindZeroVATPostingSetup is available in codeunit 131300.
GenerateVATRegistrationNo@131 | The procedure GenerateVATRegistrationNo is available in codeunit 131300.
GetAddReportingCurrency@179 | The procedure GetAddReportingCurrency is available in codeunit 131300.
GetAllowPostingFrom@196 | The procedure GetAllowPostingFrom is available in codeunit 131300.
GetAllowPostingTo@198 | The procedure GetAllowPostingTo is available in codeunit 131300.
GetAmountRoundingPrecision@104 | The procedure GetAmountRoundingPrecision is available in codeunit 131300.
GetCombinedPostedDeferralLines@206 | The procedure GetCombinedPostedDeferralLines is available in codeunit 131300.
GetCountryIntrastatCode@225 | The procedure GetCountryIntrastatCode is available in codeunit 131300.
GetCurrencyAmountRoundingPrecision@241 | The procedure GetCurrencyAmountRoundingPrecision is available in codeunit 131300.
GetCurrencyCode@195 | The procedure GetCurrencyCode is available in codeunit 131300.
GetDiscountPaymentTerm@26 | The procedure GetDiscountPaymentTerm is available in codeunit 131300.
GetGlobalDimensionCode@92 | The procedure GetGlobalDimensionCode is available in codeunit 131300.
GetInvoiceRoundingPrecisionLCY@101 | The procedure GetInvoiceRoundingPrecisionLCY is available in codeunit 131300.
GetLCYCode@182 | The procedure GetLCYCode is available in codeunit 131300.
GetPaymentTermsDiscountPct@200 | The procedure GetPaymentTermsDiscountPct is available in codeunit 131300.
GetShortcutDimensionCode@183 | The procedure GetShortcutDimensionCode is available in codeunit 131300.
GetUnitAmountRoundingPrecision@194 | The procedure GetUnitAmountRoundingPrecision is available in codeunit 131300.
InvoiceAmountRounding@2 | The procedure InvoiceAmountRounding is available in codeunit 131300.
IssueFinanceChargeMemo@130 | The procedure IssueFinanceChargeMemo is available in codeunit 131300.
PostBankAccReconciliation@45 | The procedure PostBankAccReconciliation is available in codeunit 131300.
PostCustLedgerApplication@28 | The procedure PostCustLedgerApplication is available in codeunit 131300.
PostFAJournalLine@50 | The procedure PostFAJournalLine is available in codeunit 131300.
PostGeneralJnlLine@30 | The procedure PostGeneralJnlLine is available in codeunit 131300.
PostVendLedgerApplication@33 | The procedure PostVendLedgerApplication is available in codeunit 131300.
ReverseTransaction@265 | The procedure ReverseTransaction is available in codeunit 131300.
RunAddnlReportingCurrency@103 | The procedure RunAddnlReportingCurrency is available in codeunit 131300.
RunAdjustExchangeRates@132 | The procedure RunAdjustExchangeRates is available in codeunit 131300.
RunAdjustExchangeRatesSimple@129 | The procedure RunAdjustExchangeRatesSimple is available in codeunit 131300.
SelectFAJournalBatch@54 | The procedure SelectFAJournalBatch is available in codeunit 131300.
SelectFAJournalTemplate@52 | The procedure SelectFAJournalTemplate is available in codeunit 131300.
SelectGenJnlBatch@35 | The procedure SelectGenJnlBatch is available in codeunit 131300.
SelectGenJnlTemplate@37 | The procedure SelectGenJnlTemplate is available in codeunit 131300.
SetAddReportingCurrency@51 | The procedure SetAddReportingCurrency is available in codeunit 131300.
SetAllowPostingFromTo@180 | The procedure SetAllowPostingFromTo is available in codeunit 131300.
SetAllowPostingTo@184 | The procedure SetAllowPostingTo is available in codeunit 131300.
SetAmountRoundingPrecision@181 | The procedure SetAmountRoundingPrecision is available in codeunit 131300.
SetAppliestoIdCustomer@40 | The procedure SetAppliestoIdCustomer is available in codeunit 131300.
SetAppliestoIdVendor@5 | The procedure SetAppliestoIdVendor is available in codeunit 131300.
SetApplnRoundingPrecision@177 | The procedure SetApplnRoundingPrecision is available in codeunit 131300.
SetApplyCustomerEntry@11 | The procedure SetApplyCustomerEntry is available in codeunit 131300.
SetApplyVendorEntry@6 | The procedure SetApplyVendorEntry is available in codeunit 131300.
SetBillToSellToVATCalc@176 | The procedure SetBillToSellToVATCalc is available in codeunit 131300.
SetCurrencyGainLossAccounts@121 | The procedure SetCurrencyGainLossAccounts is available in codeunit 131300.
SetGeneralPostingSetupInvtAccounts@170 | The procedure SetGeneralPostingSetupInvtAccounts is available in codeunit 131300.
SetGeneralPostingSetupMfgAccounts@165 | The procedure SetGeneralPostingSetupMfgAccounts is available in codeunit 131300.
SetGeneralPostingSetupPrepAccounts@164 | The procedure SetGeneralPostingSetupPrepAccounts is available in codeunit 131300.
SetGeneralPostingSetupPurchAccounts@169 | The procedure SetGeneralPostingSetupPurchAccounts is available in codeunit 131300.
SetGeneralPostingSetupPurchPmtDiscAccounts@168 | The procedure SetGeneralPostingSetupPurchPmtDiscAccounts is available in codeunit 131300.
SetGeneralPostingSetupSalesAccounts@166 | The procedure SetGeneralPostingSetupSalesAccounts is available in codeunit 131300.
SetGeneralPostingSetupSalesPmtDiscAccounts@167 | The procedure SetGeneralPostingSetupSalesPmtDiscAccounts is available in codeunit 131300.
SetGLAccountDirectPostingFilter@138 | The procedure SetGLAccountDirectPostingFilter is available in codeunit 131300.
SetGLAccountNotBlankGroupsFilter@144 | The procedure SetGLAccountNotBlankGroupsFilter is available in codeunit 131300.
SetGlobalDimensionCode@94 | The procedure SetGlobalDimensionCode is available in codeunit 131300.
SetIntrastatContact@228 | The procedure SetIntrastatContact is available in codeunit 131300.
SetInvRoundingPrecisionLCY@55 | The procedure SetInvRoundingPrecisionLCY is available in codeunit 131300.
SetLCYCode@185 | The procedure SetLCYCode is available in codeunit 131300.
SetMaxVATDifferenceAllowed@53 | The procedure SetMaxVATDifferenceAllowed is available in codeunit 131300.
SetShortcutDimensionCode@199 | The procedure SetShortcutDimensionCode is available in codeunit 131300.
SetUnrealizedVAT@34 | The procedure SetUnrealizedVAT is available in codeunit 131300.
SetupReportSelection@211 | The procedure SetupReportSelection is available in codeunit 131300.
SetUseLegacyGLEntryLocking@193 | The procedure SetUseLegacyGLEntryLocking is available in codeunit 131300.
SetVATRoundingType@31 | The procedure SetVATRoundingType is available in codeunit 131300.
SetWorkDate@145 | The procedure SetWorkDate is available in codeunit 131300.
SuggestBankAccountReconciliation@331 | The procedure SuggestBankAccountReconciliation is available in codeunit 131300.
UnapplyCustomerLedgerEntry@27 | The procedure UnapplyCustomerLedgerEntry is available in codeunit 131300.
UnapplyVendorLedgerEntry@21 | The procedure UnapplyVendorLedgerEntry is available in codeunit 131300.
UpdateAnalysisView@128 | The procedure UpdateAnalysisView is available in codeunit 131300.
UpdateGenPostingSetupPrepmtAccounts@160 | The procedure UpdateGenPostingSetupPrepmtAccounts is available in codeunit 131300.
UpdateGLAccountWithPostingSetup@246 | The procedure UpdateGLAccountWithPostingSetup is available in codeunit 131300.
UpdateVATPostingSetup@153 | The procedure UpdateVATPostingSetup is available in codeunit 131300.
VATAmountRounding@7 | The procedure VATAmountRounding is available in codeunit 131300.
VerifyCustApplnWithZeroTransNo@100 | The procedure VerifyCustApplnWithZeroTransNo is available in codeunit 131300.
VerifyVendApplnWithZeroTransNo@102 | The procedure VerifyVendApplnWithZeroTransNo is available in codeunit 131300.

See Also

Lib


AdjustGenJournalBalance@215 Method

The procedure AdjustGenJournalBalance is available in codeunit 131300.

Syntax

AdjustGenJournalBalance@215(
    VAR GenJournalLine@1000 : Record 81 GenJournalLine //Reference parameter of type Record
);

Parameters

GenJournalLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Adjust, General, Journal, Balance.

For a clarification about how this function works, refer to the code listed below.

      CODEUNIT.RUN(CODEUNIT::"Adjust Gen. Journal Balance",GenJournalLine);

Example

There are no examples available.
Member of Lib.Library - ERM


ApplicationAmountRounding@3 Method

The procedure ApplicationAmountRounding is available in codeunit 131300.

Syntax

ApplicationAmountRounding@3(
    ApplicationAmount@1003 : Decimal ApplicationAmount, //Input parameter of type Decimal
    CurrencyCode@1002 : Code[10] CurrencyCode //Input parameter of type Code
);

Parameters

ApplicationAmount
Input parameter of type Decimal
CurrencyCode
Input parameter of type Code

Return Value

Decimal

Remarks

The relevant search keywords are: Application, Amount, Rounding.

For a clarification about how this function works, refer to the code listed below.

      // Round Application Entry Amount.
      Currency.InitRoundingPrecision;
      IF CurrencyCode <> '' THEN
        Currency.GET(CurrencyCode);

      // Case of Appln. Rounding Precision is equals to zero, use Amount Rounding Precision.
      IF Currency."Appln. Rounding Precision" = 0 THEN
        Currency."Appln. Rounding Precision" := Currency."Amount Rounding Precision";

      EXIT(ROUND(ApplicationAmount,Currency."Appln. Rounding Precision",Currency.InvoiceRoundingDirection));

Example

There are no examples available.
Member of Lib.Library - ERM


ApplyCustomerLedgerEntries@245 Method

The procedure ApplyCustomerLedgerEntries is available in codeunit 131300.

Syntax

ApplyCustomerLedgerEntries@245(
    ApplyingToDocType@1000 : Option ApplyingToDocType, //Input parameter of type Option
    AppliedDocType@1001 : Option AppliedDocType, //Input parameter of type Option
    ApplyingToDocNo@1002 : Code[20] ApplyingToDocNo, //Input parameter of type Code
    AppliedDocNo@1003 : Code[20] AppliedDocNo //Input parameter of type Code
);

Parameters

ApplyingToDocType
Input parameter of type Option
AppliedDocType
Input parameter of type Option
ApplyingToDocNo
Input parameter of type Code
AppliedDocNo
Input parameter of type Code

Remarks

The relevant search keywords are: Apply, Customer, Ledger, Entries.

For a clarification about how this function works, refer to the code listed below.

      FindCustomerLedgerEntry(ApplyingCustLedgerEntry,ApplyingToDocType,ApplyingToDocNo);
      ApplyingCustLedgerEntry.CALCFIELDS("Remaining Amount");
      SetApplyCustomerEntry(ApplyingCustLedgerEntry,ApplyingCustLedgerEntry."Remaining Amount");
      CustLedgerEntry.SETRANGE(Open,TRUE);
      FindCustomerLedgerEntry(CustLedgerEntry,AppliedDocType,AppliedDocNo);
      WITH CustLedgerEntry DO BEGIN
        CALCFIELDS("Remaining Amount");
        VALIDATE("Amount to Apply","Remaining Amount");
        MODIFY(TRUE);
      END;
      SetAppliestoIdCustomer(CustLedgerEntry);
      PostCustLedgerApplication(ApplyingCustLedgerEntry);

Example

The below example is extracted from the test automation codeunit 134000 to show one way of using this function.

      // Setup.
      CurrencyCode := CreateCurrency(0);  // Using 0 for Application Rounding Precision for Currency.
      LibraryERM.SetAddReportingCurrency(CurrencyCode);
      AppRounding := LibraryRandom.RandDec(5,2);
      DocumentNo := CreatePostApplyGenJournalLine(GenJournalLine,DocumentType,DocumentType2,CurrencyCode,Amount,AppRounding);
      UnapplyCustLedgerEntry(DocumentType2,GenJournalLine."Document No.");

      // Exercise. Apply already Unapplied Document from Customer Ledger Entry.
      LibraryERM.ApplyCustomerLedgerEntries(DocumentType2,DocumentType,GenJournalLine."Document No.",DocumentNo);

      // Verify: Verify Application Rounding Entry on Detailed Customer Ledger Entry and Additional Currency Amount in G/L Entry.
      VerifyApplnRoundingCustLedger(GenJournalLine."Document No.",-AppRounding);
      VerifyGLEntry(GenJournalLine."Document No.",CurrencyCode,GenJournalLine."Document Type"::" ",AppRounding);
Member of Lib.Library - ERM


ApplyVendorLedgerEntries@258 Method

The procedure ApplyVendorLedgerEntries is available in codeunit 131300.

Syntax

ApplyVendorLedgerEntries@258(
    ApplyingToDocType@1003 : Option ApplyingToDocType, //Input parameter of type Option
    AppliedDocType@1002 : Option AppliedDocType, //Input parameter of type Option
    ApplyingToDocNo@1001 : Code[20] ApplyingToDocNo, //Input parameter of type Code
    AppliedDocNo@1000 : Code[20] AppliedDocNo //Input parameter of type Code
);

Parameters

ApplyingToDocType
Input parameter of type Option
AppliedDocType
Input parameter of type Option
ApplyingToDocNo
Input parameter of type Code
AppliedDocNo
Input parameter of type Code

Remarks

The relevant search keywords are: Apply, Vendor, Ledger, Entries.

For a clarification about how this function works, refer to the code listed below.

      FindVendorLedgerEntry(ApplyingVendorLedgerEntry,ApplyingToDocType,ApplyingToDocNo);
      ApplyingVendorLedgerEntry.CALCFIELDS("Remaining Amount");
      SetApplyVendorEntry(ApplyingVendorLedgerEntry,ApplyingVendorLedgerEntry."Remaining Amount");
      VendorLedgerEntry.SETRANGE(Open,TRUE);
      FindVendorLedgerEntry(VendorLedgerEntry,AppliedDocType,AppliedDocNo);
      WITH VendorLedgerEntry DO BEGIN
        CALCFIELDS("Remaining Amount");
        VALIDATE("Amount to Apply");
        MODIFY(TRUE);
      END;
      SetAppliestoIdVendor(VendorLedgerEntry);
      PostVendLedgerApplication(ApplyingVendorLedgerEntry);

Example

The below example is extracted from the test automation codeunit 134008 to show one way of using this function.

      // [FEATURE] [Apply] [Unapply] [Vendor]
      // [SCENARIO 382503] Unapply Vendor Refund and Payment when application is done from posted entries
      Initialize;

      // [GIVEN] Vendor Refund and Payment are posted then applied
      PostGenJournalLines(
        GenJournalLine,GenJournalLine."Document Type"::Payment,GenJournalLine."Document Type"::Refund,
        GenJournalLine."Account Type"::Vendor,LibraryPurchase.CreateVendorNo,LibraryRandom.RandInt(500),1);
      LibraryERM.FindVendorLedgerEntry(VendorLedgerEntry,VendorLedgerEntry."Document Type"::Refund,GenJournalLine."Document No.");
      LibraryERM.SetAppliestoIdVendor(VendorLedgerEntry);

      VendorLedgerEntry.SETRANGE("Vendor No.",GenJournalLine."Account No.");
      VendorLedgerEntry.SETRANGE("Document Type",VendorLedgerEntry."Document Type"::Refund);
      VendorLedgerEntry.FINDFIRST;
      LibraryERM.ApplyVendorLedgerEntries(
        GenJournalLine."Document Type"::Payment,VendorLedgerEntry."Document Type"::Refund,
        GenJournalLine."Document No.",VendorLedgerEntry."Document No.");

      // [WHEN] Unapply Payment and Refund
      LibraryERM.UnapplyVendorLedgerEntry(VendorLedgerEntry);

      // [THEN] Vendor Ledger Entries are unapplied
      VerifyUnappliedDtldVendLedgEntry(GenJournalLine."Account No.",GenJournalLine."Document No.");
Member of Lib.Library - ERM


CheckPreview@175 Method

The procedure CheckPreview is available in codeunit 131300.

Syntax

CheckPreview@175(
    PaymentJournal@1000 : TestPage 256 PaymentJournal //Input parameter of type TestPage
);

Parameters

PaymentJournal
Input parameter of type TestPage

Return Value

Text

Remarks

The relevant search keywords are: Check, Preview.

For a clarification about how this function works, refer to the code listed below.

      CheckPreview.TRAP;
      PaymentJournal.PreviewCheck.INVOKE;
      EXIT(CheckPreview.AmountText.VALUE);

Example

The below example is extracted from the test automation codeunit 134987 to show one way of using this function.

      // Check Amount Text on Check Preview Page after Calculating Payment discount on Payment Journal.

      // Setup: Create General Journal Line with Invoice and Payment.
      Initialize;
      CreatePaymentTerms(PaymentTerms);
      VendorNo := CreateVendorWithPaymentTerms(PaymentTerms.Code);

      // Random Values Required to make amount more than 100;
      CreateGenJournalLine(GenJournalLine,GenJournalLine."Document Type"::Invoice,VendorNo,
        -(LibraryRandom.RandDec(100,2) + 100),GenJournalLine."Bank Payment Type"::"Computer Check");
      AppliedToDocNo := GenJournalLine."Document No.";
      LibraryERM.PostGeneralJnlLine(GenJournalLine);
      PaymentDiscountAmount := ROUND(GenJournalLine.Amount - (GenJournalLine.Amount * PaymentTerms."Discount %" / 100));

      CreateGenJournalLine(GenJournalLine,GenJournalLine."Document Type"::Payment,VendorNo,0,
        GenJournalLine."Bank Payment Type"::"Computer Check");
      ModifyGenJournalLine(GenJournalLine,-PaymentDiscountAmount,AppliedToDocNo);

      // Below function required for changing the Amount in Text.
      Check.InitTextVariable;
      Check.FormatNoText(NumberText,-PaymentDiscountAmount,'');

      // Exercise: Open Check Preview Page through Payment Journal.
      COMMIT;
      PaymentJournal.OPENEDIT;
      PaymentJournal.CurrentJnlBatchName.SETVALUE(GenJournalLine."Journal Batch Name");
      ActualValue := LibraryERM.CheckPreview(PaymentJournal);

      // Verify: Verify Amount Text on Check Preview Page.
      Assert.AreEqual(NumberText[1],ActualValue,'Amount message should be same.');
Member of Lib.Library - ERM


ClearAdjustPmtDiscInVATSetup@261 Method

The procedure ClearAdjustPmtDiscInVATSetup is available in codeunit 131300.

Syntax

ClearAdjustPmtDiscInVATSetup@261(
      //param element not supplied
);

Remarks

The relevant search keywords are: Clear, Adjust, Payment, Discount, In, VAT, Setup.

For a clarification about how this function works, refer to the code listed below.

      VATPostingSetup.SETRANGE("Adjust for Payment Discount",TRUE);
      IF VATPostingSetup.FINDSET THEN
        REPEAT
          VATPostingSetup.VALIDATE("Adjust for Payment Discount",FALSE);
          VATPostingSetup.MODIFY(TRUE);
        UNTIL VATPostingSetup.NEXT = 0;

Example

The below example is extracted from the test automation codeunit 134006 to show one way of using this function.

      // Verify that no VAT are entries creates when unapplies the entry without discount but with "Adjust For Payment Discount"

      // Setup: Set "Adjust For Payment Discount" option.
      Initialize;
      EmptyDocumentType := 0;
      LibraryPmtDiscSetup.SetAdjustForPaymentDisc(TRUE);

      // Exercise: Find and modify Reverse Charge VAT posting setup with "Adjust For Payment Disc." and post invoice.
      PostedDocumentNo :=
        CreatePostSalesInvWithReverseChargeVATAdjForPmtDisc(SalesLine);
      LibraryERM.FindCustomerLedgerEntry(CustLedgEntry,CustLedgEntry."Document Type"::Invoice,PostedDocumentNo);
      CustLedgEntry.CALCFIELDS("Amount (LCY)");

      // Exercise: Post and apply document with empty type.
      CreateGenJnlLineWithPostingGroups(GenJnlLine,SalesLine."Sell-to Customer No.",
        EmptyDocumentType,-CustLedgEntry."Amount (LCY)",SalesLine);
      GenJnlLine.VALIDATE("Applies-to Doc. Type",GenJnlLine."Applies-to Doc. Type"::Invoice);
      GenJnlLine.VALIDATE("Applies-to Doc. No.",PostedDocumentNo);
      GenJnlLine.MODIFY(TRUE);
      LibraryERM.PostGeneralJnlLine(GenJnlLine);

      // Exericse: Unapply the empty document application.
      LibraryERM.FindCustomerLedgerEntry(CustLedgEntry,EmptyDocumentType,GenJnlLine."Document No.");
      LibraryERM.UnapplyCustomerLedgerEntry(CustLedgEntry);

      // Verify: Make sure that no entries have been created on unapplication.
      VerifyNoVATEntriesOnUnapplication(EmptyDocumentType,GenJnlLine."Document No.");

      // Cleanup: Return back the old value of "Adjust For Payment Discount".
      LibraryPmtDiscSetup.ClearAdjustPmtDiscInVATSetup;
Member of Lib.Library - ERM


ClearGenJournalLines@87 Method

The procedure ClearGenJournalLines is available in codeunit 131300.

Syntax

ClearGenJournalLines@87(
    GenJournalBatch@1000 : Record 232 GenJournalBatch //Input parameter of type Record
);

Parameters

GenJournalBatch
Input parameter of type Record

Remarks

The relevant search keywords are: Clear, General, Journal, Lines.

For a clarification about how this function works, refer to the code listed below.

      GenJournalLine.SETRANGE("Journal Template Name",GenJournalBatch."Journal Template Name");
      GenJournalLine.SETRANGE("Journal Batch Name",GenJournalBatch.Name);
      GenJournalLine.DELETEALL(TRUE);

Example

The below example is extracted from the test automation codeunit 134000 to show one way of using this function.

      LibraryERM.SelectGenJnlBatch(GenJournalBatch);
      LibraryERM.ClearGenJournalLines(GenJournalBatch);
      LibraryERM.CreateGeneralJnlLine(
        GenJournalLine,GenJournalBatch."Journal Template Name",GenJournalBatch.Name,DocumentType,
        GenJournalLine."Account Type"::Customer,CustomerNo,Amount);
      GenJournalLine.VALIDATE("Posting Date",PostingDate);
      GenJournalLine.VALIDATE("Currency Code",CurrencyCode);
      GenJournalLine.MODIFY(TRUE);
Member of Lib.Library - ERM


ClearIntrastatJnlLines@113 Method

The procedure ClearIntrastatJnlLines is available in codeunit 131300.

Syntax

ClearIntrastatJnlLines@113(
    IntrastatJnlBatch@1000 : Record 262 IntrastatJnlBatch //Input parameter of type Record
);

Parameters

IntrastatJnlBatch
Input parameter of type Record

Remarks

The relevant search keywords are: Clear, Intrastat, Journal, Lines.

For a clarification about how this function works, refer to the code listed below.

      IntrastatJnlLine.SETRANGE("Journal Template Name",IntrastatJnlBatch."Journal Template Name");
      IntrastatJnlLine.SETRANGE("Journal Batch Name",IntrastatJnlBatch.Name);
      IntrastatJnlLine.DELETEALL(TRUE);

Example

The below example is extracted from the test automation codeunit 134150 to show one way of using this function.

      // Create and Get Intrastat Journal Lines. Take Random Ending Date based on WORKDATE.
      CreateIntrastatJnlLineAndGetEntries(
        IntrastatJnlLine,WORKDATE,CALCDATE('<' + FORMAT(LibraryRandom.RandInt(5)) + 'M>',WORKDATE));

      // Exercise: Delete all entries from Intrastat Journal Lines.
      IntrastatJnlBatch.GET(IntrastatJnlLine."Journal Template Name",IntrastatJnlLine."Journal Batch Name");
      LibraryERM.ClearIntrastatJnlLines(IntrastatJnlBatch);

      // Verify.
      VerifyNoIntrastatLineExist(IntrastatJnlBatch."Journal Template Name",IntrastatJnlBatch.Name);
Member of Lib.Library - ERM


ConvertCurrency@13 Method

The procedure ConvertCurrency is available in codeunit 131300.

Syntax

ConvertCurrency@13(
    Amount@1003 : Decimal Amount, //Input parameter of type Decimal
    FromCur@1002 : Code[10] FromCur, //Input parameter of type Code
    ToCur@1001 : Code[10] ToCur, //Input parameter of type Code
    ConversionDate@1000 : Date ConversionDate //Input parameter of type Date
);

Parameters

Amount
Input parameter of type Decimal
FromCur
Input parameter of type Code
ToCur
Input parameter of type Code
ConversionDate
Input parameter of type Date

Return Value

Decimal

Remarks

The relevant search keywords are: Convert, Currency.

For a clarification about how this function works, refer to the code listed below.

      // Converts an Amount from one currency to another.
      // A blank currency code means LCY.
      NewAmount := Amount;

      // Convert to LCY.
      IF FromCur <> '' THEN BEGIN
        FindExchRate(CurrencyExchangeRate,FromCur,ConversionDate);
        NewAmount := NewAmount * CurrencyExchangeRate."Relational Exch. Rate Amount" / CurrencyExchangeRate."Exchange Rate Amount";
      END;

      // Convert into new currency.
      IF ToCur <> '' THEN BEGIN
        FindExchRate(CurrencyExchangeRate2,ToCur,ConversionDate);
        NewAmount := NewAmount * CurrencyExchangeRate2."Exchange Rate Amount" / CurrencyExchangeRate2."Relational Exch. Rate Amount";
      END;

Example

The below example is extracted from the test automation codeunit 134000 to show one way of using this function.

      Currency.GET(CurrencyCode);
      GLEntry.SETRANGE("Document Type",DocumentType);
      GLEntry.SETRANGE("Document No.",DocumentNo);
      GLEntry.FINDFIRST;
      Assert.AreNearlyEqual(
        Amount / 2,LibraryERM.ConvertCurrency(Amount,'',CurrencyCode,WORKDATE),Currency."Amount Rounding Precision",
        'Amount must be equal');
Member of Lib.Library - ERM


CreateAccountMapping@140 Method

The procedure CreateAccountMapping is available in codeunit 131300.

Syntax

CreateAccountMapping@140(
    VAR TextToAccMapping@1000 : Record 1251 TextToAccMapping, //Reference parameter of type Record
    MappingText@1001 : Text[250] MappingText //Input parameter of type Text
);

Parameters

TextToAccMapping
Reference parameter of type Record
MappingText
Input parameter of type Text

Remarks

The relevant search keywords are: Create, Account, Mapping.

For a clarification about how this function works, refer to the code listed below.

      WITH TextToAccMapping DO BEGIN
        INIT;
        RecRef.GETTABLE(TextToAccMapping);
        VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,FIELDNO("Line No.")));
        VALIDATE("Mapping Text",MappingText);
        INSERT(TRUE);
      END;

Example

There are no examples available.
Member of Lib.Library - ERM


CreateAccountMappingCustomer@146 Method

The procedure CreateAccountMappingCustomer is available in codeunit 131300.

Syntax

CreateAccountMappingCustomer@146(
    VAR TextToAccMapping@1000 : Record 1251 TextToAccMapping, //Reference parameter of type Record
    MappingText@1001 : Text[250] MappingText, //Input parameter of type Text
    SourceNo@1004 : Code[20] SourceNo //Input parameter of type Code
);

Parameters

TextToAccMapping
Reference parameter of type Record
MappingText
Input parameter of type Text
SourceNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Account, Mapping, Customer.

For a clarification about how this function works, refer to the code listed below.

      WITH TextToAccMapping DO BEGIN
        CreateAccountMapping(TextToAccMapping,MappingText);
        VALIDATE("Bal. Source Type","Bal. Source Type"::Customer);
        VALIDATE("Bal. Source No.",SourceNo);
        MODIFY(TRUE);
      END;

Example

The below example is extracted from the test automation codeunit 134261 to show one way of using this function.

      Initialize;

      // Setup
      CreateCustomer(Customer);
      TextMapper := COPYSTR(GenerateRandomSmallLetters(20),1,20);
      Amount := LibraryRandom.RandDecInRange(1,1000,2);
      CreateAndPostSalesInvoiceWithOneLine(Customer."No.",GenerateExtDocNo,Amount);

      CreateBankReconciliationAmountTolerance(BankAccReconciliation,0);
      CreateBankReconciliationLine(BankAccReconciliation,BankAccReconciliationLine,Amount * 2,TextMapper,'');

      // Exercise
      LibraryERM.CreateAccountMappingCustomer(TextToAccMapping,TextMapper,Customer."No.");

      RunMatch(BankAccReconciliation,TRUE);

      // Verify
      VerifyEntryApplied(BankAccReconciliationLine,TRUE);
      VerifyTextEntryApplied(BankAccReconciliationLine."Statement Line No.");
Member of Lib.Library - ERM


CreateAccountMappingGLAccount@148 Method

The procedure CreateAccountMappingGLAccount is available in codeunit 131300.

Syntax

CreateAccountMappingGLAccount@148(
    VAR TextToAccMapping@1000 : Record 1251 TextToAccMapping, //Reference parameter of type Record
    MappingText@1001 : Text[250] MappingText, //Input parameter of type Text
    CreditNo@1004 : Code[20] CreditNo, //Input parameter of type Code
    DebitNo@1003 : Code[20] DebitNo //Input parameter of type Code
);

Parameters

TextToAccMapping
Reference parameter of type Record
MappingText
Input parameter of type Text
CreditNo
Input parameter of type Code
DebitNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Account, Mapping, General Ledger, Account.

For a clarification about how this function works, refer to the code listed below.

      WITH TextToAccMapping DO BEGIN
        CreateAccountMapping(TextToAccMapping,MappingText);
        VALIDATE("Bal. Source Type","Bal. Source Type"::"G/L Account");
        VALIDATE("Debit Acc. No.",DebitNo);
        VALIDATE("Credit Acc. No.",CreditNo);
        MODIFY(TRUE);
      END;

Example

The below example is extracted from the test automation codeunit 134261 to show one way of using this function.

      Initialize;

      // Setup
      CreateCustomer(Customer);
      TextMapper := COPYSTR(GenerateRandomSmallLetters(20),1,20);
      Amount := LibraryRandom.RandDecInRange(1,1000,2);
      CreateAndPostSalesInvoiceWithOneLine(Customer."No.",GenerateExtDocNo,Amount);

      CreateBankReconciliationAmountTolerance(BankAccReconciliation,0);
      CreateBankReconciliationLine(BankAccReconciliation,BankAccReconciliationLine,Amount * 2,TextMapper,'');

      // Exercise
      LibraryERM.CreateAccountMappingGLAccount(TextToAccMapping,TextMapper,LibraryERM.CreateGLAccountNo,'');

      RunMatch(BankAccReconciliation,TRUE);

      // Verify
      VerifyEntryApplied(BankAccReconciliationLine,TRUE);
      VerifyTextEntryApplied(BankAccReconciliationLine."Statement Line No.");
Member of Lib.Library - ERM


CreateAccountMappingVendor@147 Method

The procedure CreateAccountMappingVendor is available in codeunit 131300.

Syntax

CreateAccountMappingVendor@147(
    VAR TextToAccMapping@1000 : Record 1251 TextToAccMapping, //Reference parameter of type Record
    MappingText@1001 : Text[250] MappingText, //Input parameter of type Text
    SourceNo@1004 : Code[20] SourceNo //Input parameter of type Code
);

Parameters

TextToAccMapping
Reference parameter of type Record
MappingText
Input parameter of type Text
SourceNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Account, Mapping, Vendor.

For a clarification about how this function works, refer to the code listed below.

      WITH TextToAccMapping DO BEGIN
        CreateAccountMapping(TextToAccMapping,MappingText);
        VALIDATE("Bal. Source Type","Bal. Source Type"::Vendor);
        VALIDATE("Bal. Source No.",SourceNo);
        MODIFY(TRUE);
      END;

Example

The below example is extracted from the test automation codeunit 134261 to show one way of using this function.

      Initialize;

      // Setup
      CreateVendor(Vendor);
      TextMapper := COPYSTR(GenerateRandomSmallLetters(20),1,20);
      Amount := LibraryRandom.RandDecInRange(1,1000,2);
      CreateAndPostPurchaseInvoiceWithOneLine(Vendor."No.",GenerateExtDocNo,Amount);

      CreateBankReconciliationAmountTolerance(BankAccReconciliation,0);
      CreateBankReconciliationLine(BankAccReconciliation,BankAccReconciliationLine,-Amount * 2,TextMapper,'');

      // Exercise
      LibraryERM.CreateAccountMappingVendor(TextToAccMapping,TextMapper,Vendor."No.");

      RunMatch(BankAccReconciliation,TRUE);

      // Verify
      VerifyEntryApplied(BankAccReconciliationLine,TRUE);
      VerifyTextEntryApplied(BankAccReconciliationLine."Statement Line No.");
Member of Lib.Library - ERM


CreateAccScheduleLine@39 Method

The procedure CreateAccScheduleLine is available in codeunit 131300.

Syntax

CreateAccScheduleLine@39(
    VAR AccScheduleLine@1001 : Record 85 AccScheduleLine, //Reference parameter of type Record
    ScheduleName@1000 : Code[10] ScheduleName //Input parameter of type Code
);

Parameters

AccScheduleLine
Reference parameter of type Record
ScheduleName
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Account, Schedule, Line.

For a clarification about how this function works, refer to the code listed below.

      AccScheduleLine.INIT;
      AccScheduleLine.VALIDATE("Schedule Name",ScheduleName);
      RecRef.GETTABLE(AccScheduleLine);
      AccScheduleLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,AccScheduleLine.FIELDNO("Line No.")));
      AccScheduleLine.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134480 to show one way of using this function.

      // Exercise: Create Account Schedule Name and Line.
      LibraryERM.CreateAccScheduleName(AccScheduleName);
      LibraryERM.CreateAccScheduleLine(AccScheduleLine,AccScheduleName.Name);
      AccScheduleLine.VALIDATE("Row No.",FORMAT(LibraryRandom.RandInt(5)));
      AccScheduleLine.VALIDATE(Totaling,Totaling);
      AccScheduleLine.MODIFY(TRUE);
      LibraryERM.CreateColumnLayoutName(ColumnLayoutName);
      LibraryERM.CreateColumnLayout(ColumnLayout,ColumnLayoutName.Name);
      LibraryVariableStorage.Enqueue(ColumnLayoutName.Name);
      LibraryVariableStorage.Enqueue(AccScheduleLine."Row No.");
      LibraryVariableStorage.Enqueue(UseAdditionalCurrency);
      LibraryVariableStorage.Enqueue(ExpectedAmount);

      // Verify: Open Account Schedule Overview Matrix from Account Schedule Name through AccScheduleOverviewPageHandler.
      AccountScheduleNames.OPENVIEW;
      AccountScheduleNames.FILTER.SETFILTER(Name,AccScheduleName.Name);
      AccountSchedule.TRAP;
      AccountScheduleNames.EditAccountSchedule.INVOKE;
      AccountSchedule.Overview.INVOKE;
Member of Lib.Library - ERM


CreateAccScheduleName@32 Method

The procedure CreateAccScheduleName is available in codeunit 131300.

Syntax

CreateAccScheduleName@32(
    VAR AccScheduleName@1000 : Record 84 AccScheduleName //Reference parameter of type Record
);

Parameters

AccScheduleName
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Account, Schedule, Name.

For a clarification about how this function works, refer to the code listed below.

      AccScheduleName.INIT;
      AccScheduleName.VALIDATE(
        Name,
        COPYSTR(LibraryUtility.GenerateRandomCode(AccScheduleName.FIELDNO(Name),DATABASE::"Acc. Schedule Name"),
          1,LibraryUtility.GetFieldLength(DATABASE::"Acc. Schedule Name",AccScheduleName.FIELDNO(Name))));
      AccScheduleName.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134480 to show one way of using this function.

      // Exercise: Create Account Schedule Name and Line.
      LibraryERM.CreateAccScheduleName(AccScheduleName);
      LibraryERM.CreateAccScheduleLine(AccScheduleLine,AccScheduleName.Name);
      AccScheduleLine.VALIDATE("Row No.",FORMAT(LibraryRandom.RandInt(5)));
      AccScheduleLine.VALIDATE(Totaling,Totaling);
      AccScheduleLine.MODIFY(TRUE);
      LibraryERM.CreateColumnLayoutName(ColumnLayoutName);
      LibraryERM.CreateColumnLayout(ColumnLayout,ColumnLayoutName.Name);
      LibraryVariableStorage.Enqueue(ColumnLayoutName.Name);
      LibraryVariableStorage.Enqueue(AccScheduleLine."Row No.");
      LibraryVariableStorage.Enqueue(UseAdditionalCurrency);
      LibraryVariableStorage.Enqueue(ExpectedAmount);

      // Verify: Open Account Schedule Overview Matrix from Account Schedule Name through AccScheduleOverviewPageHandler.
      AccountScheduleNames.OPENVIEW;
      AccountScheduleNames.FILTER.SETFILTER(Name,AccScheduleName.Name);
      AccountSchedule.TRAP;
      AccountScheduleNames.EditAccountSchedule.INVOKE;
      AccountSchedule.Overview.INVOKE;
Member of Lib.Library - ERM


CreateAnalysisColumn@122 Method

The procedure CreateAnalysisColumn is available in codeunit 131300.

Syntax

CreateAnalysisColumn@122(
    VAR AnalysisColumn@1001 : Record 7118 AnalysisColumn, //Reference parameter of type Record
    AnalysisArea@1003 : Option AnalysisArea, //Input parameter of type Option
    AnalysisColumnTemplate@1002 : Code[10] AnalysisColumnTemplate //Input parameter of type Code
);

Parameters

AnalysisColumn
Reference parameter of type Record
AnalysisArea
Input parameter of type Option
AnalysisColumnTemplate
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Analysis, Column.

For a clarification about how this function works, refer to the code listed below.

      AnalysisColumn.INIT;
      AnalysisColumn.VALIDATE("Analysis Area",AnalysisArea);
      AnalysisColumn.VALIDATE("Analysis Column Template",AnalysisColumnTemplate);
      RecRef.GETTABLE(AnalysisColumn);
      AnalysisColumn.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,AnalysisColumn.FIELDNO("Line No.")));
      AnalysisColumn.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134327 to show one way of using this function.

      // [FEATURE] [UI]
      // [SCENARIO 201736] "Column Header" is placed as column caption in Purchase Analysis Matrix
      Initialize;

      // [GIVEN] Analysis Report Name "N" for Purchase Analysis Area
      LibraryInventory.CreateAnalysisReportName(AnalysisReportName,AnalysisReportName."Analysis Area"::Purchase);
      AnalysisLineTemplateName := CreateAnalysisLineWithTypeVendor(AnalysisReportName."Analysis Area"::Purchase,CreateVendor);

      // [GIVEN] Analysis Column defined with "Column No." = '' and "Column Header" = "Col"
      LibraryInventory.CreateAnalysisColumnTemplate(AnalysisColumnTemplate,AnalysisReportName."Analysis Area"::Purchase);
      LibraryERM.CreateAnalysisColumn(AnalysisColumn,AnalysisReportName."Analysis Area"::Purchase,AnalysisColumnTemplate.Name);
      AnalysisColumn."Column No." := '';
      AnalysisColumn."Column Header" := LibraryUtility.GenerateGUID;
      AnalysisColumn.MODIFY;

      LibraryVariableStorage.Enqueue(0);
      LibraryVariableStorage.Enqueue(AnalysisColumn."Column Header");

      // [WHEN] Open Analysis Report Purchase for Analysis Report Name "N"
      OpenAnalysisReportPurchase(AnalysisReportName.Name,AnalysisLineTemplateName,AnalysisColumnTemplate.Name);

      // [THEN] Column "Col" is visible and has caption "Col"
      // Verification done in PurchaseAnalysisMatrixRequestPageHandler.
Member of Lib.Library - ERM


CreateAnalysisView@80 Method

The procedure CreateAnalysisView is available in codeunit 131300.

Syntax

CreateAnalysisView@80(
    VAR AnalysisView@1000 : Record 363 AnalysisView //Reference parameter of type Record
);

Parameters

AnalysisView
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Analysis, View.

For a clarification about how this function works, refer to the code listed below.

      AnalysisView.INIT;
      AnalysisView.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(AnalysisView.FIELDNO(Code),DATABASE::"Analysis View"),
          1,
          LibraryUtility.GetFieldLength(DATABASE::"Analysis View",AnalysisView.FIELDNO(Code))));

      // Validating Name as Code because value is not important.
      AnalysisView.VALIDATE(Name,AnalysisView.Code);
      AnalysisView.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134066 to show one way of using this function.

      // Setup.
      Initialize;

      // Exercise: Create Analysis View.
      LibraryERM.CreateAnalysisView(AnalysisView);
      AnalysisView.VALIDATE(Blocked,TRUE); // As  Blocked True.
      AnalysisView.MODIFY(TRUE);
      ASSERTERROR AnalysisView.VALIDATE("Dimension 2 Code",CreateDimension);

      // Verify: Verify Error Message.
      Assert.ExpectedError(STRSUBSTNO(Expected,AnalysisView.Code));
Member of Lib.Library - ERM


CreateAssesseeCode@1500009 Method

The procedure CreateAssesseeCode is available in codeunit 131300.

Syntax

CreateAssesseeCode@1500009(
    VAR AssesseeCode@1500000 : Record 13727 AssesseeCode //Reference parameter of type Record
);

Parameters

AssesseeCode
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Assessee, Code.

For a clarification about how this function works, refer to the code listed below.

      AssesseeCode.INIT;
      AssesseeCode.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(AssesseeCode.FIELDNO(Code),DATABASE::"Assessee Code"),
          1,
          LibraryUtility.GetFieldLength(DATABASE::"Assessee Code",AssesseeCode.FIELDNO(Code))));
      AssesseeCode.VALIDATE(Description,AssesseeCode.Code); // Validating Code as Description because value is not important.
      AssesseeCode.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 144020 to show one way of using this function.

      // Create Setup, Post General Journal Lines and Verify Posted Entries.
      Initialize;
      CreateIncomeTaxAccountingPeriod;
      CreateDeductoryCodeAndUpdateOnCompanyInformation;
      Amount := LibraryRandom.RandDec(1000,2); // For Random Value.
      LibraryERM.CreateAssesseeCode(AssesseeCode); // Generate Assessee Code.
      CreateTDSNatureDeductionAndTDSSetup(TDSNatureDeduction,TDSSetup,TDSNatureDeduction."TDS Group"::Contractor,AssesseeCode.Code);
      CreateTDSNatureDeductionAndTDSSetup(TDSNatureDeduction2,TDSSetup,TDSNatureDeduction2."TDS Group"::Others,AssesseeCode.Code);
      CreateNODNOCSetup(
        NODNOCHeader,NODNOCHeader.Type::Vendor,CreateVendor,AssesseeCode.Code,TDSNatureDeduction.Code,TDSNatureDeduction2.Code);

      // Exercise: Create & Post Bank Payment Voucher.
      DocumentNo := CreateAndPostBankPaymentVoucher(Amount,NODNOCHeader."No.",TDSNatureDeduction.Code,TDSNatureDeduction2.Code);

      // Verify: Verify Credit Amount On GL Entry.
      VerifyGLEntry(DocumentType::Payment,DocumentNo,Amount);
Member of Lib.Library - ERM


CreateBankAccAndLCCrLimit@1500020 Method

The procedure CreateBankAccAndLCCrLimit is available in codeunit 131300.

Syntax

CreateBankAccAndLCCrLimit@1500020(
      //param element not supplied
);

Return Value

Code[20]

Remarks

The relevant search keywords are: Crediteate, Bank, Account, LC, Credit, Limit.

For a clarification about how this function works, refer to the code listed below.

      CreateBankAccount(BankAccount);
      WITH BankLCLimitDetails DO BEGIN
        INIT;
        VALIDATE("Bank No.",BankAccount."No.");
        VALIDATE("From Date",WORKDATE);
        VALIDATE("To Date",CALCDATE('<1Y>',WORKDATE));
        VALIDATE(Amount,LibraryRandom.RandDec(1000000,1));
        INSERT(TRUE);
      END;
      EXIT(BankLCLimitDetails."Bank No.");

Example

The below example is extracted from the test automation codeunit 144069 to show one way of using this function.

      LibraryPurchase.CreateVendor(Vendor);
      LibrarySales.CreateCustomer(Customer);
      BankAcNo := LibraryERM.CreateBankAccAndLCCrLimit;
      CreateLCDetailsPurchase(LCDetail,Vendor."No.",BankAcNo,1);
      CurrencyCode := LibraryERM.CreateCurrencyWithRandomExchRates;
      CreateLCDetailsSales(LCDetail1,Customer."No.",BankAcNo,CurrencyCode,0);
      EXIT(CurrencyCode);
Member of Lib.Library - ERM


CreateBankAccount@1 Method

The procedure CreateBankAccount is available in codeunit 131300.

Syntax

CreateBankAccount@1(
    VAR BankAccount@1000 : Record 270 BankAccount //Reference parameter of type Record
);

Parameters

BankAccount
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Bank, Account.

For a clarification about how this function works, refer to the code listed below.

      FindBankAccountPostingGroup(BankAccountPostingGroup);
      BankAccount.INIT;
      BankAccount.VALIDATE("No.",LibraryUtility.GenerateRandomCode(BankAccount.FIELDNO("No."),DATABASE::"Bank Account"));
      BankAccount.VALIDATE(Name,BankAccount."No.");  // Validating No. as Name because value is not important.
      BankAccount.INSERT(TRUE);
      BankAccount.VALIDATE("Bank Acc. Posting Group",BankAccountPostingGroup.Code);
      BankAccount.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134006 to show one way of using this function.

      LibraryERM.CreateBankAccount(BankAccount);
      WITH BankAccount DO BEGIN
        VALIDATE("Currency Code",CurrencyCode);
        MODIFY;
        EXIT("No.");
      END;
Member of Lib.Library - ERM


CreateBankAccountNo@250 Method

The procedure CreateBankAccountNo is available in codeunit 131300.

Syntax

CreateBankAccountNo@250(
      //param element not supplied
);

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Bank, Account, No.

For a clarification about how this function works, refer to the code listed below.

      CreateBankAccount(BankAccount);
      EXIT(BankAccount."No.");

Example

The below example is extracted from the test automation codeunit 134141 to show one way of using this function.

      // [FEATURE] [G/L Account]
      // [SCENARIO 380298] VAT Entry shoud be created after posting Bank Acc. Reconcilation Line with G/L Account with VAT
      Initialize;

      // [GIVEN] G/L Account with VAT = 10%
      GLAccountNo := CreateGLAccountWithVATPostingSetup(VATRate);
      BankAccountNo := LibraryERM.CreateBankAccountNo;

      // [GIVEN] Bank Account Reconciliation for G/L Account with Amount = 100 (including VAT)
      CreateApplyBankAccReconcilationLine(BankAccReconciliation,BankAccReconciliationLine,
        BankAccReconciliationLine."Account Type"::"G/L Account",
        GLAccountNo,LibraryRandom.RandIntInRange(50,100),BankAccountNo);
      BankAccReconciliationLine.TransferRemainingAmountToAccount;

      // [WHEN] Post Bank Acc. Reconcilation Line
      LibraryERM.PostBankAccReconciliation(BankAccReconciliation);

      // [THEN] Known failure: error "There is no VAT Entry within the filter..."
      VATEntry.SETRANGE("Document No.",BankAccReconciliation."Statement No.");
      ASSERTERROR VATEntry.FINDFIRST;
      Assert.ExpectedError(VATEntryErr);
Member of Lib.Library - ERM


CreateBankAccountPostingGroup@152 Method

The procedure CreateBankAccountPostingGroup is available in codeunit 131300.

Syntax

CreateBankAccountPostingGroup@152(
    VAR BankAccountPostingGroup@1001 : Record 277 BankAccountPostingGroup //Reference parameter of type Record
);

Parameters

BankAccountPostingGroup
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Bank, Account, Posting, Group.

For a clarification about how this function works, refer to the code listed below.

      BankAccountPostingGroup.INIT;
      BankAccountPostingGroup.VALIDATE(
        Code,
        COPYSTR(LibraryUtility.GenerateRandomCode(BankAccountPostingGroup.FIELDNO(Code),DATABASE::"Bank Account Posting Group"),
          1,LibraryUtility.GetFieldLength(DATABASE::"Bank Account Posting Group",BankAccountPostingGroup.FIELDNO(Code))));
      BankAccountPostingGroup.INSERT(TRUE);

Example

There are no examples available.
Member of Lib.Library - ERM


CreateBankAccReconciliation@44 Method

The procedure CreateBankAccReconciliation is available in codeunit 131300.

Syntax

CreateBankAccReconciliation@44(
    VAR BankAccReconciliation@1000 : Record 273 BankAccReconciliation, //Reference parameter of type Record
    BankAccountNo@1001 : Code[20] BankAccountNo, //Input parameter of type Code
    StatementType@1002 : Option StatementType //Input parameter of type Option
);

Parameters

BankAccReconciliation
Reference parameter of type Record
BankAccountNo
Input parameter of type Code
StatementType
Input parameter of type Option

Remarks

The relevant search keywords are: Create, Bank, Account, Reconciliation.

For a clarification about how this function works, refer to the code listed below.

      BankAccReconciliation.INIT;
      BankAccReconciliation.VALIDATE("Statement Type",StatementType);
      BankAccReconciliation.VALIDATE("Bank Account No.",BankAccountNo);
      BankAccReconciliation.INSERT(TRUE);
      BankAccReconciliation.TESTFIELD("Statement No.");

Example

The below example is extracted from the test automation codeunit 134134 to show one way of using this function.

      // Take Random Statement No. Value.
      LibraryERM.CreateBankAccReconciliation(
        BankAccReconciliation,BankAccountNo,BankAccReconciliation."Statement Type"::"Bank Reconciliation");
      BankAccReconciliation.VALIDATE("Statement Date",StatementDate);
      BankAccReconciliation.MODIFY(TRUE);
      SuggestBankReconcltn(BankAccReconciliation);
Member of Lib.Library - ERM


CreateBankAccReconciliationLn@76 Method

The procedure CreateBankAccReconciliationLn is available in codeunit 131300.

Syntax

CreateBankAccReconciliationLn@76(
    VAR BankAccReconciliationLine@1000 : Record 274 BankAccReconciliationLine, //Reference parameter of type Record
    BankAccReconciliation@1003 : Record 273 BankAccReconciliation //Input parameter of type Record
);

Parameters

BankAccReconciliationLine
Reference parameter of type Record
BankAccReconciliation
Input parameter of type Record

Remarks

The relevant search keywords are: Create, Bank, Account, Reconciliation, Ln.

For a clarification about how this function works, refer to the code listed below.

      BankAccReconciliationLine.INIT;
      BankAccReconciliationLine.VALIDATE("Bank Account No.",BankAccReconciliation."Bank Account No.");
      BankAccReconciliationLine.VALIDATE("Statement No.",BankAccReconciliation."Statement No.");
      BankAccReconciliationLine.VALIDATE("Statement Type",BankAccReconciliation."Statement Type");
      RecRef.GETTABLE(BankAccReconciliationLine);
      BankAccReconciliationLine.VALIDATE(
        "Statement Line No.",LibraryUtility.GetNewLineNo(RecRef,BankAccReconciliationLine.FIELDNO("Statement Line No.")));
      BankAccReconciliationLine.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134141 to show one way of using this function.

      LibraryERM.CreateBankAccReconciliation(
        BankAccReconciliation,BankAccountNo,BankAccReconciliation."Statement Type"::"Payment Application");
      LibraryERM.CreateBankAccReconciliationLn(BankAccReconciliationLine,BankAccReconciliation);
      BankAccReconciliationLine.VALIDATE("Account Type",AccountType);
      BankAccReconciliationLine.VALIDATE("Account No.",AccountNo);
      BankAccReconciliationLine.VALIDATE("Document No.",
        LibraryUtility.GenerateRandomCode(BankAccReconciliationLine.FIELDNO("Document No."),DATABASE::"Bank Acc. Reconciliation Line"));
      BankAccReconciliationLine.VALIDATE("Statement Amount",StatementAmount);
      BankAccReconciliationLine.VALIDATE("Transaction Date",WORKDATE);
      BankAccReconciliationLine.VALIDATE(Description,AccountNo);
      BankAccReconciliationLine.MODIFY(TRUE);
Member of Lib.Library - ERM


CreateBusinessUnit@178 Method

The procedure CreateBusinessUnit is available in codeunit 131300.

Syntax

CreateBusinessUnit@178(
    VAR BusinessUnit@1000 : Record 220 BusinessUnit //Reference parameter of type Record
);

Parameters

BusinessUnit
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Business, Unit.

For a clarification about how this function works, refer to the code listed below.

      BusinessUnit.INIT;
      BusinessUnit.VALIDATE(Code,LibraryUtility.GenerateRandomCode(BusinessUnit.FIELDNO(Code),DATABASE::"Business Unit"));
      BusinessUnit.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134092 to show one way of using this function.

      LibraryERM.CreateBusinessUnit(BusinessUnit);
      BusinessUnit.VALIDATE("Company Name",COMPANYNAME);
      BusinessUnit.VALIDATE("Residual Account",LibraryERM.CreateGLAccountNo);
      BusinessUnit.VALIDATE("Data Source",DataSource);
      BusinessUnit.MODIFY(TRUE);
Member of Lib.Library - ERM


CreateChangeLogField@125 Method

The procedure CreateChangeLogField is available in codeunit 131300.

Syntax

CreateChangeLogField@125(
    VAR ChangeLogSetupField@1001 : Record 404 ChangeLogSetupField, //Reference parameter of type Record
    TableNo@1000 : Integer TableNo, //Input parameter of type Integer
    FieldNo@1002 : Integer FieldNo //Input parameter of type Integer
);

Parameters

ChangeLogSetupField
Reference parameter of type Record
TableNo
Input parameter of type Integer
FieldNo
Input parameter of type Integer

Remarks

The relevant search keywords are: Create, Change, Log, Field.

For a clarification about how this function works, refer to the code listed below.

      ChangeLogSetupField.INIT;
      ChangeLogSetupField.VALIDATE("Table No.",TableNo);
      ChangeLogSetupField.VALIDATE("Field No.",FieldNo);
      ChangeLogSetupField.INSERT(TRUE);

Example

There are no examples available.
Member of Lib.Library - ERM


CreateChangeLogTable@105 Method

The procedure CreateChangeLogTable is available in codeunit 131300.

Syntax

CreateChangeLogTable@105(
    VAR ChangeLogSetupTable@1001 : Record 403 ChangeLogSetupTable, //Reference parameter of type Record
    TableNo@1000 : Integer TableNo //Input parameter of type Integer
);

Parameters

ChangeLogSetupTable
Reference parameter of type Record
TableNo
Input parameter of type Integer

Remarks

The relevant search keywords are: Create, Change, Log, Table.

For a clarification about how this function works, refer to the code listed below.

      ChangeLogSetupTable.INIT;
      ChangeLogSetupTable.VALIDATE("Table No.",TableNo);
      ChangeLogSetupTable.INSERT(TRUE);

Example

There are no examples available.
Member of Lib.Library - ERM


CreateColumnLayout@38 Method

The procedure CreateColumnLayout is available in codeunit 131300.

Syntax

CreateColumnLayout@38(
    VAR ColumnLayout@1001 : Record 334 ColumnLayout, //Reference parameter of type Record
    ColumnLayoutName@1000 : Code[10] ColumnLayoutName //Input parameter of type Code
);

Parameters

ColumnLayout
Reference parameter of type Record
ColumnLayoutName
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Column, Layout.

For a clarification about how this function works, refer to the code listed below.

      ColumnLayout.INIT;
      ColumnLayout.VALIDATE("Column Layout Name",ColumnLayoutName);
      RecRef.GETTABLE(ColumnLayout);
      ColumnLayout.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,ColumnLayout.FIELDNO("Line No.")));
      ColumnLayout.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134480 to show one way of using this function.

      // Exercise: Create Account Schedule Name and Line.
      LibraryERM.CreateAccScheduleName(AccScheduleName);
      LibraryERM.CreateAccScheduleLine(AccScheduleLine,AccScheduleName.Name);
      AccScheduleLine.VALIDATE("Row No.",FORMAT(LibraryRandom.RandInt(5)));
      AccScheduleLine.VALIDATE(Totaling,Totaling);
      AccScheduleLine.MODIFY(TRUE);
      LibraryERM.CreateColumnLayoutName(ColumnLayoutName);
      LibraryERM.CreateColumnLayout(ColumnLayout,ColumnLayoutName.Name);
      LibraryVariableStorage.Enqueue(ColumnLayoutName.Name);
      LibraryVariableStorage.Enqueue(AccScheduleLine."Row No.");
      LibraryVariableStorage.Enqueue(UseAdditionalCurrency);
      LibraryVariableStorage.Enqueue(ExpectedAmount);

      // Verify: Open Account Schedule Overview Matrix from Account Schedule Name through AccScheduleOverviewPageHandler.
      AccountScheduleNames.OPENVIEW;
      AccountScheduleNames.FILTER.SETFILTER(Name,AccScheduleName.Name);
      AccountSchedule.TRAP;
      AccountScheduleNames.EditAccountSchedule.INVOKE;
      AccountSchedule.Overview.INVOKE;
Member of Lib.Library - ERM


CreateColumnLayoutName@36 Method

The procedure CreateColumnLayoutName is available in codeunit 131300.

Syntax

CreateColumnLayoutName@36(
    VAR ColumnLayoutName@1000 : Record 333 ColumnLayoutName //Reference parameter of type Record
);

Parameters

ColumnLayoutName
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Column, Layout, Name.

For a clarification about how this function works, refer to the code listed below.

      ColumnLayoutName.INIT;
      ColumnLayoutName.VALIDATE(
        Name,
        COPYSTR(LibraryUtility.GenerateRandomCode(ColumnLayoutName.FIELDNO(Name),DATABASE::"Column Layout Name"),
          1,LibraryUtility.GetFieldLength(DATABASE::"Column Layout Name",ColumnLayoutName.FIELDNO(Name))));
      ColumnLayoutName.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134480 to show one way of using this function.

      // Exercise: Create Account Schedule Name and Line.
      LibraryERM.CreateAccScheduleName(AccScheduleName);
      LibraryERM.CreateAccScheduleLine(AccScheduleLine,AccScheduleName.Name);
      AccScheduleLine.VALIDATE("Row No.",FORMAT(LibraryRandom.RandInt(5)));
      AccScheduleLine.VALIDATE(Totaling,Totaling);
      AccScheduleLine.MODIFY(TRUE);
      LibraryERM.CreateColumnLayoutName(ColumnLayoutName);
      LibraryERM.CreateColumnLayout(ColumnLayout,ColumnLayoutName.Name);
      LibraryVariableStorage.Enqueue(ColumnLayoutName.Name);
      LibraryVariableStorage.Enqueue(AccScheduleLine."Row No.");
      LibraryVariableStorage.Enqueue(UseAdditionalCurrency);
      LibraryVariableStorage.Enqueue(ExpectedAmount);

      // Verify: Open Account Schedule Overview Matrix from Account Schedule Name through AccScheduleOverviewPageHandler.
      AccountScheduleNames.OPENVIEW;
      AccountScheduleNames.FILTER.SETFILTER(Name,AccScheduleName.Name);
      AccountSchedule.TRAP;
      AccountScheduleNames.EditAccountSchedule.INVOKE;
      AccountSchedule.Overview.INVOKE;
Member of Lib.Library - ERM


CreateCountryRegion@82 Method

The procedure CreateCountryRegion is available in codeunit 131300.

Syntax

CreateCountryRegion@82(
    VAR CountryRegion@1000 : Record 9 CountryRegion //Reference parameter of type Record
);

Parameters

CountryRegion
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Country, Region.

For a clarification about how this function works, refer to the code listed below.

      CountryRegion.INIT;
      CountryRegion.VALIDATE(
        Code,
        COPYSTR(LibraryUtility.GenerateRandomCode(CountryRegion.FIELDNO(Code),DATABASE::"Country/Region"),
          1,LibraryUtility.GetFieldLength(DATABASE::"Country/Region",CountryRegion.FIELDNO(Code))));
      CountryRegion.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134012 to show one way of using this function.

      ReminderTerms.FINDFIRST;
      LibrarySales.CreateCustomer(Customer);
      LibraryERM.CreatePaymentMethod(PaymentMethod);
      LibraryERM.CreateCountryRegion(CountryRegion);
      Customer.VALIDATE("Payment Method Code",PaymentMethod.Code);
      Customer.VALIDATE("Reminder Terms Code",ReminderTerms.Code);
      Customer.VALIDATE("Country/Region Code",CountryRegion.Code);
      Customer.MODIFY(TRUE);
      EXIT(Customer."No.");
Member of Lib.Library - ERM


CreateCountryRegionWithIntrastatCode@226 Method

The procedure CreateCountryRegionWithIntrastatCode is available in codeunit 131300.

Syntax

CreateCountryRegionWithIntrastatCode@226(
      //param element not supplied
);

Return Value

Code[10]

Remarks

The relevant search keywords are: Create, Country, Region, Intrastat, Code.

For a clarification about how this function works, refer to the code listed below.

      CreateCountryRegion(CountryRegion);
      CountryRegion.VALIDATE(Name,LibraryUtility.GenerateGUID);
      CountryRegion.VALIDATE("Intrastat Code",LibraryUtility.GenerateGUID);
      CountryRegion.MODIFY(TRUE);
      EXIT(CountryRegion.Code);

Example

There are no examples available.
Member of Lib.Library - ERM


CreateCurrency@8 Method

The procedure CreateCurrency is available in codeunit 131300.

Syntax

CreateCurrency@8(
    VAR Currency@1000 : Record 4 Currency //Reference parameter of type Record
);

Parameters

Currency
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Currency.

For a clarification about how this function works, refer to the code listed below.

      Currency.INIT;
      Currency.VALIDATE(Code,LibraryUtility.GenerateRandomCode(Currency.FIELDNO(Code),DATABASE::Currency));
      Currency.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134000 to show one way of using this function.

      LibraryERM.CreateCurrency(Currency);
      LibraryERM.SetCurrencyGainLossAccounts(Currency);
      Currency.VALIDATE("Residual Gains Account",Currency."Realized Gains Acc.");
      Currency.VALIDATE("Residual Losses Account",Currency."Realized Losses Acc.");
      Currency.VALIDATE("Appln. Rounding Precision",ApplnRoundingPrecision);
      Currency.MODIFY(TRUE);

      LibraryERM.CreateRandomExchangeRate(Currency.Code);
      EXIT(Currency.Code);
Member of Lib.Library - ERM


CreateCurrencyForReminderLevel@64 Method

The procedure CreateCurrencyForReminderLevel is available in codeunit 131300.

Syntax

CreateCurrencyForReminderLevel@64(
    VAR CurrencyForReminderLevel@1002 : Record 329 CurrencyForReminderLevel, //Reference parameter of type Record
    ReminderTermsCode@1000 : Code[10] ReminderTermsCode, //Input parameter of type Code
    CurrencyCode@1001 : Code[10] CurrencyCode //Input parameter of type Code
);

Parameters

CurrencyForReminderLevel
Reference parameter of type Record
ReminderTermsCode
Input parameter of type Code
CurrencyCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Currency, For, Reminder, Level.

For a clarification about how this function works, refer to the code listed below.

      CurrencyForReminderLevel.INIT;
      CurrencyForReminderLevel.VALIDATE("Reminder Terms Code",ReminderTermsCode);
      RecRef.GETTABLE(CurrencyForReminderLevel);
      CurrencyForReminderLevel.VALIDATE("No.",LibraryUtility.GetNewLineNo(RecRef,CurrencyForReminderLevel.FIELDNO("No.")));
      CurrencyForReminderLevel.VALIDATE("Currency Code",CurrencyCode);
      CurrencyForReminderLevel.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134904 to show one way of using this function.

      LibraryERM.CreateCurrencyForReminderLevel(CurrencyForReminderLevel,ReminderTermsCode,CurrencyCode);
      CurrencyForReminderLevel.VALIDATE("Additional Fee",AdditionalFee);
      CurrencyForReminderLevel.MODIFY(TRUE);
Member of Lib.Library - ERM


CreateCurrencyWithExchangeRate@156 Method

The procedure CreateCurrencyWithExchangeRate is available in codeunit 131300.

Syntax

CreateCurrencyWithExchangeRate@156(
    StartingDate@1004 : Date StartingDate, //Input parameter of type Date
    ExchangeRateAmount@1003 : Decimal ExchangeRateAmount, //Input parameter of type Decimal
    AdjustmentExchangeRateAmount@1001 : Decimal AdjustmentExchangeRateAmount //Input parameter of type Decimal
);

Parameters

StartingDate
Input parameter of type Date
ExchangeRateAmount
Input parameter of type Decimal
AdjustmentExchangeRateAmount
Input parameter of type Decimal

Return Value

Code[10]

Remarks

The relevant search keywords are: Create, Currency, Exchange, Rate.

For a clarification about how this function works, refer to the code listed below.

      CurrencyCode := CreateCurrencyWithGLAccountSetup;
      CreateExchangeRate(CurrencyCode,StartingDate,ExchangeRateAmount,AdjustmentExchangeRateAmount);
      EXIT(CurrencyCode);

Example

The below example is extracted from the test automation codeunit 134006 to show one way of using this function.

      // Verify Applied Amount on Apply Entries Page when applying entries in different currencies

      // Setup
      Initialize;
      LibrarySales.CreateCustomer(Customer);
      SelectGenJournalBatch(GenJournalBatch,FALSE);
      ExchangeRateAmount := LibraryRandom.RandDecInRange(10,50,2);
      CurrencyCode := LibraryERM.CreateCurrencyWithExchangeRate(WORKDATE,ExchangeRateAmount,ExchangeRateAmount);
      PaymentAmount := LibraryRandom.RandDecInRange(100,1000,2);
      InvoiceAmount := PaymentAmount * LibraryRandom.RandIntInRange(3,5);

      // Exercise
      CreateAndPostGenJnlLineWithCurrency(
        GenJournalLine,GenJournalBatch,GenJournalLine."Document Type"::Invoice,
        Customer."No.",'',InvoiceAmount);
      CreateAndPostGenJnlLineWithCurrency(
        GenJournalLine,GenJournalBatch,GenJournalLine."Document Type"::"Credit Memo",
        Customer."No.",'',-PaymentAmount);
      CreateAndPostGenJnlLineWithCurrency(
        GenJournalLine,GenJournalBatch,GenJournalLine."Document Type"::Payment,
        Customer."No.",CurrencyCode,-PaymentAmount);

      LibraryVariableStorage.Enqueue(PaymentAmount);
      LibraryVariableStorage.Enqueue(InvoiceAmount);
      LibraryVariableStorage.Enqueue(ExchangeRateAmount);

      // Verify: verification in page handler
      RunCustomerLedgerEntries(Customer."No.",GenJournalLine."Document No.");
Member of Lib.Library - ERM


CreateCurrencyWithGLAccountSetup@155 Method

The procedure CreateCurrencyWithGLAccountSetup is available in codeunit 131300.

Syntax

CreateCurrencyWithGLAccountSetup@155(
      //param element not supplied
);

Return Value

Code[10]

Remarks

The relevant search keywords are: Create, Currency, General Ledger, Account, Setup.

For a clarification about how this function works, refer to the code listed below.

      CreateCurrency(Currency);
      WITH Currency DO BEGIN
        VALIDATE("Residual Gains Account",CreateGLAccountNo);
        VALIDATE("Residual Losses Account","Residual Gains Account");
        VALIDATE("Realized G/L Gains Account",CreateGLAccountNo);
        VALIDATE("Realized G/L Losses Account","Realized G/L Gains Account");
        VALIDATE("Realized Gains Acc.",CreateGLAccountNo);
        VALIDATE("Realized Losses Acc.","Realized Gains Acc.");
        VALIDATE("Unrealized Gains Acc.",CreateGLAccountNo);
        VALIDATE("Unrealized Losses Acc.","Unrealized Gains Acc.");
        MODIFY(TRUE);
        EXIT(Code);
      END;

Example

The below example is extracted from the test automation codeunit 134921 to show one way of using this function.

      CurrencyFactor[1] := LibraryRandom.RandDecInRange(100,200,2);
      CurrencyFactor[2] := CurrencyFactor[1] + LibraryRandom.RandDecInRange(100,200,2);
      NewPostingDate := LibraryRandom.RandDate(LibraryRandom.RandIntInRange(10,20));
      CurrencyCode := LibraryERM.CreateCurrencyWithGLAccountSetup;
      LibraryERM.CreateExchangeRate(CurrencyCode,WORKDATE,CurrencyFactor[1],CurrencyFactor[1]);
      LibraryERM.CreateExchangeRate(CurrencyCode,NewPostingDate,CurrencyFactor[2],CurrencyFactor[2]);
Member of Lib.Library - ERM


CreateCurrencyWithRandomExchRates@159 Method

The procedure CreateCurrencyWithRandomExchRates is available in codeunit 131300.

Syntax

CreateCurrencyWithRandomExchRates@159(
      //param element not supplied
);

Return Value

Code[10]

Remarks

The relevant search keywords are: Create, Currency, Random, Exchange, Rates.

For a clarification about how this function works, refer to the code listed below.

      CurrencyCode := CreateCurrencyWithGLAccountSetup;
      CreateRandomExchangeRate(CurrencyCode);
      EXIT(CurrencyCode);

Example

The below example is extracted from the test automation codeunit 134043 to show one way of using this function.

      // Verify Additional Currency Amount in GL Entry and VAT Entry after Posting Purchase Invoice.

      // Setup: Update Purchase Payables Setup and Update General Posting Setup. Create Purchase Invoice and
      // Calculate Additional Currency Amount and VAT Amount.

      Initialize;
      CurrencyCode := LibraryERM.CreateCurrencyWithRandomExchRates;
      LibraryERM.SetAddReportingCurrency(CurrencyCode);
      LibraryPurchase.SetCalcInvDiscount(TRUE);
      OriginalVATBase := -ROUND(CreatePurchaseInvoiceCalcDisc(PurchaseHeader,PurchaseLine));
      UpdateGeneralPostingSetup(PurchaseLine."Gen. Bus. Posting Group",PurchaseLine."Gen. Prod. Posting Group");
      AdditionalCurrencyAmount := LibraryERM.ConvertCurrency(OriginalVATBase,'',CurrencyCode,WORKDATE);
      VATAmount := ROUND(AdditionalCurrencyAmount * PurchaseLine."VAT %" / 100);

      // Exercise: Post Purchase Invoice and Find Purchase Invoice Header.
      PurchInvoiceNo := LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

      // Verify: Verify GL Entry and VAT Entry for Additional Currency Amount.
      GeneralPostingSetup.GET(PurchaseLine."Gen. Bus. Posting Group",PurchaseLine."Gen. Prod. Posting Group");
      VerifyGLEntry(PurchInvoiceNo,GeneralPostingSetup."Purch. Line Disc. Account",AdditionalCurrencyAmount);
Member of Lib.Library - ERM


CreateCurrencyWithRounding@142 Method

The procedure CreateCurrencyWithRounding is available in codeunit 131300.

Syntax

CreateCurrencyWithRounding@142(
      //param element not supplied
);

Return Value

Code[10]

Remarks

The relevant search keywords are: Create, Currency, Rounding.

For a clarification about how this function works, refer to the code listed below.

      Decimals := LibraryRandom.RandInt(5);
      WITH Currency DO BEGIN
        GET(
          CreateCurrencyWithExchangeRate(
            WORKDATE,LibraryRandom.RandDec(100,Decimals),LibraryRandom.RandDec(100,Decimals)));
        VALIDATE("Amount Rounding Precision",LibraryRandom.RandPrecision);
        MODIFY(TRUE);
        EXIT(Code);
      END;

Example

The below example is extracted from the test automation codeunit 134327 to show one way of using this function.

      // [FEATURE] [Job]
      // [SCENARIO 123636] The Job Total Price and Job Total Price (LCY) fields are populated in the Purchase Order/Invoice line after you select the Job No, Job Task No (in foreign currency)
      LightInit;
      // [GIVEN] Create currency with precisions
      CurrencyCode := LibraryERM.CreateCurrencyWithRounding;
      // [GIVEN] Update precision in General Ledger Setup
      LibraryERM.SetAmountRoundingPrecision(LibraryERM.GetCurrencyAmountRoundingPrecision(CurrencyCode) / 10);
      // [GIVEN] Purchase Line in FCY, where "Job No." is set
      CreatePurchLineWithCurrency(PurchaseLine,CurrencyCode);
      CreateJobTaskWithCurrency(JobTask,CurrencyCode);
      PurchaseLine.VALIDATE("Job No.",JobTask."Job No.");
      // [GIVEN] Purchase Line, where "Job Unit Price" = "P", "Job Unit Price (LCY)" = "P(LCY)", Quantity = "Q"

      // [WHEN] Enter "Job Task No." = JobTask."Job Task No." in Purchase Line
      PurchaseLine.VALIDATE("Job Task No.",JobTask."Job Task No.");

      // [THEN] Purchase Line is updated
      // [THEN] "Job Total Price" = "P" * "Q"
      // [THEN] "Job Total Price (LCY)" = "P(LCY)" * "Q"
      VerifyJobTotalPrices(PurchaseLine,CurrencyCode);
Member of Lib.Library - ERM


CreateCustomerDiscountGroup@124 Method

The procedure CreateCustomerDiscountGroup is available in codeunit 131300.

Syntax

CreateCustomerDiscountGroup@124(
    VAR CustomerDiscountGroup@1000 : Record 340 CustomerDiscountGroup //Reference parameter of type Record
);

Parameters

CustomerDiscountGroup
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Customer, Discount, Group.

For a clarification about how this function works, refer to the code listed below.

      CustomerDiscountGroup.INIT;
      CustomerDiscountGroup.VALIDATE(Code,LibraryUtility.GenerateRandomCode(CustomerDiscountGroup.FIELDNO(Code),DATABASE::"Customer Discount Group"));
      CustomerDiscountGroup.VALIDATE(Description,CustomerDiscountGroup.Code);  // Validating Code as Description because value is not important.
      CustomerDiscountGroup.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136353 to show one way of using this function.

      // [FEATURE] [Discount] [Line Discount] [Item Variant]
      // [SCENARIO 212422] "Line Discount %" of Job Planning Line is zero when "Allow Line Disc." is No in Sales Price for "All Customers", Item with Variant and Customer has "Line Discount" from Customer Discount Group

      Initialize;

      // [GIVEN] Customer Discount Group "CUSTDISC" assigned to Customer "C"
      LibraryERM.CreateCustomerDiscountGroup(CustomerDiscountGroup);
      LibrarySales.CreateCustomer(Customer);
      Customer.VALIDATE("Customer Disc. Group",CustomerDiscountGroup.Code);
      Customer.MODIFY(TRUE);

      // [GIVEN] Job and Job Task with Customer "C"
      LibraryJob.CreateJob(Job);
      Job.VALIDATE("Bill-to Customer No.",Customer."No.");
      Job.MODIFY(TRUE);
      LibraryJob.CreateJobTask(Job,JobTask);

      // [GIVEN] Item "X" with Variant "X1" and Item Discount Group "ITEMDISC"
      LibraryInventory.CreateItem(Item);
      LibraryInventory.CreateVariant(ItemVariant,Item);
      LibraryERM.CreateItemDiscountGroup(ItemDiscountGroup);
      Item.VALIDATE("Item Disc. Group",ItemDiscountGroup.Code);
      Item.MODIFY(TRUE);

      // [GIVEN] Sales Line Discount with Customer Discount Group "CUSTDISC", Item Discount Group "ITEMDISC" and "Line Discount %" = 10
      LibraryERM.CreateLineDiscForCustomer(
        SalesLineDiscount,SalesLineDiscount.Type::"Item Disc. Group",ItemDiscountGroup.Code,
        SalesLineDiscount."Sales Type"::"Customer Disc. Group",CustomerDiscountGroup.Code,WORKDATE,'','','',0);
      SalesLineDiscount.VALIDATE("Line Discount %",LibraryRandom.RandDec(10,2));
      SalesLineDiscount.MODIFY(TRUE);

      // [GIVEN] Sales Price for All Customers for Item "X", Variant "X1" is 50, "Allow Line Disc." = No
      LibrarySales.CreateSalesPrice(
        SalesPrice,Item."No.",SalesPrice."Sales Type"::"All Customers",'',
        WORKDATE,'',ItemVariant.Code,Item."Base Unit of Measure",0,LibraryRandom.RandDec(100,2));
      SalesPrice.VALIDATE("Allow Line Disc.",FALSE);
      SalesPrice.MODIFY(TRUE);

      // [GIVEN] Job Planning Line with Item "X"
      CreateSimpleJobPlanningLine(JobPlanningLine,JobTask);
      JobPlanningLine.VALIDATE(Type,JobPlanningLine.Type::Item);
      JobPlanningLine.VALIDATE("No.",Item."No.");

      // [WHEN] Validate Variant "X1" on Job Planning Line
      JobPlanningLine.VALIDATE("Variant Code",ItemVariant.Code);

      // [THEN] "Line Discount %" in Job Planning Line is 0%
      JobPlanningLine.TESTFIELD("Line Discount %",0);
Member of Lib.Library - ERM


CreateDeductorCategory@1500002 Method

The procedure CreateDeductorCategory is available in codeunit 131300.

Syntax

CreateDeductorCategory@1500002(
    VAR DeductorCategory@1500002 : Record 16498 DeductorCategory //Reference parameter of type Record
);

Parameters

DeductorCategory
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Deductor, Category.

For a clarification about how this function works, refer to the code listed below.

      DeductorCategory.INIT;
      DeductorCategory.VALIDATE(Code,COPYSTR(LibraryUtility.GenerateRandomCode(DeductorCategory.FIELDNO(Code),DATABASE::"Deductor Category"),1,LibraryUtility.GetFieldLength(DATABASE::"Deductor Category",DeductorCategory.FIELDNO(Code))));
      DeductorCategory.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 144011 to show one way of using this function.

      LibraryERM.CreateDeductorCategory(DeductorCategory);
      CompanyInformation.VALIDATE("Deductor Category",DeductorCategory.Code);
      CompanyInformation.MODIFY(TRUE);
Member of Lib.Library - ERM


CreateDeferralTemplate@203 Method

The procedure CreateDeferralTemplate is available in codeunit 131300.

Syntax

CreateDeferralTemplate@203(
    VAR DeferralTemplate@1000 : Record 1700 DeferralTemplate, //Reference parameter of type Record
    CalcMethod@1001 : Option CalcMethod, //Input parameter of type Option
    StartDate@1002 : Option StartDate, //Input parameter of type Option
    NumOfPeriods@1003 : Integer NumOfPeriods //Input parameter of type Integer
);

Parameters

DeferralTemplate
Reference parameter of type Record
CalcMethod
Input parameter of type Option
StartDate
Input parameter of type Option
NumOfPeriods
Input parameter of type Integer

Remarks

The relevant search keywords are: Create, Deferral, Template.

For a clarification about how this function works, refer to the code listed below.

      DeferralTemplate.INIT;
      DeferralTemplate."Deferral Code" :=
        LibraryUtility.GenerateRandomCode(DeferralTemplate.FIELDNO("Deferral Code"),DATABASE::"Deferral Template");
      DeferralTemplate."Deferral Account" := CreateGLAccountNo;
      DeferralTemplate."Calc. Method" := CalcMethod;
      DeferralTemplate."Start Date" := StartDate;
      DeferralTemplate."No. of Periods" := NumOfPeriods;
      DeferralTemplate."Period Description" := DeferralTemplate."Deferral Code";
      DeferralTemplate.INSERT(TRUE);

Example

There are no examples available.
Member of Lib.Library - ERM


CreateDeferralTemplateCode@204 Method

The procedure CreateDeferralTemplateCode is available in codeunit 131300.

Syntax

CreateDeferralTemplateCode@204(
    CalcMethod@1001 : Option CalcMethod, //Input parameter of type Option
    StartDate@1002 : Option StartDate, //Input parameter of type Option
    NumOfPeriods@1003 : Integer NumOfPeriods //Input parameter of type Integer
);

Parameters

CalcMethod
Input parameter of type Option
StartDate
Input parameter of type Option
NumOfPeriods
Input parameter of type Integer

Return Value

Code[10]

Remarks

The relevant search keywords are: Create, Deferral, Template, Code.

For a clarification about how this function works, refer to the code listed below.

      CreateDeferralTemplate(DeferralTemplate,CalcMethod,StartDate,NumOfPeriods);
      EXIT(DeferralTemplate."Deferral Code");

Example

The below example is extracted from the test automation codeunit 134805 to show one way of using this function.

      EXIT(LibraryERM.CreateDeferralTemplateCode(CalcMethod,StartDate,NumOfPeriods));
Member of Lib.Library - ERM


CreateExchangeRate@154 Method

The procedure CreateExchangeRate is available in codeunit 131300.

Syntax

CreateExchangeRate@154(
    CurrencyCode@1001 : Code[10] CurrencyCode, //Input parameter of type Code
    StartingDate@1005 : Date StartingDate, //Input parameter of type Date
    ExchangeRateAmount@1003 : Decimal ExchangeRateAmount, //Input parameter of type Decimal
    AdjustmentExchangeRateAmount@1004 : Decimal AdjustmentExchangeRateAmount //Input parameter of type Decimal
);

Parameters

CurrencyCode
Input parameter of type Code
StartingDate
Input parameter of type Date
ExchangeRateAmount
Input parameter of type Decimal
AdjustmentExchangeRateAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Exchange, Rate.

For a clarification about how this function works, refer to the code listed below.

      WITH CurrencyExchangeRate DO BEGIN
        INIT;
        VALIDATE("Currency Code",CurrencyCode);
        VALIDATE("Starting Date",StartingDate);
        INSERT(TRUE);

        VALIDATE("Exchange Rate Amount",ExchangeRateAmount);
        VALIDATE("Adjustment Exch. Rate Amount",AdjustmentExchangeRateAmount);
        VALIDATE("Relational Exch. Rate Amount",1);
        VALIDATE("Relational Adjmt Exch Rate Amt",1);
        MODIFY(TRUE);
      END;

Example

The below example is extracted from the test automation codeunit 134006 to show one way of using this function.

      // Verify Application Rounding and Balance amounts
      // Setup.
      ApplicationRoundingPrecision := 1;
      LineAmount := 99;
      // prime numbers are required to obtain non-whole number after currency conversion
      CurrencyFactor := 7 / 3;
      LibraryERM.SetApplnRoundingPrecision(ApplicationRoundingPrecision);
      LibraryERM.CreateCurrency(Currency);
      Currency.VALIDATE("Invoice Rounding Precision",0.01);
      Currency.MODIFY(TRUE);
      LibraryERM.CreateExchangeRate(Currency.Code,WORKDATE,CurrencyFactor,CurrencyFactor);
      LibrarySales.CreateCustomer(Customer);
      Customer.VALIDATE("Currency Code",Currency.Code);
      Customer.MODIFY(TRUE);
      SelectGenJournalBatch(GenJournalBatch,FALSE);

      // Excercise
      CreateAndPostSalesDocument(
        SalesLine,WORKDATE,Customer."No.",LibraryInventory.CreateItem(Item),SalesHeader."Document Type"::Invoice,
        1,LineAmount);
      LineAmount := SalesLine."Amount Including VAT";
      CreateGeneralJournalLines(
        GenJournalLine,GenJournalBatch,1,Customer."No.",GenJournalLine."Document Type"::Payment,
        -1 * ROUND(LineAmount / CurrencyFactor,ApplicationRoundingPrecision,'<'));
      GenJournalLine.VALIDATE("Currency Code",'');
      GenJournalLine.MODIFY(TRUE);

      // Verify is done in page handler
      LibraryVariableStorage.Enqueue(ROUND(LineAmount / CurrencyFactor,Currency."Invoice Rounding Precision"));
      LibraryVariableStorage.Enqueue(GenJournalLine.Amount);
      CODEUNIT.RUN(CODEUNIT::"Gen. Jnl.-Apply",GenJournalLine);
Member of Lib.Library - ERM


CreateExchRate@16 Method

The procedure CreateExchRate is available in codeunit 131300.

Syntax

CreateExchRate@16(
    VAR CurrencyExchangeRate@1002 : Record 330 CurrencyExchangeRate, //Reference parameter of type Record
    CurrencyCode@1001 : Code[10] CurrencyCode, //Input parameter of type Code
    StartingDate@1000 : Date StartingDate //Input parameter of type Date
);

Parameters

CurrencyExchangeRate
Reference parameter of type Record
CurrencyCode
Input parameter of type Code
StartingDate
Input parameter of type Date

Remarks

The relevant search keywords are: Create, Exchange, Rate.

For a clarification about how this function works, refer to the code listed below.

      CurrencyExchangeRate.INIT;
      CurrencyExchangeRate.VALIDATE("Currency Code",CurrencyCode);
      CurrencyExchangeRate.VALIDATE("Starting Date",StartingDate);
      CurrencyExchangeRate.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134006 to show one way of using this function.

      WITH CurrencyExchangeRate DO BEGIN
        LibraryERM.CreateExchRate(CurrencyExchangeRate,CurrencyCode,FromDate);
        VALIDATE("Exchange Rate Amount",Rate);
        VALIDATE("Adjustment Exch. Rate Amount",Rate);
        VALIDATE("Relational Exch. Rate Amount",RelationalRate);
        VALIDATE("Relational Adjmt Exch Rate Amt",RelationalRate);
        MODIFY(TRUE);
      END;
Member of Lib.Library - ERM


CreateExciseBusPostingGroup@1500001 Method

The procedure CreateExciseBusPostingGroup is available in codeunit 131300.

Syntax

CreateExciseBusPostingGroup@1500001(
      //param element not supplied
);

Return Value

Code[10]

Remarks

The relevant search keywords are: Create, Excise, Business, Posting, Group.

For a clarification about how this function works, refer to the code listed below.

      WITH ExciseBusPostingGroup DO BEGIN
        INIT;
        VALIDATE(
          Code,
          COPYSTR(
            LibraryUtility.GenerateRandomCode(FIELDNO(Code),DATABASE::"Excise Bus. Posting Group"),
            1,
            LibraryUtility.GetFieldLength(DATABASE::"Excise Bus. Posting Group",FIELDNO(Code))));
        VALIDATE(Description,Code);
        INSERT(TRUE);
        EXIT(Code);
      END;

Example

There are no examples available.
Member of Lib.Library - ERM


CreateExcisePostingSetup@1500000 Method

The procedure CreateExcisePostingSetup is available in codeunit 131300.

Syntax

CreateExcisePostingSetup@1500000(
    VAR ExcisePostngSetup@1002 : Record 13711 ExcisePostngSetup, //Reference parameter of type Record
    BEDCalculationType@1500000 : Option BEDCalculationType, //Input parameter of type Option
    BEDPercent@1500001 : Decimal BEDPercent, //Input parameter of type Decimal
    NewSSI@1500002 : Boolean NewSSI //Input parameter of type Boolean
);

Parameters

ExcisePostngSetup
Reference parameter of type Record
BEDCalculationType
Input parameter of type Option
BEDPercent
Input parameter of type Decimal
NewSSI
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, Excise, Posting, Setup.

For a clarification about how this function works, refer to the code listed below.

      WITH ExcisePostngSetup DO BEGIN
        INIT;
        VALIDATE("Excise Bus. Posting Group",CreateExciseBusPostingGroup);
        VALIDATE("Excise Prod. Posting Group",CreateExciseProdPostingGroup);
        VALIDATE("BED Calculation Type",BEDCalculationType);
        VALIDATE("BED %",BEDPercent);
        VALIDATE(SSI,NewSSI);
        INSERT(TRUE);
      END;

Example

The below example is extracted from the test automation codeunit 144001 to show one way of using this function.

      WITH ExcisePostingSetup DO BEGIN
        LibraryERM.CreateExcisePostingSetup(
          ExcisePostingSetup,"BED Calculation Type"::"Excise %",ExciseAmount,FALSE);
        // Will include BCD Amount only to BED Amount.
        // BED Amount is a part of Excise.
        "Cenvat Cr. Receivable(Trading)" := ServiceTaxAsExciseHelper.CreateGLAccount;
        "Cenvat Cr. Receivable Account" := ServiceTaxAsExciseHelper.CreateGLAccount;
        "Cenvat Transfered(Trading)" := ServiceTaxAsExciseHelper.CreateGLAccount;
        "eCess %" := LibraryRandom.RandInt(10);
        "eCess Calculation Formula" := 'BED AMOUNT';
        "SHE Cess %" := LibraryRandom.RandInt(10);
        "SHE Cess Calculation Formula" := 'BED AMOUNT';
        "Setoff available" := TRUE;
        MODIFY(TRUE);
      END;
Member of Lib.Library - ERM


CreateExciseProdPostingGroup@1500007 Method

The procedure CreateExciseProdPostingGroup is available in codeunit 131300.

Syntax

CreateExciseProdPostingGroup@1500007(
      //param element not supplied
);

Return Value

Code[10]

Remarks

The relevant search keywords are: Create, Excise, Product, Posting, Group.

For a clarification about how this function works, refer to the code listed below.

      WITH ExciseProdPostingGroup DO BEGIN
        INIT;
        VALIDATE(
          Code,
          COPYSTR(
            LibraryUtility.GenerateRandomCode(FIELDNO(Code),DATABASE::"Excise Prod. Posting Group"),
            1,
            LibraryUtility.GetFieldLength(DATABASE::"Excise Prod. Posting Group",FIELDNO(Code))));
        VALIDATE(Description,Code);
        VALIDATE("Chapter No.",LibraryUtility.GenerateGUID);
        VALIDATE("Heading No",LibraryUtility.GenerateGUID);
        INSERT(TRUE);
        EXIT(Code);
      END;

Example

There are no examples available.
Member of Lib.Library - ERM


CreateFADepreciationBook@353 Method

The procedure CreateFADepreciationBook is available in codeunit 131300.

Syntax

CreateFADepreciationBook@353(
    VAR FADepreciationBook@1000 : Record 5612 FADepreciationBook, //Reference parameter of type Record
    FANo@1001 : Code[20] FANo, //Input parameter of type Code
    DepreciationBookCode@1003 : Code[10] DepreciationBookCode //Input parameter of type Code
);

Parameters

FADepreciationBook
Reference parameter of type Record
FANo
Input parameter of type Code
DepreciationBookCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Fixed Asset, Depreciation, Book.

For a clarification about how this function works, refer to the code listed below.

      FADepreciationBook.INIT;
      FADepreciationBook.VALIDATE("FA No.",FANo);
      FADepreciationBook.VALIDATE("Depreciation Book Code",DepreciationBookCode);
      FADepreciationBook.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134049 to show one way of using this function.

      LibraryFixedAsset.CreateFADepreciationBook(FADepreciationBook,No,DepreciationBookCode);
      UpdateDateFADepreciationBook(FADepreciationBook,DepreciationBookCode);
      FADepreciationBook.VALIDATE("FA Posting Group",FAPostingGroup);
      FADepreciationBook.MODIFY(TRUE);
Member of Lib.Library - ERM


CreateFAJournalLine@49 Method

The procedure CreateFAJournalLine is available in codeunit 131300.

Syntax

CreateFAJournalLine@49(
    VAR FAJournalLine@1006 : Record 5621 FAJournalLine, //Reference parameter of type Record
    JournalTemplateName@1005 : Code[10] JournalTemplateName, //Input parameter of type Code
    JournalBatchName@1004 : Code[10] JournalBatchName, //Input parameter of type Code
    DocumentType@1003 : Option DocumentType, //Input parameter of type Option
    FAPostingType@1002 : Option FAPostingType, //Input parameter of type Option
    FANo@1001 : Code[20] FANo, //Input parameter of type Code
    Amount@1000 : Decimal Amount //Input parameter of type Decimal
);

Parameters

FAJournalLine
Reference parameter of type Record
JournalTemplateName
Input parameter of type Code
JournalBatchName
Input parameter of type Code
DocumentType
Input parameter of type Option
FAPostingType
Input parameter of type Option
FANo
Input parameter of type Code
Amount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Fixed Asset, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      // Find a balanced template/batch pair.
      FAJournalBatch.GET(JournalTemplateName,JournalBatchName);

      // Create a General Journal Entry.
      FAJournalLine.INIT;
      FAJournalLine.VALIDATE("Journal Template Name",JournalTemplateName);
      FAJournalLine.VALIDATE("Journal Batch Name",JournalBatchName);
      RecRef.GETTABLE(FAJournalLine);
      FAJournalLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,FAJournalLine.FIELDNO("Line No.")));
      FAJournalLine.INSERT(TRUE);
      FAJournalLine.VALIDATE("Posting Date",WORKDATE);  // Defaults to work date.
      FAJournalLine.VALIDATE("Document Type",DocumentType);
      FAJournalLine.VALIDATE("FA No.",FANo);
      FAJournalLine.VALIDATE("FA Posting Type",FAPostingType);
      FAJournalLine.VALIDATE("FA Posting Date",WORKDATE);
      FAJournalLine.VALIDATE(Amount,Amount);
      IF NoSeries.GET(FAJournalBatch."No. Series") THEN
        FAJournalLine.VALIDATE(
          "Document No.",NoSeriesMgt.GetNextNo(FAJournalBatch."No. Series",WORKDATE,FALSE));  // Unused but required field for posting.
      FAJournalLine.VALIDATE("External Document No.",FAJournalLine."Document No.");  // Unused but required for vendor posting.
      FAJournalLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134450 to show one way of using this function.

      CreateFAJournalBatch(FAJournalBatch);
      LibraryFixedAsset.CreateFAJournalLine(FAJournalLine,FAJournalBatch."Journal Template Name",FAJournalBatch.Name);
      FAJournalLine.VALIDATE("Document Type",DocumentType);
      FAJournalLine.VALIDATE("Document No.",GetDocumentNo(FAJournalBatch));
      FAJournalLine.VALIDATE("Posting Date",WORKDATE);
      FAJournalLine.VALIDATE("FA Posting Date",WORKDATE);
      FAJournalLine.VALIDATE("FA Posting Type",FAPostingType);
      FAJournalLine.VALIDATE("FA No.",FANo);
      FAJournalLine.VALIDATE(Amount,LibraryRandom.RandInt(1000));  // Using Random Number Generator for Amount.
      FAJournalLine.VALIDATE("Depreciation Book Code",DepreciationBookCode);
      FAJournalLine.MODIFY(TRUE);
Member of Lib.Library - ERM


CreateFinanceChargeMemoHeader@72 Method

The procedure CreateFinanceChargeMemoHeader is available in codeunit 131300.

Syntax

CreateFinanceChargeMemoHeader@72(
    VAR FinanceChargeMemoHeader@1000 : Record 302 FinanceChargeMemoHeader, //Reference parameter of type Record
    CustomerNo@1001 : Code[20] CustomerNo //Input parameter of type Code
);

Parameters

FinanceChargeMemoHeader
Reference parameter of type Record
CustomerNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Finance, Charge, Memo, Header.

For a clarification about how this function works, refer to the code listed below.

      FinanceChargeMemoHeader.INIT;
      FinanceChargeMemoHeader.INSERT(TRUE);
      FinanceChargeMemoHeader.VALIDATE("Customer No.",CustomerNo);
      FindVATSetupForCust(CustomerNo);
      FinanceChargeMemoHeader.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134700 to show one way of using this function.

      LibrarySales.CreateCustomer(Customer);
      LibraryERM.CreateFinanceChargeMemoHeader(FinanceChargeMemoHeader,Customer."No.");
      LibraryERM.CreateFinanceChargeTerms(FinanceChargeTerms);
      FinanceChargeMemoHeader.VALIDATE("Fin. Charge Terms Code",FinanceChargeTerms.Code);
      FinanceChargeMemoHeader.MODIFY(TRUE);
      LibraryERM.CreateFinanceChargeMemoLine(
        FinanceChargeMemoLine,FinanceChargeMemoHeader."No.",FinanceChargeMemoLine.Type::"G/L Account");
      Amount := LibraryRandom.RandDecInDecimalRange(1,100,2);
      FinanceChargeMemoLine.VALIDATE("Remaining Amount",Amount);
      FinanceChargeMemoLine.VALIDATE(Amount,Amount);
      FinanceChargeMemoLine.MODIFY(TRUE);
      FinanceChargeMemoHeader.CALCFIELDS("Remaining Amount","Interest Amount");
Member of Lib.Library - ERM


CreateFinanceChargeMemoLine@71 Method

The procedure CreateFinanceChargeMemoLine is available in codeunit 131300.

Syntax

CreateFinanceChargeMemoLine@71(
    VAR FinanceChargeMemoLine@1002 : Record 303 FinanceChargeMemoLine, //Reference parameter of type Record
    FinanceChargeMemoHeaderNo@1000 : Code[20] FinanceChargeMemoHeaderNo, //Input parameter of type Code
    Type@1001 : Option Type //Input parameter of type Option
);

Parameters

FinanceChargeMemoLine
Reference parameter of type Record
FinanceChargeMemoHeaderNo
Input parameter of type Code
Type
Input parameter of type Option

Remarks

The relevant search keywords are: Create, Finance, Charge, Memo, Line.

For a clarification about how this function works, refer to the code listed below.

      FinanceChargeMemoLine.INIT;
      FinanceChargeMemoLine.VALIDATE("Finance Charge Memo No.",FinanceChargeMemoHeaderNo);
      RecRef.GETTABLE(FinanceChargeMemoLine);
      FinanceChargeMemoLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,FinanceChargeMemoLine.FIELDNO("Line No.")));
      FinanceChargeMemoLine.INSERT(TRUE);
      FinanceChargeMemoLine.VALIDATE(Type,Type);
      FinanceChargeMemoLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134700 to show one way of using this function.

      LibrarySales.CreateCustomer(Customer);
      LibraryERM.CreateFinanceChargeMemoHeader(FinanceChargeMemoHeader,Customer."No.");
      LibraryERM.CreateFinanceChargeTerms(FinanceChargeTerms);
      FinanceChargeMemoHeader.VALIDATE("Fin. Charge Terms Code",FinanceChargeTerms.Code);
      FinanceChargeMemoHeader.MODIFY(TRUE);
      LibraryERM.CreateFinanceChargeMemoLine(
        FinanceChargeMemoLine,FinanceChargeMemoHeader."No.",FinanceChargeMemoLine.Type::"G/L Account");
      Amount := LibraryRandom.RandDecInDecimalRange(1,100,2);
      FinanceChargeMemoLine.VALIDATE("Remaining Amount",Amount);
      FinanceChargeMemoLine.VALIDATE(Amount,Amount);
      FinanceChargeMemoLine.MODIFY(TRUE);
      FinanceChargeMemoHeader.CALCFIELDS("Remaining Amount","Interest Amount");
Member of Lib.Library - ERM


CreateFinanceChargeTerms@77 Method

The procedure CreateFinanceChargeTerms is available in codeunit 131300.

Syntax

CreateFinanceChargeTerms@77(
    VAR FinanceChargeTerms@1000 : Record 5 FinanceChargeTerms //Reference parameter of type Record
);

Parameters

FinanceChargeTerms
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Finance, Charge, Terms.

For a clarification about how this function works, refer to the code listed below.

      FinanceChargeTerms.INIT;
      FinanceChargeTerms.VALIDATE(
        Code,
        COPYSTR(LibraryUtility.GenerateRandomCode(FinanceChargeTerms.FIELDNO(Code),DATABASE::"Finance Charge Terms"),
          1,
          LibraryUtility.GetFieldLength(DATABASE::"Finance Charge Terms",FinanceChargeTerms.FIELDNO(Code))));
      FinanceChargeTerms.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134700 to show one way of using this function.

      LibrarySales.CreateCustomer(Customer);
      LibraryERM.CreateFinanceChargeMemoHeader(FinanceChargeMemoHeader,Customer."No.");
      LibraryERM.CreateFinanceChargeTerms(FinanceChargeTerms);
      FinanceChargeMemoHeader.VALIDATE("Fin. Charge Terms Code",FinanceChargeTerms.Code);
      FinanceChargeMemoHeader.MODIFY(TRUE);
      LibraryERM.CreateFinanceChargeMemoLine(
        FinanceChargeMemoLine,FinanceChargeMemoHeader."No.",FinanceChargeMemoLine.Type::"G/L Account");
      Amount := LibraryRandom.RandDecInDecimalRange(1,100,2);
      FinanceChargeMemoLine.VALIDATE("Remaining Amount",Amount);
      FinanceChargeMemoLine.VALIDATE(Amount,Amount);
      FinanceChargeMemoLine.MODIFY(TRUE);
      FinanceChargeMemoHeader.CALCFIELDS("Remaining Amount","Interest Amount");
Member of Lib.Library - ERM


CreateFinanceChargeText@73 Method

The procedure CreateFinanceChargeText is available in codeunit 131300.

Syntax

CreateFinanceChargeText@73(
    VAR FinanceChargeText@1004 : Record 301 FinanceChargeText, //Reference parameter of type Record
    FinChargeTermsCode@1003 : Code[10] FinChargeTermsCode, //Input parameter of type Code
    Position@1002 : Option Position, //Input parameter of type Option
    Text@1000 : Text[100] Text //Input parameter of type Text
);

Parameters

FinanceChargeText
Reference parameter of type Record
FinChargeTermsCode
Input parameter of type Code
Position
Input parameter of type Option
Text
Input parameter of type Text

Remarks

The relevant search keywords are: Create, Finance, Charge, Text.

For a clarification about how this function works, refer to the code listed below.

      FinanceChargeText.INIT;
      FinanceChargeText.VALIDATE("Fin. Charge Terms Code",FinChargeTermsCode);
      FinanceChargeText.VALIDATE(Position,Position);
      RecRef.GETTABLE(FinanceChargeText);
      FinanceChargeText.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,FinanceChargeText.FIELDNO("Line No.")));
      FinanceChargeText.INSERT(TRUE);
      FinanceChargeText.VALIDATE(Text,Text);
      FinanceChargeText.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - ERM


CreateFixedAsset@348 Method

The procedure CreateFixedAsset is available in codeunit 131300.

Syntax

CreateFixedAsset@348(
    VAR FixedAsset@1000 : Record 5600 FixedAsset //Reference parameter of type Record
);

Parameters

FixedAsset
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Fixed, Asset.

For a clarification about how this function works, refer to the code listed below.

      LibraryFixedAsset.CreateFixedAsset(FixedAsset);

Example

The below example is extracted from the test automation codeunit 134100 to show one way of using this function.

      LibraryFixedAsset.CreateFixedAsset(FixedAsset);
      FAPostingGroupCode := CreateFAPostingGroupWithPostingSetup(LineGLAccount);

      LibraryFixedAsset.CreateFADepreciationBook(FADepreciationBook,FixedAsset."No.",LibraryFixedAsset.GetDefaultDeprBook);
      FADepreciationBook.VALIDATE("FA Posting Group",FAPostingGroupCode);
      FADepreciationBook.MODIFY(TRUE);

      EXIT(FixedAsset."No.");
Member of Lib.Library - ERM


CreateGenBusPostingGroup@43 Method

The procedure CreateGenBusPostingGroup is available in codeunit 131300.

Syntax

CreateGenBusPostingGroup@43(
    VAR GenBusinessPostingGroup@1001 : Record 250 GenBusinessPostingGroup //Reference parameter of type Record
);

Parameters

GenBusinessPostingGroup
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, General, Business, Posting, Group.

For a clarification about how this function works, refer to the code listed below.

      GenBusinessPostingGroup.INIT;
      GenBusinessPostingGroup.VALIDATE(
        Code,
        COPYSTR(LibraryUtility.GenerateRandomCode(GenBusinessPostingGroup.FIELDNO(Code),DATABASE::"Gen. Business Posting Group"),
          1,LibraryUtility.GetFieldLength(DATABASE::"Gen. Business Posting Group",GenBusinessPostingGroup.FIELDNO(Code))));

      // Validating Code as Name because value is not important.
      GenBusinessPostingGroup.VALIDATE(Description,GenBusinessPostingGroup.Code);
      GenBusinessPostingGroup.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134047 to show one way of using this function.

      LibraryERM.CreateGenBusPostingGroup(GenBusinessPostingGroup);
      LibraryERM.CreateGenProdPostingGroup(GenProductPostingGroup);
      LibraryERM.CreateGeneralPostingSetup(GenPostingSetup,GenBusinessPostingGroup.Code,GenProductPostingGroup.Code);
Member of Lib.Library - ERM


CreateGeneralJnlLine@15 Method

The procedure CreateGeneralJnlLine is available in codeunit 131300.

Syntax

CreateGeneralJnlLine@15(
    VAR GenJournalLine@1006 : Record 81 GenJournalLine, //Reference parameter of type Record
    JournalTemplateName@1005 : Code[10] JournalTemplateName, //Input parameter of type Code
    JournalBatchName@1004 : Code[10] JournalBatchName, //Input parameter of type Code
    DocumentType@1003 : Option DocumentType, //Input parameter of type Option
    AccountType@1002 : Option AccountType, //Input parameter of type Option
    AccountNo@1001 : Code[20] AccountNo, //Input parameter of type Code
    Amount@1000 : Decimal Amount //Input parameter of type Decimal
);

Parameters

GenJournalLine
Reference parameter of type Record
JournalTemplateName
Input parameter of type Code
JournalBatchName
Input parameter of type Code
DocumentType
Input parameter of type Option
AccountType
Input parameter of type Option
AccountNo
Input parameter of type Code
Amount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, General, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      GenJournalBatch.GET(JournalTemplateName,JournalBatchName);
      CreateGeneralJnlLineWithBalAcc(GenJournalLine,JournalTemplateName,JournalBatchName,DocumentType,AccountType,AccountNo,
        GenJournalBatch."Bal. Account Type",GenJournalBatch."Bal. Account No.",Amount);

Example

The below example is extracted from the test automation codeunit 134000 to show one way of using this function.

      LibraryERM.SelectGenJnlBatch(GenJournalBatch);
      LibraryERM.ClearGenJournalLines(GenJournalBatch);
      LibraryERM.CreateGeneralJnlLine(
        GenJournalLine,GenJournalBatch."Journal Template Name",GenJournalBatch.Name,DocumentType,
        GenJournalLine."Account Type"::Customer,CustomerNo,Amount);
      GenJournalLine.VALIDATE("Posting Date",PostingDate);
      GenJournalLine.VALIDATE("Currency Code",CurrencyCode);
      GenJournalLine.MODIFY(TRUE);
Member of Lib.Library - ERM


CreateGeneralJnlLine2@136 Method

The procedure CreateGeneralJnlLine2 is available in codeunit 131300.

Syntax

CreateGeneralJnlLine2@136(
    VAR GenJournalLine@1006 : Record 81 GenJournalLine, //Reference parameter of type Record
    JournalTemplateName@1005 : Code[10] JournalTemplateName, //Input parameter of type Code
    JournalBatchName@1004 : Code[10] JournalBatchName, //Input parameter of type Code
    DocumentType@1003 : Option DocumentType, //Input parameter of type Option
    AccountType@1002 : Option AccountType, //Input parameter of type Option
    AccountNo@1001 : Code[20] AccountNo, //Input parameter of type Code
    Amount@1000 : Decimal Amount //Input parameter of type Decimal
);

Parameters

GenJournalLine
Reference parameter of type Record
JournalTemplateName
Input parameter of type Code
JournalBatchName
Input parameter of type Code
DocumentType
Input parameter of type Option
AccountType
Input parameter of type Option
AccountNo
Input parameter of type Code
Amount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, General, Journal, Line2.

For a clarification about how this function works, refer to the code listed below.

      // This function should replace the identical one above, but it requires a lot of changes to existing tests so I'm keeping both for now and will refactor when time permits
      GenJournalBatch.GET(JournalTemplateName,JournalBatchName);
      CreateGeneralJnlLine2WithBalAcc(GenJournalLine,JournalTemplateName,JournalBatchName,DocumentType,AccountType,AccountNo,
        GenJournalBatch."Bal. Account Type",GenJournalBatch."Bal. Account No.",Amount);

Example

The below example is extracted from the test automation codeunit 144085 to show one way of using this function.

      LibraryERM.CreateGeneralJnlLine2(GenJournalLine,GenJournalTemplate.Name,GenJnlBatchName,GenJournalLine."Document Type"::Payment,
        AccountType,AccountNo,Amount);
      GenJournalLine.VALIDATE("Posting Date",PostingDate);
      GenJournalLine.MODIFY(TRUE);
      EXIT(GenJournalLine."Document No.");
Member of Lib.Library - ERM


CreateGeneralJnlLine2WithBalAcc@135 Method

The procedure CreateGeneralJnlLine2WithBalAcc is available in codeunit 131300.

Syntax

CreateGeneralJnlLine2WithBalAcc@135(
    VAR GenJournalLine@1006 : Record 81 GenJournalLine, //Reference parameter of type Record
    JournalTemplateName@1005 : Code[10] JournalTemplateName, //Input parameter of type Code
    JournalBatchName@1004 : Code[10] JournalBatchName, //Input parameter of type Code
    DocumentType@1003 : Option DocumentType, //Input parameter of type Option
    AccountType@1002 : Option AccountType, //Input parameter of type Option
    AccountNo@1001 : Code[20] AccountNo, //Input parameter of type Code
    BalAccountType@1008 : Option BalAccountType, //Input parameter of type Option
    BalAccountNo@1007 : Code[20] BalAccountNo, //Input parameter of type Code
    Amount@1000 : Decimal Amount //Input parameter of type Decimal
);

Parameters

GenJournalLine
Reference parameter of type Record
JournalTemplateName
Input parameter of type Code
JournalBatchName
Input parameter of type Code
DocumentType
Input parameter of type Option
AccountType
Input parameter of type Option
AccountNo
Input parameter of type Code
BalAccountType
Input parameter of type Option
BalAccountNo
Input parameter of type Code
Amount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, General, Journal, Line2, Bal, Account.

For a clarification about how this function works, refer to the code listed below.

      // This function should replace the identical one above, but it requires a lot of changes to existing tests so I'm keeping both for now and will refactor when time permits
      LibraryJournals.CreateGenJournalLine2(GenJournalLine,JournalTemplateName,JournalBatchName,DocumentType,AccountType,AccountNo,
        BalAccountType,BalAccountNo,Amount);

      // Update Cheque No. and Cheque Date when Account Type is Bank Account to avoid failures, value is not important for test.
      IF  AccountType = GenJournalLine."Account Type"::"Bank Account" THEN BEGIN
        GenJournalLine.VALIDATE("Cheque No.",GenJournalLine."Document No.");
        GenJournalLine.VALIDATE("Cheque Date",WORKDATE);
        GenJournalLine.MODIFY(TRUE);
      END;

Example

There are no examples available.
Member of Lib.Library - ERM


CreateGeneralJnlLineWithBalAcc@134 Method

The procedure CreateGeneralJnlLineWithBalAcc is available in codeunit 131300.

Syntax

CreateGeneralJnlLineWithBalAcc@134(
    VAR GenJournalLine@1006 : Record 81 GenJournalLine, //Reference parameter of type Record
    JournalTemplateName@1005 : Code[10] JournalTemplateName, //Input parameter of type Code
    JournalBatchName@1004 : Code[10] JournalBatchName, //Input parameter of type Code
    DocumentType@1003 : Option DocumentType, //Input parameter of type Option
    AccountType@1002 : Option AccountType, //Input parameter of type Option
    AccountNo@1001 : Code[20] AccountNo, //Input parameter of type Code
    BalAccountType@1008 : Option BalAccountType, //Input parameter of type Option
    BalAccountNo@1007 : Code[20] BalAccountNo, //Input parameter of type Code
    Amount@1000 : Decimal Amount //Input parameter of type Decimal
);

Parameters

GenJournalLine
Reference parameter of type Record
JournalTemplateName
Input parameter of type Code
JournalBatchName
Input parameter of type Code
DocumentType
Input parameter of type Option
AccountType
Input parameter of type Option
AccountNo
Input parameter of type Code
BalAccountType
Input parameter of type Option
BalAccountNo
Input parameter of type Code
Amount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, General, Journal, Line, Bal, Account.

For a clarification about how this function works, refer to the code listed below.

      LibraryJournals.CreateGenJournalLine(GenJournalLine,JournalTemplateName,JournalBatchName,DocumentType,AccountType,AccountNo,
        BalAccountType,BalAccountNo,Amount);

      // Update Cheque No. and Cheque Date when Account Type is Bank Account to avoid failures, value is not important for test.
      IF  AccountType = GenJournalLine."Account Type"::"Bank Account" THEN BEGIN
        GenJournalLine.VALIDATE("Cheque No.",GenJournalLine."Document No.");
        GenJournalLine.VALIDATE("Cheque Date",WORKDATE);
        GenJournalLine.MODIFY(TRUE);
      END;

Example

The below example is extracted from the test automation codeunit 134000 to show one way of using this function.

      WITH GenJournalTemplate DO BEGIN
        LibraryERM.CreateGenJournalTemplate(GenJournalTemplate);
        VALIDATE(Type,Type::"Cash Receipts");
        MODIFY(TRUE);
        LibraryERM.CreateGenJournalBatch(GenJournalBatch,Name);
      END;

      LibraryERM.CreateGeneralJnlLineWithBalAcc(
        GenJournalLine,GenJournalBatch."Journal Template Name",GenJournalBatch.Name,
        GenJournalLine."Document Type"::Payment,GenJournalLine."Account Type"::Customer,AccountNo,
        GenJournalLine."Bal. Account Type"::"G/L Account",LibraryERM.CreateGLAccountNo,0);
Member of Lib.Library - ERM


CreateGeneralPostingSetup@47 Method

The procedure CreateGeneralPostingSetup is available in codeunit 131300.

Syntax

CreateGeneralPostingSetup@47(
    VAR GeneralPostingSetup@1003 : Record 252 GeneralPostingSetup, //Reference parameter of type Record
    GenBusPostingGroup@1001 : Code[10] GenBusPostingGroup, //Input parameter of type Code
    GenProdPostingGroup@1002 : Code[10] GenProdPostingGroup //Input parameter of type Code
);

Parameters

GeneralPostingSetup
Reference parameter of type Record
GenBusPostingGroup
Input parameter of type Code
GenProdPostingGroup
Input parameter of type Code

Remarks

The relevant search keywords are: Create, General, Posting, Setup.

For a clarification about how this function works, refer to the code listed below.

      GeneralPostingSetup.INIT;
      GeneralPostingSetup.VALIDATE("Gen. Bus. Posting Group",GenBusPostingGroup);
      GeneralPostingSetup.VALIDATE("Gen. Prod. Posting Group",GenProdPostingGroup);
      GeneralPostingSetup.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134041 to show one way of using this function.

      LibraryVariableStorage.Enqueue(PostingAction::"Payment Tolerance Accounts");

      LibraryPmtDiscSetup.SetAdjustForPaymentDisc(TRUE);
      LibraryPmtDiscSetup.SetPmtTolerance(0);
      RunChangePaymentTolerance(TRUE,LibraryRandom.RandDec(10,2),LibraryRandom.RandDecInRange(100,200,2));

      LibraryERM.FindGeneralPostingSetupInvtFull(GeneralPostingSetup);
      LibraryERM.CreateGenProdPostingGroup(GenProductPostingGroup);
      LibraryERM.CreateGeneralPostingSetup(
        GeneralPostingSetup,GeneralPostingSetup."Gen. Bus. Posting Group",GenProductPostingGroup.Code);
      UpdateGeneralPostingSetupSalesPmtAccounts(GeneralPostingSetup);
      UpdateGeneralPostingSetupPurchPmtAccounts(GeneralPostingSetup);
      GeneralPostingSetup.VALIDATE("COGS Account",LibraryERM.CreateGLAccountNo);
      GeneralPostingSetup.VALIDATE("Sales Account",LibraryERM.CreateGLAccountNo);
      GeneralPostingSetup.MODIFY(TRUE);

      LibraryERM.CreateVATBusinessPostingGroup(VATBusinessPostingGroup);
      LibraryERM.CreateVATProductPostingGroup(VATProductPostingGroup);
      LibraryERM.CreateVATPostingSetup(VATPostingSetup,VATBusinessPostingGroup.Code,VATProductPostingGroup.Code);
      UpdateVATPostingSetup(VATPostingSetup,VATPercent,VATCalculationType);

      GenProductPostingGroup.VALIDATE("Def. VAT Prod. Posting Group",VATProductPostingGroup.Code);
      GenProductPostingGroup.MODIFY(TRUE);
Member of Lib.Library - ERM


CreateGeneralPostingSetupInvt@163 Method

The procedure CreateGeneralPostingSetupInvt is available in codeunit 131300.

Syntax

CreateGeneralPostingSetupInvt@163(
    VAR GeneralPostingSetup@1000 : Record 252 GeneralPostingSetup //Reference parameter of type Record
);

Parameters

GeneralPostingSetup
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, General, Posting, Setup, Invt.

For a clarification about how this function works, refer to the code listed below.

      CreateGenBusPostingGroup(GenBusinessPostingGroup);
      CreateGenProdPostingGroup(GenProductPostingGroup);
      CreateGeneralPostingSetup(GeneralPostingSetup,GenBusinessPostingGroup.Code,GenProductPostingGroup.Code);
      GeneralPostingSetup.VALIDATE("Sales Account",CreateGLAccountNo);
      GeneralPostingSetup.VALIDATE("Purch. Account",CreateGLAccountNo);
      GeneralPostingSetup.VALIDATE("COGS Account",CreateGLAccountNo);
      GeneralPostingSetup.VALIDATE("Inventory Adjmt. Account",CreateGLAccountNo);
      GeneralPostingSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134104 to show one way of using this function.

      LibraryERM.CreateGeneralPostingSetupInvt(GeneralPostingSetup);
      LibraryERM.SetGeneralPostingSetupPrepAccounts(GeneralPostingSetup);
      LibraryERM.SetGeneralPostingSetupSalesAccounts(GeneralPostingSetup);
      LibraryERM.SetGeneralPostingSetupPurchAccounts(GeneralPostingSetup);
      LibraryERM.SetGeneralPostingSetupMfgAccounts(GeneralPostingSetup);
      GeneralPostingSetup.MODIFY(TRUE);
      CreateRelatedZeroVATPostingSetup(VATPostingSetup,VATBusPostingGroupCode);
      UpdateGLAccountWithVATAndGenSetup(GeneralPostingSetup."Sales Prepayments Account",VATPostingSetup,GeneralPostingSetup);
      UpdateGLAccountWithVATAndGenSetup(GeneralPostingSetup."Purch. Prepayments Account",VATPostingSetup,GeneralPostingSetup);
Member of Lib.Library - ERM


CreateGenJnlAllocation@63 Method

The procedure CreateGenJnlAllocation is available in codeunit 131300.

Syntax

CreateGenJnlAllocation@63(
    VAR GenJnlAllocation@1000 : Record 221 GenJnlAllocation, //Reference parameter of type Record
    JournalTemplateName@1001 : Code[10] JournalTemplateName, //Input parameter of type Code
    JournalBatchName@1002 : Code[10] JournalBatchName, //Input parameter of type Code
    LineNo@1003 : Integer LineNo //Input parameter of type Integer
);

Parameters

GenJnlAllocation
Reference parameter of type Record
JournalTemplateName
Input parameter of type Code
JournalBatchName
Input parameter of type Code
LineNo
Input parameter of type Integer

Remarks

The relevant search keywords are: Create, General, Journal, Allocation.

For a clarification about how this function works, refer to the code listed below.

      GenJnlAllocation.INIT;
      GenJnlAllocation.VALIDATE("Journal Template Name",JournalTemplateName);
      GenJnlAllocation.VALIDATE("Journal Batch Name",JournalBatchName);
      GenJnlAllocation.VALIDATE("Journal Line No.",LineNo);
      RecRef.GETTABLE(GenJnlAllocation);
      GenJnlAllocation.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,GenJnlAllocation.FIELDNO("Line No.")));
      GenJnlAllocation.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134146 to show one way of using this function.

      LibraryERM.CreateGenJnlAllocation(
        GenJnlAllocation,GenJournalLine."Journal Template Name",GenJournalLine."Journal Batch Name",GenJournalLine."Line No.");
      GenJnlAllocation.VALIDATE("Account No.",AccountNo);
      GenJnlAllocation.VALIDATE("Allocation %",AllocationPercent);
      GenJnlAllocation.MODIFY(TRUE);
Member of Lib.Library - ERM


CreateGenJournalBatch@75 Method

The procedure CreateGenJournalBatch is available in codeunit 131300.

Syntax

CreateGenJournalBatch@75(
    VAR GenJournalBatch@1000 : Record 232 GenJournalBatch, //Reference parameter of type Record
    JournalTemplateName@1001 : Code[10] JournalTemplateName //Input parameter of type Code
);

Parameters

GenJournalBatch
Reference parameter of type Record
JournalTemplateName
Input parameter of type Code

Remarks

The relevant search keywords are: Create, General, Journal, Batch.

For a clarification about how this function works, refer to the code listed below.

      // creates a new Gen. Journal Batch named with the next available number (if it does not yet exist), OR
      // returns the Gen. Journal batch named with the next available number
      // calling ConvertNumericToText to avoid auto-removal of the batch during posting by COD13
      GenJournalBatch.INIT;
      GenJournalBatch.VALIDATE("Journal Template Name",JournalTemplateName);
      GenJournalBatch.VALIDATE(
        Name,
        LibraryUtility.ConvertNumericToText(
        COPYSTR(
          LibraryUtility.GenerateRandomCode(GenJournalBatch.FIELDNO(Name),DATABASE::"Gen. Journal Batch"),
          1,
            LibraryUtility.GetFieldLength(DATABASE::"Gen. Journal Batch",GenJournalBatch.FIELDNO(Name)))));
      GenJournalBatch.VALIDATE(Description,GenJournalBatch.Name);  // Validating Name as Description because value is not important.
      IF GenJournalBatch.INSERT(TRUE) THEN ;

Example

The below example is extracted from the test automation codeunit 134000 to show one way of using this function.

      WITH GenJournalTemplate DO BEGIN
        LibraryERM.CreateGenJournalTemplate(GenJournalTemplate);
        VALIDATE(Type,Type::"Cash Receipts");
        MODIFY(TRUE);
        LibraryERM.CreateGenJournalBatch(GenJournalBatch,Name);
      END;

      LibraryERM.CreateGeneralJnlLineWithBalAcc(
        GenJournalLine,GenJournalBatch."Journal Template Name",GenJournalBatch.Name,
        GenJournalLine."Document Type"::Payment,GenJournalLine."Account Type"::Customer,AccountNo,
        GenJournalLine."Bal. Account Type"::"G/L Account",LibraryERM.CreateGLAccountNo,0);
Member of Lib.Library - ERM


CreateGenJournalTemplate@68 Method

The procedure CreateGenJournalTemplate is available in codeunit 131300.

Syntax

CreateGenJournalTemplate@68(
    VAR GenJournalTemplate@1000 : Record 80 GenJournalTemplate //Reference parameter of type Record
);

Parameters

GenJournalTemplate
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, General, Journal, Template.

For a clarification about how this function works, refer to the code listed below.

      GenJournalTemplate.INIT;
      GenJournalTemplate.VALIDATE(
        Name,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(GenJournalTemplate.FIELDNO(Name),DATABASE::"Gen. Journal Template"),
          1,
          LibraryUtility.GetFieldLength(DATABASE::"Gen. Journal Template",GenJournalTemplate.FIELDNO(Name))));
      GenJournalTemplate.VALIDATE(Description,GenJournalTemplate.Name);
      // Validating Name as Description because value is not important.
      GenJournalTemplate.INSERT(TRUE);

      IF NOT GenJournalTemplate."Force Doc. Balance" THEN BEGIN
        GenJournalTemplate.VALIDATE("Force Doc. Balance",TRUE);  // This field is FALSE by default in ES. Setting this to TRUE to match ES with W1.
        GenJournalTemplate.MODIFY(TRUE);
      END;

Example

The below example is extracted from the test automation codeunit 134000 to show one way of using this function.

      WITH GenJournalTemplate DO BEGIN
        LibraryERM.CreateGenJournalTemplate(GenJournalTemplate);
        VALIDATE(Type,Type::"Cash Receipts");
        MODIFY(TRUE);
        LibraryERM.CreateGenJournalBatch(GenJournalBatch,Name);
      END;

      LibraryERM.CreateGeneralJnlLineWithBalAcc(
        GenJournalLine,GenJournalBatch."Journal Template Name",GenJournalBatch.Name,
        GenJournalLine."Document Type"::Payment,GenJournalLine."Account Type"::Customer,AccountNo,
        GenJournalLine."Bal. Account Type"::"G/L Account",LibraryERM.CreateGLAccountNo,0);
Member of Lib.Library - ERM


CreateGenPostSetup@1500014 Method

The procedure CreateGenPostSetup is available in codeunit 131300.

Syntax

CreateGenPostSetup@1500014(
    GenBusPostGrp@1500000 : Code[10] GenBusPostGrp, //Input parameter of type Code
    GenProdPostGrp@1500004 : Code[10] GenProdPostGrp //Input parameter of type Code
);

Parameters

GenBusPostGrp
Input parameter of type Code
GenProdPostGrp
Input parameter of type Code

Remarks

The relevant search keywords are: Create, General, Post, Setup.

For a clarification about how this function works, refer to the code listed below.

      SetGeneralPostingSetup.RESET;
      SetGeneralPostingSetup.SETRANGE("Gen. Bus. Posting Group",GenBusPostGrp);
      SetGeneralPostingSetup.SETRANGE("Gen. Prod. Posting Group",GenProdPostGrp);
      IF NOT SetGeneralPostingSetup.FINDFIRST THEN BEGIN
        GeneralPostingSetup.SETFILTER("Gen. Bus. Posting Group",'<>%1','');
        GeneralPostingSetup.SETFILTER("Gen. Prod. Posting Group",'<>%1','');
        GeneralPostingSetup.SETFILTER("Sales Account",'<>%1','');
        GeneralPostingSetup.SETFILTER("Purch. Account",'<>%1','');
        GeneralPostingSetup.SETFILTER("COGS Account",'<>%1','');
        GeneralPostingSetup.SETFILTER("COGS Account (Interim)",'<>''''');
        GeneralPostingSetup.SETFILTER("Inventory Adjmt. Account",'<>%1','');
        GeneralPostingSetup.SETFILTER("Sales Credit Memo Account",'<>%1','');
        GeneralPostingSetup.SETFILTER("Purch. Credit Memo Account",'<>%1','');
        GeneralPostingSetup.SETFILTER("Direct Cost Applied Account",'<>%1','');
        GeneralPostingSetup.SETFILTER("Overhead Applied Account",'<>%1','');
        GeneralPostingSetup.SETFILTER("Purchase Variance Account",'<>%1','');
        GeneralPostingSetup.SETFILTER("Sales Prepayments Account",'<>%1','');
        GeneralPostingSetup.SETFILTER("Purch. Prepayments Account",'<>%1','');
        IF GeneralPostingSetup.FINDFIRST THEN BEGIN
          SetGeneralPostingSetup := GeneralPostingSetup;
          SetGeneralPostingSetup."Gen. Bus. Posting Group" := GenBusPostGrp;
          SetGeneralPostingSetup."Gen. Prod. Posting Group" := GenProdPostGrp;
          SetGeneralPostingSetup.INSERT(TRUE);
        END;
      END;

Example

The below example is extracted from the test automation codeunit 136104 to show one way of using this function.

      // [SCENARIO 143443] Create Service Credit Memo for Type Cost, post it and verify the Service Ledger Entries.

      // [GIVEN] Find Service Cost, create Customer without Price Including VAT.
      Initialize;
      LibraryService.FindServiceCost(ServiceCost);
      CustomerNo := CustomerWithPriceIncludingVAT(FALSE);

      // [WHEN] Create Service Credit Memo and post it.
      No := LibraryService.CreateServiceCreditMemoHeaderUsingPage;
      CreateCreditMemoLine(No,CustomerNo,ServiceLine.Type::Cost,ServiceCost.Code);

      ServiceLines.RESET;
      ServiceLines.SETCURRENTKEY("Document Type","Document No.","Line No.");
      ServiceLines.SETRANGE("Document Type",ServiceLines."Document Type"::"Credit Memo");
      ServiceLines.SETRANGE("Document No.",No);
      IF ServiceLines.FINDSET THEN REPEAT
        LibraryERM.CreateGenPostSetup(ServiceLines."Gen. Bus. Posting Group",ServiceLines."Gen. Prod. Posting Group");
      UNTIL ServiceLines.NEXT = 0;

      ServiceCreditMemoOpenEdit(ServiceCreditMemo,No);
      Quantity := ServiceCreditMemo.ServLines.Quantity.ASDECIMAL;
      ServiceCreditMemo.Post.INVOKE;

      // [THEN] Verify the Service Ledger Entries for the posted Service Credit Memo.
      VerifyCreditMemoServiceLedgerEntry(No,CustomerNo,ServiceCost.Code,Quantity);
Member of Lib.Library - ERM


CreateGenProdPostingGroup@42 Method

The procedure CreateGenProdPostingGroup is available in codeunit 131300.

Syntax

CreateGenProdPostingGroup@42(
    VAR GenProductPostingGroup@1000 : Record 251 GenProductPostingGroup //Reference parameter of type Record
);

Parameters

GenProductPostingGroup
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, General, Product, Posting, Group.

For a clarification about how this function works, refer to the code listed below.

      GenProductPostingGroup.INIT;
      GenProductPostingGroup.VALIDATE(
        Code,
        COPYSTR(LibraryUtility.GenerateRandomCode(GenProductPostingGroup.FIELDNO(Code),DATABASE::"Gen. Product Posting Group"),
          1,LibraryUtility.GetFieldLength(DATABASE::"Gen. Product Posting Group",GenProductPostingGroup.FIELDNO(Code))));

      // Validating Code as Name because value is not important.
      GenProductPostingGroup.VALIDATE(Description,GenProductPostingGroup.Code);
      GenProductPostingGroup.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134041 to show one way of using this function.

      LibraryVariableStorage.Enqueue(PostingAction::"Payment Tolerance Accounts");

      LibraryPmtDiscSetup.SetAdjustForPaymentDisc(TRUE);
      LibraryPmtDiscSetup.SetPmtTolerance(0);
      RunChangePaymentTolerance(TRUE,LibraryRandom.RandDec(10,2),LibraryRandom.RandDecInRange(100,200,2));

      LibraryERM.FindGeneralPostingSetupInvtFull(GeneralPostingSetup);
      LibraryERM.CreateGenProdPostingGroup(GenProductPostingGroup);
      LibraryERM.CreateGeneralPostingSetup(
        GeneralPostingSetup,GeneralPostingSetup."Gen. Bus. Posting Group",GenProductPostingGroup.Code);
      UpdateGeneralPostingSetupSalesPmtAccounts(GeneralPostingSetup);
      UpdateGeneralPostingSetupPurchPmtAccounts(GeneralPostingSetup);
      GeneralPostingSetup.VALIDATE("COGS Account",LibraryERM.CreateGLAccountNo);
      GeneralPostingSetup.VALIDATE("Sales Account",LibraryERM.CreateGLAccountNo);
      GeneralPostingSetup.MODIFY(TRUE);

      LibraryERM.CreateVATBusinessPostingGroup(VATBusinessPostingGroup);
      LibraryERM.CreateVATProductPostingGroup(VATProductPostingGroup);
      LibraryERM.CreateVATPostingSetup(VATPostingSetup,VATBusinessPostingGroup.Code,VATProductPostingGroup.Code);
      UpdateVATPostingSetup(VATPostingSetup,VATPercent,VATCalculationType);

      GenProductPostingGroup.VALIDATE("Def. VAT Prod. Posting Group",VATProductPostingGroup.Code);
      GenProductPostingGroup.MODIFY(TRUE);
Member of Lib.Library - ERM


CreateGLAccount@14 Method

The procedure CreateGLAccount is available in codeunit 131300.

Syntax

CreateGLAccount@14(
    VAR GLAccount@1000 : Record 15 GLAccount //Reference parameter of type Record
);

Parameters

GLAccount
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, General Ledger, Account.

For a clarification about how this function works, refer to the code listed below.

      GLAccount.INIT;
      // Prefix a number to fix errors for local build.
      GLAccount.VALIDATE(
        "No.",
        PADSTR(
          '1' + LibraryUtility.GenerateRandomCode(GLAccount.FIELDNO("No."),DATABASE::"G/L Account"),MAXSTRLEN(GLAccount."No."),'0'));
      GLAccount.VALIDATE(Name,GLAccount."No.");  // Enter No. as Name because value is not important.
      GLAccount.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134025 to show one way of using this function.

      Currency.GET(CurrencyCode);
      LibraryERM.CreateGLAccount(GLAccount);
      Currency.VALIDATE("Residual Gains Account",GLAccount."No.");
      Currency.VALIDATE("Residual Losses Account",GLAccount."No.");
      Currency.MODIFY(TRUE);
Member of Lib.Library - ERM


CreateGLAccountNo@149 Method

The procedure CreateGLAccountNo is available in codeunit 131300.

Syntax

CreateGLAccountNo@149(
      //param element not supplied
);

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, General Ledger, Account, No.

For a clarification about how this function works, refer to the code listed below.

      CreateGLAccount(GLAccount);
      EXIT(GLAccount."No.");

Example

The below example is extracted from the test automation codeunit 134015 to show one way of using this function.

      LibraryERM.FindGeneralPostingSetup(GeneralPostingSetup);
      GeneralPostingSetup."Sales Pmt. Disc. Debit Acc." := LibraryERM.CreateGLAccountNo;  // Using assignment to avoid error in ES.
      GeneralPostingSetup.MODIFY(TRUE);
      EXIT(GeneralPostingSetup."Gen. Bus. Posting Group");
Member of Lib.Library - ERM


CreateGLAccountNoWithDirectPosting@151 Method

The procedure CreateGLAccountNoWithDirectPosting is available in codeunit 131300.

Syntax

CreateGLAccountNoWithDirectPosting@151(
      //param element not supplied
);

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, General Ledger, Account, No, Direct, Posting.

For a clarification about how this function works, refer to the code listed below.

      CreateGLAccount(GLAccount);
      GLAccount.VALIDATE("Direct Posting",TRUE);
      GLAccount.MODIFY;
      EXIT(GLAccount."No.");

Example

The below example is extracted from the test automation codeunit 134230 to show one way of using this function.

      // TestDeleteUsedDimension
      // Tests that it is not allowed to delete dimensions and dimension values which are still
      // in use. Verification expects an apropriate exception.

      // Setup
      LibraryDimension.CreateDimension(Dimension);
      LibraryDimension.CreateDimensionValue(DimensionValue,Dimension.Code);
      GLAccNo := LibraryERM.CreateGLAccountNoWithDirectPosting;

      // Create a default dimension for GL Account
      LibraryDimension.CreateDefaultDimensionGLAcc(DefaultDimension,GLAccNo,
        Dimension.Code,DimensionValue.Code);

      // Create a general journal line using new default dimension
      CreateGenJournalLine(GenJournalLine,
        GenJournalLine."Document Type"::Invoice,
        GenJournalLine."Account Type"::"G/L Account",
        GLAccNo);

      // Exercise & Verify
      ASSERTERROR DimensionValue.DELETE(TRUE);
      ASSERTERROR Dimension.DELETE(TRUE);
Member of Lib.Library - ERM


CreateGLAccountWithPurchSetup@150 Method

The procedure CreateGLAccountWithPurchSetup is available in codeunit 131300.

Syntax

CreateGLAccountWithPurchSetup@150(
      //param element not supplied
);

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, General Ledger, Account, Purchase, Setup.

For a clarification about how this function works, refer to the code listed below.

      FindVATPostingSetup(VATPostingSetup,VATPostingSetup."VAT Calculation Type"::"Normal VAT");
      EXIT(CreateGLAccountWithVATPostingSetup(VATPostingSetup,GLAccount."Gen. Posting Type"::Purchase));

Example

The below example is extracted from the test automation codeunit 134029 to show one way of using this function.

      // [SCENARIO 121626] "Country Code","VAT Registration No.","Bill-to/Pay-to No." are copied to VAT Entry from Vendor that is set as "Bal. Account" while "Account No." is empty in the Gen. Journal Line.
      Initialize;

      // [GIVEN] Two Posting Dates "D1", "D2". "D2" > "D1".
      FOR i := 1 TO 2 DO BEGIN
        PostingDate[i] := WORKDATE + i;
        Amount[i] := LibraryRandom.RandDec(100,2);
      END;

      // [GIVEN] G/L Account "S" with posting type "Purchase"
      GLAccountNo := LibraryERM.CreateGLAccountWithPurchSetup;

      // [GIVEN] Vendor "V1" with "Country Code" = "X1" and "VAT Registration No." = "Y1"
      CreateVendorWithVATRegNo(Vendor[1]);

      // [GIVEN] Vendor "V2" with "Country Code" = "X2" and "VAT Registration No." = "Y2"
      CreateVendorWithVATRegNo(Vendor[2]);

      // [GIVEN] 1st Journal Line with "Posting Date" = "D2", empty "Account No.", "Bal. Account Type"="Vendor", "Bal. Account No." = "V2"
      FindAndClearGenJnlBatch(GenJournalBatch);
      CreateVendGenJournalLine(GenJournalLine,GenJournalBatch,PostingDate[2],Vendor[2]."No.",-Amount[2]);

      // [GIVEN] 2nd Journal Line with "Posting Date" = "D1", empty "Account No.", "Bal. Account Type"="Vendor", "Bal. Account No." = "V1"
      CreateVendGenJournalLine(GenJournalLine,GenJournalBatch,PostingDate[1],Vendor[1]."No.",-Amount[1]);

      // [GIVEN] 3rd Journal Line with "Posting Date" = "D2", "Account No." = "S" and empty "Bal. Account No."
      CreateGLGenJournalLine(GenJournalLine,GenJournalBatch,PostingDate[2],GLAccountNo,-Amount[2]);

      // [GIVEN] 4th Journal Line with "Posting Date" = "D1", "Account No." = "S" and empty "Bal. Account No."
      CreateGLGenJournalLine(GenJournalLine,GenJournalBatch,PostingDate[1],GLAccountNo,-Amount[1]);

      // [GIVEN] Change order Gen Journal Lines By "Posting Date". New line's numbers order: 2, 4, 1, 3
      GenJournalLine.SETCURRENTKEY("Journal Template Name","Journal Batch Name","Posting Date","Document No.");

      // [WHEN] Post Gen. Journal lines
      CODEUNIT.RUN(CODEUNIT::"Gen. Jnl.-Post Batch",GenJournalLine);

      // [THEN] Posted VAT Entry related to Vendor "V1" has "Country Code" = "X1", "VAT Registration No." = "Y1", "Bill-to/Pay-to No." = "V1"
      FindVendLedgerEntry(VendorLedgerEntry,Vendor[1]."No.");
      VerifyVATEntryCVInfo(
        VendorLedgerEntry."Transaction No.",
        Vendor[1]."Country/Region Code",Vendor[1]."VAT Registration No.",Vendor[1]."No.");

      // [THEN] Posted VAT Entry related to Vendor "V2" has "Country Code" = "X2", "VAT Registration No." = "Y2", "Bill-to/Pay-to No." = "V2"
      FindVendLedgerEntry(VendorLedgerEntry,Vendor[2]."No.");
      VerifyVATEntryCVInfo(
        VendorLedgerEntry."Transaction No.",
        Vendor[2]."Country/Region Code",Vendor[2]."VAT Registration No.",Vendor[2]."No.");
Member of Lib.Library - ERM


CreateGLAccountWithSalesSetup@157 Method

The procedure CreateGLAccountWithSalesSetup is available in codeunit 131300.

Syntax

CreateGLAccountWithSalesSetup@157(
      //param element not supplied
);

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, General Ledger, Account, Sales, Setup.

For a clarification about how this function works, refer to the code listed below.

      FindVATPostingSetup(VATPostingSetup,VATPostingSetup."VAT Calculation Type"::"Normal VAT");
      EXIT(CreateGLAccountWithVATPostingSetup(VATPostingSetup,GLAccount."Gen. Posting Type"::Sale));

Example

The below example is extracted from the test automation codeunit 134029 to show one way of using this function.

      // [SCENARIO 121626] "Country Code","VAT Registration No.","Bill-to/Pay-to No." are copied to VAT Entry from Customer that is set as "Bal. Account" while "Account No." is empty in the Gen. Journal Line.
      Initialize;

      // [GIVEN] Two Posting Dates "D1", "D2". "D2" > "D1".
      FOR i := 1 TO 2 DO BEGIN
        PostingDate[i] := WORKDATE + i;
        Amount[i] := LibraryRandom.RandDec(100,2);
      END;

      // [GIVEN] G/L Account "S" with posting type "Sale"
      GLAccountNo := LibraryERM.CreateGLAccountWithSalesSetup;

      // [GIVEN] Customer "C1" with "Country Code" = "X1" and "VAT Registration No." = "Y1"
      LibrarySales.CreateCustomerWithVATRegNo(Customer[1]);

      // [GIVEN] Customer "C2" with "Country Code" = "X2" and "VAT Registration No." = "Y2"
      LibrarySales.CreateCustomerWithVATRegNo(Customer[2]);

      // [GIVEN] 1st Journal Line with "Posting Date" = "D2", empty "Account No.", "Bal. Account Type"="Customer", "Bal. Account No." = "C2"
      FindAndClearGenJnlBatch(GenJournalBatch);
      CreateCustGenJournalLine(GenJournalLine,GenJournalBatch,PostingDate[2],Customer[2]."No.",Amount[2]);

      // [GIVEN] 2nd Journal Line with "Posting Date" = "D1", empty "Account No.", "Bal. Account Type"="Customer", "Bal. Account No." = "C1"
      CreateCustGenJournalLine(GenJournalLine,GenJournalBatch,PostingDate[1],Customer[1]."No.",Amount[1]);

      // [GIVEN] 3rd Journal Line with "Posting Date" = "D2", "Account No." = "S" and empty "Bal. Account No."
      CreateGLGenJournalLine(GenJournalLine,GenJournalBatch,PostingDate[2],GLAccountNo,Amount[2]);

      // [GIVEN] 4th Journal Line with "Posting Date" = "D1", "Account No." = "S" and empty "Bal. Account No."
      CreateGLGenJournalLine(GenJournalLine,GenJournalBatch,PostingDate[1],GLAccountNo,Amount[1]);

      // [GIVEN] Change order Gen Journal Lines By "Posting Date". New line's numbers order: 2, 4, 1, 3
      GenJournalLine.SETCURRENTKEY("Journal Template Name","Journal Batch Name","Posting Date","Document No.");

      // [WHEN] Post Gen. Journal lines
      CODEUNIT.RUN(CODEUNIT::"Gen. Jnl.-Post Batch",GenJournalLine);

      // [THEN] Posted VAT Entry related to Customer "C1" has "Country Code" = "X1", "VAT Registration No." = "Y1", "Bill-to/Pay-to No." = "C1"
      FindCustLedgerEntry(CustLedgerEntry,Customer[1]."No.");
      VerifyVATEntryCVInfo(
        CustLedgerEntry."Transaction No.",
        Customer[1]."Country/Region Code",Customer[1]."VAT Registration No.",Customer[1]."No.");

      // [THEN] Posted VAT Entry related to Customer "C2" has "Country Code" = "X2", "VAT Registration No." = "Y2", "Bill-to/Pay-to No." = "C2"
      FindCustLedgerEntry(CustLedgerEntry,Customer[2]."No.");
      VerifyVATEntryCVInfo(
        CustLedgerEntry."Transaction No.",
        Customer[2]."Country/Region Code",Customer[2]."VAT Registration No.",Customer[2]."No.");
Member of Lib.Library - ERM


CreateGLAccountWithVATPostingSetup@143 Method

The procedure CreateGLAccountWithVATPostingSetup is available in codeunit 131300.

Syntax

CreateGLAccountWithVATPostingSetup@143(
    VAR VATPostingSetup@1001 : Record 325 VATPostingSetup, //Reference parameter of type Record
    GenPostingType@1003 : Option GenPostingType //Input parameter of type Option
);

Parameters

VATPostingSetup
Reference parameter of type Record
GenPostingType
Input parameter of type Option

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, General Ledger, Account, VAT, Posting, Setup.

For a clarification about how this function works, refer to the code listed below.

      FindGeneralPostingSetup(GeneralPostingSetup);
      CreateGLAccount(GLAccount);
      WITH GLAccount DO BEGIN
        VALIDATE("Account Type","Account Type"::Posting);
        VALIDATE("Gen. Posting Type",GenPostingType);
        VALIDATE("Gen. Bus. Posting Group",GeneralPostingSetup."Gen. Bus. Posting Group");
        VALIDATE("Gen. Prod. Posting Group",GeneralPostingSetup."Gen. Prod. Posting Group");
        VALIDATE("VAT Bus. Posting Group",VATPostingSetup."VAT Bus. Posting Group");
        VALIDATE("VAT Prod. Posting Group",VATPostingSetup."VAT Prod. Posting Group");
        MODIFY(TRUE);
        EXIT("No.");
      END;

Example

The below example is extracted from the test automation codeunit 134006 to show one way of using this function.

      VATPostingSetup."VAT Bus. Posting Group" := VATBusPostingGroup;
      VATPostingSetup."VAT Prod. Posting Group" := FindNoVATPostingSetup(VATBusPostingGroup);
      EXIT(LibraryERM.CreateGLAccountWithVATPostingSetup(VATPostingSetup,GLAccount."Gen. Posting Type"::Sale));
Member of Lib.Library - ERM


CreateGLBudgetEntry@91 Method

The procedure CreateGLBudgetEntry is available in codeunit 131300.

Syntax

CreateGLBudgetEntry@91(
    VAR GLBudgetEntry2@1000 : Record 96 GLBudgetEntry2, //Reference parameter of type Record
    BudgetDate@1001 : Date BudgetDate, //Input parameter of type Date
    GLAccountNo@1002 : Code[20] GLAccountNo, //Input parameter of type Code
    BudgetName@1003 : Code[10] BudgetName //Input parameter of type Code
);

Parameters

GLBudgetEntry2
Reference parameter of type Record
BudgetDate
Input parameter of type Date
GLAccountNo
Input parameter of type Code
BudgetName
Input parameter of type Code

Remarks

The relevant search keywords are: Create, General Ledger, Budget, Entry.

For a clarification about how this function works, refer to the code listed below.

      IF GLBudgetEntry.FINDLAST THEN;
      GLBudgetEntry2.INIT;
      GLBudgetEntry2.VALIDATE("Entry No.",GLBudgetEntry."Entry No." + 1);
      GLBudgetEntry2.VALIDATE("Budget Name",BudgetName);
      GLBudgetEntry2.VALIDATE("G/L Account No.",GLAccountNo);
      GLBudgetEntry2.VALIDATE(Date,BudgetDate);
      GLBudgetEntry2.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134037 to show one way of using this function.

      // [FEATURE] [G/L Budget Entry]
      // [SCENARIO 262033] It is possible to copy G/L Budget to itself with time shift
      Initialize;

      // [GIVEN] G/L Budget with 5 entries of 1000
      LibraryERM.CreateGLBudgetName(GLBudgetName);
      BudgetDate := WORKDATE;
      GLAccountNo := LibraryERM.CreateGLAccountNo;
      NumOfPeriods := LibraryRandom.RandIntInRange(3,10);
      BudgetAmount := LibraryRandom.RandDecInRange(100,1000,1);
      AdjFactor := LibraryRandom.RandDecInRange(1,3,1);

      FOR I := 1 TO NumOfPeriods DO BEGIN
        BudgetDate := CALCDATE('<1M>',BudgetDate);
        LibraryERM.CreateGLBudgetEntry(GLBudgetEntry,BudgetDate,GLAccountNo,GLBudgetName.Name);
        GLBudgetEntry.Amount := BudgetAmount;
        GLBudgetEntry.MODIFY;
      END;

      // [WHEN] Copy G/L Budget to itself with time shift and adjustment factor of 1.5
      RunCopyGLBudget(GLBudgetName.Name,GLBudgetName.Name,'<2M>',AdjFactor);

      // [THEN] 10 G/L entries in budget
      GLBudgetEntry.SETCURRENTKEY("Budget Name","G/L Account No.",Date);
      GLBudgetEntry.SETRANGE("Budget Name",GLBudgetName.Name);
      Assert.RecordCount(GLBudgetEntry,NumOfPeriods * 2);

      // [THEN] Sum of G/L Budget Entries is 12500
      GLBudgetEntry.CALCSUMS(Amount);
      GLBudgetEntry.TESTFIELD(Amount,ROUND(BudgetAmount * NumOfPeriods * (1 + AdjFactor)));
Member of Lib.Library - ERM


CreateGLBudgetName@79 Method

The procedure CreateGLBudgetName is available in codeunit 131300.

Syntax

CreateGLBudgetName@79(
    VAR GLBudgetName@1000 : Record 95 GLBudgetName //Reference parameter of type Record
);

Parameters

GLBudgetName
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, General Ledger, Budget, Name.

For a clarification about how this function works, refer to the code listed below.

      GLBudgetName.INIT;
      GLBudgetName.VALIDATE(Name,LibraryUtility.GenerateRandomCode(GLBudgetName.FIELDNO(Name),DATABASE::"G/L Budget Name"));
      GLBudgetName.VALIDATE(Description,GLBudgetName.Name);
      GLBudgetName.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134037 to show one way of using this function.

      // Create a new budget and run copy budget batch to copy budget entry
      LibraryERM.CreateGLBudgetName(GLBudgetName);

      CopyGLBudget(CopyFromBudgetName,GLBudgetName.Name,FromBudgetEntryCount,BudgetYear);

      // Run Date compression GL Budget for the newly created budget
      RunDateCompressBudget(GLBudgetName.Name,BudgetYear,PeriodLength);

      // Validate budget entry after compression
      ValidateBudgetEntry(GLBudgetName.Name,FromBudgetEntryCount,FromBudgetEntryAmountSum);
Member of Lib.Library - ERM


CreateICGLAccount@111 Method

The procedure CreateICGLAccount is available in codeunit 131300.

Syntax

CreateICGLAccount@111(
    VAR ICGLAccount@1000 : Record 410 ICGLAccount //Reference parameter of type Record
);

Parameters

ICGLAccount
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, ICGL, Account.

For a clarification about how this function works, refer to the code listed below.

      ICGLAccount.INIT;
      ICGLAccount.VALIDATE(
        "No.",
        COPYSTR(
          LibraryUtility.GenerateRandomCode(ICGLAccount.FIELDNO("No."),DATABASE::"IC G/L Account"),1,
          LibraryUtility.GetFieldLength(DATABASE::"IC G/L Account",ICGLAccount.FIELDNO("No."))));
      ICGLAccount.VALIDATE(Name,ICGLAccount."No.");  // Validating No. as Name because value is not important.
      ICGLAccount.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134151 to show one way of using this function.

      LibraryERM.CreateGLAccount(GLAccount);
      LibraryERM.CreateICGLAccount(ICGLAccount);
      ICGLAccount.VALIDATE("Map-to G/L Acc. No.",GLAccount."No.");
      ICGLAccount.MODIFY(TRUE);
Member of Lib.Library - ERM


CreateICPartner@108 Method

The procedure CreateICPartner is available in codeunit 131300.

Syntax

CreateICPartner@108(
    VAR ICPartner@1000 : Record 413 ICPartner //Reference parameter of type Record
);

Parameters

ICPartner
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Inter-Company, Partner.

For a clarification about how this function works, refer to the code listed below.

      ICPartner.INIT;
      ICPartner.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(ICPartner.FIELDNO(Code),DATABASE::"IC Partner"),1,
          LibraryUtility.GetFieldLength(DATABASE::"IC Partner",ICPartner.FIELDNO(Code))));
      ICPartner.VALIDATE(Name,ICPartner.Code);  // Validating Name as Code because value is not important.
      ICPartner.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134151 to show one way of using this function.

      // Setup: Create IC Partner without Receivable and Payable Account and Create IC General Journal Line.
      LibraryERM.CreateICPartner(ICPartner);
      CreateAndUpdateICJournalLine(
        GenJournalLine,GenJournalLine."Document Type"::Invoice,GenJournalLine."Account Type"::"IC Partner",ICPartner.Code,SignFactor);

      // Exercise.
      ASSERTERROR LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // Verify: Verify Error Message.
      Assert.ExpectedError(STRSUBSTNO(AccountErr,FieldCaption,ICPartner.Code));
Member of Lib.Library - ERM


CreateIncomeTaxAccountingPeriod@1500003 Method

The procedure CreateIncomeTaxAccountingPeriod is available in codeunit 131300.

Syntax

CreateIncomeTaxAccountingPeriod@1500003(
    VAR IncomeTaxAccountingPeriod@1000 : Record 13724 IncomeTaxAccountingPeriod //Reference parameter of type Record
);

Parameters

IncomeTaxAccountingPeriod
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Income, Tax, Accounting, Period.

For a clarification about how this function works, refer to the code listed below.

      IF IncomeTaxAccountingPeriod.FINDLAST THEN
        No := IncomeTaxAccountingPeriod."No." + LibraryRandom.RandInt(2)
      ELSE
        No := LibraryRandom.RandInt(2);
      IncomeTaxAccountingPeriod.INIT;
      IncomeTaxAccountingPeriod.VALIDATE("No.",No);
      IncomeTaxAccountingPeriod.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 144015 to show one way of using this function.

      LibraryERM.CreateIncomeTaxAccountingPeriod(IncomeTaxAccountingPeriod);
      IncomeTaxAccountingPeriod.VALIDATE("Starting Date",WORKDATE);
      IncomeTaxAccountingPeriod.VALIDATE("Ending Date",LibraryRandom.RandDate(5));
      IncomeTaxAccountingPeriod.MODIFY(TRUE);
      CreateIncomeTaxPeriodSetup(IncomeTaxAccountingPeriod."No.");
Member of Lib.Library - ERM


CreateIncomeTaxPeriod@1500004 Method

The procedure CreateIncomeTaxPeriod is available in codeunit 131300.

Syntax

CreateIncomeTaxPeriod@1500004(
    VAR IncomeTaxPeriodSetUp@1500000 : Record 16501 IncomeTaxPeriodSetUp, //Reference parameter of type Record
    IncomeTaxAccountingPeriodNo@1500001 : Integer IncomeTaxAccountingPeriodNo, //Input parameter of type Integer
    Quarter@1500002 : Option Quarter //Input parameter of type Option
);

Parameters

IncomeTaxPeriodSetUp
Reference parameter of type Record
IncomeTaxAccountingPeriodNo
Input parameter of type Integer
Quarter
Input parameter of type Option

Remarks

The relevant search keywords are: Create, Income, Tax, Period.

For a clarification about how this function works, refer to the code listed below.

      IncomeTaxPeriodSetUp.INIT;
      IncomeTaxPeriodSetUp.VALIDATE("No.",IncomeTaxAccountingPeriodNo);
      IncomeTaxPeriodSetUp.VALIDATE(Quarter,Quarter);
      IncomeTaxPeriodSetUp.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 144013 to show one way of using this function.

      LibrarySetupStorage.Restore;
      IF isInitialized THEN
        EXIT;
      GeneralLedgerSetup.GET;
      CompanyInformation.GET;
      LibraryTDS.CreateDeductoryCodeAndUpdateOnCompanyInformation(CompanyInformation);
      LibraryTDS.UpdateTDSNilChallanInGeneralLedgerSetup;
      LibraryTDS.CreateIncomeTaxAccPeriod(IncomeTaxAccountingPeriod);
      LibraryTDS.CreateIncomeTaxPeriod(IncomeTaxPeriodSetup,IncomeTaxAccountingPeriod."No.",1);
      LibraryTDS.CreateAssesseeandNODNOCSetup(
        NodNocHeader,TDSNatureOfDeduction,TDSSetup,'',ServiceTaxWithTDSHelper.CreateVendorWithPANNo,NodNocHeader.Type::Vendor,
        IncomeTaxAccountingPeriod."Starting Date");
      isInitialized := TRUE;
      COMMIT;
      LibrarySetupStorage.Save(DATABASE::"Company Information");
Member of Lib.Library - ERM


CreateInsurance@46 Method

The procedure CreateInsurance is available in codeunit 131300.

Syntax

CreateInsurance@46(
    VAR Insurance@1000 : Record 5628 Insurance //Reference parameter of type Record
);

Parameters

Insurance
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Insurance.

For a clarification about how this function works, refer to the code listed below.

      Insurance.INIT;
      Insurance.INSERT(TRUE);
      Insurance.VALIDATE(Description,Insurance."No.");  // Validating No as Description because value is not important.
      Insurance.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134478 to show one way of using this function.

      // Test the Dimension in Insurance Ledger Entry.

      // 1.Setup: Create Insurance Journal Line, create Dimension for Insurance Journal.
      Initialize;
      LibraryFixedAsset.CreateInsurance(Insurance);
      CreateInsuranceJournalLine(InsuranceJournalLine,Insurance."No.");
      DimensionOnInsuranceJournal(InsuranceJournalLine);
      FANo := InsuranceJournalLine."FA No.";
      DimensionSetID := InsuranceJournalLine."Dimension Set ID";

      // 2.Exercise: Post the created Insurance Journal Line.
      LibraryFixedAsset.PostInsuranceJournal(InsuranceJournalLine);

      // 3.Verify: Verify Insurance Ledger Entry.
      VerifyInsCoverageLedgerEntry(FANo,DimensionSetID);
Member of Lib.Library - ERM


CreateIntrastatContact@227 Method

The procedure CreateIntrastatContact is available in codeunit 131300.

Syntax

CreateIntrastatContact@227(
    ContactType@1000 : Option ContactType //Input parameter of type Option
);

Parameters

ContactType
Input parameter of type Option

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Intrastat, Contact.

For a clarification about how this function works, refer to the code listed below.

      CASE ContactType OF
        CompanyInformation."Intrastat Contact Type"::Contact:
          EXIT(LibraryMarketing.CreateIntrastatContact(CreateCountryRegionWithIntrastatCode));
        CompanyInformation."Intrastat Contact Type"::Vendor:
          EXIT(LibraryPurchase.CreateIntrastatContact(CreateCountryRegionWithIntrastatCode));
      END;

Example

The below example is extracted from the test automation codeunit 134150 to show one way of using this function.

      // [FEATURE] [Intrastat Setup] [UT] [UI]
      // [SCENARIO 255730] Set "Intrastat Contact Type" and "Intrastat Contact No." fields via "Intrastat Setup" page
      Initialize;

      // Set "Intrastat Contact Type" = "Contact"
      IntrastatContactNo := LibraryERM.CreateIntrastatContact(CompanyInformation."Intrastat Contact Type"::Contact);
      SetIntrastatContactViaPage(CompanyInformation."Intrastat Contact Type"::Contact,IntrastatContactNo);
      VerifyIntrastatContact(CompanyInformation."Intrastat Contact Type"::Contact,IntrastatContactNo);

      // Set "Intrastat Contact Type" = "Vendor"
      IntrastatContactNo := LibraryERM.CreateIntrastatContact(CompanyInformation."Intrastat Contact Type"::Vendor);
      SetIntrastatContactViaPage(CompanyInformation."Intrastat Contact Type"::Vendor,IntrastatContactNo);
      VerifyIntrastatContact(CompanyInformation."Intrastat Contact Type"::Vendor,IntrastatContactNo);

      // Trying to set "Intrastat Contact Type" = "Contact" with vendor
      Vendor.GET(LibraryPurchase.CreateIntrastatContact(''));
      ASSERTERROR SetIntrastatContactViaPage(CompanyInformation."Intrastat Contact Type"::Contact,Vendor."No.");
      Assert.ExpectedErrorCode('TestValidation');
      Assert.ExpectedError(Contact.TABLECAPTION);

      // Trying to set "Intrastat Contact Type" = "Vendor" with contact
      Contact.GET(LibraryMarketing.CreateIntrastatContact(''));
      ASSERTERROR SetIntrastatContactViaPage(CompanyInformation."Intrastat Contact Type"::Vendor,Contact."No.");
      Assert.ExpectedErrorCode('TestValidation');
      Assert.ExpectedError(Vendor.TABLECAPTION);
Member of Lib.Library - ERM


CreateIntrastatJnlBatch@97 Method

The procedure CreateIntrastatJnlBatch is available in codeunit 131300.

Syntax

CreateIntrastatJnlBatch@97(
    VAR IntrastatJnlBatch@1000 : Record 262 IntrastatJnlBatch, //Reference parameter of type Record
    JournalTemplateName@1001 : Code[10] JournalTemplateName //Input parameter of type Code
);

Parameters

IntrastatJnlBatch
Reference parameter of type Record
JournalTemplateName
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Intrastat, Journal, Batch.

For a clarification about how this function works, refer to the code listed below.

      IntrastatJnlBatch.INIT;
      IntrastatJnlBatch.VALIDATE("Journal Template Name",JournalTemplateName);
      IntrastatJnlBatch.VALIDATE(
        Name,LibraryUtility.GenerateRandomCode(IntrastatJnlBatch.FIELDNO(Name),DATABASE::"Intrastat Jnl. Batch"));
      IntrastatJnlBatch.VALIDATE(Description,IntrastatJnlBatch.Name);
      IntrastatJnlBatch.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134063 to show one way of using this function.

      LibraryERM.CreateIntrastatJnlBatch(IntrastatJnlBatch,JournalTemplateName);
      IntrastatJnlBatch.VALIDATE("Statistics Period",FORMAT(JournalDate,0,'<Year><Month,2>'));  // Take Value in YYMM format.
      IntrastatJnlBatch.MODIFY(TRUE);
Member of Lib.Library - ERM


CreateIntrastatJnlLine@96 Method

The procedure CreateIntrastatJnlLine is available in codeunit 131300.

Syntax

CreateIntrastatJnlLine@96(
    VAR IntrastatJnlLine@1002 : Record 263 IntrastatJnlLine, //Reference parameter of type Record
    JournalTemplateName@1001 : Code[10] JournalTemplateName, //Input parameter of type Code
    JournalBatchName@1000 : Code[10] JournalBatchName //Input parameter of type Code
);

Parameters

IntrastatJnlLine
Reference parameter of type Record
JournalTemplateName
Input parameter of type Code
JournalBatchName
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Intrastat, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      IntrastatJnlLine.INIT;
      IntrastatJnlLine.VALIDATE("Journal Template Name",JournalTemplateName);
      IntrastatJnlLine.VALIDATE("Journal Batch Name",JournalBatchName);
      RecRef.GETTABLE(IntrastatJnlLine);
      IntrastatJnlLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,IntrastatJnlLine.FIELDNO("Line No.")));
      IntrastatJnlLine.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134063 to show one way of using this function.

      LibraryERM.CreateIntrastatJnlTemplate(IntrastatJnlTemplate);
      CreateAndUpdateIntrastatBatch(IntrastatJnlBatch,IntrastatJnlTemplate.Name,JournalDate);
      LibraryERM.CreateIntrastatJnlLine(IntrastatJnlLine,IntrastatJnlBatch."Journal Template Name",IntrastatJnlBatch.Name);
Member of Lib.Library - ERM


CreateIntrastatJnlTemplate@98 Method

The procedure CreateIntrastatJnlTemplate is available in codeunit 131300.

Syntax

CreateIntrastatJnlTemplate@98(
    VAR IntrastatJnlTemplate@1000 : Record 261 IntrastatJnlTemplate //Reference parameter of type Record
);

Parameters

IntrastatJnlTemplate
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Intrastat, Journal, Template.

For a clarification about how this function works, refer to the code listed below.

      IntrastatJnlTemplate.INIT;
      IntrastatJnlTemplate.VALIDATE(
        Name,LibraryUtility.GenerateRandomCode(IntrastatJnlTemplate.FIELDNO(Name),DATABASE::"Intrastat Jnl. Template"));
      IntrastatJnlTemplate.VALIDATE(Description,IntrastatJnlTemplate.Name);
      IntrastatJnlTemplate.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134063 to show one way of using this function.

      LibraryERM.CreateIntrastatJnlTemplate(IntrastatJnlTemplate);
      CreateAndUpdateIntrastatBatch(IntrastatJnlBatch,IntrastatJnlTemplate.Name,JournalDate);
      LibraryERM.CreateIntrastatJnlLine(IntrastatJnlLine,IntrastatJnlBatch."Journal Template Name",IntrastatJnlBatch.Name);
Member of Lib.Library - ERM


CreateIntrastatJnlTemplateAndBatch@187 Method

The procedure CreateIntrastatJnlTemplateAndBatch is available in codeunit 131300.

Syntax

CreateIntrastatJnlTemplateAndBatch@187(
    VAR IntrastatJnlBatch@1000 : Record 262 IntrastatJnlBatch, //Reference parameter of type Record
    JournalDate@1002 : Date JournalDate //Input parameter of type Date
);

Parameters

IntrastatJnlBatch
Reference parameter of type Record
JournalDate
Input parameter of type Date

Remarks

The relevant search keywords are: Create, Intrastat, Journal, Template, Batch.

For a clarification about how this function works, refer to the code listed below.

      CreateIntrastatJnlTemplate(IntrastatJnlTemplate);
      CreateIntrastatJnlBatch(IntrastatJnlBatch,IntrastatJnlTemplate.Name);
      IntrastatJnlBatch.VALIDATE(
        "Statistics Period",FORMAT(JournalDate,0,LibraryFiscalYear.GetStatisticsPeriod));
      IntrastatJnlBatch.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134150 to show one way of using this function.

      // [FEATURE] [Purchase]
      // [SCENARIO] Check Intrastat Journal Entries after Posting Purchase Order and Get Entries with New Posting Date.

      // [GIVEN] Create Purchase Order with New Posting Date and Create New Batch and Template for Intrastat Journal with difference with 1 Year.
      Initialize;
      NewPostingDate := CALCDATE('<' + FORMAT(LibraryRandom.RandInt(5)) + 'Y>',WORKDATE);
      CreateAndPostPurchaseOrder(PurchaseLine,NewPostingDate);

      // [GIVEN] Two Intrastat Journal Batches for the same period
      LibraryERM.CreateIntrastatJnlTemplateAndBatch(IntrastatJnlBatch,NewPostingDate);
      LibraryERM.CreateIntrastatJnlTemplateAndBatch(SecondIntrastatJnlBatch,NewPostingDate);

      COMMIT;  // Commit is required to commit the posted entries.
      LibraryVariableStorage.Enqueue(IntrastatJnlBatch."Journal Template Name");
      LibraryVariableStorage.Enqueue(TRUE); // Show Item Charge entries

      // [WHEN] Get Entries from Intrastat Journal pages for two Batches with the same period with "Show item charge entries" options set to TRUE
      // use created "Journal Template Name" in IntrastatJnlTemplateListPageHandler
      IntrastatJournal.OPENEDIT;
      IntrastatJournal.GetEntries.INVOKE;

      // [THEN] Verify that Entry values on Intrastat Journal Page match Purchase Line values
      IntrastatJournal.FILTER.SETFILTER("Item No.",PurchaseLine."No.");
      IntrastatJournal.Type.ASSERTEQUALS(FORMAT(IntrastatJournal.Type.GETOPTION(1))); // Option 1 for Receipt Value.
      IntrastatJournal.Quantity.ASSERTEQUALS(PurchaseLine.Quantity);
      IntrastatJournal.Date.ASSERTEQUALS(NewPostingDate);

      // [THEN] No Entries suggested in a second Intrastat Journal
      // added verification for TFS 375494 scenario
      LibraryVariableStorage.Enqueue(SecondIntrastatJnlBatch."Journal Template Name");
      LibraryVariableStorage.Enqueue(TRUE); // Show Item Charge entries
      OpenAndVerifyIntrastatJournalLine(SecondIntrastatJnlBatch.Name,PurchaseLine."No.",FALSE);

      IntrastatJnlBatch.DELETE(TRUE);
      SecondIntrastatJnlBatch.DELETE(TRUE);
Member of Lib.Library - ERM


CreateInvDiscForCustomer@17 Method

The procedure CreateInvDiscForCustomer is available in codeunit 131300.

Syntax

CreateInvDiscForCustomer@17(
    VAR CustInvoiceDisc@1000 : Record 19 CustInvoiceDisc, //Reference parameter of type Record
    Code@1001 : Code[20] Code, //Input parameter of type Code
    CurrencyCode@1003 : Code[10] CurrencyCode, //Input parameter of type Code
    MinimumAmount@1004 : Decimal MinimumAmount //Input parameter of type Decimal
);

Parameters

CustInvoiceDisc
Reference parameter of type Record
Code
Input parameter of type Code
CurrencyCode
Input parameter of type Code
MinimumAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Invoice, Discount, For, Customer.

For a clarification about how this function works, refer to the code listed below.

      CustInvoiceDisc.INIT;
      CustInvoiceDisc.VALIDATE(Code,Code);
      CustInvoiceDisc.VALIDATE("Currency Code",CurrencyCode);
      CustInvoiceDisc.VALIDATE("Minimum Amount",MinimumAmount);
      CustInvoiceDisc.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134039 to show one way of using this function.

      LibraryERM.CreateInvDiscForCustomer(CustInvoiceDisc,CustomerNo,'',0);  // Set Zero for Charge Amount.
      CustInvoiceDisc.VALIDATE("Discount %",LibraryRandom.RandDec(10,2));  // Take Random Discount.
      CustInvoiceDisc.MODIFY(TRUE);
Member of Lib.Library - ERM


CreateInvDiscForVendor@9 Method

The procedure CreateInvDiscForVendor is available in codeunit 131300.

Syntax

CreateInvDiscForVendor@9(
    VAR VendorInvoiceDisc@1000 : Record 24 VendorInvoiceDisc, //Reference parameter of type Record
    Code@1001 : Code[20] Code, //Input parameter of type Code
    CurrencyCode@1003 : Code[10] CurrencyCode, //Input parameter of type Code
    MinimumAmount@1004 : Decimal MinimumAmount //Input parameter of type Decimal
);

Parameters

VendorInvoiceDisc
Reference parameter of type Record
Code
Input parameter of type Code
CurrencyCode
Input parameter of type Code
MinimumAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Invoice, Discount, For, Vendor.

For a clarification about how this function works, refer to the code listed below.

      VendorInvoiceDisc.INIT;
      VendorInvoiceDisc.VALIDATE(Code,Code);
      VendorInvoiceDisc.VALIDATE("Currency Code",CurrencyCode);
      VendorInvoiceDisc.VALIDATE("Minimum Amount",MinimumAmount);
      VendorInvoiceDisc.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134039 to show one way of using this function.

      LibraryERM.CreateInvDiscForVendor(VendorInvoiceDisc,VendorNo,'',0); // Set Zero for Charge Amount.
      VendorInvoiceDisc.VALIDATE("Discount %",LibraryRandom.RandDec(10,2));  // Take Random Discount.
      VendorInvoiceDisc.MODIFY(TRUE);
Member of Lib.Library - ERM


CreateItemAnalysisView@88 Method

The procedure CreateItemAnalysisView is available in codeunit 131300.

Syntax

CreateItemAnalysisView@88(
    VAR ItemAnalysisView@1001 : Record 7152 ItemAnalysisView, //Reference parameter of type Record
    AnalysisArea@1000 : Option AnalysisArea //Input parameter of type Option
);

Parameters

ItemAnalysisView
Reference parameter of type Record
AnalysisArea
Input parameter of type Option

Remarks

The relevant search keywords are: Create, Item, Analysis, View.

For a clarification about how this function works, refer to the code listed below.

      ItemAnalysisView.INIT;
      ItemAnalysisView.VALIDATE("Analysis Area",AnalysisArea);
      ItemAnalysisView.VALIDATE(Code,LibraryUtility.GenerateRandomCode(ItemAnalysisView.FIELDNO(Code),DATABASE::"Item Analysis View"));
      // Validating Name as Code because value is not important.
      ItemAnalysisView.VALIDATE(Name,ItemAnalysisView.Code);
      ItemAnalysisView.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134327 to show one way of using this function.

      // Check Cost Amount(Expected) on Purchase Analysis Matrix when Item Ledger Entry Type Filter Purchase.

      // Setup: Post Purchase Document with Ship Option and Create Analysis Report Name.
      Initialize;
      ItemNo := CreateItem;
      CreatePurchaseOrder(PurchaseHeader,PurchaseLine,ItemNo);
      FindValueEntry(ValueEntry,ItemNo,PurchaseHeader."Buy-from Vendor No.",
        LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,FALSE));
      LibraryVariableStorage.Enqueue(ValueEntry."Cost Amount (Expected)");
      LibraryERM.CreateItemAnalysisView(ItemAnalysisView,ItemAnalysisView."Analysis Area"::Purchase);
      LibraryInventory.CreateAnalysisReportName(AnalysisReportName,ItemAnalysisView."Analysis Area");

      // Exercise: Open Analysis Report Purchase with Correct filter Item Ledger Entry Type Purchase.
      OpenAnalysisReportPurchase(AnalysisReportName.Name,
        CreateAnalysisLineWithTypeVendor(ItemAnalysisView."Analysis Area",PurchaseHeader."Buy-from Vendor No."),
        CreateAnalysisColumnWithItemLedgerEntryType(ItemAnalysisView."Analysis Area",
          FORMAT(ValueEntry."Item Ledger Entry Type"::Purchase),AnalysisColumn."Value Type"::"Cost Amount"));

      // Verify: Verification done in PurchaseAnalysisMatrixRequestPageHandler.
Member of Lib.Library - ERM


CreateItemBudgetName@230 Method

The procedure CreateItemBudgetName is available in codeunit 131300.

Syntax

CreateItemBudgetName@230(
    VAR ItemBudgetName@1000 : Record 7132 ItemBudgetName, //Reference parameter of type Record
    AnalysisArea@1001 : Option AnalysisArea //Input parameter of type Option
);

Parameters

ItemBudgetName
Reference parameter of type Record
AnalysisArea
Input parameter of type Option

Remarks

The relevant search keywords are: Create, Item, Budget, Name.

For a clarification about how this function works, refer to the code listed below.

      ItemBudgetName.INIT;
      ItemBudgetName.VALIDATE("Analysis Area",AnalysisArea);
      ItemBudgetName.VALIDATE(Name,LibraryUtility.GenerateGUID);
      ItemBudgetName.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134922 to show one way of using this function.

      // [FEATURE] [Sales]
      // [SCENARIO 274259] "Sales Budget Overview" page saves values previously set

      Initialize;

      // [GIVEN] New Dimension "ABC"
      LibraryDimension.CreateDimension(Dimension);

      // [GIVEN] Sales Budget "X" with "Budget Dimension 1 Code" = "ABC"
      LibraryERM.CreateItemBudgetName(ItemBudgetName,ItemBudgetName."Analysis Area"::Sales);
      ItemBudgetName.VALIDATE("Budget Dimension 1 Code",Dimension.Code);
      ItemBudgetName.MODIFY(TRUE);

      // [GIVEN] Opened page "Sales Budgets" with Budget "X"
      BudgetNamesSales.OPENEDIT;
      BudgetNamesSales.FILTER.SETFILTER(Name,ItemBudgetName.Name);
      SalesBudgetOverview.TRAP;

      // [GIVEN] "Sales Budget Overview" page opened and "X" set for "Show as Lines"
      BudgetNamesSales.EditBudget.INVOKE;
      SalesBudgetOverview.LineDimCode.SETVALUE(Dimension.Code);
      SalesBudgetOverview.CLOSE;
      SalesBudgetOverview.TRAP;

      // [WHEN] Open "Sales Budget Overview" page again
      BudgetNamesSales.EditBudget.INVOKE;

      // [THEN] "Show as Lines" is "X"
      Assert.AreEqual(Dimension.Code,SalesBudgetOverview.LineDimCode.VALUE,'Value was not saved on Sales Budget Overview page');
Member of Lib.Library - ERM


CreateItemDiscountGroup@205 Method

The procedure CreateItemDiscountGroup is available in codeunit 131300.

Syntax

CreateItemDiscountGroup@205(
    VAR ItemDiscountGroup@1001 : Record 341 ItemDiscountGroup //Reference parameter of type Record
);

Parameters

ItemDiscountGroup
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Item, Discount, Group.

For a clarification about how this function works, refer to the code listed below.

      ItemDiscountGroup.INIT;
      ItemDiscountGroup.VALIDATE(
        Code,LibraryUtility.GenerateRandomCode(ItemDiscountGroup.FIELDNO(Code),DATABASE::"Item Discount Group"));
      ItemDiscountGroup.VALIDATE(Description,ItemDiscountGroup.Code);  // Validating Code as Description because value is not important.
      ItemDiscountGroup.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136353 to show one way of using this function.

      // [FEATURE] [Discount] [Line Discount] [Item Variant]
      // [SCENARIO 212422] "Line Discount %" of Job Planning Line is zero when "Allow Line Disc." is No in Sales Price for "All Customers", Item with Variant and Customer has "Line Discount" from Customer Discount Group

      Initialize;

      // [GIVEN] Customer Discount Group "CUSTDISC" assigned to Customer "C"
      LibraryERM.CreateCustomerDiscountGroup(CustomerDiscountGroup);
      LibrarySales.CreateCustomer(Customer);
      Customer.VALIDATE("Customer Disc. Group",CustomerDiscountGroup.Code);
      Customer.MODIFY(TRUE);

      // [GIVEN] Job and Job Task with Customer "C"
      LibraryJob.CreateJob(Job);
      Job.VALIDATE("Bill-to Customer No.",Customer."No.");
      Job.MODIFY(TRUE);
      LibraryJob.CreateJobTask(Job,JobTask);

      // [GIVEN] Item "X" with Variant "X1" and Item Discount Group "ITEMDISC"
      LibraryInventory.CreateItem(Item);
      LibraryInventory.CreateVariant(ItemVariant,Item);
      LibraryERM.CreateItemDiscountGroup(ItemDiscountGroup);
      Item.VALIDATE("Item Disc. Group",ItemDiscountGroup.Code);
      Item.MODIFY(TRUE);

      // [GIVEN] Sales Line Discount with Customer Discount Group "CUSTDISC", Item Discount Group "ITEMDISC" and "Line Discount %" = 10
      LibraryERM.CreateLineDiscForCustomer(
        SalesLineDiscount,SalesLineDiscount.Type::"Item Disc. Group",ItemDiscountGroup.Code,
        SalesLineDiscount."Sales Type"::"Customer Disc. Group",CustomerDiscountGroup.Code,WORKDATE,'','','',0);
      SalesLineDiscount.VALIDATE("Line Discount %",LibraryRandom.RandDec(10,2));
      SalesLineDiscount.MODIFY(TRUE);

      // [GIVEN] Sales Price for All Customers for Item "X", Variant "X1" is 50, "Allow Line Disc." = No
      LibrarySales.CreateSalesPrice(
        SalesPrice,Item."No.",SalesPrice."Sales Type"::"All Customers",'',
        WORKDATE,'',ItemVariant.Code,Item."Base Unit of Measure",0,LibraryRandom.RandDec(100,2));
      SalesPrice.VALIDATE("Allow Line Disc.",FALSE);
      SalesPrice.MODIFY(TRUE);

      // [GIVEN] Job Planning Line with Item "X"
      CreateSimpleJobPlanningLine(JobPlanningLine,JobTask);
      JobPlanningLine.VALIDATE(Type,JobPlanningLine.Type::Item);
      JobPlanningLine.VALIDATE("No.",Item."No.");

      // [WHEN] Validate Variant "X1" on Job Planning Line
      JobPlanningLine.VALIDATE("Variant Code",ItemVariant.Code);

      // [THEN] "Line Discount %" in Job Planning Line is 0%
      JobPlanningLine.TESTFIELD("Line Discount %",0);
Member of Lib.Library - ERM


CreateLineDiscForCustomer@23 Method

The procedure CreateLineDiscForCustomer is available in codeunit 131300.

Syntax

CreateLineDiscForCustomer@23(
    VAR SalesLineDiscount@1001 : Record 7004 SalesLineDiscount, //Reference parameter of type Record
    Type@1000 : Option Type, //Input parameter of type Option
    Code@1002 : Code[20] Code, //Input parameter of type Code
    SalesType@1003 : Option SalesType, //Input parameter of type Option
    SalesCode@1004 : Code[20] SalesCode, //Input parameter of type Code
    StartingDate@1005 : Date StartingDate, //Input parameter of type Date
    CurrencyCode@1006 : Code[10] CurrencyCode, //Input parameter of type Code
    VariantCode@1007 : Code[10] VariantCode, //Input parameter of type Code
    UnitOfMeasureCode@1008 : Code[10] UnitOfMeasureCode, //Input parameter of type Code
    MinimumQuantity@1009 : Decimal MinimumQuantity //Input parameter of type Decimal
);

Parameters

SalesLineDiscount
Reference parameter of type Record
Type
Input parameter of type Option
Code
Input parameter of type Code
SalesType
Input parameter of type Option
SalesCode
Input parameter of type Code
StartingDate
Input parameter of type Date
CurrencyCode
Input parameter of type Code
VariantCode
Input parameter of type Code
UnitOfMeasureCode
Input parameter of type Code
MinimumQuantity
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Line, Discount, For, Customer.

For a clarification about how this function works, refer to the code listed below.

      SalesLineDiscount.INIT;
      SalesLineDiscount.VALIDATE(Type,Type);
      SalesLineDiscount.VALIDATE(Code,Code);
      SalesLineDiscount.VALIDATE("Sales Type",SalesType);
      SalesLineDiscount.VALIDATE("Sales Code",SalesCode);
      SalesLineDiscount.VALIDATE("Starting Date",StartingDate);
      SalesLineDiscount.VALIDATE("Currency Code",CurrencyCode);
      IF Type = SalesLineDiscount.Type::Item THEN BEGIN
        SalesLineDiscount.VALIDATE("Variant Code",VariantCode);
        SalesLineDiscount.VALIDATE("Unit of Measure Code",UnitOfMeasureCode);
      END;
      SalesLineDiscount.VALIDATE("Minimum Quantity",MinimumQuantity);
      SalesLineDiscount.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134332 to show one way of using this function.

      // Create a random discount without item quantity limitation (to be sure it is applied when recalculating lines)
      LibraryERM.CreateLineDiscForCustomer(SalesLineDiscount,
        SalesLineDiscount.Type::Item,Item."No.",SalesLineDiscount."Sales Type"::Customer,CustomerCode,WORKDATE,'','',
        Item."Base Unit of Measure",0);
      SalesLineDiscount.VALIDATE("Line Discount %",LibraryRandom.RandInt(100));
      SalesLineDiscount.MODIFY(TRUE);
Member of Lib.Library - ERM


CreateLineDiscForVendor@29 Method

The procedure CreateLineDiscForVendor is available in codeunit 131300.

Syntax

CreateLineDiscForVendor@29(
    VAR PurchaseLineDiscount@1000 : Record 7014 PurchaseLineDiscount, //Reference parameter of type Record
    ItemNo@1001 : Code[20] ItemNo, //Input parameter of type Code
    VendorNo@1002 : Code[20] VendorNo, //Input parameter of type Code
    StartingDate@1003 : Date StartingDate, //Input parameter of type Date
    CurrencyCode@1004 : Code[10] CurrencyCode, //Input parameter of type Code
    VariantCode@1005 : Code[10] VariantCode, //Input parameter of type Code
    UnitofMeasureCode@1006 : Code[10] UnitofMeasureCode, //Input parameter of type Code
    MinimumQuantity@1007 : Decimal MinimumQuantity //Input parameter of type Decimal
);

Parameters

PurchaseLineDiscount
Reference parameter of type Record
ItemNo
Input parameter of type Code
VendorNo
Input parameter of type Code
StartingDate
Input parameter of type Date
CurrencyCode
Input parameter of type Code
VariantCode
Input parameter of type Code
UnitofMeasureCode
Input parameter of type Code
MinimumQuantity
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Line, Discount, For, Vendor.

For a clarification about how this function works, refer to the code listed below.

      PurchaseLineDiscount.INIT;
      PurchaseLineDiscount.VALIDATE("Item No.",ItemNo);
      PurchaseLineDiscount.VALIDATE("Vendor No.",VendorNo);
      PurchaseLineDiscount.VALIDATE("Starting Date",StartingDate);
      PurchaseLineDiscount.VALIDATE("Currency Code",CurrencyCode);
      PurchaseLineDiscount.VALIDATE("Variant Code",VariantCode);
      PurchaseLineDiscount.VALIDATE("Unit of Measure Code",UnitofMeasureCode);
      PurchaseLineDiscount.VALIDATE("Minimum Quantity",MinimumQuantity);
      PurchaseLineDiscount.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134327 to show one way of using this function.

      // Required Random Value for "Minimum Quantity" and "Line Discount %" fields value is not important.
      Item.GET(CreateItem);
      LibraryERM.CreateLineDiscForVendor(
        PurchaseLineDiscount,Item."No.",CreateVendor,WORKDATE,'','',Item."Base Unit of Measure",LibraryRandom.RandInt(10));
      PurchaseLineDiscount.VALIDATE("Line Discount %",LibraryRandom.RandInt(10));
      PurchaseLineDiscount.MODIFY(TRUE);
Member of Lib.Library - ERM


CreateNODNOCHeader@1500011 Method

The procedure CreateNODNOCHeader is available in codeunit 131300.

Syntax

CreateNODNOCHeader@1500011(
    VAR NODNOCHeader@1500000 : Record 13786 NODNOCHeader, //Reference parameter of type Record
    Type@1500001 : Option Type, //Input parameter of type Option
    No@1500002 : Code[20] No //Input parameter of type Code
);

Parameters

NODNOCHeader
Reference parameter of type Record
Type
Input parameter of type Option
No
Input parameter of type Code

Remarks

The relevant search keywords are: Create, NODNOC, Header.

For a clarification about how this function works, refer to the code listed below.

      NODNOCHeader.INIT;
      NODNOCHeader.VALIDATE(Type,Type);
      NODNOCHeader.VALIDATE("No.",No);
      NODNOCHeader.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 144020 to show one way of using this function.

      LibraryERM.CreateNODNOCHeader(NODNOCHeader,Type,No);
      NODNOCHeader.VALIDATE("Assesse Code",AssesseeCode);
      NODNOCHeader.MODIFY(TRUE);
      LibraryERM.CreateNODNOCLines(NODNOCLines,NODNOCHeader,CodeContractor);
      IF CodeOthers <> '' THEN
        LibraryERM.CreateNODNOCLines(NODNOCLines,NODNOCHeader,CodeOthers);
      UpdateNODNOCLines(NODNOCLines,NODNOCHeader.Type::Vendor);
Member of Lib.Library - ERM


CreateNODNOCLines@1500012 Method

The procedure CreateNODNOCLines is available in codeunit 131300.

Syntax

CreateNODNOCLines@1500012(
    VAR NODNOCLines@1500000 : Record 13785 NODNOCLines, //Reference parameter of type Record
    NODNOCHeader@1500001 : Record 13786 NODNOCHeader, //Input parameter of type Record
    NODNOC@1500002 : Code[10] NODNOC //Input parameter of type Code
);

Parameters

NODNOCLines
Reference parameter of type Record
NODNOCHeader
Input parameter of type Record
NODNOC
Input parameter of type Code

Remarks

The relevant search keywords are: Create, NODNOC, Lines.

For a clarification about how this function works, refer to the code listed below.

      NODNOCLines.INIT;
      NODNOCLines.VALIDATE(Type,NODNOCHeader.Type);
      NODNOCLines.VALIDATE("No.",NODNOCHeader."No.");
      NODNOCLines.VALIDATE("NOD/NOC",NODNOC);
      NODNOCLines.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 144020 to show one way of using this function.

      LibraryERM.CreateNODNOCHeader(NODNOCHeader,Type,No);
      NODNOCHeader.VALIDATE("Assesse Code",AssesseeCode);
      NODNOCHeader.MODIFY(TRUE);
      LibraryERM.CreateNODNOCLines(NODNOCLines,NODNOCHeader,CodeContractor);
      IF CodeOthers <> '' THEN
        LibraryERM.CreateNODNOCLines(NODNOCLines,NODNOCHeader,CodeOthers);
      UpdateNODNOCLines(NODNOCLines,NODNOCHeader.Type::Vendor);
Member of Lib.Library - ERM


CreateNoSeriesCode@18 Method

The procedure CreateNoSeriesCode is available in codeunit 131300.

Syntax

CreateNoSeriesCode@18(
      //param element not supplied
);

Return Value

Code[10]

Remarks

The relevant search keywords are: Create, No, Series, Code.

For a clarification about how this function works, refer to the code listed below.

      // Create Number Series and Number Series Line and return the No. Series Code.
      LibraryUtility.CreateNoSeries(NoSeries,TRUE,TRUE,FALSE);
      LibraryUtility.CreateNoSeriesLine(NoSeriesLine,NoSeries.Code,'','');
      EXIT(NoSeries.Code);

Example

The below example is extracted from the test automation codeunit 134710 to show one way of using this function.

      LibraryERM.CreateGenJournalBatch(GenJournalBatch,JournalTemplateName);
      GenJournalBatch."No. Series" := LibraryERM.CreateNoSeriesCode;
      GenJournalBatch.MODIFY;
      EXIT(GenJournalBatch.Name);
Member of Lib.Library - ERM


CreatePaymentMethod@127 Method

The procedure CreatePaymentMethod is available in codeunit 131300.

Syntax

CreatePaymentMethod@127(
    VAR PaymentMethod@1000 : Record 289 PaymentMethod //Reference parameter of type Record
);

Parameters

PaymentMethod
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Payment, Method.

For a clarification about how this function works, refer to the code listed below.

      PaymentMethod.INIT;
      PaymentMethod.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(PaymentMethod.FIELDNO(Code),DATABASE::"Payment Method"),1,
          LibraryUtility.GetFieldLength(DATABASE::"Payment Method",PaymentMethod.FIELDNO(Code))));
      PaymentMethod.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134012 to show one way of using this function.

      ReminderTerms.FINDFIRST;
      LibrarySales.CreateCustomer(Customer);
      LibraryERM.CreatePaymentMethod(PaymentMethod);
      LibraryERM.CreateCountryRegion(CountryRegion);
      Customer.VALIDATE("Payment Method Code",PaymentMethod.Code);
      Customer.VALIDATE("Reminder Terms Code",ReminderTerms.Code);
      Customer.VALIDATE("Country/Region Code",CountryRegion.Code);
      Customer.MODIFY(TRUE);
      EXIT(Customer."No.");
Member of Lib.Library - ERM


CreatePaymentTerms@41 Method

The procedure CreatePaymentTerms is available in codeunit 131300.

Syntax

CreatePaymentTerms@41(
    VAR PaymentTerms@1000 : Record 3 PaymentTerms //Reference parameter of type Record
);

Parameters

PaymentTerms
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Payment, Terms.

For a clarification about how this function works, refer to the code listed below.

      PaymentTerms.INIT;
      PaymentTerms.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(PaymentTerms.FIELDNO(Code),DATABASE::"Payment Terms"),
          1,
          LibraryUtility.GetFieldLength(DATABASE::"Payment Terms",PaymentTerms.FIELDNO(Code))));
      PaymentTerms.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134006 to show one way of using this function.

      LibraryERM.CreatePaymentTerms(PaymentTerms);
      PaymentTerms.VALIDATE("Discount %",LibraryRandom.RandDec(5,2));
      PaymentTerms.MODIFY(TRUE);
      EXIT(PaymentTerms.Code);
Member of Lib.Library - ERM


CreatePaymentTermsDiscount@1043 Method

The procedure CreatePaymentTermsDiscount is available in codeunit 131300.

Syntax

CreatePaymentTermsDiscount@1043(
    VAR PaymentTerms@1001 : Record 3 PaymentTerms, //Reference parameter of type Record
    CalcPmtDiscOnCrMemos@1002 : Boolean CalcPmtDiscOnCrMemos //Input parameter of type Boolean
);

Parameters

PaymentTerms
Reference parameter of type Record
CalcPmtDiscOnCrMemos
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, Payment, Terms, Discount.

For a clarification about how this function works, refer to the code listed below.

      CreatePaymentTerms(PaymentTerms);
      PaymentTerms.VALIDATE("Calc. Pmt. Disc. on Cr. Memos",CalcPmtDiscOnCrMemos);
      EVALUATE(PaymentTerms."Due Date Calculation",'<' + FORMAT(LibraryRandom.RandInt(5)) + 'M>');
      EVALUATE(PaymentTerms."Discount Date Calculation",'<' + FORMAT(LibraryRandom.RandInt(10)) + 'D>');
      PaymentTerms.VALIDATE("Due Date Calculation",PaymentTerms."Due Date Calculation");
      PaymentTerms.VALIDATE("Discount Date Calculation",PaymentTerms."Discount Date Calculation");
      PaymentTerms.VALIDATE("Discount %",LibraryRandom.RandInt(10));
      PaymentTerms.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134006 to show one way of using this function.

      // Take Random Values for Payment Terms.
      LibraryERM.CreatePaymentTermsDiscount(PaymentTerms,TRUE);
      EXIT(PaymentTerms.Code);
Member of Lib.Library - ERM


CreatePostCode@186 Method

The procedure CreatePostCode is available in codeunit 131300.

Syntax

CreatePostCode@186(
    VAR PostCode@1000 : Record 225 PostCode //Reference parameter of type Record
);

Parameters

PostCode
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Post, Code.

For a clarification about how this function works, refer to the code listed below.

      PostCode.INIT;
      PostCode.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(PostCode.FIELDNO(Code),DATABASE::"Post Code"),
          1,
          LibraryUtility.GetFieldLength(DATABASE::"Post Code",PostCode.FIELDNO(Code))));
      PostCode.VALIDATE(
        City,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(PostCode.FIELDNO(City),DATABASE::"Post Code"),
          1,
          LibraryUtility.GetFieldLength(DATABASE::"Post Code",PostCode.FIELDNO(City))));
      CountryRegion.NEXT(LibraryRandom.RandInt(CountryRegion.COUNT));
      PostCode.VALIDATE("Country/Region Code",CountryRegion.Code);
      PostCode.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134088 to show one way of using this function.

      LibraryERM.CreatePostCode(PostCode);
      LibraryERM.CreateCountryRegion(CountryRegion);
      LibraryPurchase.CreateVendor(Vendor);
      Vendor.VALIDATE("Country/Region Code",CountryRegion.Code);
      Vendor.VALIDATE("Post Code",PostCode.Code);
      Vendor.VALIDATE(County,LibraryUtility.GenerateGUID);
      Vendor.MODIFY(TRUE);
Member of Lib.Library - ERM


CreatePrepaymentVATSetup@190 Method

The procedure CreatePrepaymentVATSetup is available in codeunit 131300.

Syntax

CreatePrepaymentVATSetup@190(
    VAR LineGLAccount@1009 : Record 15 LineGLAccount, //Reference parameter of type Record
    VAR PrepmtGLAccount@1005 : Record 15 PrepmtGLAccount, //Reference parameter of type Record
    GenPostingType@1006 : Option GenPostingType, //Input parameter of type Option
    VATCalcType@1001 : Option VATCalcType, //Input parameter of type Option
    PrepmtVATCalcType@1002 : Option PrepmtVATCalcType //Input parameter of type Option
);

Parameters

LineGLAccount
Reference parameter of type Record
PrepmtGLAccount
Reference parameter of type Record
GenPostingType
Input parameter of type Option
VATCalcType
Input parameter of type Option
PrepmtVATCalcType
Input parameter of type Option

Remarks

The relevant search keywords are: Create, Prepayment, VAT, Setup.

For a clarification about how this function works, refer to the code listed below.

      PassedGLAccount := LineGLAccount;
      CreatePrepaymentGenPostingSetup(GenPostingSetup,PrepmtGLAccount,GenPostingType,PassedGLAccount);
      SetPostingGroupsOnPrepmtGLAccount(PrepmtGLAccount,GenPostingSetup,GenPostingType,PrepmtVATCalcType,PassedGLAccount);

      CreateGLAccount(LineGLAccount);
      IF (PrepmtVATCalcType = VATCalcType) AND (VATCalcType <> VATCalcType::"Full VAT") THEN
        SetPostingGroupsOnPrepmtGLAccount(LineGLAccount,GenPostingSetup,GenPostingType,VATCalcType,PrepmtGLAccount)
      ELSE BEGIN
        PassedGLAccount."Gen. Bus. Posting Group" := PrepmtGLAccount."Gen. Bus. Posting Group";
        PassedGLAccount."VAT Bus. Posting Group" := PrepmtGLAccount."VAT Bus. Posting Group";
        SetPostingGroupsOnPrepmtGLAccount(LineGLAccount,GenPostingSetup,GenPostingType,VATCalcType,PassedGLAccount);
      END;

Example

The below example is extracted from the test automation codeunit 134100 to show one way of using this function.

      // [FEATURE] [Sales] [VAT]
      // [SCENARIO 128406] Changed VAT Prod Posting Group on Sales Line.

      // 1. Setup: Create a Sales Order, create an Item, create a Customer with new posting setup, change the Prepayement Percent in Sales
      // Line, change the VAT Prod. Posting Group in Sales Line.
      Initialize;
      LibrarySales.CreatePrepaymentVATSetup(LineGLAccount,VATCalculationType::"Normal VAT");
      CreateSalesDocumentPrepayment(
        SalesHeader,SalesLine,CreateCustomerWithVAT(LineGLAccount."VAT Bus. Posting Group"),
        CreateItemVATProdPostingGroup(LineGLAccount."VAT Prod. Posting Group"));
      UpdateGeneralPostingSetupInGL(SalesLine);
      FindSalesLine(SalesLine,SalesHeader);
      PrepaymentPercentInSalesLine(SalesLine,LibraryRandom.RandDec(99,5));
      NewVATProdPostingGr := LibraryERM.CreateRelatedVATPostingSetup(LineGLAccount);
      SalesLine.VALIDATE("VAT Prod. Posting Group",NewVATProdPostingGr);
      SalesLine.MODIFY(TRUE);

      // 2. Exercise: Post the Prepayment Invoice and post the Sales Order as Ship and Invoice.
      LibrarySales.PostSalesPrepaymentInvoice(SalesHeader);
      InvoiceNo := LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      // 3. Verify: Verify GL Account.
      VerifyGLAccountForVAT(SalesLine);
      VerifyGLAccountForNewVAT(SalesLine,InvoiceNo);
Member of Lib.Library - ERM


CreateRandomExchangeRate@25 Method

The procedure CreateRandomExchangeRate is available in codeunit 131300.

Syntax

CreateRandomExchangeRate@25(
    CurrencyCode@1001 : Code[10] CurrencyCode //Input parameter of type Code
);

Parameters

CurrencyCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Random, Exchange, Rate.

For a clarification about how this function works, refer to the code listed below.

      CurrencyExchangeRate.INIT;
      CurrencyExchangeRate.VALIDATE("Currency Code",CurrencyCode);
      CurrencyExchangeRate.VALIDATE("Starting Date",FindEarliestDateForExhRate);
      CurrencyExchangeRate.INSERT(TRUE);

      // Using RANDOM Exchange Rate Amount and Adjustment Exchange Rate, between 100 and 400 (Standard Value).
      CurrencyExchangeRate.VALIDATE("Exchange Rate Amount",100 * LibraryRandom.RandInt(4));
      CurrencyExchangeRate.VALIDATE("Adjustment Exch. Rate Amount",CurrencyExchangeRate."Exchange Rate Amount");

      // Relational Exch. Rate Amount and Relational Adjmt Exch Rate Amt always greater than Exchange Rate Amount.
      CurrencyExchangeRate.VALIDATE("Relational Exch. Rate Amount",2 * CurrencyExchangeRate."Exchange Rate Amount");
      CurrencyExchangeRate.VALIDATE("Relational Adjmt Exch Rate Amt",CurrencyExchangeRate."Relational Exch. Rate Amount");
      CurrencyExchangeRate.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134000 to show one way of using this function.

      LibraryERM.CreateCurrency(Currency);
      LibraryERM.SetCurrencyGainLossAccounts(Currency);
      Currency.VALIDATE("Residual Gains Account",Currency."Realized Gains Acc.");
      Currency.VALIDATE("Residual Losses Account",Currency."Realized Losses Acc.");
      Currency.VALIDATE("Appln. Rounding Precision",ApplnRoundingPrecision);
      Currency.MODIFY(TRUE);

      LibraryERM.CreateRandomExchangeRate(Currency.Code);
      EXIT(Currency.Code);
Member of Lib.Library - ERM


CreateRandomVATIdentifierAndGetCode@133 Method

The procedure CreateRandomVATIdentifierAndGetCode is available in codeunit 131300.

Syntax

CreateRandomVATIdentifierAndGetCode@133(
      //param element not supplied
);

Return Value

Text

Remarks

The relevant search keywords are: Create, Random, VAT, Identifier, Get, Code.

For a clarification about how this function works, refer to the code listed below.

      EXIT(LibraryUtility.GenerateRandomCode(VATPostingSetup.FIELDNO("VAT Identifier"),DATABASE::"VAT Posting Setup"));

Example

There are no examples available.
Member of Lib.Library - ERM


CreateReasonCode@85 Method

The procedure CreateReasonCode is available in codeunit 131300.

Syntax

CreateReasonCode@85(
    VAR ReasonCode@1000 : Record 231 ReasonCode //Reference parameter of type Record
);

Parameters

ReasonCode
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Reason, Code.

For a clarification about how this function works, refer to the code listed below.

      ReasonCode.INIT;
      ReasonCode.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(ReasonCode.FIELDNO(Code),DATABASE::"Reason Code"),
          1,LibraryUtility.GetFieldLength(DATABASE::"Reason Code",ReasonCode.FIELDNO(Code))));
      ReasonCode.VALIDATE(Description,ReasonCode.Code);  // Validating Description as Code because value is not important.
      ReasonCode.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134819 to show one way of using this function.

      // Unit test - Table 1101 Cost Journal Line - Verify that in case of an empty Reason Code, this property will be set to Journal Batch's Reason Code value
      LibraryCostAccounting.CreateCostTypeNoGLRange(CostType);
      LibraryCostAccounting.CreateCostTypeNoGLRange(BalCostType);
      LibraryCostAccounting.CreateCostJournalTemplate(CostJournalTemplate);
      LibraryCostAccounting.CreateCostJournalBatch(CostJournalBatch,CostJournalTemplate.Name);
      LibraryERM.CreateReasonCode(ReasonCode);
      CostJournalBatch.VALIDATE("Reason Code",ReasonCode.Code);
      CostJournalBatch.MODIFY(TRUE);

      LibraryCostAccounting.CreateCostJournalLineBasic(
        CostJournalLine,CostJournalTemplate.Name,CostJournalBatch.Name,WORKDATE,CostType."No.",BalCostType."No.");

      CostJournalLine.TESTFIELD("Reason Code",CostJournalBatch."Reason Code");

      CostJournalTemplate.DELETE(TRUE)
Member of Lib.Library - ERM


CreateRecurringBatchName@61 Method

The procedure CreateRecurringBatchName is available in codeunit 131300.

Syntax

CreateRecurringBatchName@61(
    VAR GenJournalBatch@1000 : Record 232 GenJournalBatch, //Reference parameter of type Record
    JournalTemplateName@1002 : Code[10] JournalTemplateName //Input parameter of type Code
);

Parameters

GenJournalBatch
Reference parameter of type Record
JournalTemplateName
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Recurring, Batch, Name.

For a clarification about how this function works, refer to the code listed below.

      // Create New General Journal Batch with a random Name of String length less than 10.
      GenJournalTemplate.GET(JournalTemplateName);
      GenJournalBatch.INIT;
      GenJournalBatch.VALIDATE("Journal Template Name",GenJournalTemplate.Name);
      GenJournalBatch.VALIDATE(
        Name,
        COPYSTR(LibraryUtility.GenerateRandomCode(GenJournalBatch.FIELDNO(Name),DATABASE::"Gen. Journal Batch"),
          1,LibraryUtility.GetFieldLength(DATABASE::"Gen. Journal Batch",GenJournalBatch.FIELDNO(Name))));
      GenJournalBatch.INSERT(TRUE);
      GenJournalBatch.VALIDATE("Posting No. Series",GenJournalTemplate."Posting No. Series");
      GenJournalBatch.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134077 to show one way of using this function.

      // Verify Currency Factor and Amount(LCY) on Recurring General Journal.

      // Setup: Find Recurring Template,Create a Recurring Batch and create a Payment in Recurring General Journal taking Random value for Amount.
      Initialize;
      LibraryERM.FindRecurringTemplateName(GenJournalTemplate);
      LibraryERM.CreateRecurringBatchName(GenJournalBatch,GenJournalTemplate.Name);
      LibraryERM.CreateGeneralJnlLine(
        GenJournalLine,GenJournalTemplate.Name,GenJournalBatch.Name,GenJournalLine."Document Type"::Payment,
        GenJournalLine."Account Type"::Customer,CreateCustomer(CreateCurrency),LibraryRandom.RandDec(100,2));

      // Exercise: Calculate the Currency Factor for validation.
      CurrencyExchangeRate.GET(GenJournalLine."Currency Code",LibraryERM.FindEarliestDateForExhRate);
      CurrencyFactor := CurrencyExchangeRate."Exchange Rate Amount" / CurrencyExchangeRate."Relational Exch. Rate Amount";

      // Verify: Validate 'Currency factor' and 'Amount(LCY)' on Recurring General Journal.
      VerifyCurrencyFactorAmountLCY(GenJournalLine,CurrencyFactor);
Member of Lib.Library - ERM


CreateRecurringTemplateName@60 Method

The procedure CreateRecurringTemplateName is available in codeunit 131300.

Syntax

CreateRecurringTemplateName@60(
    VAR GenJournalTemplate@1000 : Record 80 GenJournalTemplate //Reference parameter of type Record
);

Parameters

GenJournalTemplate
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Recurring, Template, Name.

For a clarification about how this function works, refer to the code listed below.

      GenJournalTemplate.INIT;
      GenJournalTemplate.VALIDATE(
        Name,
        COPYSTR(LibraryUtility.GenerateRandomCode(GenJournalTemplate.FIELDNO(Name),DATABASE::"Gen. Journal Template"),
          1,LibraryUtility.GetFieldLength(DATABASE::"Gen. Journal Template",GenJournalTemplate.FIELDNO(Name))));
      GenJournalTemplate.INSERT(TRUE);
      GenJournalTemplate.VALIDATE("Posting No. Series",LibraryUtility.GetGlobalNoSeriesCode);
      GenJournalTemplate.VALIDATE(Recurring,TRUE);
      GenJournalTemplate.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134227 to show one way of using this function.

      // [FEATURE] [UT]
      // [SCENARIO 381263] IsReccuring function returns TRUE when Reccuring = TRUE in template of general journal line
      LibraryERM.CreateRecurringTemplateName(GenJournalTemplate);
      GenJournalLine.INIT;
      GenJournalLine."Journal Template Name" := GenJournalTemplate.Name;
      Assert.IsTrue(GenJournalLine.IsRecurring,'');
Member of Lib.Library - ERM


CreateRelatedVATPostingSetup@189 Method

The procedure CreateRelatedVATPostingSetup is available in codeunit 131300.

Syntax

CreateRelatedVATPostingSetup@189(
    GLAccount@1000 : Record 15 GLAccount //Input parameter of type Record
);

Parameters

GLAccount
Input parameter of type Record

Return Value

Code[10]

Remarks

The relevant search keywords are: Create, Related, VAT, Posting, Setup.

For a clarification about how this function works, refer to the code listed below.

      VATPostingSetup.GET(GLAccount."VAT Bus. Posting Group",GLAccount."VAT Prod. Posting Group");
      CreateVATProductPostingGroup(VATProductPostingGroup);
      VATPostingSetup."VAT Prod. Posting Group" := VATProductPostingGroup.Code;
      VATPostingSetup."Sales VAT Account" := CreateGLAccountNo;
      VATPostingSetup."Purchase VAT Account" := CreateGLAccountNo;
      VATPostingSetup.INSERT;
      EXIT(VATPostingSetup."VAT Prod. Posting Group");

Example

The below example is extracted from the test automation codeunit 134100 to show one way of using this function.

      // [FEATURE] [Sales] [VAT]
      // [SCENARIO 128406] Changed VAT Prod Posting Group on Sales Line.

      // 1. Setup: Create a Sales Order, create an Item, create a Customer with new posting setup, change the Prepayement Percent in Sales
      // Line, change the VAT Prod. Posting Group in Sales Line.
      Initialize;
      LibrarySales.CreatePrepaymentVATSetup(LineGLAccount,VATCalculationType::"Normal VAT");
      CreateSalesDocumentPrepayment(
        SalesHeader,SalesLine,CreateCustomerWithVAT(LineGLAccount."VAT Bus. Posting Group"),
        CreateItemVATProdPostingGroup(LineGLAccount."VAT Prod. Posting Group"));
      UpdateGeneralPostingSetupInGL(SalesLine);
      FindSalesLine(SalesLine,SalesHeader);
      PrepaymentPercentInSalesLine(SalesLine,LibraryRandom.RandDec(99,5));
      NewVATProdPostingGr := LibraryERM.CreateRelatedVATPostingSetup(LineGLAccount);
      SalesLine.VALIDATE("VAT Prod. Posting Group",NewVATProdPostingGr);
      SalesLine.MODIFY(TRUE);

      // 2. Exercise: Post the Prepayment Invoice and post the Sales Order as Ship and Invoice.
      LibrarySales.PostSalesPrepaymentInvoice(SalesHeader);
      InvoiceNo := LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      // 3. Verify: Verify GL Account.
      VerifyGLAccountForVAT(SalesLine);
      VerifyGLAccountForNewVAT(SalesLine,InvoiceNo);
Member of Lib.Library - ERM


CreateReminderHeader@12 Method

The procedure CreateReminderHeader is available in codeunit 131300.

Syntax

CreateReminderHeader@12(
    VAR ReminderHeader@1000 : Record 295 ReminderHeader //Reference parameter of type Record
);

Parameters

ReminderHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Reminder, Header.

For a clarification about how this function works, refer to the code listed below.

      ReminderHeader.INIT;
      ReminderHeader.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134375 to show one way of using this function.

      LibraryERM.CreateReminderHeader(ReminderHeader);
      ReminderHeader.VALIDATE("Customer No.",CustomerNo);
      ReminderHeader.VALIDATE("Document Date",CALCDATE('<3M>',WORKDATE));
      ReminderHeader.MODIFY(TRUE);
Member of Lib.Library - ERM


CreateReminderLevel@10 Method

The procedure CreateReminderLevel is available in codeunit 131300.

Syntax

CreateReminderLevel@10(
    VAR ReminderLevel@1001 : Record 293 ReminderLevel, //Reference parameter of type Record
    ReminderTermsCode@1000 : Code[10] ReminderTermsCode //Input parameter of type Code
);

Parameters

ReminderLevel
Reference parameter of type Record
ReminderTermsCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Reminder, Level.

For a clarification about how this function works, refer to the code listed below.

      ReminderLevel.INIT;
      ReminderLevel.VALIDATE("Reminder Terms Code",ReminderTermsCode);
      ReminderLevel.NewRecord;
      ReminderLevel.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134375 to show one way of using this function.

      // Create Reminder Level with Grace Period of Five Days and a Random Additional Fee between 1 to 5. Upper Boundary 5 is important.
      LibraryERM.CreateReminderLevel(ReminderLevel,ReminderTermsCode);
      EVALUATE(ReminderLevel."Grace Period",'<5D>');
      ReminderLevel.VALIDATE("Additional Fee (LCY)",LibraryRandom.RandInt(5));
      ReminderLevel.MODIFY(TRUE);
Member of Lib.Library - ERM


CreateReminderLine@69 Method

The procedure CreateReminderLine is available in codeunit 131300.

Syntax

CreateReminderLine@69(
    VAR ReminderLine@1002 : Record 296 ReminderLine, //Reference parameter of type Record
    ReminderNo@1000 : Code[20] ReminderNo, //Input parameter of type Code
    Type@1001 : Option Type //Input parameter of type Option
);

Parameters

ReminderLine
Reference parameter of type Record
ReminderNo
Input parameter of type Code
Type
Input parameter of type Option

Remarks

The relevant search keywords are: Create, Reminder, Line.

For a clarification about how this function works, refer to the code listed below.

      ReminderLine.INIT;
      ReminderLine.VALIDATE("Reminder No.",ReminderNo);
      RecRef.GETTABLE(ReminderLine);
      ReminderLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,ReminderLine.FIELDNO("Line No.")));
      ReminderLine.INSERT(TRUE);
      ReminderLine.VALIDATE(Type,Type);
      ReminderLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134700 to show one way of using this function.

      LibrarySales.CreateCustomer(Customer);
      LibraryERM.CreateReminderHeader(ReminderHeader);
      ReminderHeader.VALIDATE("Customer No.",Customer."No.");
      ReminderHeader.MODIFY(TRUE);
      LibraryERM.CreateReminderLine(ReminderLine,ReminderHeader."No.",ReminderLine.Type::"G/L Account");
      Amount := LibraryRandom.RandDecInDecimalRange(1,100,2);
      ReminderLine.VALIDATE("Remaining Amount",Amount);
      ReminderLine.VALIDATE(Amount,Amount);
      ReminderLine.MODIFY(TRUE);
      ReminderHeader.CALCFIELDS("Remaining Amount","Interest Amount");
Member of Lib.Library - ERM


CreateReminderTerms@4 Method

The procedure CreateReminderTerms is available in codeunit 131300.

Syntax

CreateReminderTerms@4(
    VAR ReminderTerms@1000 : Record 292 ReminderTerms //Reference parameter of type Record
);

Parameters

ReminderTerms
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Reminder, Terms.

For a clarification about how this function works, refer to the code listed below.

      ReminderTerms.INIT;
      ReminderTerms.VALIDATE(Code,LibraryUtility.GenerateRandomCode(ReminderTerms.FIELDNO(Code),DATABASE::"Reminder Terms"));
      ReminderTerms.VALIDATE(Description,ReminderTerms.Code);
      ReminderTerms.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134375 to show one way of using this function.

      // Create a new Reminder Term and take Random Minimum Amount Greater than 5.
      LibraryERM.CreateReminderTerms(ReminderTerms);
      ReminderTerms.VALIDATE("Minimum Amount (LCY)",5 * LibraryRandom.RandInt(10));
      ReminderTerms.MODIFY(TRUE);

      // Create Levels for Reminder Term, Creat Random levels greater than 2. Minimum 2 Levels are required.
      FOR Counter := 1 TO 2 * LibraryRandom.RandInt(5) DO
        CreateReminderLevel(ReminderTerms.Code);
      EXIT(ReminderTerms.Code);
Member of Lib.Library - ERM


CreateReminderText@110 Method

The procedure CreateReminderText is available in codeunit 131300.

Syntax

CreateReminderText@110(
    VAR ReminderText@1000 : Record 294 ReminderText, //Reference parameter of type Record
    ReminderTermsCode@1002 : Code[10] ReminderTermsCode, //Input parameter of type Code
    ReminderLevel@1003 : Integer ReminderLevel, //Input parameter of type Integer
    Position@1004 : Option Position, //Input parameter of type Option
    Text@1001 : Text[100] Text //Input parameter of type Text
);

Parameters

ReminderText
Reference parameter of type Record
ReminderTermsCode
Input parameter of type Code
ReminderLevel
Input parameter of type Integer
Position
Input parameter of type Option
Text
Input parameter of type Text

Remarks

The relevant search keywords are: Create, Reminder, Text.

For a clarification about how this function works, refer to the code listed below.

      ReminderText.INIT;
      ReminderText.VALIDATE("Reminder Terms Code",ReminderTermsCode);
      ReminderText.VALIDATE("Reminder Level",ReminderLevel);
      ReminderText.VALIDATE(Position,Position);
      RecRef.GETTABLE(ReminderText);
      ReminderText.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,ReminderText.FIELDNO("Line No.")));
      ReminderText.INSERT(TRUE);
      ReminderText.VALIDATE(Text,Text);
      ReminderText.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134904 to show one way of using this function.

      // Setup: Set the Rounding Precision.
      Initialize;
      LibraryERM.SetInvRoundingPrecisionLCY(LibraryRandom.RandDec(1,2));
      ReminderTermsCode := CreateReminderTerms(ReminderLevel,'');
      LibraryERM.CreateReminderText(ReminderText,ReminderTermsCode,ReminderLevel."No.",
        ReminderText.Position::Ending,'Reminder Text');

      // Setup: Create and Post Sales Invoice.
      CreateAndPostSalesInvoice(SalesHeader,ReminderTermsCode,'');

      // Setup: Re-Set the Rounding Precision.
      LibraryERM.SetInvRoundingPrecisionLCY(LibraryRandom.RandDec(1,1));

      // Exercise: Create and Suggest Reminder Lines.
      ReminderNo :=
        CreateAndSuggestReminder(
          SalesHeader."Sell-to Customer No.",CALCDATE('<1D>',CALCDATE(ReminderLevel."Grace Period",SalesHeader."Due Date")));

      // Verify: Verify Reminder Lines after Suggesting.
      VerifyReminderRoundingLine(ReminderNo);
Member of Lib.Library - ERM


CreateReturnReasonCode@126 Method

The procedure CreateReturnReasonCode is available in codeunit 131300.

Syntax

CreateReturnReasonCode@126(
    VAR ReturnReason@1001 : Record 6635 ReturnReason //Reference parameter of type Record
);

Parameters

ReturnReason
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Return, Reason, Code.

For a clarification about how this function works, refer to the code listed below.

      ReturnReason.INIT;
      ReturnReason.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(ReturnReason.FIELDNO(Code),DATABASE::"Return Reason"),
          1,LibraryUtility.GetFieldLength(DATABASE::"Return Reason",ReturnReason.FIELDNO(Code))));
      ReturnReason.VALIDATE(Description,ReturnReason.Code);  // Validating Description as Code because value is not important.
      ReturnReason.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134383 to show one way of using this function.

      LibraryERM.CreateReturnReasonCode(ReturnReason);
      ReturnReason."Inventory Value Zero" := InventoryValueZero;
      ReturnReason.MODIFY;
      EXIT(ReturnReason.Code);
Member of Lib.Library - ERM


CreateSourceCode@58 Method

The procedure CreateSourceCode is available in codeunit 131300.

Syntax

CreateSourceCode@58(
    VAR SourceCode@1001 : Record 230 SourceCode //Reference parameter of type Record
);

Parameters

SourceCode
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Source, Code.

For a clarification about how this function works, refer to the code listed below.

      SourceCode.INIT;
      SourceCode.VALIDATE(
        Code,
        COPYSTR(LibraryUtility.GenerateRandomCode(SourceCode.FIELDNO(Code),DATABASE::"Source Code"),
          1,LibraryUtility.GetFieldLength(DATABASE::"Source Code",SourceCode.FIELDNO(Code))));
      SourceCode.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134006 to show one way of using this function.

      // Setup: Create Source Code, update Source Code Setup, create and post General Journal Lines.
      LibraryERM.CreateSourceCode(SourceCode);
      CreateAndUpdateSourceCodeSetup(SourceCode.Code);
      CreateAndPostGenJournalLine(GenJournalLine,DocumentType,DocumentType2,1,Amount);
      // Using 1 to create one line for Payment/Refund.

      // Exercise: Apply and Unapply Payment/Refund from Customer Ledger Entry.
      ApplyAndPostCustomerEntry(
        GenJournalLine."Document No.",GenJournalLine."Document No.",-GenJournalLine.Amount,DocumentType,DocumentType2);
      UnapplyCustLedgerEntry(GenJournalLine."Document Type",GenJournalLine."Document No.");

      // Verify: Verify that correct Source Code updated on Detailed Customer Ledger Entry.
      VerifySourceCodeDtldCustLedger(DocumentType,GenJournalLine."Document No.",SourceCode.Code);
Member of Lib.Library - ERM


CreateStandardGeneralJournal@90 Method

The procedure CreateStandardGeneralJournal is available in codeunit 131300.

Syntax

CreateStandardGeneralJournal@90(
    VAR StandardGeneralJournal@1000 : Record 750 StandardGeneralJournal, //Reference parameter of type Record
    JournalTemplateName@1001 : Code[10] JournalTemplateName //Input parameter of type Code
);

Parameters

StandardGeneralJournal
Reference parameter of type Record
JournalTemplateName
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Standard, General, Journal.

For a clarification about how this function works, refer to the code listed below.

      StandardGeneralJournal.INIT;
      StandardGeneralJournal.VALIDATE("Journal Template Name",JournalTemplateName);
      StandardGeneralJournal.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(StandardGeneralJournal.FIELDNO(Code),DATABASE::"Standard General Journal"),
          1,
          LibraryUtility.GetFieldLength(DATABASE::"Standard General Journal",StandardGeneralJournal.FIELDNO(Code))));

      // Validating Code as Description because value is not important.
      StandardGeneralJournal.VALIDATE(Description,StandardGeneralJournal.Code);
      StandardGeneralJournal.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134226 to show one way of using this function.

      // Test error occurs on running Create Customer Journal Lines Report without General Journal Template.

      // 1. Setup: Create General Journal Batch and Find Standard General Journal.
      Initialize;
      CreateGeneralJournalBatch(GenJournalBatch);
      LibraryERM.CreateStandardGeneralJournal(StandardGeneralJournal,GenJournalBatch."Journal Template Name");

      // 2. Exercise: Run Create Customer Journal Lines Report without General Journal Template.
      ASSERTERROR RunCreateCustomerJournalLines(Customer,'',GenJournalBatch.Name,StandardGeneralJournal.Code);

      // 3. Verify: Verify error occurs on running Create Customer Journal Lines Report without General Journal Template.
      Assert.ExpectedError(STRSUBSTNO(GenJournalTemplateError));

      // 4. Tear Down: Delete earlier created General Journal Template.
      DeleteGeneralJournalTemplate(GenJournalBatch."Journal Template Name");
Member of Lib.Library - ERM


CreateStandardItemJournal@93 Method

The procedure CreateStandardItemJournal is available in codeunit 131300.

Syntax

CreateStandardItemJournal@93(
    VAR StandardItemJournal@1000 : Record 752 StandardItemJournal, //Reference parameter of type Record
    JournalTemplateName@1001 : Code[10] JournalTemplateName //Input parameter of type Code
);

Parameters

StandardItemJournal
Reference parameter of type Record
JournalTemplateName
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Standard, Item, Journal.

For a clarification about how this function works, refer to the code listed below.

      StandardItemJournal.INIT;
      StandardItemJournal.VALIDATE("Journal Template Name",JournalTemplateName);
      StandardItemJournal.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(StandardItemJournal.FIELDNO(Code),DATABASE::"Standard Item Journal"),
          1,
          LibraryUtility.GetFieldLength(DATABASE::"Standard Item Journal",StandardItemJournal.FIELDNO(Code))));

      // Validating Code as Description because value is not important.
      StandardItemJournal.VALIDATE(Description,StandardItemJournal.Code);
      StandardItemJournal.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136602 to show one way of using this function.

      // Test batch creation of Journal Lines for Item without filter.

      // 1. Setup: Create Item Journal batch and Standard Item Journal.
      Initialize;
      CreateItemJournalBatch(ItemJournalBatch);
      LibraryERM.CreateStandardItemJournal(StandardItemJournal,ItemJournalBatch."Journal Template Name");

      // 2. Exercise: Run Report Create Item Journal Lines without any filter.
      RunCreateItemJournalLines(
        Item,
        ItemJournalBatch,
        ItemJournalLine."Entry Type"::"Positive Adjmt.",
        WORKDATE,
        StandardItemJournal.Code);

      // 3. Verify: Verify Number of line in Item Journal Line.
      VerifyCountItemJournalLine(ItemJournalBatch,Item.COUNT);
Member of Lib.Library - ERM


CreateState@1500025 Method

The procedure CreateState is available in codeunit 131300.

Syntax

CreateState@1500025(
    VAR State@1500000 : Record 13762 State //Reference parameter of type Record
);

Parameters

State
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, State.

For a clarification about how this function works, refer to the code listed below.

      State.INIT;
      State.VALIDATE(Code,
        COPYSTR(LibraryUtility.GenerateRandomCode(State.FIELDNO(Code),DATABASE::State),
          1,LibraryUtility.GetFieldLength(DATABASE::State,State.FIELDNO(Code))));
      State.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 144014 to show one way of using this function.

      LibraryERM.CreateTaxArea(TaxArea);
      LibraryERM.CreateTaxJurisdiction(TaxJurisdiction);
      LibraryERM.CreateTaxGroup(TaxGroup);
      LibraryWarehouse.CreateLocation(Location);
      LibraryERM.CreateState(State);
      Location.VALIDATE("State Code",State.Code);
      Location.MODIFY;
      LibraryERM.CreateState(State);
      TaxJurisdiction.VALIDATE("State Code",Location."State Code");
      TaxJurisdiction.VALIDATE("Tax Type",TaxJurisdiction."Tax Type"::CST);
      TaxJurisdiction.MODIFY(TRUE);
      ServiceTaxAsExciseHelper.CreateTaxAreaLocations(Location.Code,State.Code,TaxArea.Code,TaxAreaLocationsType::Customer);
      LibraryERM.CreateTaxAreaLine(TaxAreaLine,TaxArea.Code,TaxJurisdiction.Code);
      TaxAreaLine.VALIDATE("Include Tax Base",TRUE);
      TaxAreaLine.MODIFY;
      LibraryERM.CreateTaxDetail(TaxDetail,TaxJurisdiction.Code,TaxGroup.Code,TaxDetail."Tax Type"::"Sales Tax",WORKDATE);
      TaxDetail.VALIDATE("Tax Below Maximum",LibraryRandom.RandDecInRange(10,15,2));
      TaxDetail.MODIFY(TRUE);
Member of Lib.Library - ERM


CreateStructureDetails@1500005 Method

The procedure CreateStructureDetails is available in codeunit 131300.

Syntax

CreateStructureDetails@1500005(
    VAR StructureDetails@1500000 : Record 13793 StructureDetails, //Reference parameter of type Record
    Code@1500001 : Code[10] Code, //Input parameter of type Code
    CalculationOrder@1500002 : Integer CalculationOrder, //Input parameter of type Integer
    Type@1500003 : Option Type, //Input parameter of type Option
    TaxChargeGroup@1500004 : Code[10] TaxChargeGroup, //Input parameter of type Code
    TaxChargeCode@1500005 : Code[10] TaxChargeCode //Input parameter of type Code
);

Parameters

StructureDetails
Reference parameter of type Record
Code
Input parameter of type Code
CalculationOrder
Input parameter of type Integer
Type
Input parameter of type Option
TaxChargeGroup
Input parameter of type Code
TaxChargeCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Structure, Details.

For a clarification about how this function works, refer to the code listed below.

      StructureDetails.INIT;
      StructureDetails.VALIDATE(Code,Code);
      StructureDetails.VALIDATE("Calculation Order",CalculationOrder);
      StructureDetails.VALIDATE(Type,Type);
      StructureDetails.VALIDATE("Tax/Charge Group",TaxChargeGroup);
      StructureDetails.VALIDATE("Tax/Charge Code",TaxChargeCode);
      StructureDetails.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 144001 to show one way of using this function.

      LibraryERM.CreateStructureHeader(StructureHeader);
      WITH StructureDetails DO BEGIN
        LibraryERM.CreateStructureDetails(StructureDetails,StructureHeader.Code,1,Type::Excise,'',''); // Value 1 for Calculation Order Field.
        VALIDATE(CVD,TRUE);
        VALIDATE("CVD Payable to Third Party",TRUE);
        VALIDATE("CVD Third Party Code",ServiceTaxAsExciseHelper.CreateGLAccount);
        VALIDATE("Include Base",TRUE);
        VALIDATE("Include Line Discount",TRUE);
        VALIDATE("Include Invoice Discount",TRUE);
        MODIFY(TRUE);
      END;
Member of Lib.Library - ERM


CreateStructureHeader@1500006 Method

The procedure CreateStructureHeader is available in codeunit 131300.

Syntax

CreateStructureHeader@1500006(
    VAR StructureHeader@1000 : Record 13792 StructureHeader //Reference parameter of type Record
);

Parameters

StructureHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Structure, Header.

For a clarification about how this function works, refer to the code listed below.

      StructureHeader.INIT;
      StructureHeader.VALIDATE(Code,
        COPYSTR(LibraryUtility.GenerateRandomCode(StructureHeader.FIELDNO(Code),DATABASE::"Structure Header"),
          1,LibraryUtility.GetFieldLength(DATABASE::"Structure Header",StructureHeader.FIELDNO(Code))));
      StructureHeader.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 144001 to show one way of using this function.

      LibraryERM.CreateStructureHeader(StructureHeader);
      WITH StructureDetails DO BEGIN
        LibraryERM.CreateStructureDetails(StructureDetails,StructureHeader.Code,1,Type::Excise,'',''); // Value 1 for Calculation Order Field.
        VALIDATE(CVD,TRUE);
        VALIDATE("CVD Payable to Third Party",TRUE);
        VALIDATE("CVD Third Party Code",ServiceTaxAsExciseHelper.CreateGLAccount);
        VALIDATE("Include Base",TRUE);
        VALIDATE("Include Line Discount",TRUE);
        VALIDATE("Include Invoice Discount",TRUE);
        MODIFY(TRUE);
      END;
Member of Lib.Library - ERM


CreateTaxArea@116 Method

The procedure CreateTaxArea is available in codeunit 131300.

Syntax

CreateTaxArea@116(
    VAR TaxArea@1002 : Record 318 TaxArea //Reference parameter of type Record
);

Parameters

TaxArea
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Tax, Area.

For a clarification about how this function works, refer to the code listed below.

      TaxArea.INIT;
      TaxArea.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(TaxArea.FIELDNO(Code),DATABASE::"Tax Area"),
          1,
          LibraryUtility.GetFieldLength(DATABASE::"Tax Area",TaxArea.FIELDNO(Code))));
      TaxArea.VALIDATE(Description,TaxArea.Code);  // Validating Code as Description because value is not important.
      TaxArea.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 144014 to show one way of using this function.

      LibraryERM.CreateTaxArea(TaxArea);
      LibraryERM.CreateTaxJurisdiction(TaxJurisdiction);
      LibraryERM.CreateTaxGroup(TaxGroup);
      LibraryWarehouse.CreateLocation(Location);
      LibraryERM.CreateState(State);
      Location.VALIDATE("State Code",State.Code);
      Location.MODIFY;
      LibraryERM.CreateState(State);
      TaxJurisdiction.VALIDATE("State Code",Location."State Code");
      TaxJurisdiction.VALIDATE("Tax Type",TaxJurisdiction."Tax Type"::CST);
      TaxJurisdiction.MODIFY(TRUE);
      ServiceTaxAsExciseHelper.CreateTaxAreaLocations(Location.Code,State.Code,TaxArea.Code,TaxAreaLocationsType::Customer);
      LibraryERM.CreateTaxAreaLine(TaxAreaLine,TaxArea.Code,TaxJurisdiction.Code);
      TaxAreaLine.VALIDATE("Include Tax Base",TRUE);
      TaxAreaLine.MODIFY;
      LibraryERM.CreateTaxDetail(TaxDetail,TaxJurisdiction.Code,TaxGroup.Code,TaxDetail."Tax Type"::"Sales Tax",WORKDATE);
      TaxDetail.VALIDATE("Tax Below Maximum",LibraryRandom.RandDecInRange(10,15,2));
      TaxDetail.MODIFY(TRUE);
Member of Lib.Library - ERM


CreateTaxAreaAndTaxAreaLine@1500041 Method

The procedure CreateTaxAreaAndTaxAreaLine is available in codeunit 131300.

Syntax

CreateTaxAreaAndTaxAreaLine@1500041(
    VAR TaxArea@1500001 : Record 318 TaxArea, //Reference parameter of type Record
    TaxJurisdiction@1500000 : Code[10] TaxJurisdiction, //Input parameter of type Code
    CalcFormula@1500003 : Text[80] CalcFormula, //Input parameter of type Text
    CalculationOrder@1500004 : Integer CalculationOrder, //Input parameter of type Integer
    InclTaxBase@1500002 : Boolean InclTaxBase //Input parameter of type Boolean
);

Parameters

TaxArea
Reference parameter of type Record
TaxJurisdiction
Input parameter of type Code
CalcFormula
Input parameter of type Text
CalculationOrder
Input parameter of type Integer
InclTaxBase
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, Tax, Area, Tax, Area, Line.

For a clarification about how this function works, refer to the code listed below.

      WITH TaxArea DO BEGIN
        INIT;
        VALIDATE(Code,LibraryUtility.GenerateRandomCode(FIELDNO(Code),DATABASE::"Tax Area"));
        INSERT(TRUE);
      END;
      WITH TaxAreaLine DO BEGIN
        INIT;
        VALIDATE("Tax Area",TaxArea.Code);
        VALIDATE("Tax Jurisdiction Code",TaxJurisdiction);
        VALIDATE("Calculation Order",CalculationOrder);
        VALIDATE(Formula,CalcFormula);
        VALIDATE("Include Tax Base",InclTaxBase);
        INSERT(TRUE);
      END;

Example

There are no examples available.
Member of Lib.Library - ERM


CreateTaxAreaLine@117 Method

The procedure CreateTaxAreaLine is available in codeunit 131300.

Syntax

CreateTaxAreaLine@117(
    VAR TaxAreaLine@1000 : Record 319 TaxAreaLine, //Reference parameter of type Record
    TaxAreaCode@1001 : Code[20] TaxAreaCode, //Input parameter of type Code
    TaxJurisdictionCode@1002 : Code[10] TaxJurisdictionCode //Input parameter of type Code
);

Parameters

TaxAreaLine
Reference parameter of type Record
TaxAreaCode
Input parameter of type Code
TaxJurisdictionCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Tax, Area, Line.

For a clarification about how this function works, refer to the code listed below.

      TaxAreaLine.INIT;
      TaxAreaLine.VALIDATE("Tax Area",TaxAreaCode);
      TaxAreaLine.VALIDATE("Tax Jurisdiction Code",TaxJurisdictionCode);
      TaxAreaLine.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 144014 to show one way of using this function.

      LibraryERM.CreateTaxArea(TaxArea);
      LibraryERM.CreateTaxJurisdiction(TaxJurisdiction);
      LibraryERM.CreateTaxGroup(TaxGroup);
      LibraryWarehouse.CreateLocation(Location);
      LibraryERM.CreateState(State);
      Location.VALIDATE("State Code",State.Code);
      Location.MODIFY;
      LibraryERM.CreateState(State);
      TaxJurisdiction.VALIDATE("State Code",Location."State Code");
      TaxJurisdiction.VALIDATE("Tax Type",TaxJurisdiction."Tax Type"::CST);
      TaxJurisdiction.MODIFY(TRUE);
      ServiceTaxAsExciseHelper.CreateTaxAreaLocations(Location.Code,State.Code,TaxArea.Code,TaxAreaLocationsType::Customer);
      LibraryERM.CreateTaxAreaLine(TaxAreaLine,TaxArea.Code,TaxJurisdiction.Code);
      TaxAreaLine.VALIDATE("Include Tax Base",TRUE);
      TaxAreaLine.MODIFY;
      LibraryERM.CreateTaxDetail(TaxDetail,TaxJurisdiction.Code,TaxGroup.Code,TaxDetail."Tax Type"::"Sales Tax",WORKDATE);
      TaxDetail.VALIDATE("Tax Below Maximum",LibraryRandom.RandDecInRange(10,15,2));
      TaxDetail.MODIFY(TRUE);
Member of Lib.Library - ERM


CreateTaxComponent@1500043 Method

The procedure CreateTaxComponent is available in codeunit 131300.

Syntax

CreateTaxComponent@1500043(
    VAR TaxComponent@1500000 : Record 16479 TaxComponent //Reference parameter of type Record
);

Parameters

TaxComponent
Reference parameter of type Record

Return Value

Code[10]

Remarks

The relevant search keywords are: Create, Tax, Component.

For a clarification about how this function works, refer to the code listed below.

      WITH TaxComponent DO BEGIN
        INIT;
        VALIDATE(Code,LibraryUtility.GenerateRandomCode(FIELDNO(Code),DATABASE::"Tax Component"));
        VALIDATE(Description,LibraryUtility.GenerateRandomText(10));
        INSERT(TRUE);
        EXIT(Code);
      END;

Example

There are no examples available.
Member of Lib.Library - ERM


CreateTaxDetail@115 Method

The procedure CreateTaxDetail is available in codeunit 131300.

Syntax

CreateTaxDetail@115(
    VAR TaxDetail@1002 : Record 322 TaxDetail, //Reference parameter of type Record
    TaxJurisdictionCode@1003 : Code[10] TaxJurisdictionCode, //Input parameter of type Code
    TaxGroupCode@1004 : Code[10] TaxGroupCode, //Input parameter of type Code
    TaxType@1000 : Option TaxType, //Input parameter of type Option
    EffectiveDate@1001 : Date EffectiveDate //Input parameter of type Date
);

Parameters

TaxDetail
Reference parameter of type Record
TaxJurisdictionCode
Input parameter of type Code
TaxGroupCode
Input parameter of type Code
TaxType
Input parameter of type Option
EffectiveDate
Input parameter of type Date

Remarks

The relevant search keywords are: Create, Tax, Detail.

For a clarification about how this function works, refer to the code listed below.

      TaxDetail.INIT;
      TaxDetail.VALIDATE("Tax Jurisdiction Code",TaxJurisdictionCode);
      TaxDetail.VALIDATE("Tax Group Code",TaxGroupCode);
      TaxDetail.VALIDATE("Tax Type",TaxType);
      TaxDetail.VALIDATE("Effective Date",EffectiveDate);
      TaxDetail.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134388 to show one way of using this function.

      LibraryERM.CreateTaxGroup(TaxGroup);
      LibraryERM.CreateTaxDetail(TaxDetail,CreateSalesTaxJurisdiction,TaxGroup.Code,TaxDetail."Tax Type"::"Sales Tax",WORKDATE);
Member of Lib.Library - ERM


CreateTaxDetails@1500038 Method

The procedure CreateTaxDetails is available in codeunit 131300.

Syntax

CreateTaxDetails@1500038(
    VAR TaxGroup@1500003 : Record 321 TaxGroup, //Reference parameter of type Record
    TaxJurisdiction@1500000 : Code[10] TaxJurisdiction, //Input parameter of type Code
    CapitalGoods@1500001 : Boolean CapitalGoods, //Input parameter of type Boolean
    CreditableGoods@1500002 : Boolean CreditableGoods //Input parameter of type Boolean
);

Parameters

TaxGroup
Reference parameter of type Record
TaxJurisdiction
Input parameter of type Code
CapitalGoods
Input parameter of type Boolean
CreditableGoods
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, Tax, Details.

For a clarification about how this function works, refer to the code listed below.

      CreateTaxGroup(TaxGroup);
      WITH DummyTaxDetail DO BEGIN
        VALIDATE("Tax Jurisdiction Code",TaxJurisdiction);
        VALIDATE("Tax Group Code",TaxGroup.Code);
        VALIDATE("Tax Below Maximum",LibraryRandom.RandDec(10,2));
        VALIDATE("Capital Goods",CapitalGoods);
        VALIDATE("Creditable Goods",CreditableGoods);
        INSERT(TRUE);
      END;

Example

There are no examples available.
Member of Lib.Library - ERM


CreateTaxGroup@112 Method

The procedure CreateTaxGroup is available in codeunit 131300.

Syntax

CreateTaxGroup@112(
    VAR TaxGroup@1000 : Record 321 TaxGroup //Reference parameter of type Record
);

Parameters

TaxGroup
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Tax, Group.

For a clarification about how this function works, refer to the code listed below.

      TaxGroup.INIT;
      TaxGroup.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(TaxGroup.FIELDNO(Code),DATABASE::"Tax Group"),
          1,
          LibraryUtility.GetFieldLength(DATABASE::"Tax Group",TaxGroup.FIELDNO(Code))));
      TaxGroup.VALIDATE(Description,TaxGroup.Code);  // Validating Code as Description because value is not important.
      TaxGroup.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134388 to show one way of using this function.

      // Test creation of Sales Tax Group.

      // Setup.
      Initialize;

      // Exercise.
      LibraryERM.CreateTaxGroup(TaxGroup);

      // Verify: Verify created Tax Group exists.
      TaxGroup.GET(TaxGroup.Code);
Member of Lib.Library - ERM


CreateTaxJurisdiction@114 Method

The procedure CreateTaxJurisdiction is available in codeunit 131300.

Syntax

CreateTaxJurisdiction@114(
    VAR TaxJurisdiction@1000 : Record 320 TaxJurisdiction //Reference parameter of type Record
);

Parameters

TaxJurisdiction
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Tax, Jurisdiction.

For a clarification about how this function works, refer to the code listed below.

      TaxJurisdiction.INIT;
      TaxJurisdiction.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(TaxJurisdiction.FIELDNO(Code),DATABASE::"Tax Jurisdiction"),
          1,
          LibraryUtility.GetFieldLength(DATABASE::"Tax Jurisdiction",TaxJurisdiction.FIELDNO(Code))));
      TaxJurisdiction.VALIDATE(Description,TaxJurisdiction.Code);  // Validating Code as Description because value is not important.
      TaxJurisdiction.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134388 to show one way of using this function.

      LibraryERM.CreateTaxJurisdiction(TaxJurisdiction);
      LibraryERM.CreateGLAccount(GLAccount);
      TaxJurisdiction.VALIDATE("Tax Account (Sales)",GLAccount."No.");
      TaxJurisdiction.VALIDATE("Tax Account (Purchases)",GLAccount."No.");
      TaxJurisdiction.VALIDATE("Reverse Charge (Purchases)",GLAccount."No.");
      TaxJurisdiction.VALIDATE("Report-to Jurisdiction",TaxJurisdiction.Code);
      TaxJurisdiction.VALIDATE("Calculate Tax on Tax",TRUE);
      TaxJurisdiction.MODIFY(TRUE);
      EXIT(TaxJurisdiction.Code);
Member of Lib.Library - ERM


CreateTDSNatureDeduction@1500008 Method

The procedure CreateTDSNatureDeduction is available in codeunit 131300.

Syntax

CreateTDSNatureDeduction@1500008(
    VAR TDSNatureDeduction@1500000 : Record 13726 TDSNatureDeduction //Reference parameter of type Record
);

Parameters

TDSNatureDeduction
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, TDS, Nature, Deduction.

For a clarification about how this function works, refer to the code listed below.

      TDSNatureDeduction.INIT;
      TDSNatureDeduction.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(TDSNatureDeduction.FIELDNO(Code),DATABASE::"TDS Nature of Deduction"),
          1,
          LibraryUtility.GetFieldLength(DATABASE::"TDS Nature of Deduction",TDSNatureDeduction.FIELDNO(Code))));
      TDSNatureDeduction.VALIDATE(Description,TDSNatureDeduction.Code); // Validating Code as Description because value is not important.
      TDSNatureDeduction.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 144020 to show one way of using this function.

      LibraryERM.CreateTDSNatureDeduction(TDSNatureDeduction);
      TDSNatureDeduction.VALIDATE("TDS Group",TDSGroup);
      TDSNatureDeduction.MODIFY(TRUE);
      CreateTDSSetUp(TDSSetup,TDSNatureDeduction.Code,AssesseeCode);
Member of Lib.Library - ERM


CreateTDSSetup@1500010 Method

The procedure CreateTDSSetup is available in codeunit 131300.

Syntax

CreateTDSSetup@1500010(
    VAR TDSSetup@1500000 : Record 13728 TDSSetup, //Reference parameter of type Record
    TDSNatureDeduction@1500001 : Code[10] TDSNatureDeduction, //Input parameter of type Code
    AssesseeCode@1500002 : Code[10] AssesseeCode, //Input parameter of type Code
    EffectiveDate@1500003 : Date EffectiveDate, //Input parameter of type Date
    ConcessionalCode@1500004 : Code[10] ConcessionalCode //Input parameter of type Code
);

Parameters

TDSSetup
Reference parameter of type Record
TDSNatureDeduction
Input parameter of type Code
AssesseeCode
Input parameter of type Code
EffectiveDate
Input parameter of type Date
ConcessionalCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, TDS, Setup.

For a clarification about how this function works, refer to the code listed below.

      TDSSetup.INIT;
      TDSSetup.VALIDATE("TDS Nature of Deduction",TDSNatureDeduction);
      TDSSetup.VALIDATE("Assessee Code",AssesseeCode);
      TDSSetup.VALIDATE("Effective Date",EffectiveDate);
      TDSSetup.VALIDATE("Concessional Code",ConcessionalCode);
      TDSSetup.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 144020 to show one way of using this function.

      LibraryERM.CreateTDSNatureDeduction(TDSNatureDeduction);
      TDSNatureDeduction.VALIDATE("TDS Group",TDSGroup);
      TDSNatureDeduction.MODIFY(TRUE);
      IF TDSNatureDeduction."TDS Group" = TDSNatureDeduction."TDS Group"::"Payable to Non Residents" THEN BEGIN
        LibraryTDS.CreateTDSSetup(TDSSetup,TDSNatureDeduction.Code,AssesseeCode,TODAY,'','',0,CountryCode);
        TDSSetup.VALIDATE("TDS %",LibraryRandom.RandInt(5));
        TDSSetup.VALIDATE("Non PAN TDS %",LibraryRandom.RandInt(5));
        TDSSetup.VALIDATE("Surcharge %",LibraryRandom.RandInt(5));
        TDSSetup.VALIDATE("eCESS %",LibraryRandom.RandInt(5));
        TDSSetup.MODIFY(TRUE);
      END;
Member of Lib.Library - ERM


CreateTerritory@209 Method

The procedure CreateTerritory is available in codeunit 131300.

Syntax

CreateTerritory@209(
    VAR Territory@1000 : Record 286 Territory //Reference parameter of type Record
);

Parameters

Territory
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Territory.

For a clarification about how this function works, refer to the code listed below.

      Territory.INIT;
      Territory.VALIDATE(
        Code,
        COPYSTR(LibraryUtility.GenerateRandomCode(Territory.FIELDNO(Code),DATABASE::Territory),
          1,LibraryUtility.GetFieldLength(DATABASE::Territory,Territory.FIELDNO(Code))));
      Territory.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136201 to show one way of using this function.

      LibraryMarketing.CreateContact(Contact);
      LibraryERM.CreateCountryRegion(CountryRegion);
      Contact.VALIDATE("Country/Region Code",CountryRegion.Code);
      LibraryERM.CreateCurrency(Currency);
      Contact.VALIDATE("Currency Code",Currency.Code);
      LibraryERM.CreateTerritory(Territory);
      Contact.VALIDATE("Territory Code",Territory.Code);
      Contact.MODIFY(TRUE);
Member of Lib.Library - ERM


CreateTINNo@1500026 Method

The procedure CreateTINNo is available in codeunit 131300.

Syntax

CreateTINNo@1500026(
    VAR TINNos@1500000 : Record 13701 TINNos //Reference parameter of type Record
);

Parameters

TINNos
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, TIN, No.

For a clarification about how this function works, refer to the code listed below.

      TINNos.INIT;
      TINNos.VALIDATE(Code,
        COPYSTR(LibraryUtility.GenerateRandomCode(TINNos.FIELDNO(Code),DATABASE::"T.I.N. Nos.") + LibraryUtility.GenerateRandomCode(TINNos.FIELDNO(Code),DATABASE::"T.I.N. Nos."),1,
          LibraryUtility.GetFieldLength(DATABASE::"T.I.N. Nos.",TINNos.FIELDNO(Code))));
      TINNos.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 144063 to show one way of using this function.

      StructureHeader.INIT;
      StructureHeader.VALIDATE(Code,LibraryUtility.GenerateRandomCode(StructureHeader.FIELDNO(Code),DATABASE::"Structure Header"));
      StructureHeader.VALIDATE(Description,StructureHeader.Code);
      StructureHeader.INSERT(TRUE);

      StructureLines.INIT;
      StructureLines.VALIDATE(Code,StructureHeader.Code);
      StructureLines.VALIDATE(Type,StructureLines.Type::"Sales Tax");
      StructureLines.VALIDATE("Header/Line",StructureLines."Header/Line"::Line);
      StructureLines.VALIDATE("Include Base",TRUE);
      StructureLines.VALIDATE("Include Line Discount",TRUE);
      StructureLines.VALIDATE("Include Invoice Discount",TRUE);
      StructureLines.INSERT(TRUE);

      LibraryERM.CreateTINNo(TINNos);

      LibraryERM.CreateState(State);
      State.VALIDATE("Tax Account (Sales)",LibraryERM.CreateGLAccountNo);
      State.MODIFY(TRUE);

      Customer.GET(CustomerNo);
      Customer.VALIDATE("State Code",State.Code);
      Customer.MODIFY(TRUE);

      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location);
      Location.VALIDATE("State Code",State.Code);
      Location."T.I.N. No." := TINNos.Code;
      Location.VALIDATE("T.C.A.N. No.",LibraryTCS.CreateTCANNo);
      Location.MODIFY(TRUE);

      LibraryERM.CreateTaxGroup(TaxGroup);

      LibraryERM.CreateTaxJurisdiction(TaxJurisdiction);
      TaxJurisdiction.VALIDATE("Tax Type",TaxJurisdiction."Tax Type"::VAT);
      TaxJurisdiction.VALIDATE("State Code",State.Code);
      TaxJurisdiction.MODIFY(TRUE);

      LibraryERM.CreateTaxArea(TaxArea);
      LibraryERM.CreateTaxAreaLine(TaxAreaLine,TaxArea.Code,TaxJurisdiction.Code);
      TaxAreaLine.VALIDATE("Include Tax Base",TRUE);
      TaxAreaLine.MODIFY(TRUE);

      ServiceTaxAsExciseHelper.CreateTaxAreaLocations(Location.Code,State.Code,TaxArea.Code,TaxAreaLoc.Type::Customer);

      LibraryERM.CreateTaxDetail(TaxDetail,TaxJurisdiction.Code,TaxGroup.Code,TaxDetail."Tax Type"::"Sales Tax",WORKDATE);
      TaxDetail.VALIDATE("Tax Below Maximum",LibraryRandom.RandDec(10,2));
      TaxDetail.VALIDATE("Creditable Goods",TRUE);
      TaxDetail.VALIDATE("Capital Goods",TRUE);
      TaxDetail.MODIFY(TRUE);
Member of Lib.Library - ERM


CreateVATBusinessPostingGroup@109 Method

The procedure CreateVATBusinessPostingGroup is available in codeunit 131300.

Syntax

CreateVATBusinessPostingGroup@109(
    VAR VATBusinessPostingGroup@1000 : Record 323 VATBusinessPostingGroup //Reference parameter of type Record
);

Parameters

VATBusinessPostingGroup
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, VAT, Business, Posting, Group.

For a clarification about how this function works, refer to the code listed below.

      VATBusinessPostingGroup.INIT;
      VATBusinessPostingGroup.VALIDATE(
        Code,
        COPYSTR(LibraryUtility.GenerateRandomCode(VATBusinessPostingGroup.FIELDNO(Code),DATABASE::"VAT Business Posting Group"),
          1,LibraryUtility.GetFieldLength(DATABASE::"VAT Business Posting Group",VATBusinessPostingGroup.FIELDNO(Code))));

      // Validating Code as Name because value is not important.
      VATBusinessPostingGroup.VALIDATE(Description,VATBusinessPostingGroup.Code);
      VATBusinessPostingGroup.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134006 to show one way of using this function.

      LibraryERM.CreateVATBusinessPostingGroup(VATBusinessPostingGroup);
      LibraryERM.CreateVATProductPostingGroup(VATProductPostingGroup);
      LibraryERM.CreateVATPostingSetup(
        VATPostingSetup,VATBusinessPostingGroup.Code,VATProductPostingGroup.Code);
      WITH VATPostingSetup DO BEGIN
        VALIDATE("VAT %",VATPercent);
        VALIDATE("Sales VAT Account",LibraryERM.CreateGLAccountNo);
        VALIDATE("Purchase VAT Account",LibraryERM.CreateGLAccountNo);
        MODIFY(TRUE);
      END;
Member of Lib.Library - ERM


CreateVATBusinessPostingGroups@1500019 Method

The procedure CreateVATBusinessPostingGroups is available in codeunit 131300.

Syntax

CreateVATBusinessPostingGroups@1500019(
    VATBusinessPostingGroups@1000 : Code[10] VATBusinessPostingGroups //Input parameter of type Code
);

Parameters

VATBusinessPostingGroups
Input parameter of type Code

Remarks

The relevant search keywords are: Create, VAT, Business, Posting, Groups.

For a clarification about how this function works, refer to the code listed below.

      VATBusinessPostingGroup.INIT;
      VATBusinessPostingGroup.VALIDATE(Code,VATBusinessPostingGroups);
      // Validating Code as Name because value is not important.
      VATBusinessPostingGroup.VALIDATE(Description,VATBusinessPostingGroup.Code);
      VATBusinessPostingGroup.INSERT(TRUE);

Example

There are no examples available.
Member of Lib.Library - ERM


CreateVATClause@222 Method

The procedure CreateVATClause is available in codeunit 131300.

Syntax

CreateVATClause@222(
    VAR VATClause@1000 : Record 560 VATClause //Reference parameter of type Record
);

Parameters

VATClause
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, VAT, Clause.

For a clarification about how this function works, refer to the code listed below.

      VATClause.INIT;
      VATClause.VALIDATE(Code,
        COPYSTR(LibraryUtility.GenerateRandomCode(VATClause.FIELDNO(Code),DATABASE::"VAT Clause"),
          1,LibraryUtility.GetFieldLength(DATABASE::"VAT Clause",VATClause.FIELDNO(Code))));
      VATClause.VALIDATE(Description,LibraryUtility.GenerateGUID);
      VATClause.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134385 to show one way of using this function.

      LibraryERM.CreateVATClause(VATClause);
      EXIT(VATClause.Code);
Member of Lib.Library - ERM


CreateVATPostingSetup@106 Method

The procedure CreateVATPostingSetup is available in codeunit 131300.

Syntax

CreateVATPostingSetup@106(
    VAR VATPostingSetup@1003 : Record 325 VATPostingSetup, //Reference parameter of type Record
    VATBusPostingGroup@1001 : Code[10] VATBusPostingGroup, //Input parameter of type Code
    VATProdPostingGroup@1002 : Code[10] VATProdPostingGroup //Input parameter of type Code
);

Parameters

VATPostingSetup
Reference parameter of type Record
VATBusPostingGroup
Input parameter of type Code
VATProdPostingGroup
Input parameter of type Code

Remarks

The relevant search keywords are: Create, VAT, Posting, Setup.

For a clarification about how this function works, refer to the code listed below.

      VATPostingSetup.INIT;
      VATPostingSetup.VALIDATE("VAT Bus. Posting Group",VATBusPostingGroup);
      VATPostingSetup.VALIDATE("VAT Prod. Posting Group",VATProdPostingGroup);
      VATPostingSetup.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134006 to show one way of using this function.

      LibraryERM.CreateVATBusinessPostingGroup(VATBusinessPostingGroup);
      LibraryERM.CreateVATProductPostingGroup(VATProductPostingGroup);
      LibraryERM.CreateVATPostingSetup(
        VATPostingSetup,VATBusinessPostingGroup.Code,VATProductPostingGroup.Code);
      WITH VATPostingSetup DO BEGIN
        VALIDATE("VAT %",VATPercent);
        VALIDATE("Sales VAT Account",LibraryERM.CreateGLAccountNo);
        VALIDATE("Purchase VAT Account",LibraryERM.CreateGLAccountNo);
        MODIFY(TRUE);
      END;
Member of Lib.Library - ERM


CreateVATPostingSetups@1500013 Method

The procedure CreateVATPostingSetups is available in codeunit 131300.

Syntax

CreateVATPostingSetups@1500013(
    VATBusPostCode@1500000 : Code[10] VATBusPostCode, //Input parameter of type Code
    VATGenPostCode@1500007 : Code[10] VATGenPostCode //Input parameter of type Code
);

Parameters

VATBusPostCode
Input parameter of type Code
VATGenPostCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, VAT, Posting, Setups.

For a clarification about how this function works, refer to the code listed below.

      SetVATPostingSetup.RESET;
      SetVATPostingSetup.SETCURRENTKEY("VAT Bus. Posting Group","VAT Prod. Posting Group");
      SetVATPostingSetup.SETRANGE("VAT Bus. Posting Group",VATBusPostCode);
      SetVATPostingSetup.SETRANGE("VAT Prod. Posting Group",VATGenPostCode);
      IF NOT SetVATPostingSetup.FINDFIRST THEN BEGIN
        VATPostingSetup.SETFILTER("VAT Prod. Posting Group",'<>%1','');
        // VATPostingSetup.SETFILTER("VAT %",'<>%1',0);
        VATPostingSetup.SETRANGE("VAT Calculation Type",VATPostingSetup."VAT Calculation Type"::"Normal VAT");
        VATPostingSetup.SETFILTER("Sales VAT Account",'<>%1','');
        VATPostingSetup.SETFILTER("Purchase VAT Account",'<>%1','');
        IF VATPostingSetup.FINDFIRST THEN BEGIN
          SetVATPostingSetup := VATPostingSetup;
          SetVATPostingSetup."Unrealized VAT Type" := SetVATPostingSetup."Unrealized VAT Type"::" ";
          SetVATPostingSetup."VAT Bus. Posting Group" := VATBusPostCode;
          SetVATPostingSetup."VAT Prod. Posting Group" := VATGenPostCode;
          SetVATPostingSetup.INSERT(TRUE);
        END;
      END;

Example

The below example is extracted from the test automation codeunit 134404 to show one way of using this function.

      LibrarySales.CreateCustomer(Customer);
      CreateMandate(Customer."No.",SEPADirectDebitMandate);
      CreateStdCustSalesLine(Customer."No.",SEPADirectDebitMandate.ID,StandardCustomerSalesCode);
      LibraryERM.CreateVATPostingSetups(Customer."VAT Bus. Posting Group",'');
      StandardCustomerSalesCode.CreateSalesInvoice(WORKDATE,WORKDATE);
      SalesHeader.SETRANGE("Document Type",SalesHeader."Document Type"::Invoice);
      SalesHeader.SETRANGE("Sell-to Customer No.",Customer."No.");
      SalesHeader.SETRANGE("Direct Debit Mandate ID",SEPADirectDebitMandate.ID);
      SalesHeader.FINDFIRST;
      SalesLine.SETRANGE("Document Type",SalesHeader."Document Type");
      SalesLine.SETRANGE("Document No.",SalesHeader."No.");
      SalesLine.FINDFIRST;
      SalesLine.TESTFIELD(Type,SalesLine.Type::"G/L Account");
Member of Lib.Library - ERM


CreateVATPostingSetupWithAccounts@172 Method

The procedure CreateVATPostingSetupWithAccounts is available in codeunit 131300.

Syntax

CreateVATPostingSetupWithAccounts@172(
    VAR VATPostingSetup@1003 : Record 325 VATPostingSetup, //Reference parameter of type Record
    VATCalculationType@1002 : Option VATCalculationType, //Input parameter of type Option
    VATRate@1004 : Decimal VATRate //Input parameter of type Decimal
);

Parameters

VATPostingSetup
Reference parameter of type Record
VATCalculationType
Input parameter of type Option
VATRate
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, VAT, Posting, Setup, Accounts.

For a clarification about how this function works, refer to the code listed below.

      VATPostingSetup.INIT;
      CreateVATBusinessPostingGroup(VATBusinessPostingGroup);
      CreateVATProductPostingGroup(VATProductPostingGroup);
      VATPostingSetup.VALIDATE("VAT Bus. Posting Group",VATBusinessPostingGroup.Code);
      VATPostingSetup.VALIDATE("VAT Prod. Posting Group",VATProductPostingGroup.Code);
      VATPostingSetup.VALIDATE("VAT Calculation Type",VATCalculationType);
      // VATPostingSetup.VALIDATE("VAT %",VATRate);
      VATPostingSetup.VALIDATE("VAT %",0);
      VATPostingSetup.VALIDATE("VAT Identifier",
        LibraryUtility.GenerateRandomCode(VATPostingSetup.FIELDNO("VAT Identifier"),DATABASE::"VAT Posting Setup"));
      VATPostingSetup.VALIDATE("Sales VAT Account",CreateGLAccountNo);
      VATPostingSetup.VALIDATE("Purchase VAT Account",CreateGLAccountNo);
      VATPostingSetup.VALIDATE("Tax Category",'S');
      VATPostingSetup.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134008 to show one way of using this function.

      LibraryERM.CreateVATPostingSetupWithAccounts(
        VATPostingSetup,VATPostingSetup."VAT Calculation Type"::"Normal VAT",LibraryRandom.RandInt(10));
      SelectGeneralJournalBatch(GenJournalBatch);

      // Use Random value for Amount because value is not important.
      LibraryERM.CreateGeneralJnlLine(
        GenJournalLine,GenJournalBatch."Journal Template Name",GenJournalBatch.Name,
        GenJournalLine."Document Type",GenJournalLine."Account Type",
        LibraryERM.CreateGLAccountWithVATPostingSetup(VATPostingSetup,GenJournalLine."Gen. Posting Type"::Sale),
        LibraryRandom.RandDec(1000,2));
      LibraryERM.PostGeneralJnlLine(GenJournalLine);
Member of Lib.Library - ERM


CreateVATProductPostingGroup@107 Method

The procedure CreateVATProductPostingGroup is available in codeunit 131300.

Syntax

CreateVATProductPostingGroup@107(
    VAR VATProductPostingGroup@1000 : Record 324 VATProductPostingGroup //Reference parameter of type Record
);

Parameters

VATProductPostingGroup
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, VAT, Product, Posting, Group.

For a clarification about how this function works, refer to the code listed below.

      VATProductPostingGroup.INIT;
      VATProductPostingGroup.VALIDATE(
        Code,
        COPYSTR(LibraryUtility.GenerateRandomCode(VATProductPostingGroup.FIELDNO(Code),DATABASE::"VAT Product Posting Group"),
          1,LibraryUtility.GetFieldLength(DATABASE::"VAT Product Posting Group",VATProductPostingGroup.FIELDNO(Code))));

      // Validating Code as Name because value is not important.
      VATProductPostingGroup.VALIDATE(Description,VATProductPostingGroup.Code);
      VATProductPostingGroup.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134006 to show one way of using this function.

      LibraryERM.CreateVATBusinessPostingGroup(VATBusinessPostingGroup);
      LibraryERM.CreateVATProductPostingGroup(VATProductPostingGroup);
      LibraryERM.CreateVATPostingSetup(
        VATPostingSetup,VATBusinessPostingGroup.Code,VATProductPostingGroup.Code);
      WITH VATPostingSetup DO BEGIN
        VALIDATE("VAT %",VATPercent);
        VALIDATE("Sales VAT Account",LibraryERM.CreateGLAccountNo);
        VALIDATE("Purchase VAT Account",LibraryERM.CreateGLAccountNo);
        MODIFY(TRUE);
      END;
Member of Lib.Library - ERM


CreateVATProductPostingGroups@1500018 Method

The procedure CreateVATProductPostingGroups is available in codeunit 131300.

Syntax

CreateVATProductPostingGroups@1500018(
    VATProductPostingGroups@1000 : Code[10] VATProductPostingGroups //Input parameter of type Code
);

Parameters

VATProductPostingGroups
Input parameter of type Code

Remarks

The relevant search keywords are: Create, VAT, Product, Posting, Groups.

For a clarification about how this function works, refer to the code listed below.

      VATProductPostingGroup.INIT;
      VATProductPostingGroup.VALIDATE(Code,VATProductPostingGroups);
      // Validating Code as Name because value is not important.
      VATProductPostingGroup.VALIDATE(Description,VATProductPostingGroup.Code);
      VATProductPostingGroup.INSERT(TRUE);

Example

There are no examples available.
Member of Lib.Library - ERM


CreateVATRegistrationNoFormat@81 Method

The procedure CreateVATRegistrationNoFormat is available in codeunit 131300.

Syntax

CreateVATRegistrationNoFormat@81(
    VAR VATRegistrationNoFormat@1000 : Record 381 VATRegistrationNoFormat, //Reference parameter of type Record
    CountryRegionCode@1001 : Code[10] CountryRegionCode //Input parameter of type Code
);

Parameters

VATRegistrationNoFormat
Reference parameter of type Record
CountryRegionCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, VAT, Registration, No, Format.

For a clarification about how this function works, refer to the code listed below.

      VATRegistrationNoFormat.INIT;
      VATRegistrationNoFormat.VALIDATE("Country/Region Code",CountryRegionCode);
      RecRef.GETTABLE(VATRegistrationNoFormat);
      VATRegistrationNoFormat.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,VATRegistrationNoFormat.FIELDNO("Line No.")));
      VATRegistrationNoFormat.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134047 to show one way of using this function.

      CreateCountryVATRegistration(CountryRegionCode);
      LibraryERM.CreateVATRegistrationNoFormat(VATRegistrationNoFormat,CountryRegionCode);
      VATRegistrationNoFormat.VALIDATE(Format,'TEST1.###.1');  // Taking Hard Coded Value because of Format Restriction.
      VATRegistrationNoFormat.MODIFY(TRUE);
Member of Lib.Library - ERM


CreateVATStatementLine@119 Method

The procedure CreateVATStatementLine is available in codeunit 131300.

Syntax

CreateVATStatementLine@119(
    VAR VATStatementLine@1000 : Record 256 VATStatementLine, //Reference parameter of type Record
    StatementTemplateName@1001 : Code[10] StatementTemplateName, //Input parameter of type Code
    StatementName@1002 : Code[10] StatementName //Input parameter of type Code
);

Parameters

VATStatementLine
Reference parameter of type Record
StatementTemplateName
Input parameter of type Code
StatementName
Input parameter of type Code

Remarks

The relevant search keywords are: Create, VAT, Statement, Line.

For a clarification about how this function works, refer to the code listed below.

      VATStatementLine.INIT;
      VATStatementLine.VALIDATE("Statement Template Name",StatementTemplateName);
      VATStatementLine.VALIDATE("Statement Name",StatementName);
      RecRef.GETTABLE(VATStatementLine);
      VATStatementLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,VATStatementLine.FIELDNO("Line No.")));
      VATStatementLine.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134992 to show one way of using this function.

      LibraryERM.CreateVATStatementTemplate(VATStatementTemplate);
      LibraryERM.CreateVATStatementName(VATStatementName,VATStatementTemplate.Name);
      LibraryERM.CreateVATStatementLine(VATStatementLine,VATStatementTemplate.Name,VATStatementName.Name);
      VATStatementLine.VALIDATE("Row No.",FORMAT(LibraryRandom.RandInt(100)));
      VATStatementLine.VALIDATE(Type,VATStatementLine.Type::"VAT Entry Totaling");
      VATStatementLine.VALIDATE("Gen. Posting Type",GenPostingType);
      VATStatementLine.VALIDATE("VAT Bus. Posting Group",VATPostingSetup."VAT Bus. Posting Group");
      VATStatementLine.VALIDATE("VAT Prod. Posting Group",VATPostingSetup."VAT Prod. Posting Group");
      VATStatementLine.VALIDATE("Amount Type",VATStatementLine."Amount Type"::Amount);
      VATStatementLine.MODIFY(TRUE);
Member of Lib.Library - ERM


CreateVATStatementName@120 Method

The procedure CreateVATStatementName is available in codeunit 131300.

Syntax

CreateVATStatementName@120(
    VAR VATStatementName@1000 : Record 257 VATStatementName, //Reference parameter of type Record
    StatementTemplateName@1001 : Code[10] StatementTemplateName //Input parameter of type Code
);

Parameters

VATStatementName
Reference parameter of type Record
StatementTemplateName
Input parameter of type Code

Remarks

The relevant search keywords are: Create, VAT, Statement, Name.

For a clarification about how this function works, refer to the code listed below.

      VATStatementName.INIT;
      VATStatementName.VALIDATE("Statement Template Name",StatementTemplateName);
      VATStatementName.VALIDATE(
        Name,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(VATStatementName.FIELDNO(Name),DATABASE::"VAT Statement Name"),1,
          LibraryUtility.GetFieldLength(DATABASE::"VAT Statement Name",VATStatementName.FIELDNO(Name))));
      VATStatementName.VALIDATE(Description,VATStatementName.Name);  // Validating Name as Description because value is not important.
      VATStatementName.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134992 to show one way of using this function.

      LibraryERM.CreateVATStatementTemplate(VATStatementTemplate);
      LibraryERM.CreateVATStatementName(VATStatementName,VATStatementTemplate.Name);
      LibraryERM.CreateVATStatementLine(VATStatementLine,VATStatementTemplate.Name,VATStatementName.Name);
      VATStatementLine.VALIDATE("Row No.",FORMAT(LibraryRandom.RandInt(100)));
      VATStatementLine.VALIDATE(Type,VATStatementLine.Type::"VAT Entry Totaling");
      VATStatementLine.VALIDATE("Gen. Posting Type",GenPostingType);
      VATStatementLine.VALIDATE("VAT Bus. Posting Group",VATPostingSetup."VAT Bus. Posting Group");
      VATStatementLine.VALIDATE("VAT Prod. Posting Group",VATPostingSetup."VAT Prod. Posting Group");
      VATStatementLine.VALIDATE("Amount Type",VATStatementLine."Amount Type"::Amount);
      VATStatementLine.MODIFY(TRUE);
Member of Lib.Library - ERM


CreateVATStatementNameWithTemplate@219 Method

The procedure CreateVATStatementNameWithTemplate is available in codeunit 131300.

Syntax

CreateVATStatementNameWithTemplate@219(
    VAR VATStatementName@1000 : Record 257 VATStatementName //Reference parameter of type Record
);

Parameters

VATStatementName
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, VAT, Statement, Name, Template.

For a clarification about how this function works, refer to the code listed below.

      CreateVATStatementTemplate(VATStatementTemplate);
      CreateVATStatementName(VATStatementName,VATStatementTemplate.Name);

Example

There are no examples available.
Member of Lib.Library - ERM


CreateVATStatementTemplate@118 Method

The procedure CreateVATStatementTemplate is available in codeunit 131300.

Syntax

CreateVATStatementTemplate@118(
    VAR VATStatementTemplate@1000 : Record 255 VATStatementTemplate //Reference parameter of type Record
);

Parameters

VATStatementTemplate
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, VAT, Statement, Template.

For a clarification about how this function works, refer to the code listed below.

      VATStatementTemplate.INIT;
      VATStatementTemplate.VALIDATE(
        Name,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(VATStatementTemplate.FIELDNO(Name),DATABASE::"VAT Statement Template"),1,
          LibraryUtility.GetFieldLength(DATABASE::"VAT Statement Template",VATStatementTemplate.FIELDNO(Name))));
      VATStatementTemplate.VALIDATE(Description,VATStatementTemplate.Name);  // Validating Name as Description because value is not important.
      VATStatementTemplate.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134992 to show one way of using this function.

      LibraryERM.CreateVATStatementTemplate(VATStatementTemplate);
      LibraryERM.CreateVATStatementName(VATStatementName,VATStatementTemplate.Name);
      LibraryERM.CreateVATStatementLine(VATStatementLine,VATStatementTemplate.Name,VATStatementName.Name);
      VATStatementLine.VALIDATE("Row No.",FORMAT(LibraryRandom.RandInt(100)));
      VATStatementLine.VALIDATE(Type,VATStatementLine.Type::"VAT Entry Totaling");
      VATStatementLine.VALIDATE("Gen. Posting Type",GenPostingType);
      VATStatementLine.VALIDATE("VAT Bus. Posting Group",VATPostingSetup."VAT Bus. Posting Group");
      VATStatementLine.VALIDATE("VAT Prod. Posting Group",VATPostingSetup."VAT Prod. Posting Group");
      VATStatementLine.VALIDATE("Amount Type",VATStatementLine."Amount Type"::Amount);
      VATStatementLine.MODIFY(TRUE);
Member of Lib.Library - ERM


FindBankAccount@57 Method

The procedure FindBankAccount is available in codeunit 131300.

Syntax

FindBankAccount@57(
    VAR BankAccount@1000 : Record 270 BankAccount //Reference parameter of type Record
);

Parameters

BankAccount
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Bank, Account.

For a clarification about how this function works, refer to the code listed below.

      BankAccount.SETFILTER("Bank Acc. Posting Group",'<>%1','');
      BankAccount.SETRANGE("Currency Code",'');
      BankAccount.SETRANGE(Blocked,FALSE);
      IF NOT BankAccount.FINDFIRST THEN
        CreateBankAccount(BankAccount);

Example

The below example is extracted from the test automation codeunit 134001 to show one way of using this function.

      LibraryERM.FindBankAccount(BankAccount);
      LibraryERM.SelectGenJnlBatch(GenJournalBatch);
      LibraryERM.ClearGenJournalLines(GenJournalBatch);
      LibraryERM.CreateGeneralJnlLine(
        GenJournalLine,GenJournalBatch."Journal Template Name",GenJournalBatch.Name,DocumentType,
        GenJournalLine."Account Type"::Vendor,AccountNo,Amount);
      GenJournalLine.VALIDATE("Bal. Account Type",GenJournalLine."Bal. Account Type"::"Bank Account");
      GenJournalLine.VALIDATE("Bal. Account No.",BankAccount."No.");
      GenJournalLine.MODIFY(TRUE);
Member of Lib.Library - ERM


FindBankAccountPostingGroup@95 Method

The procedure FindBankAccountPostingGroup is available in codeunit 131300.

Syntax

FindBankAccountPostingGroup@95(
    VAR BankAccountPostingGroup@1000 : Record 277 BankAccountPostingGroup //Reference parameter of type Record
);

Parameters

BankAccountPostingGroup
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Bank, Account, Posting, Group.

For a clarification about how this function works, refer to the code listed below.

      IF NOT BankAccountPostingGroup.FINDFIRST THEN
        CreateBankAccountPostingGroup(BankAccountPostingGroup);

Example

The below example is extracted from the test automation codeunit 134086 to show one way of using this function.

      LibraryERM.FindBankAccountPostingGroup(BankAccountPostingGroup);
      LibraryERM.CreateBankAccount(BankAccount);
      BankAccount.VALIDATE("Currency Code",CurrencyCode);
      BankAccount.VALIDATE("Bank Acc. Posting Group",BankAccountPostingGroup.Code);
      BankAccount.MODIFY(TRUE);
      EXIT(BankAccount."No.");
Member of Lib.Library - ERM


FindCountryRegion@137 Method

The procedure FindCountryRegion is available in codeunit 131300.

Syntax

FindCountryRegion@137(
    VAR CountryRegion@1000 : Record 9 CountryRegion //Reference parameter of type Record
);

Parameters

CountryRegion
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Country, Region.

For a clarification about how this function works, refer to the code listed below.

      IF NOT CountryRegion.FINDFIRST THEN
        CreateCountryRegion(CountryRegion);

Example

There are no examples available.
Member of Lib.Library - ERM


FindCurrency@56 Method

The procedure FindCurrency is available in codeunit 131300.

Syntax

FindCurrency@56(
    VAR Currency@1000 : Record 4 Currency //Reference parameter of type Record
);

Parameters

Currency
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Currency.

For a clarification about how this function works, refer to the code listed below.

      IF NOT Currency.FINDFIRST THEN
        CreateCurrency(Currency);

Example

The below example is extracted from the test automation codeunit 134045 to show one way of using this function.

      // Check VAT Difference on VAT Amount Line for Sales Order after changing Currency on Sales Header.

      // Setup: Create Sales Order and calculate VAT Amount.
      Initialize;
      VATDifference := ModifyAllowVATDifferenceSales(TRUE);
      CreateSalesDocumentAndCalcVAT(SalesHeader,SalesLine,SalesHeader."Document Type"::Order,VATDifference);

      // Exercise: Change Currency on Sales Header and Calculate VAT Amount Lines.
      LibraryERM.FindCurrency(Currency);
      SalesHeader.VALIDATE("Currency Code",Currency.Code);
      SalesHeader.MODIFY(TRUE);
      CalcSalesVATAmountLines(VATAmountLine,SalesHeader,SalesLine);

      // Verify: Verify VAT Amount Line for VAT Difference.
      Assert.AreEqual(0,VATAmountLine."VAT Difference",STRSUBSTNO(VATDifferenceErr,0,VATAmountLine.TABLECAPTION));

      // Tear Down: Delete Sales Header.
      SalesHeader.DELETE(TRUE);
Member of Lib.Library - ERM


FindCustomerLedgerEntry@20 Method

The procedure FindCustomerLedgerEntry is available in codeunit 131300.

Syntax

FindCustomerLedgerEntry@20(
    VAR CustLedgerEntry@1002 : Record 21 CustLedgerEntry, //Reference parameter of type Record
    DocumentType@1001 : Option DocumentType, //Input parameter of type Option
    DocumentNo@1000 : Code[20] DocumentNo //Input parameter of type Code
);

Parameters

CustLedgerEntry
Reference parameter of type Record
DocumentType
Input parameter of type Option
DocumentNo
Input parameter of type Code

Remarks

The relevant search keywords are: Find, Customer, Ledger, Entry.

For a clarification about how this function works, refer to the code listed below.

      // Finds the matching Customer Ledger Entry from a General Journal Line.
      WITH CustLedgerEntry DO BEGIN
        SETRANGE("Document Type",DocumentType);
        SETRANGE("Document No.",DocumentNo);
        FINDFIRST;
      END;

Example

The below example is extracted from the test automation codeunit 134000 to show one way of using this function.

      LibraryERM.FindCustomerLedgerEntry(CustLedgerEntry,DocumentType,DocumentNo);
      LibraryERM.UnapplyCustomerLedgerEntry(CustLedgerEntry);
Member of Lib.Library - ERM


FindDeferralLine@214 Method

The procedure FindDeferralLine is available in codeunit 131300.

Syntax

FindDeferralLine@214(
    VAR DeferralLine@1000 : Record 1702 DeferralLine, //Reference parameter of type Record
    DeferralDocType@1004 : Option DeferralDocType, //Input parameter of type Option
    GenJnlBatchName@1005 : Code[10] GenJnlBatchName, //Input parameter of type Code
    GenJnlTemplateName@1006 : Code[10] GenJnlTemplateName, //Input parameter of type Code
    DocType@1003 : Integer DocType, //Input parameter of type Integer
    DocNo@1002 : Code[20] DocNo, //Input parameter of type Code
    LineNo@1001 : Integer LineNo //Input parameter of type Integer
);

Parameters

DeferralLine
Reference parameter of type Record
DeferralDocType
Input parameter of type Option
GenJnlBatchName
Input parameter of type Code
GenJnlTemplateName
Input parameter of type Code
DocType
Input parameter of type Integer
DocNo
Input parameter of type Code
LineNo
Input parameter of type Integer

Remarks

The relevant search keywords are: Find, Deferral, Line.

For a clarification about how this function works, refer to the code listed below.

      WITH DeferralLine DO BEGIN
        SETRANGE("Deferral Doc. Type",DeferralDocType);
        SETRANGE("Gen. Jnl. Batch Name",GenJnlBatchName);
        SETRANGE("Gen. Jnl. Template Name",GenJnlTemplateName);
        SETRANGE("Document Type",DocType);
        SETRANGE("Document No.",DocNo);
        SETRANGE("Line No.",LineNo);
        FINDFIRST;
      END;

Example

The below example is extracted from the test automation codeunit 134804 to show one way of using this function.

      ASSERTERROR DeferralHeader.GET(GetPurchDeferralDocType,'','',DocType,DocNo,LineNo);
      ASSERTERROR LibraryERM.FindDeferralLine(DeferralLine,GetPurchDeferralDocType,'','',DocType,DocNo,LineNo);
Member of Lib.Library - ERM


FindDirectPostingGLAccount@139 Method

The procedure FindDirectPostingGLAccount is available in codeunit 131300.

Syntax

FindDirectPostingGLAccount@139(
    VAR GLAccount@1000 : Record 15 GLAccount //Reference parameter of type Record
);

Parameters

GLAccount
Reference parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Find, Direct, Posting, General Ledger, Account.

For a clarification about how this function works, refer to the code listed below.

      SetGLAccountDirectPostingFilter(GLAccount);
      GLAccount.FINDFIRST;
      EXIT(GLAccount."No.");

Example

The below example is extracted from the test automation codeunit 134008 to show one way of using this function.

      VATPostingSetup.SETFILTER("VAT %",'>0');
      VATPostingSetup.FINDLAST;
      VATPostingSetup.VALIDATE("Unrealized VAT Type",UnrealizedVATType);
      VATPostingSetup.VALIDATE("Sales VAT Unreal. Account",LibraryERM.FindDirectPostingGLAccount(GLAccount));
      VATPostingSetup.MODIFY(TRUE);
Member of Lib.Library - ERM


FindEarliestDateForExhRate@201 Method

The procedure FindEarliestDateForExhRate is available in codeunit 131300.

Syntax

FindEarliestDateForExhRate@201(
      //param element not supplied
);

Return Value

Date

Remarks

The relevant search keywords are: Find, Earliest, Date, For, Exh, Rate.

For a clarification about how this function works, refer to the code listed below.

      Date := MinDate(WORKDATE,TODAY);
      GLEntry.SETCURRENTKEY("Posting Date");
      IF GLEntry.FINDFIRST THEN
        Date := MinDate(Date,NORMALDATE(GLEntry."Posting Date"));
      EXIT(Date);

Example

There are no examples available.
Member of Lib.Library - ERM


FindExchRate@22 Method

The procedure FindExchRate is available in codeunit 131300.

Syntax

FindExchRate@22(
    VAR CurrencyExchangeRate@1002 : Record 330 CurrencyExchangeRate, //Reference parameter of type Record
    Currency@1001 : Code[10] Currency, //Input parameter of type Code
    ConversionDate@1000 : Date ConversionDate //Input parameter of type Date
);

Parameters

CurrencyExchangeRate
Reference parameter of type Record
Currency
Input parameter of type Code
ConversionDate
Input parameter of type Date

Remarks

The relevant search keywords are: Find, Exchange, Rate.

For a clarification about how this function works, refer to the code listed below.

      // Returns the Exchange Rate for a specified Currency at a specified Date. If multiple Exchange Rates exists it picks the latest.
      CurrencyExchangeRate.SETRANGE("Currency Code",Currency);
      CurrencyExchangeRate.SETRANGE("Starting Date",0D,ConversionDate);
      CurrencyExchangeRate.FINDLAST;

Example

The below example is extracted from the test automation codeunit 134902 to show one way of using this function.

      LibraryERM.FindExchRate(CurrencyExchangeRate,CurrencyCode,ConversionDate);
      EXIT(
        ROUND(
          Amount * CurrencyExchangeRate."Exchange Rate Amount" / CurrencyExchangeRate."Relational Exch. Rate Amount",
          LibraryERM.GetAmountRoundingPrecision));
Member of Lib.Library - ERM


FindExcisePostingSetup@1500015 Method

The procedure FindExcisePostingSetup is available in codeunit 131300.

Syntax

FindExcisePostingSetup@1500015(
    VAR ExcisePostingSetup@1500000 : Record 13711 ExcisePostingSetup //Reference parameter of type Record
);

Parameters

ExcisePostingSetup
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Excise, Posting, Setup.

For a clarification about how this function works, refer to the code listed below.

      ExcisePostingSetup.SETFILTER("Excise Bus. Posting Group",'<>%1','');
      ExcisePostingSetup.SETFILTER("Excise Prod. Posting Group",'<>%1','');
      ExcisePostingSetup.FINDFIRST;

Example

The below example is extracted from the test automation codeunit 144001 to show one way of using this function.

      ExcisePostingSetup.SETRANGE("BED Calculation Type",ExcisePostingSetup."BED Calculation Type"::"Excise %");
      LibraryERM.FindExcisePostingSetup(ExcisePostingSetup);
Member of Lib.Library - ERM


FindGenBusinessPostingGroup@65 Method

The procedure FindGenBusinessPostingGroup is available in codeunit 131300.

Syntax

FindGenBusinessPostingGroup@65(
    VAR GenBusinessPostingGroup@1000 : Record 250 GenBusinessPostingGroup //Reference parameter of type Record
);

Parameters

GenBusinessPostingGroup
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, General, Business, Posting, Group.

For a clarification about how this function works, refer to the code listed below.

      IF NOT GenBusinessPostingGroup.FINDFIRST THEN
        CreateGenBusPostingGroup(GenBusinessPostingGroup);

Example

The below example is extracted from the test automation codeunit 134327 to show one way of using this function.

      LibraryERM.FindGenBusinessPostingGroup(GenBusinessPostingGroup);
      LibraryERM.FindVATBusinessPostingGroup(VATBusinessPostingGroup);
      TempVendor.INIT;
      TempVendor.VALIDATE("No.",GenerateVendorNo);
      TempVendor.INSERT;
      TempVendor.VALIDATE("Gen. Bus. Posting Group",GenBusinessPostingGroup.Code);
      TempVendor.VALIDATE("VAT Bus. Posting Group",VATBusinessPostingGroup.Code);
      TempVendor.VALIDATE("Vendor Posting Group",LibraryPurchase.FindVendorPostingGroup);
      TempVendor.MODIFY(TRUE);
Member of Lib.Library - ERM


FindGeneralJournalSourceCode@86 Method

The procedure FindGeneralJournalSourceCode is available in codeunit 131300.

Syntax

FindGeneralJournalSourceCode@86(
      //param element not supplied
);

Return Value

Code[10]

Remarks

The relevant search keywords are: Find, General, Journal, Source, Code.

For a clarification about how this function works, refer to the code listed below.

      // Find general journal source code
      WITH GenJournalTemplate DO BEGIN
        SETRANGE(Type,Type::General);
        SETRANGE(Recurring,FALSE);
        SETFILTER("Source Code",'<>%1','');
        SETRANGE("Sub Type","Sub Type"::" ");
        FINDFIRST;
        EXIT("Source Code");
      END;

Example

The below example is extracted from the test automation codeunit 134381 to show one way of using this function.

      // Test setup default dimension priority.

      // Setup: Find Source Code.
      Initialize;
      SourceCode := LibraryERM.FindGeneralJournalSourceCode;

      // Exercise: Create default dimension priority 1 for Customer, 1 for Vendor and  2 for G/L Account with source code.
      SetDefaultDimensionPriority(SourceCode);

      // Verify: Verify default dimension priority for Customer, Vendor and G/L Account with Source Code must exist.
      VerifyDefaultDimensionPriority(SourceCode);
Member of Lib.Library - ERM


FindGeneralPostingSetup@99 Method

The procedure FindGeneralPostingSetup is available in codeunit 131300.

Syntax

FindGeneralPostingSetup@99(
    VAR GeneralPostingSetup@1000 : Record 252 GeneralPostingSetup //Reference parameter of type Record
);

Parameters

GeneralPostingSetup
Reference parameter of type Record

Return Value

Boolean

Remarks

The relevant search keywords are: Find, General, Posting, Setup.

For a clarification about how this function works, refer to the code listed below.

      GeneralPostingSetup.SETFILTER("Gen. Bus. Posting Group",'<>%1','');
      GeneralPostingSetup.SETFILTER("Gen. Prod. Posting Group",'<>%1','');
      GeneralPostingSetup.FINDFIRST;
      EXIT(TRUE);

Example

The below example is extracted from the test automation codeunit 134007 to show one way of using this function.

      LibraryERM.FindGeneralPostingSetup(GeneralPostingSetup);
      LibraryERM.FindVATPostingSetup(VATPostingSetup,VATPostingSetup."VAT Calculation Type"::"Reverse Charge VAT");
      VATPostingSetup.VALIDATE("Adjust for Payment Discount",TRUE);
      VATPostingSetup.MODIFY(TRUE);
      VendNo :=
        CreateVendorWithPostingSetup(GeneralPostingSetup."Gen. Bus. Posting Group",VATPostingSetup."VAT Bus. Posting Group");
      ItemNo :=
        CreateItemWithPostingSetup(GeneralPostingSetup."Gen. Prod. Posting Group",VATPostingSetup."VAT Prod. Posting Group");
      LibraryPurchase.CreatePurchHeader(PurchHeader,PurchHeader."Document Type"::Invoice,VendNo);
      LibraryPurchase.CreatePurchaseLine(PurchLine,PurchHeader,PurchLine.Type::Item,ItemNo,LibraryRandom.RandInt(100));
      UpdateDirectUnitCostOnPurchaseLine(PurchLine,LibraryRandom.RandDec(100,2));
      EXIT(LibraryPurchase.PostPurchaseDocument(PurchHeader,TRUE,TRUE));
Member of Lib.Library - ERM


FindGeneralPostingSetupInvtBase@161 Method

The procedure FindGeneralPostingSetupInvtBase is available in codeunit 131300.

Syntax

FindGeneralPostingSetupInvtBase@161(
    VAR GeneralPostingSetup@1000 : Record 252 GeneralPostingSetup //Reference parameter of type Record
);

Parameters

GeneralPostingSetup
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, General, Posting, Setup, Invt, Base.

For a clarification about how this function works, refer to the code listed below.

      GeneralPostingSetup.SETFILTER("Gen. Bus. Posting Group",'<>%1','');
      GeneralPostingSetup.SETFILTER("Gen. Prod. Posting Group",'<>%1','');
      GeneralPostingSetup.SETFILTER("COGS Account",'<>%1','');
      GeneralPostingSetup.SETFILTER("Sales Account",'<>%1','');
      GeneralPostingSetup.SETFILTER("Purch. Account",'<>%1','');
      GeneralPostingSetup.SETFILTER("Inventory Adjmt. Account",'<>%1','');
      IF NOT GeneralPostingSetup.FINDFIRST THEN BEGIN
        GeneralPostingSetup.SETRANGE("Purch. Account");
        GeneralPostingSetup.SETRANGE("Inventory Adjmt. Account");
        IF GeneralPostingSetup.FINDFIRST THEN BEGIN
          GeneralPostingSetup.SETFILTER("Purch. Account",CreateGLAccountNo);
          GeneralPostingSetup.SETFILTER("Inventory Adjmt. Account",CreateGLAccountNo);
          GeneralPostingSetup.MODIFY(TRUE);
        END ELSE
          CreateGeneralPostingSetupInvt(GeneralPostingSetup);
      END;

Example

There are no examples available.
Member of Lib.Library - ERM


FindGeneralPostingSetupInvtFull@173 Method

The procedure FindGeneralPostingSetupInvtFull is available in codeunit 131300.

Syntax

FindGeneralPostingSetupInvtFull@173(
    VAR GeneralPostingSetup@1000 : Record 252 GeneralPostingSetup //Reference parameter of type Record
);

Parameters

GeneralPostingSetup
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, General, Posting, Setup, Invt, Full.

For a clarification about how this function works, refer to the code listed below.

      GeneralPostingSetup.SETFILTER("Gen. Bus. Posting Group",'<>%1','');
      GeneralPostingSetup.SETFILTER("Gen. Prod. Posting Group",'<>%1','');
      GeneralPostingSetup.SETFILTER("Sales Account",'<>%1','');
      GeneralPostingSetup.SETFILTER("Purch. Account",'<>%1','');
      GeneralPostingSetup.SETFILTER("COGS Account",'<>%1','');
      GeneralPostingSetup.SETFILTER("COGS Account (Interim)",'<>''''');
      GeneralPostingSetup.SETFILTER("Inventory Adjmt. Account",'<>%1','');
      GeneralPostingSetup.SETFILTER("Sales Credit Memo Account",'<>%1','');
      GeneralPostingSetup.SETFILTER("Purch. Credit Memo Account",'<>%1','');
      GeneralPostingSetup.SETFILTER("Direct Cost Applied Account",'<>%1','');
      GeneralPostingSetup.SETFILTER("Overhead Applied Account",'<>%1','');
      GeneralPostingSetup.SETFILTER("Purchase Variance Account",'<>%1','');
      GeneralPostingSetup.SETFILTER("Sales Prepayments Account",'<>%1','');
      GeneralPostingSetup.SETFILTER("Purch. Prepayments Account",'<>%1','');
      IF NOT GeneralPostingSetup.FINDFIRST THEN BEGIN
        GeneralPostingSetup.SETRANGE("Sales Prepayments Account");
        GeneralPostingSetup.SETRANGE("Purch. Prepayments Account");
        IF GeneralPostingSetup.FINDFIRST THEN BEGIN
          SetGeneralPostingSetupPrepAccounts(GeneralPostingSetup);
          GeneralPostingSetup.MODIFY(TRUE);
        END ELSE BEGIN
          GeneralPostingSetup.SETRANGE("COGS Account (Interim)");
          GeneralPostingSetup.SETRANGE("Direct Cost Applied Account");
          GeneralPostingSetup.SETRANGE("Overhead Applied Account");
          GeneralPostingSetup.SETRANGE("Purchase Variance Account");
          IF GeneralPostingSetup.FINDFIRST THEN BEGIN
            SetGeneralPostingSetupInvtAccounts(GeneralPostingSetup);
            SetGeneralPostingSetupMfgAccounts(GeneralPostingSetup);
            SetGeneralPostingSetupPrepAccounts(GeneralPostingSetup);
            GeneralPostingSetup.MODIFY(TRUE);
          END ELSE BEGIN
            GeneralPostingSetup.SETRANGE("Purch. Account");
            GeneralPostingSetup.SETRANGE("Purch. Credit Memo Account");
            IF GeneralPostingSetup.FINDFIRST THEN BEGIN
              SetGeneralPostingSetupInvtAccounts(GeneralPostingSetup);
              SetGeneralPostingSetupMfgAccounts(GeneralPostingSetup);
              SetGeneralPostingSetupPrepAccounts(GeneralPostingSetup);
              SetGeneralPostingSetupPurchAccounts(GeneralPostingSetup);
              GeneralPostingSetup.MODIFY(TRUE);
            END ELSE
              FindGeneralPostingSetupInvtBase(GeneralPostingSetup);
          END;
        END;
      END;

Example

The below example is extracted from the test automation codeunit 134006 to show one way of using this function.

      LibraryERM.FindGeneralPostingSetupInvtFull(GeneralPostingSetup);
      LibraryERM.FindVATPostingSetup(VATPostingSetup,VATPostingSetup."VAT Calculation Type"::"Reverse Charge VAT");
      VATPostingSetup.VALIDATE("Adjust for Payment Discount",TRUE);
      VATPostingSetup.MODIFY(TRUE);
      VendNo :=
        CreateCustomerWithPostingSetup(GeneralPostingSetup."Gen. Bus. Posting Group",VATPostingSetup."VAT Bus. Posting Group");
      ItemNo :=
        CreateItemWithPostingSetup(GeneralPostingSetup."Gen. Prod. Posting Group",VATPostingSetup."VAT Prod. Posting Group");
      LibrarySales.CreateSalesHeader(SalesHeader,SalesHeader."Document Type"::Invoice,VendNo);
      LibrarySales.CreateSalesLine(SalesLine,SalesHeader,SalesLine.Type::Item,ItemNo,LibraryRandom.RandInt(100));
      SalesLine.VALIDATE("Unit Price",LibraryRandom.RandDec(100,2));
      SalesLine.MODIFY(TRUE);
      EXIT(LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE));
Member of Lib.Library - ERM


FindGeneralPostingSetupInvtToGL@197 Method

The procedure FindGeneralPostingSetupInvtToGL is available in codeunit 131300.

Syntax

FindGeneralPostingSetupInvtToGL@197(
    VAR GeneralPostingSetup@1000 : Record 252 GeneralPostingSetup //Reference parameter of type Record
);

Parameters

GeneralPostingSetup
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, General, Posting, Setup, Invt, To, General Ledger.

For a clarification about how this function works, refer to the code listed below.

      GeneralPostingSetup.SETRANGE("Gen. Bus. Posting Group",'');
      GeneralPostingSetup.SETFILTER("Gen. Prod. Posting Group",'<>%1','');
      GeneralPostingSetup.SETFILTER("COGS Account",'<>%1','');
      GeneralPostingSetup.SETFILTER("COGS Account (Interim)",'<>%1','');
      GeneralPostingSetup.SETFILTER("Inventory Adjmt. Account",'<>%1','');
      GeneralPostingSetup.SETFILTER("Direct Cost Applied Account",'<>%1','');
      GeneralPostingSetup.SETFILTER("Overhead Applied Account",'<>%1','');
      GeneralPostingSetup.SETFILTER("Purchase Variance Account",'<>%1','');
      GeneralPostingSetup.SETFILTER("Invt. Accrual Acc. (Interim)",'<>%1','');
      IF NOT GeneralPostingSetup.FINDFIRST THEN BEGIN
        GeneralPostingSetup.SETRANGE("COGS Account (Interim)");
        GeneralPostingSetup.SETRANGE("Direct Cost Applied Account");
        GeneralPostingSetup.SETRANGE("Overhead Applied Account");
        GeneralPostingSetup.SETRANGE("Purchase Variance Account");
        GeneralPostingSetup.SETRANGE("Invt. Accrual Acc. (Interim)");
        IF GeneralPostingSetup.FINDFIRST THEN BEGIN
          SetGeneralPostingSetupInvtAccounts(GeneralPostingSetup);
          SetGeneralPostingSetupMfgAccounts(GeneralPostingSetup);
          GeneralPostingSetup.MODIFY(TRUE);
        END ELSE
          FindGeneralPostingSetupInvtBase(GeneralPostingSetup);
      END;

Example

There are no examples available.
Member of Lib.Library - ERM


FindGenJournalBatch@78 Method

The procedure FindGenJournalBatch is available in codeunit 131300.

Syntax

FindGenJournalBatch@78(
    VAR GenJournalBatch@1000 : Record 232 GenJournalBatch, //Reference parameter of type Record
    JournalTemplateName@1001 : Code[10] JournalTemplateName //Input parameter of type Code
);

Parameters

GenJournalBatch
Reference parameter of type Record
JournalTemplateName
Input parameter of type Code

Remarks

The relevant search keywords are: Find, General, Journal, Batch.

For a clarification about how this function works, refer to the code listed below.

      GenJournalBatch.SETRANGE("Journal Template Name",JournalTemplateName);
      IF NOT GenJournalBatch.FINDFIRST THEN
        CreateGenJournalBatch(GenJournalBatch,JournalTemplateName);

Example

The below example is extracted from the test automation codeunit 134451 to show one way of using this function.

      // Verify program opens General Journal batch on clicking lookup on 'Gen. Jnl. Batch Name' on FA Journal Setup.

      // 1.Setup: Find Depreciation Book,FA Journal Template and FA Journal Batch.
      Initialize;
      LibraryFixedAsset.CreateDepreciationBook(DepreciationBook);
      GenJournalTemplate.SETRANGE(Type,GenJournalTemplate.Type::Assets);
      LibraryERM.FindGenJournalTemplate(GenJournalTemplate);
      LibraryERM.FindGenJournalBatch(GenJournalBatch,GenJournalTemplate.Name);

      // Variables 'GenJournalTemplateName' and 'GenJournalBatchName' are declared Global as they are used in Handler method.
      GenJournalTemplateName := GenJournalTemplate.Name;
      GenJournalBatchName := GenJournalBatch.Name;

      // 2.Exercise: From Depreciation Book open FA Journal Setup page.
      OpenFAJnlSetupFromDepBook(DepreciationBook.Code);

      // 3.Verify: Verification is done in 'GenJournalBatchesHandler' handler method.
Member of Lib.Library - ERM


FindGenJournalTemplate@66 Method

The procedure FindGenJournalTemplate is available in codeunit 131300.

Syntax

FindGenJournalTemplate@66(
    VAR GenJournalTemplate@1000 : Record 80 GenJournalTemplate //Reference parameter of type Record
);

Parameters

GenJournalTemplate
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, General, Journal, Template.

For a clarification about how this function works, refer to the code listed below.

      GenJournalTemplate.SETRANGE(Recurring,FALSE);
      GenJournalTemplate.SETRANGE("Sub Type",GenJournalTemplate."Sub Type"::" ");
      IF NOT GenJournalTemplate.FINDFIRST THEN BEGIN
        CreateGenJournalTemplate(GenJournalTemplate);
        IF GenJournalTemplate.GETRANGEMIN(Type) = GenJournalTemplate.GETRANGEMAX(Type) THEN BEGIN
          GenJournalTemplate.VALIDATE(Type,GenJournalTemplate.GETRANGEMIN(Type));
          GenJournalTemplate.MODIFY(TRUE);
        END;
      END;

Example

The below example is extracted from the test automation codeunit 134014 to show one way of using this function.

      GenJournalTemplate.SETRANGE(Recurring,FALSE);
      GenJournalTemplate.SETRANGE(Type,GenJournalTemplate.Type::General);
      LibraryERM.FindGenJournalTemplate(GenJournalTemplate);
      LibraryERM.CreateGenJournalBatch(GenJournalBatch,GenJournalTemplate.Name);
Member of Lib.Library - ERM


FindGenPostingSetupWithDefVAT@174 Method

The procedure FindGenPostingSetupWithDefVAT is available in codeunit 131300.

Syntax

FindGenPostingSetupWithDefVAT@174(
    VAR GeneralPostingSetup@1000 : Record 252 GeneralPostingSetup //Reference parameter of type Record
);

Parameters

GeneralPostingSetup
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, General, Posting, Setup, Def, VAT.

For a clarification about how this function works, refer to the code listed below.

      FindGeneralPostingSetupInvtFull(GeneralPostingSetup);
      FindVATPostingSetupInvt(VATPostingSetup);
      GenBusPostingGroup.GET(GeneralPostingSetup."Gen. Bus. Posting Group");
      GenBusPostingGroup.VALIDATE("Def. VAT Bus. Posting Group",VATPostingSetup."VAT Bus. Posting Group");
      GenBusPostingGroup.MODIFY;
      GenProdPostingGroup.GET(GeneralPostingSetup."Gen. Prod. Posting Group");
      GenProdPostingGroup.VALIDATE("Def. VAT Prod. Posting Group",VATPostingSetup."VAT Prod. Posting Group");
      GenProdPostingGroup.MODIFY;

Example

The below example is extracted from the test automation codeunit 137063 to show one way of using this function.

      CapacityUnitOfMeasure.SETRANGE(Type,CapacityType);
      CapacityUnitOfMeasure.FINDFIRST;
      LibraryERM.FindGenPostingSetupWithDefVAT(GeneralPostingSetup);
      LibraryManufacturing.CreateWorkCenter(WorkCenter);
      WorkCenter.VALIDATE("Unit of Measure Code",CapacityUnitOfMeasure.Code);
      WorkCenter.VALIDATE("Shop Calendar Code",UpdateShopCalendarWorkingDays(StartTime,EndTime));
      WorkCenter.VALIDATE("Gen. Prod. Posting Group",GeneralPostingSetup."Gen. Prod. Posting Group");
      WorkCenter.MODIFY(TRUE);
      LibraryManufacturing.CalculateWorkCenterCalendar(WorkCenter,CALCDATE('<-2M>',WORKDATE),CALCDATE('<2M>',WORKDATE));
Member of Lib.Library - ERM


FindGenProductPostingGroup@70 Method

The procedure FindGenProductPostingGroup is available in codeunit 131300.

Syntax

FindGenProductPostingGroup@70(
    VAR GenProductPostingGroup@1000 : Record 251 GenProductPostingGroup //Reference parameter of type Record
);

Parameters

GenProductPostingGroup
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, General, Product, Posting, Group.

For a clarification about how this function works, refer to the code listed below.

      IF NOT GenProductPostingGroup.FINDFIRST THEN
        CreateGenProdPostingGroup(GenProductPostingGroup);

Example

The below example is extracted from the test automation codeunit 134091 to show one way of using this function.

      LibraryERM.FindGenProductPostingGroup(GenProductPostingGroup);
      VATPostingSetup.SETRANGE("Unrealized VAT Type",VATPostingSetup."Unrealized VAT Type"::" ");
      LibraryERM.FindVATPostingSetup(VATPostingSetup,VATPostingSetup."VAT Calculation Type"::"Normal VAT");
      GLAccount.GET(GLAccountNo);
      GLAccount.VALIDATE("Gen. Posting Type",GLAccount."Gen. Posting Type"::" ");
      GLAccount.VALIDATE("Gen. Prod. Posting Group",GenProductPostingGroup.Code);
      GLAccount.VALIDATE("VAT Prod. Posting Group",VATPostingSetup."VAT Prod. Posting Group");
      GLAccount.MODIFY(TRUE);
      EXIT(GLAccountNo);
Member of Lib.Library - ERM


FindGLAccount@59 Method

The procedure FindGLAccount is available in codeunit 131300.

Syntax

FindGLAccount@59(
    VAR GLAccount@1000 : Record 15 GLAccount //Reference parameter of type Record
);

Parameters

GLAccount
Reference parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Find, General Ledger, Account.

For a clarification about how this function works, refer to the code listed below.

      // Filter G/L Account so that errors are not generated due to mandatory fields.
      SetGLAccountDirectPostingFilter(GLAccount);
      SetGLAccountNotBlankGroupsFilter(GLAccount);
      GLAccount.FINDFIRST;
      EXIT(GLAccount."No.");

Example

The below example is extracted from the test automation codeunit 134014 to show one way of using this function.

      // Setup: Update General Ledger Setup and VAT Setup, Create and Post Sales Invoice.
      LibraryERM.FindGLAccount(GLAccount);
      UpdateUnrealizedVATSetup(VATPostingSetup,UnrealizedVATType,GLAccount."No.",GLAccount."No.");
      CreateSalesInvoice(SalesHeader,VATPostingSetup);
      PostedDocumentNo := LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      // Exercise: Make Payment against Invoice and Apply the Payment over Invoice.
      CreateAndPostJournalLine(
        GenJournalLine,GenJournalLine."Account Type"::Customer,SalesHeader."Sell-to Customer No.",
        -CalculateHalfSalesVATAmount(PostedDocumentNo),'');
      ApplyAndPostCustomerEntry(CustLedgerEntry."Document Type"::Payment,GenJournalLine."Document No.",PostedDocumentNo);
Member of Lib.Library - ERM


FindGLAccountDataSet@141 Method

The procedure FindGLAccountDataSet is available in codeunit 131300.

Syntax

FindGLAccountDataSet@141(
    VAR GLAccount@1000 : Record 15 GLAccount //Reference parameter of type Record
);

Parameters

GLAccount
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, General Ledger, Account, Data, Set.

For a clarification about how this function works, refer to the code listed below.

      SetGLAccountDirectPostingFilter(GLAccount);
      SetGLAccountNotBlankGroupsFilter(GLAccount);
      GLAccount.FINDSET;

Example

The below example is extracted from the test automation codeunit 134902 to show one way of using this function.

      // Test that system inserts the row in the next line while using the function InsertGLAccounts in Acc. Schedule Line.

      // Setup: Create Acc. Schedule name and Acc. Schedule line.
      Initialize;
      LibraryERM.CreateAccScheduleName(AccScheduleName);
      LibraryERM.FindGLAccountDataSet(GLAccount);
      LibraryVariableStorage.Enqueue(GLAccount."No.");
      LibraryERM.CreateAccScheduleLine(AccScheduleLine,AccScheduleName.Name);

      // Exercise: Insert second row in Acc. Schedule Line by using InsertGLAccounts function.
      AccSchedManagement.InsertGLAccounts(AccScheduleLine);

      // Verify that system insert the record in the next line.
      AccScheduleLine.SETRANGE("Schedule Name",AccScheduleName.Name);
      AccScheduleLine.FINDLAST;
      AccScheduleLine.TESTFIELD("Row No.",GLAccount."No.");
Member of Lib.Library - ERM


FindPaymentMethod@83 Method

The procedure FindPaymentMethod is available in codeunit 131300.

Syntax

FindPaymentMethod@83(
    VAR PaymentMethod@1000 : Record 289 PaymentMethod //Reference parameter of type Record
);

Parameters

PaymentMethod
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Payment, Method.

For a clarification about how this function works, refer to the code listed below.

      PaymentMethod.SETRANGE("Bal. Account No.",'');
      IF NOT PaymentMethod.FINDFIRST THEN
        CreatePaymentMethod(PaymentMethod);

Example

The below example is extracted from the test automation codeunit 134006 to show one way of using this function.

      // Check General Ledger, Customer Ledger and Detailed Customer ledger entries after posting Sales documents with Currency and Apply to Oldest Application Method.

      // Setup: Modify General Ledger setup for Appln. Rounding Precision and Create Customer with Currency and with Apply to Oldest Application Method, Create and post Sales Invoice with Random Quantity and Unit Price.
      Initialize;
      LibraryERM.SetApplnRoundingPrecision(LibraryRandom.RandDec(10,2));  // Taken Random value for Rounding Precision.
      LibraryERM.FindPaymentMethod(PaymentMethod);
      CreateAndModifyCustomer(Customer,Customer."Application Method"::"Apply to Oldest",PaymentMethod.Code);
      ModifyCurrency(Customer."Currency Code",LibraryRandom.RandDec(10,2));  // Taken Random value for Rounding Precision.
      LibraryInventory.CreateItem(Item);
      DocumentNo :=
        CreateAndPostSalesDocument(
          SalesLine,WORKDATE,Customer."No.",Item."No.",SalesHeader."Document Type"::Invoice,
          LibraryRandom.RandDec(10,2),LibraryRandom.RandDec(100,2));

      // Exercise: Create and post Sales Credit Memo.
      DocumentNo2 :=
        CreateAndPostSalesDocument(
          SalesLine,WORKDATE,Customer."No.",Item."No.",SalesHeader."Document Type"::"Credit Memo",
          SalesLine.Quantity,SalesLine."Unit Price");

      // Verify: Verify GL, Customer and Detailed Customer ledger entries.
      VerifyEntriesAfterPostingSalesDocument(CustLedgerEntry."Document Type"::"Credit Memo",DocumentNo,DocumentNo2);
Member of Lib.Library - ERM


FindPaymentTerms@84 Method

The procedure FindPaymentTerms is available in codeunit 131300.

Syntax

FindPaymentTerms@84(
    VAR PaymentTerms@1000 : Record 3 PaymentTerms //Reference parameter of type Record
);

Parameters

PaymentTerms
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Payment, Terms.

For a clarification about how this function works, refer to the code listed below.

      IF NOT PaymentTerms.FINDFIRST THEN
        CreatePaymentTerms(PaymentTerms);

Example

The below example is extracted from the test automation codeunit 134376 to show one way of using this function.

      CreateCustomer(Customer);
      LibraryERM.FindPaymentTerms(PaymentTerms);
      Customer."Payment Terms Code" := PaymentTerms.Code;
      Customer.MODIFY(TRUE);
Member of Lib.Library - ERM


FindPaymentTermsCode@48 Method

The procedure FindPaymentTermsCode is available in codeunit 131300.

Syntax

FindPaymentTermsCode@48(
      //param element not supplied
);

Return Value

Code[10]

Remarks

The relevant search keywords are: Find, Payment, Terms, Code.

For a clarification about how this function works, refer to the code listed below.

      EVALUATE(DateFormular_0D,'<0D>');

      IF PaymentTerms.FIELDACTIVE("Due Date Calculation") THEN // Field is disabled on IT build
        PaymentTerms.SETRANGE("Due Date Calculation",DateFormular_0D);
      IF NOT PaymentTerms.FINDFIRST THEN
        CreatePaymentTerms(PaymentTerms);
      EXIT(PaymentTerms.Code);

Example

There are no examples available.
Member of Lib.Library - ERM


FindPostCode@89 Method

The procedure FindPostCode is available in codeunit 131300.

Syntax

FindPostCode@89(
    VAR PostCode@1000 : Record 225 PostCode //Reference parameter of type Record
);

Parameters

PostCode
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Post, Code.

For a clarification about how this function works, refer to the code listed below.

      IF NOT PostCode.FINDFIRST THEN
        CreatePostCode(PostCode);

Example

The below example is extracted from the test automation codeunit 136101 to show one way of using this function.

      PostCode.SETFILTER(City,'<>%1','');
      PostCode.SETFILTER("Country/Region Code",'<>%1','');
      LibraryERM.FindPostCode(PostCode);
Member of Lib.Library - ERM


FindRecurringTemplateName@62 Method

The procedure FindRecurringTemplateName is available in codeunit 131300.

Syntax

FindRecurringTemplateName@62(
    VAR GenJournalTemplate@1000 : Record 80 GenJournalTemplate //Reference parameter of type Record
);

Parameters

GenJournalTemplate
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Recurring, Template, Name.

For a clarification about how this function works, refer to the code listed below.

      GenJournalTemplate.SETRANGE(Type,GenJournalTemplate.Type::General);
      GenJournalTemplate.SETRANGE(Recurring,TRUE);
      IF NOT GenJournalTemplate.FINDFIRST THEN
        CreateRecurringTemplateName(GenJournalTemplate);

Example

The below example is extracted from the test automation codeunit 134077 to show one way of using this function.

      // Verify Currency Factor and Amount(LCY) on Recurring General Journal.

      // Setup: Find Recurring Template,Create a Recurring Batch and create a Payment in Recurring General Journal taking Random value for Amount.
      Initialize;
      LibraryERM.FindRecurringTemplateName(GenJournalTemplate);
      LibraryERM.CreateRecurringBatchName(GenJournalBatch,GenJournalTemplate.Name);
      LibraryERM.CreateGeneralJnlLine(
        GenJournalLine,GenJournalTemplate.Name,GenJournalBatch.Name,GenJournalLine."Document Type"::Payment,
        GenJournalLine."Account Type"::Customer,CreateCustomer(CreateCurrency),LibraryRandom.RandDec(100,2));

      // Exercise: Calculate the Currency Factor for validation.
      CurrencyExchangeRate.GET(GenJournalLine."Currency Code",LibraryERM.FindEarliestDateForExhRate);
      CurrencyFactor := CurrencyExchangeRate."Exchange Rate Amount" / CurrencyExchangeRate."Relational Exch. Rate Amount";

      // Verify: Validate 'Currency factor' and 'Amount(LCY)' on Recurring General Journal.
      VerifyCurrencyFactorAmountLCY(GenJournalLine,CurrencyFactor);
Member of Lib.Library - ERM


FindUnrealVATPostingSetup@162 Method

The procedure FindUnrealVATPostingSetup is available in codeunit 131300.

Syntax

FindUnrealVATPostingSetup@162(
    VAR VATPostingSetup@1000 : Record 325 VATPostingSetup, //Reference parameter of type Record
    UnrealizedVATType@1002 : Option UnrealizedVATType //Input parameter of type Option
);

Parameters

VATPostingSetup
Reference parameter of type Record
UnrealizedVATType
Input parameter of type Option

Remarks

The relevant search keywords are: Find, Unreal, VAT, Posting, Setup.

For a clarification about how this function works, refer to the code listed below.

      VATPostingSetup.SETFILTER("VAT Bus. Posting Group",'<>%1','');
      VATPostingSetup.SETFILTER("VAT Prod. Posting Group",'<>%1','');
      VATPostingSetup.SETRANGE("VAT Calculation Type",VATPostingSetup."VAT Calculation Type"::"Normal VAT");
      VATPostingSetup.SETRANGE("Unrealized VAT Type",UnrealizedVATType);
      // VATPostingSetup.SETFILTER("VAT %",'>%1',0);
      IF NOT VATPostingSetup.FINDFIRST THEN BEGIN
        VATPostingSetup.SETRANGE("Unrealized VAT Type");
      VATPostingSetup.FINDFIRST;
        VATPostingSetup."Unrealized VAT Type" := UnrealizedVATType;
        IF VATPostingSetup."Sales VAT Unreal. Account" = '' THEN
          VATPostingSetup.VALIDATE("Sales VAT Unreal. Account",CreateGLAccountNo);
        IF VATPostingSetup."Purch. VAT Unreal. Account" = '' THEN
          VATPostingSetup.VALIDATE("Purch. VAT Unreal. Account",CreateGLAccountNo);
        VATPostingSetup.MODIFY(TRUE);
      END;

Example

The below example is extracted from the test automation codeunit 134008 to show one way of using this function.

      LibraryERM.FindUnrealVATPostingSetup(VATPostingSetup,VATPostingSetup."Unrealized VAT Type"::Percentage);
      EXIT(
        LibraryERM.CreateGLAccountWithVATPostingSetup(VATPostingSetup,GLAccount."Gen. Posting Type"::Sale));
Member of Lib.Library - ERM


FindVATBusinessPostingGroup@67 Method

The procedure FindVATBusinessPostingGroup is available in codeunit 131300.

Syntax

FindVATBusinessPostingGroup@67(
    VAR VATBusinessPostingGroup@1000 : Record 323 VATBusinessPostingGroup //Reference parameter of type Record
);

Parameters

VATBusinessPostingGroup
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, VAT, Business, Posting, Group.

For a clarification about how this function works, refer to the code listed below.

      IF NOT VATBusinessPostingGroup.FINDFIRST THEN
        CreateVATBusinessPostingGroup(VATBusinessPostingGroup);

Example

The below example is extracted from the test automation codeunit 134014 to show one way of using this function.

      LibraryERM.CreateVATProductPostingGroup(VATProductPostingGroup);
      LibraryERM.FindVATBusinessPostingGroup(VATBusinessPostingGroup);

      LibraryERM.CreateVATPostingSetup(VATPostingSetup,VATBusinessPostingGroup.Code,VATProductPostingGroup.Code);
      VATPostingSetup.VALIDATE("VAT Identifier",VATPostingSetup."VAT Prod. Posting Group");
      VATPostingSetup.VALIDATE("VAT %",LibraryRandom.RandDec(10,2));
      VATPostingSetup.VALIDATE("VAT Calculation Type",VATPostingSetup."VAT Calculation Type"::"Normal VAT");
      VATPostingSetup.VALIDATE("Unrealized VAT Type",VATPostingSetup."Unrealized VAT Type"::First);
      VATPostingSetup.VALIDATE("Purchase VAT Account",LibraryERM.CreateGLAccountNo);
      VATPostingSetup.VALIDATE("Purch. VAT Unreal. Account",LibraryERM.CreateGLAccountNo);
      VATPostingSetup.VALIDATE("Sales VAT Account",LibraryERM.CreateGLAccountNo);
      VATPostingSetup.VALIDATE("Sales VAT Unreal. Account",LibraryERM.CreateGLAccountNo);
      VATPostingSetup.MODIFY(TRUE);
Member of Lib.Library - ERM


FindVATPostingSetup@19 Method

The procedure FindVATPostingSetup is available in codeunit 131300.

Syntax

FindVATPostingSetup@19(
    VAR VATPostingSetup@1000 : Record 325 VATPostingSetup, //Reference parameter of type Record
    VATCalculationType@1001 : Option VATCalculationType //Input parameter of type Option
);

Parameters

VATPostingSetup
Reference parameter of type Record
VATCalculationType
Input parameter of type Option

Remarks

The relevant search keywords are: Find, VAT, Posting, Setup.

For a clarification about how this function works, refer to the code listed below.

      VATPostingSetup.SETFILTER("VAT Bus. Posting Group",'<>%1','');
      VATPostingSetup.SETFILTER("VAT Prod. Posting Group",'<>%1','');
      VATPostingSetup.SETRANGE("VAT Calculation Type",VATCalculationType);
      // VATPostingSetup.SETFILTER("VAT %",'>%1',0);
      IF NOT VATPostingSetup.FINDFIRST THEN
        CreateVATPostingSetupWithAccounts(VATPostingSetup,VATCalculationType,LibraryRandom.RandDecInDecimalRange(10,25,0));

Example

The below example is extracted from the test automation codeunit 134006 to show one way of using this function.

      LibraryERM.FindGeneralPostingSetupInvtFull(GeneralPostingSetup);
      LibraryERM.FindVATPostingSetup(VATPostingSetup,VATPostingSetup."VAT Calculation Type"::"Reverse Charge VAT");
      VATPostingSetup.VALIDATE("Adjust for Payment Discount",TRUE);
      VATPostingSetup.MODIFY(TRUE);
      VendNo :=
        CreateCustomerWithPostingSetup(GeneralPostingSetup."Gen. Bus. Posting Group",VATPostingSetup."VAT Bus. Posting Group");
      ItemNo :=
        CreateItemWithPostingSetup(GeneralPostingSetup."Gen. Prod. Posting Group",VATPostingSetup."VAT Prod. Posting Group");
      LibrarySales.CreateSalesHeader(SalesHeader,SalesHeader."Document Type"::Invoice,VendNo);
      LibrarySales.CreateSalesLine(SalesLine,SalesHeader,SalesLine.Type::Item,ItemNo,LibraryRandom.RandInt(100));
      SalesLine.VALIDATE("Unit Price",LibraryRandom.RandDec(100,2));
      SalesLine.MODIFY(TRUE);
      EXIT(LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE));
Member of Lib.Library - ERM


FindVATPostingSetupInvt@171 Method

The procedure FindVATPostingSetupInvt is available in codeunit 131300.

Syntax

FindVATPostingSetupInvt@171(
    VAR VATPostingSetup@1001 : Record 325 VATPostingSetup //Reference parameter of type Record
);

Parameters

VATPostingSetup
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, VAT, Posting, Setup, Invt.

For a clarification about how this function works, refer to the code listed below.

      VATPostingSetup.SETFILTER("VAT Prod. Posting Group",'<>%1','');
      // VATPostingSetup.SETFILTER("VAT %",'<>%1',0);
      VATPostingSetup.SETRANGE("VAT Calculation Type",VATPostingSetup."VAT Calculation Type"::"Normal VAT");
      VATPostingSetup.SETFILTER("Sales VAT Account",'<>%1','');
      VATPostingSetup.SETFILTER("Purchase VAT Account",'<>%1','');
      IF NOT VATPostingSetup.FINDFIRST THEN
        CreateVATPostingSetupWithAccounts(VATPostingSetup,
          VATPostingSetup."VAT Calculation Type"::"Normal VAT",LibraryRandom.RandDecInDecimalRange(10,25,0));

Example

There are no examples available.
Member of Lib.Library - ERM


FindVATProductPostingGroup@74 Method

The procedure FindVATProductPostingGroup is available in codeunit 131300.

Syntax

FindVATProductPostingGroup@74(
    VAR VATProductPostingGroup@1000 : Record 324 VATProductPostingGroup //Reference parameter of type Record
);

Parameters

VATProductPostingGroup
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, VAT, Product, Posting, Group.

For a clarification about how this function works, refer to the code listed below.

      IF NOT VATProductPostingGroup.FINDFIRST THEN
        CreateVATProductPostingGroup(VATProductPostingGroup);

Example

The below example is extracted from the test automation codeunit 134102 to show one way of using this function.

      // To set Gen. Product Posting Group with Non-blank Def. VAT Prod. Posting Group on G/L Account.
      GenProductPostingGroup.SETFILTER("Def. VAT Prod. Posting Group",'<>%1','');
      LibraryERM.FindGenProductPostingGroup(GenProductPostingGroup);
      GeneralPostingSetup.SETRANGE("Gen. Prod. Posting Group",GenProductPostingGroup.Code);
      LibraryERM.FindGeneralPostingSetup(GeneralPostingSetup);

      VATProductPostingGroup.SETRANGE(Code,GenProductPostingGroup."Def. VAT Prod. Posting Group");
      LibraryERM.FindVATProductPostingGroup(VATProductPostingGroup);
      VATPostingSetup.SETRANGE("VAT Prod. Posting Group",VATProductPostingGroup.Code);
      LibraryERM.FindVATPostingSetup(VATPostingSetup,VATPostingSetup."VAT Calculation Type"::"Normal VAT");
Member of Lib.Library - ERM


FindVATSetupForCust@1500016 Method

The procedure FindVATSetupForCust is available in codeunit 131300.

Syntax

FindVATSetupForCust@1500016(
    CustCode@1500000 : Code[20] CustCode //Input parameter of type Code
);

Parameters

CustCode
Input parameter of type Code

Remarks

The relevant search keywords are: Find, VAT, Setup, For, Customer.

For a clarification about how this function works, refer to the code listed below.

      IF NOT Cust.GET(CustCode) THEN
        EXIT;
      IF CustPostGroup.GET(Cust."Customer Posting Group") THEN BEGIN
        CreateVATSetupForGL(Cust."VAT Bus. Posting Group",CustPostGroup."Additional Fee Account");
        CreateVATSetupForGL(Cust."VAT Bus. Posting Group",CustPostGroup."Interest Account");
      END;

Example

There are no examples available.
Member of Lib.Library - ERM


FindVendorLedgerEntry@24 Method

The procedure FindVendorLedgerEntry is available in codeunit 131300.

Syntax

FindVendorLedgerEntry@24(
    VAR VendorLedgerEntry@1002 : Record 25 VendorLedgerEntry, //Reference parameter of type Record
    DocumentType@1001 : Option DocumentType, //Input parameter of type Option
    DocumentNo@1000 : Code[20] DocumentNo //Input parameter of type Code
);

Parameters

VendorLedgerEntry
Reference parameter of type Record
DocumentType
Input parameter of type Option
DocumentNo
Input parameter of type Code

Remarks

The relevant search keywords are: Find, Vendor, Ledger, Entry.

For a clarification about how this function works, refer to the code listed below.

      // Finds the matching Vendor Ledger Entry from a General Journal Line.
      WITH VendorLedgerEntry DO BEGIN
        SETRANGE("Document Type",DocumentType);
        SETRANGE("Document No.",DocumentNo);
        FINDFIRST;
      END;

Example

The below example is extracted from the test automation codeunit 134001 to show one way of using this function.

      LibraryERM.FindVendorLedgerEntry(ApplyingVendorLedgerEntry,DocumentType,DocumentNo);
      ApplyingVendorLedgerEntry.CALCFIELDS("Remaining Amount");
      LibraryERM.SetApplyVendorEntry(ApplyingVendorLedgerEntry,ApplyingVendorLedgerEntry."Remaining Amount");

      // Find Posted Vendor Ledger Entries.
      VendorLedgerEntry.SETRANGE("Vendor No.",ApplyingVendorLedgerEntry."Vendor No.");
      VendorLedgerEntry.SETRANGE("Applying Entry",FALSE);
      VendorLedgerEntry.FINDSET;
      REPEAT
        VendorLedgerEntry.CALCFIELDS("Remaining Amount");
        VendorLedgerEntry.VALIDATE("Amount to Apply",VendorLedgerEntry."Remaining Amount");
        VendorLedgerEntry.MODIFY(TRUE);
      UNTIL VendorLedgerEntry.NEXT = 0;

      // Set Applies-to ID.
      LibraryERM.SetAppliestoIdVendor(VendorLedgerEntry);
Member of Lib.Library - ERM


FindZeroVATPostingSetup@158 Method

The procedure FindZeroVATPostingSetup is available in codeunit 131300.

Syntax

FindZeroVATPostingSetup@158(
    VAR VATPostingSetup@1001 : Record 325 VATPostingSetup, //Reference parameter of type Record
    VATCalculationType@1000 : Option VATCalculationType //Input parameter of type Option
);

Parameters

VATPostingSetup
Reference parameter of type Record
VATCalculationType
Input parameter of type Option

Remarks

The relevant search keywords are: Find, Zero, VAT, Posting, Setup.

For a clarification about how this function works, refer to the code listed below.

      VATPostingSetup.SETFILTER("VAT Bus. Posting Group",'<>%1','');
      VATPostingSetup.SETFILTER("VAT Prod. Posting Group",'<>%1','');
      VATPostingSetup.SETRANGE("VAT Calculation Type",VATCalculationType);
      VATPostingSetup.SETRANGE("VAT %",0);
      IF NOT VATPostingSetup.FINDFIRST THEN
        CreateVATPostingSetupWithAccounts(VATPostingSetup,VATCalculationType,0);

Example

The below example is extracted from the test automation codeunit 134007 to show one way of using this function.

      LibraryERM.FindZeroVATPostingSetup(VATPostingSetup,VATPostingSetup."VAT Calculation Type"::"Normal VAT");
      EXIT(LibraryERM.CreateGLAccountWithVATPostingSetup(VATPostingSetup,GLAccount."Gen. Posting Type"::Purchase));
Member of Lib.Library - ERM


GenerateVATRegistrationNo@131 Method

The procedure GenerateVATRegistrationNo is available in codeunit 131300.

Syntax

GenerateVATRegistrationNo@131(
    CountryRegionCode@1004 : Code[10] CountryRegionCode //Input parameter of type Code
);

Parameters

CountryRegionCode
Input parameter of type Code

Return Value

Text[20]

Remarks

The relevant search keywords are: Generate, VAT, Registration, No.

For a clarification about how this function works, refer to the code listed below.

      // Generate VAT Registration No. as per VAT Registration No. format.
      VATRegistrationNoFormat.SETRANGE("Country/Region Code",CountryRegionCode);
      IF VATRegistrationNoFormat.FINDFIRST THEN
        FOR i := 1 TO STRLEN(VATRegistrationNoFormat.Format) DO BEGIN
          FormatType := COPYSTR(VATRegistrationNoFormat.Format,i,1);
          CASE FormatType OF
            'A'..'Z','0'..'9','.','-':
              VATRegNo := INSSTR(VATRegNo,FormatType,i);
            '#':
              VATRegNo := INSSTR(VATRegNo,FORMAT(LibraryRandom.RandInt(9)),i);
            '@':
              BEGIN
                RandomCharacter := LibraryRandom.RandInt(25) + 65;  // For the generation of random character.
                VATRegNo := INSSTR(VATRegNo,FORMAT(RandomCharacter),i);  // Used as constant as VAT Registration validation is not important.
              END
            ELSE
              VATRegNo := INSSTR(VATRegNo,FORMAT(LibraryRandom.RandInt(9)),i);
        END;
        END
      ELSE
        VATRegNo :=
          COPYSTR(LibraryUtility.GenerateRandomCode(VATRegistrationNoFormat.FIELDNO(Format),DATABASE::"VAT Registration No. Format"),
            1,LibraryUtility.GetFieldLength(DATABASE::"VAT Registration No. Format",VATRegistrationNoFormat.FIELDNO(Format)));

Example

The below example is extracted from the test automation codeunit 134992 to show one way of using this function.

      LibraryERM.CreateCountryRegion(CountryRegion);
      CountryRegion.VALIDATE("EU Country/Region Code",CountryRegion.Code);
      CountryRegion.MODIFY(TRUE);
      LibrarySales.CreateCustomer(Customer);
      Customer.VALIDATE("Country/Region Code",CountryRegion.Code);
      Customer.VALIDATE("VAT Registration No.",LibraryERM.GenerateVATRegistrationNo(CountryRegion.Code));
      Customer.MODIFY(TRUE);
Member of Lib.Library - ERM


GetAddReportingCurrency@179 Method

The procedure GetAddReportingCurrency is available in codeunit 131300.

Syntax

GetAddReportingCurrency@179(
      //param element not supplied
);

Return Value

Code[10]

Remarks

The relevant search keywords are: Get, Add, Reporting, Currency.

For a clarification about how this function works, refer to the code listed below.

      GeneralLedgerSetup.GET;
      EXIT(GeneralLedgerSetup."Additional Reporting Currency");

Example

There are no examples available.
Member of Lib.Library - ERM


GetAllowPostingFrom@196 Method

The procedure GetAllowPostingFrom is available in codeunit 131300.

Syntax

GetAllowPostingFrom@196(
      //param element not supplied
);

Return Value

Date

Remarks

The relevant search keywords are: Get, Allow, Posting, From.

For a clarification about how this function works, refer to the code listed below.

      GeneralLedgerSetup.GET;
      EXIT(GeneralLedgerSetup."Allow Posting From");

Example

There are no examples available.
Member of Lib.Library - ERM


GetAllowPostingTo@198 Method

The procedure GetAllowPostingTo is available in codeunit 131300.

Syntax

GetAllowPostingTo@198(
      //param element not supplied
);

Return Value

Date

Remarks

The relevant search keywords are: Get, Allow, Posting, To.

For a clarification about how this function works, refer to the code listed below.

      GeneralLedgerSetup.GET;
      EXIT(GeneralLedgerSetup."Allow Posting To");

Example

There are no examples available.
Member of Lib.Library - ERM


GetAmountRoundingPrecision@104 Method

The procedure GetAmountRoundingPrecision is available in codeunit 131300.

Syntax

GetAmountRoundingPrecision@104(
      //param element not supplied
);

Return Value

Decimal

Remarks

The relevant search keywords are: Get, Amount, Rounding, Precision.

For a clarification about how this function works, refer to the code listed below.

      GeneralLedgerSetup.GET;
      EXIT(GeneralLedgerSetup."Amount Rounding Precision");

Example

The below example is extracted from the test automation codeunit 134025 to show one way of using this function.

      // [FEATURE] [Partial Payment]
      // [SCENARIO 363444] Unrealized VAT Entries are filled with percentage amount values in case of partial applying Sales Invoice with negative line

      // [GIVEN] Enable GLSetup."Unealized VAT".  Config "VAT Posting Setup"."Unrealized VAT Type" = Percentage.
      EnableUnrealizedSetup(VATPostingSetup,VATPostingSetup."Unrealized VAT Type"::Percentage,FALSE,FALSE);
      AmountRoundingPrecision := LibraryERM.GetAmountRoundingPrecision;

      // [GIVEN] Create and post Sales Invoice with two lines:
      // [GIVEN] Positive Line: Quantity = 1,"Unit Price" = 1000, VAT Amount = 200
      // [GIVEN] Negative Line: Quantity = -1,"Unit Price" = 800, VAT Amount = 160
      DocumentNo :=
        CreatePostSalesInvoiceWithNegativeLine(SalesHeader,VATPostingSetup,VATBaseAmount,VATAmount,AmountRoundingPrecision);

      // [GIVEN] Post customer partial payment with amount = 30% of Invoice
      DocAmount := VATBaseAmount[1] + VATAmount[1] - (VATBaseAmount[2] + VATAmount[2]);
      Fraction := LibraryRandom.RandIntInRange(3,5);
      AmountToApply := ROUND(DocAmount / Fraction,AmountRoundingPrecision);
      CreateAndPostPaymentJournaLine(GenJournalLine,SalesHeader."Bill-to Customer No.",'',-AmountToApply);

      // [WHEN] Apply payment to the invoice
      ApplyAndPostCustomerEntry(
        DocumentNo,GenJournalLine."Document No.",GenJournalLine."Document Type"::Payment,
        SalesHeader."Document Type");

      // [THEN] Positive realized VAT Entry has Base = 240, Amount = 48  (30% of 160)
      VerifyPositiveVATEntry(
        GenJournalLine."Document No.",ROUND(VATBaseAmount[2] / Fraction),ROUND(VATAmount[2] / Fraction));

      // [THEN] Negative realized VAT Entry has Base = -300, Amount = -60 (30% of 200)
      VerifyNegativeVATEntry(
        GenJournalLine."Document No.",-ROUND(VATBaseAmount[1] / Fraction),-ROUND(VATAmount[1] / Fraction));
Member of Lib.Library - ERM


GetCombinedPostedDeferralLines@206 Method

The procedure GetCombinedPostedDeferralLines is available in codeunit 131300.

Syntax

GetCombinedPostedDeferralLines@206(
    VAR TempPostedDeferralLine@1000 : TEMPORARY Record 1705 TempPostedDeferralLine, //Reference Temporary parameter of type Record
    DocNo@1002 : Code[20] DocNo //Input parameter of type Code
);

Parameters

TempPostedDeferralLine
Reference Temporary parameter of type Record
DocNo
Input parameter of type Code

Remarks

The relevant search keywords are: Get, Combined, Posted, Deferral, Lines.

For a clarification about how this function works, refer to the code listed below.

      PostedDeferralLine.SETRANGE("Document No.",DocNo);
      PostedDeferralLine.FINDSET;
      REPEAT
        TempPostedDeferralLine.SETRANGE("Document No.",DocNo);
        TempPostedDeferralLine.SETRANGE("Posting Date",PostedDeferralLine."Posting Date");
        IF NOT TempPostedDeferralLine.FINDFIRST THEN BEGIN
          TempPostedDeferralLine.INIT;
          TempPostedDeferralLine."Document No." := DocNo;
          TempPostedDeferralLine."Posting Date" := PostedDeferralLine."Posting Date";
          TempPostedDeferralLine.INSERT;
        END;
        TempPostedDeferralLine.Amount += PostedDeferralLine.Amount;
        TempPostedDeferralLine.MODIFY;
      UNTIL PostedDeferralLine.NEXT = 0;
      TempPostedDeferralLine.SETRANGE("Document No.");
      TempPostedDeferralLine.SETRANGE("Posting Date");

Example

The below example is extracted from the test automation codeunit 134804 to show one way of using this function.

      FilterGLEntry(GLEntry,DocNo,AccNo,GLEntry."Gen. Posting Type"::" ");
      LibraryERM.GetCombinedPostedDeferralLines(TempPostedDeferralLine,DocNo);
      TempPostedDeferralLine.FINDSET;
      REPEAT
        GLEntry.SETFILTER(Amount,'<%1',0);
        GLEntry.SETRANGE("Posting Date",TempPostedDeferralLine."Posting Date");
        GLEntry.FINDFIRST;
        GLEntry.TESTFIELD(Amount,-TempPostedDeferralLine.Amount);
      UNTIL TempPostedDeferralLine.NEXT = 0;
Member of Lib.Library - ERM


GetCountryIntrastatCode@225 Method

The procedure GetCountryIntrastatCode is available in codeunit 131300.

Syntax

GetCountryIntrastatCode@225(
    CountryRegionCode@1000 : Code[10] CountryRegionCode //Input parameter of type Code
);

Parameters

CountryRegionCode
Input parameter of type Code

Return Value

Code[10]

Remarks

The relevant search keywords are: Get, Country, Intrastat, Code.

For a clarification about how this function works, refer to the code listed below.

      CountryRegion.GET(CountryRegionCode);
      EXIT(CountryRegion."Intrastat Code");

Example

There are no examples available.
Member of Lib.Library - ERM


GetCurrencyAmountRoundingPrecision@241 Method

The procedure GetCurrencyAmountRoundingPrecision is available in codeunit 131300.

Syntax

GetCurrencyAmountRoundingPrecision@241(
    CurrencyCode@1000 : Code[10] CurrencyCode //Input parameter of type Code
);

Parameters

CurrencyCode
Input parameter of type Code

Return Value

Decimal

Remarks

The relevant search keywords are: Get, Currency, Amount, Rounding, Precision.

For a clarification about how this function works, refer to the code listed below.

      Currency.Initialize(CurrencyCode);
      EXIT(Currency."Amount Rounding Precision");

Example

The below example is extracted from the test automation codeunit 134100 to show one way of using this function.

      WITH SalesLine DO BEGIN
        FIND;
        LineAmount :=
          ROUND("Quantity Invoiced" * "Unit Price",LibraryERM.GetCurrencyAmountRoundingPrecision("Currency Code"));
        PrepaymentAmount :=
          ROUND(LineAmount * "Prepayment %" / 100,LibraryERM.GetCurrencyAmountRoundingPrecision("Currency Code"));
        PrepaymentAmountInclVAT := PrepaymentAmount;
        IF NOT PricesIncludingVAT THEN
          PrepaymentAmountInclVAT :=
            ROUND(PrepaymentAmount * (100 + "VAT %") / 100,LibraryERM.GetCurrencyAmountRoundingPrecision("Currency Code"));

        Assert.AreEqual(
          PrepaymentAmountInclVAT,
          "Prepmt. Amt. Incl. VAT",
          STRSUBSTNO(AmountErr,FIELDCAPTION("Prepmt. Amt. Incl. VAT"),PrepaymentAmountInclVAT,TABLECAPTION));
      END;
Member of Lib.Library - ERM


GetCurrencyCode@195 Method

The procedure GetCurrencyCode is available in codeunit 131300.

Syntax

GetCurrencyCode@195(
    Code@1000 : Code[10] Code //Input parameter of type Code
);

Parameters

Code
Input parameter of type Code

Return Value

Code[10]

Remarks

The relevant search keywords are: Get, Currency, Code.

For a clarification about how this function works, refer to the code listed below.

      GeneralLedgerSetup.GET;
      EXIT(GeneralLedgerSetup.GetCurrencyCode(Code));

Example

The below example is extracted from the test automation codeunit 134403 to show one way of using this function.

      IF Initialized THEN
        EXIT;

      EURCode := LibraryERM.GetCurrencyCode('EUR');
      DefaultLineAmount := LibraryRandom.RandDec(1000,2);

      LibraryERM.CreateGenJournalTemplate(GenJournalTemplate);
      LibraryERM.CreateGenJournalBatch(GenJournalBatch,GenJournalTemplate.Name);
      LibraryERM.CreateBankAccount(BankAccount);
      IF EURCode = 'EUR' THEN
        LibraryERM.CreateExchangeRate(EURCode,CALCDATE('<-1Y>',TODAY),LibraryRandom.RandDec(100,2),
          LibraryRandom.RandDec(100,2));

      Vendor.INIT;
      Vendor."No." := 'TEST-SEPA';
      IF Vendor.FIND THEN
        Vendor.DELETE;
      Vendor.Name := 'Microsoft';
      Vendor.Address := 'Microsoft Way 1';
      Vendor.City := 'MS Town';
      Vendor."Post Code" := 'AL-1234';
      LibraryERM.FindPaymentTerms(PaymentTerms);
      Vendor.VALIDATE("Payment Terms Code",PaymentTerms.Code);
      LibraryERM.FindPaymentMethod(PaymentMethod);
      Vendor.VALIDATE("Payment Method Code",PaymentMethod.Code);
      Vendor.VALIDATE("Vendor Posting Group",LibraryPurchase.FindVendorPostingGroup);
      Vendor.INSERT;

      LibraryPurchase.CreateVendorBankAccount(VendorBankAccount,Vendor."No.");
      VendorBankAccount.Name := 'Alban Bank No. 1';
      VendorBankAccount."Bank Account No." := '1234567890';
      VendorBankAccount.IBAN := 'AL47 2121 1009 0000 0002 3569 8741';
      VendorBankAccount.MODIFY;

      LibrarySales.CreateCustomer(Customer);
      LibrarySales.CreateCustomerBankAccount(CustomerBankAccount,Customer."No.");

      NoSeries.FINDFIRST;
      CreateBankExpSetup;
      BankAccount."Bank Account No." := '1234 12345678';
      BankAccount.IBAN := 'AL47 2121 1009 0000 0002 3569 8741';
      BankAccount."Credit Transfer Msg. Nos." := NoSeries.Code;
      BankAccount."Payment Export Format" := BankExportImportSetup.Code;
      BankAccount.MODIFY;
      Initialized := TRUE;
Member of Lib.Library - ERM


GetDiscountPaymentTerm@26 Method

The procedure GetDiscountPaymentTerm is available in codeunit 131300.

Syntax

GetDiscountPaymentTerm@26(
    VAR PaymentTerms@1000 : Record 3 PaymentTerms //Reference parameter of type Record
);

Parameters

PaymentTerms
Reference parameter of type Record

Remarks

The relevant search keywords are: Get, Discount, Payment, Term.

For a clarification about how this function works, refer to the code listed below.

      PaymentTerms.SETFILTER("Due Date Calculation",'<>''''');
      PaymentTerms.SETFILTER("Discount Date Calculation",'<>''''');
      PaymentTerms.SETFILTER("Discount %",'>%1',0);
      IF NOT PaymentTerms.FINDFIRST THEN
        CreatePaymentTermsDiscount(PaymentTerms,FALSE);

Example

The below example is extracted from the test automation codeunit 134000 to show one way of using this function.

      // Calculate Due Date and Discount Percentage.
      LibraryERM.GetDiscountPaymentTerm(PaymentTerms);
      DueDate := CALCDATE(PaymentTerms."Discount Date Calculation",WORKDATE);
      PaymentDiscountPercent := PaymentTerms."Discount %";
Member of Lib.Library - ERM


GetGlobalDimensionCode@92 Method

The procedure GetGlobalDimensionCode is available in codeunit 131300.

Syntax

GetGlobalDimensionCode@92(
    DimNo@1000 : Integer DimNo //Input parameter of type Integer
);

Parameters

DimNo
Input parameter of type Integer

Return Value

Code[20]

Remarks

The relevant search keywords are: Get, Global, Dimension, Code.

For a clarification about how this function works, refer to the code listed below.

      GeneralLedgerSetup.GET;
      CASE DimNo OF
        1:
          EXIT(GeneralLedgerSetup."Global Dimension 1 Code");
        2:
          EXIT(GeneralLedgerSetup."Global Dimension 2 Code");
      END;

Example

The below example is extracted from the test automation codeunit 134006 to show one way of using this function.

      LibraryERM.CreateGeneralJnlLine(
        GenJournalLine,GenJournalBatch."Journal Template Name",GenJournalBatch.Name,DocumentType,
        GenJournalLine."Account Type"::Customer,CustomerNo,Amount);
      LibraryDimension.CreateDimensionValue(DimVal,LibraryERM.GetGlobalDimensionCode(1));
      WITH GenJournalLine DO BEGIN
        VALIDATE("Applies-to ID","Document No.");
        VALIDATE("Shortcut Dimension 1 Code",DimVal.Code);
        MODIFY(TRUE);
        DimSetID := "Dimension Set ID";
      END;
Member of Lib.Library - ERM


GetInvoiceRoundingPrecisionLCY@101 Method

The procedure GetInvoiceRoundingPrecisionLCY is available in codeunit 131300.

Syntax

GetInvoiceRoundingPrecisionLCY@101(
      //param element not supplied
);

Return Value

Decimal

Remarks

The relevant search keywords are: Get, Invoice, Rounding, Precision, LCY.

For a clarification about how this function works, refer to the code listed below.

      GeneralLedgerSetup.GET;
      EXIT(GeneralLedgerSetup."Inv. Rounding Precision (LCY)");

Example

There are no examples available.
Member of Lib.Library - ERM


GetLCYCode@182 Method

The procedure GetLCYCode is available in codeunit 131300.

Syntax

GetLCYCode@182(
      //param element not supplied
);

Return Value

Code[10]

Remarks

The relevant search keywords are: Get, LCY, Code.

For a clarification about how this function works, refer to the code listed below.

      GeneralLedgerSetup.GET;
      EXIT(GeneralLedgerSetup."LCY Code");

Example

The below example is extracted from the test automation codeunit 134264 to show one way of using this function.

      Amount := LibraryRandom.RandDec(1000,2);
      PostingDate := WORKDATE + LibraryRandom.RandInt(10);

      BankAccNo :=
        LibraryUtility.GenerateRandomCode(
          BankAccReconLine.FIELDNO("Bank Account No."),DATABASE::"Bank Acc. Reconciliation Line");

      WITH BankAcc DO BEGIN
        INIT;
        "No." := BankAccNo;
        "Currency Code" := LibraryERM.GetLCYCode;
        INSERT;
      END;

      StatementNo :=
        LibraryUtility.GenerateRandomCode(
          BankAccReconLine.FIELDNO("Statement No."),DATABASE::"Bank Acc. Reconciliation Line");
Member of Lib.Library - ERM


GetPaymentTermsDiscountPct@200 Method

The procedure GetPaymentTermsDiscountPct is available in codeunit 131300.

Syntax

GetPaymentTermsDiscountPct@200(
    PaymentTerms@1000 : Record 3 PaymentTerms //Input parameter of type Record
);

Parameters

PaymentTerms
Input parameter of type Record

Return Value

Decimal

Remarks

The relevant search keywords are: Get, Payment, Terms, Discount, Percent.

For a clarification about how this function works, refer to the code listed below.

      EXIT(PaymentTerms."Discount %");

Example

The below example is extracted from the test automation codeunit 134914 to show one way of using this function.

      FOR i := 1 TO ARRAYLEN(VATPostingSetup) DO BEGIN
        LibraryERM.CreatePaymentTermsDiscount(PaymentTerms,FALSE);
        CreatePostPurchaseInvoice(GenJournalLine,VATPostingSetup[i],VendorNo,PaymentTerms.Code);
        InvoiceNo[i] := GenJournalLine."Document No.";
        InvoiceAmount[i] := GenJournalLine.Amount;
        DiscountAmount[i] := ROUND(InvoiceAmount[i] * LibraryPmtDiscSetup.GetPaymentTermsDiscountPct(PaymentTerms.Code) / 100);
      END;
Member of Lib.Library - ERM


GetShortcutDimensionCode@183 Method

The procedure GetShortcutDimensionCode is available in codeunit 131300.

Syntax

GetShortcutDimensionCode@183(
    DimNo@1000 : Integer DimNo //Input parameter of type Integer
);

Parameters

DimNo
Input parameter of type Integer

Return Value

Code[20]

Remarks

The relevant search keywords are: Get, Shortcut, Dimension, Code.

For a clarification about how this function works, refer to the code listed below.

      GeneralLedgerSetup.GET;
      CASE DimNo OF
        1:
          EXIT(GeneralLedgerSetup."Shortcut Dimension 1 Code");
        2:
          EXIT(GeneralLedgerSetup."Shortcut Dimension 2 Code");
        3:
          EXIT(GeneralLedgerSetup."Shortcut Dimension 3 Code");
        4:
          EXIT(GeneralLedgerSetup."Shortcut Dimension 4 Code");
        5:
          EXIT(GeneralLedgerSetup."Shortcut Dimension 5 Code");
        6:
          EXIT(GeneralLedgerSetup."Shortcut Dimension 6 Code");
        7:
          EXIT(GeneralLedgerSetup."Shortcut Dimension 7 Code");
        8:
          EXIT(GeneralLedgerSetup."Shortcut Dimension 8 Code");
      END;

Example

The below example is extracted from the test automation codeunit 134141 to show one way of using this function.

      // [FEATURE] [Dimension] [UT]
      // [SCENARIO 379516] Payment Reconciliation Journal correctly updates shortcut dimensions
      Initialize;
      UpdateGeneralShortcutDimensionSetup;

      // [GIVEN] Dimension 'D' with value 'V'. GLSetup."Shortcut Dimension 1 Code" = 'D'.
      // [GIVEN] Payment Reconciliation Journal Line.
      // [WHEN] Update journal line "Shortcut Dimension 1 Code" = 'V'
      BankAccReconciliationLine.INIT;
      FOR i := 1 TO ARRAYLEN(DimensionValue) DO BEGIN
        LibraryDimension.FindDimensionValue(DimensionValue[i],LibraryERM.GetShortcutDimensionCode(i));
        BankAccReconciliationLine.ValidateShortcutDimCode(i,DimensionValue[i].Code);
      END;

      // [THEN] Journal line Dimension Set Entry ("Dimension Set ID") contains Dimension 'D' with value 'V' record.
      FOR i := 1 TO ARRAYLEN(DimensionValue) DO
        Assert.AreEqual(
          DimensionValue[i].Code,
          GetDimensionValueCodeFromSetEntry(BankAccReconciliationLine."Dimension Set ID",DimensionValue[i]."Dimension Code"),
          DimensionValue[i].FIELDCAPTION(Code));
Member of Lib.Library - ERM


GetUnitAmountRoundingPrecision@194 Method

The procedure GetUnitAmountRoundingPrecision is available in codeunit 131300.

Syntax

GetUnitAmountRoundingPrecision@194(
      //param element not supplied
);

Return Value

Decimal

Remarks

The relevant search keywords are: Get, Unit, Amount, Rounding, Precision.

For a clarification about how this function works, refer to the code listed below.

      GeneralLedgerSetup.GET;
      EXIT(GeneralLedgerSetup."Unit-Amount Rounding Precision");

Example

The below example is extracted from the test automation codeunit 136305 to show one way of using this function.

      // Test Job Unit Cost, Job Unit Price on Job G/L Journal Line when Unit Cost Factor is defined on Job Card.

      // 1. Setup: Create Job with Job Task and Job G/L Account Price.
      Initialize;
      CreateJobJournalBatch(GenJournalBatch);
      CreateJobWithJobTask(JobTask);
      LibraryJob.CreateJobGLAccountPrice(
        JobGLAccountPrice,JobTask."Job No.",JobTask."Job Task No.",LibraryERM.CreateGLAccountNo,'');
      UpdateUnitCostFactorOnJobGLAccountPrice(JobGLAccountPrice);

      // 2. Exercise: Create Job G/L Journal Line, Taking rounding precision as used in General Journal Line Table rounding precision.
      CreateJobGLJournalLine(
        GenJournalLine,GenJournalBatch,GenJournalLine."Bal. Account Type"::"G/L Account",JobGLAccountPrice."G/L Account No.",
        LibraryERM.CreateGLAccountNo,JobGLAccountPrice."Job No.",JobGLAccountPrice."Job Task No.",'');  // Passing Blank for Currency Code.
      JobUnitCost := GenJournalLine.Amount / GenJournalLine."Job Quantity";
      JobUnitPrice :=
        ROUND(
          (GenJournalLine.Amount / GenJournalLine."Job Quantity") * JobGLAccountPrice."Unit Cost Factor",
          LibraryJob.GetUnitAmountRoundingPrecision(GenJournalLine."Currency Code"));

      // 3. Verify: Verify values on Job G/L Journal Lines.
      VerifyJobGLJournalLine(GenJournalLine,JobUnitCost,JobUnitPrice);

      // 4. Tear Down: Delete newly created batch.
      GenJournalBatch.GET(GenJournalLine."Journal Template Name",GenJournalLine."Journal Batch Name");
      GenJournalBatch.DELETE(TRUE);
Member of Lib.Library - ERM


InvoiceAmountRounding@2 Method

The procedure InvoiceAmountRounding is available in codeunit 131300.

Syntax

InvoiceAmountRounding@2(
    InvoiceAmont@1000 : Decimal InvoiceAmont, //Input parameter of type Decimal
    CurrencyCode@1002 : Code[10] CurrencyCode //Input parameter of type Code
);

Parameters

InvoiceAmont
Input parameter of type Decimal
CurrencyCode
Input parameter of type Code

Return Value

Decimal

Remarks

The relevant search keywords are: Invoice, Amount, Rounding.

For a clarification about how this function works, refer to the code listed below.

      // Round Invoice Amount.
      Currency.InitRoundingPrecision;
      IF CurrencyCode <> '' THEN
        Currency.GET(CurrencyCode);
      EXIT(ROUND(InvoiceAmont,Currency."Invoice Rounding Precision",Currency.InvoiceRoundingDirection));

Example

There are no examples available.
Member of Lib.Library - ERM


IssueFinanceChargeMemo@130 Method

The procedure IssueFinanceChargeMemo is available in codeunit 131300.

Syntax

IssueFinanceChargeMemo@130(
    FinanceChargeMemoHeader@1059 : Record 302 FinanceChargeMemoHeader //Input parameter of type Record
);

Parameters

FinanceChargeMemoHeader
Input parameter of type Record

Remarks

The relevant search keywords are: Issue, Finance, Charge, Memo.

For a clarification about how this function works, refer to the code listed below.

      FinanceChargeMemoHeader.SETRANGE("No.",FinanceChargeMemoHeader."No.");
      CLEAR(IssueFinanceChargeMemos);
      IssueFinanceChargeMemos.SETTABLEVIEW(FinanceChargeMemoHeader);
      IssueFinanceChargeMemos.USEREQUESTPAGE(FALSE);
      IssueFinanceChargeMemos.RUN;

Example

The below example is extracted from the test automation codeunit 134009 to show one way of using this function.

      FinanceChargeMemoLine.SETRANGE("Document Type",FinanceChargeMemoLine."Document Type"::Invoice);
      FinanceChargeMemoLine.SETRANGE("Document No.",DocumentNo);
      FinanceChargeMemoLine.FINDFIRST;
      FinanceChargeMemoHeader.GET(FinanceChargeMemoLine."Finance Charge Memo No.");
      LibraryERM.IssueFinanceChargeMemo(FinanceChargeMemoHeader);
      EXIT(FinanceChargeMemoHeader."No.");
Member of Lib.Library - ERM


PostBankAccReconciliation@45 Method

The procedure PostBankAccReconciliation is available in codeunit 131300.

Syntax

PostBankAccReconciliation@45(
    BankAccReconciliation@1000 : Record 273 BankAccReconciliation //Input parameter of type Record
);

Parameters

BankAccReconciliation
Input parameter of type Record

Remarks

The relevant search keywords are: Post, Bank, Account, Reconciliation.

For a clarification about how this function works, refer to the code listed below.

      CODEUNIT.RUN(CODEUNIT::"Bank Acc. Reconciliation Post",BankAccReconciliation);

Example

The below example is extracted from the test automation codeunit 134134 to show one way of using this function.

      // Check Reverse Error After Suggest and Modify Bank Reconciliation and Post.

      // Setup: Create General Journal Line With Customer and Post it.
      Initialize;
      WITH GenJournalLine DO BEGIN
        CreateAndPostGenJournalLine(
          GenJournalLine,"Document Type"::" ","Account Type"::Customer,LibrarySales.CreateCustomerNo,
          "Bank Payment Type"::" ",'',CreateBankAccount,LibraryRandom.RandDec(100,2),'');

        CreateAndSuggestBankReconcltn(BankAccReconciliation,"Bal. Account No.","Posting Date");
        ModifyBankReconcltn(BankAccReconciliation);
        LibraryERM.PostBankAccReconciliation(BankAccReconciliation);

        // Exercise: Create and Suggest Bank Reconciliation, Modify and Post it.
        ReverseBankAccountLedgerEntry(BankAccountLedgerEntry,"Document No.");
      END;
      // Verify: Verify Reversing Error for Bank Account Ledger Entry After Modify and Post Bank Reconciliation.
      Assert.AreEqual(STRSUBSTNO(ReverseErr,BankAccountLedgerEntry."Entry No."),GETLASTERRORTEXT,VerifyErr);
Member of Lib.Library - ERM


PostCustLedgerApplication@28 Method

The procedure PostCustLedgerApplication is available in codeunit 131300.

Syntax

PostCustLedgerApplication@28(
    CustLedgerEntry@1000 : Record 21 CustLedgerEntry //Input parameter of type Record
);

Parameters

CustLedgerEntry
Input parameter of type Record

Remarks

The relevant search keywords are: Post, Customer, Ledger, Application.

For a clarification about how this function works, refer to the code listed below.

      // Post Application Entries.
      CODEUNIT.RUN(CODEUNIT::"CustEntry-Apply Posted Entries",CustLedgerEntry);

Example

The below example is extracted from the test automation codeunit 134006 to show one way of using this function.

      LibraryERM.FindCustomerLedgerEntry(CustLedgerEntry,DocumentType,DocumentNo);
      LibraryERM.SetApplyCustomerEntry(CustLedgerEntry,AmountToApply);
      LibraryERM.FindCustomerLedgerEntry(CustLedgerEntry2,DocumentType2,DocumentNo2);
      CustLedgerEntry2.FINDSET;
      REPEAT
        CustLedgerEntry2.CALCFIELDS("Remaining Amount");
        CustLedgerEntry2.VALIDATE("Amount to Apply",CustLedgerEntry2."Remaining Amount");
        CustLedgerEntry2.MODIFY(TRUE);
      UNTIL CustLedgerEntry2.NEXT = 0;

      LibraryERM.SetAppliestoIdCustomer(CustLedgerEntry2);
      LibraryERM.PostCustLedgerApplication(CustLedgerEntry);
Member of Lib.Library - ERM


PostFAJournalLine@50 Method

The procedure PostFAJournalLine is available in codeunit 131300.

Syntax

PostFAJournalLine@50(
    FAJournalLine@1000 : Record 5621 FAJournalLine //Input parameter of type Record
);

Parameters

FAJournalLine
Input parameter of type Record

Remarks

The relevant search keywords are: Post, Fixed Asset, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      CODEUNIT.RUN(CODEUNIT::"FA Jnl.-Post Batch",FAJournalLine);

Example

The below example is extracted from the test automation codeunit 134450 to show one way of using this function.

      // Test the Appreciation of Fixed Assets.

      // 1.Setup: Create Fixed Asset, FA Acquisition, FA Journal Line and Insert FA Bal Account.
      Initialize;
      LibraryFixedAsset.CreateFAWithPostingGroup(FixedAsset);
      CreateJournalSetupDepreciation(DepreciationBook);
      CreateFADepreciationBook(FADepreciationBook,FixedAsset."No.",FixedAsset."FA Posting Group",DepreciationBook.Code);

      CreateFAJournalLine(
        FAJournalLine,FixedAsset."No.",FADepreciationBook."Depreciation Book Code",
        FAJournalLine."Document Type",FAJournalLine."FA Posting Type");
      LibraryFixedAsset.PostFAJournalLine(FAJournalLine);
      CreateFAGLJournal(
        GenJournalLine,FixedAsset."No.",FADepreciationBook."Depreciation Book Code",
        GenJournalLine."FA Posting Type"::Appreciation);

      IndexationAndIntegrationInBook(FADepreciationBook."Depreciation Book Code");
      UpdateAppreciationAccount(FixedAsset."FA Posting Group");
      GenJournalLine.SETRANGE("Account No.",GenJournalLine."Account No.");
      FAGetBalanceAccount.InsertAcc(GenJournalLine); // Insert FA Bal Account.

      // 2.Exercise: Post FA G/L Line.
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // 3.Verify: Verify Amount on FA Ledger Entry Correctly Populated.
      VerifyAmountInFATransaction(FixedAsset."No.",FAJournalLine."FA Posting Type"::Appreciation);
Member of Lib.Library - ERM


PostGeneralJnlLine@30 Method

The procedure PostGeneralJnlLine is available in codeunit 131300.

Syntax

PostGeneralJnlLine@30(
    GenJournalLine@1000 : Record 81 GenJournalLine //Input parameter of type Record
);

Parameters

GenJournalLine
Input parameter of type Record

Remarks

The relevant search keywords are: Post, General, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      CODEUNIT.RUN(CODEUNIT::"Gen. Jnl.-Post Batch",GenJournalLine);

Example

The below example is extracted from the test automation codeunit 134000 to show one way of using this function.

      // [FEATURE] [Dimension] [Payment Discount]
      // [SCENARIO 376797] Sales payment journal with dimension applied to posted Invoice can be posted in case of Discount, "Payment Disc. Debit Acc." with default dimension with "Value Posting" = "Same Code"
      Initialize;

      // [GIVEN] Customer with "Payment Disc. Debit Acc." = "A"
      // [GIVEN] Default Dimension "D" with "Value Posting" = "Same Code" is set for G/L Account "A"
      CustomerNo := CreateCustomer;
      GLAccountNo := CreateCustPostingGrPmtDiscDebitAccNo(CustomerNo);
      CreateDefaultDimensionGLAccSameValue(DimensionValue,GLAccountNo);

      // [GIVEN] Posted Sales Invoice with Amount Including VAT = 10000 and possible Discount = 2%. No dimension is set.
      CreateAndPostGenJnlLine(
        GenJournalLine,WORKDATE,GenJournalLine."Document Type"::Invoice,LibraryRandom.RandIntInRange(1000,2000),CustomerNo,'');
      PaymentAmount := -GenJournalLine.Amount + GenJournalLine.Amount * GetPmtTermsDiscountPct / 100;

      // [GIVEN] Sales Journal with Payment Amount = 9800 and applied to posted Invoice. Dimension "D" is set.
      CreateGenJnlLineWithAppliesToDocNo(
        GenJournalLine,GenJournalLine."Account Type"::Customer,CustomerNo,GenJournalLine."Document No.");
      GenJournalLine.VALIDATE("Dimension Set ID",LibraryDimension.CreateDimSet(0,DimensionValue."Dimension Code",DimensionValue.Code));
      GenJournalLine.VALIDATE(Amount,PaymentAmount);
      GenJournalLine.MODIFY;

      // [WHEN] Post Sales Journal
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // [THEN] Posted G/L Entry with "G/L Account No." = "A" has Dimension "D"
      FindGLEntry(GLEntry,GenJournalLine."Document No.",GLAccountNo);
      Assert.AreEqual(GenJournalLine."Dimension Set ID",GLEntry."Dimension Set ID",GLEntry.FIELDCAPTION("Dimension Set ID"))
Member of Lib.Library - ERM


PostVendLedgerApplication@33 Method

The procedure PostVendLedgerApplication is available in codeunit 131300.

Syntax

PostVendLedgerApplication@33(
    VendorLedgerEntry@1000 : Record 25 VendorLedgerEntry //Input parameter of type Record
);

Parameters

VendorLedgerEntry
Input parameter of type Record

Remarks

The relevant search keywords are: Post, Vendor, Ledger, Application.

For a clarification about how this function works, refer to the code listed below.

      // Post Application Entries.
      CODEUNIT.RUN(CODEUNIT::"VendEntry-Apply Posted Entries",VendorLedgerEntry);

Example

The below example is extracted from the test automation codeunit 134001 to show one way of using this function.

      ApplyVendorEntry(VendorLedgerEntry,DocumentType,DocumentNo);
      LibraryERM.PostVendLedgerApplication(VendorLedgerEntry);
Member of Lib.Library - ERM


ReverseTransaction@265 Method

The procedure ReverseTransaction is available in codeunit 131300.

Syntax

ReverseTransaction@265(
    TransactionNo@1001 : Integer TransactionNo //Input parameter of type Integer
);

Parameters

TransactionNo
Input parameter of type Integer

Remarks

The relevant search keywords are: Reverse, Transaction.

For a clarification about how this function works, refer to the code listed below.

      ReversalEntry.SetHideDialog(TRUE);
      ReversalEntry.ReverseTransaction(TransactionNo);

Example

The below example is extracted from the test automation codeunit 134080 to show one way of using this function.

      // [FEATURE] [Reverse] [Purchase]
      // [SCENARIO] Program doesn't allow to reverse the payment transaction when Realized gain or loss entries associated with Vendor Receipt transaction.

      // [GIVEN] Create Currency, Vendor, Apply Payment on Invoice using Gen. Journal Line.
      Initialize;
      CurrencyCode := CreateCurrencyWithMultipleExchangeRate(StartingDate,StartingDate2);
      CreatePostPaymentWithAppln(
        GenJournalLine,GenJournalLine."Account Type"::Vendor,CreateVendor(CurrencyCode),CurrencyCode,1,StartingDate);

      // [GIVEN] Unapply Payment
      UnapplyVendorEntry(VendorLedgerEntry,VendorLedgerEntry."Document Type"::Payment,GenJournalLine."Document No.");

      // [WHEN] Reverse Payment
      ASSERTERROR LibraryERM.ReverseTransaction(VendorLedgerEntry."Transaction No.");

      // [THEN] Error raised that you cannot reverse transaction because the entry has an associated Realized Gain/Loss entry.
      Assert.ExpectedError(STRSUBSTNO(ReversalErr,VendorLedgerEntry.TABLECAPTION,VendorLedgerEntry."Entry No."));
Member of Lib.Library - ERM


RunAddnlReportingCurrency@103 Method

The procedure RunAddnlReportingCurrency is available in codeunit 131300.

Syntax

RunAddnlReportingCurrency@103(
    CurrencyCode@1002 : Code[10] CurrencyCode, //Input parameter of type Code
    DocumentNo@1001 : Code[20] DocumentNo, //Input parameter of type Code
    NewRetainedEarningsGLAccNo@1003 : Code[20] NewRetainedEarningsGLAccNo //Input parameter of type Code
);

Parameters

CurrencyCode
Input parameter of type Code
DocumentNo
Input parameter of type Code
NewRetainedEarningsGLAccNo
Input parameter of type Code

Remarks

The relevant search keywords are: Run, Additional, Reporting, Currency.

For a clarification about how this function works, refer to the code listed below.

      // Run Additional Currency Reporting Report for ACY.
      AdjustAddReportingCurrency.SetAddCurr(CurrencyCode);
      AdjustAddReportingCurrency.InitializeRequest(DocumentNo,NewRetainedEarningsGLAccNo);
      AdjustAddReportingCurrency.USEREQUESTPAGE(FALSE);
      AdjustAddReportingCurrency.RUN;

Example

The below example is extracted from the test automation codeunit 134025 to show one way of using this function.

      CreateCurrencyWithExchangeRate(CurrencyExchangeRate);
      LibraryERM.CreateRandomExchangeRate(CurrencyExchangeRate."Currency Code");
      UpdateResidualAccountCurrency(CurrencyExchangeRate."Currency Code");
      LibraryERM.SetAddReportingCurrency(CurrencyExchangeRate."Currency Code");
      LibraryERM.RunAddnlReportingCurrency(
        CurrencyExchangeRate."Currency Code",CurrencyExchangeRate."Currency Code",
        LibraryERM.CreateGLAccountWithSalesSetup);
Member of Lib.Library - ERM


RunAdjustExchangeRates@132 Method

The procedure RunAdjustExchangeRates is available in codeunit 131300.

Syntax

RunAdjustExchangeRates@132(
    CurrencyCode@1000 : Code[10] CurrencyCode, //Input parameter of type Code
    StartDate@1008 : Date StartDate, //Input parameter of type Date
    EndDate@1003 : Date EndDate, //Input parameter of type Date
    PostingDescription@1007 : Text[50] PostingDescription, //Input parameter of type Text
    PostingDate@1004 : Date PostingDate, //Input parameter of type Date
    PostingDocNo@1005 : Code[20] PostingDocNo, //Input parameter of type Code
    AdjGLAcc@1006 : Boolean AdjGLAcc //Input parameter of type Boolean
);

Parameters

CurrencyCode
Input parameter of type Code
StartDate
Input parameter of type Date
EndDate
Input parameter of type Date
PostingDescription
Input parameter of type Text
PostingDate
Input parameter of type Date
PostingDocNo
Input parameter of type Code
AdjGLAcc
Input parameter of type Boolean

Remarks

The relevant search keywords are: Run, Adjust, Exchange, Rates.

For a clarification about how this function works, refer to the code listed below.

      Currency.SETRANGE(Code,CurrencyCode);
      AdjustExchangeRates.SETTABLEVIEW(Currency);
      AdjustExchangeRates.InitializeRequest2(StartDate,EndDate,PostingDescription,PostingDate,PostingDocNo,TRUE,AdjGLAcc);
      AdjustExchangeRates.USEREQUESTPAGE(FALSE);
      AdjustExchangeRates.RUN;

Example

The below example is extracted from the test automation codeunit 134080 to show one way of using this function.

      // [SCENARIO 221966] Posting Description with long Currency Code and Amount is not truncated on run "Adjust Exchange Rates" report
      Initialize;

      // [GIVEN] Currency Code "XXX" with length 3+
      CurrencyCode := CreateCurrency;
      Assert.IsTrue(STRLEN(CurrencyCode) > 2,'The length of currency code must be greater than 2');

      // [GIVEN] Posted Gen. Journal Line with Currency Code "XXX" and Amount "YYY"
      CreateGenAndModifyExchRate(
        GenJournalLine,GenJournalLine."Account Type"::"Bank Account",CreateBankAccount(CurrencyCode),
        GenJournalLine."Document Type"::" ",LibraryRandom.RandDec(100,2),LibraryRandom.RandInt(50));
      AdjExchDocNo := LibraryUtility.GenerateGUID;

      // [GIVEN] Posting Description template string "D" = "RANDDESC %1 %2"
      DescLen := MAXSTRLEN(GLEntry.Description) - STRLEN(STRSUBSTNO(' %1 %2',GenJournalLine."Currency Code",GenJournalLine.Amount));
      Description := COPYSTR(LibraryUtility.GenerateRandomAlphabeticText(DescLen,0) + ' %1 %2',1);

      ExpectedDescription := STRSUBSTNO(Description,GenJournalLine."Currency Code",GenJournalLine.Amount);

      // [WHEN] "Adjust Exchange Rates" report run with "D" as Description
      LibraryERM.RunAdjustExchangeRates(CurrencyCode,0D,WORKDATE,Description,WORKDATE,AdjExchDocNo,FALSE);

      // [THEN] Description in G/L entries is equal to "RANDDESC XXX YYY"
      GLEntry.SETRANGE("Document No.",AdjExchDocNo);
      GLEntry.SETRANGE("Posting Date",WORKDATE);
      GLEntry.FINDSET;
      REPEAT
        GLEntry.TESTFIELD(Description,PADSTR(ExpectedDescription,MAXSTRLEN(GLEntry.Description)));
      UNTIL GLEntry.NEXT = 0;
Member of Lib.Library - ERM


RunAdjustExchangeRatesSimple@129 Method

The procedure RunAdjustExchangeRatesSimple is available in codeunit 131300.

Syntax

RunAdjustExchangeRatesSimple@129(
    CurrencyCode@1000 : Code[10] CurrencyCode, //Input parameter of type Code
    EndDate@1003 : Date EndDate, //Input parameter of type Date
    PostingDate@1004 : Date PostingDate //Input parameter of type Date
);

Parameters

CurrencyCode
Input parameter of type Code
EndDate
Input parameter of type Date
PostingDate
Input parameter of type Date

Remarks

The relevant search keywords are: Run, Adjust, Exchange, Rates, Simple.

For a clarification about how this function works, refer to the code listed below.

      RunAdjustExchangeRates(
        CurrencyCode,0D,EndDate,'Test',PostingDate,LibraryUtility.GenerateGUID,FALSE);

Example

The below example is extracted from the test automation codeunit 134022 to show one way of using this function.

      // Check No Remaining Amount is left when a Credit Memo with Currency Code is applied to two refunds.

      // Setup: Update Pmt. Discount Grace Period in General Ledger Setup. Create a Customer with Payment term code having Calc. Discount on Credit Memo.
      // Create Currency with its currency exchange rate.
      Initialize;
      GenJournalLineAmount := 10 * LibraryRandom.RandDec(1000,2);
      LibraryPmtDiscSetup.SetPmtDiscGracePeriodByText('<' + FORMAT(LibraryRandom.RandInt(5)) + 'D>');
      CustomerNoToApply := CreateCustomer(CreatePaymentTermsWithDiscOnCreditMemo);  // CustomerNoToApply is used in report handler
      CurrencyCode := CreateCurrencyWithGainLossAccount;
      AdjustmentFactor := CreateAndUpdateCurrencyExchangeRate(CurrencyCode);

      // Exercise: Create and Post One Credit Memo with currency and two refunds. Apply it through Customer Ledger Entries. Run Adjust Currency Exchange Rate
      // Batch job.
      CreateGenJournalLineWithCurrencyCode(
        GenJournalLine,CustomerNoToApply,CurrencyCode,GenJournalLine."Document Type"::"Credit Memo",
        -GenJournalLineAmount,WORKDATE,GenJournalLine."Account Type"::Customer);
      PostGeneralJnlLine(GenJournalLine);
      FOR Index := 1 TO 2 DO BEGIN
        CreateGenJournalLineWithCurrencyCode(
          GenJournalLine,CustomerNoToApply,'',GenJournalLine."Document Type"::Refund,
          (GenJournalLineAmount * AdjustmentFactor) / 2 ,CALCDATE('<1D>',WORKDATE),GenJournalLine."Account Type"::Customer);
        PostGeneralJnlLine(GenJournalLine);
      END;
      LibraryERM.RunAdjustExchangeRatesSimple(CurrencyCode,WORKDATE,WORKDATE);
      LibraryVariableStorage.Enqueue(CustomerNoToApply);
      ApplyCustomerLedgerEntries(CustomerNoToApply,GenJournalLine."Document Type"::"Credit Memo");

      // Verify : Verify that no remaing amount is left in Refund and Credit Memo.
      VerifyRefundAndCreditMemoRemainingAmountIsZero(CustomerNoToApply);
Member of Lib.Library - ERM


SelectFAJournalBatch@54 Method

The procedure SelectFAJournalBatch is available in codeunit 131300.

Syntax

SelectFAJournalBatch@54(
    VAR FAJournalBatch@1000 : Record 5620 FAJournalBatch //Reference parameter of type Record
);

Parameters

FAJournalBatch
Reference parameter of type Record

Remarks

The relevant search keywords are: Select, Fixed Asset, Journal, Batch.

For a clarification about how this function works, refer to the code listed below.

      // Select FA Journal Batch Name for FA Journal Line.
      FAJournalBatch.SETRANGE("Journal Template Name",SelectFAJournalTemplate);
      IF FAJournalBatch.FINDFIRST THEN
        EXIT;
      // Create New FA Journal Batch.
      FAJournalBatch.INIT;
      FAJournalBatch.VALIDATE("Journal Template Name",SelectFAJournalTemplate);
      FAJournalBatch.VALIDATE(Name,
        COPYSTR(LibraryUtility.GenerateRandomCode(FAJournalBatch.FIELDNO(Name),DATABASE::"FA Journal Batch"),
          1,LibraryUtility.GetFieldLength(DATABASE::"FA Journal Batch",FAJournalBatch.FIELDNO(Name))));
      FAJournalBatch.INSERT(TRUE);
      FAJournalBatch.VALIDATE("No. Series",CreateNoSeriesCode);
      FAJournalBatch.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - ERM


SelectFAJournalTemplate@52 Method

The procedure SelectFAJournalTemplate is available in codeunit 131300.

Syntax

SelectFAJournalTemplate@52(
      //param element not supplied
);

Return Value

Code[10]

Remarks

The relevant search keywords are: Select, Fixed Asset, Journal, Template.

For a clarification about how this function works, refer to the code listed below.

      // Select FA Journal Template Name for FA Journal Line.
      FAJournalTemplate.SETRANGE(Recurring,FALSE);
      IF NOT FAJournalTemplate.FINDFIRST THEN BEGIN
        FAJournalTemplate.INIT;
        FAJournalTemplate.VALIDATE(
          Name,COPYSTR(LibraryUtility.GenerateRandomCode(FAJournalTemplate.FIELDNO(Name),DATABASE::"FA Journal Template"),
            1,LibraryUtility.GetFieldLength(DATABASE::"FA Journal Template",FAJournalTemplate.FIELDNO(Name))));
        FAJournalTemplate.VALIDATE(Recurring,FALSE);
        FAJournalTemplate.INSERT(TRUE);
      END;
      EXIT(FAJournalTemplate.Name);

Example

There are no examples available.
Member of Lib.Library - ERM


SelectGenJnlBatch@35 Method

The procedure SelectGenJnlBatch is available in codeunit 131300.

Syntax

SelectGenJnlBatch@35(
    VAR GenJournalBatch@1000 : Record 232 GenJournalBatch //Reference parameter of type Record
);

Parameters

GenJournalBatch
Reference parameter of type Record

Remarks

The relevant search keywords are: Select, General, Journal, Batch.

For a clarification about how this function works, refer to the code listed below.

      LibraryJournals.SelectGenJournalBatch(GenJournalBatch,SelectGenJnlTemplate);

Example

The below example is extracted from the test automation codeunit 134000 to show one way of using this function.

      LibraryERM.SelectGenJnlBatch(GenJournalBatch);
      LibraryERM.ClearGenJournalLines(GenJournalBatch);
      LibraryERM.CreateGeneralJnlLine(
        GenJournalLine,GenJournalBatch."Journal Template Name",GenJournalBatch.Name,DocumentType,
        GenJournalLine."Account Type"::Customer,CustomerNo,Amount);
      GenJournalLine.VALIDATE("Posting Date",PostingDate);
      GenJournalLine.VALIDATE("Currency Code",CurrencyCode);
      GenJournalLine.MODIFY(TRUE);
Member of Lib.Library - ERM


SelectGenJnlTemplate@37 Method

The procedure SelectGenJnlTemplate is available in codeunit 131300.

Syntax

SelectGenJnlTemplate@37(
      //param element not supplied
);

Return Value

Code[10]

Remarks

The relevant search keywords are: Select, General, Journal, Template.

For a clarification about how this function works, refer to the code listed below.

      EXIT(LibraryJournals.SelectGenJournalTemplate(GenJournalTemplate.Type::General,PAGE::"General Journal"));

Example

There are no examples available.
Member of Lib.Library - ERM


SetAddReportingCurrency@51 Method

The procedure SetAddReportingCurrency is available in codeunit 131300.

Syntax

SetAddReportingCurrency@51(
    AdditionalReportingCurrency@1000 : Code[10] AdditionalReportingCurrency //Input parameter of type Code
);

Parameters

AdditionalReportingCurrency
Input parameter of type Code

Remarks

The relevant search keywords are: Set, Add, Reporting, Currency.

For a clarification about how this function works, refer to the code listed below.

      GeneralLedgerSetup.GET;
      GeneralLedgerSetup."Additional Reporting Currency" := AdditionalReportingCurrency;
      GeneralLedgerSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134000 to show one way of using this function.

      // Check Application Rounding Entry in Detailed Customer Ledger Entry and Additional Currency Amount in G/L Entry
      // with Apply and Unapply Invoice and Payment with Random Values and using 0 for Application Rounding Precision for Currency..
      Initialize;
      CurrencyCode := CreateCurrency(0);
      LibraryERM.SetAddReportingCurrency(CurrencyCode);
      AppRounding := LibraryRandom.RandDec(5,2);
      DocumentNo :=
        ApplyUnapplyCustRounding(
          GenJournalLine."Document Type"::Invoice,GenJournalLine."Document Type"::Payment,CurrencyCode,
          10 * LibraryRandom.RandDec(100,2),AppRounding);

      // Verify: Verify Additional Currency Amount in G/L Entry.
      VerifyGLEntry(DocumentNo,CurrencyCode,GenJournalLine."Document Type"::" ",AppRounding);
Member of Lib.Library - ERM


SetAllowPostingFromTo@180 Method

The procedure SetAllowPostingFromTo is available in codeunit 131300.

Syntax

SetAllowPostingFromTo@180(
    FromDate@1000 : Date FromDate, //Input parameter of type Date
    ToDate@1001 : Date ToDate //Input parameter of type Date
);

Parameters

FromDate
Input parameter of type Date
ToDate
Input parameter of type Date

Remarks

The relevant search keywords are: Set, Allow, Posting, From, To.

For a clarification about how this function works, refer to the code listed below.

      GeneralLedgerSetup.GET;
      GeneralLedgerSetup."Allow Posting From" := FromDate;
      GeneralLedgerSetup."Allow Posting To" := ToDate;
      GeneralLedgerSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134383 to show one way of using this function.

      // [FEATURE] [Purchase]
      // [SCENARIO 378711] "Receive" and "Invoice" fields remain unchanged when purchase order cannot be received due to "Posting Date" is out of allowed posting date range.

      // [GIVEN] GLSetup."Allow Posting From" = 01/01/2016
      // [GIVEN] GLSetup."Allow Posting To" = 31/01/2016
      Initialize;
      LibraryERM.SetAllowPostingFromTo(WORKDATE - 10,WORKDATE - 1);

      // [GIVEN] Purchase order "PO" with "Posting Date" = 21/02/2016, "Receive" = FALSE, "Invoice" = FALSE
      CreatePurchaseOrder(PurchaseHeader,PurchaseLine,PurchaseHeader."Document Type"::Order);
      COMMIT;

      // [WHEN] Post "PO" as receipt
      ASSERTERROR LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,FALSE);

      // [THEN] "Posting Date is not within your range of allowed posting dates." error thrown
      PurchaseHeader.FIND;
      Assert.ExpectedError(PostingDateNotAllowedErr);

      // [THEN] "PO".Receive = FALSE
      PurchaseHeader.TESTFIELD(Receive,FALSE);
      // [THEN] "PO".Invoice = FALSE
      PurchaseHeader.TESTFIELD(Invoice,FALSE);
Member of Lib.Library - ERM


SetAllowPostingTo@184 Method

The procedure SetAllowPostingTo is available in codeunit 131300.

Syntax

SetAllowPostingTo@184(
    ToDate@1001 : Date ToDate //Input parameter of type Date
);

Parameters

ToDate
Input parameter of type Date

Remarks

The relevant search keywords are: Set, Allow, Posting, To.

For a clarification about how this function works, refer to the code listed below.

      GeneralLedgerSetup.GET;
      GeneralLedgerSetup."Allow Posting To" := ToDate;
      GeneralLedgerSetup.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - ERM


SetAmountRoundingPrecision@181 Method

The procedure SetAmountRoundingPrecision is available in codeunit 131300.

Syntax

SetAmountRoundingPrecision@181(
    AmountRoundingPrecision@1000 : Decimal AmountRoundingPrecision //Input parameter of type Decimal
);

Parameters

AmountRoundingPrecision
Input parameter of type Decimal

Remarks

The relevant search keywords are: Set, Amount, Rounding, Precision.

For a clarification about how this function works, refer to the code listed below.

      GeneralLedgerSetup.GET;
      GeneralLedgerSetup."Amount Rounding Precision" := AmountRoundingPrecision;
      GeneralLedgerSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134327 to show one way of using this function.

      // [FEATURE] [Job]
      // [SCENARIO 123636] The Job Total Price and Job Total Price (LCY) fields are populated in the Purchase Order/Invoice line after you select the Job No, Job Task No (in local currency)
      LightInit;
      // [GIVEN] Update precision in General Ledger Setup
      LibraryERM.SetAmountRoundingPrecision(LibraryRandom.RandPrecision);
      // [GIVEN] Purchase Line in LCY, where "Job No." is set
      CreatePurchLineAndJobTask(PurchaseLine,JobTask);
      // [GIVEN] Purchase Line, where "Job Unit Price" = "P", "Job Unit Price (LCY)" = "P(LCY)", Quantity = "Q"

      // [WHEN] Enter "Job Task No." = JobTask."Job Task No." in Purchase Line
      PurchaseLine.VALIDATE("Job Task No.",JobTask."Job Task No.");

      // [THEN] Purchase Line is updated
      // [THEN] "Job Total Price" = "P" * "Q"
      // [THEN] "Job Total Price (LCY)" = "P(LCY)" * "Q"
      VerifyJobTotalPrices(PurchaseLine,'');
Member of Lib.Library - ERM


SetAppliestoIdCustomer@40 Method

The procedure SetAppliestoIdCustomer is available in codeunit 131300.

Syntax

SetAppliestoIdCustomer@40(
    VAR CustLedgerEntry@1001 : Record 21 CustLedgerEntry //Reference parameter of type Record
);

Parameters

CustLedgerEntry
Reference parameter of type Record

Remarks

The relevant search keywords are: Set, Appliesto, Id, Customer.

For a clarification about how this function works, refer to the code listed below.

      // Set Applies-to ID.
      CustLedgerEntry.LOCKTABLE;
      CustLedgerEntry.FINDFIRST;
      REPEAT
        CustLedgerEntry.TESTFIELD(Open,TRUE);
        CustLedgerEntry.VALIDATE("Applies-to ID",USERID);
        IF CustLedgerEntry."Amount to Apply" = 0 THEN BEGIN
          CustLedgerEntry.CALCFIELDS("Remaining Amount");
          CustLedgerEntry.VALIDATE("Amount to Apply",CustLedgerEntry."Remaining Amount");
        END;
        CustLedgerEntry.MODIFY(TRUE);
      UNTIL CustLedgerEntry.NEXT = 0;

Example

The below example is extracted from the test automation codeunit 134006 to show one way of using this function.

      LibraryERM.FindCustomerLedgerEntry(CustLedgerEntry,DocumentType,DocumentNo);
      LibraryERM.SetApplyCustomerEntry(CustLedgerEntry,AmountToApply);
      LibraryERM.FindCustomerLedgerEntry(CustLedgerEntry2,DocumentType2,DocumentNo2);
      CustLedgerEntry2.FINDSET;
      REPEAT
        CustLedgerEntry2.CALCFIELDS("Remaining Amount");
        CustLedgerEntry2.VALIDATE("Amount to Apply",CustLedgerEntry2."Remaining Amount");
        CustLedgerEntry2.MODIFY(TRUE);
      UNTIL CustLedgerEntry2.NEXT = 0;

      LibraryERM.SetAppliestoIdCustomer(CustLedgerEntry2);
      LibraryERM.PostCustLedgerApplication(CustLedgerEntry);
Member of Lib.Library - ERM


SetAppliestoIdVendor@5 Method

The procedure SetAppliestoIdVendor is available in codeunit 131300.

Syntax

SetAppliestoIdVendor@5(
    VAR VendorLedgerEntry@1003 : Record 25 VendorLedgerEntry //Reference parameter of type Record
);

Parameters

VendorLedgerEntry
Reference parameter of type Record

Remarks

The relevant search keywords are: Set, Appliesto, Id, Vendor.

For a clarification about how this function works, refer to the code listed below.

      // Set Applies-to ID.
      VendorLedgerEntry.LOCKTABLE;
      VendorLedgerEntry.FINDFIRST;
      REPEAT
        VendorLedgerEntry.TESTFIELD(Open,TRUE);
        VendorLedgerEntry.VALIDATE("Applies-to ID",USERID);
        VendorLedgerEntry.VALIDATE("Applying Entry",TRUE);
        IF VendorLedgerEntry."Amount to Apply" = 0 THEN BEGIN
          VendorLedgerEntry.CALCFIELDS("Remaining Amount");
          VendorLedgerEntry.VALIDATE("Amount to Apply",VendorLedgerEntry."Remaining Amount");
        END;
        VendorLedgerEntry.MODIFY(TRUE);
      UNTIL VendorLedgerEntry.NEXT = 0;

Example

The below example is extracted from the test automation codeunit 134001 to show one way of using this function.

      LibraryERM.FindVendorLedgerEntry(ApplyingVendorLedgerEntry,DocumentType,DocumentNo);
      ApplyingVendorLedgerEntry.CALCFIELDS("Remaining Amount");
      LibraryERM.SetApplyVendorEntry(ApplyingVendorLedgerEntry,ApplyingVendorLedgerEntry."Remaining Amount");

      // Find Posted Vendor Ledger Entries.
      VendorLedgerEntry.SETRANGE("Vendor No.",ApplyingVendorLedgerEntry."Vendor No.");
      VendorLedgerEntry.SETRANGE("Applying Entry",FALSE);
      VendorLedgerEntry.FINDSET;
      REPEAT
        VendorLedgerEntry.CALCFIELDS("Remaining Amount");
        VendorLedgerEntry.VALIDATE("Amount to Apply",VendorLedgerEntry."Remaining Amount");
        VendorLedgerEntry.MODIFY(TRUE);
      UNTIL VendorLedgerEntry.NEXT = 0;

      // Set Applies-to ID.
      LibraryERM.SetAppliestoIdVendor(VendorLedgerEntry);
Member of Lib.Library - ERM


SetApplnRoundingPrecision@177 Method

The procedure SetApplnRoundingPrecision is available in codeunit 131300.

Syntax

SetApplnRoundingPrecision@177(
    ApplnRoundingPrecision@1000 : Decimal ApplnRoundingPrecision //Input parameter of type Decimal
);

Parameters

ApplnRoundingPrecision
Input parameter of type Decimal

Remarks

The relevant search keywords are: Set, Application, Rounding, Precision.

For a clarification about how this function works, refer to the code listed below.

      GeneralLedgerSetup.GET;
      GeneralLedgerSetup.VALIDATE("Appln. Rounding Precision",ApplnRoundingPrecision);
      GeneralLedgerSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134006 to show one way of using this function.

      // Check General Ledger, Customer Ledger and Detailed Customer ledger entries after Posting Sales Order with Currency and Payment method with a balance account.

      // Setup: Modify General Ledger setup for Appln. Rounding Precision and Create Customer with Currency and with Payment method with a balance account.
      Initialize;
      LibraryERM.SetApplnRoundingPrecision(LibraryRandom.RandDec(10,2));  // Taken Random value for Rounding Precision.
      CreateAndModifyCustomer(Customer,Customer."Application Method"::Manual,FindPaymentMethodWithBalanceAccount);  // Taken Zero value for Currency Application Rounding Precision.

      // Exercise: Create and post Sales Order with Random Quantity and Unit Price.
      DocumentNo :=
        CreateAndPostSalesDocument(
          SalesLine,WORKDATE,Customer."No.",LibraryInventory.CreateItemNo,SalesHeader."Document Type"::Order,
          LibraryRandom.RandDec(10,2),LibraryRandom.RandDec(100,2));

      // Verify: Verify GL, Customer and Detailed Customer ledger entries.
      VerifyEntriesAfterPostingSalesDocument(CustLedgerEntry."Document Type"::Payment,DocumentNo,DocumentNo);
Member of Lib.Library - ERM


SetApplyCustomerEntry@11 Method

The procedure SetApplyCustomerEntry is available in codeunit 131300.

Syntax

SetApplyCustomerEntry@11(
    VAR CustLedgerEntry@1000 : Record 21 CustLedgerEntry, //Reference parameter of type Record
    AmountToApply@1002 : Decimal AmountToApply //Input parameter of type Decimal
);

Parameters

CustLedgerEntry
Reference parameter of type Record
AmountToApply
Input parameter of type Decimal

Remarks

The relevant search keywords are: Set, Apply, Customer, Entry.

For a clarification about how this function works, refer to the code listed below.

      // Clear any existing applying entries.
      CustLedgerEntry2.SETRANGE("Applying Entry",TRUE);
      CustLedgerEntry2.SETFILTER("Entry No.",'<>%1',CustLedgerEntry."Entry No.");
      IF CustLedgerEntry2.FINDSET THEN
        REPEAT
          CustLedgerEntry2.VALIDATE("Applying Entry",FALSE);
          CustLedgerEntry2.MODIFY(TRUE);
        UNTIL CustLedgerEntry2.NEXT = 0;

      // Clear Applies-to IDs
      CustLedgerEntry2.RESET;
      CustLedgerEntry2.SETFILTER("Applies-to ID",'<>%1','');
      IF CustLedgerEntry2.FINDSET THEN
        REPEAT
          CustLedgerEntry2.VALIDATE("Applies-to ID",'');
          CustLedgerEntry2.MODIFY(TRUE);
        UNTIL CustLedgerEntry2.NEXT = 0;

      // Apply Payment Entry on Posted Invoice.
      WITH CustLedgerEntry DO BEGIN
        VALIDATE("Applying Entry",TRUE);
        VALIDATE("Applies-to ID",USERID);
        VALIDATE("Amount to Apply",AmountToApply);
        MODIFY(TRUE);
      END;
      CODEUNIT.RUN(CODEUNIT::"Cust. Entry-Edit",CustLedgerEntry);
      COMMIT;

Example

The below example is extracted from the test automation codeunit 134006 to show one way of using this function.

      LibraryERM.FindCustomerLedgerEntry(CustLedgerEntry,DocumentType,DocumentNo);
      LibraryERM.SetApplyCustomerEntry(CustLedgerEntry,AmountToApply);
      LibraryERM.FindCustomerLedgerEntry(CustLedgerEntry2,DocumentType2,DocumentNo2);
      CustLedgerEntry2.FINDSET;
      REPEAT
        CustLedgerEntry2.CALCFIELDS("Remaining Amount");
        CustLedgerEntry2.VALIDATE("Amount to Apply",CustLedgerEntry2."Remaining Amount");
        CustLedgerEntry2.MODIFY(TRUE);
      UNTIL CustLedgerEntry2.NEXT = 0;

      LibraryERM.SetAppliestoIdCustomer(CustLedgerEntry2);
      LibraryERM.PostCustLedgerApplication(CustLedgerEntry);
Member of Lib.Library - ERM


SetApplyVendorEntry@6 Method

The procedure SetApplyVendorEntry is available in codeunit 131300.

Syntax

SetApplyVendorEntry@6(
    VAR VendorLedgerEntry@1000 : Record 25 VendorLedgerEntry, //Reference parameter of type Record
    AmountToApply@1002 : Decimal AmountToApply //Input parameter of type Decimal
);

Parameters

VendorLedgerEntry
Reference parameter of type Record
AmountToApply
Input parameter of type Decimal

Remarks

The relevant search keywords are: Set, Apply, Vendor, Entry.

For a clarification about how this function works, refer to the code listed below.

      // Clear any existing applying entries.
      VendorLedgerEntry2.SETRANGE("Applying Entry",TRUE);
      VendorLedgerEntry2.SETFILTER("Entry No.",'<>%1',VendorLedgerEntry."Entry No.");
      IF VendorLedgerEntry2.FINDSET THEN
        REPEAT
          VendorLedgerEntry2.VALIDATE("Applying Entry",FALSE);
          VendorLedgerEntry2.MODIFY(TRUE);
        UNTIL VendorLedgerEntry2.NEXT = 0;

      // Clear Applies-to IDs.
      VendorLedgerEntry2.RESET;
      VendorLedgerEntry2.SETFILTER("Applies-to ID",'<>%1','');
      IF VendorLedgerEntry2.FINDSET THEN
        REPEAT
          VendorLedgerEntry2.VALIDATE("Applies-to ID",'');
          VendorLedgerEntry2.MODIFY(TRUE);
        UNTIL VendorLedgerEntry2.NEXT = 0;

      // Apply Payment Entry on Posted Invoice.
      WITH VendorLedgerEntry DO BEGIN
        VALIDATE("Applying Entry",TRUE);
        VALIDATE("Applies-to ID",USERID);
        VALIDATE("Amount to Apply",AmountToApply);
        MODIFY(TRUE);
      END;
      CODEUNIT.RUN(CODEUNIT::"Vend. Entry-Edit",VendorLedgerEntry);

Example

The below example is extracted from the test automation codeunit 134001 to show one way of using this function.

      LibraryERM.FindVendorLedgerEntry(ApplyingVendorLedgerEntry,DocumentType,DocumentNo);
      ApplyingVendorLedgerEntry.CALCFIELDS("Remaining Amount");
      LibraryERM.SetApplyVendorEntry(ApplyingVendorLedgerEntry,ApplyingVendorLedgerEntry."Remaining Amount");

      // Find Posted Vendor Ledger Entries.
      VendorLedgerEntry.SETRANGE("Vendor No.",ApplyingVendorLedgerEntry."Vendor No.");
      VendorLedgerEntry.SETRANGE("Applying Entry",FALSE);
      VendorLedgerEntry.FINDSET;
      REPEAT
        VendorLedgerEntry.CALCFIELDS("Remaining Amount");
        VendorLedgerEntry.VALIDATE("Amount to Apply",VendorLedgerEntry."Remaining Amount");
        VendorLedgerEntry.MODIFY(TRUE);
      UNTIL VendorLedgerEntry.NEXT = 0;

      // Set Applies-to ID.
      LibraryERM.SetAppliestoIdVendor(VendorLedgerEntry);
Member of Lib.Library - ERM


SetBillToSellToVATCalc@176 Method

The procedure SetBillToSellToVATCalc is available in codeunit 131300.

Syntax

SetBillToSellToVATCalc@176(
    BillToSellToVATCalc@1000 : Option BillToSellToVATCalc //Input parameter of type Option
);

Parameters

BillToSellToVATCalc
Input parameter of type Option

Remarks

The relevant search keywords are: Set, Bill, To, Sell, To, VAT, Calc.

For a clarification about how this function works, refer to the code listed below.

      GeneralLedgerSetup.GET;
      GeneralLedgerSetup.VALIDATE("Bill-to/Sell-to VAT Calc.",BillToSellToVATCalc);
      GeneralLedgerSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 136101 to show one way of using this function.

      // [SCENARIO 363375] "VAT Bus. Posting Group" should not be updated if "Bill-to Customer No." update is not confirmed.
      Initialize;
      // Setup for test
      LibraryERM.SetBillToSellToVATCalc(GeneralLedgerSetup."Bill-to/Sell-to VAT Calc."::"Bill-to/Pay-to No.");
      // [GIVEN] Service Order ("SO") for "Bill-to Customer No." = "C1", "VAT Bus. Posting Group" = "V1"
      CreateCustomerWithVATBusPostGroup(Customer1);
      // [GIVEN] Customer "C2", where "VAT Bus. Posting Group" = "V2"
      CreateCustomerWithVATBusPostGroup(Customer2);
      CreateServiceInvoiceWithServiceLine(ServiceHeader,ServiceLine,Customer1."No.");
      // [WHEN] Change Customer "C1" to "C2" in "SO". Confirm update of "SO"."Sell-to Customer No." and cancel update of "SO"."Bill-to Customer No."
      ChangeCustomerNo(ServiceHeader,Customer2."No.");
      // [THEN] "Service Header"."VAT Bus. Posting Group" = "V1"
      // [THEN] "Service Line"."VAT Bus. Posting Group" = "V1"
      VerifyVATBusPostGroupServiceOrder(ServiceHeader,ServiceLine,Customer1."VAT Bus. Posting Group");
Member of Lib.Library - ERM


SetCurrencyGainLossAccounts@121 Method

The procedure SetCurrencyGainLossAccounts is available in codeunit 131300.

Syntax

SetCurrencyGainLossAccounts@121(
    VAR Currency@1000 : Record 4 Currency //Reference parameter of type Record
);

Parameters

Currency
Reference parameter of type Record

Remarks

The relevant search keywords are: Set, Currency, Gain, Loss, Accounts.

For a clarification about how this function works, refer to the code listed below.

      // Find a correct account for realized adjustment
      GLAccount.SETRANGE("Income/Balance",GLAccount."Income/Balance"::"Income Statement");
      GLAccount.SETRANGE("Account Type",GLAccount."Account Type"::Posting);
      GLAccount.SETRANGE("Gen. Posting Type",GLAccount."Gen. Posting Type"::" ");
      GLAccount.SETRANGE(Blocked,FALSE);
      GLAccount.FINDSET;
      GLAccount.NEXT(0); // Needed to trick preCAL

      Currency.VALIDATE("Realized Losses Acc.",PopGLAccount(GLAccount));
      Currency.VALIDATE("Realized Gains Acc.",PopGLAccount(GLAccount));
      Currency.VALIDATE("Unrealized Losses Acc.",PopGLAccount(GLAccount));
      Currency.VALIDATE("Unrealized Gains Acc.",PopGLAccount(GLAccount));
      Currency.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134000 to show one way of using this function.

      LibraryERM.CreateCurrency(Currency);
      LibraryERM.SetCurrencyGainLossAccounts(Currency);
      Currency.VALIDATE("Residual Gains Account",Currency."Realized Gains Acc.");
      Currency.VALIDATE("Residual Losses Account",Currency."Realized Losses Acc.");
      Currency.VALIDATE("Appln. Rounding Precision",ApplnRoundingPrecision);
      Currency.MODIFY(TRUE);

      LibraryERM.CreateRandomExchangeRate(Currency.Code);
      EXIT(Currency.Code);
Member of Lib.Library - ERM


SetGeneralPostingSetupInvtAccounts@170 Method

The procedure SetGeneralPostingSetupInvtAccounts is available in codeunit 131300.

Syntax

SetGeneralPostingSetupInvtAccounts@170(
    VAR GeneralPostingSetup@1000 : Record 252 GeneralPostingSetup //Reference parameter of type Record
);

Parameters

GeneralPostingSetup
Reference parameter of type Record

Remarks

The relevant search keywords are: Set, General, Posting, Setup, Invt, Accounts.

For a clarification about how this function works, refer to the code listed below.

      WITH GeneralPostingSetup DO BEGIN
        IF "COGS Account" = '' THEN
          VALIDATE("COGS Account",CreateGLAccountNo);
        IF "COGS Account (Interim)" = '' THEN
          VALIDATE("COGS Account (Interim)",CreateGLAccountNo);
        IF "Inventory Adjmt. Account" = '' THEN
          VALIDATE("Inventory Adjmt. Account",CreateGLAccountNo);
        IF "Invt. Accrual Acc. (Interim)" = '' THEN
          VALIDATE("Invt. Accrual Acc. (Interim)",CreateGLAccountNo);
      END;

Example

There are no examples available.
Member of Lib.Library - ERM


SetGeneralPostingSetupMfgAccounts@165 Method

The procedure SetGeneralPostingSetupMfgAccounts is available in codeunit 131300.

Syntax

SetGeneralPostingSetupMfgAccounts@165(
    VAR GeneralPostingSetup@1000 : Record 252 GeneralPostingSetup //Reference parameter of type Record
);

Parameters

GeneralPostingSetup
Reference parameter of type Record

Remarks

The relevant search keywords are: Set, General, Posting, Setup, Mfg, Accounts.

For a clarification about how this function works, refer to the code listed below.

      WITH GeneralPostingSetup DO BEGIN
        IF "Direct Cost Applied Account" = '' THEN
          VALIDATE("Direct Cost Applied Account",CreateGLAccountNo);
        IF "Overhead Applied Account" = '' THEN
          VALIDATE("Overhead Applied Account",CreateGLAccountNo);
        IF "Purchase Variance Account" = '' THEN
          VALIDATE("Purchase Variance Account",CreateGLAccountNo);
      END;

Example

The below example is extracted from the test automation codeunit 134104 to show one way of using this function.

      LibraryERM.CreateGeneralPostingSetupInvt(GeneralPostingSetup);
      LibraryERM.SetGeneralPostingSetupPrepAccounts(GeneralPostingSetup);
      LibraryERM.SetGeneralPostingSetupSalesAccounts(GeneralPostingSetup);
      LibraryERM.SetGeneralPostingSetupPurchAccounts(GeneralPostingSetup);
      LibraryERM.SetGeneralPostingSetupMfgAccounts(GeneralPostingSetup);
      GeneralPostingSetup.MODIFY(TRUE);
      CreateRelatedZeroVATPostingSetup(VATPostingSetup,VATBusPostingGroupCode);
      UpdateGLAccountWithVATAndGenSetup(GeneralPostingSetup."Sales Prepayments Account",VATPostingSetup,GeneralPostingSetup);
      UpdateGLAccountWithVATAndGenSetup(GeneralPostingSetup."Purch. Prepayments Account",VATPostingSetup,GeneralPostingSetup);
Member of Lib.Library - ERM


SetGeneralPostingSetupPrepAccounts@164 Method

The procedure SetGeneralPostingSetupPrepAccounts is available in codeunit 131300.

Syntax

SetGeneralPostingSetupPrepAccounts@164(
    VAR GeneralPostingSetup@1000 : Record 252 GeneralPostingSetup //Reference parameter of type Record
);

Parameters

GeneralPostingSetup
Reference parameter of type Record

Remarks

The relevant search keywords are: Set, General, Posting, Setup, Prep, Accounts.

For a clarification about how this function works, refer to the code listed below.

      WITH GeneralPostingSetup DO BEGIN
        IF "Sales Prepayments Account" = '' THEN
          VALIDATE("Sales Prepayments Account",CreateGLAccountNo);
        IF "Purch. Prepayments Account" = '' THEN
          VALIDATE("Purch. Prepayments Account",CreateGLAccountNo);
      END;

Example

The below example is extracted from the test automation codeunit 134104 to show one way of using this function.

      LibraryERM.CreateGeneralPostingSetupInvt(GeneralPostingSetup);
      LibraryERM.SetGeneralPostingSetupPrepAccounts(GeneralPostingSetup);
      LibraryERM.SetGeneralPostingSetupSalesAccounts(GeneralPostingSetup);
      LibraryERM.SetGeneralPostingSetupPurchAccounts(GeneralPostingSetup);
      LibraryERM.SetGeneralPostingSetupMfgAccounts(GeneralPostingSetup);
      GeneralPostingSetup.MODIFY(TRUE);
      CreateRelatedZeroVATPostingSetup(VATPostingSetup,VATBusPostingGroupCode);
      UpdateGLAccountWithVATAndGenSetup(GeneralPostingSetup."Sales Prepayments Account",VATPostingSetup,GeneralPostingSetup);
      UpdateGLAccountWithVATAndGenSetup(GeneralPostingSetup."Purch. Prepayments Account",VATPostingSetup,GeneralPostingSetup);
Member of Lib.Library - ERM


SetGeneralPostingSetupPurchAccounts@169 Method

The procedure SetGeneralPostingSetupPurchAccounts is available in codeunit 131300.

Syntax

SetGeneralPostingSetupPurchAccounts@169(
    VAR GeneralPostingSetup@1000 : Record 252 GeneralPostingSetup //Reference parameter of type Record
);

Parameters

GeneralPostingSetup
Reference parameter of type Record

Remarks

The relevant search keywords are: Set, General, Posting, Setup, Purchase, Accounts.

For a clarification about how this function works, refer to the code listed below.

      WITH GeneralPostingSetup DO BEGIN
        IF "Purch. Account" = '' THEN
          VALIDATE("Purch. Account",CreateGLAccountNo);
        IF "Purch. Line Disc. Account" = '' THEN
          VALIDATE("Purch. Line Disc. Account",CreateGLAccountNo);
        IF "Purch. Inv. Disc. Account" = '' THEN
          VALIDATE("Purch. Inv. Disc. Account",CreateGLAccountNo);
        IF "Purch. Credit Memo Account" = '' THEN
          VALIDATE("Purch. Credit Memo Account",CreateGLAccountNo);
      END;

Example

The below example is extracted from the test automation codeunit 134104 to show one way of using this function.

      LibraryERM.CreateGeneralPostingSetupInvt(GeneralPostingSetup);
      LibraryERM.SetGeneralPostingSetupPrepAccounts(GeneralPostingSetup);
      LibraryERM.SetGeneralPostingSetupSalesAccounts(GeneralPostingSetup);
      LibraryERM.SetGeneralPostingSetupPurchAccounts(GeneralPostingSetup);
      LibraryERM.SetGeneralPostingSetupMfgAccounts(GeneralPostingSetup);
      GeneralPostingSetup.MODIFY(TRUE);
      CreateRelatedZeroVATPostingSetup(VATPostingSetup,VATBusPostingGroupCode);
      UpdateGLAccountWithVATAndGenSetup(GeneralPostingSetup."Sales Prepayments Account",VATPostingSetup,GeneralPostingSetup);
      UpdateGLAccountWithVATAndGenSetup(GeneralPostingSetup."Purch. Prepayments Account",VATPostingSetup,GeneralPostingSetup);
Member of Lib.Library - ERM


SetGeneralPostingSetupPurchPmtDiscAccounts@168 Method

The procedure SetGeneralPostingSetupPurchPmtDiscAccounts is available in codeunit 131300.

Syntax

SetGeneralPostingSetupPurchPmtDiscAccounts@168(
    VAR GeneralPostingSetup@1000 : Record 252 GeneralPostingSetup //Reference parameter of type Record
);

Parameters

GeneralPostingSetup
Reference parameter of type Record

Remarks

The relevant search keywords are: Set, General, Posting, Setup, Purchase, Payment, Discount, Accounts.

For a clarification about how this function works, refer to the code listed below.

      WITH GeneralPostingSetup DO BEGIN
        IF "Purch. Pmt. Disc. Debit Acc." = '' THEN
          VALIDATE("Purch. Pmt. Disc. Debit Acc.",CreateGLAccountNo);
        IF "Purch. Pmt. Disc. Credit Acc." = '' THEN
          VALIDATE("Purch. Pmt. Disc. Credit Acc.",CreateGLAccountNo);
        IF "Purch. Pmt. Tol. Debit Acc." = '' THEN
          VALIDATE("Purch. Pmt. Tol. Debit Acc.",CreateGLAccountNo);
        IF "Purch. Pmt. Tol. Credit Acc." = '' THEN
          VALIDATE("Purch. Pmt. Tol. Credit Acc.",CreateGLAccountNo);
      END;

Example

The below example is extracted from the test automation codeunit 134007 to show one way of using this function.

      GeneralPostingSetup.GET(GenBusPostingGroup,GenProdPostingGroup);
      LibraryERM.SetGeneralPostingSetupPurchPmtDiscAccounts(GeneralPostingSetup);
      LibraryERM.SetGeneralPostingSetupSalesPmtDiscAccounts(GeneralPostingSetup);
      GeneralPostingSetup.MODIFY(TRUE);
Member of Lib.Library - ERM


SetGeneralPostingSetupSalesAccounts@166 Method

The procedure SetGeneralPostingSetupSalesAccounts is available in codeunit 131300.

Syntax

SetGeneralPostingSetupSalesAccounts@166(
    VAR GeneralPostingSetup@1000 : Record 252 GeneralPostingSetup //Reference parameter of type Record
);

Parameters

GeneralPostingSetup
Reference parameter of type Record

Remarks

The relevant search keywords are: Set, General, Posting, Setup, Sales, Accounts.

For a clarification about how this function works, refer to the code listed below.

      WITH GeneralPostingSetup DO BEGIN
        IF "Sales Account" = '' THEN
          VALIDATE("Sales Account",CreateGLAccountNo);
        IF "Sales Line Disc. Account" = '' THEN
          VALIDATE("Sales Line Disc. Account",CreateGLAccountNo);
        IF "Sales Inv. Disc. Account" = '' THEN
          VALIDATE("Sales Inv. Disc. Account",CreateGLAccountNo);
        IF "Sales Credit Memo Account" = '' THEN
          VALIDATE("Sales Credit Memo Account",CreateGLAccountNo);
      END;

Example

The below example is extracted from the test automation codeunit 134104 to show one way of using this function.

      LibraryERM.CreateGeneralPostingSetupInvt(GeneralPostingSetup);
      LibraryERM.SetGeneralPostingSetupPrepAccounts(GeneralPostingSetup);
      LibraryERM.SetGeneralPostingSetupSalesAccounts(GeneralPostingSetup);
      LibraryERM.SetGeneralPostingSetupPurchAccounts(GeneralPostingSetup);
      LibraryERM.SetGeneralPostingSetupMfgAccounts(GeneralPostingSetup);
      GeneralPostingSetup.MODIFY(TRUE);
      CreateRelatedZeroVATPostingSetup(VATPostingSetup,VATBusPostingGroupCode);
      UpdateGLAccountWithVATAndGenSetup(GeneralPostingSetup."Sales Prepayments Account",VATPostingSetup,GeneralPostingSetup);
      UpdateGLAccountWithVATAndGenSetup(GeneralPostingSetup."Purch. Prepayments Account",VATPostingSetup,GeneralPostingSetup);
Member of Lib.Library - ERM


SetGeneralPostingSetupSalesPmtDiscAccounts@167 Method

The procedure SetGeneralPostingSetupSalesPmtDiscAccounts is available in codeunit 131300.

Syntax

SetGeneralPostingSetupSalesPmtDiscAccounts@167(
    VAR GeneralPostingSetup@1000 : Record 252 GeneralPostingSetup //Reference parameter of type Record
);

Parameters

GeneralPostingSetup
Reference parameter of type Record

Remarks

The relevant search keywords are: Set, General, Posting, Setup, Sales, Payment, Discount, Accounts.

For a clarification about how this function works, refer to the code listed below.

      WITH GeneralPostingSetup DO BEGIN
        IF "Sales Pmt. Disc. Debit Acc." = '' THEN
          VALIDATE("Sales Pmt. Disc. Debit Acc.",CreateGLAccountNo);
        IF "Sales Pmt. Disc. Credit Acc." = '' THEN
          VALIDATE("Sales Pmt. Disc. Credit Acc.",CreateGLAccountNo);
        IF "Sales Pmt. Tol. Debit Acc." = '' THEN
          VALIDATE("Sales Pmt. Tol. Debit Acc.",CreateGLAccountNo);
        IF "Sales Pmt. Tol. Credit Acc." = '' THEN
          VALIDATE("Sales Pmt. Tol. Credit Acc.",CreateGLAccountNo);
      END;

Example

The below example is extracted from the test automation codeunit 134007 to show one way of using this function.

      GeneralPostingSetup.GET(GenBusPostingGroup,GenProdPostingGroup);
      LibraryERM.SetGeneralPostingSetupPurchPmtDiscAccounts(GeneralPostingSetup);
      LibraryERM.SetGeneralPostingSetupSalesPmtDiscAccounts(GeneralPostingSetup);
      GeneralPostingSetup.MODIFY(TRUE);
Member of Lib.Library - ERM


SetGLAccountDirectPostingFilter@138 Method

The procedure SetGLAccountDirectPostingFilter is available in codeunit 131300.

Syntax

SetGLAccountDirectPostingFilter@138(
    VAR GLAccount@1000 : Record 15 GLAccount //Reference parameter of type Record
);

Parameters

GLAccount
Reference parameter of type Record

Remarks

The relevant search keywords are: Set, General Ledger, Account, Direct, Posting, Filter.

For a clarification about how this function works, refer to the code listed below.

      GLAccount.SETRANGE(Blocked,FALSE);
      GLAccount.SETRANGE("Account Type",GLAccount."Account Type"::Posting);
      GLAccount.SETRANGE("Direct Posting",TRUE);

Example

The below example is extracted from the test automation codeunit 136602 to show one way of using this function.

      // Test batch creation of Journal Lines for G/L Account without filter.

      // 1. Setup: Create General Journal Batch and Standard General Journal.
      Initialize;
      CreateGeneralJournalBatch(GenJournalBatch);
      LibraryERM.CreateStandardGeneralJournal(StandardGeneralJournal,GenJournalBatch."Journal Template Name");

      // 2. Exercise: Run Report Create G/L Acc. Journal Lines with Direct Posting and Account Type as Posting of G/L Account.
      LibraryERM.SetGLAccountDirectPostingFilter(GLAccount);
      RunCreateGLAccountJournalLines(
        GLAccount,
        GenJournalBatch,
        GenJournalLine."Document Type"::" ",
        WORKDATE,
        StandardGeneralJournal.Code);

      // 3. Verify: Verify Number of line in General Journal Line.
      VerifyCountGeneralJournalLine(GenJournalBatch,GLAccount.COUNT);
Member of Lib.Library - ERM


SetGLAccountNotBlankGroupsFilter@144 Method

The procedure SetGLAccountNotBlankGroupsFilter is available in codeunit 131300.

Syntax

SetGLAccountNotBlankGroupsFilter@144(
    VAR GLAccount@1000 : Record 15 GLAccount //Reference parameter of type Record
);

Parameters

GLAccount
Reference parameter of type Record

Remarks

The relevant search keywords are: Set, General Ledger, Account, Not, Blank, Groups, Filter.

For a clarification about how this function works, refer to the code listed below.

      GLAccount.SETFILTER("Gen. Posting Type",'<>%1',GLAccount."Gen. Posting Type"::" ");
      GLAccount.SETFILTER("Gen. Bus. Posting Group",'<>%1','');
      GLAccount.SETFILTER("Gen. Prod. Posting Group",'<>%1','');
      GLAccount.SETFILTER("VAT Prod. Posting Group",'<>%1','');
      GLAccount.SETFILTER("Service Tax Group Code",'=%1','');

Example

There are no examples available.
Member of Lib.Library - ERM


SetGlobalDimensionCode@94 Method

The procedure SetGlobalDimensionCode is available in codeunit 131300.

Syntax

SetGlobalDimensionCode@94(
    DimNo@1000 : Integer DimNo, //Input parameter of type Integer
    DimCode@1001 : Code[20] DimCode //Input parameter of type Code
);

Parameters

DimNo
Input parameter of type Integer
DimCode
Input parameter of type Code

Remarks

The relevant search keywords are: Set, Global, Dimension, Code.

For a clarification about how this function works, refer to the code listed below.

      GeneralLedgerSetup.GET;
      CASE DimNo OF
        1:
          GeneralLedgerSetup.VALIDATE("Global Dimension 1 Code",DimCode);
        2:
          GeneralLedgerSetup.VALIDATE("Global Dimension 2 Code",DimCode);
      END;
      GeneralLedgerSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134263 to show one way of using this function.

      IF LibraryERM.GetGlobalDimensionCode(1) = '' THEN BEGIN
        LibraryDim.CreateDimension(Dimension);
        LibraryERM.SetGlobalDimensionCode(1,Dimension.Code);
        LibraryDim.CreateDimensionValue(DimValue,Dimension.Code);
      END ELSE BEGIN
        DimValue.SETRANGE("Dimension Code",LibraryERM.GetGlobalDimensionCode(1));
        DimValue.SETRANGE("Dimension Value Type",DimValue."Dimension Value Type"::Standard);
        DimValue.SETRANGE(Blocked,FALSE);
        DimValue.FINDFIRST;
      END;
Member of Lib.Library - ERM


SetIntrastatContact@228 Method

The procedure SetIntrastatContact is available in codeunit 131300.

Syntax

SetIntrastatContact@228(
    ContactType@1001 : Option ContactType, //Input parameter of type Option
    ContactNo@1002 : Code[20] ContactNo //Input parameter of type Code
);

Parameters

ContactType
Input parameter of type Option
ContactNo
Input parameter of type Code

Remarks

The relevant search keywords are: Set, Intrastat, Contact.

For a clarification about how this function works, refer to the code listed below.

      CompanyInformation.GET;
      CompanyInformation.VALIDATE("Intrastat Contact Type",ContactType);
      CompanyInformation.VALIDATE("Intrastat Contact No.",ContactNo);
      CompanyInformation.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - ERM


SetInvRoundingPrecisionLCY@55 Method

The procedure SetInvRoundingPrecisionLCY is available in codeunit 131300.

Syntax

SetInvRoundingPrecisionLCY@55(
    InvRoundingPrecisionLCY@1000 : Decimal InvRoundingPrecisionLCY //Input parameter of type Decimal
);

Parameters

InvRoundingPrecisionLCY
Input parameter of type Decimal

Remarks

The relevant search keywords are: Set, Invoice, Rounding, Precision, LCY.

For a clarification about how this function works, refer to the code listed below.

      GeneralLedgerSetup.GET;
      GeneralLedgerSetup.VALIDATE("Inv. Rounding Precision (LCY)",InvRoundingPrecisionLCY);
      GeneralLedgerSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134129 to show one way of using this function.

      LibraryPmtDiscSetup.SetAdjustForPaymentDisc(TRUE);
      LibraryERM.SetInvRoundingPrecisionLCY(0.01);
Member of Lib.Library - ERM


SetLCYCode@185 Method

The procedure SetLCYCode is available in codeunit 131300.

Syntax

SetLCYCode@185(
    LCYCode@1000 : Code[10] LCYCode //Input parameter of type Code
);

Parameters

LCYCode
Input parameter of type Code

Remarks

The relevant search keywords are: Set, LCY, Code.

For a clarification about how this function works, refer to the code listed below.

      GeneralLedgerSetup.GET;
      GeneralLedgerSetup.VALIDATE("LCY Code",LCYCode);
      GeneralLedgerSetup.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - ERM


SetMaxVATDifferenceAllowed@53 Method

The procedure SetMaxVATDifferenceAllowed is available in codeunit 131300.

Syntax

SetMaxVATDifferenceAllowed@53(
    MaxVATDifferenceAllowed@1000 : Decimal MaxVATDifferenceAllowed //Input parameter of type Decimal
);

Parameters

MaxVATDifferenceAllowed
Input parameter of type Decimal

Remarks

The relevant search keywords are: Set, Max, VAT, Difference, Allowed.

For a clarification about how this function works, refer to the code listed below.

      GeneralLedgerSetup.GET;
      GeneralLedgerSetup.VALIDATE("Max. VAT Difference Allowed",MaxVATDifferenceAllowed);
      GeneralLedgerSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134028 to show one way of using this function.

      Result := LibraryRandom.RandDec(2,2);  // Use any Random decimal value between 0.01 and 1.99, value is not important.
      LibraryERM.SetMaxVATDifferenceAllowed(Result);
      IF SalesAndReceivables THEN
        LibrarySales.SetAllowVATDifference(TRUE)
      ELSE
        LibraryPurchase.SetAllowVATDifference(TRUE);
Member of Lib.Library - ERM


SetShortcutDimensionCode@199 Method

The procedure SetShortcutDimensionCode is available in codeunit 131300.

Syntax

SetShortcutDimensionCode@199(
    DimNo@1000 : Integer DimNo, //Input parameter of type Integer
    DimCode@1001 : Code[20] DimCode //Input parameter of type Code
);

Parameters

DimNo
Input parameter of type Integer
DimCode
Input parameter of type Code

Remarks

The relevant search keywords are: Set, Shortcut, Dimension, Code.

For a clarification about how this function works, refer to the code listed below.

      GeneralLedgerSetup.GET;
      CASE DimNo OF
        1:
          GeneralLedgerSetup.VALIDATE("Shortcut Dimension 1 Code",DimCode);
        2:
          GeneralLedgerSetup.VALIDATE("Shortcut Dimension 2 Code",DimCode);
        3:
          GeneralLedgerSetup.VALIDATE("Shortcut Dimension 3 Code",DimCode);
        4:
          GeneralLedgerSetup.VALIDATE("Shortcut Dimension 4 Code",DimCode);
        5:
          GeneralLedgerSetup.VALIDATE("Shortcut Dimension 5 Code",DimCode);
        6:
          GeneralLedgerSetup.VALIDATE("Shortcut Dimension 6 Code",DimCode);
        7:
          GeneralLedgerSetup.VALIDATE("Shortcut Dimension 7 Code",DimCode);
        8:
          GeneralLedgerSetup.VALIDATE("Shortcut Dimension 8 Code",DimCode);
      END;
      GeneralLedgerSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134141 to show one way of using this function.

      FOR i := 1 TO 8 DO BEGIN
        LibraryDimension.CreateDimWithDimValue(DimensionValue);
        LibraryERM.SetShortcutDimensionCode(i,DimensionValue."Dimension Code");
      END;
Member of Lib.Library - ERM


SetUnrealizedVAT@34 Method

The procedure SetUnrealizedVAT is available in codeunit 131300.

Syntax

SetUnrealizedVAT@34(
    UnrealizedVAT@1001 : Boolean UnrealizedVAT //Input parameter of type Boolean
);

Parameters

UnrealizedVAT
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, Unrealized, VAT.

For a clarification about how this function works, refer to the code listed below.

      GeneralLedgerSetup.GET;
      GeneralLedgerSetup.VALIDATE("Unrealized VAT",UnrealizedVAT);
      GeneralLedgerSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134008 to show one way of using this function.

      // [FEATURE] [Unrealized VAT] [Adjust For Payment Discount]
      // [SCENARIO 371480] Single corrective VAT Entry for Invoice should be created when unapply payment with Unrealized VAT and Adjust For Payment Discount

      Initialize;
      // [GIVEN] Invoice with Unrealized VAT ("VAT Base" = "X", "VAT Amount" = "Y") and Adjust For Payment Discount
      LibraryERM.SetUnrealizedVAT(TRUE);
      GLAccount.GET(CreateGLAccountWithUnrealizedVAT);
      PrepareSetupWithAdjForPmtDiscount(
        CustomerNo,OldAdjustForPaymentDiscount,GLAccount);
      CreateGenJournalLineWithBalanceAcc(
        GenJournalLine,GenJournalLine."Document Type"::Invoice,GenJournalLine."Account Type"::Customer,CustomerNo,
        GenJournalLine."Bal. Account Type"::"G/L Account",GLAccount."No.",1);
      LibraryERM.PostGeneralJnlLine(GenJournalLine);
      InvUnrealVATEntryNo := FindVATEntry(GenJournalLine."Document Type",GenJournalLine."Document No.");
      VATBase := GenJournalLine."Bal. VAT Base Amount";
      VATAmount := GenJournalLine."Bal. VAT Amount";
      // [GIVEN] Payment applied to Invoice
      PostApplyPaymentToInvoice(CustLedgerEntry,CustomerNo,GenJournalLine."Document No.",GenJournalLine."Document Type"::Invoice);

      // [WHEN] Unapply Payment
      LibraryERM.UnapplyCustomerLedgerEntry(CustLedgerEntry);

      // [THEN] Single corrective VAT Entry created with "Base" = -"X", "Amount" = "-Y"
      VerifySingleCorrectiveVATEntry(
        CustLedgerEntry."Document Type",CustLedgerEntry."Document No.",InvUnrealVATEntryNo,
        -VATBase,-VATAmount);

      // TearDown.
      UpdateVATPostingSetup(GLAccount,OldAdjustForPaymentDiscount);
Member of Lib.Library - ERM


SetupReportSelection@211 Method

The procedure SetupReportSelection is available in codeunit 131300.

Syntax

SetupReportSelection@211(
    ReportUsage@1001 : Option ReportUsage, //Input parameter of type Option
    ReportId@1002 : Integer ReportId //Input parameter of type Integer
);

Parameters

ReportUsage
Input parameter of type Option
ReportId
Input parameter of type Integer

Remarks

The relevant search keywords are: Setup, Report, Selection.

For a clarification about how this function works, refer to the code listed below.

      ReportSelections.SETRANGE(Usage,ReportUsage);
      ReportSelections.DELETEALL;
      ReportSelections.INIT;
      ReportSelections.VALIDATE(Usage,ReportUsage);
      ReportSelections.VALIDATE(Sequence,'1');
      ReportSelections.VALIDATE("Report ID",ReportId);
      ReportSelections.INSERT(TRUE);

Example

There are no examples available.
Member of Lib.Library - ERM


SetUseLegacyGLEntryLocking@193 Method

The procedure SetUseLegacyGLEntryLocking is available in codeunit 131300.

Syntax

SetUseLegacyGLEntryLocking@193(
    UseLegacyGLEntryLocking@1000 : Boolean UseLegacyGLEntryLocking //Input parameter of type Boolean
);

Parameters

UseLegacyGLEntryLocking
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, Use, Legacy, General Ledger, Entry, Locking.

For a clarification about how this function works, refer to the code listed below.

      GeneralLedgerSetup.GET;
      GeneralLedgerSetup."Use Legacy G/L Entry Locking" := UseLegacyGLEntryLocking;
      GeneralLedgerSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134101 to show one way of using this function.

      // [FEATURE] [Sales] [FCY]
      // [SCENARIO 243217] GL Entry after Posting Prepayment Sales Invoice with Currency.

      // [GIVEN] Update General Ledger, Inventory Setup and Create Sales Prepayment Invoice.
      Initialize;
      LibraryERM.SetUseLegacyGLEntryLocking(TRUE);
      InventorySetup.GET;
      UpdateInventorySetup(TRUE,InventorySetup."Automatic Cost Adjustment"::Always);
      GLAccountNo := SetupAndCreateSalesPrepayment(SalesLine,LibraryRandom.RandDec(10,2));

      // [WHEN] Post Sales Prepayment Invoice
      SalesHeader.GET(SalesLine."Document Type",SalesLine."Document No.");
      AmountLCY := ROUND(LibraryERM.ConvertCurrency(SalesLine."Prepmt. Line Amount",SalesHeader."Currency Code",'',WORKDATE));
      DocumentNo := GetPostedDocumentNo(SalesHeader."Prepayment No. Series");
      LibrarySales.PostSalesPrepaymentInvoice(SalesHeader);

      // [THEN] Verify GL Entry Amount after Conversion with Currency Exchange Rate.
      VerifyGLEntry(DocumentNo,GLAccountNo,-AmountLCY);

      // Tear Down.
      UpdateInventorySetup(InventorySetup."Automatic Cost Posting",InventorySetup."Automatic Cost Adjustment");
Member of Lib.Library - ERM


SetVATRoundingType@31 Method

The procedure SetVATRoundingType is available in codeunit 131300.

Syntax

SetVATRoundingType@31(
    Direction@1000 : Text[1] Direction //Input parameter of type Text
);

Parameters

Direction
Input parameter of type Text

Remarks

The relevant search keywords are: Set, VAT, Rounding, Type.

For a clarification about how this function works, refer to the code listed below.

      GeneralLedgerSetup.GET;
      CASE Direction OF
        '<':
          GeneralLedgerSetup."VAT Rounding Type" := GeneralLedgerSetup."VAT Rounding Type"::Down;
        '>':
          GeneralLedgerSetup."VAT Rounding Type" := GeneralLedgerSetup."VAT Rounding Type"::Up;
        '=':
          GeneralLedgerSetup."VAT Rounding Type" := GeneralLedgerSetup."VAT Rounding Type"::Nearest;
      END;
      GeneralLedgerSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134040 to show one way of using this function.

      // Setup:
      LibraryERM.SetVATRoundingType(VATRoundingDirection);
      // Exercise: Create Sales Document for two different VAT Posting Groups and calculate VAT Amount.
      CreateVATSalesDocument(SalesHeader,TempSalesLine,DocumentType,CurrencyCode);
      SalesLine.CalcVATAmountLines(QtyType::General,SalesHeader,TempSalesLine,VATAmountLine);

      // Verify: Verify VAT Amount field on Sales Document Statistics (VAT Amount Line Table) with GL VAT Rounding.
      TempSalesLine.FINDSET;
      REPEAT
        VerifyVATOnStatistics(
          TempSalesLine."VAT %",RoundVATAmount(TempSalesLine."Line Amount" * TempSalesLine."VAT %" / 100,RoundingType));
      UNTIL TempSalesLine.NEXT = 0;
Member of Lib.Library - ERM


SetWorkDate@145 Method

The procedure SetWorkDate is available in codeunit 131300.

Syntax

SetWorkDate@145(
      //param element not supplied
);

Remarks

The relevant search keywords are: Set, Work, Date.

For a clarification about how this function works, refer to the code listed below.

      // Set workdate to date of last transaction or today
      GLEntry.SETCURRENTKEY("G/L Account No.","Posting Date");
      OK := TRUE;
      REPEAT
        GLEntry.SETFILTER("G/L Account No.",'>%1',GLEntry."G/L Account No.");
        GLEntry.SETFILTER("Posting Date",'>%1',GLEntry."Posting Date");
        IF GLEntry.FINDFIRST THEN BEGIN
          GLEntry.SETRANGE("G/L Account No.",GLEntry."G/L Account No.");
          GLEntry.SETRANGE("Posting Date");
          GLEntry.FINDLAST;
        END ELSE
          OK := FALSE
      UNTIL NOT OK;

      IF GLEntry."Posting Date" = 0D THEN
        WORKDATE := TODAY
      ELSE
        WORKDATE := NORMALDATE(GLEntry."Posting Date");

Example

The below example is extracted from the test automation codeunit 137156 to show one way of using this function.

      LibrarySetupStorage.Restore;
      LibraryVariableStorage.Clear;
      LibraryERM.SetWorkDate; // IT.

      // Lazy Setup.
      IF isInitialized THEN
        EXIT;

      LibraryERMCountryData.UpdateGeneralLedgerSetup;
      LibraryERMCountryData.CreateVATData;
      LibraryERMCountryData.UpdatePurchasesPayablesSetup;
      LibraryERMCountryData.CreateGeneralPostingSetupData;
      LibraryERMCountryData.UpdateGeneralPostingSetup;
      LibraryERMCountryData.UpdateSalesReceivablesSetup; // GB.

      NoSeriesSetup;
      ItemJournalSetup;
      LocationSetup;

      isInitialized := TRUE;
      COMMIT;
      LibrarySetupStorage.Save(DATABASE::"General Ledger Setup");
      LibrarySetupStorage.Save(DATABASE::"Inventory Setup");
      LibrarySetupStorage.Save(DATABASE::"Sales & Receivables Setup");
Member of Lib.Library - ERM


SuggestBankAccountReconciliation@331 Method

The procedure SuggestBankAccountReconciliation is available in codeunit 131300.

Syntax

SuggestBankAccountReconciliation@331(
    VAR BankAccReconciliation@1000 : Record 273 BankAccReconciliation, //Reference parameter of type Record
    BankAccount@1001 : Record 270 BankAccount, //Input parameter of type Record
    StatementType@1003 : Option StatementType, //Input parameter of type Option
    IncludeChecks@1004 : Boolean IncludeChecks //Input parameter of type Boolean
);

Parameters

BankAccReconciliation
Reference parameter of type Record
BankAccount
Input parameter of type Record
StatementType
Input parameter of type Option
IncludeChecks
Input parameter of type Boolean

Remarks

The relevant search keywords are: Suggest, Bank, Account, Reconciliation.

For a clarification about how this function works, refer to the code listed below.

      CreateBankAccReconciliation(BankAccReconciliation,BankAccount."No.",StatementType);

      SuggestBankAccReconLines.SetStmt(BankAccReconciliation);
      SuggestBankAccReconLines.SETTABLEVIEW(BankAccount);
      SuggestBankAccReconLines.InitializeRequest(WORKDATE,WORKDATE,IncludeChecks);
      SuggestBankAccReconLines.USEREQUESTPAGE(FALSE);

      SuggestBankAccReconLines.RUN;

Example

There are no examples available.
Member of Lib.Library - ERM


UnapplyCustomerLedgerEntry@27 Method

The procedure UnapplyCustomerLedgerEntry is available in codeunit 131300.

Syntax

UnapplyCustomerLedgerEntry@27(
    CustLedgerEntry@1000 : Record 21 CustLedgerEntry //Input parameter of type Record
);

Parameters

CustLedgerEntry
Input parameter of type Record

Remarks

The relevant search keywords are: Unapply, Customer, Ledger, Entry.

For a clarification about how this function works, refer to the code listed below.

      LibraryERMUnapply.UnapplyCustomerLedgerEntry(CustLedgerEntry);

Example

The below example is extracted from the test automation codeunit 134000 to show one way of using this function.

      LibraryERM.FindCustomerLedgerEntry(CustLedgerEntry,DocumentType,DocumentNo);
      LibraryERM.UnapplyCustomerLedgerEntry(CustLedgerEntry);
Member of Lib.Library - ERM


UnapplyVendorLedgerEntry@21 Method

The procedure UnapplyVendorLedgerEntry is available in codeunit 131300.

Syntax

UnapplyVendorLedgerEntry@21(
    VendorLedgerEntry@1001 : Record 25 VendorLedgerEntry //Input parameter of type Record
);

Parameters

VendorLedgerEntry
Input parameter of type Record

Remarks

The relevant search keywords are: Unapply, Vendor, Ledger, Entry.

For a clarification about how this function works, refer to the code listed below.

      LibraryERMUnapply.UnapplyVendorLedgerEntry(VendorLedgerEntry);

Example

The below example is extracted from the test automation codeunit 134007 to show one way of using this function.

      // Verify that no VAT are entries creates when unapplies the entry without discount but with "Adjust For Payment Discount"

      // Setup: Set "Adjust For Payment Discount" option.
      Initialize;
      LibraryPmtDiscSetup.SetAdjustForPaymentDisc(TRUE);
      EmptyDocumentType := 0;

      // Exercise: Find and modify Reverse Charge VAT posting setup with "Adjust For Payment Disc." and post invoice.
      PostedDocumentNo :=
        CreatePostPurchInvWithReverseChargeVATAdjForPmtDisc(PurchLine);
      LibraryERM.FindVendorLedgerEntry(VendLedgEntry,VendLedgEntry."Document Type"::Invoice,PostedDocumentNo);
      VendLedgEntry.CALCFIELDS("Amount (LCY)");

      // Exercise: Post and apply document with empty type.
      CreateGenJnlLineWithPostingGroups(GenJnlLine,PurchLine."Pay-to Vendor No.",EmptyDocumentType,
        -VendLedgEntry."Amount (LCY)",PurchLine);
      GenJnlLine.VALIDATE("Applies-to Doc. Type",GenJnlLine."Applies-to Doc. Type"::Invoice);
      GenJnlLine.VALIDATE("Applies-to Doc. No.",PostedDocumentNo);
      GenJnlLine.MODIFY(TRUE);
      LibraryERM.PostGeneralJnlLine(GenJnlLine);

      // Exericse: Unapply the empty document application.
      LibraryERM.FindVendorLedgerEntry(VendLedgEntry,EmptyDocumentType,GenJnlLine."Document No.");
      LibraryERM.UnapplyVendorLedgerEntry(VendLedgEntry);

      // Verify: Make sure that no entries have been created on unapplication.
      VerifyNoVATEntriesOnUnapplication(EmptyDocumentType,GenJnlLine."Document No.");

      // Tear Down: Return back the old value of "Adjust For Payment Discount".
      LibraryPmtDiscSetup.ClearAdjustPmtDiscInVATSetup;
Member of Lib.Library - ERM


UpdateAnalysisView@128 Method

The procedure UpdateAnalysisView is available in codeunit 131300.

Syntax

UpdateAnalysisView@128(
    VAR AnalysisView@1000 : Record 363 AnalysisView //Reference parameter of type Record
);

Parameters

AnalysisView
Reference parameter of type Record

Remarks

The relevant search keywords are: Update, Analysis, View.

For a clarification about how this function works, refer to the code listed below.

      CODEUNIT.RUN(CODEUNIT::"Update Analysis View",AnalysisView)

Example

The below example is extracted from the test automation codeunit 134480 to show one way of using this function.

      // [SCENARIO 381290] Check quantity of records in G/L Entries Dimension Overview Matrix opened for selected Posted General Lines
      Initialize;

      // [GIVEN] G/L Account "GLACC" with a new Dimension "DIM" with a Dimension Value "DV"
      // [GIVEN] Analysis View "AV" with the source of G/L Account and with "DIM" and "GLACC"
      LibraryERM.CreateGLAccount(GLAccount);
      LibraryDimension.CreateDimWithDimValue(DimensionValue);
      LibraryERM.CreateAnalysisView(AnalysisView);
      UpdateDimensionInAnalysisView(AnalysisView,GLAccount."No.",DimensionValue."Dimension Code");

      // [GIVEN] A 3 Gen. Journal Lines posted with "GLACC" and "DIM"
      NoOfGLEntries := LibraryRandom.RandIntInRange(2,10);
      LibraryVariableStorage.Enqueue(NoOfGLEntries);
      CreatePostJournalLinesWithDimension(DimensionValue,GLAccount."No.",NoOfGLEntries);

      // [GIVEN] "AV" is updated with codeunit "Update Analysis View"
      LibraryERM.UpdateAnalysisView(AnalysisView);

      // [WHEN] G/L Entries Dimension Overview Matrix Page is opened for Analysis View "AV"
      AnalysisViewList.OPENVIEW;
      AnalysisViewList.GOTORECORD(AnalysisView);
      AnalysisbyDimensions.TRAP;
      AnalysisViewList.EditAnalysis.INVOKE;

      // [THEN] GL Entries Dimension Overview Matrix Page shows 3 entries through GLEntriesDimOvervMatrixVerifyCountPageHandler
      AnalysisbyDimensions.ShowMatrix.INVOKE;
Member of Lib.Library - ERM


UpdateGenPostingSetupPrepmtAccounts@160 Method

The procedure UpdateGenPostingSetupPrepmtAccounts is available in codeunit 131300.

Syntax

UpdateGenPostingSetupPrepmtAccounts@160(
    VAR GeneralPostingSetup@1000 : Record 252 GeneralPostingSetup //Reference parameter of type Record
);

Parameters

GeneralPostingSetup
Reference parameter of type Record

Remarks

The relevant search keywords are: Update, General, Posting, Setup, Prepmt, Accounts.

For a clarification about how this function works, refer to the code listed below.

      GeneralPostingSetup.VALIDATE("Sales Prepayments Account",CreateGLAccountWithSalesSetup);
      GeneralPostingSetup.VALIDATE("Purch. Prepayments Account",CreateGLAccountWithPurchSetup);
      GeneralPostingSetup.MODIFY;

Example

There are no examples available.
Member of Lib.Library - ERM


UpdateGLAccountWithPostingSetup@246 Method

The procedure UpdateGLAccountWithPostingSetup is available in codeunit 131300.

Syntax

UpdateGLAccountWithPostingSetup@246(
    VAR GLAccount@1000 : Record 15 GLAccount, //Reference parameter of type Record
    GenPostingType@1004 : Option GenPostingType, //Input parameter of type Option
    GeneralPostingSetup@1001 : Record 252 GeneralPostingSetup, //Input parameter of type Record
    VATPostingSetup@1003 : Record 325 VATPostingSetup //Input parameter of type Record
);

Parameters

GLAccount
Reference parameter of type Record
GenPostingType
Input parameter of type Option
GeneralPostingSetup
Input parameter of type Record
VATPostingSetup
Input parameter of type Record

Remarks

The relevant search keywords are: Update, General Ledger, Account, Posting, Setup.

For a clarification about how this function works, refer to the code listed below.

      WITH GLAccount DO BEGIN
        VALIDATE("Gen. Posting Type",GenPostingType);
        VALIDATE("Gen. Bus. Posting Group",GeneralPostingSetup."Gen. Bus. Posting Group");
        VALIDATE("Gen. Prod. Posting Group",GeneralPostingSetup."Gen. Prod. Posting Group");
        VALIDATE("VAT Bus. Posting Group",VATPostingSetup."VAT Bus. Posting Group");
        VALIDATE("VAT Prod. Posting Group",VATPostingSetup."VAT Prod. Posting Group");
        MODIFY(TRUE);
      END;

Example

The below example is extracted from the test automation codeunit 134041 to show one way of using this function.

      // [FEATURE] [Unapply] [Sales] [Payment Discount] [Payment Discount Tolerance]
      // [SCENARIO 376166] The equal VAT Amount from Payment Tolerance and Payment Discount should be adjusted correctly on unapplication with multiple invoices

      Initialize;
      SetupUnapplyPaymentWithPaymentToleranceScenario(
        Customer,
        GeneralPostingSetup,
        VATPostingSetup,
        VATPostingSetup."VAT Calculation Type"::"Normal VAT",
        10);

      PmtPostingDate := LibraryRandom.RandDate(10);
      LibraryERM.CreateGLAccount(GLAccount);
      LibraryERM.UpdateGLAccountWithPostingSetup(
        GLAccount,GLAccount."Gen. Posting Type"::Sale,GeneralPostingSetup,VATPostingSetup);

      // [GIVEN] Posted invoices with total amount of "Payment Tolerance" = 180 and "Payment Discount" = 180
      // "Payment Tolerance" = 30 + 60 + 90; "Payment Discount" = 60; "Payment Discount Tolerance" = 120
      CreateFixedSalesInvWithPmtDiscTol(Customer."No.",GLAccount."No.",PmtPostingDate + 1,PmtPostingDate + 2,1200,60,10,FALSE);
      CreateFixedSalesInvWithPmtDiscTol(Customer."No.",GLAccount."No.",PmtPostingDate - 1,PmtPostingDate + 1,2400,120,10,TRUE);
      CreateFixedSalesInvWithPmtDiscTol(Customer."No.",GLAccount."No.",PmtPostingDate - 1,PmtPostingDate - 1,3600,180,200,FALSE);

      // [GIVEN] Posted payment applied to all invoices
      CreateFixedGenJnlLinePaymentWithApplToMultipleInvoices(
        GenJnlLine,PmtPostingDate,GenJnlLine."Account Type"::Customer,Customer."No.",-6840);
      ApplyAndPostPmtToMultipleSalesInvoices(CustLedgEntry,GenJnlLine);

      // [WHEN] Unapply payment
      LibraryERM.UnapplyCustomerLedgerEntry(CustLedgEntry);

      // [THEN] Total VAT Amount of adjusted VAT on "Payment Tolerance" and "Payment Discount" = -360
      VerifyUnappliedCustomerVATEntries(GenJnlLine."Document Type",GenJnlLine."Document No.",-360);

      LibraryPmtDiscSetup.ClearAdjustPmtDiscInVATSetup;
Member of Lib.Library - ERM


UpdateVATPostingSetup@153 Method

The procedure UpdateVATPostingSetup is available in codeunit 131300.

Syntax

UpdateVATPostingSetup@153(
    VAR VATPostingSetup@1000 : Record 325 VATPostingSetup, //Reference parameter of type Record
    VATPercent@1001 : Integer VATPercent //Input parameter of type Integer
);

Parameters

VATPostingSetup
Reference parameter of type Record
VATPercent
Input parameter of type Integer

Remarks

The relevant search keywords are: Update, VAT, Posting, Setup.

For a clarification about how this function works, refer to the code listed below.

      FindVATPostingSetup(VATPostingSetup,VATPostingSetup."VAT Calculation Type"::"Normal VAT");
      // VATPostingSetup."VAT %" := VATPercent;
      VATPostingSetup."VAT %" := 0;
      VATPostingSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134030 to show one way of using this function.

      IF isInitialized THEN
        EXIT;
      LibraryERMCountryData.CreateVATData;
      LibraryERMCountryData.UpdateSalesReceivablesSetup;
      LibraryERMCountryData.UpdateGeneralPostingSetup;
      LibraryERMCountryData.UpdateVATPostingSetup;
      isInitialized := TRUE;
      COMMIT;
Member of Lib.Library - ERM


VATAmountRounding@7 Method

The procedure VATAmountRounding is available in codeunit 131300.

Syntax

VATAmountRounding@7(
    VATAmount@1001 : Decimal VATAmount, //Input parameter of type Decimal
    CurrencyCode@1000 : Code[10] CurrencyCode //Input parameter of type Code
);

Parameters

VATAmount
Input parameter of type Decimal
CurrencyCode
Input parameter of type Code

Return Value

Decimal

Remarks

The relevant search keywords are: VAT, Amount, Rounding.

For a clarification about how this function works, refer to the code listed below.

      // Round VAT Entry Amount.
      Currency.InitRoundingPrecision;
      IF CurrencyCode <> '' THEN
        Currency.GET(CurrencyCode);

      EXIT(ROUND(VATAmount,Currency."Amount Rounding Precision",Currency.VATRoundingDirection));

Example

The below example is extracted from the test automation codeunit 134026 to show one way of using this function.

      // Verify General Ledger Register for Unrealized VAT Entry.
      GLEntry.SETRANGE("Document No.",GenJournalLine."Document No.");
      GLEntry.SETRANGE("Bal. Account No.",VATPostingSetup."Purch. VAT Unreal. Account");
      GLEntry.FINDLAST;
      UnrealizedVATAmount :=
        LibraryERM.VATAmountRounding(
          GenJournalLine."Amount (LCY)" * VATPostingSetup."VAT %" / (100 + VATPostingSetup."VAT %"),GenJournalLine."Currency Code");
      Assert.AreNearlyEqual(
        UnrealizedVATAmount,GLEntry.Amount,LibraryERM.GetAmountRoundingPrecision,GLEntry.FIELDCAPTION(Amount));
Member of Lib.Library - ERM


VerifyCustApplnWithZeroTransNo@100 Method

The procedure VerifyCustApplnWithZeroTransNo is available in codeunit 131300.

Syntax

VerifyCustApplnWithZeroTransNo@100(
    DocumentNo@1002 : Code[20] DocumentNo, //Input parameter of type Code
    DocumentType@1001 : Option DocumentType, //Input parameter of type Option
    AmountLCY@1000 : Decimal AmountLCY //Input parameter of type Decimal
);

Parameters

DocumentNo
Input parameter of type Code
DocumentType
Input parameter of type Option
AmountLCY
Input parameter of type Decimal

Remarks

The relevant search keywords are: Verify, Customer, Application, Zero, Transaction, No.

For a clarification about how this function works, refer to the code listed below.

      DtldCustLedgEntry.SETRANGE("Document Type",DocumentType);
      DtldCustLedgEntry.SETRANGE("Document No.",DocumentNo);
      DtldCustLedgEntry.SETRANGE("Entry Type",DtldCustLedgEntry."Entry Type"::Application);
      DtldCustLedgEntry.FINDLAST;
      DtldCustLedgEntry.TESTFIELD("Transaction No.",0);
      DtldCustLedgEntry.TESTFIELD("Application No.");
      DtldCustLedgEntry.TESTFIELD("Amount (LCY)",AmountLCY);

Example

The below example is extracted from the test automation codeunit 134015 to show one way of using this function.

      // 1. Setup: Update Unrealized VAT as True on General Ledger Setup, VAT Posting Setup with Unrealized VAT Type as parameter.
      // Create and post Sales Credit Memo.
      Initialize;
      LibraryERM.FindUnrealVATPostingSetup(VATPostingSetup,UnrealizedVATType);
      UpdateVATPostingSetup(VATPostingSetup,FALSE);

      LibrarySales.CreateSalesHeader(
        SalesHeader,SalesHeader."Document Type"::"Credit Memo",CreateCustomer(VATPostingSetup."VAT Bus. Posting Group"));
      LibrarySales.CreateSalesLine(
        SalesLine,SalesHeader,SalesLine.Type::Item,CreateItem(VATPostingSetup."VAT Prod. Posting Group"),
        LibraryRandom.RandDec(10,2));  // Use Random for Quantity.

      Amount := SalesLine.Quantity * SalesLine."Unit Price" * (1 + SalesLine."VAT %" / 100);
      DocumentNo := LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      // 2. Exercise: Create and post General Journal Line with Document Type as Refund and apply it on Credit Memo.
      // 2 is required for partial Refund.
      CreateAndPostGeneralJournal(
        GenJournalLine,GenJournalLine."Account Type"::Customer,SalesHeader."Sell-to Customer No.",'',Amount / 2);
      ApplyAndPostCustomerEntry(CustLedgerEntry."Document Type"::Refund,DocumentNo,GenJournalLine."Document No.");

      // 3. Verify: Verify Dtld Customer Ledger Entry after apply Refund on Credit Memo.
      LibraryERM.VerifyCustApplnWithZeroTransNo(
        GenJournalLine."Document No.",GLEntry."Document Type"::Refund,-GenJournalLine."Amount (LCY)");
Member of Lib.Library - ERM


VerifyVendApplnWithZeroTransNo@102 Method

The procedure VerifyVendApplnWithZeroTransNo is available in codeunit 131300.

Syntax

VerifyVendApplnWithZeroTransNo@102(
    DocumentNo@1002 : Code[20] DocumentNo, //Input parameter of type Code
    DocumentType@1001 : Option DocumentType, //Input parameter of type Option
    AmountLCY@1000 : Decimal AmountLCY //Input parameter of type Decimal
);

Parameters

DocumentNo
Input parameter of type Code
DocumentType
Input parameter of type Option
AmountLCY
Input parameter of type Decimal

Remarks

The relevant search keywords are: Verify, Vendor, Application, Zero, Transaction, No.

For a clarification about how this function works, refer to the code listed below.

      DtldVendLedgEntry.SETRANGE("Document Type",DocumentType);
      DtldVendLedgEntry.SETRANGE("Document No.",DocumentNo);
      DtldVendLedgEntry.SETRANGE("Entry Type",DtldVendLedgEntry."Entry Type"::Application);
      DtldVendLedgEntry.FINDLAST;
      DtldVendLedgEntry.TESTFIELD("Transaction No.",0);
      DtldVendLedgEntry.TESTFIELD("Application No.");
      DtldVendLedgEntry.TESTFIELD("Amount (LCY)",AmountLCY);

Example

The below example is extracted from the test automation codeunit 134015 to show one way of using this function.

      // 1. Setup: Update Unrealized VAT as True on General Ledger Setup, VAT Posting Setup with Unrealized VAT Type Last.
      // Create and post Purchase Credit Memo with currency.
      Initialize;
      LibraryERM.FindUnrealVATPostingSetup(VATPostingSetup,UnrealizedVATType);
      UpdateVATPostingSetup(VATPostingSetup,FALSE);

      LibraryPurchase.CreatePurchHeader(
        PurchaseHeader,PurchaseHeader."Document Type"::"Credit Memo",CreateVendor(VATPostingSetup."VAT Bus. Posting Group"));

      LibraryPurchase.CreatePurchaseLine(
        PurchaseLine,PurchaseHeader,PurchaseLine.Type::Item,CreateItem(VATPostingSetup."VAT Prod. Posting Group"),
        LibraryRandom.RandDec(10,2));

      UpdatePurchaseHeader(PurchaseHeader,CurrencyCode);

      Amount := PurchaseLine.Quantity * PurchaseLine."Direct Unit Cost" * (1 + PurchaseLine."VAT %" / 100);
      DocumentNo := LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

      // 2. Exercise: Create and post General Journal Line with Document Type as Refund with different Currency and apply it on Credit
      // Memo. 2 is required for partial Refund.
      CreateAndPostGeneralJournal(
        GenJournalLine,GenJournalLine."Account Type"::Vendor,PurchaseHeader."Buy-from Vendor No.",CurrencyCode2,
        -LibraryERM.ConvertCurrency(Amount,'',CurrencyCode,WORKDATE) / 2);
      ApplyAndPostVendorEntry(VendorLedgerEntry."Document Type"::Refund,DocumentNo,GenJournalLine."Document No.");

      // 3. Verify: Verify Dtld Vendor Ledger Entry after apply Refund on Credit Memo.
      LibraryERM.VerifyVendApplnWithZeroTransNo(
        GenJournalLine."Document No.",GLEntry."Document Type"::Refund,-GenJournalLine."Amount (LCY)");
Member of Lib.Library - ERM


Library - ERM Country Data Class

Lib.Library - ERM Country Data

COD131305 applies to ERM,W1,IN.
Procedures to create demo data present in W1 but missing in countries

Methods

Name | Description
CreateGeneralPostingSetupData@10 | The procedure CreateGeneralPostingSetupData is available in codeunit 131305.
CreateGLAccountForPrepayment@1120000 | The procedure CreateGLAccountForPrepayment is available in codeunit 131305.
CreateNewFiscalYear@16 | The procedure CreateNewFiscalYear is available in codeunit 131305.
CreateTransportMethodTableData@23 | The procedure CreateTransportMethodTableData is available in codeunit 131305.
CreateUnitsOfMeasure@12 | The procedure CreateUnitsOfMeasure is available in codeunit 131305.
CreateVATData@18 | The procedure CreateVATData is available in codeunit 131305.
DisableActivateChequeNoOnGeneralLedgerSetup@22 | The procedure DisableActivateChequeNoOnGeneralLedgerSetup is available in codeunit 131305.
InitializeCountry@20 | The procedure InitializeCountry is available in codeunit 131305.
RemoveBlankGenJournalTemplate@24 | The procedure RemoveBlankGenJournalTemplate is available in codeunit 131305.
SetupCostAccounting@19 | The procedure SetupCostAccounting is available in codeunit 131305.
UpdateAccountInCustomerPostingGroup@1 | The procedure UpdateAccountInCustomerPostingGroup is available in codeunit 131305.
UpdateAccountInServiceCosts@4 | The procedure UpdateAccountInServiceCosts is available in codeunit 131305.
UpdateAccountInVendorPostingGroups@2 | The procedure UpdateAccountInVendorPostingGroups is available in codeunit 131305.
UpdateAccountsInServiceContractAccountGroups@3 | The procedure UpdateAccountsInServiceContractAccountGroups is available in codeunit 131305.
UpdateCalendarSetup@9 | The procedure UpdateCalendarSetup is available in codeunit 131305.
UpdateFAJnlTemplateName@21 | The procedure UpdateFAJnlTemplateName is available in codeunit 131305.
UpdateFAPostingGroup@15 | The procedure UpdateFAPostingGroup is available in codeunit 131305.
UpdateFAPostingType@27 | The procedure UpdateFAPostingType is available in codeunit 131305.
UpdateGeneralLedgerSetup@11 | The procedure UpdateGeneralLedgerSetup is available in codeunit 131305.
UpdateGeneralPostingSetup@5 | The procedure UpdateGeneralPostingSetup is available in codeunit 131305.
UpdateGenJournalTemplate@6 | The procedure UpdateGenJournalTemplate is available in codeunit 131305.
UpdateGenProdPostingGroup@13 | The procedure UpdateGenProdPostingGroup is available in codeunit 131305.
UpdateInventoryPostingSetup@140 | The procedure UpdateInventoryPostingSetup is available in codeunit 131305.
UpdateLocalData@26 | The procedure UpdateLocalData is available in codeunit 131305.
UpdateLocalPostingSetup@25 | The procedure UpdateLocalPostingSetup is available in codeunit 131305.
UpdatePrepaymentAccounts@14 | The procedure UpdatePrepaymentAccounts is available in codeunit 131305.
UpdatePurchasesPayablesSetup@7 | The procedure UpdatePurchasesPayablesSetup is available in codeunit 131305.
UpdateSalesReceivablesSetup@8 | The procedure UpdateSalesReceivablesSetup is available in codeunit 131305.
UpdateVATPostingSetup@17 | The procedure UpdateVATPostingSetup is available in codeunit 131305.

See Also

Lib


CreateGeneralPostingSetupData@10 Method

The procedure CreateGeneralPostingSetupData is available in codeunit 131305.

Syntax

CreateGeneralPostingSetupData@10(
      //param element not supplied
);

Remarks

The relevant search keywords are: Create, General, Posting, Setup, Data.

For a clarification about how this function works, refer to the code listed below.

      CreateMissingGeneralPostingSetup;

Example

The below example is extracted from the test automation codeunit 134382 to show one way of using this function.

      LibraryVariableStorage.Clear;

      // Lazy Setup.
      IF isInitialized THEN
        EXIT;

      ClearDimensionPriority;
      LibraryERMCountryData.UpdateGeneralLedgerSetup;
      LibraryERMCountryData.CreateVATData;
      LibraryERMCountryData.UpdatePurchasesPayablesSetup;
      LibraryERMCountryData.CreateGeneralPostingSetupData;
      LibraryERMCountryData.UpdateGeneralPostingSetup;
      LibraryERMCountryData.UpdateLocalPostingSetup;
      isInitialized := TRUE;
      COMMIT;
Member of Lib.Library - ERM Country Data


CreateGLAccountForPrepayment@1120000 Method

The procedure CreateGLAccountForPrepayment is available in codeunit 131305.

Syntax

CreateGLAccountForPrepayment@1120000(
    GenBusPostingGroup@1120000 : Code[10] GenBusPostingGroup, //Input parameter of type Code
    GenProdPostingGroup@1120001 : Code[10] GenProdPostingGroup, //Input parameter of type Code
    GenPostingType@1120002 : Option GenPostingType //Input parameter of type Option
);

Parameters

GenBusPostingGroup
Input parameter of type Code
GenProdPostingGroup
Input parameter of type Code
GenPostingType
Input parameter of type Option

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, General Ledger, Account, For, Prepayment.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.FindVATPostingSetup(VATPostingSetup,VATPostingSetup."VAT Calculation Type"::"Normal VAT");
      LibraryERM.CreateGLAccount(GLAccount);
      GLAccount.VALIDATE("Gen. Posting Type",GenPostingType);
      GLAccount.VALIDATE("Gen. Bus. Posting Group",GenBusPostingGroup);
      GLAccount.VALIDATE("Gen. Prod. Posting Group",GenProdPostingGroup);
      GLAccount.VALIDATE("VAT Bus. Posting Group",VATPostingSetup."VAT Bus. Posting Group");
      GLAccount.VALIDATE("VAT Prod. Posting Group",VATPostingSetup."VAT Prod. Posting Group");
      GLAccount.MODIFY(TRUE);
      EXIT(GLAccount."No.");

Example

There are no examples available.
Member of Lib.Library - ERM Country Data


CreateNewFiscalYear@16 Method

The procedure CreateNewFiscalYear is available in codeunit 131305.

Syntax

CreateNewFiscalYear@16(
      //param element not supplied
);

Remarks

The relevant search keywords are: Create, New, Fiscal, Year.

For a clarification about how this function works, refer to the code listed below.

      LibraryFiscalYear.CreateFiscalYear;

Example

There are no examples available.
Member of Lib.Library - ERM Country Data


CreateTransportMethodTableData@23 Method

The procedure CreateTransportMethodTableData is available in codeunit 131305.

Syntax

CreateTransportMethodTableData@23(
      //param element not supplied
);

Remarks

The relevant search keywords are: Create, Transport, Method, Table, Data.

For a clarification about how this function works, refer to the code listed below.

      EXIT;

Example

There are no examples available.
Member of Lib.Library - ERM Country Data


CreateUnitsOfMeasure@12 Method

The procedure CreateUnitsOfMeasure is available in codeunit 131305.

Syntax

CreateUnitsOfMeasure@12(
      //param element not supplied
);

Remarks

The relevant search keywords are: Create, Units, Of, Measure.

For a clarification about how this function works, refer to the code listed below.

      EXIT;

Example

There are no examples available.
Member of Lib.Library - ERM Country Data


CreateVATData@18 Method

The procedure CreateVATData is available in codeunit 131305.

Syntax

CreateVATData@18(
      //param element not supplied
);

Remarks

The relevant search keywords are: Create, VAT, Data.

For a clarification about how this function works, refer to the code listed below.

      CreateVATSetup;

Example

The below example is extracted from the test automation codeunit 134001 to show one way of using this function.

      LibraryVariableStorage.Clear;
      LibrarySetupStorage.Restore;
      IF isInitialized THEN
        EXIT;

      // Setup default fixture

      // Create new payment terms with random discount due date and discount percentage.
      // The due date must be after the discount due date.
      ReplacePaymentTerms(
        PmtTerms,'NEW','<1M>','<' + FORMAT(LibraryRandom.RandInt(20)) + 'D>',LibraryRandom.RandInt(200) / 10);
      ModifyGenJnlBatchNoSeries;
      LibraryERMCountryData.CreateVATData;
      LibraryERMCountryData.UpdateGeneralPostingSetup;
      LibraryERMCountryData.UpdateAccountInVendorPostingGroups;
      LibraryERMCountryData.UpdatePurchasesPayablesSetup;
      LibraryERMCountryData.UpdateGeneralLedgerSetup;
      isInitialized := TRUE;
      COMMIT;
      LibrarySetupStorage.Save(DATABASE::"General Ledger Setup");
Member of Lib.Library - ERM Country Data


DisableActivateChequeNoOnGeneralLedgerSetup@22 Method

The procedure DisableActivateChequeNoOnGeneralLedgerSetup is available in codeunit 131305.

Syntax

DisableActivateChequeNoOnGeneralLedgerSetup@22(
      //param element not supplied
);

Remarks

The relevant search keywords are: Disable, Activate, Cheque, No, On, General, Ledger, Setup.

For a clarification about how this function works, refer to the code listed below.

      GeneralLedgerSetup.GET;
      GeneralLedgerSetup.VALIDATE("Activate Cheque No.",FALSE);
      GeneralLedgerSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134987 to show one way of using this function.

      LibraryVariableStorage.Clear;
      LibrarySetupStorage.Restore;
      IF IsInitialized THEN
        EXIT;

      LibraryERMCountryData.DisableActivateChequeNoOnGeneralLedgerSetup;
      LibraryERMCountryData.UpdateGenJournalTemplate;
      LibraryERMCountryData.RemoveBlankGenJournalTemplate;
      LibraryERMCountryData.UpdateGeneralPostingSetup;
      LibraryERMCountryData.UpdateLocalData;
      UpdateIntrastatCountryCode; // Required for Intrastat.
      LibraryERMCountryData.UpdateLocalPostingSetup;

      IsInitialized := TRUE;

      LibrarySetupStorage.Save(DATABASE::"General Ledger Setup");
Member of Lib.Library - ERM Country Data


InitializeCountry@20 Method

The procedure InitializeCountry is available in codeunit 131305.

Syntax

InitializeCountry@20(
      //param element not supplied
);

Remarks

The relevant search keywords are: Initialize, Country.

For a clarification about how this function works, refer to the code listed below.

      EXIT;

Example

The below example is extracted from the test automation codeunit 134179 to show one way of using this function.

      LibraryVariableStorage.Clear;
      UserSetup.DELETEALL;
      LibraryERMCountryData.InitializeCountry;
      LibraryERMCountryData.UpdateGeneralPostingSetup;
      LibraryERMCountryData.CreateVATData;
      LibraryERMCountryData.UpdatePurchasesPayablesSetup;
      LibraryWorkflow.DisableAllWorkflows;
      PostedApprovalEntry.DELETEALL;
Member of Lib.Library - ERM Country Data


RemoveBlankGenJournalTemplate@24 Method

The procedure RemoveBlankGenJournalTemplate is available in codeunit 131305.

Syntax

RemoveBlankGenJournalTemplate@24(
      //param element not supplied
);

Remarks

The relevant search keywords are: Remove, Blank, General, Journal, Template.

For a clarification about how this function works, refer to the code listed below.

      EXIT;

Example

The below example is extracted from the test automation codeunit 134987 to show one way of using this function.

      LibraryVariableStorage.Clear;
      LibrarySetupStorage.Restore;
      IF IsInitialized THEN
        EXIT;

      LibraryERMCountryData.DisableActivateChequeNoOnGeneralLedgerSetup;
      LibraryERMCountryData.UpdateGenJournalTemplate;
      LibraryERMCountryData.RemoveBlankGenJournalTemplate;
      LibraryERMCountryData.UpdateGeneralPostingSetup;
      LibraryERMCountryData.UpdateLocalData;
      UpdateIntrastatCountryCode; // Required for Intrastat.
      LibraryERMCountryData.UpdateLocalPostingSetup;

      IsInitialized := TRUE;

      LibrarySetupStorage.Save(DATABASE::"General Ledger Setup");
Member of Lib.Library - ERM Country Data


SetupCostAccounting@19 Method

The procedure SetupCostAccounting is available in codeunit 131305.

Syntax

SetupCostAccounting@19(
      //param element not supplied
);

Remarks

The relevant search keywords are: Setup, Cost, Accounting.

For a clarification about how this function works, refer to the code listed below.

      EXIT;

Example

There are no examples available.
Member of Lib.Library - ERM Country Data


UpdateAccountInCustomerPostingGroup@1 Method

The procedure UpdateAccountInCustomerPostingGroup is available in codeunit 131305.

Syntax

UpdateAccountInCustomerPostingGroup@1(
      //param element not supplied
);

Remarks

The relevant search keywords are: Update, Account, In, Customer, Posting, Group.

For a clarification about how this function works, refer to the code listed below.

      EXIT;

Example

There are no examples available.
Member of Lib.Library - ERM Country Data


UpdateAccountInServiceCosts@4 Method

The procedure UpdateAccountInServiceCosts is available in codeunit 131305.

Syntax

UpdateAccountInServiceCosts@4(
      //param element not supplied
);

Remarks

The relevant search keywords are: Update, Account, In, Service, Costs.

For a clarification about how this function works, refer to the code listed below.

      EXIT;

Example

There are no examples available.
Member of Lib.Library - ERM Country Data


UpdateAccountInVendorPostingGroups@2 Method

The procedure UpdateAccountInVendorPostingGroups is available in codeunit 131305.

Syntax

UpdateAccountInVendorPostingGroups@2(
      //param element not supplied
);

Remarks

The relevant search keywords are: Update, Account, In, Vendor, Posting, Groups.

For a clarification about how this function works, refer to the code listed below.

      EXIT;

Example

The below example is extracted from the test automation codeunit 134001 to show one way of using this function.

      LibraryVariableStorage.Clear;
      LibrarySetupStorage.Restore;
      IF isInitialized THEN
        EXIT;

      // Setup default fixture

      // Create new payment terms with random discount due date and discount percentage.
      // The due date must be after the discount due date.
      ReplacePaymentTerms(
        PmtTerms,'NEW','<1M>','<' + FORMAT(LibraryRandom.RandInt(20)) + 'D>',LibraryRandom.RandInt(200) / 10);
      ModifyGenJnlBatchNoSeries;
      LibraryERMCountryData.CreateVATData;
      LibraryERMCountryData.UpdateGeneralPostingSetup;
      LibraryERMCountryData.UpdateAccountInVendorPostingGroups;
      LibraryERMCountryData.UpdatePurchasesPayablesSetup;
      LibraryERMCountryData.UpdateGeneralLedgerSetup;
      isInitialized := TRUE;
      COMMIT;
      LibrarySetupStorage.Save(DATABASE::"General Ledger Setup");
Member of Lib.Library - ERM Country Data


UpdateAccountsInServiceContractAccountGroups@3 Method

The procedure UpdateAccountsInServiceContractAccountGroups is available in codeunit 131305.

Syntax

UpdateAccountsInServiceContractAccountGroups@3(
      //param element not supplied
);

Remarks

The relevant search keywords are: Update, Accounts, In, Service, Contract, Account, Groups.

For a clarification about how this function works, refer to the code listed below.

      EXIT;

Example

There are no examples available.
Member of Lib.Library - ERM Country Data


UpdateCalendarSetup@9 Method

The procedure UpdateCalendarSetup is available in codeunit 131305.

Syntax

UpdateCalendarSetup@9(
      //param element not supplied
);

Remarks

The relevant search keywords are: Update, Calendar, Setup.

For a clarification about how this function works, refer to the code listed below.

      EXIT;

Example

There are no examples available.
Member of Lib.Library - ERM Country Data


UpdateFAJnlTemplateName@21 Method

The procedure UpdateFAJnlTemplateName is available in codeunit 131305.

Syntax

UpdateFAJnlTemplateName@21(
      //param element not supplied
);

Remarks

The relevant search keywords are: Update, Fixed Asset, Journal, Template, Name.

For a clarification about how this function works, refer to the code listed below.

      EXIT;

Example

There are no examples available.
Member of Lib.Library - ERM Country Data


UpdateFAPostingGroup@15 Method

The procedure UpdateFAPostingGroup is available in codeunit 131305.

Syntax

UpdateFAPostingGroup@15(
      //param element not supplied
);

Remarks

The relevant search keywords are: Update, Fixed Asset, Posting, Group.

For a clarification about how this function works, refer to the code listed below.

      EXIT;

Example

There are no examples available.
Member of Lib.Library - ERM Country Data


UpdateFAPostingType@27 Method

The procedure UpdateFAPostingType is available in codeunit 131305.

Syntax

UpdateFAPostingType@27(
      //param element not supplied
);

Remarks

The relevant search keywords are: Update, Fixed Asset, Posting, Type.

For a clarification about how this function works, refer to the code listed below.

      EXIT;

Example

There are no examples available.
Member of Lib.Library - ERM Country Data


UpdateGeneralLedgerSetup@11 Method

The procedure UpdateGeneralLedgerSetup is available in codeunit 131305.

Syntax

UpdateGeneralLedgerSetup@11(
      //param element not supplied
);

Remarks

The relevant search keywords are: Update, General, Ledger, Setup.

For a clarification about how this function works, refer to the code listed below.

      GeneralLedgerSetup.GET;
      GeneralLedgerSetup.VALIDATE("Activate Cheque No.",FALSE);
      GeneralLedgerSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134001 to show one way of using this function.

      LibraryVariableStorage.Clear;
      LibrarySetupStorage.Restore;
      IF isInitialized THEN
        EXIT;

      // Setup default fixture

      // Create new payment terms with random discount due date and discount percentage.
      // The due date must be after the discount due date.
      ReplacePaymentTerms(
        PmtTerms,'NEW','<1M>','<' + FORMAT(LibraryRandom.RandInt(20)) + 'D>',LibraryRandom.RandInt(200) / 10);
      ModifyGenJnlBatchNoSeries;
      LibraryERMCountryData.CreateVATData;
      LibraryERMCountryData.UpdateGeneralPostingSetup;
      LibraryERMCountryData.UpdateAccountInVendorPostingGroups;
      LibraryERMCountryData.UpdatePurchasesPayablesSetup;
      LibraryERMCountryData.UpdateGeneralLedgerSetup;
      isInitialized := TRUE;
      COMMIT;
      LibrarySetupStorage.Save(DATABASE::"General Ledger Setup");
Member of Lib.Library - ERM Country Data


UpdateGeneralPostingSetup@5 Method

The procedure UpdateGeneralPostingSetup is available in codeunit 131305.

Syntax

UpdateGeneralPostingSetup@5(
      //param element not supplied
);

Remarks

The relevant search keywords are: Update, General, Posting, Setup.

For a clarification about how this function works, refer to the code listed below.

      UpdateAccountsInGeneralPostingSetup;

Example

The below example is extracted from the test automation codeunit 134001 to show one way of using this function.

      LibraryVariableStorage.Clear;
      LibrarySetupStorage.Restore;
      IF isInitialized THEN
        EXIT;

      // Setup default fixture

      // Create new payment terms with random discount due date and discount percentage.
      // The due date must be after the discount due date.
      ReplacePaymentTerms(
        PmtTerms,'NEW','<1M>','<' + FORMAT(LibraryRandom.RandInt(20)) + 'D>',LibraryRandom.RandInt(200) / 10);
      ModifyGenJnlBatchNoSeries;
      LibraryERMCountryData.CreateVATData;
      LibraryERMCountryData.UpdateGeneralPostingSetup;
      LibraryERMCountryData.UpdateAccountInVendorPostingGroups;
      LibraryERMCountryData.UpdatePurchasesPayablesSetup;
      LibraryERMCountryData.UpdateGeneralLedgerSetup;
      isInitialized := TRUE;
      COMMIT;
      LibrarySetupStorage.Save(DATABASE::"General Ledger Setup");
Member of Lib.Library - ERM Country Data


UpdateGenJournalTemplate@6 Method

The procedure UpdateGenJournalTemplate is available in codeunit 131305.

Syntax

UpdateGenJournalTemplate@6(
      //param element not supplied
);

Remarks

The relevant search keywords are: Update, General, Journal, Template.

For a clarification about how this function works, refer to the code listed below.

      EXIT;

Example

The below example is extracted from the test automation codeunit 134987 to show one way of using this function.

      LibraryVariableStorage.Clear;
      LibrarySetupStorage.Restore;
      IF IsInitialized THEN
        EXIT;

      LibraryERMCountryData.DisableActivateChequeNoOnGeneralLedgerSetup;
      LibraryERMCountryData.UpdateGenJournalTemplate;
      LibraryERMCountryData.RemoveBlankGenJournalTemplate;
      LibraryERMCountryData.UpdateGeneralPostingSetup;
      LibraryERMCountryData.UpdateLocalData;
      UpdateIntrastatCountryCode; // Required for Intrastat.
      LibraryERMCountryData.UpdateLocalPostingSetup;

      IsInitialized := TRUE;

      LibrarySetupStorage.Save(DATABASE::"General Ledger Setup");
Member of Lib.Library - ERM Country Data


UpdateGenProdPostingGroup@13 Method

The procedure UpdateGenProdPostingGroup is available in codeunit 131305.

Syntax

UpdateGenProdPostingGroup@13(
      //param element not supplied
);

Remarks

The relevant search keywords are: Update, General, Product, Posting, Group.

For a clarification about how this function works, refer to the code listed below.

      EXIT;

Example

The below example is extracted from the test automation codeunit 134820 to show one way of using this function.

      IF IsInitialized THEN
        EXIT;
      IF UpdateCountryData THEN BEGIN
        LibraryERMCountryData.CreateVATData;
        LibraryERMCountryData.UpdateGenProdPostingGroup;
        LibraryERMCountryData.UpdateGeneralPostingSetup;
        UpdateCountryData := FALSE;
      END;
      IsInitialized := TRUE;
      COMMIT;
Member of Lib.Library - ERM Country Data


UpdateInventoryPostingSetup@140 Method

The procedure UpdateInventoryPostingSetup is available in codeunit 131305.

Syntax

UpdateInventoryPostingSetup@140(
      //param element not supplied
);

Remarks

The relevant search keywords are: Update, Inventory, Posting, Setup.

For a clarification about how this function works, refer to the code listed below.

      EXIT;

Example

The below example is extracted from the test automation codeunit 137067 to show one way of using this function.

      // [FEATURE] [Planning Worksheet] [Item Tracking] [Manufacturing]
      // [SCENARIO 376248] Surplus Reservation Entry exists after recalculation of Production Item supply and surplus exists because of "Order Multiple" rounding.

      Initialize;

      // [GIVEN] Production Item with Order Multiple = "X", "Order Tracking Policy" = "Tracking Only", available stock = "S".
      OrderMultipleQty := LibraryRandom.RandDecInRange(10,50,1);
      WITH Item DO BEGIN
        LibraryVariableStorage.Enqueue(WillNotAffectExistingMsg);
        CreateItem(Item,"Reordering Policy"::"Lot-for-Lot","Replenishment System"::"Prod. Order");
        VALIDATE("Minimum Order Quantity",OrderMultipleQty);
        VALIDATE("Order Multiple",OrderMultipleQty);
        VALIDATE("Order Tracking Policy","Order Tracking Policy"::"Tracking Only");
        MODIFY(TRUE);
        LibraryInventory.CreateStockkeepingUnitForLocationAndVariant(
          StockkeepingUnit,LocationRed.Code,"No.",'');
        LibraryInventory.CreateInventoryPostingSetup(InventoryPostingSetup,LocationRed.Code,"Inventory Posting Group");
        LibraryInventory.UpdateInventoryPostingSetup(LocationRed);
        UpdateInventoryOnLocation(
          ItemJournalLine,"No.",LocationRed.Code,WORKDATE,LibraryRandom.RandDecInRange(100,200,2));
      END;

      // [GIVEN] Create Sales Order of Quantity = "S" + "X" / 2, delivery date = WORKDATE + 2 weeks. Calculate regeneration plan and carry out.
      CreateSalesOrder(SalesHeader,SalesLine,Item."No.",ItemJournalLine.Quantity + OrderMultipleQty / 2);
      SalesLine.VALIDATE("Location Code",LocationRed.Code);
      SalesLine.MODIFY(TRUE);
      SalesHeader.VALIDATE("Requested Delivery Date",CALCDATE('<+2W>',WORKDATE));
      SalesHeader.MODIFY(TRUE);
      CalculateRegenerativePlanAndCarryOut(Item."No.",Item."No.",TRUE);

      // [GIVEN] Open created Production Order, set "Ending Date" to WORKDATE + 4 weeks.
      WITH ProductionOrder DO BEGIN
        SETRANGE("Source Type","Source Type"::Item);
        SETRANGE("Source No.",Item."No.");
        FINDFIRST;
        VALIDATE("Ending Date",CALCDATE('<+4W>',WORKDATE));
        MODIFY(TRUE);
      END;

      // [WHEN] Calculate regeneration plan and carry out.
      CalcRegenPlanAcceptAndCarryOut(
        FindRequisitionWkshName(ReqWkshTemplate.Type::Planning),Item."No.");

      // [THEN] Surplus Reservation Entry is present of Quantity = "X" / 2.
      VerifySurplusReservationEntry(Item."No.",OrderMultipleQty / 2);
Member of Lib.Library - ERM Country Data


UpdateLocalData@26 Method

The procedure UpdateLocalData is available in codeunit 131305.

Syntax

UpdateLocalData@26(
      //param element not supplied
);

Remarks

The relevant search keywords are: Update, Local, Data.

For a clarification about how this function works, refer to the code listed below.

      EXIT;

Example

The below example is extracted from the test automation codeunit 134251 to show one way of using this function.

      LibraryVariableStorage.Clear;
      CloseExistingEntries;
      IF isInitialized THEN
        EXIT;

      LibraryVariableStorage.Clear;
      LibraryERMCountryData.UpdateLocalData;
      LibraryERMCountryData.CreateVATData;
      LibraryERMCountryData.UpdateGeneralPostingSetup;
      isInitialized := TRUE;
Member of Lib.Library - ERM Country Data


UpdateLocalPostingSetup@25 Method

The procedure UpdateLocalPostingSetup is available in codeunit 131305.

Syntax

UpdateLocalPostingSetup@25(
      //param element not supplied
);

Remarks

The relevant search keywords are: Update, Local, Posting, Setup.

For a clarification about how this function works, refer to the code listed below.

      EXIT;

Example

The below example is extracted from the test automation codeunit 134140 to show one way of using this function.

      LibraryVariableStorage.Clear;
      IF isInitialized THEN
        EXIT;
      LibraryERMCountryData.UpdateLocalPostingSetup;
      LibraryERMCountryData.UpdateGeneralPostingSetup;
      isInitialized := TRUE;
      COMMIT;
Member of Lib.Library - ERM Country Data


UpdatePrepaymentAccounts@14 Method

The procedure UpdatePrepaymentAccounts is available in codeunit 131305.

Syntax

UpdatePrepaymentAccounts@14(
      //param element not supplied
);

Remarks

The relevant search keywords are: Update, Prepayment, Accounts.

For a clarification about how this function works, refer to the code listed below.

      EXIT;

Example

The below example is extracted from the test automation codeunit 137158 to show one way of using this function.

      LibraryVariableStorage.Clear;
      LibrarySetupStorage.Restore;

      // Lazy Setup.
      IF isInitialized THEN
        EXIT;
      LibraryERMCountryData.CreateVATData;
      NoSeriesSetup;
      ItemJournalSetup(ItemJournalTemplate,ItemJournalBatch,ItemJournalTemplate.Type::Item);
      ItemJournalSetup(ReclassItemJournalTemplate,ReclassItemJournalBatch,ReclassItemJournalTemplate.Type::Transfer);
      LocationSetup;
      LibraryERMCountryData.CreateGeneralPostingSetupData;
      LibraryERMCountryData.UpdateGeneralPostingSetup;
      LibraryERMCountryData.UpdateGeneralLedgerSetup;
      LibraryERMCountryData.UpdatePrepaymentAccounts;
      LibraryERMCountryData.UpdateSalesReceivablesSetup;
      LibrarySetupStorage.Save(DATABASE::"Sales & Receivables Setup");
      isInitialized := TRUE;
      COMMIT;
Member of Lib.Library - ERM Country Data


UpdatePurchasesPayablesSetup@7 Method

The procedure UpdatePurchasesPayablesSetup is available in codeunit 131305.

Syntax

UpdatePurchasesPayablesSetup@7(
      //param element not supplied
);

Remarks

The relevant search keywords are: Update, Purchases, Payables, Setup.

For a clarification about how this function works, refer to the code listed below.

      EXIT;

Example

The below example is extracted from the test automation codeunit 134001 to show one way of using this function.

      LibraryVariableStorage.Clear;
      LibrarySetupStorage.Restore;
      IF isInitialized THEN
        EXIT;

      // Setup default fixture

      // Create new payment terms with random discount due date and discount percentage.
      // The due date must be after the discount due date.
      ReplacePaymentTerms(
        PmtTerms,'NEW','<1M>','<' + FORMAT(LibraryRandom.RandInt(20)) + 'D>',LibraryRandom.RandInt(200) / 10);
      ModifyGenJnlBatchNoSeries;
      LibraryERMCountryData.CreateVATData;
      LibraryERMCountryData.UpdateGeneralPostingSetup;
      LibraryERMCountryData.UpdateAccountInVendorPostingGroups;
      LibraryERMCountryData.UpdatePurchasesPayablesSetup;
      LibraryERMCountryData.UpdateGeneralLedgerSetup;
      isInitialized := TRUE;
      COMMIT;
      LibrarySetupStorage.Save(DATABASE::"General Ledger Setup");
Member of Lib.Library - ERM Country Data


UpdateSalesReceivablesSetup@8 Method

The procedure UpdateSalesReceivablesSetup is available in codeunit 131305.

Syntax

UpdateSalesReceivablesSetup@8(
      //param element not supplied
);

Remarks

The relevant search keywords are: Update, Sales, Receivables, Setup.

For a clarification about how this function works, refer to the code listed below.

      EXIT;

Example

The below example is extracted from the test automation codeunit 134900 to show one way of using this function.

      LibraryVariableStorage.Clear;
      LibrarySetupStorage.Restore;
      IF isInitialized THEN
        EXIT;

      LibraryERMCountryData.CreateVATData;
      LibraryERMCountryData.UpdatePurchasesPayablesSetup;
      LibraryERMCountryData.UpdateSalesReceivablesSetup;
      LibraryERMCountryData.UpdateGeneralPostingSetup;
      LibraryERMCountryData.UpdateLocalData;
      LibrarySetupStorage.Save(DATABASE::"Sales & Receivables Setup");
      LibrarySetupStorage.Save(DATABASE::"Purchases & Payables Setup");
      LibrarySetupStorage.Save(DATABASE::"General Ledger Setup");
      isInitialized := TRUE;
      COMMIT;
Member of Lib.Library - ERM Country Data


UpdateVATPostingSetup@17 Method

The procedure UpdateVATPostingSetup is available in codeunit 131305.

Syntax

UpdateVATPostingSetup@17(
      //param element not supplied
);

Remarks

The relevant search keywords are: Update, VAT, Posting, Setup.

For a clarification about how this function works, refer to the code listed below.

      EXIT;

Example

There are no examples available.
Member of Lib.Library - ERM Country Data


Library - ERM Unapply Class

Lib.Library - ERM Unapply

COD131301 applies to RES,ERM,SCM,W1,All.
Branching extension library for CU131300: Library - ERM
Encapsulates functionality for unapplying customer and vendor ledger entries because the function GenJnlPostLine.UnapplyVendLedgEntry has different signatures in AU,NZ builds.

Methods

Name | Description
UnapplyCustomerLedgerEntry@27 | The procedure UnapplyCustomerLedgerEntry is available in codeunit 131301.
UnapplyCustomerLedgerEntryBase@2 | The procedure UnapplyCustomerLedgerEntryBase is available in codeunit 131301.
UnapplyVendorLedgerEntry@21 | The procedure UnapplyVendorLedgerEntry is available in codeunit 131301.
UnapplyVendorLedgerEntryBase@1 | The procedure UnapplyVendorLedgerEntryBase is available in codeunit 131301.

See Also

Lib


UnapplyCustomerLedgerEntry@27 Method

The procedure UnapplyCustomerLedgerEntry is available in codeunit 131301.

Syntax

UnapplyCustomerLedgerEntry@27(
    CustLedgerEntry@1000 : Record 21 CustLedgerEntry //Input parameter of type Record
);

Parameters

CustLedgerEntry
Input parameter of type Record

Remarks

The relevant search keywords are: Unapply, Customer, Ledger, Entry.

For a clarification about how this function works, refer to the code listed below.

      UnapplyCustomerLedgerEntryBase(CustLedgerEntry,0D);

Example

There are no examples available.
Member of Lib.Library - ERM Unapply


UnapplyCustomerLedgerEntryBase@2 Method

The procedure UnapplyCustomerLedgerEntryBase is available in codeunit 131301.

Syntax

UnapplyCustomerLedgerEntryBase@2(
    CustLedgerEntry@1000 : Record 21 CustLedgerEntry, //Input parameter of type Record
    PostingDate@1001 : Date PostingDate //Input parameter of type Date
);

Parameters

CustLedgerEntry
Input parameter of type Record
PostingDate
Input parameter of type Date

Remarks

The relevant search keywords are: Unapply, Customer, Ledger, Entry, Base.

For a clarification about how this function works, refer to the code listed below.

      DetailedCustLedgEntry.SETRANGE("Entry Type",DetailedCustLedgEntry."Entry Type"::Application);
      DetailedCustLedgEntry.SETRANGE("Customer No.",CustLedgerEntry."Customer No.");
      DetailedCustLedgEntry.SETRANGE("Document No.",CustLedgerEntry."Document No.");
      DetailedCustLedgEntry.SETRANGE("Cust. Ledger Entry No.",CustLedgerEntry."Entry No.");
      DetailedCustLedgEntry.SETRANGE(Unapplied,FALSE);
      DetailedCustLedgEntry.FINDFIRST;
      WITH DetailedCustLedgEntry DO BEGIN
        IF PostingDate = 0D THEN
          PostingDate := "Posting Date";
        SourceCodeSetup.GET;
        CustLedgerEntry.GET("Cust. Ledger Entry No.");
        GenJournalLine.VALIDATE("Document No.","Document No.");
        GenJournalLine.VALIDATE("Posting Date",PostingDate);
        GenJournalLine.VALIDATE("Account Type",GenJournalLine."Account Type"::Customer);
        GenJournalLine.VALIDATE("Account No.","Customer No.");
        GenJournalLine.VALIDATE(Correction,TRUE);
        GenJournalLine.VALIDATE("Document Type",GenJournalLine."Document Type"::" ");
        GenJournalLine.VALIDATE(Description,CustLedgerEntry.Description);
        GenJournalLine.VALIDATE("Shortcut Dimension 1 Code",CustLedgerEntry."Global Dimension 1 Code");
        GenJournalLine.VALIDATE("Shortcut Dimension 2 Code",CustLedgerEntry."Global Dimension 2 Code");
        GenJournalLine.VALIDATE("Posting Group",CustLedgerEntry."Customer Posting Group");
        GenJournalLine.VALIDATE("Source Type",GenJournalLine."Source Type"::Vendor);
        GenJournalLine.VALIDATE("Source No.","Customer No.");
        GenJournalLine.VALIDATE("Source Code",SourceCodeSetup."Unapplied Sales Entry Appln.");
        GenJournalLine.VALIDATE("Source Currency Code","Currency Code");
        GenJournalLine.VALIDATE("System-Created Entry",TRUE);
        GenJnlPostLine.UnapplyCustLedgEntry(GenJournalLine,DetailedCustLedgEntry);
      END;

Example

The below example is extracted from the test automation codeunit 134091 to show one way of using this function.

      CustLedgerEntry.SETRANGE("Customer No.",CustNo);
      CustLedgerEntry.SETRANGE("Document No.",DocNo);
      CustLedgerEntry.SETRANGE(Open,FALSE);
      CustLedgerEntry.FINDLAST;
      LibraryERMUnapply.UnapplyCustomerLedgerEntryBase(CustLedgerEntry,PostingDate);
Member of Lib.Library - ERM Unapply


UnapplyVendorLedgerEntry@21 Method

The procedure UnapplyVendorLedgerEntry is available in codeunit 131301.

Syntax

UnapplyVendorLedgerEntry@21(
    VendorLedgerEntry@1001 : Record 25 VendorLedgerEntry //Input parameter of type Record
);

Parameters

VendorLedgerEntry
Input parameter of type Record

Remarks

The relevant search keywords are: Unapply, Vendor, Ledger, Entry.

For a clarification about how this function works, refer to the code listed below.

      UnapplyVendorLedgerEntryBase(VendorLedgerEntry,0D);

Example

There are no examples available.
Member of Lib.Library - ERM Unapply


UnapplyVendorLedgerEntryBase@1 Method

The procedure UnapplyVendorLedgerEntryBase is available in codeunit 131301.

Syntax

UnapplyVendorLedgerEntryBase@1(
    VendorLedgerEntry@1001 : Record 25 VendorLedgerEntry, //Input parameter of type Record
    PostingDate@1005 : Date PostingDate //Input parameter of type Date
);

Parameters

VendorLedgerEntry
Input parameter of type Record
PostingDate
Input parameter of type Date

Remarks

The relevant search keywords are: Unapply, Vendor, Ledger, Entry, Base.

For a clarification about how this function works, refer to the code listed below.

      DetailedVendorLedgEntry.SETRANGE("Entry Type",DetailedVendorLedgEntry."Entry Type"::Application);
      DetailedVendorLedgEntry.SETRANGE("Vendor No.",VendorLedgerEntry."Vendor No.");
      DetailedVendorLedgEntry.SETRANGE("Document No.",VendorLedgerEntry."Document No.");
      DetailedVendorLedgEntry.SETRANGE("Vendor Ledger Entry No.",VendorLedgerEntry."Entry No.");
      DetailedVendorLedgEntry.SETRANGE(Unapplied,FALSE);
      DetailedVendorLedgEntry.FINDFIRST;
      WITH DetailedVendorLedgEntry DO BEGIN
        IF PostingDate = 0D THEN
          PostingDate := "Posting Date";
        SourceCodeSetup.GET;
        VendorLedgerEntry.GET("Vendor Ledger Entry No.");
        GenJournalLine.VALIDATE("Document No.","Document No.");
        GenJournalLine.VALIDATE("Posting Date",PostingDate);
        GenJournalLine.VALIDATE("Account Type",GenJournalLine."Account Type"::Vendor);
        GenJournalLine.VALIDATE("Account No.","Vendor No.");
        GenJournalLine.VALIDATE(Correction,TRUE);
        GenJournalLine.VALIDATE("Document Type",GenJournalLine."Document Type"::" ");
        GenJournalLine.VALIDATE(Description,VendorLedgerEntry.Description);
        GenJournalLine.VALIDATE("Shortcut Dimension 1 Code",VendorLedgerEntry."Global Dimension 1 Code");
        GenJournalLine.VALIDATE("Shortcut Dimension 2 Code",VendorLedgerEntry."Global Dimension 2 Code");
        GenJournalLine.VALIDATE("Posting Group",VendorLedgerEntry."Vendor Posting Group");
        GenJournalLine.VALIDATE("Source Type",GenJournalLine."Source Type"::Vendor);
        GenJournalLine.VALIDATE("Source No.","Vendor No.");
        GenJournalLine.VALIDATE("Source Code",SourceCodeSetup."Unapplied Purch. Entry Appln.");
        GenJournalLine.VALIDATE("Source Currency Code","Currency Code");
        GenJournalLine.VALIDATE("System-Created Entry",TRUE);
        GenJnlPostLine.UnapplyVendLedgEntry(GenJournalLine,DetailedVendorLedgEntry);
      END;

Example

The below example is extracted from the test automation codeunit 134091 to show one way of using this function.

      VendorLedgerEntry.SETRANGE("Vendor No.",VendNo);
      VendorLedgerEntry.SETRANGE("Document No.",DocNo);
      VendorLedgerEntry.SETRANGE(Open,FALSE);
      VendorLedgerEntry.FINDLAST;
      LibraryERMUnapply.UnapplyVendorLedgerEntryBase(VendorLedgerEntry,PostingDate);
Member of Lib.Library - ERM Unapply


Library - Error Message Class

Lib.Library - Error Message

COD132215 applies to W1,All.

Methods

Name | Description
AssertLogIfEqualToExists@12 | The procedure AssertLogIfEqualToExists is available in codeunit 132215.
AssertLogIfGreaterThanExists@13 | The procedure AssertLogIfGreaterThanExists is available in codeunit 132215.
AssertLogIfInvalidCharactersExists@18 | The procedure AssertLogIfInvalidCharactersExists is available in codeunit 132215.
AssertLogIfLengthExceededExists@4 | The procedure AssertLogIfLengthExceededExists is available in codeunit 132215.
AssertLogIfLessThanExists@20 | The procedure AssertLogIfLessThanExists is available in codeunit 132215.
AssertLogIfMessageExists@3 | The procedure AssertLogIfMessageExists is available in codeunit 132215.
AssertLogIfNotEqualToExists@14 | The procedure AssertLogIfNotEqualToExists is available in codeunit 132215.
AssertLogIfOutsideRangeExists@11 | The procedure AssertLogIfOutsideRangeExists is available in codeunit 132215.
AssertLogSimpleMessageExists@10 | The procedure AssertLogSimpleMessageExists is available in codeunit 132215.
LoadErrorMessages@2 | The procedure LoadErrorMessages is available in codeunit 132215.
TrapErrorMessages@1 | The procedure TrapErrorMessages is available in codeunit 132215.

See Also

Lib


AssertLogIfEqualToExists@12 Method

The procedure AssertLogIfEqualToExists is available in codeunit 132215.

Syntax

AssertLogIfEqualToExists@12(
    RecRelatedVariant@1000 : Variant RecRelatedVariant, //Input parameter of type Variant
    FieldNumber@1001 : Integer FieldNumber, //Input parameter of type Integer
    MessageType@1002 : Option MessageType, //Input parameter of type Option
    ValueVariant@1010 : Variant ValueVariant //Input parameter of type Variant
);

Parameters

RecRelatedVariant
Input parameter of type Variant
FieldNumber
Input parameter of type Integer
MessageType
Input parameter of type Option
ValueVariant
Input parameter of type Variant

Remarks

The relevant search keywords are: Assert, Log, If, Equal, To, Exists.

For a clarification about how this function works, refer to the code listed below.

      AssertGetRecordRefAndFieldRef(RecRelatedVariant,FieldNumber,RecordRef,FieldRef);

      ExpectedDescription := STRSUBSTNO(IfEqualToErr,FieldRef.CAPTION,FORMAT(RecordRef.RECORDID),ValueVariant);
      AssertMessageExists(ExpectedDescription,MessageType);

Example

There are no examples available.
Member of Lib.Library - Error Message


AssertLogIfGreaterThanExists@13 Method

The procedure AssertLogIfGreaterThanExists is available in codeunit 132215.

Syntax

AssertLogIfGreaterThanExists@13(
    RecRelatedVariant@1000 : Variant RecRelatedVariant, //Input parameter of type Variant
    FieldNumber@1001 : Integer FieldNumber, //Input parameter of type Integer
    MessageType@1002 : Option MessageType, //Input parameter of type Option
    LowerBound@1007 : Variant LowerBound //Input parameter of type Variant
);

Parameters

RecRelatedVariant
Input parameter of type Variant
FieldNumber
Input parameter of type Integer
MessageType
Input parameter of type Option
LowerBound
Input parameter of type Variant

Remarks

The relevant search keywords are: Assert, Log, If, Greater, Than, Exists.

For a clarification about how this function works, refer to the code listed below.

      AssertGetRecordRefAndFieldRef(RecRelatedVariant,FieldNumber,RecordRef,FieldRef);

      ExpectedDescription := STRSUBSTNO(IfGreaterThanErr,FieldRef.CAPTION,FORMAT(RecordRef.RECORDID),LowerBound);
      AssertMessageExists(ExpectedDescription,MessageType);

Example

There are no examples available.
Member of Lib.Library - Error Message


AssertLogIfInvalidCharactersExists@18 Method

The procedure AssertLogIfInvalidCharactersExists is available in codeunit 132215.

Syntax

AssertLogIfInvalidCharactersExists@18(
    RecRelatedVariant@1000 : Variant RecRelatedVariant, //Input parameter of type Variant
    FieldNumber@1001 : Integer FieldNumber, //Input parameter of type Integer
    MessageType@1002 : Option MessageType //Input parameter of type Option
);

Parameters

RecRelatedVariant
Input parameter of type Variant
FieldNumber
Input parameter of type Integer
MessageType
Input parameter of type Option

Remarks

The relevant search keywords are: Assert, Log, If, Invalid, Characters, Exists.

For a clarification about how this function works, refer to the code listed below.

      AssertGetRecordRefAndFieldRef(RecRelatedVariant,FieldNumber,RecordRef,FieldRef);

      ExpectedDescription := STRSUBSTNO(IfInvalidCharactersErr,FieldRef.CAPTION,FORMAT(RecordRef.RECORDID));
      AssertMessageExists(ExpectedDescription,MessageType);

Example

There are no examples available.
Member of Lib.Library - Error Message


AssertLogIfLengthExceededExists@4 Method

The procedure AssertLogIfLengthExceededExists is available in codeunit 132215.

Syntax

AssertLogIfLengthExceededExists@4(
    RecRelatedVariant@1000 : Variant RecRelatedVariant, //Input parameter of type Variant
    FieldNumber@1001 : Integer FieldNumber, //Input parameter of type Integer
    ExpectedMessageType@1002 : Option ExpectedMessageType, //Input parameter of type Option
    MaxLength@1003 : Integer MaxLength //Input parameter of type Integer
);

Parameters

RecRelatedVariant
Input parameter of type Variant
FieldNumber
Input parameter of type Integer
ExpectedMessageType
Input parameter of type Option
MaxLength
Input parameter of type Integer

Remarks

The relevant search keywords are: Assert, Log, If, Length, Exceeded, Exists.

For a clarification about how this function works, refer to the code listed below.

      AssertGetRecordRefAndFieldRef(RecRelatedVariant,FieldNumber,RecordRef,FieldRef);

      StringLength := STRLEN(FORMAT(FieldRef.VALUE));
      IF StringLength <= MaxLength THEN
        ERROR(StringLengthCorrectErr);

      ExpectedDescription := STRSUBSTNO(IfLengthExceededErr,FieldRef.CAPTION,FORMAT(RecordRef.RECORDID),MaxLength,StringLength);

      AssertMessageExists(ExpectedDescription,ExpectedMessageType);

Example

There are no examples available.
Member of Lib.Library - Error Message


AssertLogIfLessThanExists@20 Method

The procedure AssertLogIfLessThanExists is available in codeunit 132215.

Syntax

AssertLogIfLessThanExists@20(
    RecRelatedVariant@1000 : Variant RecRelatedVariant, //Input parameter of type Variant
    FieldNumber@1001 : Integer FieldNumber, //Input parameter of type Integer
    MessageType@1002 : Option MessageType, //Input parameter of type Option
    UpperBound@1010 : Variant UpperBound //Input parameter of type Variant
);

Parameters

RecRelatedVariant
Input parameter of type Variant
FieldNumber
Input parameter of type Integer
MessageType
Input parameter of type Option
UpperBound
Input parameter of type Variant

Remarks

The relevant search keywords are: Assert, Log, If, Less, Than, Exists.

For a clarification about how this function works, refer to the code listed below.

      AssertGetRecordRefAndFieldRef(RecRelatedVariant,FieldNumber,RecordRef,FieldRef);

      ExpectedDescription := STRSUBSTNO(IfLessThanErr,FieldRef.CAPTION,FORMAT(RecordRef.RECORDID),UpperBound);
      AssertMessageExists(ExpectedDescription,MessageType);

Example

There are no examples available.
Member of Lib.Library - Error Message


AssertLogIfMessageExists@3 Method

The procedure AssertLogIfMessageExists is available in codeunit 132215.

Syntax

AssertLogIfMessageExists@3(
    RecRelatedVariant@1000 : Variant RecRelatedVariant, //Input parameter of type Variant
    FieldNumber@1001 : Integer FieldNumber, //Input parameter of type Integer
    ExpectedMessageType@1002 : Option ExpectedMessageType //Input parameter of type Option
);

Parameters

RecRelatedVariant
Input parameter of type Variant
FieldNumber
Input parameter of type Integer
ExpectedMessageType
Input parameter of type Option

Remarks

The relevant search keywords are: Assert, Log, If, Message, Exists.

For a clarification about how this function works, refer to the code listed below.

      AssertGetRecordRefAndFieldRef(RecRelatedVariant,FieldNumber,RecordRef,FieldRef);

      ExpectedDescription := STRSUBSTNO(IfEmptyErr,FieldRef.CAPTION,FORMAT(RecordRef.RECORDID));
      AssertMessageExists(ExpectedDescription,ExpectedMessageType);

Example

There are no examples available.
Member of Lib.Library - Error Message


AssertLogIfNotEqualToExists@14 Method

The procedure AssertLogIfNotEqualToExists is available in codeunit 132215.

Syntax

AssertLogIfNotEqualToExists@14(
    RecRelatedVariant@1000 : Variant RecRelatedVariant, //Input parameter of type Variant
    FieldNumber@1001 : Integer FieldNumber, //Input parameter of type Integer
    MessageType@1002 : Option MessageType, //Input parameter of type Option
    ValueVariant@1010 : Variant ValueVariant //Input parameter of type Variant
);

Parameters

RecRelatedVariant
Input parameter of type Variant
FieldNumber
Input parameter of type Integer
MessageType
Input parameter of type Option
ValueVariant
Input parameter of type Variant

Remarks

The relevant search keywords are: Assert, Log, If, Not, Equal, To, Exists.

For a clarification about how this function works, refer to the code listed below.

      AssertGetRecordRefAndFieldRef(RecRelatedVariant,FieldNumber,RecordRef,FieldRef);

      ExpectedDescription := STRSUBSTNO(IfNotEqualToErr,FieldRef.CAPTION,FORMAT(RecordRef.RECORDID),ValueVariant);
      AssertMessageExists(ExpectedDescription,MessageType);

Example

There are no examples available.
Member of Lib.Library - Error Message


AssertLogIfOutsideRangeExists@11 Method

The procedure AssertLogIfOutsideRangeExists is available in codeunit 132215.

Syntax

AssertLogIfOutsideRangeExists@11(
    RecRelatedVariant@1000 : Variant RecRelatedVariant, //Input parameter of type Variant
    FieldNumber@1001 : Integer FieldNumber, //Input parameter of type Integer
    MessageType@1002 : Option MessageType, //Input parameter of type Option
    LowerBound@1007 : Variant LowerBound, //Input parameter of type Variant
    UpperBound@1010 : Variant UpperBound //Input parameter of type Variant
);

Parameters

RecRelatedVariant
Input parameter of type Variant
FieldNumber
Input parameter of type Integer
MessageType
Input parameter of type Option
LowerBound
Input parameter of type Variant
UpperBound
Input parameter of type Variant

Remarks

The relevant search keywords are: Assert, Log, If, Outside, Range, Exists.

For a clarification about how this function works, refer to the code listed below.

      AssertGetRecordRefAndFieldRef(RecRelatedVariant,FieldNumber,RecordRef,FieldRef);

      ExpectedDescription := STRSUBSTNO(IfOutsideRangeErr,FieldRef.CAPTION,FORMAT(RecordRef.RECORDID),LowerBound,UpperBound);
      AssertMessageExists(ExpectedDescription,MessageType);

Example

There are no examples available.
Member of Lib.Library - Error Message


AssertLogSimpleMessageExists@10 Method

The procedure AssertLogSimpleMessageExists is available in codeunit 132215.

Syntax

AssertLogSimpleMessageExists@10(
    MessageType@1003 : Option MessageType, //Input parameter of type Option
    ExpectedDescription@1004 : Text ExpectedDescription //Input parameter of type Text
);

Parameters

MessageType
Input parameter of type Option
ExpectedDescription
Input parameter of type Text

Remarks

The relevant search keywords are: Assert, Log, Simple, Message, Exists.

For a clarification about how this function works, refer to the code listed below.

      AssertMessageExists(ExpectedDescription,MessageType);

Example

There are no examples available.
Member of Lib.Library - Error Message


LoadErrorMessages@2 Method

The procedure LoadErrorMessages is available in codeunit 132215.

Syntax

LoadErrorMessages@2(
      //param element not supplied
);

Remarks

The relevant search keywords are: Load, Error, Messages.

For a clarification about how this function works, refer to the code listed below.

      IF ErrorMessages.FIRST THEN
        REPEAT
          TempErrorMessage.INIT;
          TempErrorMessage.ID += 1;
          EVALUATE(TempErrorMessage."Message Type",ErrorMessages."Message Type".VALUE);
          TempErrorMessage.Description := ErrorMessages.Description.VALUE;
          TempErrorMessage."Table Name" := ErrorMessages."Table Name".VALUE;
          TempErrorMessage."Field Name" := ErrorMessages."Field Name".VALUE;
          TempErrorMessage."Additional Information" := ErrorMessages."Additional Information".VALUE;
          TempErrorMessage."Support Url" := ErrorMessages."Support Url".VALUE;
          TempErrorMessage.INSERT;
        UNTIL NOT ErrorMessages.NEXT;

Example

There are no examples available.
Member of Lib.Library - Error Message


TrapErrorMessages@1 Method

The procedure TrapErrorMessages is available in codeunit 132215.

Syntax

TrapErrorMessages@1(
      //param element not supplied
);

Remarks

The relevant search keywords are: Trap, Error, Messages.

For a clarification about how this function works, refer to the code listed below.

      ErrorMessages.TRAP;

Example

There are no examples available.
Member of Lib.Library - Error Message


Library - Fiscal Year Class

Lib.Library - Fiscal Year

COD131302 applies to ERM,W1,All.
Library Functions related to Fiscal Year.

Methods

Name | Description
CheckPostingDate@4 | The procedure CheckPostingDate is available in codeunit 131302.
CloseAccountingPeriod@5 | The procedure CloseAccountingPeriod is available in codeunit 131302.
CloseFiscalYear@2 | The procedure CloseFiscalYear is available in codeunit 131302.
CreateFiscalYear@3 | The procedure CreateFiscalYear is available in codeunit 131302.
FindAccountingPeirodStartEndDate@9 | The procedure FindAccountingPeirodStartEndDate is available in codeunit 131302.
GetAccountingPeriodDate@7 | The procedure GetAccountingPeriodDate is available in codeunit 131302.
GetFirstPostingDate@1 | The procedure GetFirstPostingDate is available in codeunit 131302.
GetInitialPostingDate@1030 | The procedure GetInitialPostingDate is available in codeunit 131302.
GetLastPostingDate@8 | The procedure GetLastPostingDate is available in codeunit 131302.
GetPastNewYearDate@11 | The procedure GetPastNewYearDate is available in codeunit 131302.
GetStatisticsPeriod@6 | The procedure GetStatisticsPeriod is available in codeunit 131302.
IdentifyOpenAccountingPeriod@65 | The procedure IdentifyOpenAccountingPeriod is available in codeunit 131302.
UpdateAllowGAccDeletionBeforeDateOnGLSetup@22 | The procedure UpdateAllowGAccDeletionBeforeDateOnGLSetup is available in codeunit 131302.
VerifyDateCompressFALedgerError@97 | The procedure VerifyDateCompressFALedgerError is available in codeunit 131302.

See Also

Lib


CheckPostingDate@4 Method

The procedure CheckPostingDate is available in codeunit 131302.

Syntax

CheckPostingDate@4(
    PostingDate@1001 : Date PostingDate //Input parameter of type Date
);

Parameters

PostingDate
Input parameter of type Date

Remarks

The relevant search keywords are: Check, Posting, Date.

For a clarification about how this function works, refer to the code listed below.

      // Check if Posting Date is outside the Accounting Period then Create New Fiscal Year and close it.
      AccountingPeriod.FINDLAST;
      IF PostingDate > AccountingPeriod."Starting Date" THEN BEGIN
        CreateFiscalYear;
        CloseFiscalYear;
      END;

Example

The below example is extracted from the test automation codeunit 134007 to show one way of using this function.

      // Check error when Unapplying Vendor Ledger entry which have been Date Compressed.

      // Setup: Create and post General Journal Lines, find Closed Fiscal Year, Date Compress the Vendor Ledger Entry.
      Initialize;
      FirstPostingDate := LibraryFiscalYear.GetFirstPostingDate(TRUE);
      LibraryFiscalYear.CheckPostingDate(FirstPostingDate);
      CreatePostApplyGenJournalLine(
        GenJournalLine,GenJournalLine."Document Type"::Invoice,GenJournalLine."Document Type"::Payment,
        -LibraryRandom.RandDec(100,2),FirstPostingDate);
      DateCompressForVendor(GenJournalLine,FirstPostingDate,DateComprRegister."Period Length"::Day);
      FindDetailedLedgerEntry(
        DetailedVendorLedgEntry,DetailedVendorLedgEntry."Entry Type"::Application,'',GenJournalLine."Account No.");

      // Exercise: Unapply Vendor Ledger Entry Which have been Date Compress.
      ASSERTERROR VendEntryApplyPostedEntries.PostUnApplyVendor(
          DetailedVendorLedgEntry,GenJournalLine."Account No.",GenJournalLine."Posting Date");

      // Verify: Verify error when Unapplying Vendor Ledger entry which have been Date Compress.
      Assert.AreEqual(STRSUBSTNO(DateCompressUnapplyErr,VendorLedgerEntry.TABLECAPTION),GETLASTERRORTEXT,MessageDoNotMatchErr);
Member of Lib.Library - Fiscal Year


CloseAccountingPeriod@5 Method

The procedure CloseAccountingPeriod is available in codeunit 131302.

Syntax

CloseAccountingPeriod@5(
      //param element not supplied
);

Remarks

The relevant search keywords are: Close, Accounting, Period.

For a clarification about how this function works, refer to the code listed below.

      AccountingPeriod.SETRANGE(Closed,FALSE);
      AccountingPeriod.MODIFYALL(Closed,TRUE);

Example

The below example is extracted from the test automation codeunit 134819 to show one way of using this function.

      // Setup
      LibraryFiscalYear.CloseAccountingPeriod;
      CostTypeInsert(CostTypeNo,FALSE);
      CostEntryInsert(CostEntry,CostTypeNo,0);

      // Exercise
      CostType.GET(CostTypeNo);
      ASSERTERROR CostType.DELETE(TRUE);

      // Verify
      Assert.IsTrue(STRPOS(GETLASTERRORTEXT,EntriesWithinOpenFiscalYear) > 0,UnexpectedErr);
Member of Lib.Library - Fiscal Year


CloseFiscalYear@2 Method

The procedure CloseFiscalYear is available in codeunit 131302.

Syntax

CloseFiscalYear@2(
      //param element not supplied
);

Remarks

The relevant search keywords are: Close, Fiscal, Year.

For a clarification about how this function works, refer to the code listed below.

      // Close All opened Fiscal Years.
      AccountingPeriod.SETRANGE("New Fiscal Year",TRUE);
      AccountingPeriod.SETRANGE(Closed,FALSE);
      FOR Counter := 1 TO AccountingPeriod.COUNT - 1 DO BEGIN
        CODEUNIT.RUN(CODEUNIT::"Fiscal Year-Close",AccountingPeriod);
        IF Counter < AccountingPeriod.COUNT THEN
          AccountingPeriod.NEXT;
      END;
      COMMIT;  // Required because Modal Page Pops Up.

Example

The below example is extracted from the test automation codeunit 134032 to show one way of using this function.

      // Setup: Close the Open Fiscal Year. Make Payment and Invoice entries for a Customer from General Journal Line with same random
      // amount and Post them.
      LibraryFiscalYear.CloseFiscalYear;
      NoOfLines := LibraryRandom.RandInt(5);
      CreateDocumentLine(GenJournalLine,CustomerNo,NoOfLines,FirstPostingDate,Period);
      JnlLineAmount := NoOfLines * GenJournalLine.Amount;
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // Exercise: Run the Date Compress Customer Ledger Batch Report.
      DateCompressForCustomer(GenJournalLine,FirstPostingDate,PeriodLength);

      // Verify: Verify the Amount in Customer Ledger Entry.
      VerifyCustomerLedgerEntry(GenJournalLine."Account No.",JnlLineAmount);
      EXIT(GenJournalLine."Posting Date");
Member of Lib.Library - Fiscal Year


CreateFiscalYear@3 Method

The procedure CreateFiscalYear is available in codeunit 131302.

Syntax

CreateFiscalYear@3(
      //param element not supplied
);

Remarks

The relevant search keywords are: Create, Fiscal, Year.

For a clarification about how this function works, refer to the code listed below.

      // Find a Date to create a new Fiscal Year if no Fiscal Year exists in Demo Data.
      Date.SETRANGE("Period Type",Date."Period Type"::Year);
      Date.SETRANGE("Period No.",DATE2DMY(WORKDATE,3));
      Date.FINDFIRST;

      // Create a new Fiscal Year With Number of Periods = 12, Period Length = 1M.
      CLEAR(CreateFiscalYear);
      EVALUATE(PeriodLength,'<1M>');
      CreateFiscalYear.InitializeRequest(12,PeriodLength,Date."Period Start");
      CreateFiscalYear.USEREQUESTPAGE(FALSE);
      CreateFiscalYear.RUN;

Example

The below example is extracted from the test automation codeunit 134043 to show one way of using this function.

      // Check Amount on GL Entry After Running Close Income Statement with Closing Fiscal Year.

      // Setup: Close Already Opened Fiscal Year. Create New One, Update New currency on General Ledger Setup.
      // Create General Line and Post them with Random Values.
      Initialize;
      LibraryFiscalYear.CloseFiscalYear;
      LibraryFiscalYear.CreateFiscalYear;
      PostingDate := LibraryFiscalYear.GetFirstPostingDate(FALSE);

      CurrencyCode := LibraryERM.CreateCurrencyWithRandomExchRates;
      LibraryERM.SetAddReportingCurrency(CurrencyCode);

      SelectGenJournalBatch(GenJournalBatch);
      LibraryERM.CreateGLAccount(GLAccount);
      LibraryERM.CreateGeneralJnlLine(
        GenJournalLine,GenJournalBatch."Journal Template Name",GenJournalBatch.Name,GenJournalLine."Document Type"::" ",
        GenJournalLine."Account Type"::"G/L Account",GLAccount."No.",-LibraryRandom.RandDec(100,2));
      GenJournalLine.VALIDATE("Posting Date",PostingDate);
      GenJournalLine.MODIFY(TRUE);
      AdditionalCurrencyAmount := ROUND(LibraryERM.ConvertCurrency(GenJournalLine.Amount,'',CurrencyCode,WORKDATE));
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // Close Newly Created Fiscal Year. Customized Date formula required to calculate Fiscal Ending Date.
      LibraryFiscalYear.CloseFiscalYear;
      PostingDate := CALCDATE('<1M-1D>',LibraryFiscalYear.GetLastPostingDate(TRUE));

      // Exercise: Run Close Income Statement Batch Report.
      RunCloseIncomeStatementBatchJob(GenJournalLine,PostingDate);

      // Verify: Verify GL Entry for Fiscal Year Ending Date.
      EVALUATE(PostingDate,STRSUBSTNO(FiscalPostingDateTok,PostingDate));
      VerifyGLEntryForFiscalYear(PostingDate,GenJournalLine."Account No.",-GenJournalLine.Amount,-AdditionalCurrencyAmount);
Member of Lib.Library - Fiscal Year


FindAccountingPeirodStartEndDate@9 Method

The procedure FindAccountingPeirodStartEndDate is available in codeunit 131302.

Syntax

FindAccountingPeirodStartEndDate@9(
    VAR StartDate@1001 : Date StartDate, //Reference parameter of type Date
    VAR EndDate@1002 : Date EndDate, //Reference parameter of type Date
    NumberOfPeriods@1003 : Integer NumberOfPeriods //Input parameter of type Integer
);

Parameters

StartDate
Reference parameter of type Date
EndDate
Reference parameter of type Date
NumberOfPeriods
Input parameter of type Integer

Remarks

The relevant search keywords are: Find, Accounting, Peirod, Start, End, Date.

For a clarification about how this function works, refer to the code listed below.

      AccountingPeriod.FINDSET;
      StartDate := AccountingPeriod."Starting Date";
      AccountingPeriod.NEXT(NumberOfPeriods);
      EndDate := AccountingPeriod."Starting Date" - 1;

Example

The below example is extracted from the test automation codeunit 134996 to show one way of using this function.

      LibraryFiscalYear.FindAccountingPeirodStartEndDate(ExpectedAccPeriodStartDate,ExpectedAccPeriodEndDate,NumberOfPeriods);

      MakeActualAndExpectedDateFilters(
        ExpectedAccPeriodStartDate + LibraryRandom.RandIntInRange(5,10),
        ExpectedAccPeriodEndDate - LibraryRandom.RandIntInRange(5,10),
        ExpectedAccPeriodStartDate,ExpectedAccPeriodEndDate,
        ActualDateFilter,ExpectedDateFilter)
Member of Lib.Library - Fiscal Year


GetAccountingPeriodDate@7 Method

The procedure GetAccountingPeriodDate is available in codeunit 131302.

Syntax

GetAccountingPeriodDate@7(
    PostingDate@1001 : Date PostingDate //Input parameter of type Date
);

Parameters

PostingDate
Input parameter of type Date

Return Value

Date

Remarks

The relevant search keywords are: Get, Accounting, Period, Date.

For a clarification about how this function works, refer to the code listed below.

      AccountingPeriod.SETRANGE("Starting Date",0D,PostingDate);
      AccountingPeriod.FINDLAST;
      EXIT(AccountingPeriod."Starting Date");

Example

The below example is extracted from the test automation codeunit 134480 to show one way of using this function.

      // Check Item Analysis View Entry With Period Date Compression.

      // Create Item Analysis Entry and Create,Post Sales Invoice.
      Initialize;
      PostingDate := CreateAnalysisAndSalesInvoice(ItemAnalysisView,SalesLine,TRUE);

      // Run Item Analysis and Verify Posting Date on Item Analysis View Entry with Date Compression Year with Calculation
      // of Accounting Period Entry.
      RunAndVerifyItemAnalysis(
        ItemAnalysisView,SalesLine,ItemAnalysisView."Date Compression"::Period,LibraryFiscalYear.GetAccountingPeriodDate(PostingDate));
Member of Lib.Library - Fiscal Year


GetFirstPostingDate@1 Method

The procedure GetFirstPostingDate is available in codeunit 131302.

Syntax

GetFirstPostingDate@1(
    Closed@1001 : Boolean Closed //Input parameter of type Boolean
);

Parameters

Closed
Input parameter of type Boolean

Return Value

Date

Remarks

The relevant search keywords are: Get, First, Posting, Date.

For a clarification about how this function works, refer to the code listed below.

      AccountingPeriod.SETRANGE(Closed,Closed);
      AccountingPeriod.FINDFIRST;
      EXIT(AccountingPeriod."Starting Date");

Example

The below example is extracted from the test automation codeunit 134007 to show one way of using this function.

      // Check error when Unapplying Vendor Ledger entry which have been Date Compressed.

      // Setup: Create and post General Journal Lines, find Closed Fiscal Year, Date Compress the Vendor Ledger Entry.
      Initialize;
      FirstPostingDate := LibraryFiscalYear.GetFirstPostingDate(TRUE);
      LibraryFiscalYear.CheckPostingDate(FirstPostingDate);
      CreatePostApplyGenJournalLine(
        GenJournalLine,GenJournalLine."Document Type"::Invoice,GenJournalLine."Document Type"::Payment,
        -LibraryRandom.RandDec(100,2),FirstPostingDate);
      DateCompressForVendor(GenJournalLine,FirstPostingDate,DateComprRegister."Period Length"::Day);
      FindDetailedLedgerEntry(
        DetailedVendorLedgEntry,DetailedVendorLedgEntry."Entry Type"::Application,'',GenJournalLine."Account No.");

      // Exercise: Unapply Vendor Ledger Entry Which have been Date Compress.
      ASSERTERROR VendEntryApplyPostedEntries.PostUnApplyVendor(
          DetailedVendorLedgEntry,GenJournalLine."Account No.",GenJournalLine."Posting Date");

      // Verify: Verify error when Unapplying Vendor Ledger entry which have been Date Compress.
      Assert.AreEqual(STRSUBSTNO(DateCompressUnapplyErr,VendorLedgerEntry.TABLECAPTION),GETLASTERRORTEXT,MessageDoNotMatchErr);
Member of Lib.Library - Fiscal Year


GetInitialPostingDate@1030 Method

The procedure GetInitialPostingDate is available in codeunit 131302.

Syntax

GetInitialPostingDate@1030(
      //param element not supplied
);

Return Value

Date

Remarks

The relevant search keywords are: Get, Initial, Posting, Date.

For a clarification about how this function works, refer to the code listed below.

      EXIT(GetFirstPostingDate(TRUE));

Example

There are no examples available.
Member of Lib.Library - Fiscal Year


GetLastPostingDate@8 Method

The procedure GetLastPostingDate is available in codeunit 131302.

Syntax

GetLastPostingDate@8(
    Closed@1001 : Boolean Closed //Input parameter of type Boolean
);

Parameters

Closed
Input parameter of type Boolean

Return Value

Date

Remarks

The relevant search keywords are: Get, Last, Posting, Date.

For a clarification about how this function works, refer to the code listed below.

      AccountingPeriod.SETRANGE(Closed,Closed);
      AccountingPeriod.FINDLAST;
      EXIT(AccountingPeriod."Starting Date");

Example

The below example is extracted from the test automation codeunit 134043 to show one way of using this function.

      // Check Amount on GL Entry After Running Close Income Statement with Closing Fiscal Year.

      // Setup: Close Already Opened Fiscal Year. Create New One, Update New currency on General Ledger Setup.
      // Create General Line and Post them with Random Values.
      Initialize;
      LibraryFiscalYear.CloseFiscalYear;
      LibraryFiscalYear.CreateFiscalYear;
      PostingDate := LibraryFiscalYear.GetFirstPostingDate(FALSE);

      CurrencyCode := LibraryERM.CreateCurrencyWithRandomExchRates;
      LibraryERM.SetAddReportingCurrency(CurrencyCode);

      SelectGenJournalBatch(GenJournalBatch);
      LibraryERM.CreateGLAccount(GLAccount);
      LibraryERM.CreateGeneralJnlLine(
        GenJournalLine,GenJournalBatch."Journal Template Name",GenJournalBatch.Name,GenJournalLine."Document Type"::" ",
        GenJournalLine."Account Type"::"G/L Account",GLAccount."No.",-LibraryRandom.RandDec(100,2));
      GenJournalLine.VALIDATE("Posting Date",PostingDate);
      GenJournalLine.MODIFY(TRUE);
      AdditionalCurrencyAmount := ROUND(LibraryERM.ConvertCurrency(GenJournalLine.Amount,'',CurrencyCode,WORKDATE));
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // Close Newly Created Fiscal Year. Customized Date formula required to calculate Fiscal Ending Date.
      LibraryFiscalYear.CloseFiscalYear;
      PostingDate := CALCDATE('<1M-1D>',LibraryFiscalYear.GetLastPostingDate(TRUE));

      // Exercise: Run Close Income Statement Batch Report.
      RunCloseIncomeStatementBatchJob(GenJournalLine,PostingDate);

      // Verify: Verify GL Entry for Fiscal Year Ending Date.
      EVALUATE(PostingDate,STRSUBSTNO(FiscalPostingDateTok,PostingDate));
      VerifyGLEntryForFiscalYear(PostingDate,GenJournalLine."Account No.",-GenJournalLine.Amount,-AdditionalCurrencyAmount);
Member of Lib.Library - Fiscal Year


GetPastNewYearDate@11 Method

The procedure GetPastNewYearDate is available in codeunit 131302.

Syntax

GetPastNewYearDate@11(
    NumberOfPastYears@1000 : Integer NumberOfPastYears //Input parameter of type Integer
);

Parameters

NumberOfPastYears
Input parameter of type Integer

Return Value

Date

Remarks

The relevant search keywords are: Get, Past, New, Year, Date.

For a clarification about how this function works, refer to the code listed below.

      EXIT(CALCDATE(STRSUBSTNO('<-%1Y-CY>',NumberOfPastYears),WORKDATE));

Example

The below example is extracted from the test automation codeunit 134228 to show one way of using this function.

      // [SCENARIO 258044] Stan can delete G/L Account having posted G/L entries in closed accounting period with posting date later GLSetup."Allow G/L Acc. Deletion Before".
      // [SCENARIO 258044] He must approve confirmation.
      Initialize;

      LibraryFiscalYear.UpdateAllowGAccDeletionBeforeDateOnGLSetup(LibraryFiscalYear.GetPastNewYearDate(5));
      IntitializeGLAccountWithClosedEntriesClosedAccountingPeriod(GLAccount);

      LibraryVariableStorage.Enqueue(TRUE);
      GLAccount.DELETE(TRUE);

      GLEntry.INIT;
      GLEntry.SETRANGE("G/L Account No.",GLAccount."No.");
      Assert.RecordIsEmpty(GLEntry);
Member of Lib.Library - Fiscal Year


GetStatisticsPeriod@6 Method

The procedure GetStatisticsPeriod is available in codeunit 131302.

Syntax

GetStatisticsPeriod@6(
      //param element not supplied
);

Return Value

Text

Remarks

The relevant search keywords are: Get, Statistics, Period.

For a clarification about how this function works, refer to the code listed below.

      EXIT('<Year><Month,2>');

Example

There are no examples available.
Member of Lib.Library - Fiscal Year


IdentifyOpenAccountingPeriod@65 Method

The procedure IdentifyOpenAccountingPeriod is available in codeunit 131302.

Syntax

IdentifyOpenAccountingPeriod@65(
      //param element not supplied
);

Return Value

Date

Remarks

The relevant search keywords are: Identify, Open, Accounting, Period.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(AccountingPeriod);
      CloseAccountingPeriod;
      AccountingPeriod.INIT;
      AccountingPeriod.VALIDATE("Starting Date",CALCDATE('<+1M>',GetLastPostingDate(TRUE)));
      AccountingPeriod.INSERT(TRUE);
      EXIT(AccountingPeriod."Starting Date");

Example

The below example is extracted from the test automation codeunit 134152 to show one way of using this function.

      // [FEATURE] [UT] [Sales] [Intercompany] [Accounting Period]
      // [Scenario 378300] Update IC Partner Code of Customer with open entries within a fiscal year

      // [GIVEN] Set Customer and IC Partner
      ICPartnerCode := CreateICPartner;
      LibrarySales.CreateCustomer(Customer);

      // [GIVEN] Opened Customer Ledger Entry within current Accounting Period
      PostingDate := LibraryFiscalYear.IdentifyOpenAccountingPeriod;
      CreateCustLedgEntry(Customer."No.",PostingDate,TRUE);

      // [WHEN] Validate IC Partner Code on Customer
      ASSERTERROR Customer.VALIDATE("IC Partner Code",ICPartnerCode);

      // [THEN] Error occurs: You cannot change the contents of the IC Partner Code field because ...
      Assert.ExpectedError(STRSUBSTNO(ICPartnerCodeModifyErr,Customer.FIELDCAPTION("IC Partner Code"),Customer.TABLECAPTION));
Member of Lib.Library - Fiscal Year


UpdateAllowGAccDeletionBeforeDateOnGLSetup@22 Method

The procedure UpdateAllowGAccDeletionBeforeDateOnGLSetup is available in codeunit 131302.

Syntax

UpdateAllowGAccDeletionBeforeDateOnGLSetup@22(
    NewDate@1000 : Date NewDate //Input parameter of type Date
);

Parameters

NewDate
Input parameter of type Date

Remarks

The relevant search keywords are: Update, Allow, G, Account, Deletion, Before, Date, On, General Ledger, Setup.

For a clarification about how this function works, refer to the code listed below.

      GeneralLedgerSetup.GET;
      GeneralLedgerSetup."Allow G/L Acc. Deletion Before" := NewDate;
      GeneralLedgerSetup.MODIFY;

Example

The below example is extracted from the test automation codeunit 134228 to show one way of using this function.

      // [SCENARIO 258044] Stan can confirm to delete G/L Account having posted G/L entries in closed accounting period with posting date later GLSetup."Allow G/L Acc. Deletion Before"

      Initialize;

      LibraryFiscalYear.UpdateAllowGAccDeletionBeforeDateOnGLSetup(0D);
      IntitializeGLAccountWithClosedEntriesClosedAccountingPeriod(GLAccount);

      ASSERTERROR GLAccount.DELETE(TRUE);

      Assert.ExpectedError(CannotDeleteGLAccountBadSetupErr);

      GLEntry.INIT;
      GLEntry.SETRANGE("G/L Account No.",GLAccount."No.");
      Assert.RecordIsNotEmpty(GLEntry);
Member of Lib.Library - Fiscal Year


VerifyDateCompressFALedgerError@97 Method

The procedure VerifyDateCompressFALedgerError is available in codeunit 131302.

Syntax

VerifyDateCompressFALedgerError@97(
      //param element not supplied
);

Remarks

The relevant search keywords are: Verify, Date, Compress, Fixed Asset, Ledger, Error.

For a clarification about how this function works, refer to the code listed below.

      AccountingPeriod.SETRANGE("Date Locked",FALSE);
      AccountingPeriod.SETRANGE(Closed,FALSE);
      AccountingPeriod.SETRANGE("New Fiscal Year",TRUE);
      AccountingPeriod.FINDFIRST;
      Assert.ExpectedError(
        STRSUBSTNO(DateCompressErrorErr,AccountingPeriod.FIELDCAPTION("Date Locked"),AccountingPeriod.TABLECAPTION,
          AccountingPeriod.FIELDCAPTION("Starting Date"),AccountingPeriod."Starting Date"));

Example

The below example is extracted from the test automation codeunit 134049 to show one way of using this function.

      // Test the Date Compression with open Accounting Period.

      // 1.Setup: Create and modify Fixed Asset, create General Journal Batch, create Generel Journal Line,
      // post the FA General Journal line.
      Initialize;
      FANo := CreateFixedAssetWithDimension;
      CreateGenJournalBatch(GenJournalBatch);
      CreateGeneralJournalLines(GenJournalLine,GenJournalBatch,FANo,GenJournalLine."FA Posting Type"::"Acquisition Cost");
      PostingDateInGenJournalLine(GenJournalLine,LibraryFiscalYear.GetFirstPostingDate(FALSE));
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // 2.Exercise: Run the Date Compress FA Ledger.
      ASSERTERROR
        RunDateCompressFALedger(
          FANo,LibraryFiscalYear.GetFirstPostingDate(FALSE),LibraryFiscalYear.GetFirstPostingDate(FALSE),
          DateComprRegister."Period Length"::Day);

      // 3.Verify: Verify the Error message.
      LibraryFiscalYear.VerifyDateCompressFALedgerError;
Member of Lib.Library - Fiscal Year


Library - Fixed Asset Class

Lib.Library - Fixed Asset

COD131330 applies to RES,ERM,SCM,W1,IN.

Methods

Name | Description
CreateCommentLine@13 | The procedure CreateCommentLine is available in codeunit 131330.
CreateDepreciationBook@55 | The procedure CreateDepreciationBook is available in codeunit 131330.
CreateDepreciationTableHeader@74 | The procedure CreateDepreciationTableHeader is available in codeunit 131330.
CreateDepreciationTableLine@9 | The procedure CreateDepreciationTableLine is available in codeunit 131330.
CreateFABlock@1500009 | The procedure CreateFABlock is available in codeunit 131330.
CreateFAClass@1500015 | The procedure CreateFAClass is available in codeunit 131330.
CreateFADepreciationBook@53 | The procedure CreateFADepreciationBook is available in codeunit 131330.
CreateFAIncomeTaxAccPeriod@1500006 | The procedure CreateFAIncomeTaxAccPeriod is available in codeunit 131330.
CreateFAJournalBatch@64 | The procedure CreateFAJournalBatch is available in codeunit 131330.
CreateFAJournalLine@49 | The procedure CreateFAJournalLine is available in codeunit 131330.
CreateFAJournalSetup@57 | The procedure CreateFAJournalSetup is available in codeunit 131330.
CreateFALocation@1500000 | The procedure CreateFALocation is available in codeunit 131330.
CreateFAPostingGroup@58 | The procedure CreateFAPostingGroup is available in codeunit 131330.
CreateFAReclassJournal@3 | The procedure CreateFAReclassJournal is available in codeunit 131330.
CreateFAReclassJournalBatch@8 | The procedure CreateFAReclassJournalBatch is available in codeunit 131330.
CreateFASubclass@7 | The procedure CreateFASubclass is available in codeunit 131330.
CreateFAWithPostingGroup@22 | The procedure CreateFAWithPostingGroup is available in codeunit 131330.
CreateFixedAsset@48 | The procedure CreateFixedAsset is available in codeunit 131330.
CreateFAAllocation@60 | The procedure CreateFAAllocation is available in codeunit 131330.
CreateGLBudgetName@18 | The procedure CreateGLBudgetName is available in codeunit 131330.
CreateInsurance@46 | The procedure CreateInsurance is available in codeunit 131330.
CreateInsuranceJournalBatch@10 | The procedure CreateInsuranceJournalBatch is available in codeunit 131330.
CreateInsuranceJournalLine@1 | The procedure CreateInsuranceJournalLine is available in codeunit 131330.
CreateInsuranceType@100 | The procedure CreateInsuranceType is available in codeunit 131330.
CreateJournalTemplate@6 | The procedure CreateJournalTemplate is available in codeunit 131330.
CreateMainAssetComponent@89 | The procedure CreateMainAssetComponent is available in codeunit 131330.
CreateMaintenance@92 | The procedure CreateMaintenance is available in codeunit 131330.
FindEmployee@17 | The procedure FindEmployee is available in codeunit 131330.
FindFAClass@14 | The procedure FindFAClass is available in codeunit 131330.
FindFAJournalBatch@4 | The procedure FindFAJournalBatch is available in codeunit 131330.
FindFAJournalTemplate@5 | The procedure FindFAJournalTemplate is available in codeunit 131330.
FindFALocation@16 | The procedure FindFALocation is available in codeunit 131330.
FindFASubclass@15 | The procedure FindFASubclass is available in codeunit 131330.
FindInsurance@11 | The procedure FindInsurance is available in codeunit 131330.
GetDefaultDeprBook@21 | The procedure GetDefaultDeprBook is available in codeunit 131330.
PostFAJournalLine@50 | The procedure PostFAJournalLine is available in codeunit 131330.
PostFAJournalLineBatch@12 | The procedure PostFAJournalLineBatch is available in codeunit 131330.
PostInsuranceJournal@2 | The procedure PostInsuranceJournal is available in codeunit 131330.
VerifyLastFARegisterGLRegisterOneToOneRelation@20 | The procedure VerifyLastFARegisterGLRegisterOneToOneRelation is available in codeunit 131330.
VerifyMaintenanceLastFARegisterGLRegisterOneToOneRelation@19 | The procedure VerifyMaintenanceLastFARegisterGLRegisterOneToOneRelation is available in codeunit 131330.

See Also

Lib


CreateCommentLine@13 Method

The procedure CreateCommentLine is available in codeunit 131330.

Syntax

CreateCommentLine@13(
    VAR CommentLine@1000 : Record 97 CommentLine, //Reference parameter of type Record
    TableName@1001 : Option TableName, //Input parameter of type Option
    No@1002 : Code[20] No //Input parameter of type Code
);

Parameters

CommentLine
Reference parameter of type Record
TableName
Input parameter of type Option
No
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Comment, Line.

For a clarification about how this function works, refer to the code listed below.

      CommentLine.INIT;
      CommentLine.VALIDATE("Table Name",TableName);
      CommentLine.VALIDATE("No.",No);
      RecRef.GETTABLE(CommentLine);
      CommentLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,CommentLine.FIELDNO("Line No.")));
      CommentLine.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134452 to show one way of using this function.

      // Test Comment Deletion for Insurance.

      // 1. Setup: Create Insurance and Comment for It.
      Initialize;
      LibraryFixedAsset.CreateInsurance(Insurance);
      LibraryFixedAsset.CreateCommentLine(CommentLine,CommentLine."Table Name"::Insurance,Insurance."No.");

      // 2. Exercise: Delete Comment.
      CommentLine.DELETE(TRUE);

      // 3. Verify: Verify Comment successfully deleted.
      CommentLine.SETRANGE("Table Name",CommentLine."Table Name"::Insurance);
      CommentLine.SETRANGE("No.",Insurance."No.");
      Assert.IsFalse(
        CommentLine.FINDFIRST,
        STRSUBSTNO(
          CommentLineExistError,CommentLine.TABLECAPTION,CommentLine.FIELDCAPTION("No."),CommentLine."No.",
          CommentLine.FIELDCAPTION("Line No."),CommentLine."Line No."));
Member of Lib.Library - Fixed Asset


CreateDepreciationBook@55 Method

The procedure CreateDepreciationBook is available in codeunit 131330.

Syntax

CreateDepreciationBook@55(
    VAR DepreciationBook@1000 : Record 5611 DepreciationBook //Reference parameter of type Record
);

Parameters

DepreciationBook
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Depreciation, Book.

For a clarification about how this function works, refer to the code listed below.

      DepreciationBook.INIT;
      DepreciationBook.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(DepreciationBook.FIELDNO(Code),DATABASE::"Depreciation Book"),
          1,LibraryUtility.GetFieldLength(DATABASE::"Depreciation Book",DepreciationBook.FIELDNO(Code))));
      DepreciationBook.VALIDATE(Description,DepreciationBook.Code);  // Validating Description as Code because value is not important.
      DepreciationBook.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134135 to show one way of using this function.

      LibraryFixedAsset.CreateDepreciationBook(DepreciationBook);
      WITH DepreciationBook DO BEGIN
        VALIDATE("G/L Integration - Acq. Cost",TRUE);
        VALIDATE("G/L Integration - Maintenance",FALSE);
        VALIDATE("G/L Integration - Depreciation",TRUE);
        VALIDATE("G/L Integration - Disposal",TRUE);
        MODIFY(TRUE);
        EXIT(Code);
      END;
Member of Lib.Library - Fixed Asset


CreateDepreciationTableHeader@74 Method

The procedure CreateDepreciationTableHeader is available in codeunit 131330.

Syntax

CreateDepreciationTableHeader@74(
    VAR DepreciationTableHeader@1000 : Record 5642 DepreciationTableHeader //Reference parameter of type Record
);

Parameters

DepreciationTableHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Depreciation, Table, Header.

For a clarification about how this function works, refer to the code listed below.

      DepreciationTableHeader.INIT;
      DepreciationTableHeader.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(DepreciationTableHeader.FIELDNO(Code),DATABASE::"Depreciation Table Header"),
          1,
          LibraryUtility.GetFieldLength(DATABASE::"Depreciation Table Header",DepreciationTableHeader.FIELDNO(Code))));

      // Validating Description as Code because value is not important.
      DepreciationTableHeader.VALIDATE(Description,DepreciationTableHeader.Code);
      DepreciationTableHeader.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134450 to show one way of using this function.

      // Test Depreciation Table and Line Creation.

      // 1. Setup:
      Initialize;

      // 2. Exercise: Create FA Depreciation Table Header and Line.
      LibraryFixedAsset.CreateDepreciationTableHeader(DepreciationTableHeader);
      CreateDepreciationTableLine(DepreciationTableLine,DepreciationTableHeader.Code);

      // 3. Verify: Check FA Depreciation Table created correctly.
      DepreciationTableHeader.GET(DepreciationTableLine."Depreciation Table Code");
      DepreciationTableLine.TESTFIELD(
        "No. of Units in Period",
        ROUND(DepreciationTableHeader."Total No. of Units" * DepreciationTableLine."Period Depreciation %" / 100,0.00001));
Member of Lib.Library - Fixed Asset


CreateDepreciationTableLine@9 Method

The procedure CreateDepreciationTableLine is available in codeunit 131330.

Syntax

CreateDepreciationTableLine@9(
    VAR DepreciationTableLine@1001 : Record 5643 DepreciationTableLine, //Reference parameter of type Record
    DepreciationTableCode@1000 : Code[10] DepreciationTableCode //Input parameter of type Code
);

Parameters

DepreciationTableLine
Reference parameter of type Record
DepreciationTableCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Depreciation, Table, Line.

For a clarification about how this function works, refer to the code listed below.

      DepreciationTableLine.SETRANGE("Depreciation Table Code",DepreciationTableCode);
      // Check if Lines are alredy exist.
      IF DepreciationTableLine.FINDLAST THEN;
      DepreciationTableLine.INIT;
      DepreciationTableLine.VALIDATE("Depreciation Table Code",DepreciationTableCode);
      DepreciationTableLine.VALIDATE("Period No.",DepreciationTableLine."Period No." + 1);
      DepreciationTableLine.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134450 to show one way of using this function.

      LibraryFixedAsset.CreateDepreciationTableLine(DepreciationTableLine,DepreciationTableHeaderCode);
      // Using RANDOM value for Period Depreciation %.
      DepreciationTableLine.VALIDATE("Period Depreciation %",10 * LibraryRandom.RandDec(10,2));
      DepreciationTableLine.MODIFY(TRUE);
Member of Lib.Library - Fixed Asset


CreateFABlock@1500009 Method

The procedure CreateFABlock is available in codeunit 131330.

Syntax

CreateFABlock@1500009(
    VAR FABlock@1500000 : Record 16518 FABlock, //Reference parameter of type Record
    FAClassCode@1500001 : Code[10] FAClassCode //Input parameter of type Code
);

Parameters

FABlock
Reference parameter of type Record
FAClassCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Fixed Asset, Block.

For a clarification about how this function works, refer to the code listed below.

      FABlock.INIT;
      FABlock.VALIDATE("FA Class Code",FAClassCode);
      FABlock.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(FABlock.FIELDNO(Code),DATABASE::"FA Block"),
          1,LibraryUtility.GetFieldLength(DATABASE::"FA Block",FABlock.FIELDNO(Code))));
      FABlock.VALIDATE(Description,FABlock.Code + ' ' + FABlock."FA Class Code");
      FABlock.INSERT(TRUE)

Example

The below example is extracted from the test automation codeunit 144010 to show one way of using this function.

      LibraryFixedAsset.CreateFABlock(FABlock,FAClassCode);
      FABlock.VALIDATE("Depreciation %",LibraryRandom.RandDecInDecimalRange(1,100,2));
      FABlock.VALIDATE("Add. Depreciation %",LibraryRandom.RandDecInDecimalRange(1,100,2));
      FABlock.MODIFY(TRUE)
Member of Lib.Library - Fixed Asset


CreateFAClass@1500015 Method

The procedure CreateFAClass is available in codeunit 131330.

Syntax

CreateFAClass@1500015(
    VAR FAClass@1500000 : Record 5607 FAClass //Reference parameter of type Record
);

Parameters

FAClass
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Fixed Asset, Class.

For a clarification about how this function works, refer to the code listed below.

      FAClass.INIT;
      FAClass.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(FAClass.FIELDNO(Code),DATABASE::"FA Class"),
          1,LibraryUtility.GetFieldLength(DATABASE::"FA Class",FAClass.FIELDNO(Code))));
      FAClass.VALIDATE(Name,FAClass.Code);
      FAClass.INSERT(TRUE)

Example

The below example is extracted from the test automation codeunit 144010 to show one way of using this function.

      CreateAndValidateDepreciationBookIncomeTax(DepreciationBook);
      LibraryFixedAsset.CreateFAClass(FAClass);
      CreateAndValidateFABlock(FABlock,FAClass.Code);
      LibraryFixedAsset.CreateFASubclass(FASubclass);
      LibraryFixedAsset.CreateFALocation(FALocation);
      LibraryFixedAsset.CreateFAPostingGroup(FAPostingGroup);
Member of Lib.Library - Fixed Asset


CreateFADepreciationBook@53 Method

The procedure CreateFADepreciationBook is available in codeunit 131330.

Syntax

CreateFADepreciationBook@53(
    VAR FADepreciationBook@1000 : Record 5612 FADepreciationBook, //Reference parameter of type Record
    FANo@1001 : Code[20] FANo, //Input parameter of type Code
    DepreciationBookCode@1003 : Code[10] DepreciationBookCode //Input parameter of type Code
);

Parameters

FADepreciationBook
Reference parameter of type Record
FANo
Input parameter of type Code
DepreciationBookCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Fixed Asset, Depreciation, Book.

For a clarification about how this function works, refer to the code listed below.

      FADepreciationBook.INIT;
      FADepreciationBook.VALIDATE("FA No.",FANo);
      FADepreciationBook.VALIDATE("Depreciation Book Code",DepreciationBookCode);
      FADepreciationBook.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134049 to show one way of using this function.

      LibraryFixedAsset.CreateFADepreciationBook(FADepreciationBook,No,DepreciationBookCode);
      UpdateDateFADepreciationBook(FADepreciationBook,DepreciationBookCode);
      FADepreciationBook.VALIDATE("FA Posting Group",FAPostingGroup);
      FADepreciationBook.MODIFY(TRUE);
Member of Lib.Library - Fixed Asset


CreateFAIncomeTaxAccPeriod@1500006 Method

The procedure CreateFAIncomeTaxAccPeriod is available in codeunit 131330.

Syntax

CreateFAIncomeTaxAccPeriod@1500006(
    CurrentDate@1500009 : Date CurrentDate //Input parameter of type Date
);

Parameters

CurrentDate
Input parameter of type Date

Remarks

The relevant search keywords are: Create, Fixed Asset, Income, Tax, Account, Period.

For a clarification about how this function works, refer to the code listed below.

      StartingDate := CALCDATE('<CM+1D-1M>',CurrentDate);

      FiscalYearStartDate := StartingDate;
      EVALUATE(PeriodLength,'<1M>');

      FOR i := 1 TO 13 DO BEGIN
        FAAccountingPeriodIncTax.INIT;
        FAAccountingPeriodIncTax."Starting Date" := FiscalYearStartDate;
        FAAccountingPeriodIncTax.VALIDATE("Starting Date");
        IF (i = 1) OR (i = 13) THEN
          FAAccountingPeriodIncTax."New Fiscal Year" := TRUE;
        IF NOT FAAccountingPeriodIncTax.FIND THEN
          FAAccountingPeriodIncTax.INSERT;
        FiscalYearStartDate := CALCDATE(PeriodLength,FiscalYearStartDate);
      END;

Example

The below example is extracted from the test automation codeunit 134450 to show one way of using this function.

      LibraryVariableStorage.Clear;
      IF isInitialized THEN
        EXIT;

      LibraryERMCountryData.CreateVATData;
      LibraryERMCountryData.UpdateFAPostingGroup;
      LibraryERMCountryData.CreateNewFiscalYear;
      LibraryERMCountryData.UpdateVATPostingSetup;
      LibraryERMCountryData.UpdatePurchasesPayablesSetup;
      LibraryERMCountryData.UpdateAccountInCustomerPostingGroup;
      LibraryFixedAsset.CreateFAIncomeTaxAccPeriod(WORKDATE);
      isInitialized := TRUE;
      COMMIT;
Member of Lib.Library - Fixed Asset


CreateFAJournalBatch@64 Method

The procedure CreateFAJournalBatch is available in codeunit 131330.

Syntax

CreateFAJournalBatch@64(
    VAR FAJournalBatch@1000 : Record 5620 FAJournalBatch, //Reference parameter of type Record
    JournalTemplateName@1001 : Code[10] JournalTemplateName //Input parameter of type Code
);

Parameters

FAJournalBatch
Reference parameter of type Record
JournalTemplateName
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Fixed Asset, Journal, Batch.

For a clarification about how this function works, refer to the code listed below.

      // creates a new FA Journal Batch named with the next available number (if it does not yet exist), OR
      // returns the FA Journal batch named with the next available number

      FAJournalBatch.INIT;
      FAJournalBatch.VALIDATE("Journal Template Name",JournalTemplateName);
      FAJournalBatch.VALIDATE(
        Name,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(FAJournalBatch.FIELDNO(Name),DATABASE::"FA Journal Batch"),
          1,
          LibraryUtility.GetFieldLength(DATABASE::"FA Journal Batch",FAJournalBatch.FIELDNO(Name))));
      FAJournalBatch.VALIDATE(Description,FAJournalBatch.Name);  // Validating Description as Name because value is not important.
      IF FAJournalBatch.INSERT(TRUE) THEN ;

Example

The below example is extracted from the test automation codeunit 134450 to show one way of using this function.

      FAJournalTemplate.SETRANGE(Recurring,FALSE);
      LibraryFixedAsset.FindFAJournalTemplate(FAJournalTemplate);
      LibraryFixedAsset.CreateFAJournalBatch(FAJournalBatch,FAJournalTemplate.Name);
      FAJournalBatch.VALIDATE("No. Series",LibraryUtility.GetGlobalNoSeriesCode);
      FAJournalBatch.MODIFY(TRUE);
Member of Lib.Library - Fixed Asset


CreateFAJournalLine@49 Method

The procedure CreateFAJournalLine is available in codeunit 131330.

Syntax

CreateFAJournalLine@49(
    VAR FAJournalLine@1006 : Record 5621 FAJournalLine, //Reference parameter of type Record
    JournalTemplateName@1005 : Code[10] JournalTemplateName, //Input parameter of type Code
    JournalBatchName@1004 : Code[10] JournalBatchName //Input parameter of type Code
);

Parameters

FAJournalLine
Reference parameter of type Record
JournalTemplateName
Input parameter of type Code
JournalBatchName
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Fixed Asset, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      // Create a Fixed Asset General Journal Entry.
      FAJournalLine.INIT;
      FAJournalLine.VALIDATE("Journal Template Name",JournalTemplateName);
      FAJournalLine.VALIDATE("Journal Batch Name",JournalBatchName);
      RecRef.GETTABLE(FAJournalLine);
      FAJournalLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,FAJournalLine.FIELDNO("Line No.")));
      FAJournalLine.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134450 to show one way of using this function.

      CreateFAJournalBatch(FAJournalBatch);
      LibraryFixedAsset.CreateFAJournalLine(FAJournalLine,FAJournalBatch."Journal Template Name",FAJournalBatch.Name);
      FAJournalLine.VALIDATE("Document Type",DocumentType);
      FAJournalLine.VALIDATE("Document No.",GetDocumentNo(FAJournalBatch));
      FAJournalLine.VALIDATE("Posting Date",WORKDATE);
      FAJournalLine.VALIDATE("FA Posting Date",WORKDATE);
      FAJournalLine.VALIDATE("FA Posting Type",FAPostingType);
      FAJournalLine.VALIDATE("FA No.",FANo);
      FAJournalLine.VALIDATE(Amount,LibraryRandom.RandInt(1000));  // Using Random Number Generator for Amount.
      FAJournalLine.VALIDATE("Depreciation Book Code",DepreciationBookCode);
      FAJournalLine.MODIFY(TRUE);
Member of Lib.Library - Fixed Asset


CreateFAJournalSetup@57 Method

The procedure CreateFAJournalSetup is available in codeunit 131330.

Syntax

CreateFAJournalSetup@57(
    VAR FAJournalSetup@1000 : Record 5605 FAJournalSetup, //Reference parameter of type Record
    DepreciationBookCode@1001 : Code[10] DepreciationBookCode, //Input parameter of type Code
    UserID@1002 : Code[20] UserID //Input parameter of type Code
);

Parameters

FAJournalSetup
Reference parameter of type Record
DepreciationBookCode
Input parameter of type Code
UserID
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Fixed Asset, Journal, Setup.

For a clarification about how this function works, refer to the code listed below.

      FAJournalSetup.INIT;
      FAJournalSetup.VALIDATE("Depreciation Book Code",DepreciationBookCode);
      FAJournalSetup.VALIDATE("User ID",UserID);
      FAJournalSetup.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134135 to show one way of using this function.

      LibraryJournals.CreateGenJournalBatch(GenJournalBatch);
      LibraryFixedAsset.CreateFAJournalSetup(FAJournalSetup,DepreciationBookCode,'');
      FAJournalSetup.VALIDATE("Gen. Jnl. Template Name",GenJournalBatch."Journal Template Name");
      FAJournalSetup.VALIDATE("Gen. Jnl. Batch Name",GenJournalBatch.Name);
      FAJournalSetup.MODIFY(TRUE);
Member of Lib.Library - Fixed Asset


CreateFALocation@1500000 Method

The procedure CreateFALocation is available in codeunit 131330.

Syntax

CreateFALocation@1500000(
    VAR FALocation@1000 : Record 5609 FALocation //Reference parameter of type Record
);

Parameters

FALocation
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Fixed Asset, Location.

For a clarification about how this function works, refer to the code listed below.

      FALocation.INIT;
      FALocation.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(FALocation.FIELDNO(Code),DATABASE::"FA Location"),1,
          LibraryUtility.GetFieldLength(DATABASE::"FA Location",FALocation.FIELDNO(Code))));
      FALocation.INSERT(TRUE)

Example

The below example is extracted from the test automation codeunit 144010 to show one way of using this function.

      CreateAndValidateDepreciationBookIncomeTax(DepreciationBook);
      LibraryFixedAsset.CreateFAClass(FAClass);
      CreateAndValidateFABlock(FABlock,FAClass.Code);
      LibraryFixedAsset.CreateFASubclass(FASubclass);
      LibraryFixedAsset.CreateFALocation(FALocation);
      LibraryFixedAsset.CreateFAPostingGroup(FAPostingGroup);
Member of Lib.Library - Fixed Asset


CreateFAPostingGroup@58 Method

The procedure CreateFAPostingGroup is available in codeunit 131330.

Syntax

CreateFAPostingGroup@58(
    VAR FAPostingGroup@1000 : Record 5606 FAPostingGroup //Reference parameter of type Record
);

Parameters

FAPostingGroup
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Fixed Asset, Posting, Group.

For a clarification about how this function works, refer to the code listed below.

      FAPostingGroup.INIT;
      FAPostingGroup.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(FAPostingGroup.FIELDNO(Code),DATABASE::"FA Posting Group"),
          1,LibraryUtility.GetFieldLength(DATABASE::"FA Posting Group",FAPostingGroup.FIELDNO(Code))));
      FAPostingGroup.VALIDATE("Acquisition Cost Account",LibraryERM.CreateGLAccountWithPurchSetup);
      FAPostingGroup.VALIDATE("Accum. Depreciation Account",LibraryERM.CreateGLAccountNo);
      FAPostingGroup.VALIDATE("Write-Down Account",LibraryERM.CreateGLAccountNo);
      FAPostingGroup.VALIDATE("Appreciation Account",LibraryERM.CreateGLAccountNo);
      FAPostingGroup.VALIDATE("Custom 1 Account",LibraryERM.CreateGLAccountNo);
      FAPostingGroup.VALIDATE("Custom 2 Account",LibraryERM.CreateGLAccountNo);
      FAPostingGroup.VALIDATE("Acq. Cost Acc. on Disposal",LibraryERM.CreateGLAccountWithPurchSetup);
      FAPostingGroup.VALIDATE("Accum. Depr. Acc. on Disposal",LibraryERM.CreateGLAccountNo);
      FAPostingGroup.VALIDATE("Write-Down Acc. on Disposal",LibraryERM.CreateGLAccountNo);
      FAPostingGroup.VALIDATE("Appreciation Acc. on Disposal",LibraryERM.CreateGLAccountNo);
      FAPostingGroup.VALIDATE("Custom 1 Account on Disposal",LibraryERM.CreateGLAccountNo);
      FAPostingGroup.VALIDATE("Custom 2 Account on Disposal",LibraryERM.CreateGLAccountNo);
      FAPostingGroup.VALIDATE("Gains Acc. on Disposal",LibraryERM.CreateGLAccountNo);
      FAPostingGroup.VALIDATE("Losses Acc. on Disposal",LibraryERM.CreateGLAccountNo);
      FAPostingGroup.VALIDATE("Book Val. Acc. on Disp. (Gain)",LibraryERM.CreateGLAccountNo);
      FAPostingGroup.VALIDATE("Sales Acc. on Disp. (Gain)",LibraryERM.CreateGLAccountNo);
      FAPostingGroup.VALIDATE("Write-Down Bal. Acc. on Disp.",LibraryERM.CreateGLAccountNo);
      FAPostingGroup.VALIDATE("Apprec. Bal. Acc. on Disp.",LibraryERM.CreateGLAccountNo);
      FAPostingGroup.VALIDATE("Custom 1 Bal. Acc. on Disposal",LibraryERM.CreateGLAccountNo);
      FAPostingGroup.VALIDATE("Custom 2 Bal. Acc. on Disposal",LibraryERM.CreateGLAccountNo);
      FAPostingGroup.VALIDATE("Maintenance Expense Account",LibraryERM.CreateGLAccountWithPurchSetup);
      FAPostingGroup.VALIDATE("Maintenance Bal. Acc.",LibraryERM.CreateGLAccountNo);
      FAPostingGroup.VALIDATE("Acquisition Cost Bal. Acc.",LibraryERM.CreateGLAccountNo);
      FAPostingGroup.VALIDATE("Depreciation Expense Acc.",LibraryERM.CreateGLAccountNo);
      FAPostingGroup.VALIDATE("Write-Down Expense Acc.",LibraryERM.CreateGLAccountNo);
      FAPostingGroup.VALIDATE("Appreciation Bal. Account",LibraryERM.CreateGLAccountNo);
      FAPostingGroup.VALIDATE("Custom 1 Expense Acc.",LibraryERM.CreateGLAccountNo);
      FAPostingGroup.VALIDATE("Custom 2 Expense Acc.",LibraryERM.CreateGLAccountNo);
      FAPostingGroup.VALIDATE("Sales Bal. Acc.",LibraryERM.CreateGLAccountNo);
      FAPostingGroup.VALIDATE("Sales Acc. on Disp. (Loss)",LibraryERM.CreateGLAccountNo);
      FAPostingGroup.VALIDATE("Book Val. Acc. on Disp. (Loss)",LibraryERM.CreateGLAccountNo);

      FAPostingGroup.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134135 to show one way of using this function.

      LibraryFixedAsset.CreateFAPostingGroup(FAPostingGroup);
      LibraryFixedAsset.CreateFixedAsset(FixedAsset);
      LibraryFixedAsset.CreateFADepreciationBook(FADepreciationBook,FixedAsset."No.",DepreciationBookCode);
      FADepreciationBook.VALIDATE("FA Posting Group",FAPostingGroup.Code);
      FADepreciationBook.MODIFY(TRUE);
      EXIT(FixedAsset."No.");
Member of Lib.Library - Fixed Asset


CreateFAReclassJournal@3 Method

The procedure CreateFAReclassJournal is available in codeunit 131330.

Syntax

CreateFAReclassJournal@3(
    VAR FAReclassJournalLine@1000 : Record 5624 FAReclassJournalLine, //Reference parameter of type Record
    JournalTemplateName@1001 : Code[10] JournalTemplateName, //Input parameter of type Code
    JournalBatchName@1002 : Code[10] JournalBatchName //Input parameter of type Code
);

Parameters

FAReclassJournalLine
Reference parameter of type Record
JournalTemplateName
Input parameter of type Code
JournalBatchName
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Fixed Asset, Reclass, Journal.

For a clarification about how this function works, refer to the code listed below.

      // Create a Fixed Asset Reclass Journal Entry.
      FAReclassJournalLine.INIT;
      FAReclassJournalLine.VALIDATE("Journal Template Name",JournalTemplateName);
      FAReclassJournalLine.VALIDATE("Journal Batch Name",JournalBatchName);
      RecRef.GETTABLE(FAReclassJournalLine);
      FAReclassJournalLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,FAReclassJournalLine.FIELDNO("Line No.")));
      FAReclassJournalLine.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134453 to show one way of using this function.

      FAReclassJournalTemplate.FINDFIRST;
      LibraryFixedAsset.CreateFAReclassJournalBatch(FAReclassJournalBatch,FAReclassJournalTemplate.Name);
      LibraryFixedAsset.CreateFAReclassJournal(
        FAReclassJournalLine,FAReclassJournalBatch."Journal Template Name",FAReclassJournalBatch.Name);
      FAReclassJournalLine.VALIDATE("FA Posting Date",CALCDATE('<' + PeriodTxt + 'M>',WORKDATE));
      DocumentNo := LibraryUtility.GenerateGUID;
      FAReclassJournalLine.VALIDATE("Document No.",DocumentNo);
      FAReclassJournalLine.VALIDATE("FA No.",FANo);
      FAReclassJournalLine.VALIDATE("New FA No.",NewFANo);
      FAReclassJournalLine.VALIDATE("Depreciation Book Code",DepreciationBookCode);
      FAReclassJournalLine.VALIDATE("Reclassify Acq. Cost %",ReclassifyAcqCostPct);
      FAReclassJournalLine.VALIDATE("Reclassify Acquisition Cost",TRUE);
      FAReclassJournalLine.VALIDATE("Reclassify Depreciation",TRUE);
      FAReclassJournalLine.MODIFY(TRUE);
      CODEUNIT.RUN(CODEUNIT::"FA Reclass. Jnl.-Transfer",FAReclassJournalLine);
Member of Lib.Library - Fixed Asset


CreateFAReclassJournalBatch@8 Method

The procedure CreateFAReclassJournalBatch is available in codeunit 131330.

Syntax

CreateFAReclassJournalBatch@8(
    VAR FAReclassJournalBatch@1000 : Record 5623 FAReclassJournalBatch, //Reference parameter of type Record
    JournalTemplateName@1001 : Code[10] JournalTemplateName //Input parameter of type Code
);

Parameters

FAReclassJournalBatch
Reference parameter of type Record
JournalTemplateName
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Fixed Asset, Reclass, Journal, Batch.

For a clarification about how this function works, refer to the code listed below.

      FAReclassJournalBatch.INIT;
      FAReclassJournalBatch.VALIDATE("Journal Template Name",JournalTemplateName);
      FAReclassJournalBatch.VALIDATE(
        Name,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(FAReclassJournalBatch.FIELDNO(Name),DATABASE::"FA Reclass. Journal Batch"),
          1,
          LibraryUtility.GetFieldLength(DATABASE::"FA Journal Batch",FAReclassJournalBatch.FIELDNO(Name))));

      // Validating Description as Name because value is not important.
      FAReclassJournalBatch.VALIDATE(Description,FAReclassJournalBatch.Name);
      FAReclassJournalBatch.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134453 to show one way of using this function.

      FAReclassJournalTemplate.FINDFIRST;
      LibraryFixedAsset.CreateFAReclassJournalBatch(FAReclassJournalBatch,FAReclassJournalTemplate.Name);
      LibraryFixedAsset.CreateFAReclassJournal(
        FAReclassJournalLine,FAReclassJournalBatch."Journal Template Name",FAReclassJournalBatch.Name);
      FAReclassJournalLine.VALIDATE("FA Posting Date",CALCDATE('<' + PeriodTxt + 'M>',WORKDATE));
      DocumentNo := LibraryUtility.GenerateGUID;
      FAReclassJournalLine.VALIDATE("Document No.",DocumentNo);
      FAReclassJournalLine.VALIDATE("FA No.",FANo);
      FAReclassJournalLine.VALIDATE("New FA No.",NewFANo);
      FAReclassJournalLine.VALIDATE("Depreciation Book Code",DepreciationBookCode);
      FAReclassJournalLine.VALIDATE("Reclassify Acq. Cost %",ReclassifyAcqCostPct);
      FAReclassJournalLine.VALIDATE("Reclassify Acquisition Cost",TRUE);
      FAReclassJournalLine.VALIDATE("Reclassify Depreciation",TRUE);
      FAReclassJournalLine.MODIFY(TRUE);
      CODEUNIT.RUN(CODEUNIT::"FA Reclass. Jnl.-Transfer",FAReclassJournalLine);
Member of Lib.Library - Fixed Asset


CreateFASubclass@7 Method

The procedure CreateFASubclass is available in codeunit 131330.

Syntax

CreateFASubclass@7(
    VAR FASubclass@1000 : Record 5608 FASubclass //Reference parameter of type Record
);

Parameters

FASubclass
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Fixed Asset, Subclass.

For a clarification about how this function works, refer to the code listed below.

      FASubclass.INIT;
      FASubclass.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(FASubclass.FIELDNO(Code),DATABASE::"FA Subclass"),
          1,
          LibraryUtility.GetFieldLength(DATABASE::"FA Subclass",FASubclass.FIELDNO(Code))));

      // Validating Name as Code because value is not important.
      FASubclass.VALIDATE(Name,FASubclass.Code);
      FASubclass.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134450 to show one way of using this function.

      // Test Fixed Asset Posting Group.

      // 1. Setup:
      Initialize;

      // 2. Exercise: Create Fixed Asset Posting Group and Sub Class.
      LibraryFixedAsset.CreateFAPostingGroup(FAPostingGroup);
      LibraryFixedAsset.CreateFASubclass(FASubclass);

      // 3. Verify: Check FA Posting Group and Sub Class generated.
      FAPostingGroup.GET(FAPostingGroup.Code);
      FASubclass.GET(FASubclass.Code);
Member of Lib.Library - Fixed Asset


CreateFAWithPostingGroup@22 Method

The procedure CreateFAWithPostingGroup is available in codeunit 131330.

Syntax

CreateFAWithPostingGroup@22(
    VAR FixedAsset@1000 : Record 5600 FixedAsset //Reference parameter of type Record
);

Parameters

FixedAsset
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Fixed Asset, Posting, Group.

For a clarification about how this function works, refer to the code listed below.

      CreateFAPostingGroup(FAPostingGroup);
      CreateFixedAsset(FixedAsset);
      FixedAsset.VALIDATE("FA Posting Group",FAPostingGroup.Code);
      FixedAsset.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134049 to show one way of using this function.

      DepreciationBook.GET(LibraryFixedAsset.GetDefaultDeprBook);
      LibraryFixedAsset.CreateFAWithPostingGroup(FixedAsset);
      CreateFADepreciationBook(FADepreciationBook,FixedAsset."No.",DepreciationBook.Code,FixedAsset."FA Posting Group");
      UpdateFixedAsset(FixedAsset);
      AttachDimensionOnFixedAsset(DimensionValue,FixedAsset."No.");
      EXIT(FixedAsset."No.");
Member of Lib.Library - Fixed Asset


CreateFixedAsset@48 Method

The procedure CreateFixedAsset is available in codeunit 131330.

Syntax

CreateFixedAsset@48(
    VAR FixedAsset@1000 : Record 5600 FixedAsset //Reference parameter of type Record
);

Parameters

FixedAsset
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Fixed, Asset.

For a clarification about how this function works, refer to the code listed below.

      LibraryUtility.UpdateSetupNoSeriesCode(DATABASE::"FA Setup",FASetup.FIELDNO("Fixed Asset Nos."));

      FixedAsset.INIT;
      FixedAsset.INSERT(TRUE);
      FixedAsset.VALIDATE(Description,FixedAsset."No.");  // Validating Description as No because value is not important.
      LibraryERM.FindGenProductPostingGroup(GenProductPostingGroup);
      FixedAsset.VALIDATE("Gen. Prod. Posting Group",GenProductPostingGroup.Code);
      FixedAsset.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134100 to show one way of using this function.

      LibraryFixedAsset.CreateFixedAsset(FixedAsset);
      FAPostingGroupCode := CreateFAPostingGroupWithPostingSetup(LineGLAccount);

      LibraryFixedAsset.CreateFADepreciationBook(FADepreciationBook,FixedAsset."No.",LibraryFixedAsset.GetDefaultDeprBook);
      FADepreciationBook.VALIDATE("FA Posting Group",FAPostingGroupCode);
      FADepreciationBook.MODIFY(TRUE);

      EXIT(FixedAsset."No.");
Member of Lib.Library - Fixed Asset


CreateFAAllocation@60 Method

The procedure CreateFAAllocation is available in codeunit 131330.

Syntax

CreateFAAllocation@60(
    VAR FAAllocation@1000 : Record 5615 FAAllocation, //Reference parameter of type Record
    Code@1003 : Code[10] Code, //Input parameter of type Code
    AllocationType@1001 : Option AllocationType //Input parameter of type Option
);

Parameters

FAAllocation
Reference parameter of type Record
Code
Input parameter of type Code
AllocationType
Input parameter of type Option

Remarks

The relevant search keywords are: Create, Fixed Asset, Allocation.

For a clarification about how this function works, refer to the code listed below.

      FAAllocation.INIT;
      FAAllocation.VALIDATE(Code,Code);
      FAAllocation.VALIDATE("Allocation Type",AllocationType);
      RecRef.GETTABLE(FAAllocation);
      FAAllocation.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,FAAllocation.FIELDNO("Line No.")));
      FAAllocation.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134450 to show one way of using this function.

      // Using Random Number Generator for creating the lines.
      FOR Counter := 1 TO 1 + LibraryRandom.RandInt(3) DO BEGIN
        CLEAR(FAAllocation);
        LibraryFixedAsset.CreateFAAllocation(FAAllocation,FAPostingGroup,FAAllocation."Allocation Type"::Depreciation);
        UpdateFAAllocation(FAAllocation);
      END;
      EXIT(Counter);
Member of Lib.Library - Fixed Asset


CreateGLBudgetName@18 Method

The procedure CreateGLBudgetName is available in codeunit 131330.

Syntax

CreateGLBudgetName@18(
    VAR GLBudgetName@1000 : Record 95 GLBudgetName //Reference parameter of type Record
);

Parameters

GLBudgetName
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, General Ledger, Budget, Name.

For a clarification about how this function works, refer to the code listed below.

      GLBudgetName.INIT;
      GLBudgetName.VALIDATE(
        Name,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(GLBudgetName.FIELDNO(Name),DATABASE::"G/L Budget Name"),
          1,
          LibraryUtility.GetFieldLength(DATABASE::"G/L Budget Name",GLBudgetName.FIELDNO(Name))));

      // Validating Description as Name because value is not important.
      GLBudgetName.VALIDATE(Description,GLBudgetName.Name);
      GLBudgetName.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134453 to show one way of using this function.

      // Test and verify Copy FA Entries To G/L Budget Report functionality for Active Fixed Asset..

      // 1. Setup: Create Fixed Asset, FA Depreciation Book with FA Posting Group. Create and post General Journal Lines.
      Initialize;
      LibraryFixedAsset.CreateFAWithPostingGroup(FixedAsset);
      CreateFADepreciationBook(FADepreciationBook,FixedAsset."No.",FixedAsset."FA Posting Group",LibraryFixedAsset.GetDefaultDeprBook);
      CreateAndPostFAJournalLines(FADepreciationBook);
      LibraryFixedAsset.CreateGLBudgetName(GLBudgetName);
      COMMIT;  // COMMIT required for Batch Report.

      // 2. Exercise: Run Copy FA Entries To G/L Budget.
      RunCopyFAEntriesToGLBudget(FixedAsset."No.",LibraryFixedAsset.GetDefaultDeprBook,GLBudgetName.Name,WORKDATE);

      // 3. Verify: Verify FA Entries must be copy to G\L Budget Entries for Active Fixed Asset.
      // Using 6 because we have created 6 General Journal Lines with different FA Posting Type.
      Assert.AreEqual(6,GetNumberOfGLBudgetEntries(GLBudgetName.Name),GLBudgetEntriesMustExistMsg);
      LibraryFixedAsset.VerifyLastFARegisterGLRegisterOneToOneRelation; // TFS 376879
Member of Lib.Library - Fixed Asset


CreateInsurance@46 Method

The procedure CreateInsurance is available in codeunit 131330.

Syntax

CreateInsurance@46(
    VAR Insurance@1000 : Record 5628 Insurance //Reference parameter of type Record
);

Parameters

Insurance
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Insurance.

For a clarification about how this function works, refer to the code listed below.

      LibraryUtility.UpdateSetupNoSeriesCode(DATABASE::"FA Setup",FASetup.FIELDNO("Insurance Nos."));

      Insurance.INIT;
      Insurance.INSERT(TRUE);
      Insurance.VALIDATE(Description,Insurance."No.");  // Validating Description as No because value is not important.
      Insurance.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134452 to show one way of using this function.

      // Test that Insurance Journal Posted successfully with different batch jobs.

      // 1. Setup: Create Insurance and fixed asset.
      Initialize;
      LibraryFixedAsset.CreateInsurance(Insurance);
      LibraryFixedAsset.CreateFixedAsset(FixedAsset);

      // 2. Exercise: Create Insurance Journal Batch and Post Insurance Journal.
      InsuranceJournalTemplate.FINDFIRST;
      LibraryFixedAsset.CreateInsuranceJournalBatch(InsuranceJournalBatch,InsuranceJournalTemplate.Name);
      Amount[1] := CreatePostInsuranceJournalLine(InsuranceJournalBatch,FixedAsset."No.",Insurance."No.");

      InsuranceJournalBatch.GET(InsuranceJournalBatch."Journal Template Name",INCSTR(InsuranceJournalBatch.Name));
      Amount[2] := CreatePostInsuranceJournalLine(InsuranceJournalBatch,FixedAsset."No.",Insurance."No.");

      // 3. Verification: To verify Insurance number, Document type and Amount are posted properly.
      VerifyCoverageLedgerEntry(FixedAsset."No.",Amount,Insurance."No.");
Member of Lib.Library - Fixed Asset


CreateInsuranceJournalBatch@10 Method

The procedure CreateInsuranceJournalBatch is available in codeunit 131330.

Syntax

CreateInsuranceJournalBatch@10(
    VAR InsuranceJournalBatch@1000 : Record 5634 InsuranceJournalBatch, //Reference parameter of type Record
    JournalTemplateName@1001 : Code[10] JournalTemplateName //Input parameter of type Code
);

Parameters

InsuranceJournalBatch
Reference parameter of type Record
JournalTemplateName
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Insurance, Journal, Batch.

For a clarification about how this function works, refer to the code listed below.

      InsuranceJournalBatch.INIT;
      InsuranceJournalBatch.VALIDATE("Journal Template Name",JournalTemplateName);
      InsuranceJournalBatch.VALIDATE(
        Name,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(InsuranceJournalBatch.FIELDNO(Name),DATABASE::"Insurance Journal Batch"),
          1,
          LibraryUtility.GetFieldLength(DATABASE::"Insurance Journal Batch",InsuranceJournalBatch.FIELDNO(Name))));

      // Validating Description as Name because value is not important.
      InsuranceJournalBatch.VALIDATE(Description,InsuranceJournalBatch.Name);
      InsuranceJournalBatch.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134452 to show one way of using this function.

      // Test that Insurance Journal Posted successfully with different batch jobs.

      // 1. Setup: Create Insurance and fixed asset.
      Initialize;
      LibraryFixedAsset.CreateInsurance(Insurance);
      LibraryFixedAsset.CreateFixedAsset(FixedAsset);

      // 2. Exercise: Create Insurance Journal Batch and Post Insurance Journal.
      InsuranceJournalTemplate.FINDFIRST;
      LibraryFixedAsset.CreateInsuranceJournalBatch(InsuranceJournalBatch,InsuranceJournalTemplate.Name);
      Amount[1] := CreatePostInsuranceJournalLine(InsuranceJournalBatch,FixedAsset."No.",Insurance."No.");

      InsuranceJournalBatch.GET(InsuranceJournalBatch."Journal Template Name",INCSTR(InsuranceJournalBatch.Name));
      Amount[2] := CreatePostInsuranceJournalLine(InsuranceJournalBatch,FixedAsset."No.",Insurance."No.");

      // 3. Verification: To verify Insurance number, Document type and Amount are posted properly.
      VerifyCoverageLedgerEntry(FixedAsset."No.",Amount,Insurance."No.");
Member of Lib.Library - Fixed Asset


CreateInsuranceJournalLine@1 Method

The procedure CreateInsuranceJournalLine is available in codeunit 131330.

Syntax

CreateInsuranceJournalLine@1(
    VAR InsuranceJournalLine@1000 : Record 5635 InsuranceJournalLine, //Reference parameter of type Record
    JournalTemplateName@1001 : Code[10] JournalTemplateName, //Input parameter of type Code
    JournalBatchName@1002 : Code[10] JournalBatchName //Input parameter of type Code
);

Parameters

InsuranceJournalLine
Reference parameter of type Record
JournalTemplateName
Input parameter of type Code
JournalBatchName
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Insurance, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      // Create an Insurance Journal Entry.
      InsuranceJournalLine.INIT;
      InsuranceJournalLine.VALIDATE("Journal Template Name",JournalTemplateName);
      InsuranceJournalLine.VALIDATE("Journal Batch Name",JournalBatchName);
      RecRef.GETTABLE(InsuranceJournalLine);
      InsuranceJournalLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,InsuranceJournalLine.FIELDNO("Line No.")));
      InsuranceJournalLine.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134452 to show one way of using this function.

      LibraryFixedAsset.CreateInsuranceJournalLine(
        InsuranceJournalLine,InsuranceJournalBatch."Journal Template Name",InsuranceJournalBatch.Name);
      InsuranceJournalLine.VALIDATE("Posting Date",PostingDate);
      InsuranceJournalLine.VALIDATE("Document Type",InsuranceJournalLine."Document Type"::Invoice);
      InsuranceJournalLine.VALIDATE("Document No.",FANo); // Inputting FA No. as Document No is not important.
      InsuranceJournalLine.VALIDATE("Insurance No.",InsuranceNo);
      InsuranceJournalLine.VALIDATE("FA No.",FANo);
      InsuranceJournalLine.VALIDATE(Amount,LibraryRandom.RandDec(100,2));  // Use Random because value is not important.
      InsuranceJournalLine.MODIFY(TRUE);
Member of Lib.Library - Fixed Asset


CreateInsuranceType@100 Method

The procedure CreateInsuranceType is available in codeunit 131330.

Syntax

CreateInsuranceType@100(
    VAR InsuranceType@1000 : Record 5630 InsuranceType //Reference parameter of type Record
);

Parameters

InsuranceType
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Insurance, Type.

For a clarification about how this function works, refer to the code listed below.

      InsuranceType.INIT;
      InsuranceType.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(InsuranceType.FIELDNO(Code),DATABASE::"Insurance Type"),
          1,
          LibraryUtility.GetFieldLength(DATABASE::"Insurance Type",InsuranceType.FIELDNO(Code))));

      // Validating Description as Code because value is not important.
      InsuranceType.VALIDATE(Description,InsuranceType.Code);
      InsuranceType.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134450 to show one way of using this function.

      // Test New Insurance Types in Insurance Setup.

      // 1. Setup:
      Initialize;

      // 2. Exercise: Create FA Insurance Type.
      LibraryFixedAsset.CreateInsuranceType(InsuranceType);

      // 3. Verify: Check FA Insurance Type Created Correctly.
      InsuranceType.GET(InsuranceType.Code);
Member of Lib.Library - Fixed Asset


CreateJournalTemplate@6 Method

The procedure CreateJournalTemplate is available in codeunit 131330.

Syntax

CreateJournalTemplate@6(
    VAR FAJournalTemplate@1000 : Record 5619 FAJournalTemplate //Reference parameter of type Record
);

Parameters

FAJournalTemplate
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Journal, Template.

For a clarification about how this function works, refer to the code listed below.

      FAJournalTemplate.INIT;
      FAJournalTemplate.VALIDATE(
        Name,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(FAJournalTemplate.FIELDNO(Name),DATABASE::"FA Journal Template"),
          1,
          LibraryUtility.GetFieldLength(DATABASE::"FA Journal Template",FAJournalTemplate.FIELDNO(Name))));

      // Validating Description as Name because value is not important.
      FAJournalTemplate.VALIDATE(Description,FAJournalTemplate.Name);
      FAJournalTemplate.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134450 to show one way of using this function.

      // Test FA Journal Template.

      // 1.Setup:
      Initialize;

      // 2.Exercise: Create FA Journal Template.
      LibraryFixedAsset.CreateJournalTemplate(FAJournalTemplate);

      // 3. Verify: Check FA Journal Template created correctly.
      FAJournalTemplate.GET(FAJournalTemplate.Name);
Member of Lib.Library - Fixed Asset


CreateMainAssetComponent@89 Method

The procedure CreateMainAssetComponent is available in codeunit 131330.

Syntax

CreateMainAssetComponent@89(
    VAR MainAssetComponent@1000 : Record 5640 MainAssetComponent, //Reference parameter of type Record
    MainAssetNo@1001 : Code[20] MainAssetNo, //Input parameter of type Code
    FANo@1003 : Code[20] FANo //Input parameter of type Code
);

Parameters

MainAssetComponent
Reference parameter of type Record
MainAssetNo
Input parameter of type Code
FANo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Main, Asset, Component.

For a clarification about how this function works, refer to the code listed below.

      MainAssetComponent.INIT;
      MainAssetComponent.VALIDATE("Main Asset No.",MainAssetNo);
      MainAssetComponent.VALIDATE("FA No.",FANo);
      MainAssetComponent.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134450 to show one way of using this function.

      // Test Main Assets Components.

      // 1. Setup: Create Fixed Assets.
      Initialize;
      LibraryFixedAsset.CreateFixedAsset(FixedAsset);
      LibraryFixedAsset.CreateFixedAsset(FixedAsset2);

      // 2. Exercise: Create FAs for FA Main Asset and FA No for FA Main Asset Creation.
      LibraryFixedAsset.CreateMainAssetComponent(MainAssetComponent,FixedAsset."No.",FixedAsset2."No.");

      // 3. Verify: Check FA main Asset Component Created Correctly.
      MainAssetComponent.GET(FixedAsset."No.",FixedAsset2."No.");
      MainAssetComponent.TESTFIELD(Description,FixedAsset2.Description);
Member of Lib.Library - Fixed Asset


CreateMaintenance@92 Method

The procedure CreateMaintenance is available in codeunit 131330.

Syntax

CreateMaintenance@92(
    VAR Maintenance@1000 : Record 5626 Maintenance //Reference parameter of type Record
);

Parameters

Maintenance
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Maintenance.

For a clarification about how this function works, refer to the code listed below.

      Maintenance.INIT;
      Maintenance.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(Maintenance.FIELDNO(Code),DATABASE::Maintenance),
          1,
          LibraryUtility.GetFieldLength(DATABASE::Maintenance,Maintenance.FIELDNO(Code))));

      // Validating Description as Code because value is not important.
      Maintenance.VALIDATE(Description,Maintenance.Code);
      Maintenance.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134450 to show one way of using this function.

      // Test New Maintenance Code.

      // 1. Setup:
      Initialize;

      // 2. Exercise: Create FA Maintenance.
      LibraryFixedAsset.CreateMaintenance(Maintenance);

      // 3. Verify: Check FA Maintenance Created Correctly.
      Maintenance.GET(Maintenance.Code);
Member of Lib.Library - Fixed Asset


FindEmployee@17 Method

The procedure FindEmployee is available in codeunit 131330.

Syntax

FindEmployee@17(
    VAR Employee@1000 : Record 5200 Employee //Reference parameter of type Record
);

Parameters

Employee
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Employee.

For a clarification about how this function works, refer to the code listed below.

      Employee.FINDSET;

Example

The below example is extracted from the test automation codeunit 134450 to show one way of using this function.

      // Update Responsible Employee, FA Class Code, FA Subclass Code, FA Location Code, Vendor No.,
      // Maintenance Vendor No. on Fixed Asset.
      LibraryFixedAsset.FindEmployee(Employee);
      LibraryFixedAsset.FindFAClass(FAClass);
      LibraryFixedAsset.FindFASubclass(FASubclass);
      LibraryFixedAsset.FindFALocation(FALocation);
      FindVendor(Vendor);
      FixedAsset.VALIDATE("Responsible Employee",Employee."No.");
      FixedAsset.VALIDATE("FA Class Code",FAClass.Code);
      FixedAsset.VALIDATE("FA Subclass Code",FASubclass.Code);
      FixedAsset.VALIDATE("FA Location Code",FALocation.Code);
      FixedAsset.VALIDATE("Vendor No.",Vendor."No.");
      FixedAsset.VALIDATE("Maintenance Vendor No.",Vendor."No.");
      SaveValuesOnTempFixedAsset(FixedAssetOld,FixedAsset);
      FixedAsset.MODIFY(TRUE);
Member of Lib.Library - Fixed Asset


FindFAClass@14 Method

The procedure FindFAClass is available in codeunit 131330.

Syntax

FindFAClass@14(
    VAR FAClass@1000 : Record 5607 FAClass //Reference parameter of type Record
);

Parameters

FAClass
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Fixed Asset, Class.

For a clarification about how this function works, refer to the code listed below.

      FAClass.FINDSET;

Example

The below example is extracted from the test automation codeunit 134049 to show one way of using this function.

      LibraryHumanResource.CreateEmployee(Employee);
      LibraryFixedAsset.FindFAClass(FAClass);
      LibraryFixedAsset.FindFASubclass(FASubclass);
      FixedAsset.VALIDATE("Responsible Employee",Employee."No.");
      FixedAsset.VALIDATE("FA Class Code",FAClass.Code);
      FixedAsset.VALIDATE("FA Subclass Code",FASubclass.Code);
      FixedAsset.MODIFY(TRUE);
Member of Lib.Library - Fixed Asset


FindFAJournalBatch@4 Method

The procedure FindFAJournalBatch is available in codeunit 131330.

Syntax

FindFAJournalBatch@4(
    VAR FAJournalBatch@1000 : Record 5620 FAJournalBatch, //Reference parameter of type Record
    JournalTemplateName@1001 : Code[10] JournalTemplateName //Input parameter of type Code
);

Parameters

FAJournalBatch
Reference parameter of type Record
JournalTemplateName
Input parameter of type Code

Remarks

The relevant search keywords are: Find, Fixed Asset, Journal, Batch.

For a clarification about how this function works, refer to the code listed below.

      FAJournalBatch.SETRANGE("Journal Template Name",JournalTemplateName);
      FAJournalBatch.FINDFIRST;

Example

The below example is extracted from the test automation codeunit 134451 to show one way of using this function.

      // Verify program populates FA Journal Batch Name list when lookup is invoked on 'FA Journal Batch Name' field on FA Journal Setup.

      // 1.Setup: Find Depreciation Book,FA Journal Template and FA Journal Batch.
      Initialize;
      LibraryFixedAsset.CreateDepreciationBook(DepreciationBook);
      FAJournalTemplate.SETRANGE(Recurring,FALSE);
      LibraryFixedAsset.FindFAJournalTemplate(FAJournalTemplate);
      LibraryFixedAsset.FindFAJournalBatch(FAJournalBatch,FAJournalTemplate.Name);

      // Variables 'FAJournalTemplateName' and 'FAJournalBatchName' are declared Global as they are used in Handler method.
      FAJournalTemplateName := FAJournalTemplate.Name;
      FAJournalBatchName := FAJournalBatch.Name;

      // 2.Exercise: From Depreciation Book open FA Journal Setup page.
      OpenFAJnlSetupFromDepBook(DepreciationBook.Code);

      // 3.Verify: Verification is done in 'FAJournalBatchesHandler' handler method.
Member of Lib.Library - Fixed Asset


FindFAJournalTemplate@5 Method

The procedure FindFAJournalTemplate is available in codeunit 131330.

Syntax

FindFAJournalTemplate@5(
    VAR FAJournalTemplate@1000 : Record 5619 FAJournalTemplate //Reference parameter of type Record
);

Parameters

FAJournalTemplate
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Fixed Asset, Journal, Template.

For a clarification about how this function works, refer to the code listed below.

      FAJournalTemplate.FINDFIRST;

Example

The below example is extracted from the test automation codeunit 134450 to show one way of using this function.

      FAJournalTemplate.SETRANGE(Recurring,FALSE);
      LibraryFixedAsset.FindFAJournalTemplate(FAJournalTemplate);
      LibraryFixedAsset.CreateFAJournalBatch(FAJournalBatch,FAJournalTemplate.Name);
      FAJournalBatch.VALIDATE("No. Series",LibraryUtility.GetGlobalNoSeriesCode);
      FAJournalBatch.MODIFY(TRUE);
Member of Lib.Library - Fixed Asset


FindFALocation@16 Method

The procedure FindFALocation is available in codeunit 131330.

Syntax

FindFALocation@16(
    VAR FALocation@1000 : Record 5609 FALocation //Reference parameter of type Record
);

Parameters

FALocation
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Fixed Asset, Location.

For a clarification about how this function works, refer to the code listed below.

      FALocation.FINDSET;

Example

The below example is extracted from the test automation codeunit 134450 to show one way of using this function.

      // Update Responsible Employee, FA Class Code, FA Subclass Code, FA Location Code, Vendor No.,
      // Maintenance Vendor No. on Fixed Asset.
      LibraryFixedAsset.FindEmployee(Employee);
      LibraryFixedAsset.FindFAClass(FAClass);
      LibraryFixedAsset.FindFASubclass(FASubclass);
      LibraryFixedAsset.FindFALocation(FALocation);
      FindVendor(Vendor);
      FixedAsset.VALIDATE("Responsible Employee",Employee."No.");
      FixedAsset.VALIDATE("FA Class Code",FAClass.Code);
      FixedAsset.VALIDATE("FA Subclass Code",FASubclass.Code);
      FixedAsset.VALIDATE("FA Location Code",FALocation.Code);
      FixedAsset.VALIDATE("Vendor No.",Vendor."No.");
      FixedAsset.VALIDATE("Maintenance Vendor No.",Vendor."No.");
      SaveValuesOnTempFixedAsset(FixedAssetOld,FixedAsset);
      FixedAsset.MODIFY(TRUE);
Member of Lib.Library - Fixed Asset


FindFASubclass@15 Method

The procedure FindFASubclass is available in codeunit 131330.

Syntax

FindFASubclass@15(
    VAR FASubclass@1000 : Record 5608 FASubclass //Reference parameter of type Record
);

Parameters

FASubclass
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Fixed Asset, Subclass.

For a clarification about how this function works, refer to the code listed below.

      FASubclass.FINDSET;

Example

The below example is extracted from the test automation codeunit 134049 to show one way of using this function.

      LibraryHumanResource.CreateEmployee(Employee);
      LibraryFixedAsset.FindFAClass(FAClass);
      LibraryFixedAsset.FindFASubclass(FASubclass);
      FixedAsset.VALIDATE("Responsible Employee",Employee."No.");
      FixedAsset.VALIDATE("FA Class Code",FAClass.Code);
      FixedAsset.VALIDATE("FA Subclass Code",FASubclass.Code);
      FixedAsset.MODIFY(TRUE);
Member of Lib.Library - Fixed Asset


FindInsurance@11 Method

The procedure FindInsurance is available in codeunit 131330.

Syntax

FindInsurance@11(
    VAR Insurance@1000 : Record 5628 Insurance //Reference parameter of type Record
);

Parameters

Insurance
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Insurance.

For a clarification about how this function works, refer to the code listed below.

      Insurance.FINDSET;

Example

The below example is extracted from the test automation codeunit 134450 to show one way of using this function.

      LibraryFixedAsset.FindInsurance(Insurance);
      PurchaseLine.VALIDATE("Insurance No.",Insurance."No.");
      PurchaseLine.MODIFY(TRUE);
Member of Lib.Library - Fixed Asset


GetDefaultDeprBook@21 Method

The procedure GetDefaultDeprBook is available in codeunit 131330.

Syntax

GetDefaultDeprBook@21(
      //param element not supplied
);

Return Value

Code[10]

Remarks

The relevant search keywords are: Get, Default, Depr, Book.

For a clarification about how this function works, refer to the code listed below.

      FASetup.GET;
      EXIT(FASetup."Default Depr. Book");

Example

There are no examples available.
Member of Lib.Library - Fixed Asset


PostFAJournalLine@50 Method

The procedure PostFAJournalLine is available in codeunit 131330.

Syntax

PostFAJournalLine@50(
    VAR FAJournalLine@1000 : Record 5621 FAJournalLine //Reference parameter of type Record
);

Parameters

FAJournalLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Post, Fixed Asset, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      FAJournalLine.SETRANGE("Journal Template Name",FAJournalLine."Journal Template Name");
      FAJournalLine.SETRANGE("Journal Batch Name",FAJournalLine."Journal Batch Name");
      CODEUNIT.RUN(CODEUNIT::"FA Jnl.-Post Batch",FAJournalLine);

Example

The below example is extracted from the test automation codeunit 134450 to show one way of using this function.

      // Test the Appreciation of Fixed Assets.

      // 1.Setup: Create Fixed Asset, FA Acquisition, FA Journal Line and Insert FA Bal Account.
      Initialize;
      LibraryFixedAsset.CreateFAWithPostingGroup(FixedAsset);
      CreateJournalSetupDepreciation(DepreciationBook);
      CreateFADepreciationBook(FADepreciationBook,FixedAsset."No.",FixedAsset."FA Posting Group",DepreciationBook.Code);

      CreateFAJournalLine(
        FAJournalLine,FixedAsset."No.",FADepreciationBook."Depreciation Book Code",
        FAJournalLine."Document Type",FAJournalLine."FA Posting Type");
      LibraryFixedAsset.PostFAJournalLine(FAJournalLine);
      CreateFAGLJournal(
        GenJournalLine,FixedAsset."No.",FADepreciationBook."Depreciation Book Code",
        GenJournalLine."FA Posting Type"::Appreciation);

      IndexationAndIntegrationInBook(FADepreciationBook."Depreciation Book Code");
      UpdateAppreciationAccount(FixedAsset."FA Posting Group");
      GenJournalLine.SETRANGE("Account No.",GenJournalLine."Account No.");
      FAGetBalanceAccount.InsertAcc(GenJournalLine); // Insert FA Bal Account.

      // 2.Exercise: Post FA G/L Line.
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // 3.Verify: Verify Amount on FA Ledger Entry Correctly Populated.
      VerifyAmountInFATransaction(FixedAsset."No.",FAJournalLine."FA Posting Type"::Appreciation);
Member of Lib.Library - Fixed Asset


PostFAJournalLineBatch@12 Method

The procedure PostFAJournalLineBatch is available in codeunit 131330.

Syntax

PostFAJournalLineBatch@12(
    VAR FAJournalBatch@1000 : Record 5620 FAJournalBatch //Reference parameter of type Record
);

Parameters

FAJournalBatch
Reference parameter of type Record

Remarks

The relevant search keywords are: Post, Fixed Asset, Journal, Line, Batch.

For a clarification about how this function works, refer to the code listed below.

      CODEUNIT.RUN(CODEUNIT::"FA. Jnl.-B.Post",FAJournalBatch);

Example

The below example is extracted from the test automation codeunit 134450 to show one way of using this function.

      // Test the Post Fixed Asset Journal through FA Journal Batch.

      // 1.Setup: Create Fixed Asset,Depreciation Book,FA Depreciation Book, Create FA Journal Batch and create FA Journal Line.
      Initialize;
      LibraryFixedAsset.CreateFAWithPostingGroup(FixedAsset);
      CreateJournalSetupDepreciation(DepreciationBook);
      CreateFADepreciationBook(FADepreciationBook,FixedAsset."No.",FixedAsset."FA Posting Group",DepreciationBook.Code);

      CreateFAJournalLine(
        FAJournalLine,FixedAsset."No.",FADepreciationBook."Depreciation Book Code",
        FAJournalLine."Document Type"::" ",FAJournalLine."FA Posting Type"::"Acquisition Cost");

      COMMIT; // Commit is required for Posting
      FAJournalLineAmount := FAJournalLine.Amount;
      FAJournalBatch.GET(FAJournalLine."Journal Template Name",FAJournalLine."Journal Batch Name");

      // 2.Exercise: Post FA Journal Line through FA Journal Batch.
      FAJournalBatch.SETRANGE("Journal Template Name",FAJournalLine."Journal Template Name");
      FAJournalBatch.SETRANGE(Name,FAJournalLine."Journal Batch Name");
      LibraryFixedAsset.PostFAJournalLineBatch(FAJournalBatch);

      // 3.Verify: Verify Amount in FA Ledger Entry.
      VerifyAmountInFAEntry(FixedAsset."No.",FALedgerEntry."FA Posting Type"::"Acquisition Cost",FAJournalLineAmount);
Member of Lib.Library - Fixed Asset


PostInsuranceJournal@2 Method

The procedure PostInsuranceJournal is available in codeunit 131330.

Syntax

PostInsuranceJournal@2(
    VAR InsuranceJournalLine@1000 : Record 5635 InsuranceJournalLine //Reference parameter of type Record
);

Parameters

InsuranceJournalLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Post, Insurance, Journal.

For a clarification about how this function works, refer to the code listed below.

      InsuranceJournalLine.SETRANGE("Journal Template Name",InsuranceJournalLine."Journal Template Name");
      InsuranceJournalLine.SETRANGE("Journal Batch Name",InsuranceJournalLine."Journal Batch Name");
      CODEUNIT.RUN(CODEUNIT::"Insurance Jnl.-Post Batch",InsuranceJournalLine);

Example

The below example is extracted from the test automation codeunit 134452 to show one way of using this function.

      LibraryFiscalYear.CreateFiscalYear;
      LibraryFiscalYear.CloseFiscalYear;

      LibraryFixedAsset.CreateInsurance(Insurance);
      LibraryFixedAsset.CreateFixedAsset(FixedAsset);

      CreateInsuranceJournalBatch(InsuranceJournalBatch);
      JournalBatchName := InsuranceJournalBatch.Name;

      CreateInsuranceJournalLine(
        InsuranceJournalLine,InsuranceJournalBatch,FixedAsset."No.",Insurance."No.",LibraryFiscalYear.GetLastPostingDate(TRUE));
      CreateInsuranceJournalLine(
        InsuranceJournalLine,InsuranceJournalBatch,FixedAsset."No.",Insurance."No.",LibraryFiscalYear.GetLastPostingDate(TRUE));
      LibraryFixedAsset.PostInsuranceJournal(InsuranceJournalLine);
      LibraryUtility.GenerateGUID;  // Hack to fix problem with Generate GUID.
Member of Lib.Library - Fixed Asset


VerifyLastFARegisterGLRegisterOneToOneRelation@20 Method

The procedure VerifyLastFARegisterGLRegisterOneToOneRelation is available in codeunit 131330.

Syntax

VerifyLastFARegisterGLRegisterOneToOneRelation@20(
      //param element not supplied
);

Remarks

The relevant search keywords are: Verify, Last, Fixed Asset, Register, General Ledger, Register, One, To, One, Relation.

For a clarification about how this function works, refer to the code listed below.

      GLRegister.FINDLAST;
      FARegister.FINDLAST;
      Assert.AreEqual(GLRegister."No.",FARegister."G/L Register No.",FARegisterGLRegisterErr);

      GLEntry.SETRANGE("Entry No.",GLRegister."From Entry No.",GLRegister."To Entry No.");
      GLEntry.SETRANGE("FA Entry Type",GLEntry."FA Entry Type"::"Fixed Asset");
      GLEntry.FINDSET;
      REPEAT
        Assert.IsTrue(
          GLEntry."FA Entry No." IN [FARegister."From Entry No."..FARegister."To Entry No."],
          FARegisterGLRegisterErr);
      UNTIL GLEntry.NEXT = 0;

Example

The below example is extracted from the test automation codeunit 134451 to show one way of using this function.

      // Test the Posting of Sales Invoice with two lines Fixed Assets with "Use Duplication List".

      // 1.Setup: Create Fixed Asset,2 Depreciation Books, FA Posting Group, Create Customer, Create Sales Invoice with 2 lines.
      Initialize;

      CreateDeprBookPartOfDuplicationList(DepreciationBook);
      CreateDeprBookPartOfDuplicationList(DepreciationBook2);

      LibraryFixedAsset.CreateFAWithPostingGroup(FixedAsset);
      CreateFADepreciationBook(FixedAsset."No.",DepreciationBook.Code,FixedAsset."FA Posting Group");
      CreateFADepreciationBook(FixedAsset."No.",DepreciationBook2.Code,FixedAsset."FA Posting Group");

      LibraryPurchase.CreatePurchHeader(PurchHeader,PurchHeader."Document Type"::Invoice,LibraryPurchase.CreateVendorNo);
      CreatePurchLine(PurchLine,PurchHeader,FixedAsset."No.",DepreciationBook.Code);
      CreatePurchLine(PurchLine2,PurchHeader,FixedAsset."No.",DepreciationBook2.Code);

      // 2.Exercise: Post Sales Invoice.
      LibraryPurchase.PostPurchaseDocument(PurchHeader,TRUE,TRUE);

      // 3.Verify: Verify FA Ledger Entry.
      VerifyFALedgerEntry(FixedAsset."No.",DepreciationBook2.Code);
      LibraryFixedAsset.VerifyLastFARegisterGLRegisterOneToOneRelation; // TFS 376879
Member of Lib.Library - Fixed Asset


VerifyMaintenanceLastFARegisterGLRegisterOneToOneRelation@19 Method

The procedure VerifyMaintenanceLastFARegisterGLRegisterOneToOneRelation is available in codeunit 131330.

Syntax

VerifyMaintenanceLastFARegisterGLRegisterOneToOneRelation@19(
      //param element not supplied
);

Remarks

The relevant search keywords are: Verify, Maintenance, Last, Fixed Asset, Register, General Ledger, Register, One, To, One, Relation.

For a clarification about how this function works, refer to the code listed below.

      GLRegister.FINDLAST;
      FARegister.FINDLAST;
      Assert.AreEqual(GLRegister."No.",FARegister."G/L Register No.",FARegisterGLRegisterErr);

      GLEntry.SETRANGE("Entry No.",GLRegister."From Entry No.",GLRegister."To Entry No.");
      GLEntry.SETRANGE("FA Entry Type",GLEntry."FA Entry Type"::Maintenance);
      GLEntry.FINDSET;
      REPEAT
        Assert.IsTrue(
          GLEntry."FA Entry No." IN [FARegister."From Maintenance Entry No."..FARegister."To Maintenance Entry No."],
          FARegisterGLRegisterErr);
      UNTIL GLEntry.NEXT = 0;

Example

The below example is extracted from the test automation codeunit 134981 to show one way of using this function.

      // Test and verify Maintenance Register Report.

      // 1. Setup: Create Fixed Asset, FA Depreciation Book, First Maintenance, Second Maintenance, General Journal Batch,
      // First Journal Line with First Maintenance, Second Journal Line with Second Maintenance, Post Journal Line.
      Initialize;
      OldDefaultDeprBook := UpdateFASetup(CreateDepreciationBook);
      LibraryFixedAsset.CreateFAWithPostingGroup(FixedAsset);
      CreateFADepreciationBook(FADepreciationBook,FixedAsset);
      LibraryFixedAsset.CreateMaintenance(Maintenance);
      LibraryFixedAsset.CreateMaintenance(Maintenance2);

      CreateGeneralJournalBatch(GenJournalBatch);
      CreateGeneralJournalLine(GenJournalLine,GenJournalBatch,FADepreciationBook,GenJournalLine."FA Posting Type"::Maintenance);
      UpdateMaintenanceOnJournalLine(GenJournalLine,Maintenance.Code);

      CreateGeneralJournalLine(GenJournalLine,GenJournalBatch,FADepreciationBook,GenJournalLine."FA Posting Type"::Maintenance);
      UpdateMaintenanceOnJournalLine(GenJournalLine,Maintenance2.Code);

      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // 2. Exercise: Run the Maintenance Register Report.
      FARegister.SETRANGE("Journal Batch Name",GenJournalBatch.Name);
      CLEAR(MaintenanceRegister);
      MaintenanceRegister.SETTABLEVIEW(FARegister);
      MaintenanceRegister.RUN;

      // 3. Verify: Verify values on Maintenance Register Report.
      LibraryReportDataset.LoadDataSetFile;
      VerifyMaintenanceRegisterLine(Maintenance.Code);
      VerifyMaintenanceRegisterLine(Maintenance2.Code);

      // Tear Down.
      UpdateFASetup(OldDefaultDeprBook);
      LibraryFixedAsset.VerifyMaintenanceLastFARegisterGLRegisterOneToOneRelation; // TFS 376879
Member of Lib.Library - Fixed Asset


Library - Human Resource Class

Lib.Library - Human Resource

COD131901 applies to RES,ERM,SCM,W1,All.
Contains all utility functions related to Human Resource.

Methods

Name | Description
CreateAlternativeAddress@2 | The procedure CreateAlternativeAddress is available in codeunit 131901.
CreateConfidential@10 | The procedure CreateConfidential is available in codeunit 131901.
CreateConfidentialInformation@25 | The procedure CreateConfidentialInformation is available in codeunit 131901.
CreateEmployee@4 | The procedure CreateEmployee is available in codeunit 131901.
CreateEmployeeAbsence@9 | The procedure CreateEmployeeAbsence is available in codeunit 131901.
CreateEmployeeQualification@1 | The procedure CreateEmployeeQualification is available in codeunit 131901.
CreateEmployeeRelative@12 | The procedure CreateEmployeeRelative is available in codeunit 131901.
CreateEmployeeStatGroup@14 | The procedure CreateEmployeeStatGroup is available in codeunit 131901.
CreateEmploymentContract@11 | The procedure CreateEmploymentContract is available in codeunit 131901.
CreateMiscArticle@8 | The procedure CreateMiscArticle is available in codeunit 131901.
CreateMiscArticleInformation@5 | The procedure CreateMiscArticleInformation is available in codeunit 131901.
CreateQualification@13 | The procedure CreateQualification is available in codeunit 131901.
CreateRelative@7 | The procedure CreateRelative is available in codeunit 131901.
CreateUnion@3 | The procedure CreateUnion is available in codeunit 131901.
SetupEmployeeNumberSeries@6 | The procedure SetupEmployeeNumberSeries is available in codeunit 131901.

See Also

Lib


CreateAlternativeAddress@2 Method

The procedure CreateAlternativeAddress is available in codeunit 131901.

Syntax

CreateAlternativeAddress@2(
    VAR AlternativeAddress@1000 : Record 5201 AlternativeAddress, //Reference parameter of type Record
    EmployeeNo@1001 : Code[20] EmployeeNo //Input parameter of type Code
);

Parameters

AlternativeAddress
Reference parameter of type Record
EmployeeNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Alternative, Address.

For a clarification about how this function works, refer to the code listed below.

      AlternativeAddress.INIT;
      AlternativeAddress.VALIDATE("Employee No.",EmployeeNo);
      AlternativeAddress.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(AlternativeAddress.FIELDNO(Code),DATABASE::"Alternative Address"),
          1,
          LibraryUtility.GetFieldLength(DATABASE::"Alternative Address",AlternativeAddress.FIELDNO(Code))));
      AlternativeAddress.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136903 to show one way of using this function.

      LibraryERM.CreatePostCode(PostCode);  // Creation of Post Code is required to avoid special characters in existing ones.

      LibraryHumanResource.CreateAlternativeAddress(AlternativeAddress,EmployeeNo);
      AlternativeAddress.VALIDATE(
        Address,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(AlternativeAddress.FIELDNO(Address),DATABASE::"Alternative Address"),
          1,
          LibraryUtility.GetFieldLength(DATABASE::"Alternative Address",AlternativeAddress.FIELDNO(Address))));
      AlternativeAddress.VALIDATE("Post Code",PostCode.Code);
      AlternativeAddress.VALIDATE("Country/Region Code",PostCode."Country/Region Code");
      AlternativeAddress.MODIFY(TRUE);
Member of Lib.Library - Human Resource


CreateConfidential@10 Method

The procedure CreateConfidential is available in codeunit 131901.

Syntax

CreateConfidential@10(
    VAR Confidential@1000 : Record 5215 Confidential //Reference parameter of type Record
);

Parameters

Confidential
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Confidential.

For a clarification about how this function works, refer to the code listed below.

      Confidential.INIT;
      Confidential.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(Confidential.FIELDNO(Code),DATABASE::Confidential),
          1,
          LibraryUtility.GetFieldLength(DATABASE::Confidential,Confidential.FIELDNO(Code))));
      Confidential.VALIDATE(Description,Confidential.Code);
      Confidential.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136903 to show one way of using this function.

      LibraryHumanResource.CreateConfidential(Confidential);
      EXIT(Confidential.Code);
Member of Lib.Library - Human Resource


CreateConfidentialInformation@25 Method

The procedure CreateConfidentialInformation is available in codeunit 131901.

Syntax

CreateConfidentialInformation@25(
    VAR ConfidentialInformation@1000 : Record 5216 ConfidentialInformation, //Reference parameter of type Record
    EmployeeNo@1001 : Code[20] EmployeeNo, //Input parameter of type Code
    ConfidentialCode@1002 : Code[10] ConfidentialCode //Input parameter of type Code
);

Parameters

ConfidentialInformation
Reference parameter of type Record
EmployeeNo
Input parameter of type Code
ConfidentialCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Confidential, Information.

For a clarification about how this function works, refer to the code listed below.

      ConfidentialInformation.INIT;
      ConfidentialInformation.VALIDATE("Employee No.",EmployeeNo);
      ConfidentialInformation.VALIDATE("Confidential Code",ConfidentialCode);
      RecRef.GETTABLE(ConfidentialInformation);
      ConfidentialInformation.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,ConfidentialInformation.FIELDNO("Line No.")));
      ConfidentialInformation.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136404 to show one way of using this function.

      // Test Confidential Information Overview Matrix after creation of Confidential Information for Employee.

      // 1. Setup: Create Employee and Confidential Information for the Employee.
      Initialize;
      LibraryHumanResource.CreateEmployee(Employee);
      Confidential.FINDFIRST;
      LibraryHumanResource.CreateConfidentialInformation(ConfidentialInformation,Employee."No.",Confidential.Code);
      LibraryVariableStorage.Enqueue(Employee."No.");  // Assign variable for page handler.

      // 2. Exercise: Run Confidential Information Overview page from Employee card page and run Show Matrix from it.
      EmployeeCard.OPENEDIT;
      EmployeeCard.FILTER.SETFILTER("No.",Employee."No.");
      ConfidentialInfoOverview.TRAP;
      EmployeeCard."Page Confidential Info. Overview".INVOKE;
      COMMIT;
      ConfidentialInfoOverview.ShowMatrix.INVOKE;

      // 3. Verify: Verify value on Confidential Information Overview Matrix performed on Confidential Information Overview Matrix
      // page handler.
Member of Lib.Library - Human Resource


CreateEmployee@4 Method

The procedure CreateEmployee is available in codeunit 131901.

Syntax

CreateEmployee@4(
    VAR Employee@1000 : Record 5200 Employee //Reference parameter of type Record
);

Parameters

Employee
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Employee.

For a clarification about how this function works, refer to the code listed below.

      Employee.INIT;
      Employee.INSERT(TRUE);
      UpdateEmployeeName(Employee);
      Employee.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134049 to show one way of using this function.

      LibraryHumanResource.CreateEmployee(Employee);
      LibraryFixedAsset.FindFAClass(FAClass);
      LibraryFixedAsset.FindFASubclass(FASubclass);
      FixedAsset.VALIDATE("Responsible Employee",Employee."No.");
      FixedAsset.VALIDATE("FA Class Code",FAClass.Code);
      FixedAsset.VALIDATE("FA Subclass Code",FASubclass.Code);
      FixedAsset.MODIFY(TRUE);
Member of Lib.Library - Human Resource


CreateEmployeeAbsence@9 Method

The procedure CreateEmployeeAbsence is available in codeunit 131901.

Syntax

CreateEmployeeAbsence@9(
    VAR EmployeeAbsence@1000 : Record 5207 EmployeeAbsence //Reference parameter of type Record
);

Parameters

EmployeeAbsence
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Employee, Absence.

For a clarification about how this function works, refer to the code listed below.

      EmployeeAbsence.INIT;
      EmployeeAbsence.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136404 to show one way of using this function.

      LibraryHumanResource.CreateEmployeeAbsence(EmployeeAbsence);
      EmployeeAbsence.VALIDATE("Employee No.",EmployeeNo);
      EmployeeAbsence.VALIDATE("From Date",WORKDATE);
      EmployeeAbsence.VALIDATE("Cause of Absence Code",GetCauseOfAbsenceCode);

      // Use random for Quantity.
      EmployeeAbsence.VALIDATE(Quantity,LibraryRandom.RandInt(100) + LibraryUtility.GenerateRandomFraction);
      EmployeeAbsence.MODIFY(TRUE);
Member of Lib.Library - Human Resource


CreateEmployeeQualification@1 Method

The procedure CreateEmployeeQualification is available in codeunit 131901.

Syntax

CreateEmployeeQualification@1(
    VAR EmployeeQualification@1000 : Record 5203 EmployeeQualification, //Reference parameter of type Record
    EmployeeNo@1001 : Code[20] EmployeeNo //Input parameter of type Code
);

Parameters

EmployeeQualification
Reference parameter of type Record
EmployeeNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Employee, Qualification.

For a clarification about how this function works, refer to the code listed below.

      EmployeeQualification.INIT;
      EmployeeQualification.VALIDATE("Employee No.",EmployeeNo);
      RecRef.GETTABLE(EmployeeQualification);
      EmployeeQualification.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,EmployeeQualification.FIELDNO("Line No.")));
      EmployeeQualification.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136404 to show one way of using this function.

      Qualification.FINDFIRST;
      LibraryHumanResource.CreateEmployeeQualification(EmployeeQualification,EmployeeNo);
      EmployeeQualification.VALIDATE("Qualification Code",Qualification.Code);
      EmployeeQualification.MODIFY(TRUE);
      EXIT(Qualification.Code);
Member of Lib.Library - Human Resource


CreateEmployeeRelative@12 Method

The procedure CreateEmployeeRelative is available in codeunit 131901.

Syntax

CreateEmployeeRelative@12(
    VAR EmployeeRelative@1003 : Record 5205 EmployeeRelative, //Reference parameter of type Record
    EmployeeNo@1002 : Code[20] EmployeeNo //Input parameter of type Code
);

Parameters

EmployeeRelative
Reference parameter of type Record
EmployeeNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Employee, Relative.

For a clarification about how this function works, refer to the code listed below.

      EmployeeRelative.INIT;
      EmployeeRelative.VALIDATE("Employee No.",EmployeeNo);
      RecRef.GETTABLE(EmployeeRelative);
      EmployeeRelative.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,EmployeeRelative.FIELDNO("Line No.")));
      EmployeeRelative.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136903 to show one way of using this function.

      LibraryHumanResource.CreateEmployeeRelative(EmployeeRelative,EmployeeNo);
      EmployeeRelative.VALIDATE("Relative Code",FindRelative);
      EmployeeRelative.VALIDATE("First Name",FindRelative);
      EmployeeRelative.VALIDATE("Birth Date",WORKDATE);
      EmployeeRelative.MODIFY(TRUE);
Member of Lib.Library - Human Resource


CreateEmployeeStatGroup@14 Method

The procedure CreateEmployeeStatGroup is available in codeunit 131901.

Syntax

CreateEmployeeStatGroup@14(
    VAR EmployeeStatisticsGroup@1000 : Record 5212 EmployeeStatisticsGroup //Reference parameter of type Record
);

Parameters

EmployeeStatisticsGroup
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Employee, Stat, Group.

For a clarification about how this function works, refer to the code listed below.

      EmployeeStatisticsGroup.INIT;
      EmployeeStatisticsGroup.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(EmployeeStatisticsGroup.FIELDNO(Code),DATABASE::"Employee Statistics Group"),
          1,
          LibraryUtility.GetFieldLength(DATABASE::"Employee Statistics Group",EmployeeStatisticsGroup.FIELDNO(Code))));
      EmployeeStatisticsGroup.VALIDATE(Description,EmployeeStatisticsGroup.Code);
      EmployeeStatisticsGroup.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136903 to show one way of using this function.

      LibraryHumanResource.CreateEmployeeStatGroup(EmployeeStatisticsGroup);
      EXIT(EmployeeStatisticsGroup.Code);
Member of Lib.Library - Human Resource


CreateEmploymentContract@11 Method

The procedure CreateEmploymentContract is available in codeunit 131901.

Syntax

CreateEmploymentContract@11(
    VAR EmploymentContract@1000 : Record 5211 EmploymentContract //Reference parameter of type Record
);

Parameters

EmploymentContract
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Employment, Contract.

For a clarification about how this function works, refer to the code listed below.

      EmploymentContract.INIT;
      EmploymentContract.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(EmploymentContract.FIELDNO(Code),DATABASE::"Employment Contract"),
          1,
          LibraryUtility.GetFieldLength(DATABASE::"Employment Contract",EmploymentContract.FIELDNO(Code))));
      EmploymentContract.VALIDATE(Description,EmploymentContract.Code);
      EmploymentContract.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136903 to show one way of using this function.

      LibraryHumanResource.CreateEmploymentContract(EmploymentContract);
Member of Lib.Library - Human Resource


CreateMiscArticle@8 Method

The procedure CreateMiscArticle is available in codeunit 131901.

Syntax

CreateMiscArticle@8(
    VAR MiscArticle@1000 : Record 5213 MiscArticle //Reference parameter of type Record
);

Parameters

MiscArticle
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Misc, Article.

For a clarification about how this function works, refer to the code listed below.

      MiscArticle.INIT;
      MiscArticle.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(MiscArticle.FIELDNO(Code),DATABASE::"Misc. Article"),
          1,
          LibraryUtility.GetFieldLength(DATABASE::"Misc. Article",MiscArticle.FIELDNO(Code))));
      MiscArticle.VALIDATE(Description,MiscArticle.Code);
      MiscArticle.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136903 to show one way of using this function.

      LibraryHumanResource.CreateMiscArticle(MiscArticle);
      EXIT(MiscArticle.Code);
Member of Lib.Library - Human Resource


CreateMiscArticleInformation@5 Method

The procedure CreateMiscArticleInformation is available in codeunit 131901.

Syntax

CreateMiscArticleInformation@5(
    VAR MiscArticleInformation@1000 : Record 5214 MiscArticleInformation, //Reference parameter of type Record
    EmployeeNo@1001 : Code[20] EmployeeNo, //Input parameter of type Code
    MiscArticleCode@1004 : Code[10] MiscArticleCode //Input parameter of type Code
);

Parameters

MiscArticleInformation
Reference parameter of type Record
EmployeeNo
Input parameter of type Code
MiscArticleCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Misc, Article, Information.

For a clarification about how this function works, refer to the code listed below.

      MiscArticleInformation.INIT;
      MiscArticleInformation.VALIDATE("Employee No.",EmployeeNo);
      MiscArticleInformation.VALIDATE("Misc. Article Code",MiscArticleCode);
      RecRef.GETTABLE(MiscArticleInformation);
      MiscArticleInformation.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,MiscArticleInformation.FIELDNO("Line No.")));
      MiscArticleInformation.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136404 to show one way of using this function.

      // Test Miscellaneous Articles Overview Matrix after creation of Miscellaneous Article Information for Employee.

      // 1. Setup: Create Employee and Miscellaneous Article Information for the Employee.
      Initialize;
      LibraryHumanResource.CreateEmployee(Employee);
      MiscArticle.FINDFIRST;
      LibraryHumanResource.CreateMiscArticleInformation(MiscArticleInformation,Employee."No.",MiscArticle.Code);
      LibraryVariableStorage.Enqueue(Employee."No.");  // Assign variable for page handler.

      // 2. Exercise: Run Miscellaneous Articles Overview page from Employee card page and run Show Matrix from it.
      EmployeeCard.OPENEDIT;
      EmployeeCard.FILTER.SETFILTER("No.",Employee."No.");
      MiscArticlesOverview.TRAP;
      EmployeeCard."Page Misc. Articles Overview".INVOKE;
      COMMIT;
      MiscArticlesOverview.ShowMatrix.INVOKE;

      // 3. Verify: Verify value on Miscellaneous Articles Overview Matrix performed on Miscellaneous Articles Overview Matrix
      // page handler.
Member of Lib.Library - Human Resource


CreateQualification@13 Method

The procedure CreateQualification is available in codeunit 131901.

Syntax

CreateQualification@13(
    VAR Qualification@1000 : Record 5202 Qualification //Reference parameter of type Record
);

Parameters

Qualification
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Qualification.

For a clarification about how this function works, refer to the code listed below.

      Qualification.INIT;
      Qualification.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(Qualification.FIELDNO(Code),DATABASE::Qualification),
          1,
          LibraryUtility.GetFieldLength(DATABASE::Qualification,Qualification.FIELDNO(Code))));
      Qualification.VALIDATE(Description,Qualification.Code);
      Qualification.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136903 to show one way of using this function.

      LibraryHumanResource.CreateQualification(Qualification);
      EXIT(Qualification.Code);
Member of Lib.Library - Human Resource


CreateRelative@7 Method

The procedure CreateRelative is available in codeunit 131901.

Syntax

CreateRelative@7(
    VAR Relative@1000 : Record 5204 Relative //Reference parameter of type Record
);

Parameters

Relative
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Relative.

For a clarification about how this function works, refer to the code listed below.

      Relative.INIT;
      Relative.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(Relative.FIELDNO(Code),DATABASE::Relative),
          1,
          LibraryUtility.GetFieldLength(DATABASE::Relative,Relative.FIELDNO(Code))));
      Relative.VALIDATE(Description,Relative.Code);
      Relative.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136903 to show one way of using this function.

      LibraryHumanResource.CreateRelative(Relative);
      EXIT(Relative.Code);
Member of Lib.Library - Human Resource


CreateUnion@3 Method

The procedure CreateUnion is available in codeunit 131901.

Syntax

CreateUnion@3(
    VAR Union@1000 : Record 5209 Union //Reference parameter of type Record
);

Parameters

Union
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Union.

For a clarification about how this function works, refer to the code listed below.

      Union.INIT;
      Union.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(Union.FIELDNO(Code),DATABASE::Union),
          1,
          LibraryUtility.GetFieldLength(DATABASE::Union,Union.FIELDNO(Code))));
      Union.VALIDATE(Name,Union.Code);
      Union.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136903 to show one way of using this function.

      // Test that the values of Code in Employee - Unions Report must match in Corresponding Employee Table values.

      // 1. Setup: Find Union and Modify Employee.
      Initialize;
      LibraryHumanResource.CreateEmployee(Employee);
      LibraryHumanResource.CreateUnion(Union);
      ModifyEmployeeUnions(Employee,Union.Code);

      // 2. Exercise: Generate Employee - Unions Report.
      COMMIT;
      CLEAR(EmployeeUnions);
      Union.SETRANGE(Code,Union.Code);
      EmployeeUnions.SETTABLEVIEW(Union);
      EmployeeUnions.RUN;

      // 3. Verify: Verify that the values of Code in Employee - Unions Report must match in Corresponding Employee Table values.
      LibraryReportDataset.LoadDataSetFile;
      LibraryReportDataset.SetRange('Union_Code',Union.Code);
      Assert.IsTrue(LibraryReportDataset.GetNextRow,'find element with the union code');
Member of Lib.Library - Human Resource


SetupEmployeeNumberSeries@6 Method

The procedure SetupEmployeeNumberSeries is available in codeunit 131901.

Syntax

SetupEmployeeNumberSeries@6(
      //param element not supplied
);

Return Value

Code[10]

Remarks

The relevant search keywords are: Setup, Employee, Number, Series.

For a clarification about how this function works, refer to the code listed below.

      HumanResourcesSetup.GET;
      IF HumanResourcesSetup."Employee Nos." = '' THEN
        HumanResourcesSetup.VALIDATE("Employee Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      HumanResourcesSetup.MODIFY(TRUE);
      EXIT(HumanResourcesSetup."Employee Nos.");

Example

The below example is extracted from the test automation codeunit 134777 to show one way of using this function.

      DataSensitivity.DELETEALL;

      IF IsInitialized THEN
        EXIT;

      LibraryHumanResource.SetupEmployeeNumberSeries;

      IsInitialized := TRUE;
      COMMIT;
Member of Lib.Library - Human Resource


Library - Incoming Documents Class

Lib.Library - Incoming Documents

COD131100 applies to ERM,W1,All.

Methods

Name | Description
CreateNewIncomingDocument@11 | The procedure CreateNewIncomingDocument is available in codeunit 131100.
InitIncomingDocuments@3 | The procedure InitIncomingDocuments is available in codeunit 131100.

See Also

Lib


CreateNewIncomingDocument@11 Method

The procedure CreateNewIncomingDocument is available in codeunit 131100.

Syntax

CreateNewIncomingDocument@11(
    VAR IncomingDocument@1000 : Record 130 IncomingDocument //Reference parameter of type Record
);

Parameters

IncomingDocument
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, New, Incoming, Document.

For a clarification about how this function works, refer to the code listed below.

      IncomingDocument.INIT;
      IncomingDocument."Entry No." := 0;
      IncomingDocument.Description := 'abcdefghijklmnopqrstuvxyz123';
      IncomingDocument.SetURL('http://www.microsoft.com/Dynamics');
      IncomingDocument.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134179 to show one way of using this function.

      // [SCENARIO] This test verifies E2E scenario for the purchase invoice approval and basic purchase invoice posting workflow.
      // [GIVEN] A Purchase Invoice created from an Incoming Document.
      // [GIVEN] Purchase Invoice Approval Workflow that has Purchaser as the approver and No Limit as the limit type.
      // [WHEN] Purchase Invoice is sent for approval.
      // [THEN] Approval Request is created for the purchaser.
      // [WHEN] Purchaser approves the approval request.
      // [THEN] Purchase Invoice is released.
      // [THEN] Purchase Invoice is posted.
      // [THEN] A payment line is created.

      Initialize;
      EnableIncDocWorkflow;

      LibraryWorkflow.CreateEnabledWorkflow(Workflow,WorkflowSetup.PurchaseInvoiceApprovalWorkflowCode);

      EnablePurchInvWorkflow;

      // Setup - Create Incoming Document.
      LibraryIncomingDocuments.InitIncomingDocuments;
      LibraryIncomingDocuments.CreateNewIncomingDocument(IncomingDocument);

      // Verify - Notification Entry.
      VerifyNotificationEntry(IncomingDocument.RECORDID);

      // Setup - Create 2 usersetups
      LibraryDocumentApprovals.CreateOrFindUserSetup(CurrentUserSetup,USERID);
      LibraryDocumentApprovals.CreateMockupUserSetup(ApproverUserSetup);

      // Setup - Chain of approvers
      LibraryDocumentApprovals.SetApprover(CurrentUserSetup,ApproverUserSetup);

      // Setup - Create purchase invoice for the incoming document.
      CreatePurchInvWithLine(PurchHeader,LibraryRandom.RandInt(5000));
      PurchHeader.VALIDATE("Incoming Document Entry No.",IncomingDocument."Entry No.");
      PurchHeader.MODIFY(TRUE);

      // Setup - Update Purchaser Code
      SetPurchDocPurchaserCode(PurchHeader,ApproverUserSetup."Salespers./Purch. Code");

      // Excercise - Open Purchase invoice card and sent it for approval
      SendPurchaseInvoiceForApproval(PurchHeader);

      // Verify - Purchase invoice status is set to Pending Approval
      VerifyPurchaseInvIsPendingApproval(PurchHeader);

      // Setup - Assign the approval entry to current user so that it can be approved
      LibraryDocumentApprovals.GetApprovalEntries(ApprovalEntry,PurchHeader.RECORDID);
      LibraryDocumentApprovals.UpdateApprovalEntryWithCurrUser(PurchHeader.RECORDID);

      // Exercise - Approve the approval request
      ApprovalsMgmt.ApproveRecordApprovalRequest(PurchHeader.RECORDID);

      // Verify - Payment line has been created.
      PurchInvHeader.SETRANGE("Pre-Assigned No.",PurchHeader."No.");
      PurchInvHeader.FINDFIRST;

      GenJournalLine.SETRANGE("Document Type",GenJournalLine."Document Type"::Payment);
      GenJournalLine.SETRANGE("Applies-to Doc. Type",GenJournalLine."Applies-to Doc. Type"::Invoice);
      GenJournalLine.SETRANGE("Applies-to Doc. No.",PurchInvHeader."No.");
      Assert.AreEqual(1,GenJournalLine.COUNT,'Unexpected payment line.');
      GenJournalLine.FINDFIRST;

      // Verify - Notification entry.
      VerifyNotificationEntry(GenJournalLine.RECORDID);
Member of Lib.Library - Incoming Documents


InitIncomingDocuments@3 Method

The procedure InitIncomingDocuments is available in codeunit 131100.

Syntax

InitIncomingDocuments@3(
      //param element not supplied
);

Remarks

The relevant search keywords are: Init, Incoming, Documents.

For a clarification about how this function works, refer to the code listed below.

      IF IncomingDocumentsSetup.GET THEN
        IncomingDocumentsSetup.DELETE;

      LibraryERM.CreateGenJournalTemplate(GenJournalTemplate);
      LibraryERM.CreateGenJournalBatch(GenJournalBatch,GenJournalTemplate.Name);

      IncomingDocumentsSetup.INIT;
      IncomingDocumentsSetup.VALIDATE("General Journal Template Name",GenJournalTemplate.Name);
      IncomingDocumentsSetup.VALIDATE("General Journal Batch Name",GenJournalBatch.Name);
      IncomingDocumentsSetup.VALIDATE("Require Approval To Create",FALSE);
      IncomingDocumentsSetup.INSERT;

      IncomingDocumentApprover.INIT;
      IncomingDocumentApprover."User ID" := USERSECURITYID;
      IF IncomingDocumentApprover.INSERT THEN;

Example

The below example is extracted from the test automation codeunit 134179 to show one way of using this function.

      // [SCENARIO] This test verifies E2E scenario for the purchase invoice approval and basic purchase invoice posting workflow.
      // [GIVEN] A Purchase Invoice created from an Incoming Document.
      // [GIVEN] Purchase Invoice Approval Workflow that has Purchaser as the approver and No Limit as the limit type.
      // [WHEN] Purchase Invoice is sent for approval.
      // [THEN] Approval Request is created for the purchaser.
      // [WHEN] Purchaser approves the approval request.
      // [THEN] Purchase Invoice is released.
      // [THEN] Purchase Invoice is posted.
      // [THEN] A payment line is created.

      Initialize;
      EnableIncDocWorkflow;

      LibraryWorkflow.CreateEnabledWorkflow(Workflow,WorkflowSetup.PurchaseInvoiceApprovalWorkflowCode);

      EnablePurchInvWorkflow;

      // Setup - Create Incoming Document.
      LibraryIncomingDocuments.InitIncomingDocuments;
      LibraryIncomingDocuments.CreateNewIncomingDocument(IncomingDocument);

      // Verify - Notification Entry.
      VerifyNotificationEntry(IncomingDocument.RECORDID);

      // Setup - Create 2 usersetups
      LibraryDocumentApprovals.CreateOrFindUserSetup(CurrentUserSetup,USERID);
      LibraryDocumentApprovals.CreateMockupUserSetup(ApproverUserSetup);

      // Setup - Chain of approvers
      LibraryDocumentApprovals.SetApprover(CurrentUserSetup,ApproverUserSetup);

      // Setup - Create purchase invoice for the incoming document.
      CreatePurchInvWithLine(PurchHeader,LibraryRandom.RandInt(5000));
      PurchHeader.VALIDATE("Incoming Document Entry No.",IncomingDocument."Entry No.");
      PurchHeader.MODIFY(TRUE);

      // Setup - Update Purchaser Code
      SetPurchDocPurchaserCode(PurchHeader,ApproverUserSetup."Salespers./Purch. Code");

      // Excercise - Open Purchase invoice card and sent it for approval
      SendPurchaseInvoiceForApproval(PurchHeader);

      // Verify - Purchase invoice status is set to Pending Approval
      VerifyPurchaseInvIsPendingApproval(PurchHeader);

      // Setup - Assign the approval entry to current user so that it can be approved
      LibraryDocumentApprovals.GetApprovalEntries(ApprovalEntry,PurchHeader.RECORDID);
      LibraryDocumentApprovals.UpdateApprovalEntryWithCurrUser(PurchHeader.RECORDID);

      // Exercise - Approve the approval request
      ApprovalsMgmt.ApproveRecordApprovalRequest(PurchHeader.RECORDID);

      // Verify - Payment line has been created.
      PurchInvHeader.SETRANGE("Pre-Assigned No.",PurchHeader."No.");
      PurchInvHeader.FINDFIRST;

      GenJournalLine.SETRANGE("Document Type",GenJournalLine."Document Type"::Payment);
      GenJournalLine.SETRANGE("Applies-to Doc. Type",GenJournalLine."Applies-to Doc. Type"::Invoice);
      GenJournalLine.SETRANGE("Applies-to Doc. No.",PurchInvHeader."No.");
      Assert.AreEqual(1,GenJournalLine.COUNT,'Unexpected payment line.');
      GenJournalLine.FINDFIRST;

      // Verify - Notification entry.
      VerifyNotificationEntry(GenJournalLine.RECORDID);
Member of Lib.Library - Incoming Documents


Library - Inventory Class

Lib.Library - Inventory

COD132201 applies to SCM,COSTING,W1,IN.
Unsupported version tags:
Contains all utility functions related to Inventory Management.

Methods

Name | Description
CalculateCountingPeriod@41 | The procedure CalculateCountingPeriod is available in codeunit 132201.
CalculateInventory@61 | The procedure CalculateInventory is available in codeunit 132201.
ClearItemJournal@134 | The procedure ClearItemJournal is available in codeunit 132201.
CreateAnalysisColumn@6 | The procedure CreateAnalysisColumn is available in codeunit 132201.
CreateAnalysisColumnTemplate@39 | The procedure CreateAnalysisColumnTemplate is available in codeunit 132201.
CreateAnalysisLine@124 | The procedure CreateAnalysisLine is available in codeunit 132201.
CreateAnalysisLineTemplate@138 | The procedure CreateAnalysisLineTemplate is available in codeunit 132201.
CreateAnalysisReportName@62 | The procedure CreateAnalysisReportName is available in codeunit 132201.
CreateAndUpdateTransferRoute@60 | The procedure CreateAndUpdateTransferRoute is available in codeunit 132201.
CreateBaseCalendarChange@7 | The procedure CreateBaseCalendarChange is available in codeunit 132201.
CreateInventoryPeriod@149 | The procedure CreateInventoryPeriod is available in codeunit 132201.
CreateInventoryPostingGroup@148 | The procedure CreateInventoryPostingGroup is available in codeunit 132201.
CreateInventoryPostingSetup@32 | The procedure CreateInventoryPostingSetup is available in codeunit 132201.
CreateItem@18 | The procedure CreateItem is available in codeunit 132201.
CreateItemBudgetEntry@9 | The procedure CreateItemBudgetEntry is available in codeunit 132201.
CreateItemCategory@117 | The procedure CreateItemCategory is available in codeunit 132201.
CreateItemCharge@64 | The procedure CreateItemCharge is available in codeunit 132201.
CreateItemChargeAssignment@5807 | The procedure CreateItemChargeAssignment is available in codeunit 132201.
CreateItemChargeAssignPurchase@1 | The procedure CreateItemChargeAssignPurchase is available in codeunit 132201.
CreateItemChargeNo@2 | The procedure CreateItemChargeNo is available in codeunit 132201.
CreateItemCrossReference@121 | The procedure CreateItemCrossReference is available in codeunit 132201.
CreateItemJnlLineWithNoItem@180 | The procedure CreateItemJnlLineWithNoItem is available in codeunit 132201.
CreateItemJournal@55 | The procedure CreateItemJournal is available in codeunit 132201.
CreateItemJournalBatch@52 | The procedure CreateItemJournalBatch is available in codeunit 132201.
CreateItemJournalBatchByType@4 | The procedure CreateItemJournalBatchByType is available in codeunit 132201.
CreateItemJournalLine@34 | The procedure CreateItemJournalLine is available in codeunit 132201.
CreateItemJournalLineInItemTemplate@27 | The procedure CreateItemJournalLineInItemTemplate is available in codeunit 132201.
CreateItemJournalTemplate@68 | The procedure CreateItemJournalTemplate is available in codeunit 132201.
CreateItemManufacturing@8 | The procedure CreateItemManufacturing is available in codeunit 132201.
CreateItemNo@71 | The procedure CreateItemNo is available in codeunit 132201.
CreateItemNoWithPostingSetup@21 | The procedure CreateItemNoWithPostingSetup is available in codeunit 132201.
CreateItemNoWithVATProdPostingGroup@66 | The procedure CreateItemNoWithVATProdPostingGroup is available in codeunit 132201.
CreateItemTrackingCode@36 | The procedure CreateItemTrackingCode is available in codeunit 132201.
CreateItemUnitOfMeasure@20 | The procedure CreateItemUnitOfMeasure is available in codeunit 132201.
CreateItemUnitOfMeasureCode@91 | The procedure CreateItemUnitOfMeasureCode is available in codeunit 132201.
CreateItemVariant@122 | The procedure CreateItemVariant is available in codeunit 132201.
CreateItemVendor@120 | The procedure CreateItemVendor is available in codeunit 132201.
CreateItemWithPostingSetup@22 | The procedure CreateItemWithPostingSetup is available in codeunit 132201.
CreateItemWithTariffNo@47 | The procedure CreateItemWithTariffNo is available in codeunit 132201.
CreateItemWithUnitPriceAndUnitCost@69 | The procedure CreateItemWithUnitPriceAndUnitCost is available in codeunit 132201.
CreateLotNoInformation@35 | The procedure CreateLotNoInformation is available in codeunit 132201.
CreateNonStock@44 | The procedure CreateNonStock is available in codeunit 132201.
CreateNonStockItem@131 | The procedure CreateNonStockItem is available in codeunit 132201.
CreatePhysicalInventoryCountingPeriod@40 | The procedure CreatePhysicalInventoryCountingPeriod is available in codeunit 132201.
CreateProductGroup@51 | The procedure CreateProductGroup is available in codeunit 132201.
CreateSerialNoInformation@33 | The procedure CreateSerialNoInformation is available in codeunit 132201.
CreateServiceTypeItem@42 | The procedure CreateServiceTypeItem is available in codeunit 132201.
CreateShippingAgent@116 | The procedure CreateShippingAgent is available in codeunit 132201.
CreateShippingAgentService@94 | The procedure CreateShippingAgentService is available in codeunit 132201.
CreateStandardCostWorksheetName@37 | The procedure CreateStandardCostWorksheetName is available in codeunit 132201.
CreateStockKeepingUnit@129 | The procedure CreateStockKeepingUnit is available in codeunit 132201.
CreateStockkeepingUnitForLocationAndVariant@140 | The procedure CreateStockkeepingUnitForLocationAndVariant is available in codeunit 132201.
CreateTrackedItem@58 | The procedure CreateTrackedItem is available in codeunit 132201.
CreateTransferHeader@29 | The procedure CreateTransferHeader is available in codeunit 132201.
CreateTransferLine@59 | The procedure CreateTransferLine is available in codeunit 132201.
CreateTransferRoute@25 | The procedure CreateTransferRoute is available in codeunit 132201.
CreateUnitOfMeasureCode@95 | The procedure CreateUnitOfMeasureCode is available in codeunit 132201.
CreateVariant@160 | The procedure CreateVariant is available in codeunit 132201.
DateComprItemBudgetEntries@108 | The procedure DateComprItemBudgetEntries is available in codeunit 132201.
FindItemJournalTemplate@142 | The procedure FindItemJournalTemplate is available in codeunit 132201.
FindUnitOfMeasure@145 | The procedure FindUnitOfMeasure is available in codeunit 132201.
GetQtyPerForItemUOM@3 | The procedure GetQtyPerForItemUOM is available in codeunit 132201.
GetReservConfirmText@123 | The procedure GetReservConfirmText is available in codeunit 132201.
GetVariant@150 | The procedure GetVariant is available in codeunit 132201.
MakeItemJournalLine@23 | The procedure MakeItemJournalLine is available in codeunit 132201.
NoSeriesSetup@444 | The procedure NoSeriesSetup is available in codeunit 132201.
OutputJnlExplRoute@13 | The procedure OutputJnlExplRoute is available in codeunit 132201.
PostItemJournalBatch@5 | The procedure PostItemJournalBatch is available in codeunit 132201.
PostItemJournalLine@45 | The procedure PostItemJournalLine is available in codeunit 132201.
PostTransferHeader@43 | The procedure PostTransferHeader is available in codeunit 132201.
ReleaseSalesOrder@78 | The procedure ReleaseSalesOrder is available in codeunit 132201.
ReleaseTransferOrder@100 | The procedure ReleaseTransferOrder is available in codeunit 132201.
ReopenTransferOrder@11 | The procedure ReopenTransferOrder is available in codeunit 132201.
SaveAsStandardJournal@127 | The procedure SaveAsStandardJournal is available in codeunit 132201.
SelectCustomer@103 | The procedure SelectCustomer is available in codeunit 132201.
SelectGenPostingSetup@48 | The procedure SelectGenPostingSetup is available in codeunit 132201.
SelectItemJournalBatchName@53 | The procedure SelectItemJournalBatchName is available in codeunit 132201.
SelectItemJournalTemplateName@54 | The procedure SelectItemJournalTemplateName is available in codeunit 132201.
SelectVATPostingSetup@79 | The procedure SelectVATPostingSetup is available in codeunit 132201.
SetAutomaticCostAdjmtAlways@12 | The procedure SetAutomaticCostAdjmtAlways is available in codeunit 132201.
SetAutomaticCostAdjmtNever@19 | The procedure SetAutomaticCostAdjmtNever is available in codeunit 132201.
SetAutomaticCostPosting@10 | The procedure SetAutomaticCostPosting is available in codeunit 132201.
SetAverageCostSetup@16 | The procedure SetAverageCostSetup is available in codeunit 132201.
SetExpectedCostPosting@15 | The procedure SetExpectedCostPosting is available in codeunit 132201.
SetLocationMandatory@14 | The procedure SetLocationMandatory is available in codeunit 132201.
SetPreventNegativeInventory@17 | The procedure SetPreventNegativeInventory is available in codeunit 132201.
UpdateGenProdPostingSetup@56 | The procedure UpdateGenProdPostingSetup is available in codeunit 132201.
UpdateInventoryPostingSetup@57 | The procedure UpdateInventoryPostingSetup is available in codeunit 132201.
UpdateInventorySetup@49 | The procedure UpdateInventorySetup is available in codeunit 132201.
UpdateSalesLine@147 | The procedure UpdateSalesLine is available in codeunit 132201.

See Also

Lib


CalculateCountingPeriod@41 Method

The procedure CalculateCountingPeriod is available in codeunit 132201.

Syntax

CalculateCountingPeriod@41(
    VAR ItemJournalLine@1001 : Record 83 ItemJournalLine //Reference parameter of type Record
);

Parameters

ItemJournalLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Calculate, Counting, Period.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(PhysInvtCountManagement);
      PhysInvtCountManagement.InitFromItemJnl(ItemJournalLine);
      PhysInvtCountManagement.RUN;

Example

The below example is extracted from the test automation codeunit 137055 to show one way of using this function.

      // Setup: Create Item with Physical Inventory Counting Period, create and post Purchase order, create blank Item Journal Line.
      Initialize;
      LibraryInventory.CreateItem(Item);
      Quantity := LibraryRandom.RandDec(100,2);  // Using Random value.
      UpdateItemForPhysicalInventoryCountingPeriod(Item);
      CreateAndPostPurchaseOrder(Item."No.",Quantity);
      GlobalItemNo := Item."No.";  // Asssign value to global variable.

      // Create Blank Item Journal Line.
      LibraryInventory.CreateItemJournalLine(
        ItemJournalLine,ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name,
        ItemJournalLine."Entry Type"::"Positive Adjmt.",'',0.0);
      COMMIT;

      // Exercise: Calculate Counting Period.
      LibraryInventory.CalculateCountingPeriod(ItemJournalLine);

      // Verify: Verify calculated Quantity for Item in Item Journal Line.
      VerifyItemJournalLine(GlobalItemNo,Quantity);
Member of Lib.Library - Inventory


CalculateInventory@61 Method

The procedure CalculateInventory is available in codeunit 132201.

Syntax

CalculateInventory@61(
    ItemJournalLine@1004 : Record 83 ItemJournalLine, //Input parameter of type Record
    ItemNo@1003 : Code[20] ItemNo, //Input parameter of type Code
    PostingDate@1001 : Date PostingDate, //Input parameter of type Date
    ItemsNotOnInvt@1005 : Boolean ItemsNotOnInvt //Input parameter of type Boolean
);

Parameters

ItemJournalLine
Input parameter of type Record
ItemNo
Input parameter of type Code
PostingDate
Input parameter of type Date
ItemsNotOnInvt
Input parameter of type Boolean

Remarks

The relevant search keywords are: Calculate, Inventory.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(CalculateInventory);
      Item.SETRANGE("No.",ItemNo);
      CalculateInventory.USEREQUESTPAGE(FALSE);
      CalculateInventory.SETTABLEVIEW(Item);
      CalculateInventory.SetItemJnlLine(ItemJournalLine);
      CalculateInventory.InitializeRequest(PostingDate,ItemJournalLine."Document No.",ItemsNotOnInvt);
      CalculateInventory.RUN;

Example

The below example is extracted from the test automation codeunit 134475 to show one way of using this function.

      // Find Item journal Batch and create Item Journal and Calculate Inventory.
      SelectAndClearItemJournalBatch(ItemJournalBatch,ItemJournalBatch."Template Type"::"Phys. Inventory");
      ItemJournalLine.INIT;
      ItemJournalLine.VALIDATE("Journal Template Name",ItemJournalBatch."Journal Template Name");
      ItemJournalLine.VALIDATE("Journal Batch Name",ItemJournalBatch.Name);
      LibraryInventory.CalculateInventory(ItemJournalLine,ItemNo,WORKDATE,TRUE);

      // Find created Item Journal Line.
      ItemJournalLine.SETRANGE("Journal Template Name",ItemJournalBatch."Journal Template Name");
      ItemJournalLine.SETRANGE("Journal Batch Name",ItemJournalBatch.Name);
      ItemJournalLine.FINDFIRST;

      // Update Item Journal Line and attach Dimension.
      ItemJournalLine.VALIDATE(
        "Document No.",NoSeriesManagement.GetNextNo(ItemJournalBatch."No. Series",ItemJournalLine."Posting Date",FALSE));
      ItemJournalLine.VALIDATE("Qty. (Phys. Inventory)",0);
      ItemJournalLine.VALIDATE("Unit Amount",LibraryRandom.RandDec(10,2));
      ItemJournalLine.VALIDATE(
        "Dimension Set ID",
        LibraryDimension.CreateDimSet(
          ItemJournalLine."Dimension Set ID",DefaultDimension."Dimension Code",DefaultDimension."Dimension Value Code"));
      ItemJournalLine.MODIFY(TRUE);
Member of Lib.Library - Inventory


ClearItemJournal@134 Method

The procedure ClearItemJournal is available in codeunit 132201.

Syntax

ClearItemJournal@134(
    ItemJournalTemplate@1002 : Record 82 ItemJournalTemplate, //Input parameter of type Record
    ItemJournalBatch@1001 : Record 233 ItemJournalBatch //Input parameter of type Record
);

Parameters

ItemJournalTemplate
Input parameter of type Record
ItemJournalBatch
Input parameter of type Record

Remarks

The relevant search keywords are: Clear, Item, Journal.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(ItemJournalLine);
      ItemJournalLine.SETRANGE("Journal Template Name",ItemJournalTemplate.Name);
      ItemJournalLine.SETRANGE("Journal Batch Name",ItemJournalBatch.Name);
      ItemJournalLine.DELETEALL;

Example

The below example is extracted from the test automation codeunit 134377 to show one way of using this function.

      LibraryInventory.SelectItemJournalTemplateName(ItemJournalTemplate,ItemJournalTemplate.Type::Item);
      LibraryInventory.SelectItemJournalBatchName(ItemJournalBatch,ItemJournalBatch."Template Type"::Item,ItemJournalTemplate.Name);
      LibraryInventory.ClearItemJournal(ItemJournalTemplate,ItemJournalBatch);
Member of Lib.Library - Inventory


CreateAnalysisColumn@6 Method

The procedure CreateAnalysisColumn is available in codeunit 132201.

Syntax

CreateAnalysisColumn@6(
    VAR AnalysisColumn@1000 : Record 7118 AnalysisColumn, //Reference parameter of type Record
    AnalysisArea@1001 : Option AnalysisArea, //Input parameter of type Option
    AnalysisColumnTemplateName@1002 : Code[10] AnalysisColumnTemplateName //Input parameter of type Code
);

Parameters

AnalysisColumn
Reference parameter of type Record
AnalysisArea
Input parameter of type Option
AnalysisColumnTemplateName
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Analysis, Column.

For a clarification about how this function works, refer to the code listed below.

      AnalysisColumn.INIT;
      AnalysisColumn.VALIDATE("Analysis Area",AnalysisArea);
      AnalysisColumn.VALIDATE("Analysis Column Template",AnalysisColumnTemplateName);
      RecRef.GETTABLE(AnalysisColumn);
      AnalysisColumn.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,AnalysisColumn.FIELDNO("Line No.")));
      AnalysisColumn.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134327 to show one way of using this function.

      // [FEATURE] [UI]
      // [SCENARIO 201736] "Column Header" is placed as column caption in Purchase Analysis Matrix
      Initialize;

      // [GIVEN] Analysis Report Name "N" for Purchase Analysis Area
      LibraryInventory.CreateAnalysisReportName(AnalysisReportName,AnalysisReportName."Analysis Area"::Purchase);
      AnalysisLineTemplateName := CreateAnalysisLineWithTypeVendor(AnalysisReportName."Analysis Area"::Purchase,CreateVendor);

      // [GIVEN] Analysis Column defined with "Column No." = '' and "Column Header" = "Col"
      LibraryInventory.CreateAnalysisColumnTemplate(AnalysisColumnTemplate,AnalysisReportName."Analysis Area"::Purchase);
      LibraryERM.CreateAnalysisColumn(AnalysisColumn,AnalysisReportName."Analysis Area"::Purchase,AnalysisColumnTemplate.Name);
      AnalysisColumn."Column No." := '';
      AnalysisColumn."Column Header" := LibraryUtility.GenerateGUID;
      AnalysisColumn.MODIFY;

      LibraryVariableStorage.Enqueue(0);
      LibraryVariableStorage.Enqueue(AnalysisColumn."Column Header");

      // [WHEN] Open Analysis Report Purchase for Analysis Report Name "N"
      OpenAnalysisReportPurchase(AnalysisReportName.Name,AnalysisLineTemplateName,AnalysisColumnTemplate.Name);

      // [THEN] Column "Col" is visible and has caption "Col"
      // Verification done in PurchaseAnalysisMatrixRequestPageHandler.
Member of Lib.Library - Inventory


CreateAnalysisColumnTemplate@39 Method

The procedure CreateAnalysisColumnTemplate is available in codeunit 132201.

Syntax

CreateAnalysisColumnTemplate@39(
    VAR AnalysisColumnTemplate@1000 : Record 7116 AnalysisColumnTemplate, //Reference parameter of type Record
    AnalysisArea@1001 : Option AnalysisArea //Input parameter of type Option
);

Parameters

AnalysisColumnTemplate
Reference parameter of type Record
AnalysisArea
Input parameter of type Option

Remarks

The relevant search keywords are: Create, Analysis, Column, Template.

For a clarification about how this function works, refer to the code listed below.

      AnalysisColumnTemplate.INIT;
      AnalysisColumnTemplate.VALIDATE("Analysis Area",AnalysisArea);
      AnalysisColumnTemplate.VALIDATE(
        Name,LibraryUtility.GenerateRandomCode(AnalysisColumnTemplate.FIELDNO(Name),DATABASE::"Analysis Column Template"));
      AnalysisColumnTemplate.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134327 to show one way of using this function.

      // [FEATURE] [UI]
      // [SCENARIO 201736] "Column Header" is placed as column caption in Purchase Analysis Matrix
      Initialize;

      // [GIVEN] Analysis Report Name "N" for Purchase Analysis Area
      LibraryInventory.CreateAnalysisReportName(AnalysisReportName,AnalysisReportName."Analysis Area"::Purchase);
      AnalysisLineTemplateName := CreateAnalysisLineWithTypeVendor(AnalysisReportName."Analysis Area"::Purchase,CreateVendor);

      // [GIVEN] Analysis Column defined with "Column No." = '' and "Column Header" = "Col"
      LibraryInventory.CreateAnalysisColumnTemplate(AnalysisColumnTemplate,AnalysisReportName."Analysis Area"::Purchase);
      LibraryERM.CreateAnalysisColumn(AnalysisColumn,AnalysisReportName."Analysis Area"::Purchase,AnalysisColumnTemplate.Name);
      AnalysisColumn."Column No." := '';
      AnalysisColumn."Column Header" := LibraryUtility.GenerateGUID;
      AnalysisColumn.MODIFY;

      LibraryVariableStorage.Enqueue(0);
      LibraryVariableStorage.Enqueue(AnalysisColumn."Column Header");

      // [WHEN] Open Analysis Report Purchase for Analysis Report Name "N"
      OpenAnalysisReportPurchase(AnalysisReportName.Name,AnalysisLineTemplateName,AnalysisColumnTemplate.Name);

      // [THEN] Column "Col" is visible and has caption "Col"
      // Verification done in PurchaseAnalysisMatrixRequestPageHandler.
Member of Lib.Library - Inventory


CreateAnalysisLine@124 Method

The procedure CreateAnalysisLine is available in codeunit 132201.

Syntax

CreateAnalysisLine@124(
    VAR AnalysisLine@1000 : Record 7114 AnalysisLine, //Reference parameter of type Record
    AnalysisArea@1001 : Option AnalysisArea, //Input parameter of type Option
    AnalysisLineTemplateName@1002 : Code[10] AnalysisLineTemplateName //Input parameter of type Code
);

Parameters

AnalysisLine
Reference parameter of type Record
AnalysisArea
Input parameter of type Option
AnalysisLineTemplateName
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Analysis, Line.

For a clarification about how this function works, refer to the code listed below.

      AnalysisLine.INIT;
      AnalysisLine.VALIDATE("Analysis Area",AnalysisArea);
      AnalysisLine.VALIDATE("Analysis Line Template Name",AnalysisLineTemplateName);
      RecRef.GETTABLE(AnalysisLine);
      AnalysisLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,AnalysisLine.FIELDNO("Line No.")));
      AnalysisLine.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134327 to show one way of using this function.

      LibraryInventory.CreateAnalysisLineTemplate(AnalysisLineTemplate,ItemAnalysisViewAnalysisArea);
      LibraryInventory.CreateAnalysisLine(AnalysisLine,ItemAnalysisViewAnalysisArea,AnalysisLineTemplate.Name);
      AnalysisLine.VALIDATE(Type,AnalysisLine.Type::Vendor);
      AnalysisLine.VALIDATE(Range,VendorNo);
      AnalysisLine.MODIFY(TRUE);
      EXIT(AnalysisLine."Analysis Line Template Name");
Member of Lib.Library - Inventory


CreateAnalysisLineTemplate@138 Method

The procedure CreateAnalysisLineTemplate is available in codeunit 132201.

Syntax

CreateAnalysisLineTemplate@138(
    VAR AnalysisLineTemplate@1000 : Record 7112 AnalysisLineTemplate, //Reference parameter of type Record
    AnalysisArea@1001 : Option AnalysisArea //Input parameter of type Option
);

Parameters

AnalysisLineTemplate
Reference parameter of type Record
AnalysisArea
Input parameter of type Option

Remarks

The relevant search keywords are: Create, Analysis, Line, Template.

For a clarification about how this function works, refer to the code listed below.

      AnalysisLineTemplate.INIT;
      AnalysisLineTemplate.VALIDATE("Analysis Area",AnalysisArea);
      AnalysisLineTemplate.VALIDATE(
        Name,LibraryUtility.GenerateRandomCode(AnalysisLineTemplate.FIELDNO(Name),DATABASE::"Analysis Line Template"));
      AnalysisLineTemplate.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134327 to show one way of using this function.

      LibraryInventory.CreateAnalysisLineTemplate(AnalysisLineTemplate,ItemAnalysisViewAnalysisArea);
      LibraryInventory.CreateAnalysisLine(AnalysisLine,ItemAnalysisViewAnalysisArea,AnalysisLineTemplate.Name);
      AnalysisLine.VALIDATE(Type,AnalysisLine.Type::Vendor);
      AnalysisLine.VALIDATE(Range,VendorNo);
      AnalysisLine.MODIFY(TRUE);
      EXIT(AnalysisLine."Analysis Line Template Name");
Member of Lib.Library - Inventory


CreateAnalysisReportName@62 Method

The procedure CreateAnalysisReportName is available in codeunit 132201.

Syntax

CreateAnalysisReportName@62(
    VAR AnalysisReportName@1000 : Record 7111 AnalysisReportName, //Reference parameter of type Record
    AnalysisArea@1001 : Option AnalysisArea //Input parameter of type Option
);

Parameters

AnalysisReportName
Reference parameter of type Record
AnalysisArea
Input parameter of type Option

Remarks

The relevant search keywords are: Create, Analysis, Report, Name.

For a clarification about how this function works, refer to the code listed below.

      AnalysisReportName.INIT;
      AnalysisReportName.VALIDATE("Analysis Area",AnalysisArea);
      AnalysisReportName.VALIDATE(
        Name,LibraryUtility.GenerateRandomCode(AnalysisReportName.FIELDNO(Name),DATABASE::"Analysis Report Name"));
      AnalysisReportName.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134327 to show one way of using this function.

      // Check Cost Amount(Expected) on Purchase Analysis Matrix when Item Ledger Entry Type Filter Purchase.

      // Setup: Post Purchase Document with Ship Option and Create Analysis Report Name.
      Initialize;
      ItemNo := CreateItem;
      CreatePurchaseOrder(PurchaseHeader,PurchaseLine,ItemNo);
      FindValueEntry(ValueEntry,ItemNo,PurchaseHeader."Buy-from Vendor No.",
        LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,FALSE));
      LibraryVariableStorage.Enqueue(ValueEntry."Cost Amount (Expected)");
      LibraryERM.CreateItemAnalysisView(ItemAnalysisView,ItemAnalysisView."Analysis Area"::Purchase);
      LibraryInventory.CreateAnalysisReportName(AnalysisReportName,ItemAnalysisView."Analysis Area");

      // Exercise: Open Analysis Report Purchase with Correct filter Item Ledger Entry Type Purchase.
      OpenAnalysisReportPurchase(AnalysisReportName.Name,
        CreateAnalysisLineWithTypeVendor(ItemAnalysisView."Analysis Area",PurchaseHeader."Buy-from Vendor No."),
        CreateAnalysisColumnWithItemLedgerEntryType(ItemAnalysisView."Analysis Area",
          FORMAT(ValueEntry."Item Ledger Entry Type"::Purchase),AnalysisColumn."Value Type"::"Cost Amount"));

      // Verify: Verification done in PurchaseAnalysisMatrixRequestPageHandler.
Member of Lib.Library - Inventory


CreateAndUpdateTransferRoute@60 Method

The procedure CreateAndUpdateTransferRoute is available in codeunit 132201.

Syntax

CreateAndUpdateTransferRoute@60(
    VAR TransferRoute@1005 : Record 5742 TransferRoute, //Reference parameter of type Record
    TransferFrom@1001 : Code[10] TransferFrom, //Input parameter of type Code
    TransferTo@1000 : Code[10] TransferTo, //Input parameter of type Code
    InTransitCode@1004 : Code[10] InTransitCode, //Input parameter of type Code
    ShippingAgentCode@1002 : Code[10] ShippingAgentCode, //Input parameter of type Code
    ShippingAgentServiceCode@1003 : Code[10] ShippingAgentServiceCode //Input parameter of type Code
);

Parameters

TransferRoute
Reference parameter of type Record
TransferFrom
Input parameter of type Code
TransferTo
Input parameter of type Code
InTransitCode
Input parameter of type Code
ShippingAgentCode
Input parameter of type Code
ShippingAgentServiceCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Update, Transfer, Route.

For a clarification about how this function works, refer to the code listed below.

      CreateTransferRoute(TransferRoute,TransferFrom,TransferTo);
      TransferRoute.VALIDATE("In-Transit Code",InTransitCode);
      TransferRoute.VALIDATE("Shipping Agent Code",ShippingAgentCode);
      TransferRoute.VALIDATE("Shipping Agent Service Code",ShippingAgentServiceCode);
      TransferRoute.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137157 to show one way of using this function.

      // Verify Planned Delivery Date when Item with SKUs by locations and inter-location transfer
      Initialize;
      LocationBlue.FIND;
      LocationRed.FIND;

      // Create Critical Item, SKU by Location: RED, BLUE
      CreateItemCritical(Item);
      LibraryInventory.CreateStockkeepingUnitForLocationAndVariant(SKUBlue,LocationBlue.Code,Item."No.",'');
      LibraryInventory.CreateStockkeepingUnitForLocationAndVariant(SKURed,LocationRed.Code,Item."No.",'');

      // Create Route Transfer from BLUE to RED
      LibraryWarehouse.CreateAndUpdateTransferRoute(TransferRoute,LocationBlue.Code,LocationRed.Code,LocationIntransit.Code,'','');
      UpdateInboundAndOutboundWarehouseHandlingTimeOnLocation(LocationBlue);
      UpdateSKUReplenishmentSystemWithTransfer(SKURed,LocationBlue.Code);

      // Create Sales Order on RED
      CreateSalesOrder(SalesHeader,SalesLine,WORKDATE,0D,Item."No.",LocationRed.Code,LibraryRandom.RandDec(100,2));
      RunOrderPromisingFromSalesLine(SalesLine,OrderPromising::CapableToPromise,FALSE);

      // Verify that Planned Delivery Date considering BLUE outbound time transfer
      VerifyOrderPromisingLine(GetEarliestDeliveryDate(Item,LocationBlue.Code,FALSE),WORKDATE,SalesLine.Quantity);
Member of Lib.Library - Inventory


CreateBaseCalendarChange@7 Method

The procedure CreateBaseCalendarChange is available in codeunit 132201.

Syntax

CreateBaseCalendarChange@7(
    VAR BaseCalendarChange@1006 : Record 7601 BaseCalendarChange, //Reference parameter of type Record
    BaseCalendarCode@1003 : Code[10] BaseCalendarCode, //Input parameter of type Code
    RecurringSystem@1004 : Option RecurringSystem, //Input parameter of type Option
    Date@1000 : Date Date, //Input parameter of type Date
    Day@1005 : Option Day //Input parameter of type Option
);

Parameters

BaseCalendarChange
Reference parameter of type Record
BaseCalendarCode
Input parameter of type Code
RecurringSystem
Input parameter of type Option
Date
Input parameter of type Date
Day
Input parameter of type Option

Remarks

The relevant search keywords are: Create, Base, Calendar, Change.

For a clarification about how this function works, refer to the code listed below.

      BaseCalendarChange.INIT;
      BaseCalendarChange.VALIDATE("Base Calendar Code",BaseCalendarCode);
      BaseCalendarChange.VALIDATE("Recurring System",RecurringSystem);
      BaseCalendarChange.VALIDATE(Date,Date);
      BaseCalendarChange.VALIDATE(Day,Day);
      BaseCalendarChange.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136404 to show one way of using this function.

      LibraryInventory.CreateBaseCalendarChange(
        BaseCalendarChange,'',BaseCalendarChange."Recurring System"::" ",Date,BaseCalendarChange.Day::" ");
      BaseCalendarChange.VALIDATE(Nonworking,TRUE);
      BaseCalendarChange.MODIFY(TRUE);
Member of Lib.Library - Inventory


CreateInventoryPeriod@149 Method

The procedure CreateInventoryPeriod is available in codeunit 132201.

Syntax

CreateInventoryPeriod@149(
    VAR InventoryPeriod@1000 : Record 5814 InventoryPeriod, //Reference parameter of type Record
    EndingDate@1001 : Date EndingDate //Input parameter of type Date
);

Parameters

InventoryPeriod
Reference parameter of type Record
EndingDate
Input parameter of type Date

Remarks

The relevant search keywords are: Create, Inventory, Period.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(InventoryPeriod);
      IF InventoryPeriod.GET(EndingDate) THEN
        EXIT;
      InventoryPeriod.INIT;
      InventoryPeriod.VALIDATE("Ending Date",EndingDate);
      InventoryPeriod.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137101 to show one way of using this function.

      LibraryFiscalYear.CreateFiscalYear;
      PostingDate := LibraryFiscalYear.GetLastPostingDate(FALSE);
      LibraryInventory.CreateInventoryPeriod(InventoryPeriod,PostingDate);
Member of Lib.Library - Inventory


CreateInventoryPostingGroup@148 Method

The procedure CreateInventoryPostingGroup is available in codeunit 132201.

Syntax

CreateInventoryPostingGroup@148(
    VAR InventoryPostingGroup@1000 : Record 94 InventoryPostingGroup //Reference parameter of type Record
);

Parameters

InventoryPostingGroup
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Inventory, Posting, Group.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(InventoryPostingGroup);
      InventoryPostingGroup.INIT;
      InventoryPostingGroup.VALIDATE(Code,
        LibraryUtility.GenerateRandomCode(InventoryPostingGroup.FIELDNO(Code),DATABASE::"Inventory Posting Group"));
      InventoryPostingGroup.VALIDATE(Description,InventoryPostingGroup.Code);
      InventoryPostingGroup.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136601 to show one way of using this function.

      // Test if a Master Record - Item can be created using Standard Master Data Templates.

      // 1. Setup: Create new Data Template Header, Data Template Line for Inventory Posting Group, Gen. Product Posting Group.
      // Create new Instance.
      Initialize;
      LibraryRapidStart.CreateConfigTemplateHeader(ConfigTemplateHeader);
      InputTableInConfigTemplateHeader(ConfigTemplateHeader,DATABASE::Item);

      LibraryInventory.CreateInventoryPostingGroup(InventoryPostingGroup);
      CreateConfigTemplateLineForField(
        ConfigTemplateHeader.Code,Item.FIELDNO("Inventory Posting Group"),
        Item.FIELDNAME("Inventory Posting Group"),InventoryPostingGroup.Code);

      LibraryERM.FindGenProductPostingGroup(GenProductPostingGroup);
      CreateConfigTemplateLineForField(
        ConfigTemplateHeader.Code,Item.FIELDNO("Gen. Prod. Posting Group"),
        Item.FIELDNAME("Gen. Prod. Posting Group"),GenProductPostingGroup.Code);

      CreateNewInstance(ConfigTemplateHeader);

      // 2. Exercise: Apply Template to a new Item.
      LibraryInventory.CreateItem(Item);
      ApplyTemplateToItem(Item,ConfigTemplateHeader);

      // 3. Verify: Check that the Master Data Template has been applied to the Item.
      Item.GET(Item."No.");
      Item.TESTFIELD("Inventory Posting Group",InventoryPostingGroup.Code);
      Item.TESTFIELD("Gen. Prod. Posting Group",GenProductPostingGroup.Code);
Member of Lib.Library - Inventory


CreateInventoryPostingSetup@32 Method

The procedure CreateInventoryPostingSetup is available in codeunit 132201.

Syntax

CreateInventoryPostingSetup@32(
    VAR InventoryPostingSetup@1000 : Record 5813 InventoryPostingSetup, //Reference parameter of type Record
    LocationCode@1001 : Text[10] LocationCode, //Input parameter of type Text
    PostingGroupCode@1002 : Text[10] PostingGroupCode //Input parameter of type Text
);

Parameters

InventoryPostingSetup
Reference parameter of type Record
LocationCode
Input parameter of type Text
PostingGroupCode
Input parameter of type Text

Remarks

The relevant search keywords are: Create, Inventory, Posting, Setup.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(InventoryPostingSetup);
      InventoryPostingSetup.INIT;
      InventoryPostingSetup.VALIDATE("Location Code",LocationCode);
      InventoryPostingSetup.VALIDATE("Invt. Posting Group Code",PostingGroupCode);
      InventoryPostingSetup.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137016 to show one way of using this function.

      IF Qty <= 0 THEN
        EXIT;

      Item.GET(ItemNo);
      IF NOT InventoryPostingSetup.GET(SourceLocation,Item."Inventory Posting Group") THEN
        LibraryInventory.CreateInventoryPostingSetup(InventoryPostingSetup,SourceLocation,Item."Inventory Posting Group");

      SetupLocation(Location,FALSE,FALSE,FALSE,FALSE);
      SetupLocation(Location2,FALSE,FALSE,FALSE,FALSE);
      Location2."Use As In-Transit" := TRUE;
      Location2.MODIFY(TRUE);

      CLEAR(TransferHeader);
      LibraryWarehouse.CreateTransferHeader(TransferHeader,SourceLocation,Location.Code,Location2.Code);
      LibraryWarehouse.CreateTransferLine(TransferHeader,TransferLine,ItemNo,Qty);

      IF QtyToReserve > 0 THEN BEGIN
        FullReservation := (Qty = QtyToReserve);
        ReservationManagement.SetTransferLine(TransferLine,Direction::Outbound);
        ReservationManagement.AutoReserve(FullReservation,'',TransferLine."Shipment Date",
          ROUND(QtyToReserve / TransferLine."Qty. per Unit of Measure",0.00001),QtyToReserve);
      END;
Member of Lib.Library - Inventory


CreateItem@18 Method

The procedure CreateItem is available in codeunit 132201.

Syntax

CreateItem@18(
    VAR Item@1000 : Record 27 Item //Reference parameter of type Record
);

Parameters

Item
Reference parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Item.

For a clarification about how this function works, refer to the code listed below.

      ItemNoSeriesSetup(InventorySetup);
      CLEAR(Item);
      Item.INSERT(TRUE);

      CreateItemUnitOfMeasure(ItemUnitOfMeasure,Item."No.",'',1);

      LibraryERM.FindGeneralPostingSetupInvtFull(GeneralPostingSetup);
      LibraryERM.FindVATPostingSetupInvt(VATPostingSetup);
      IF NOT InventoryPostingGroup.FINDFIRST THEN
        CreateInventoryPostingGroup(InventoryPostingGroup);

      Item.VALIDATE(Description,Item."No.");  // Validation Description as No. because value is not important.
      Item.VALIDATE("Base Unit of Measure",ItemUnitOfMeasure.Code);
      Item.VALIDATE("Gen. Prod. Posting Group",GeneralPostingSetup."Gen. Prod. Posting Group");
      Item.VALIDATE("VAT Prod. Posting Group",VATPostingSetup."VAT Prod. Posting Group");
      Item.VALIDATE("Inventory Posting Group",InventoryPostingGroup.Code);

      IF TaxGroup.FINDFIRST THEN
        Item.VALIDATE("Tax Group Code",TaxGroup.Code);

      Item.MODIFY(TRUE);
      EXIT(Item."No.");

Example

The below example is extracted from the test automation codeunit 134001 to show one way of using this function.

      FindVATPostingSetup(VATPostingSetup,VATPostingSetup."VAT Calculation Type"::"Normal VAT");
      LibraryInventory.CreateItem(Item);
      Item.VALIDATE("VAT Prod. Posting Group",VATPostingSetup."VAT Prod. Posting Group");
      Item.MODIFY(TRUE);
      EXIT(Item."No.");
Member of Lib.Library - Inventory


CreateItemBudgetEntry@9 Method

The procedure CreateItemBudgetEntry is available in codeunit 132201.

Syntax

CreateItemBudgetEntry@9(
    VAR ItemBudgetEntry@1000 : Record 7134 ItemBudgetEntry, //Reference parameter of type Record
    AnalysisArea@1001 : Option AnalysisArea, //Input parameter of type Option
    BudgetName@1002 : Code[10] BudgetName, //Input parameter of type Code
    Date@1003 : Date Date, //Input parameter of type Date
    ItemNo@1004 : Code[20] ItemNo //Input parameter of type Code
);

Parameters

ItemBudgetEntry
Reference parameter of type Record
AnalysisArea
Input parameter of type Option
BudgetName
Input parameter of type Code
Date
Input parameter of type Date
ItemNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Item, Budget, Entry.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(ItemBudgetEntry);
      ItemBudgetEntry.VALIDATE("Analysis Area",AnalysisArea);
      ItemBudgetEntry.VALIDATE("Budget Name",BudgetName);
      ItemBudgetEntry.VALIDATE(Date,Date);
      ItemBudgetEntry.VALIDATE("Item No.",ItemNo);
      ItemBudgetEntry.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134477 to show one way of using this function.

      // Test changing of the global dimensions on ItemBudgetEntry.

      // 1. Setup: Find an item, valid budget name and valid dimension value for Global Dimension 2.
      Initialize;
      LibraryInventory.CreateItem(Item);
      CreateItemWithDimension(DefaultDimension,Item."No.");
      ItemBudgetName.SETRANGE("Analysis Area",ItemBudgetName."Analysis Area"::Sales);
      ItemBudgetName.FINDFIRST;
      GeneralLedgerSetup.GET;
      LibraryDimension.FindDimensionValue(DimensionValue,GeneralLedgerSetup."Global Dimension 2 Code");

      // 2. Create a budget item entry
      LibraryInventory.CreateItemBudgetEntry(
        ItemBudgetEntry,ItemBudgetEntry."Analysis Area"::Sales,ItemBudgetName.Name,WORKDATE,Item."No.");
      ItemBudgetEntry.VALIDATE("Global Dimension 2 Code",DimensionValue.Code);
      ItemBudgetEntry.MODIFY(TRUE);

      // 3. Exercise: Change Global Dimension 2 Code on General Ledger Setup.
      GeneralLedgerSetup.GET;
      LibraryDimension.ChangeGlobalDimensions(GeneralLedgerSetup."Global Dimension 1 Code",DefaultDimension."Dimension Code");

      // 4. Verify: Verify Global Dimension 2 Code on Item Budget is empty.
      ItemBudgetEntry.GET(ItemBudgetEntry."Entry No.");
      ItemBudgetEntry.TESTFIELD("Global Dimension 2 Code",'');

      // 5. Teardown: Rollback the Default Global Dimension 2 Code on General Ledger Setup.
      ASSERTERROR ERROR(Rollback);
Member of Lib.Library - Inventory


CreateItemCategory@117 Method

The procedure CreateItemCategory is available in codeunit 132201.

Syntax

CreateItemCategory@117(
    VAR ItemCategory@1005 : Record 5722 ItemCategory //Reference parameter of type Record
);

Parameters

ItemCategory
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Item, Category.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.FindGeneralPostingSetupInvtFull(GeneralPostingSetup);
      LibraryERM.FindVATPostingSetupInvt(VATPostingSetup);
      InventoryPostingGroup.FINDFIRST;

      ItemCategory.INIT;
      ItemCategory.VALIDATE(Code,LibraryUtility.GenerateRandomCode(ItemCategory.FIELDNO(Code),DATABASE::"Item Category"));
      ItemCategory.INSERT(TRUE);
      ItemCategory.VALIDATE("Def. Gen. Prod. Posting Group",GeneralPostingSetup."Gen. Prod. Posting Group");
      ItemCategory.VALIDATE("Def. Inventory Posting Group",InventoryPostingGroup.Code );
      ItemCategory.VALIDATE("Def. VAT Prod. Posting Group",VATPostingSetup."VAT Prod. Posting Group");
      ItemCategory.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137036 to show one way of using this function.

      LibraryInventory.CreateItemCategory(ItemCategory);
      LibraryInventory.CreateItem(Item);
      Item.VALIDATE("Item Category Code",ItemCategory.Code);
      Item.MODIFY(TRUE);
      EXIT(Item."No.");
Member of Lib.Library - Inventory


CreateItemCharge@64 Method

The procedure CreateItemCharge is available in codeunit 132201.

Syntax

CreateItemCharge@64(
    VAR ItemCharge@1000 : Record 5800 ItemCharge //Reference parameter of type Record
);

Parameters

ItemCharge
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Item, Charge.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(ItemCharge);
      ItemCharge.INIT;
      ItemCharge.VALIDATE("No.",LibraryUtility.GenerateRandomCode(ItemCharge.FIELDNO("No."),DATABASE::"Item Charge"));
      ItemCharge.INSERT(TRUE);

      LibraryERM.FindGeneralPostingSetupInvtBase(GeneralPostingSetup);
      LibraryERM.FindZeroVATPostingSetup(VATPostingSetup,VATPostingSetup."VAT Calculation Type"::"Normal VAT");

      ItemCharge.VALIDATE(Description,ItemCharge."No.");  // Validation Description as No. because value is not important.
      ItemCharge.VALIDATE("Gen. Prod. Posting Group",GeneralPostingSetup."Gen. Prod. Posting Group");
      ItemCharge.VALIDATE("VAT Prod. Posting Group",VATPostingSetup."VAT Prod. Posting Group");
      ItemCharge.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134150 to show one way of using this function.

      // [FEATURE] [Purchase] [Item Charge]
      // [SCENARIO 376161] Invoice and Item Charge not suggested for Intrastat Journal in different Periods - Not Cross-Border
      Initialize;
      InvoicePostingDate := CALCDATE('<' + FORMAT(LibraryRandom.RandInt(5)) + 'Y>',WORKDATE);

      // [GIVEN] Posted Purchase Invoice in "Y" period - Not Cross-border
      CompanyInformation.GET;
      CreatePurchaseHeader(
        PurchaseHeader,PurchaseHeader."Document Type"::Order,InvoicePostingDate,
        CreateVendor(CompanyInformation."Country/Region Code"));
      CreatePurchaseLine(PurchaseHeader,PurchaseLine,PurchaseLine.Type::Item,CreateItem);
      ItemNo := PurchaseLine."No.";
      DocumentNo := LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,FALSE);

      // [GIVEN] Posted Item Charge in "F" period
      CreatePurchaseHeader(
        PurchaseHeader,PurchaseHeader."Document Type"::Invoice,CALCDATE('<1M>',InvoicePostingDate),
        PurchaseHeader."Buy-from Vendor No.");
      LibraryInventory.CreateItemCharge(ItemCharge);
      CreatePurchaseLine(PurchaseHeader,PurchaseLine,PurchaseLine.Type::"Charge (Item)",ItemCharge."No.");
      CreateItemChargeAssignmentForPurchaseCreditMemo(PurchaseLine,DocumentNo);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,FALSE);

      // [GIVEN] Intrastat Batches for "Y" and "F" period
      LibraryERM.CreateIntrastatJnlTemplateAndBatch(IntrastatJnlBatch,InvoicePostingDate);
      LibraryERM.CreateIntrastatJnlTemplateAndBatch(NextIntrastatJnlBatch,PurchaseHeader."Posting Date");
      LibraryVariableStorage.Enqueue(IntrastatJnlBatch."Journal Template Name");
      LibraryVariableStorage.Enqueue(TRUE); // Show Item Charge entries

      // [WHEN] Entries suggested to Intrastat Journal "J" and "F" with "Show item charge entries" options set to TRUE
      // [THEN] Intrastat Journal "J" contains no lines
      // [THEN] Intrastat Journal "F" contains no lines
      OpenAndVerifyIntrastatJournalLine(IntrastatJnlBatch.Name,ItemNo,FALSE);
      LibraryVariableStorage.Enqueue(NextIntrastatJnlBatch."Journal Template Name");
      LibraryVariableStorage.Enqueue(TRUE); // Show Item Charge entries
      OpenAndVerifyIntrastatJournalLine(NextIntrastatJnlBatch.Name,ItemNo,FALSE);

      IntrastatJnlBatch.DELETE(TRUE);
      NextIntrastatJnlBatch.DELETE(TRUE);
Member of Lib.Library - Inventory


CreateItemChargeAssignment@5807 Method

The procedure CreateItemChargeAssignment is available in codeunit 132201.

Syntax

CreateItemChargeAssignment@5807(
    VAR ItemChargeAssignmentSales@1001 : Record 5809 ItemChargeAssignmentSales, //Reference parameter of type Record
    SalesLine@1000 : Record 37 SalesLine, //Input parameter of type Record
    DocType@1005 : Option DocType, //Input parameter of type Option
    DocNo@1007 : Code[20] DocNo, //Input parameter of type Code
    DocLineNo@1008 : Integer DocLineNo, //Input parameter of type Integer
    ItemNo@1009 : Code[20] ItemNo //Input parameter of type Code
);

Parameters

ItemChargeAssignmentSales
Reference parameter of type Record
SalesLine
Input parameter of type Record
DocType
Input parameter of type Option
DocNo
Input parameter of type Code
DocLineNo
Input parameter of type Integer
ItemNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Item, Charge, Assignment.

For a clarification about how this function works, refer to the code listed below.

      ItemChargeAssignmentSales.INIT;

      WITH ItemChargeAssignmentSales DO BEGIN
        "Document Type" := SalesLine."Document Type";
        "Document No." := SalesLine."Document No.";
        "Document Line No." := SalesLine."Line No.";
        "Item Charge No." := SalesLine."No.";
        "Unit Cost" := SalesLine."Unit Cost";
      END;

      RecRef.GETTABLE(ItemChargeAssignmentSales);
      LineNo := LibraryUtility.GetNewLineNo(RecRef,ItemChargeAssignmentSales.FIELDNO("Line No."));
      ItemChargeAssgntSales.InsertItemChargeAssgnt(ItemChargeAssignmentSales,DocType,
        DocNo,DocLineNo,ItemNo,'',LineNo,SalesLine."Unit of Measure Code");

      ItemChargeAssignmentSales.GET(SalesLine."Document Type",SalesLine."Document No.",
        SalesLine."Line No.",LineNo);
      ItemChargeAssignmentSales.VALIDATE("Qty. to Assign",SalesLine.Quantity);
      ItemChargeAssignmentSales.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134378 to show one way of using this function.

      FindShipmentLine(SalesShipmentLine,OrderNo);
      LibraryInventory.CreateItemChargeAssignment(
        ItemChargeAssignmentSales,SalesLine,ItemChargeAssignmentSales."Applies-to Doc. Type"::Shipment,
        SalesShipmentLine."Document No.",SalesShipmentLine."Line No.",SalesShipmentLine."No.");
Member of Lib.Library - Inventory


CreateItemChargeAssignPurchase@1 Method

The procedure CreateItemChargeAssignPurchase is available in codeunit 132201.

Syntax

CreateItemChargeAssignPurchase@1(
    VAR ItemChargeAssignmentPurch@1001 : Record 5805 ItemChargeAssignmentPurch, //Reference parameter of type Record
    PurchaseLine@1000 : Record 39 PurchaseLine, //Input parameter of type Record
    DocType@1005 : Option DocType, //Input parameter of type Option
    DocNo@1007 : Code[20] DocNo, //Input parameter of type Code
    DocLineNo@1008 : Integer DocLineNo, //Input parameter of type Integer
    ItemNo@1009 : Code[20] ItemNo //Input parameter of type Code
);

Parameters

ItemChargeAssignmentPurch
Reference parameter of type Record
PurchaseLine
Input parameter of type Record
DocType
Input parameter of type Option
DocNo
Input parameter of type Code
DocLineNo
Input parameter of type Integer
ItemNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Item, Charge, Assign, Purchase.

For a clarification about how this function works, refer to the code listed below.

      ItemChargeAssignmentPurch.INIT;

      WITH ItemChargeAssignmentPurch DO BEGIN
        "Document Type" := PurchaseLine."Document Type";
        "Document No." := PurchaseLine."Document No.";
        "Document Line No." := PurchaseLine."Line No.";
        "Item Charge No." := PurchaseLine."No.";
        "Unit Cost" := PurchaseLine."Unit Cost";
      END;

      RecRef.GETTABLE(ItemChargeAssignmentPurch);
      LineNo := LibraryUtility.GetNewLineNo(RecRef,ItemChargeAssignmentPurch.FIELDNO("Line No."));
      ItemChargeAssgntPurch.InsertItemChargeAssgnt(
        ItemChargeAssignmentPurch,DocType,DocNo,DocLineNo,ItemNo,'',LineNo,PurchaseLine."Unit of Measure Code");

      ItemChargeAssignmentPurch.GET(PurchaseLine."Document Type",PurchaseLine."Document No.",PurchaseLine."Line No.",LineNo);
      ItemChargeAssignmentPurch.VALIDATE("Qty. to Assign",PurchaseLine.Quantity);
      ItemChargeAssignmentPurch.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134327 to show one way of using this function.

      FindRcptLine(PurchRcptLine,OrderNo);
      LibraryInventory.CreateItemChargeAssignPurchase(
        ItemChargeAssignmentPurch,PurchLine,ItemChargeAssignmentPurch."Applies-to Doc. Type"::Receipt,
        PurchRcptLine."Document No.",PurchRcptLine."Line No.",PurchRcptLine."No.");
Member of Lib.Library - Inventory


CreateItemChargeNo@2 Method

The procedure CreateItemChargeNo is available in codeunit 132201.

Syntax

CreateItemChargeNo@2(
      //param element not supplied
);

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Item, Charge, No.

For a clarification about how this function works, refer to the code listed below.

      CreateItemCharge(ItemCharge);
      EXIT(ItemCharge."No.")

Example

The below example is extracted from the test automation codeunit 137068 to show one way of using this function.

      // [FEATURE] [Item Charge] [Costing]
      // [SCENARIO 376009] Value entry Amounts for Posted Purchase Invoice equal to line Amounts when they are changed after shipping.

      // [GIVEN] Purchase Order with 2 lines: 1 - Item and 2 - negative Item Charge, assigned to Item, shipped.
      Initialize;
      LibraryPurchase.CreatePurchHeader(
        PurchaseHeader,PurchaseHeader."Document Type"::Order,LibraryPurchase.CreateVendorNo);
      ItemNo := LibraryInventory.CreateItemNo;
      CreatePurchaseLine(
        PurchaseHeader,ItemNo,PurchaseLine.Type::Item,'',
        LibraryRandom.RandDecInRange(5,10,2),LibraryRandom.RandDecInRange(100,200,2));
      ItemChargeNo := LibraryInventory.CreateItemChargeNo;
      ChargeQty := -1; // Specific value needed for test
      CreatePurchaseLine(
        PurchaseHeader,ItemChargeNo,PurchaseLine.Type::"Charge (Item)",'',ChargeQty,
        LibraryRandom.RandDecInRange(10,20,2));
      AssignItemCharge(PurchaseHeader);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,FALSE);

      // [GIVEN] Reopen Purchase Order, Change Line Amounts for both lines.
      LibraryPurchase.ReopenPurchaseDocument(PurchaseHeader);
      AmountSum := UpdateLineAmounts(PurchaseHeader,LibraryRandom.RandDecInRange(10,20,2));

      // [WHEN] Invoice Purchase Order.
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,FALSE,TRUE);

      // [THEN] Value Entry Amounts contain last changed Amounts.
      VerifyCostAmountActualSum(ItemNo,AmountSum);
Member of Lib.Library - Inventory


CreateItemCrossReference@121 Method

The procedure CreateItemCrossReference is available in codeunit 132201.

Syntax

CreateItemCrossReference@121(
    VAR ItemCrossReference@1000 : Record 5717 ItemCrossReference, //Reference parameter of type Record
    ItemNo@1001 : Code[20] ItemNo, //Input parameter of type Code
    CrossReferenceType@1002 : Option CrossReferenceType, //Input parameter of type Option
    CrossReferenceTypeNo@1003 : Code[30] CrossReferenceTypeNo //Input parameter of type Code
);

Parameters

ItemCrossReference
Reference parameter of type Record
ItemNo
Input parameter of type Code
CrossReferenceType
Input parameter of type Option
CrossReferenceTypeNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Item, Cross, Reference.

For a clarification about how this function works, refer to the code listed below.

      ItemCrossReference.INIT;
      ItemCrossReference.VALIDATE("Item No.",ItemNo);
      ItemCrossReference.VALIDATE("Cross-Reference Type",CrossReferenceType);
      ItemCrossReference.VALIDATE("Cross-Reference Type No.",CrossReferenceTypeNo);
      ItemCrossReference.VALIDATE(
        "Cross-Reference No.",LibraryUtility.GenerateRandomCode(ItemCrossReference.FIELDNO("Cross-Reference No."),
          DATABASE::"Item Cross Reference"));
      ItemCrossReference.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136312 to show one way of using this function.

      // [FEATURE] [Requisition Worksheet] [Item Cross Reference]
      // [SCENARIO 378246] "Description 2" in Requisition Line should be empty when vendor with Item Cross Reference is selected in "Vendor No."

      // [GIVEN] Create Item with filled "Description 2" field
      LibraryInventory.CreateItem(Item);
      Item.VALIDATE("Description 2",LibraryUtility.GenerateGUID);
      Item.MODIFY(TRUE);

      // [GIVEN] Create Vendor
      LibraryPurchase.CreateVendor(Vendor);

      // [GIVEN] Create Requisition Line with filled "Description 2" field
      CreateRequisitionWorksheetline(RequisitionLine,Item."No.",'');
      RequisitionLine.VALIDATE("Description 2",LibraryUtility.GenerateGUID);
      RequisitionLine.MODIFY(TRUE);

      // [GIVEN] Generate Item Cross Reference with Description = "X"
      LibraryInventory.CreateItemCrossReference(
        ItemCrossReference,Item."No.",ItemCrossReference."Cross-Reference Type"::Vendor,Vendor."No.");
      ItemCrossReference.VALIDATE(Description,LibraryUtility.GenerateGUID);
      ItemCrossReference.MODIFY(TRUE);

      // [GIVEN] Open Requisition Worksheet Page with Requisition Line inside
      OpenRequisitionWorksheetPage(ReqWorksheet,RequisitionLine."Journal Batch Name");

      // [WHEN] Set "Vendor No." in Requisition Line
      ReqWorksheet."Vendor No.".SETVALUE(Vendor."No.");

      RequisitionLine.FIND;

      // [THEN] "Description" in Requisition Line should be same as in ItemCrossReference
      Assert.AreEqual(ItemCrossReference.Description,RequisitionLine.Description,DescriptionItemRefErr);

      // [THEN] "Description 2" in Requisition Line should be empty
      Assert.AreEqual('',RequisitionLine."Description 2",DescriptionEmptyErr);
Member of Lib.Library - Inventory


CreateItemJnlLineWithNoItem@180 Method

The procedure CreateItemJnlLineWithNoItem is available in codeunit 132201.

Syntax

CreateItemJnlLineWithNoItem@180(
    VAR ItemJournalLine@1000 : Record 83 ItemJournalLine, //Reference parameter of type Record
    ItemJournalBatch@1008 : Record 233 ItemJournalBatch, //Input parameter of type Record
    JournalTemplateName@1002 : Code[10] JournalTemplateName, //Input parameter of type Code
    JournalBatchName@1001 : Code[10] JournalBatchName, //Input parameter of type Code
    EntryType@1006 : Option EntryType //Input parameter of type Option
);

Parameters

ItemJournalLine
Reference parameter of type Record
ItemJournalBatch
Input parameter of type Record
JournalTemplateName
Input parameter of type Code
JournalBatchName
Input parameter of type Code
EntryType
Input parameter of type Option

Remarks

The relevant search keywords are: Create, Item, Journal, Line, No, Item.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(ItemJournalLine);
      ItemJournalLine.INIT;
      ItemJournalLine.VALIDATE("Journal Template Name",JournalTemplateName);
      ItemJournalLine.VALIDATE("Journal Batch Name",JournalBatchName);
      RecRef.GETTABLE(ItemJournalLine);
      ItemJournalLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,ItemJournalLine.FIELDNO("Line No.")));
      ItemJournalLine.INSERT(TRUE);
      ItemJournalLine.VALIDATE("Posting Date",WORKDATE);
      ItemJournalLine.VALIDATE("Entry Type",EntryType);
      IF NoSeries.GET(ItemJournalBatch."No. Series") THEN
        DocumentNo := NoSeriesManagement.GetNextNo(ItemJournalBatch."No. Series",ItemJournalLine."Posting Date",FALSE)
      ELSE
        DocumentNo := LibraryUtility.GenerateRandomCode(ItemJournalLine.FIELDNO("Document No."),DATABASE::"Item Journal Line");
      ItemJournalLine.VALIDATE("Document No.",DocumentNo);
      ItemJournalLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 136310 to show one way of using this function.

      ClearRevaluationJournalLines(ItemJournalBatch);
      LibraryInventory.CreateItemJnlLineWithNoItem(
        ItemJournalLine,ItemJournalBatch,ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name,
        ItemJournalLine."Entry Type"::" ");
      ItemJournalLine.VALIDATE("Item No.",ItemNo);
      ItemJournalLine.VALIDATE("Value Entry Type",ItemJournalLine."Value Entry Type"::Revaluation);
      ItemJournalLine.VALIDATE(Quantity,1);  // Taking Quantity as 1 to avoid test Failure, Value is not important as it gets overridden by Applied Quantity after Application.
      ItemJournalLine.VALIDATE("Applies-to Entry",AppliesToEntry);
      ItemJournalLine.MODIFY(TRUE);
Member of Lib.Library - Inventory


CreateItemJournal@55 Method

The procedure CreateItemJournal is available in codeunit 132201.

Syntax

CreateItemJournal@55(
    VAR ItemJournalBatch@1001 : Record 233 ItemJournalBatch, //Reference parameter of type Record
    ItemNo@1002 : Code[20] ItemNo, //Input parameter of type Code
    ItemJournalTemplateType@1003 : Option ItemJournalTemplateType, //Input parameter of type Option
    ProductionOrderNo@1004 : Code[20] ProductionOrderNo //Input parameter of type Code
);

Parameters

ItemJournalBatch
Reference parameter of type Record
ItemNo
Input parameter of type Code
ItemJournalTemplateType
Input parameter of type Option
ProductionOrderNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Item, Journal.

For a clarification about how this function works, refer to the code listed below.

      // Create Journals for Consumption and Output.
      SelectItemJournalTemplateName(ItemJournalTemplate,ItemJournalTemplateType);
      SelectItemJournalBatchName(ItemJournalBatch,ItemJournalTemplateType,ItemJournalTemplate.Name);
      IF ItemJournalTemplateType = ItemJournalTemplateType::Consumption THEN
        LibraryManufacturing.CalculateConsumption(ProductionOrderNo,ItemJournalTemplate.Name,ItemJournalBatch.Name)
      ELSE BEGIN
        LibraryManufacturing.CreateOutputJournal(ItemJournalLine,ItemJournalTemplate,ItemJournalBatch,ItemNo,ProductionOrderNo);
        OutputJnlExplRoute(ItemJournalLine);
        LibraryManufacturing.UpdateOutputJournal(ProductionOrderNo);
      END;

Example

The below example is extracted from the test automation codeunit 137003 to show one way of using this function.

      // 1. Setup: Required Costing Setups.
      // Create, Calculate and Post Consumption Journal and Explode Routing and Post Output Journal.
      CreateCostingSetup(
        PurchaseHeader,ProductionOrderNo,ItemNo,ItemNo2,AutoCostPosting,FlushingMethod,CostingMethod,
        TRUE,TRUE,FALSE,FALSE,FALSE,FALSE,FALSE);
      IF FlushingMethod = FlushingMethod::Manual THEN BEGIN
        LibraryInventory.CreateItemJournal(ItemJournalBatch,ItemNo2,ItemJournalBatch."Template Type"::Consumption,ProductionOrderNo);
        LibraryInventory.PostItemJournalLine(ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name);
        LibraryInventory.CreateItemJournal(ItemJournalBatch,ItemNo2,ItemJournalBatch."Template Type"::Output,ProductionOrderNo);
        LibraryInventory.PostItemJournalLine(ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name);
      END;
      ProductionOrder.GET(ProductionOrder.Status::Released,ProductionOrderNo);

      // 2. Exercise: Change Status of Production Order to Finished.
      // Run Adjust Cost Item Entries report and Post Inventory Cost to G/L report.
      LibraryManufacturing.ChangeStatusReleasedToFinished(ProductionOrderNo);
      LibraryCosting.AdjustCostItemEntries(ItemNo + '..' + ItemNo2,'');
      LibraryCosting.PostInvtCostToGL(FALSE,WORKDATE,'');

      // 3. Verify: Verify WIP Account General Ledger Entries for Total amount and Positive amount entries.
      VerifyWIPAmountGLEntry(ProductionOrder,ItemNo,TRUE);
Member of Lib.Library - Inventory


CreateItemJournalBatch@52 Method

The procedure CreateItemJournalBatch is available in codeunit 132201.

Syntax

CreateItemJournalBatch@52(
    VAR ItemJournalBatch@1000 : Record 233 ItemJournalBatch, //Reference parameter of type Record
    ItemJournalTemplateName@1001 : Code[10] ItemJournalTemplateName //Input parameter of type Code
);

Parameters

ItemJournalBatch
Reference parameter of type Record
ItemJournalTemplateName
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Item, Journal, Batch.

For a clarification about how this function works, refer to the code listed below.

      // Create Item Journal Batch with a random Name of String length less than 10.
      ItemJournalBatch.INIT;
      ItemJournalBatch.VALIDATE("Journal Template Name",ItemJournalTemplateName);
      ItemJournalBatch.VALIDATE(
        Name,COPYSTR(LibraryUtility.GenerateRandomCode(ItemJournalBatch.FIELDNO(Name),DATABASE::"Item Journal Batch"),1,
          MAXSTRLEN(ItemJournalBatch.Name)));
      ItemJournalBatch.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134386 to show one way of using this function.

      ItemJournalTemplate.SETRANGE(Recurring,FALSE);
      ItemJournalTemplate.SETRANGE(Type,ItemJournalTemplate.Type::Item);
      LibraryInventory.FindItemJournalTemplate(ItemJournalTemplate);
      LibraryInventory.CreateItemJournalBatch(ItemJournalBatch,ItemJournalTemplate.Name);
Member of Lib.Library - Inventory


CreateItemJournalBatchByType@4 Method

The procedure CreateItemJournalBatchByType is available in codeunit 132201.

Syntax

CreateItemJournalBatchByType@4(
    VAR ItemJournalBatch@1000 : Record 233 ItemJournalBatch, //Reference parameter of type Record
    TemplateType@1002 : Option TemplateType //Input parameter of type Option
);

Parameters

ItemJournalBatch
Reference parameter of type Record
TemplateType
Input parameter of type Option

Remarks

The relevant search keywords are: Create, Item, Journal, Batch, By, Type.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(ItemJournalBatch);
      ItemJournalTemplate.SETRANGE(Type,TemplateType);
      ItemJournalTemplate.SETRANGE(Recurring,FALSE);
      ItemJournalTemplate.FINDFIRST;
      ItemJournalBatch."Journal Template Name" := ItemJournalTemplate.Name;
      ItemJournalBatch.Name := LibraryUtility.GenerateRandomCode(ItemJournalBatch.FIELDNO(Name),DATABASE::"Item Journal Batch");
      ItemJournalBatch.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137007 to show one way of using this function.

      LibraryInventory.CreateItemJournalBatchByType(ItemJournalBatch,ItemJournalBatch."Template Type"::Transfer);
      LibraryInventory.CreateItemJournalLine(
        ItemJournalLine,ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name,
        ItemJournalLine."Entry Type"::Transfer,ItemNo,Quantity);
      ItemJournalLine.VALIDATE("Location Code",FromLocationCode);
      ItemJournalLine.VALIDATE("New Location Code",ToLocationCode);
      ItemJournalLine.MODIFY(TRUE);

      LibraryInventory.PostItemJournalLine(ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name);
Member of Lib.Library - Inventory


CreateItemJournalLine@34 Method

The procedure CreateItemJournalLine is available in codeunit 132201.

Syntax

CreateItemJournalLine@34(
    VAR ItemJournalLine@1000 : Record 83 ItemJournalLine, //Reference parameter of type Record
    JournalTemplateName@1001 : Code[10] JournalTemplateName, //Input parameter of type Code
    JournalBatchName@1002 : Code[10] JournalBatchName, //Input parameter of type Code
    EntryType@1007 : Option EntryType, //Input parameter of type Option
    ItemNo@1005 : Text[20] ItemNo, //Input parameter of type Text
    NewQuantity@1004 : Decimal NewQuantity //Input parameter of type Decimal
);

Parameters

ItemJournalLine
Reference parameter of type Record
JournalTemplateName
Input parameter of type Code
JournalBatchName
Input parameter of type Code
EntryType
Input parameter of type Option
ItemNo
Input parameter of type Text
NewQuantity
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Item, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      IF NOT ItemJournalBatch.GET(JournalTemplateName,JournalBatchName) THEN BEGIN
        ItemJournalBatch.INIT;
        ItemJournalBatch.VALIDATE("Journal Template Name",JournalTemplateName);
        ItemJournalBatch.SetupNewBatch;
        ItemJournalBatch.VALIDATE(Name,JournalBatchName);
        ItemJournalBatch.VALIDATE(Description,JournalBatchName + JOURNAL);
        ItemJournalBatch.INSERT(TRUE);
      END;
      CreateItemJnlLineWithNoItem(ItemJournalLine,ItemJournalBatch,JournalTemplateName,JournalBatchName,EntryType);
      ItemJournalLine.VALIDATE("Item No.",ItemNo);
      ItemJournalLine.VALIDATE(Quantity,NewQuantity);
      ItemJournalLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134063 to show one way of using this function.

      SelectItemJournalBatch(ItemJournalBatch);
      LibraryInventory.CreateItemJournalLine(
        ItemJournalLine,ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name,EntryType,ItemNo,
        LibraryRandom.RandDec(100,2) * 100);
      ItemJournalLine.VALIDATE("Transaction Type",TransactionType);
      ItemJournalLine.VALIDATE("Transport Method",TransportMethod);
      ItemJournalLine.VALIDATE("Country/Region Code",CountryRegionCode);
      ItemJournalLine.MODIFY(TRUE);
      LibraryInventory.PostItemJournalLine(ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name);
Member of Lib.Library - Inventory


CreateItemJournalLineInItemTemplate@27 Method

The procedure CreateItemJournalLineInItemTemplate is available in codeunit 132201.

Syntax

CreateItemJournalLineInItemTemplate@27(
    VAR ItemJournalLine@1002 : Record 83 ItemJournalLine, //Reference parameter of type Record
    ItemNo@1003 : Code[20] ItemNo, //Input parameter of type Code
    LocationCode@1004 : Code[10] LocationCode, //Input parameter of type Code
    BinCode@1005 : Code[20] BinCode, //Input parameter of type Code
    Qty@1006 : Decimal Qty //Input parameter of type Decimal
);

Parameters

ItemJournalLine
Reference parameter of type Record
ItemNo
Input parameter of type Code
LocationCode
Input parameter of type Code
BinCode
Input parameter of type Code
Qty
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Item, Journal, Line, In, Item, Template.

For a clarification about how this function works, refer to the code listed below.

      SelectItemJournalTemplateName(ItemJournalTemplate,ItemJournalTemplate.Type::Item);
      SelectItemJournalBatchName(ItemJournalBatch,ItemJournalTemplate.Type::Item,ItemJournalTemplate.Name);
      CreateItemJournalLine(
        ItemJournalLine,ItemJournalTemplate.Name,ItemJournalBatch.Name,ItemJournalLine."Entry Type"::"Positive Adjmt.",ItemNo,Qty);
      ItemJournalLine.VALIDATE("Location Code",LocationCode);
      ItemJournalLine.VALIDATE("Bin Code",BinCode);
      ItemJournalLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 136135 to show one way of using this function.

      LibraryInventory.CreateItemJournalLineInItemTemplate(ItemJournalLine,Item."No.",LocationCode,BinCode,Quantity);
      LibraryInventory.PostItemJournalLine(ItemJournalLine."Journal Template Name",ItemJournalLine."Journal Batch Name");
Member of Lib.Library - Inventory


CreateItemJournalTemplate@68 Method

The procedure CreateItemJournalTemplate is available in codeunit 132201.

Syntax

CreateItemJournalTemplate@68(
    VAR ItemJournalTemplate@1000 : Record 82 ItemJournalTemplate //Reference parameter of type Record
);

Parameters

ItemJournalTemplate
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Item, Journal, Template.

For a clarification about how this function works, refer to the code listed below.

      ItemJournalTemplate.INIT;
      ItemJournalTemplate.VALIDATE(
        Name,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(ItemJournalTemplate.FIELDNO(Name),DATABASE::"Item Journal Template"),
          1,
          LibraryUtility.GetFieldLength(DATABASE::"Item Journal Template",ItemJournalTemplate.FIELDNO(Name))));
      ItemJournalTemplate.VALIDATE(Description,ItemJournalTemplate.Name);
      // Validating Name as Description because value is not important.
      ItemJournalTemplate.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136310 to show one way of using this function.

      LibraryInventory.CreateItemJournalTemplate(ItemJournalTemplate);
      LibraryInventory.CreateItemJournalBatch(ItemJournalBatch,ItemJournalTemplate.Name);
      LibraryInventory.CreateItemJournalLine(
        ItemJournalLine,ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name,
        ItemJournalLine."Entry Type"::"Positive Adjmt.",ItemNo,Qty);
      ItemJournalLine.VALIDATE("Unit Cost",UnitCost);
      ItemJournalLine.MODIFY(TRUE);
      LibraryInventory.PostItemJournalLine(ItemJournalLine."Journal Template Name",ItemJournalLine."Journal Batch Name");
Member of Lib.Library - Inventory


CreateItemManufacturing@8 Method

The procedure CreateItemManufacturing is available in codeunit 132201.

Syntax

CreateItemManufacturing@8(
    VAR Item@1000 : Record 27 Item //Reference parameter of type Record
);

Parameters

Item
Reference parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Item, Manufacturing.

For a clarification about how this function works, refer to the code listed below.

      ItemNoSeriesSetup(InventorySetup);
      CLEAR(Item);
      Item.INSERT(TRUE);

      CreateItemUnitOfMeasure(ItemUnitOfMeasure,Item."No.",'',1);

      LibraryERM.FindGeneralPostingSetupInvtToGL(GeneralPostingSetup);
      LibraryERM.FindVATPostingSetupInvt(VATPostingSetup);
      InventoryPostingGroup.FINDFIRST;

      Item.VALIDATE(Description,Item."No.");  // Validation Description as No. because value is not important.
      Item.VALIDATE("Base Unit of Measure",ItemUnitOfMeasure.Code);
      Item.VALIDATE("Gen. Prod. Posting Group",GeneralPostingSetup."Gen. Prod. Posting Group");
      Item.VALIDATE("VAT Prod. Posting Group",VATPostingSetup."VAT Prod. Posting Group");
      Item.VALIDATE("Inventory Posting Group",InventoryPostingGroup.Code);

      IF TaxGroup.FINDFIRST THEN
        Item.VALIDATE("Tax Group Code",TaxGroup.Code);

      Item.MODIFY(TRUE);
      EXIT(Item."No.");

Example

The below example is extracted from the test automation codeunit 137002 to show one way of using this function.

      LibraryManufacturing.CreateItemManufacturing(
        Item,ItemCostingMethod,RANDOM(10),Item."Reordering Policy"::"Lot-for-Lot",FlushingMethod::Manual,'','');
      EXIT(Item."No.");
Member of Lib.Library - Inventory


CreateItemNo@71 Method

The procedure CreateItemNo is available in codeunit 132201.

Syntax

CreateItemNo@71(
      //param element not supplied
);

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Item, No.

For a clarification about how this function works, refer to the code listed below.

      CreateItem(Item);
      EXIT(Item."No.");

Example

The below example is extracted from the test automation codeunit 134103 to show one way of using this function.

      // Create Sales Order with two prepayment lines
      LibraryERM.FindVATPostingSetup(VATPostingSetup,VATPostingSetup."VAT Calculation Type"::"Normal VAT");
      ItemNo := LibraryInventory.CreateItemNo;
      CurrencyCode := CreateCurrency;
      CreateExchangeRate(CurrencyCode,WORKDATE);
      LibrarySales.CreateSalesHeader(
        SalesHeader,SalesHeader."Document Type"::Order,
        CreateCustWithCurrencyAndVATBusPostingGroup(CurrencyCode,VATPostingSetup."VAT Bus. Posting Group"));
      CreateSalesLineWithPrepmtPercentage(SalesLine,SalesHeader,ItemNo,LibraryRandom.RandIntInRange(10,40));
      CreateSalesLineWithPrepmtPercentage(SalesLine,SalesHeader,ItemNo,SalesLine."Prepayment %" + LibraryRandom.RandIntInRange(10,40));

      // Update Sales Prepayment Account
      GeneralPostingSetup.GET(SalesLine."Gen. Bus. Posting Group",SalesLine."Gen. Prod. Posting Group");
      OldSalesPrepaymentsAccountNo := GeneralPostingSetup."Sales Prepayments Account";
      GeneralPostingSetup.VALIDATE("Sales Prepayments Account",
        CreateBalanceSheetAccount(
          SalesLine."Gen. Bus. Posting Group",SalesLine."Gen. Prod. Posting Group",VATPostingSetup."VAT Prod. Posting Group"));
      GeneralPostingSetup.MODIFY(TRUE);
Member of Lib.Library - Inventory


CreateItemNoWithPostingSetup@21 Method

The procedure CreateItemNoWithPostingSetup is available in codeunit 132201.

Syntax

CreateItemNoWithPostingSetup@21(
    GenProdPostingGroup@1002 : Code[10] GenProdPostingGroup, //Input parameter of type Code
    VATProductPostingGroup@1001 : Code[10] VATProductPostingGroup //Input parameter of type Code
);

Parameters

GenProdPostingGroup
Input parameter of type Code
VATProductPostingGroup
Input parameter of type Code

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Item, No, Posting, Setup.

For a clarification about how this function works, refer to the code listed below.

      CreateItemWithPostingSetup(Item,GenProdPostingGroup,VATProductPostingGroup);
      EXIT(Item."No.");

Example

The below example is extracted from the test automation codeunit 134106 to show one way of using this function.

      CreateVATPostingSetup(VATPostingSetup,VATRate);
      CreateGeneralPostingSetup(GeneralPostingSetup);
      VendorNo :=
        LibraryPurchase.CreateVendorWithBusPostingGroups(
          GeneralPostingSetup."Gen. Bus. Posting Group",VATPostingSetup."VAT Bus. Posting Group");

      FOR i := 1 TO ARRAYLEN(ItemNo) DO
        ItemNo[i] :=
          LibraryInventory.CreateItemNoWithPostingSetup(
            GeneralPostingSetup."Gen. Prod. Posting Group",VATPostingSetup."VAT Prod. Posting Group");

      UpdatePurchasePrepmtAccount(
        CreateGLAccountWithGivenSetup(VATPostingSetup,GeneralPostingSetup),
        GeneralPostingSetup."Gen. Bus. Posting Group",GeneralPostingSetup."Gen. Prod. Posting Group");
Member of Lib.Library - Inventory


CreateItemNoWithVATProdPostingGroup@66 Method

The procedure CreateItemNoWithVATProdPostingGroup is available in codeunit 132201.

Syntax

CreateItemNoWithVATProdPostingGroup@66(
    VATProdPostGroupCode@1001 : Code[10] VATProdPostGroupCode //Input parameter of type Code
);

Parameters

VATProdPostGroupCode
Input parameter of type Code

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Item, No, VAT, Product, Posting, Group.

For a clarification about how this function works, refer to the code listed below.

      CreateItem(Item);
      Item.VALIDATE("VAT Prod. Posting Group",VATProdPostGroupCode);
      Item.MODIFY(TRUE);
      EXIT(Item."No.");

Example

There are no examples available.
Member of Lib.Library - Inventory


CreateItemTrackingCode@36 Method

The procedure CreateItemTrackingCode is available in codeunit 132201.

Syntax

CreateItemTrackingCode@36(
    VAR ItemTrackingCode@1000 : Record 6502 ItemTrackingCode //Reference parameter of type Record
);

Parameters

ItemTrackingCode
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Item, Tracking, Code.

For a clarification about how this function works, refer to the code listed below.

      ItemTrackingCode.INIT;
      ItemTrackingCode.VALIDATE(Code,LibraryUtility.GenerateRandomCode(ItemTrackingCode.FIELDNO(Code),DATABASE::"Item Tracking Code"));
      ItemTrackingCode.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134329 to show one way of using this function.

      LibraryItemTracking.CreateItemTrackingCode(ItemTrackingCode,FALSE,FALSE);
      EXIT(ItemTrackingCode.Code);
Member of Lib.Library - Inventory


CreateItemUnitOfMeasure@20 Method

The procedure CreateItemUnitOfMeasure is available in codeunit 132201.

Syntax

CreateItemUnitOfMeasure@20(
    VAR ItemUnitOfMeasure@1001 : Record 5404 ItemUnitOfMeasure, //Reference parameter of type Record
    ItemNo@1000 : Code[20] ItemNo, //Input parameter of type Code
    UnitOfMeasureCode@1002 : Code[10] UnitOfMeasureCode, //Input parameter of type Code
    QtyPerUoM@1004 : Decimal QtyPerUoM //Input parameter of type Decimal
);

Parameters

ItemUnitOfMeasure
Reference parameter of type Record
ItemNo
Input parameter of type Code
UnitOfMeasureCode
Input parameter of type Code
QtyPerUoM
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Item, Unit, Of, Measure.

For a clarification about how this function works, refer to the code listed below.

      ItemUnitOfMeasure.INIT;
      ItemUnitOfMeasure.VALIDATE("Item No.",ItemNo);

      // The IF condition is important because it grants flexibility to the function.
      IF UnitOfMeasureCode = '' THEN BEGIN
        UnitOfMeasure.SETFILTER(Code,'<>%1',UnitOfMeasureCode);
        UnitOfMeasure.FINDFIRST;
        ItemUnitOfMeasure.VALIDATE(Code,UnitOfMeasure.Code);
      END ELSE
        ItemUnitOfMeasure.VALIDATE(Code,UnitOfMeasureCode);
      IF QtyPerUoM = 0 THEN
        QtyPerUoM := 1;
      ItemUnitOfMeasure.VALIDATE("Qty. per Unit of Measure",QtyPerUoM);
      ItemUnitOfMeasure.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136306 to show one way of using this function.

      UnitOfMeasure.SETFILTER(Code,'<>%1',Item."Base Unit of Measure");
      UnitOfMeasure.FINDFIRST;
      LibraryInventory.CreateItemUnitOfMeasure(ItemUnitOfMeasure,Item."No.",UnitOfMeasure.Code,LibraryRandom.RandIntInRange(2,10));
      EXIT(ItemUnitOfMeasure.Code);
Member of Lib.Library - Inventory


CreateItemUnitOfMeasureCode@91 Method

The procedure CreateItemUnitOfMeasureCode is available in codeunit 132201.

Syntax

CreateItemUnitOfMeasureCode@91(
    VAR ItemUnitOfMeasure@1000 : Record 5404 ItemUnitOfMeasure, //Reference parameter of type Record
    ItemNo@1001 : Code[20] ItemNo, //Input parameter of type Code
    QtyPerUoM@1002 : Decimal QtyPerUoM //Input parameter of type Decimal
);

Parameters

ItemUnitOfMeasure
Reference parameter of type Record
ItemNo
Input parameter of type Code
QtyPerUoM
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Item, Unit, Of, Measure, Code.

For a clarification about how this function works, refer to the code listed below.

      CreateUnitOfMeasureCode(UnitOfMeasure);
      CreateItemUnitOfMeasure(ItemUnitOfMeasure,ItemNo,UnitOfMeasure.Code,QtyPerUoM);

Example

The below example is extracted from the test automation codeunit 134326 to show one way of using this function.

      // [SCENARIO 362692] Fields "Location Code", "Unit of Measure", "Direct Unit Cost", "Line Discount %" are copied from Blanket Order to Purchase Order when Blanket Order and Line set manually
      Initialize;
      ItemNo := LibraryInventory.CreateItemNo;
      LibraryInventory.CreateItemUnitOfMeasureCode(ItemUnitOfMeasure,ItemNo,1);
      LibraryWarehouse.CreateLocation(Location);

      // [GIVEN] Purchase Blanket Order for item "X"
      CreatePurchaseBlanketOrder(PurchaseHeaderBlanket,PurchaseLineBlanket,1,LibraryPurchase.CreateVendorNo,ItemNo); // 1 line is enough for test
      PurchaseLineBlanket.VALIDATE("Location Code",Location.Code);
      PurchaseLineBlanket.VALIDATE("Unit of Measure Code",ItemUnitOfMeasure.Code);
      PurchaseLineBlanket.VALIDATE("Direct Unit Cost",LibraryRandom.RandDec(100,2));
      PurchaseLineBlanket.VALIDATE("Line Discount %",LibraryRandom.RandDec(100,2));
      PurchaseLineBlanket.MODIFY(TRUE);

      // [GIVEN] Purchase Order with a line for the item "X"
      LibraryPurchase.CreatePurchHeader(
        PurchaseHeader,PurchaseHeader."Document Type"::Order,PurchaseHeaderBlanket."Buy-from Vendor No.");
      LibraryPurchase.CreatePurchaseLine(
        PurchaseLine,PurchaseHeader,PurchaseLine.Type::Item,PurchaseLineBlanket."No.",PurchaseLineBlanket.Quantity);

      // [WHEN] "Blanket Order Line No." is set manually
      UpdatePurchaseLineWithBlanketOrder(
        PurchaseLine,PurchaseHeaderBlanket."No.",PurchaseLineBlanket."Line No.");

      // [THEN] Fields "Location Code", "Unit of Measure", "Direct Unit Cost", "Line Discount %", "Line Discount Amount" are copied from Blanket Order Line
      WITH PurchaseLine DO BEGIN
        Assert.AreEqual(
          PurchaseLineBlanket."Location Code","Location Code",FIELDCAPTION("Location Code"));
        Assert.AreEqual(
          PurchaseLineBlanket."Unit of Measure","Unit of Measure",FIELDCAPTION("Unit of Measure"));
        Assert.AreEqual(
          PurchaseLineBlanket."Direct Unit Cost","Direct Unit Cost",FIELDCAPTION("Direct Unit Cost"));
        Assert.AreEqual(
          PurchaseLineBlanket."Line Discount %","Line Discount %",FIELDCAPTION("Line Discount %"));
        Assert.AreEqual(
          PurchaseLineBlanket."Line Discount Amount","Line Discount Amount",FIELDCAPTION("Line Discount Amount"));
      END;
Member of Lib.Library - Inventory


CreateItemVariant@122 Method

The procedure CreateItemVariant is available in codeunit 132201.

Syntax

CreateItemVariant@122(
    VAR ItemVariant@1000 : Record 5401 ItemVariant, //Reference parameter of type Record
    ItemNo@1001 : Code[20] ItemNo //Input parameter of type Code
);

Parameters

ItemVariant
Reference parameter of type Record
ItemNo
Input parameter of type Code

Return Value

Code[10]

Remarks

The relevant search keywords are: Create, Item, Variant.

For a clarification about how this function works, refer to the code listed below.

      ItemVariant.INIT;
      ItemVariant.VALIDATE("Item No.",ItemNo);
      ItemVariant.VALIDATE(Code,LibraryUtility.GenerateRandomCode(ItemVariant.FIELDNO(Code),DATABASE::"Item Variant"));
      ItemVariant.VALIDATE(Description,ItemVariant.Code);
      ItemVariant.INSERT(TRUE);
      EXIT(ItemVariant.Code)

Example

The below example is extracted from the test automation codeunit 134152 to show one way of using this function.

      // [SCENARIO 120301.3] Verify IC Partner is updated with Item info when validate Sales Line's Variant Code which is not in CrossRef setup
      Initialize;

      // [GIVEN] Sales Order with Sell-to IC Partner which has "Outbound Sales Item No. Type"="Internal No."
      LibrarySales.CreateSalesHeader(
        SalesHeader,SalesHeader."Document Type"::Order,CreateICCustomer(CreateICPartner));
      LibrarySales.CreateSalesLine(SalesLine,SalesHeader,SalesLine.Type::Item,CreateItem,LibraryRandom.RandInt(10));

      // [GIVEN] Variant Code "VAR1" for the Item "I" with CrossRef setup
      ItemCrossReference.SETRANGE(
        "Cross-Reference No.",
        CreateItemCrossRefWithVariant(SalesLine."No.",SalesLine."Sell-to Customer No.",''));
      ItemCrossReference.FINDFIRST;

      // [GIVEN] Another Variant Code "VAR2" for item "I" without CrossRef setup
      LibraryInventory.CreateItemVariant(NewItemVariant,SalesLine."No.");

      // [WHEN] Validate Sales Line's "Variant Code"="VAR2"
      SalesLine.VALIDATE("Variant Code",NewItemVariant.Code);

      // [THEN] SalesLine's fields are: "IC Partner Ref. Type"=Item, "IC Partner Reference"="I"
      Assert.AreEqual(
        SalesLine."IC Partner Ref. Type"::Item,
        SalesLine."IC Partner Ref. Type",
        STRSUBSTNO(TableFieldErr,SalesLine.TABLECAPTION,SalesLine.FIELDCAPTION("IC Partner Ref. Type")));
      Assert.AreEqual(
        SalesLine."No.",
        SalesLine."IC Partner Reference",
        STRSUBSTNO(TableFieldErr,SalesLine.TABLECAPTION,SalesLine.FIELDCAPTION("IC Partner Reference")));
Member of Lib.Library - Inventory


CreateItemVendor@120 Method

The procedure CreateItemVendor is available in codeunit 132201.

Syntax

CreateItemVendor@120(
    VAR ItemVendor@1001 : Record 99 ItemVendor, //Reference parameter of type Record
    VendorNo@1002 : Code[20] VendorNo, //Input parameter of type Code
    ItemNo@1000 : Code[20] ItemNo //Input parameter of type Code
);

Parameters

ItemVendor
Reference parameter of type Record
VendorNo
Input parameter of type Code
ItemNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Item, Vendor.

For a clarification about how this function works, refer to the code listed below.

      ItemVendor.INIT;
      ItemVendor.VALIDATE("Vendor No.",VendorNo);
      ItemVendor.VALIDATE("Item No.",ItemNo);
      ItemVendor.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134335 to show one way of using this function.

      // Using Random value for Lead Time Calculation.
      LibraryInventory.CreateItemVendor(ItemVendor,VendorNo,ItemNo);
      ItemVendor.VALIDATE(
        "Vendor Item No.",LibraryUtility.GenerateRandomCode(ItemVendor.FIELDNO("Vendor Item No."),DATABASE::"Item Vendor"));
      EVALUATE(ItemVendor."Lead Time Calculation",'<' + FORMAT(LibraryRandom.RandInt(5)) + 'D>');
      ItemVendor.MODIFY(TRUE);
Member of Lib.Library - Inventory


CreateItemWithPostingSetup@22 Method

The procedure CreateItemWithPostingSetup is available in codeunit 132201.

Syntax

CreateItemWithPostingSetup@22(
    VAR Item@1000 : Record 27 Item, //Reference parameter of type Record
    GenProdPostingGroup@1001 : Code[10] GenProdPostingGroup, //Input parameter of type Code
    VATProductPostingGroup@1002 : Code[10] VATProductPostingGroup //Input parameter of type Code
);

Parameters

Item
Reference parameter of type Record
GenProdPostingGroup
Input parameter of type Code
VATProductPostingGroup
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Item, Posting, Setup.

For a clarification about how this function works, refer to the code listed below.

      CreateItem(Item);
      Item.VALIDATE("Gen. Prod. Posting Group",GenProdPostingGroup);
      Item.VALIDATE("VAT Prod. Posting Group",VATProductPostingGroup);
      Item.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134104 to show one way of using this function.

      LibraryInventory.CreateItemWithPostingSetup(Item,GenProdPostingGroupCode,VATProdPostingGroupCode);
      EXIT(Item."No.");
Member of Lib.Library - Inventory


CreateItemWithTariffNo@47 Method

The procedure CreateItemWithTariffNo is available in codeunit 132201.

Syntax

CreateItemWithTariffNo@47(
    VAR Item@1000 : Record 27 Item, //Reference parameter of type Record
    TariffNo@1001 : Code[20] TariffNo //Input parameter of type Code
);

Parameters

Item
Reference parameter of type Record
TariffNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Item, Tariff, No.

For a clarification about how this function works, refer to the code listed below.

      CreateItem(Item);
      Item.VALIDATE("Tariff No.",TariffNo);
      Item.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - Inventory


CreateItemWithUnitPriceAndUnitCost@69 Method

The procedure CreateItemWithUnitPriceAndUnitCost is available in codeunit 132201.

Syntax

CreateItemWithUnitPriceAndUnitCost@69(
    VAR Item@1000 : Record 27 Item, //Reference parameter of type Record
    UnitPrice@1001 : Decimal UnitPrice, //Input parameter of type Decimal
    UnitCost@1003 : Decimal UnitCost //Input parameter of type Decimal
);

Parameters

Item
Reference parameter of type Record
UnitPrice
Input parameter of type Decimal
UnitCost
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Item, Unit, Price, Unit, Cost.

For a clarification about how this function works, refer to the code listed below.

      WITH Item DO BEGIN
        CreateItem(Item);
        VALIDATE("Unit Price",UnitPrice);
        VALIDATE("Unit Cost",UnitCost);
        MODIFY(TRUE);
      END;

Example

The below example is extracted from the test automation codeunit 134152 to show one way of using this function.

      LibraryInventory.CreateItemWithUnitPriceAndUnitCost(
        Item,LibraryRandom.RandDec(1000,2),LibraryRandom.RandDec(1000,2));
      EXIT(Item."No.");
Member of Lib.Library - Inventory


CreateLotNoInformation@35 Method

The procedure CreateLotNoInformation is available in codeunit 132201.

Syntax

CreateLotNoInformation@35(
    VAR LotNoInformation@1004 : Record 6505 LotNoInformation, //Reference parameter of type Record
    ItemNo@1001 : Code[20] ItemNo, //Input parameter of type Code
    VariantCode@1002 : Code[10] VariantCode, //Input parameter of type Code
    LotNo@1003 : Code[20] LotNo //Input parameter of type Code
);

Parameters

LotNoInformation
Reference parameter of type Record
ItemNo
Input parameter of type Code
VariantCode
Input parameter of type Code
LotNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Lot, No, Information.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(LotNoInformation);
      LotNoInformation.INIT;
      LotNoInformation.VALIDATE("Item No.",ItemNo);
      LotNoInformation.VALIDATE("Variant Code",VariantCode);
      LotNoInformation.VALIDATE("Lot No.",LotNo);
      LotNoInformation.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137051 to show one way of using this function.

      LibraryItemTracking.CreateLotNoInformation(LotNoInformation,ItemNo,'',LotNos[LotNoIndex]);
      LotNoInformation.VALIDATE(Blocked,TRUE);
      LotNoInformation.MODIFY(TRUE);
Member of Lib.Library - Inventory


CreateNonStock@44 Method

The procedure CreateNonStock is available in codeunit 132201.

Syntax

CreateNonStock@44(
    VAR NonstockItem@1000 : Record 5718 NonstockItem //Reference parameter of type Record
);

Parameters

NonstockItem
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Non, Stock.

For a clarification about how this function works, refer to the code listed below.

      NonstockItem.INIT;
      NonstockItem.VALIDATE(
        "Entry No.",LibraryUtility.GenerateRandomCode(NonstockItem.FIELDNO("Entry No."),DATABASE::"Nonstock Item"));
      NonstockItem.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137280 to show one way of using this function.

      LibraryPurchase.CreateVendor(Vendor);
      LibraryInventory.CreateNonStock(NonstockItem);
      NonstockItem.VALIDATE("Vendor No.",Vendor."No.");
      NonstockItem.VALIDATE(
        "Vendor Item No.",LibraryUtility.GenerateRandomCode(NonstockItem.FIELDNO("Vendor Item No."),DATABASE::"Nonstock Item"));
      NonstockItem.VALIDATE("Item Category Code",SelectItemCategoryCode);
      NonstockItem.MODIFY(TRUE);
      UpdateItemCategoryCode(NonstockItem."Item Category Code");
      NonstockItemManagement.NonstockAutoItem(NonstockItem);
Member of Lib.Library - Inventory


CreateNonStockItem@131 Method

The procedure CreateNonStockItem is available in codeunit 132201.

Syntax

CreateNonStockItem@131(
    VAR NonstockItem@1000 : Record 5718 NonstockItem //Reference parameter of type Record
);

Parameters

NonstockItem
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Non, Stock, Item.

For a clarification about how this function works, refer to the code listed below.

      ItemCategory.FINDFIRST;
      CreateProductGroup(ProductGroup,ItemCategory.Code);
      CreateUnitOfMeasureCode(UnitOfMeasure);

      CreateNonStock(NonstockItem);
      NonstockItem.VALIDATE("Vendor No.",LibraryPurchase.CreateVendorNo);
      NonstockItem.VALIDATE(
        "Vendor Item No.",LibraryUtility.GenerateRandomCode(NonstockItem.FIELDNO("Vendor Item No."),DATABASE::"Nonstock Item"));
      NonstockItem.VALIDATE("Item Category Code",ItemCategory.Code);
      NonstockItem.VALIDATE("Product Group Code",ProductGroup.Code);
      NonstockItem.VALIDATE("Unit of Measure",UnitOfMeasure.Code);
      NonstockItem.VALIDATE(Description,NonstockItem."Entry No.");
      NonstockItem.MODIFY(TRUE);
      NonstockItemManagement.NonstockAutoItem(NonstockItem);

Example

The below example is extracted from the test automation codeunit 137301 to show one way of using this function.

      // Setup: Create NonStock Item
      Initialize;
      LibraryInventory.CreateNonStockItem(NonstockItem);
      CreateSalesOrder(SalesHeader,'',NonstockItem."Vendor Item No.",LibraryRandom.RandDec(100,2));
      LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      // Exercise: Generate Inventory List Report.
      ItemLedgerEntry.SETRANGE("Item No.",NonstockItem."Vendor Item No.");
      REPORT.RUN(REPORT::"Nonstock Item Sales",TRUE,FALSE,ItemLedgerEntry);

      // Verify: Item No. shown in Nonstock Item Sales Report is equal to the Item No. shown in Nonstock Item Table.
      ItemLedgerEntry.SETRANGE("Entry Type",ItemLedgerEntry."Entry Type"::Sale);
      ItemLedgerEntry.FINDFIRST;
      LibraryReportDataset.LoadDataSetFile;
      LibraryReportDataset.SetRange('ItemLedgerEntryItemNo',NonstockItem."Vendor Item No.");
      LibraryReportDataset.GetNextRow;
      LibraryReportDataset.AssertCurrentRowValue('InvoicedQuantity',-ItemLedgerEntry.Quantity);
Member of Lib.Library - Inventory


CreatePhysicalInventoryCountingPeriod@40 Method

The procedure CreatePhysicalInventoryCountingPeriod is available in codeunit 132201.

Syntax

CreatePhysicalInventoryCountingPeriod@40(
    VAR PhysInvtCountingPeriod@1000 : Record 7381 PhysInvtCountingPeriod //Reference parameter of type Record
);

Parameters

PhysInvtCountingPeriod
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Physical, Inventory, Counting, Period.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(PhysInvtCountingPeriod);
      PhysInvtCountingPeriod.INIT;
      PhysInvtCountingPeriod.VALIDATE(
        Code,LibraryUtility.GenerateRandomCode(PhysInvtCountingPeriod.FIELDNO(Code),DATABASE::"Phys. Invt. Counting Period"));
      PhysInvtCountingPeriod.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137055 to show one way of using this function.

      LibraryInventory.CreatePhysicalInventoryCountingPeriod(PhysInvtCountingPeriod);
      Item.VALIDATE("Phys Invt Counting Period Code",PhysInvtCountingPeriod.Code);
      Item.MODIFY(TRUE);
Member of Lib.Library - Inventory


CreateProductGroup@51 Method

The procedure CreateProductGroup is available in codeunit 132201.

Syntax

CreateProductGroup@51(
    VAR ProductGroup@1000 : Record 5723 ProductGroup, //Reference parameter of type Record
    ItemCategoryCode@1001 : Code[10] ItemCategoryCode //Input parameter of type Code
);

Parameters

ProductGroup
Reference parameter of type Record
ItemCategoryCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Product, Group.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(ProductGroup);
      ProductGroup.INIT;
      ProductGroup.VALIDATE("Item Category Code",ItemCategoryCode);
      ProductGroup.VALIDATE(Code,LibraryUtility.GenerateRandomCode(ProductGroup.FIELDNO(Code),DATABASE::"Product Group"));
      ProductGroup.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137056 to show one way of using this function.

      LibraryWarehouse.CreateWarehouseClass(WarehouseClass);
      LibraryInventory.CreateProductGroup(ProductGroup,'');
      ProductGroup.VALIDATE("Warehouse Class Code",WarehouseClass.Code);
      ProductGroup.MODIFY(TRUE);
Member of Lib.Library - Inventory


CreateSerialNoInformation@33 Method

The procedure CreateSerialNoInformation is available in codeunit 132201.

Syntax

CreateSerialNoInformation@33(
    VAR SerialNoInformation@1004 : Record 6504 SerialNoInformation, //Reference parameter of type Record
    ItemNo@1001 : Code[20] ItemNo, //Input parameter of type Code
    VariantCode@1002 : Code[10] VariantCode, //Input parameter of type Code
    SerialNo@1003 : Code[20] SerialNo //Input parameter of type Code
);

Parameters

SerialNoInformation
Reference parameter of type Record
ItemNo
Input parameter of type Code
VariantCode
Input parameter of type Code
SerialNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Serial, No, Information.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(SerialNoInformation);
      SerialNoInformation.INIT;
      SerialNoInformation.VALIDATE("Item No.",ItemNo);
      SerialNoInformation.VALIDATE("Variant Code",VariantCode);
      SerialNoInformation.VALIDATE("Serial No.",SerialNo);
      SerialNoInformation.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137052 to show one way of using this function.

      // Assign Serial and Lot no based on requirments.
      IF NOT VerifyQtyToHandle THEN BEGIN
        ItemTrackingLines."Assign Serial No.".INVOKE;  // Open Enter Quantity to Create for create Serial No or with Lot No.
        ItemTrackingLines.LAST;
        IF Partial THEN
          ItemTrackingLines."Qty. to Handle (Base)".SETVALUE(0);  // Value to partially track the items.
        LibraryItemTracking.CreateSerialNoInformation(SerialNoInformation,GlobalItemNo,'',ItemTrackingLines."Serial No.".VALUE);
        UpdateSerialNoInformationAndComments(ItemTrackingLines);
        EXIT;
      END;

      // Verify: Qty to Handle- Tracking on unit quantity.
      ItemTrackingLines.LAST;
      ItemTrackingLines."Qty. to Handle (Base)".ASSERTEQUALS(1);  // For Serial No tracking - as per standard, Quantity (Base) must be -1,0,1 when Serial No. is stated.
      ItemTrackingLines.OK.INVOKE;
Member of Lib.Library - Inventory


CreateServiceTypeItem@42 Method

The procedure CreateServiceTypeItem is available in codeunit 132201.

Syntax

CreateServiceTypeItem@42(
    VAR Item@1000 : Record 27 Item //Reference parameter of type Record
);

Parameters

Item
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Service, Type, Item.

For a clarification about how this function works, refer to the code listed below.

      CreateItem(Item);
      Item.VALIDATE(Type,Item.Type::Service);
      Item.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 136306 to show one way of using this function.

      // [FEATURE] [Service Item] [Non-Inventoriable] [Update Job Item Cost]
      // [SCENARIO 252306] "Update Job Item Cost" batch job should copy non-inventoriable cost amount to job ledger entries when updating entries for an item with Type = Service

      Initialize;

      // [GIVEN] Item "I" with "Type" = "Service"
      LibraryInventory.CreateServiceTypeItem(Item);

      // [GIVEN] Purchase order for item "I" with assigned job, "Line Amount" = "X". Receive and Invoice the order.
      CreateJobWithJobTask(JobTask);
      CreatePurchaseOrderAssignJob(PurchaseHeader,PurchaseLine,LibraryPurchase.CreateVendorNo,Item."No.",JobTask);
      PostedDocNo := LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

      // [WHEN] Run "Update Job Item Cost"
      LibraryJob.RunUpdateJobItemCost(JobTask."Job No.");

      // [THEN] "Total Cost" in job ledger entry is "X"
      VerifyJobLedgerEntry(PostedDocNo,JobTask."Job No.",PurchaseLine."Line Amount",JobLedgerEntry.FIELDNO("Total Cost"));
      VerifyJobLedgerEntry(PostedDocNo,JobTask."Job No.",PurchaseLine."Line Amount",JobLedgerEntry.FIELDNO("Total Cost (LCY)"));
Member of Lib.Library - Inventory


CreateShippingAgent@116 Method

The procedure CreateShippingAgent is available in codeunit 132201.

Syntax

CreateShippingAgent@116(
    VAR ShippingAgent@1000 : Record 291 ShippingAgent //Reference parameter of type Record
);

Parameters

ShippingAgent
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Shipping, Agent.

For a clarification about how this function works, refer to the code listed below.

      ShippingAgent.INIT;
      ShippingAgent.VALIDATE(Code,LibraryUtility.GenerateRandomCode(ShippingAgent.FIELDNO(Code),DATABASE::"Shipping Agent"));
      ShippingAgent.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134150 to show one way of using this function.

      LibraryInventory.CreateShippingAgent(ShippingAgent);
      ShippingAgent."Internet Address" := ShippingInternetAddress;
      ShippingAgent.MODIFY;
      EXIT(ShippingAgent.Code);
Member of Lib.Library - Inventory


CreateShippingAgentService@94 Method

The procedure CreateShippingAgentService is available in codeunit 132201.

Syntax

CreateShippingAgentService@94(
    VAR ShippingAgentServices@1002 : Record 5790 ShippingAgentServices, //Reference parameter of type Record
    ShippingAgentCode@1001 : Code[10] ShippingAgentCode, //Input parameter of type Code
    ShippingTime@1000 : DateFormula ShippingTime //Input parameter of type DateFormula
);

Parameters

ShippingAgentServices
Reference parameter of type Record
ShippingAgentCode
Input parameter of type Code
ShippingTime
Input parameter of type DateFormula

Remarks

The relevant search keywords are: Create, Shipping, Agent, Service.

For a clarification about how this function works, refer to the code listed below.

      ShippingAgentServices.INIT;
      ShippingAgentServices.VALIDATE("Shipping Agent Code",ShippingAgentCode);
      ShippingAgentServices.VALIDATE(
        Code,LibraryUtility.GenerateRandomCode(ShippingAgentServices.FIELDNO(Code),DATABASE::"Shipping Agent Services"));
      ShippingAgentServices.INSERT(TRUE);
      ShippingAgentServices.VALIDATE("Shipping Time",ShippingTime);
      ShippingAgentServices.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 136140 to show one way of using this function.

      LibraryInventory.CreateShippingAgent(ShippingAgent);

      FOR j := 1 TO 6 DO BEGIN
        EVALUATE(ShippingTime,'<' + FORMAT(j) + 'D>');
        LibraryInventory.CreateShippingAgentService(ShippingAgentServices,ShippingAgent.Code,ShippingTime);
        ShippingAgentServicesCode[j] := ShippingAgentServices.Code;
      END;
Member of Lib.Library - Inventory


CreateStandardCostWorksheetName@37 Method

The procedure CreateStandardCostWorksheetName is available in codeunit 132201.

Syntax

CreateStandardCostWorksheetName@37(
    VAR StandardCostWorksheetName@1001 : Record 5840 StandardCostWorksheetName //Reference parameter of type Record
);

Parameters

StandardCostWorksheetName
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Standard, Cost, Worksheet, Name.

For a clarification about how this function works, refer to the code listed below.

      StandardCostWorksheetName.INIT;
      StandardCostWorksheetName.VALIDATE(
        Name,LibraryUtility.GenerateRandomCode(StandardCostWorksheetName.FIELDNO(Name),DATABASE::"Standard Cost Worksheet Name"));
      StandardCostWorksheetName.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137007 to show one way of using this function.

      // [FEATURE] [Standard Cost Worksheet] [UI]
      // [SCENARIO 210317] Standard Cost Worksheet (SCW) is opened with last selected SCW Name.
      Initialize;

      // [GIVEN] New SCW Name "X" is created.
      LibraryInventory.CreateStandardCostWorksheetName(StdCostWorksheetName);

      // [GIVEN] SCW Name is updated to "X" on the worksheet, and the page is closed.
      StandardCostWorksheet.OPENEDIT;
      StandardCostWorksheet.CurrWkshName.SETVALUE(StdCostWorksheetName.Name);
      StandardCostWorksheet.CLOSE;

      // [WHEN] Open SCW page again.
      StandardCostWorksheet.OPENVIEW;

      // [THEN] SCW Name on the page = "X".
      StandardCostWorksheet.CurrWkshName.ASSERTEQUALS(StdCostWorksheetName.Name);
Member of Lib.Library - Inventory


CreateStockKeepingUnit@129 Method

The procedure CreateStockKeepingUnit is available in codeunit 132201.

Syntax

CreateStockKeepingUnit@129(
    VAR Item@1004 : Record 27 Item, //Reference parameter of type Record
    CreatePerOption@1007 : Option CreatePerOption, //Input parameter of type Option
    NewItemInInventoryOnly@1006 : Boolean NewItemInInventoryOnly, //Input parameter of type Boolean
    NewReplacePreviousSKUs@1005 : Boolean NewReplacePreviousSKUs //Input parameter of type Boolean
);

Parameters

Item
Reference parameter of type Record
CreatePerOption
Input parameter of type Option
NewItemInInventoryOnly
Input parameter of type Boolean
NewReplacePreviousSKUs
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, Stock, Keeping, Unit.

For a clarification about how this function works, refer to the code listed below.

      CreateStockkeepingUnit.InitializeRequest(CreatePerOption,NewItemInInventoryOnly,NewReplacePreviousSKUs);
      IF Item.HASFILTER THEN
        TmpItem.COPYFILTERS(Item)
      ELSE BEGIN
        Item.GET(Item."No.");
        TmpItem.SETRANGE("No.",Item."No.");
      END;

      CreateStockkeepingUnit.SETTABLEVIEW(TmpItem);
      CreateStockkeepingUnit.USEREQUESTPAGE(FALSE);
      CreateStockkeepingUnit.RUN;

Example

The below example is extracted from the test automation codeunit 137007 to show one way of using this function.

      // [FEATURE] [Transfer] [Adjust Cost - Item Entries] [Last Direct Cost] [Stockkeeping Unit]
      // [SCENARIO 379749] "Adjust Cost - Item Entries" should not not update last direct cost of a stockkeeping unit

      Initialize;

      // [GIVEN] Item "I" with Average costing method
      CreateItemWithCostingMethod(Item,Item."Costing Method"::Average);

      // [GIVEN] Two locations "L1" and "L2" with stockkeeping unit for item "I" on each location ("SKU1" and "SKU2")
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location[1]);
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location[2]);
      Item.SETRECFILTER;
      Item.SETFILTER("Location Filter",'%1|%2',Location[1].Code,Location[2].Code);
      LibraryInventory.CreateStockKeepingUnit(Item,0,FALSE,TRUE); // Create stockkeeping units per location

      // [GIVEN] Post item stock on location "L1". Unit cost = "X1"
      UnitCost[1] := CreateAndPostItemJournalLine(Item."No.",LibraryRandom.RandInt(10),Location[1].Code);
      // [GIVEN] Post item stock on location "L2". Unit cost = "X2"
      UnitCost[2] := CreateAndPostItemJournalLine(Item."No.",LibraryRandom.RandInt(10),Location[2].Code);

      // [GIVEN] Transfer item from location "L1" to location "L2"
      CreatePostTransferJournalLine(Item."No.",1,Location[1].Code,Location[2].Code);

      // [WHEN] Run "Adjust Cost - Item Entries"
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');

      // [THEN] Last direct cost in "SKU1" = "X1", Last direct cost in "SKU2" = "X2"
      VerifySKULastDirectCost(Item."No.",Location[1].Code,UnitCost[1]);
      VerifySKULastDirectCost(Item."No.",Location[2].Code,UnitCost[2]);
Member of Lib.Library - Inventory


CreateStockkeepingUnitForLocationAndVariant@140 Method

The procedure CreateStockkeepingUnitForLocationAndVariant is available in codeunit 132201.

Syntax

CreateStockkeepingUnitForLocationAndVariant@140(
    VAR StockkeepingUnit@1000 : Record 5700 StockkeepingUnit, //Reference parameter of type Record
    LocationCode@1001 : Code[10] LocationCode, //Input parameter of type Code
    ItemNo@1002 : Code[20] ItemNo, //Input parameter of type Code
    VariantCode@1003 : Code[10] VariantCode //Input parameter of type Code
);

Parameters

StockkeepingUnit
Reference parameter of type Record
LocationCode
Input parameter of type Code
ItemNo
Input parameter of type Code
VariantCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Stockkeeping, Unit, For, Location, Variant.

For a clarification about how this function works, refer to the code listed below.

      StockkeepingUnit.INIT;
      StockkeepingUnit.VALIDATE("Location Code",LocationCode);
      StockkeepingUnit.VALIDATE("Item No.",ItemNo);
      StockkeepingUnit.VALIDATE("Variant Code",VariantCode);
      StockkeepingUnit.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137008 to show one way of using this function.

      // [FEATURE] [Net Change Plan] [Stockkeeping Unit]
      // [SCENARIO 220546] Net change planning should plan a stockkeping unit that has planning parameters configured, and the item is not set up for planning

      Initialize;

      // [GIVEN] Item "I" without planning parameters (Reordering Policy is blank)
      LibraryInventory.CreateItem(Item);
      LibraryWarehouse.CreateLocation(Location);

      // [GIVEN] Stockkeeping unit for item "I", "Reordering Policy" = "Lot-for-Lot"
      LibraryInventory.CreateStockkeepingUnitForLocationAndVariant(SKU,Location.Code,Item."No.",'');
      SKU.VALIDATE("Reordering Policy",SKU."Reordering Policy"::"Lot-for-Lot");
      SKU.MODIFY(TRUE);

      // [GIVEN] Calculate net change plan
      // This step is required to deactivate the planning assignment entry. It is created with Inactive = FALSE when a new stockkeping unit is inserted.
      // Planning worksheet will not plan anything, since there is no demand, but it will update "Inactive" to TRUE.
      CalcNetChangePlanForPlanWksh(Item."No.");

      // [GIVEN] Create sales order for "X" pcs item "I" as demand for planning
      LibrarySales.CreateSalesHeader(SalesHeader,SalesHeader."Document Type"::Order,LibrarySales.CreateCustomerNo);
      CreateSalesLineOnLocation(SalesLine,SalesHeader,Item."No.",LibraryRandom.RandInt(10),Location.Code);

      // [WHEN] Calculate net change plan
      CalcNetChangePlanForPlanWksh(Item."No.");

      // [THEN] Replenishment of "X" pcs of item "I" is suggested
      RequisitionLine.SETRANGE(Type,RequisitionLine.Type::Item);
      RequisitionLine.SETRANGE("No.",Item."No.");
      RequisitionLine.FINDFIRST;
      RequisitionLine.TESTFIELD(Quantity,SalesLine.Quantity);
Member of Lib.Library - Inventory


CreateTrackedItem@58 Method

The procedure CreateTrackedItem is available in codeunit 132201.

Syntax

CreateTrackedItem@58(
    VAR Item@1001 : Record 27 Item, //Reference parameter of type Record
    LotNos@1003 : Code[10] LotNos, //Input parameter of type Code
    SerialNos@1002 : Code[10] SerialNos, //Input parameter of type Code
    ItemTrackingCode@1000 : Code[10] ItemTrackingCode //Input parameter of type Code
);

Parameters

Item
Reference parameter of type Record
LotNos
Input parameter of type Code
SerialNos
Input parameter of type Code
ItemTrackingCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Tracked, Item.

For a clarification about how this function works, refer to the code listed below.

      CreateItem(Item);
      Item.VALIDATE("Item Tracking Code",ItemTrackingCode);
      Item.VALIDATE("Serial Nos.",SerialNos);
      Item.VALIDATE("Lot Nos.",LotNos);
      Item.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134329 to show one way of using this function.

      LibraryInventory.CreateTrackedItem(Item,LibraryUtility.GetGlobalNoSeriesCode,'',CreateItemTrackingCode);
      EXIT(Item."No.");
Member of Lib.Library - Inventory


CreateTransferHeader@29 Method

The procedure CreateTransferHeader is available in codeunit 132201.

Syntax

CreateTransferHeader@29(
    VAR TransferHeader@1000 : Record 5740 TransferHeader, //Reference parameter of type Record
    FromLocation@1001 : Text[10] FromLocation, //Input parameter of type Text
    ToLocation@1002 : Text[10] ToLocation, //Input parameter of type Text
    InTransitCode@1003 : Text[10] InTransitCode //Input parameter of type Text
);

Parameters

TransferHeader
Reference parameter of type Record
FromLocation
Input parameter of type Text
ToLocation
Input parameter of type Text
InTransitCode
Input parameter of type Text

Remarks

The relevant search keywords are: Create, Transfer, Header.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(TransferHeader);
      TransferHeader.INIT;
      TransferHeader.INSERT(TRUE);
      TransferHeader.VALIDATE("Transfer-from Code",FromLocation);
      TransferHeader.VALIDATE("Transfer-to Code",ToLocation);
      TransferHeader.VALIDATE("In-Transit Code",InTransitCode);
      TransferHeader.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 136121 to show one way of using this function.

      Location2.SETRANGE("Use As In-Transit",TRUE);
      Location2.FINDFIRST;
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location);
      LibraryWarehouse.CreateTransferHeader(TransferHeader,FromLocationCode,Location.Code,Location2.Code);
      LibraryWarehouse.CreateTransferLine(TransferHeader,TransferLine,ItemNo,OriginalQuantity);
      TransferLine.VALIDATE("Receipt Date",CALCDATE('<' + FORMAT(RANDOM(5)) + 'M>',WORKDATE));  // Used Random to calculate Receipt Date.
      TransferLine.VALIDATE("Qty. to Ship",OriginalQuantity);
      TransferLine.MODIFY(TRUE);
Member of Lib.Library - Inventory


CreateTransferLine@59 Method

The procedure CreateTransferLine is available in codeunit 132201.

Syntax

CreateTransferLine@59(
    VAR TransferHeader@1000 : Record 5740 TransferHeader, //Reference parameter of type Record
    VAR TransferLine@1001 : Record 5741 TransferLine, //Reference parameter of type Record
    ItemNo@1002 : Text[20] ItemNo, //Input parameter of type Text
    Quantity@1004 : Decimal Quantity //Input parameter of type Decimal
);

Parameters

TransferHeader
Reference parameter of type Record
TransferLine
Reference parameter of type Record
ItemNo
Input parameter of type Text
Quantity
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Transfer, Line.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(TransferLine);
      TransferLine.INIT;
      TransferLine.VALIDATE("Document No.",TransferHeader."No.");
      RecRef.GETTABLE(TransferLine);
      TransferLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,TransferLine.FIELDNO("Line No.")));
      TransferLine.INSERT(TRUE);
      TransferLine.VALIDATE("Item No.",ItemNo);
      TransferLine.VALIDATE(Quantity,Quantity);
      TransferLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 136121 to show one way of using this function.

      Location2.SETRANGE("Use As In-Transit",TRUE);
      Location2.FINDFIRST;
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location);
      LibraryWarehouse.CreateTransferHeader(TransferHeader,FromLocationCode,Location.Code,Location2.Code);
      LibraryWarehouse.CreateTransferLine(TransferHeader,TransferLine,ItemNo,OriginalQuantity);
      TransferLine.VALIDATE("Receipt Date",CALCDATE('<' + FORMAT(RANDOM(5)) + 'M>',WORKDATE));  // Used Random to calculate Receipt Date.
      TransferLine.VALIDATE("Qty. to Ship",OriginalQuantity);
      TransferLine.MODIFY(TRUE);
Member of Lib.Library - Inventory


CreateTransferRoute@25 Method

The procedure CreateTransferRoute is available in codeunit 132201.

Syntax

CreateTransferRoute@25(
    VAR TransferRoute@1000 : Record 5742 TransferRoute, //Reference parameter of type Record
    TransferFrom@1001 : Code[10] TransferFrom, //Input parameter of type Code
    TransferTo@1002 : Code[10] TransferTo //Input parameter of type Code
);

Parameters

TransferRoute
Reference parameter of type Record
TransferFrom
Input parameter of type Code
TransferTo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Transfer, Route.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(TransferRoute);
      TransferRoute.INIT;
      TransferRoute.VALIDATE("Transfer-from Code",TransferFrom);
      TransferRoute.VALIDATE("Transfer-to Code",TransferTo);
      TransferRoute.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137008 to show one way of using this function.

      // [FEATURE] [Requisition Worksheet]
      // [SCENARIO 259107] Replenishment via transfer should be planned for item on a location with inbound handling time and "Respect Planning Parameters for Supply Triggered Safety Stock"

      Initialize;

      // [GIVEN] Location "A"
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location[1]);
      // [GIVEN] Location "B" with 1 day inbound handling time
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location[2]);
      EVALUATE(Location[2]."Inbound Whse. Handling Time",'<1D>');
      Location[2].MODIFY(TRUE);
      LibraryInventory.CreateTransferRoute(TransferRoute,Location[1].Code,Location[2].Code);

      // [GIVEN] Item "I" with a stockkeeping unit on the location "B"
      // [GIVEN] Item is configured to be replenished by a transfer from location "A". Reordering policy is "Maximum Qty.", "Maximum Inventory" is "X"
      LibraryInventory.CreateItem(Item);
      LibraryInventory.CreateStockkeepingUnitForLocationAndVariant(SKU,Location[2].Code,Item."No.",'');
      SKU.VALIDATE("Reordering Policy",SKU."Reordering Policy"::"Maximum Qty.");
      SKU.VALIDATE("Reorder Point",LibraryRandom.RandIntInRange(10,20));
      SKU.VALIDATE("Maximum Inventory",SKU."Reorder Point" * 2);
      SKU.VALIDATE("Replenishment System",SKU."Replenishment System"::Transfer);
      SKU.VALIDATE("Transfer-from Code",Location[1].Code);
      SKU.MODIFY(TRUE);

      // [GIVEN] Sales order for item "I" on location "B", "Quantity" = "Y"
      LibrarySales.CreateSalesHeader(SalesHeader,SalesHeader."Document Type"::Order,LibrarySales.CreateCustomerNo);
      CreateSalesLineOnLocation(SalesLine,SalesHeader,Item."No.",LibraryRandom.RandInt(20),Location[2].Code);

      // [WHEN] Calculate requisition plan for item "I" and location "B" with the option "Respect Planning Parameters for Supply Triggered Safety Stock"
      CalculatePlanInRequisitionWorksheet(Item,Location[2].Code,WORKDATE,WORKDATE + 1);

      // [THEN] Quantity planned for replenishment "X" + "Y", transfer is planned on work date
      RequisitionLine.SETRANGE(Type,RequisitionLine.Type::Item);
      RequisitionLine.SETRANGE("No.",Item."No.");
      RequisitionLine.FINDFIRST;
      RequisitionLine.TESTFIELD(Quantity,SKU."Maximum Inventory" + SalesLine.Quantity);
      RequisitionLine.TESTFIELD("Due Date",WORKDATE);
Member of Lib.Library - Inventory


CreateUnitOfMeasureCode@95 Method

The procedure CreateUnitOfMeasureCode is available in codeunit 132201.

Syntax

CreateUnitOfMeasureCode@95(
    VAR UnitOfMeasure@1000 : Record 204 UnitOfMeasure //Reference parameter of type Record
);

Parameters

UnitOfMeasure
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Unit, Of, Measure, Code.

For a clarification about how this function works, refer to the code listed below.

      UnitOfMeasure.INIT;
      UnitOfMeasure.VALIDATE(Code,LibraryUtility.GenerateRandomCode(UnitOfMeasure.FIELDNO(Code),DATABASE::"Unit of Measure"));
      UnitOfMeasure.VALIDATE(Description,UnitOfMeasure.Code);
      UnitOfMeasure.VALIDATE("International Standard Code",
        LibraryUtility.GenerateRandomCode(UnitOfMeasure.FIELDNO("International Standard Code"),DATABASE::"Unit of Measure"));
      UnitOfMeasure.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134327 to show one way of using this function.

      // Verify that Qty to receive in Purchase Line is blank after enering G/L Account with UoM

      // Setup: Update Purchases & Payables setup, Create purchase order.
      Initialize;
      UpdateDefaultQtyToReceive(PurchasesPayablesSetup."Default Qty. to Receive"::Blank);

      CreatePurchaseDocument(PurchaseHeader,PurchaseLine,CreateVendor,PurchaseHeader."Document Type"::Order);
      GLAccount.GET(LibraryERM.CreateGLAccountWithPurchSetup);

      // Exercise: create purchase line for G/L account and update Unit of Measure
      LibraryPurchase.CreatePurchaseLine(
        PurchaseLine,PurchaseHeader,PurchaseLine.Type::"G/L Account",GLAccount."No.",LibraryRandom.RandInt(10));
      LibraryInventory.CreateUnitOfMeasureCode(UnitOfMeasure);
      PurchaseLine.VALIDATE("Unit of Measure",UnitOfMeasure.Code);

      // Verify: Verify Quantity after Undo Receipt on Posted Purchase Receipt And Quantity to Receive is blank on Purchase Line.
      Assert.AreEqual(0,PurchaseLine."Qty. to Receive",'qty. to Receive should be 0');
Member of Lib.Library - Inventory


CreateVariant@160 Method

The procedure CreateVariant is available in codeunit 132201.

Syntax

CreateVariant@160(
    VAR ItemVariant@1001 : Record 5401 ItemVariant, //Reference parameter of type Record
    Item@1000 : Record 27 Item //Input parameter of type Record
);

Parameters

ItemVariant
Reference parameter of type Record
Item
Input parameter of type Record

Remarks

The relevant search keywords are: Create, Variant.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(ItemVariant);
      ItemVariant.INIT;
      ItemVariant.VALIDATE("Item No.",Item."No.");
      ItemVariant.VALIDATE(Code,LibraryUtility.GenerateRandomCode(ItemVariant.FIELDNO(Code),DATABASE::"Item Variant"));
      ItemVariant.VALIDATE(Description,ItemVariant.Code);
      ItemVariant.INSERT;

Example

The below example is extracted from the test automation codeunit 136353 to show one way of using this function.

      // [FEATURE] [Discount] [Line Discount] [Item Variant]
      // [SCENARIO 212422] "Line Discount %" of Job Planning Line is zero when "Allow Line Disc." is No in Sales Price for "All Customers", Item with Variant and Customer has "Line Discount" from Customer Discount Group

      Initialize;

      // [GIVEN] Customer Discount Group "CUSTDISC" assigned to Customer "C"
      LibraryERM.CreateCustomerDiscountGroup(CustomerDiscountGroup);
      LibrarySales.CreateCustomer(Customer);
      Customer.VALIDATE("Customer Disc. Group",CustomerDiscountGroup.Code);
      Customer.MODIFY(TRUE);

      // [GIVEN] Job and Job Task with Customer "C"
      LibraryJob.CreateJob(Job);
      Job.VALIDATE("Bill-to Customer No.",Customer."No.");
      Job.MODIFY(TRUE);
      LibraryJob.CreateJobTask(Job,JobTask);

      // [GIVEN] Item "X" with Variant "X1" and Item Discount Group "ITEMDISC"
      LibraryInventory.CreateItem(Item);
      LibraryInventory.CreateVariant(ItemVariant,Item);
      LibraryERM.CreateItemDiscountGroup(ItemDiscountGroup);
      Item.VALIDATE("Item Disc. Group",ItemDiscountGroup.Code);
      Item.MODIFY(TRUE);

      // [GIVEN] Sales Line Discount with Customer Discount Group "CUSTDISC", Item Discount Group "ITEMDISC" and "Line Discount %" = 10
      LibraryERM.CreateLineDiscForCustomer(
        SalesLineDiscount,SalesLineDiscount.Type::"Item Disc. Group",ItemDiscountGroup.Code,
        SalesLineDiscount."Sales Type"::"Customer Disc. Group",CustomerDiscountGroup.Code,WORKDATE,'','','',0);
      SalesLineDiscount.VALIDATE("Line Discount %",LibraryRandom.RandDec(10,2));
      SalesLineDiscount.MODIFY(TRUE);

      // [GIVEN] Sales Price for All Customers for Item "X", Variant "X1" is 50, "Allow Line Disc." = No
      LibrarySales.CreateSalesPrice(
        SalesPrice,Item."No.",SalesPrice."Sales Type"::"All Customers",'',
        WORKDATE,'',ItemVariant.Code,Item."Base Unit of Measure",0,LibraryRandom.RandDec(100,2));
      SalesPrice.VALIDATE("Allow Line Disc.",FALSE);
      SalesPrice.MODIFY(TRUE);

      // [GIVEN] Job Planning Line with Item "X"
      CreateSimpleJobPlanningLine(JobPlanningLine,JobTask);
      JobPlanningLine.VALIDATE(Type,JobPlanningLine.Type::Item);
      JobPlanningLine.VALIDATE("No.",Item."No.");

      // [WHEN] Validate Variant "X1" on Job Planning Line
      JobPlanningLine.VALIDATE("Variant Code",ItemVariant.Code);

      // [THEN] "Line Discount %" in Job Planning Line is 0%
      JobPlanningLine.TESTFIELD("Line Discount %",0);
Member of Lib.Library - Inventory


DateComprItemBudgetEntries@108 Method

The procedure DateComprItemBudgetEntries is available in codeunit 132201.

Syntax

DateComprItemBudgetEntries@108(
    VAR ItemBudgetEntry@1000 : Record 7134 ItemBudgetEntry, //Reference parameter of type Record
    AnalysisAreaSelection@1001 : Option AnalysisAreaSelection, //Input parameter of type Option
    StartDate@1002 : Date StartDate, //Input parameter of type Date
    EndDate@1003 : Date EndDate, //Input parameter of type Date
    PeriodLength@1004 : Option PeriodLength, //Input parameter of type Option
    Description@1005 : Text[50] Description //Input parameter of type Text
);

Parameters

ItemBudgetEntry
Reference parameter of type Record
AnalysisAreaSelection
Input parameter of type Option
StartDate
Input parameter of type Date
EndDate
Input parameter of type Date
PeriodLength
Input parameter of type Option
Description
Input parameter of type Text

Remarks

The relevant search keywords are: Date, Compr, Item, Budget, Entries.

For a clarification about how this function works, refer to the code listed below.

      DateCompItemBudgetEntries.InitializeRequest(AnalysisAreaSelection,StartDate,EndDate,PeriodLength,Description);
      IF ItemBudgetEntry.HASFILTER THEN
        TmpItemBudgetEntry.COPYFILTERS(ItemBudgetEntry)
      ELSE BEGIN
        ItemBudgetEntry.GET(ItemBudgetEntry."Entry No.");
        TmpItemBudgetEntry.SETRANGE("Entry No.",ItemBudgetEntry."Entry No.");
      END;
      DateCompItemBudgetEntries.SETTABLEVIEW(TmpItemBudgetEntry);
      DateCompItemBudgetEntries.USEREQUESTPAGE(FALSE);
      DateCompItemBudgetEntries.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 137062 to show one way of using this function.

      // Run Date Compress Item Budget Entries when Same dimension in both Item Budget entry lines.
      // 1. Setup.
      Initialize;
      ClearEntries;
      LibraryInventory.CreateItem(Item);

      // Same Dimensions in both Item Budget Entry Lines.
      GeneralLedgerSetup.GET;
      DimensionCode := GeneralLedgerSetup."Global Dimension 1 Code";
      DimensionCode2 := GeneralLedgerSetup."Global Dimension 2 Code";
      LibraryDimension.FindDimensionValue(DimensionValue,DimensionCode);
      LibraryDimension.FindDimensionValue(DimensionValue2,DimensionCode2);

      ItemBudgetName.SETRANGE("Analysis Area",ItemBudgetName."Analysis Area"::Sales);
      ItemBudgetName.SETFILTER("Budget Dimension 1 Code",'<> %1','');
      ItemBudgetName.SETFILTER("Budget Dimension 2 Code",'<> %1','');
      ItemBudgetName.FINDFIRST;

      DimensionCode3 := ItemBudgetName."Budget Dimension 1 Code";
      DimensionCode4 := ItemBudgetName."Budget Dimension 2 Code";
      DimensionCode5 := ItemBudgetName."Budget Dimension 3 Code";
      LibraryDimension.FindDimensionValue(DimensionValue3,DimensionCode3);

      // Create Item Budget Entries.
      CreateItemBudgetEntry(Item,WORKDATE,DimensionValue.Code,DimensionValue2.Code,DimensionValue3.Code);
      CreateItemBudgetEntry(Item,CALCDATE('<1D>',WORKDATE),DimensionValue.Code,DimensionValue2.Code,DimensionValue3.Code);
      ItemBudgetEntry.SETRANGE("Budget Dimension 1 Code",DimensionValue3.Code); // filtering on created.

      // Create Selected Dimensions for Date Compress.
      CreateDimForBudgetEntry(DimensionCode,DimensionCode2,DimensionCode3,DimensionCode4,DimensionCode5);

      // 2. Exercise: Run Date compress entries.
      LibraryVariableStorage.Enqueue(DeletesEntries);  // Enqueue Value for Confirm Handler.
      LibraryVariableStorage.Enqueue(UpdateAnalysisViews);  // Enqueue Value for Confirm Handler.
      LibraryInventory.DateComprItemBudgetEntries(
        ItemBudgetEntry,0,CALCDATE('<CY-1Y+1D>',WORKDATE),CALCDATE('<CY>',WORKDATE),PeriodLength::Month,LibraryUtility.GenerateGUID);

      // 3. Verify: verify compressed Item Budget Entries and date compresed Item Budget Entries.
      VerifyDimension(ItemBudgetEntry,1,DimensionValue.Code,DimensionValue2.Code);  // Value is important for Test.
      DateComprRegister.SETRANGE("Table ID",DATABASE::"Item Budget Entry");
      VerifyDateComprRegister(DateComprRegister,1,'1','2');  // Value is important for Test.
Member of Lib.Library - Inventory


FindItemJournalTemplate@142 Method

The procedure FindItemJournalTemplate is available in codeunit 132201.

Syntax

FindItemJournalTemplate@142(
    VAR ItemJournalTemplate@1000 : Record 82 ItemJournalTemplate //Reference parameter of type Record
);

Parameters

ItemJournalTemplate
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Item, Journal, Template.

For a clarification about how this function works, refer to the code listed below.

      ItemJournalTemplate.SETRANGE(Type,ItemJournalTemplate.Type::Item);
      ItemJournalTemplate.SETRANGE(Recurring,FALSE);
      IF NOT ItemJournalTemplate.FINDFIRST THEN BEGIN
        CreateItemJournalTemplate(ItemJournalTemplate);
        ItemJournalTemplate.VALIDATE(Type,ItemJournalTemplate.Type::Item);
        ItemJournalTemplate.MODIFY(TRUE);
      END;

Example

The below example is extracted from the test automation codeunit 134383 to show one way of using this function.

      // Setup. Find Journal Batch
      LibraryInventory.FindItemJournalTemplate(ItemJournalTemplate);
      ItemJournalBatch.SETRANGE("Journal Template Name",ItemJournalTemplate.Name);
      ItemJournalBatch.FINDFIRST;

      // Setup. Create Item Journal Line and Store the Sales Amount.
      LibraryInventory.CreateItemJournalLine(
        ItemJournalLine,ItemJournalTemplate.Name,ItemJournalBatch.Name,ItemJournalLineEntryType,ItemNo,
        LibraryRandom.RandInt(5));
      ItemJournalLine.VALIDATE("Posting Date",PostingDate);
      ItemJournalLine.MODIFY(TRUE);

      // Setup. Post Item Journal Line
      LibraryInventory.PostItemJournalLine(ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name);
      EXIT(ItemJournalLine.Amount);
Member of Lib.Library - Inventory


FindUnitOfMeasure@145 Method

The procedure FindUnitOfMeasure is available in codeunit 132201.

Syntax

FindUnitOfMeasure@145(
    VAR UnitOfMeasure@1000 : Record 204 UnitOfMeasure //Reference parameter of type Record
);

Parameters

UnitOfMeasure
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Unit, Of, Measure.

For a clarification about how this function works, refer to the code listed below.

      IF NOT UnitOfMeasure.FINDFIRST THEN
        CreateUnitOfMeasureCode(UnitOfMeasure);

Example

There are no examples available.
Member of Lib.Library - Inventory


GetQtyPerForItemUOM@3 Method

The procedure GetQtyPerForItemUOM is available in codeunit 132201.

Syntax

GetQtyPerForItemUOM@3(
    ItemNo@1000 : Code[20] ItemNo, //Input parameter of type Code
    UOMCode@1001 : Code[10] UOMCode //Input parameter of type Code
);

Parameters

ItemNo
Input parameter of type Code
UOMCode
Input parameter of type Code

Return Value

Decimal

Remarks

The relevant search keywords are: Get, Quantity, Per, For, Item, UOM.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(ItemUnitOfMeasure);
      ItemUnitOfMeasure.GET(ItemNo,UOMCode);

      EXIT(ItemUnitOfMeasure."Qty. per Unit of Measure");

Example

The below example is extracted from the test automation codeunit 137056 to show one way of using this function.

      ItemQty := LibraryRandom.RandDec(10,2);
      LibraryInventory.CreateItem(Item);
      WarehouseItemJournalSetup(LocationWhite.Code);
      FindZone(Zone,LocationWhite.Code,LibraryWarehouse.SelectBinType(FALSE,FALSE,TRUE,TRUE));
      FindBinWithZone(Bin,LocationWhite.Code,Zone.Code);

      LibraryWarehouse.CreateBinContent(
        BinContent,LocationWhite.Code,Zone.Code,Bin.Code,Item."No.",'',Item."Base Unit of Measure");
      MockInventory(
        LocationWhite.Code,Zone.Code,Bin.Code,Item."No.",Item."Base Unit of Measure",
        LibraryInventory.GetQtyPerForItemUOM(Item."No.",Item."Base Unit of Measure"),ItemQty);

      LibraryWarehouse.CreateWhseJournalLine(
        WarehouseJournalLine,WarehouseJournalBatch."Journal Template Name",WarehouseJournalBatch.Name,
        LocationWhite.Code,Zone.Code,Bin.Code,WarehouseJournalLine."Entry Type"::"Negative Adjmt.",
        Item."No.",-ItemQty);

      WarehouseJournalLine.VALIDATE("To Bin Code",'');
      WarehouseJournalLine.MODIFY(TRUE);
      EXIT(WarehouseJournalLine."Whse. Document No.");
Member of Lib.Library - Inventory


GetReservConfirmText@123 Method

The procedure GetReservConfirmText is available in codeunit 132201.

Syntax

GetReservConfirmText@123(
      //param element not supplied
);

Return Value

Text

Remarks

The relevant search keywords are: Get, Reserv, Confirm, Text.

For a clarification about how this function works, refer to the code listed below.

      EXIT(ReserveConfirmMsg);

Example

There are no examples available.
Member of Lib.Library - Inventory


GetVariant@150 Method

The procedure GetVariant is available in codeunit 132201.

Syntax

GetVariant@150(
    ItemNo@1001 : Code[20] ItemNo, //Input parameter of type Code
    OldVariantCode@1002 : Code[10] OldVariantCode //Input parameter of type Code
);

Parameters

ItemNo
Input parameter of type Code
OldVariantCode
Input parameter of type Code

Return Value

Code[10]

Remarks

The relevant search keywords are: Get, Variant.

For a clarification about how this function works, refer to the code listed below.

      ItemVariant.SETRANGE("Item No.",ItemNo);
      ItemVariant.SETFILTER(Code,'<>%1',OldVariantCode);
      IF ItemVariant.COUNT = 0 THEN
        EXIT('');
      ItemVariant.NEXT(RANDOM(ItemVariant.COUNT));
      EXIT(ItemVariant.Code);

Example

The below example is extracted from the test automation codeunit 137091 to show one way of using this function.

      // Setup.
      Initialize;
      LibraryAssembly.CreateItem(Item,Item."Costing Method"::Standard,Item."Replenishment System"::Assembly,'','');
      LibraryAssembly.CreateItem(Item1,Item."Costing Method"::Standard,Item."Replenishment System"::Purchase,'','');
      LibraryAssembly.CreateResource(Resource,TRUE,'');

      LibraryAssembly.CreateAssemblyListComponent(
        BOMComponent.Type::Resource,Resource."No.",Item."No.",'',
        BOMComponent."Resource Usage Type"::Direct,LibraryRandom.RandDec(20,2),TRUE);
      LibraryAssembly.CreateAssemblyListComponent(
        BOMComponent.Type::Resource,Resource."No.",Item."No.",'',
        BOMComponent."Resource Usage Type"::Direct,20 + LibraryRandom.RandDec(20,2),TRUE);

      LibraryAssembly.CreateAssemblyListComponent(
        BOMComponent.Type::Item,Item1."No.",Item."No.",'',
        BOMComponent."Resource Usage Type"::Direct,LibraryRandom.RandDec(20,2),TRUE);
      LibraryAssembly.CreateAssemblyListComponent(
        BOMComponent.Type::Item,Item1."No.",Item."No.",'',
        BOMComponent."Resource Usage Type"::Direct,20 + LibraryRandom.RandDec(20,2),TRUE);
      SaveInitialAssemblyList(TempBOMComponent,Item."No.");
      StdCostLevel := 1;
      CalculateStandardCost.CalcItem(Item."No.",TRUE);
      CalculateStandardCost.CalcAssemblyItemPrice(Item."No.");
      LibraryAssembly.CreateAssemblyHeader(AssemblyHeader,WorkDate2,Item."No.",'',LibraryRandom.RandDec(10,2),'');

      // Exercise.
      LibraryAssembly.CreateAssemblyLine(AssemblyHeader,AssemblyLine,AssemblyLine.Type::Item,Item1."No.",
        LibraryAssembly.GetUnitOfMeasureCode(AssemblyLine.Type::Item,Item1."No.",TRUE),40 + LibraryRandom.RandDec(20,2),0,'');
      IF UseVariant THEN
        AssemblyLine.VALIDATE("Variant Code",LibraryInventory.GetVariant(Item1."No.",AssemblyLine."Variant Code"));
      AssemblyLine.MODIFY(TRUE);
      LibraryAssembly.CreateAssemblyLine(AssemblyHeader,AssemblyLine,AssemblyLine.Type::Resource,Resource."No.",
        LibraryAssembly.GetUnitOfMeasureCode(AssemblyLine.Type::Resource,Resource."No.",TRUE),
        40 + LibraryRandom.RandDec(20,2),0,'');
      LibraryAssembly.UpdateOrderCost(AssemblyHeader);

      // Validate.
      VerifyOrderLines(AssemblyHeader."No.",TRUE);
      VerifyOrderHeader(AssemblyHeader."No.");
      VerifyInitialAssemblyList(TempBOMComponent,Item."No.");
Member of Lib.Library - Inventory


MakeItemJournalLine@23 Method

The procedure MakeItemJournalLine is available in codeunit 132201.

Syntax

MakeItemJournalLine@23(
    VAR ItemJournalLine@1000 : Record 83 ItemJournalLine, //Reference parameter of type Record
    ItemJournalBatch@1001 : Record 233 ItemJournalBatch, //Input parameter of type Record
    Item@1002 : Record 27 Item, //Input parameter of type Record
    PostingDate@1006 : Date PostingDate, //Input parameter of type Date
    EntryType@1004 : Option EntryType, //Input parameter of type Option
    Quantity@1003 : Decimal Quantity //Input parameter of type Decimal
);

Parameters

ItemJournalLine
Reference parameter of type Record
ItemJournalBatch
Input parameter of type Record
Item
Input parameter of type Record
PostingDate
Input parameter of type Date
EntryType
Input parameter of type Option
Quantity
Input parameter of type Decimal

Remarks

The relevant search keywords are: Make, Item, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(ItemJournalLine);
      ItemJournalLine."Journal Template Name" := ItemJournalBatch."Journal Template Name";
      ItemJournalLine."Journal Batch Name" := ItemJournalBatch.Name;
      ItemJournalLine."Posting Date" := PostingDate;
      ItemJournalLine."Entry Type" := EntryType;
      ItemJournalBatch.CALCFIELDS("Template Type");
      IF ItemJournalBatch."Template Type" = ItemJournalBatch."Template Type"::Revaluation THEN
        ItemJournalLine."Value Entry Type" := ItemJournalLine."Value Entry Type"::Revaluation;
      ItemJournalLine.VALIDATE("Item No.",Item."No.");
      ItemJournalLine.VALIDATE(Quantity,Quantity);
      ItemJournalLine."Document No." :=
        LibraryUtility.GenerateRandomCode(ItemJournalLine.FIELDNO("Document No."),DATABASE::"Item Journal Line");
      RecRef.GETTABLE(ItemJournalLine);
      ItemJournalLine."Line No." := LibraryUtility.GetNewLineNo(RecRef,ItemJournalLine.FIELDNO("Line No."));

Example

The below example is extracted from the test automation codeunit 137611 to show one way of using this function.

      LibraryInventory.CreateItemJournalBatchByType(ItemJournalBatch,ItemJournalBatch."Template Type"::Output);

      Item.GET(ProdOrderLine."Item No.");
      LibraryInventory.MakeItemJournalLine(
        ItemJournalLine,ItemJournalBatch,Item,WORKDATE,ItemJournalLine."Entry Type"::"Positive Adjmt.",0);
      ItemJournalLine.VALIDATE("Entry Type",ItemJournalLine."Entry Type"::Output);
      ItemJournalLine.VALIDATE("Order Type",ItemJournalLine."Order Type"::Production);
      ItemJournalLine.VALIDATE("Order No.",ProdOrderLine."Prod. Order No.");
      ItemJournalLine.VALIDATE("Order Line No.",ProdOrderLine."Line No.");
      ItemJournalLine.VALIDATE("Item No.",ProdOrderLine."Item No.");
      ItemJournalLine.SetUpNewLine(ItemJournalLine);
      ItemJournalLine.INSERT;
Member of Lib.Library - Inventory


NoSeriesSetup@444 Method

The procedure NoSeriesSetup is available in codeunit 132201.

Syntax

NoSeriesSetup@444(
    VAR InventorySetup@1000 : Record 313 InventorySetup //Reference parameter of type Record
);

Parameters

InventorySetup
Reference parameter of type Record

Remarks

The relevant search keywords are: No, Series, Setup.

For a clarification about how this function works, refer to the code listed below.

      InventorySetup.GET;
      InventorySetup.VALIDATE("Internal Movement Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      InventorySetup.VALIDATE("Inventory Movement Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      InventorySetup.VALIDATE("Inventory Pick Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      InventorySetup.VALIDATE("Item Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      InventorySetup.VALIDATE("Posted Invt. Pick Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      InventorySetup.VALIDATE("Posted Transfer Rcpt. Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      InventorySetup.VALIDATE("Posted Transfer Shpt. Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      InventorySetup.VALIDATE("Registered Invt. Movement Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      InventorySetup.VALIDATE("Transfer Order Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      InventorySetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134418 to show one way of using this function.

      IF Initialized THEN
        EXIT;

      Initialized := TRUE;
      LibraryERMCountryData.CreateVATData;
      LibraryERMCountryData.UpdateGeneralLedgerSetup;
      LibraryERMCountryData.UpdateGeneralPostingSetup;
      LibraryERMCountryData.UpdatePurchasesPayablesSetup;
      LibraryInventory.NoSeriesSetup(InventorySetup);
Member of Lib.Library - Inventory


OutputJnlExplRoute@13 Method

The procedure OutputJnlExplRoute is available in codeunit 132201.

Syntax

OutputJnlExplRoute@13(
    VAR ItemJournalLine@1000 : Record 83 ItemJournalLine //Reference parameter of type Record
);

Parameters

ItemJournalLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Output, Journal, Expl, Route.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(OutputJnlExplRoute);
      OutputJnlExplRoute.RUN(ItemJournalLine);

Example

The below example is extracted from the test automation codeunit 137001 to show one way of using this function.

      LibraryInventory.SelectItemJournalTemplateName(ItemJournalTemplate,Type);
      LibraryInventory.SelectItemJournalBatchName(
        ItemJournalBatch,ItemJournalBatch."Template Type"::Consumption,ItemJournalTemplate.Name);

      CASE Type OF
        ItemJournalTemplate.Type::Consumption:
          LibraryManufacturing.CalculateConsumption(ProductionOrderNo,ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name);
        ItemJournalTemplate.Type::Output:
          BEGIN
            LibraryInventory.ClearItemJournal(ItemJournalTemplate,ItemJournalBatch);
            LibraryManufacturing.CreateOutputJournal(ItemJournalLine,ItemJournalTemplate,ItemJournalBatch,'',ProductionOrderNo);
            LibraryInventory.OutputJnlExplRoute(ItemJournalLine);
          END;
      END;

      ItemJournalLine.SETRANGE("Journal Template Name",ItemJournalBatch."Journal Template Name");
      ItemJournalLine.SETRANGE("Journal Batch Name",ItemJournalBatch.Name);
      ItemJournalLine.FINDSET;
      REPEAT
        TempItemJournalLine := ItemJournalLine;
        TempItemJournalLine.INSERT;
      UNTIL ItemJournalLine.NEXT = 0;

      LibraryInventory.PostItemJournalLine(ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name);
Member of Lib.Library - Inventory


PostItemJournalBatch@5 Method

The procedure PostItemJournalBatch is available in codeunit 132201.

Syntax

PostItemJournalBatch@5(
    ItemJournalBatch@1000 : Record 233 ItemJournalBatch //Input parameter of type Record
);

Parameters

ItemJournalBatch
Input parameter of type Record

Remarks

The relevant search keywords are: Post, Item, Journal, Batch.

For a clarification about how this function works, refer to the code listed below.

      PostItemJournalLine(ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name);

Example

The below example is extracted from the test automation codeunit 137053 to show one way of using this function.

      LibraryPatterns.CalculateInventoryValueRun(ItemJournalBatch,Item,PostingDate,1,FALSE,FALSE,FALSE,0,FALSE,'','');
      ItemJournalLine.SETRANGE("Journal Template Name",ItemJournalBatch."Journal Template Name");
      ItemJournalLine.SETRANGE("Journal Batch Name",ItemJournalBatch.Name);
      ItemJournalLine.FINDFIRST;
      ItemJournalLine.VALIDATE("Inventory Value (Revalued)",RevaluedInvValue);
      ItemJournalLine.MODIFY;
      LibraryInventory.PostItemJournalBatch(ItemJournalBatch);
Member of Lib.Library - Inventory


PostItemJournalLine@45 Method

The procedure PostItemJournalLine is available in codeunit 132201.

Syntax

PostItemJournalLine@45(
    JournalTemplateName@1001 : Text[10] JournalTemplateName, //Input parameter of type Text
    JournalBatchName@1002 : Text[10] JournalBatchName //Input parameter of type Text
);

Parameters

JournalTemplateName
Input parameter of type Text
JournalBatchName
Input parameter of type Text

Remarks

The relevant search keywords are: Post, Item, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      ItemJournalLine.INIT;
      ItemJournalLine.VALIDATE("Journal Template Name",JournalTemplateName);
      ItemJournalLine.VALIDATE("Journal Batch Name",JournalBatchName);
      CODEUNIT.RUN(CODEUNIT::"Item Jnl.-Post Batch",ItemJournalLine);

Example

The below example is extracted from the test automation codeunit 134063 to show one way of using this function.

      SelectItemJournalBatch(ItemJournalBatch);
      LibraryInventory.CreateItemJournalLine(
        ItemJournalLine,ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name,EntryType,ItemNo,
        LibraryRandom.RandDec(100,2) * 100);
      ItemJournalLine.VALIDATE("Transaction Type",TransactionType);
      ItemJournalLine.VALIDATE("Transport Method",TransportMethod);
      ItemJournalLine.VALIDATE("Country/Region Code",CountryRegionCode);
      ItemJournalLine.MODIFY(TRUE);
      LibraryInventory.PostItemJournalLine(ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name);
Member of Lib.Library - Inventory


PostTransferHeader@43 Method

The procedure PostTransferHeader is available in codeunit 132201.

Syntax

PostTransferHeader@43(
    VAR TransferHeader@1000 : Record 5740 TransferHeader, //Reference parameter of type Record
    Ship@1001 : Boolean Ship, //Input parameter of type Boolean
    Receive@1002 : Boolean Receive //Input parameter of type Boolean
);

Parameters

TransferHeader
Reference parameter of type Record
Ship
Input parameter of type Boolean
Receive
Input parameter of type Boolean

Remarks

The relevant search keywords are: Post, Transfer, Header.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(TransferOrderPostShipment);
      IF Ship THEN
        TransferOrderPostShipment.RUN(TransferHeader);
      IF Receive THEN BEGIN
        TransferOrderPostReceipt.SetHideValidationDialog(TRUE);
        TransferOrderPostReceipt.RUN(TransferHeader);
      END;

Example

The below example is extracted from the test automation codeunit 137007 to show one way of using this function.

      // [FEATURE] [Adjust Cost - Item Entries]
      // [SCENARIO 380442] "Applied Enry to Adjust" mark should be removed when the entry is closed and invoiced, and all open applied outbounds have other cost sources

      Initialize;
      // [GIVEN] Item "I" with FIFO costing method
      CreateItemWithCostingMethod(Item,Item."Costing Method"::FIFO);

      // [GIVEN] Two locations "L1" and "L2", and a transit location
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location[1]);
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location[2]);
      LibraryWarehouse.CreateInTransitLocation(Location[3]);

      // [GIVEN] Purchase 3 pcs of item "I" on location "L1". Unit cost = 2.4875. Receive only.
      CreatePurchaseOrderPostReceipt(PurchaseHeader[1],LibraryPurchase.CreateVendorNo,Location[1].Code,Item."No.",3,2.4875);
      // [GIVEN] Purchase 3 pcs of item "I" on location "L2". Unit cost = 2.48827. Receive only.
      CreatePurchaseOrderPostReceipt(PurchaseHeader[2],PurchaseHeader[1]."Buy-from Vendor No.",Location[1].Code,Item."No.",3,2.48827);

      // [GIVEN] Create a transfer order from location "L1" to "L2". Split transfer into 5 lines with quantitues: 1, 1, 2, 1, 1
      // [GIVEN] Post transfer
      LibraryInventory.CreateTransferHeader(TransferHeader,Location[1].Code,Location[2].Code,Location[3].Code);
      LibraryInventory.CreateTransferLine(TransferHeader,TransferLine,Item."No.",1);
      LibraryInventory.CreateTransferLine(TransferHeader,TransferLine,Item."No.",1);
      LibraryInventory.CreateTransferLine(TransferHeader,TransferLine,Item."No.",2);
      LibraryInventory.CreateTransferLine(TransferHeader,TransferLine,Item."No.",1);
      LibraryInventory.CreateTransferLine(TransferHeader,TransferLine,Item."No.",1);
      LibraryInventory.PostTransferHeader(TransferHeader,TRUE,TRUE);

      // [GIVEN] Invoice the first purchase order
      PurchInvoiceNo := LibraryPurchase.PostPurchaseDocument(PurchaseHeader[1],FALSE,TRUE);

      // [WHEN] Run cost adjustment
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');

      // [THEN] First receipt item ledger entry is rounded
      // [THEN] Receipt entry is not marked as "Applied entry to adjust"
      VerifyAppliedEntryToAdjust(Item."No.");
      VerifyItemLedgerEntryRounding(PurchInvoiceNo);

      // [WHEN] Invoice remaining purchase quantity, adjust cost
      PurchInvoiceNo := LibraryPurchase.PostPurchaseDocument(PurchaseHeader[2],FALSE,TRUE);
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');

      // [THEN] Second receipt item ledger entry is rounded
      VerifyAppliedEntryToAdjust(Item."No.");
      VerifyItemLedgerEntryRounding(PurchInvoiceNo);
Member of Lib.Library - Inventory


ReleaseSalesOrder@78 Method

The procedure ReleaseSalesOrder is available in codeunit 132201.

Syntax

ReleaseSalesOrder@78(
    VAR SalesHeader@1000 : Record 36 SalesHeader //Reference parameter of type Record
);

Parameters

SalesHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Release, Sales, Order.

For a clarification about how this function works, refer to the code listed below.

      ReleaseSalesDoc.PerformManualRelease(SalesHeader);

Example

There are no examples available.
Member of Lib.Library - Inventory


ReleaseTransferOrder@100 Method

The procedure ReleaseTransferOrder is available in codeunit 132201.

Syntax

ReleaseTransferOrder@100(
    VAR TransferHeader@1001 : Record 5740 TransferHeader //Reference parameter of type Record
);

Parameters

TransferHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Release, Transfer, Order.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(ReleaseTransferDocument);
      ReleaseTransferDocument.RUN(TransferHeader);

Example

The below example is extracted from the test automation codeunit 137021 to show one way of using this function.

      // Setup
      Initialize;

      // Test setup
      TestSetup;
      LFLItemSetup(Item,TRUE,'','','',0,0,0);

      // Exercise
      CreateSalesReturnOrder(SalesHeader,Item,1,CALCDATE(PlanningStartDate,CALCDATE('<+1W+1D>',WORKDATE)),LocationOne.Code);
      CreateTransferOrder(
        TransferHeader,Item."No.",LocationWhite.Code,LocationOne.Code,CALCDATE(PlanningStartDate,CALCDATE('<+1W+1D>',WORKDATE)),1);
      LibraryWarehouse.ReleaseTransferOrder(TransferHeader);
      LibraryWarehouse.CreateWhseShipmentFromTO(TransferHeader);
      SalesPlan(Item,1,CALCDATE(PlanningStartDate,CALCDATE('<+1W+1D>',WORKDATE)),LocationOne.Code,LocationOne.Code);

      // Verify planning worksheet lines - check in doc section more info on the TDS
      AssertNumberOfLinesForItem(Item,1);
      AssertPlanningLine(Item,RequisitionLine."Action Message"::Cancel,0D,
        CALCDATE(PlanningStartDate,CALCDATE('<+1W+1D>',WORKDATE)),1,0,RequisitionLine."Ref. Order Type"::Transfer,'',1);
Member of Lib.Library - Inventory


ReopenTransferOrder@11 Method

The procedure ReopenTransferOrder is available in codeunit 132201.

Syntax

ReopenTransferOrder@11(
    VAR TransferHeader@1001 : Record 5740 TransferHeader //Reference parameter of type Record
);

Parameters

TransferHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Reopen, Transfer, Order.

For a clarification about how this function works, refer to the code listed below.

      ReleaseTransferDocument.Reopen(TransferHeader);

Example

The below example is extracted from the test automation codeunit 137038 to show one way of using this function.

      // [FEATURE] [Warehouse Request] [Warehouse Receipt]
      // [SCENARIO 381426] Warehouse Request is created for shipped not received Transfer Order when "Require Receipt" is set on destination Location. The status of the Whse. Request matches the status of the Transfer Order.
      Initialize;

      // [GIVEN] Item with inventory on Location "L1".
      // [GIVEN] Two partially shipped not received Transfer Orders "T1", "T2" from "L1" to Location "L2".
      CreateTwoPartlyShipTransferOrders(TransferHeader,TRUE);

      // [GIVEN] "T2" is re-opened.
      LibraryWarehouse.ReopenTransferOrder(TransferHeader[2]);

      // [WHEN] Turn on "Require Receipt" on "L2".
      Location.GET(TransferHeader[1]."Transfer-to Code");
      Location.VALIDATE("Require Receive",TRUE);

      // [THEN] Warehouse Request with "Released" status is created for "T1".
      WarehouseRequest.GET(
        WarehouseRequest.Type::Inbound,Location.Code,DATABASE::"Transfer Line",1,TransferHeader[1]."No.");
      WarehouseRequest.TESTFIELD("Document Status",TransferHeader[1].Status::Released);

      // [THEN] Warehouse Request with "Open" status is created for "T2".
      WarehouseRequest.GET(
        WarehouseRequest.Type::Inbound,Location.Code,DATABASE::"Transfer Line",1,TransferHeader[2]."No.");
      WarehouseRequest.TESTFIELD("Document Status",TransferHeader[2].Status::Open);
Member of Lib.Library - Inventory


SaveAsStandardJournal@127 Method

The procedure SaveAsStandardJournal is available in codeunit 132201.

Syntax

SaveAsStandardJournal@127(
    VAR GenJournalBatch@1000 : Record 232 GenJournalBatch, //Reference parameter of type Record
    Code@1004 : Code[10] Code, //Input parameter of type Code
    SaveAmount@1005 : Boolean SaveAmount //Input parameter of type Boolean
);

Parameters

GenJournalBatch
Reference parameter of type Record
Code
Input parameter of type Code
SaveAmount
Input parameter of type Boolean

Remarks

The relevant search keywords are: Save, As, Standard, Journal.

For a clarification about how this function works, refer to the code listed below.

      GenJournalLine.SETRANGE("Journal Template Name",GenJournalBatch."Journal Template Name");
      GenJournalLine.SETRANGE("Journal Batch Name",GenJournalBatch.Name);
      SaveAsStandardGenJournal.Initialise(GenJournalLine,GenJournalBatch);
      SaveAsStandardGenJournal.InitializeRequest(Code,'',SaveAmount);
      SaveAsStandardGenJournal.USEREQUESTPAGE(FALSE);
      SaveAsStandardGenJournal.RUNMODAL;
      IF NOT SaveAsStandardGenJournal.GetStdGeneralJournal(StandardGeneralJournal) THEN;

Example

The below example is extracted from the test automation codeunit 137043 to show one way of using this function.

      // Setup : Create General Journal Template and General Journal Batch.
      // Create Multiple General Lines and save Them as standard Journal.
      Initialize;
      CreateGenJournalTemplateBatch(GenJournalBatch);
      CreateGenJournalLines(GenJournalBatch,StandardGeneralJournalCode);
      DeleteAndGetStandardJournal(GenJournalLine,GenJournalBatch,StandardGeneralJournalCode);

      // Exercise : Save standard Journal.
      LibraryInventory.SaveAsStandardJournal(GenJournalBatch,StandardGeneralJournalCode,TRUE);

      // Verify : Verify Number Standard General Journal Created.
      // Verify : Verify General Journal Line Inserted through Get STandard Journal.
      VerifyStandardGeneralJournal(GenJournalBatch."Journal Template Name",3);
      VerifyGenJournalLine(GenJournalBatch);

      // Tear Down : Delete General Lines Created.
      DeleteGenJournalLine(GenJournalLine,GenJournalBatch."Journal Template Name",GenJournalBatch.Name);
Member of Lib.Library - Inventory


SelectCustomer@103 Method

The procedure SelectCustomer is available in codeunit 132201.

Syntax

SelectCustomer@103(
      //param element not supplied
);

Return Value

Code[20]

Remarks

The relevant search keywords are: Select, Customer.

For a clarification about how this function works, refer to the code listed below.

      // Select a customer and modify if Currency Code and Location Code not are blank.
      Customer.SETRANGE("Currency Code",'');
      Customer.SETRANGE("Location Code",'');
      IF NOT Customer.FINDFIRST THEN BEGIN
        Customer.RESET;
        Customer.FINDFIRST;
        Customer.VALIDATE("Currency Code",'');
        Customer.VALIDATE("Location Code",'');
        Customer.MODIFY(TRUE);
      END;
      EXIT(Customer."No.");

Example

There are no examples available.
Member of Lib.Library - Inventory


SelectGenPostingSetup@48 Method

The procedure SelectGenPostingSetup is available in codeunit 132201.

Syntax

SelectGenPostingSetup@48(
    VAR GeneralPostingSetup@1000 : Record 252 GeneralPostingSetup //Reference parameter of type Record
);

Parameters

GeneralPostingSetup
Reference parameter of type Record

Remarks

The relevant search keywords are: Select, General, Posting, Setup.

For a clarification about how this function works, refer to the code listed below.

      // Filter General Posting Setup so that errors are not generated due to mandatory fields.
      GeneralPostingSetup.SETFILTER("Gen. Bus. Posting Group",'<>%1','');
      GeneralPostingSetup.SETFILTER("Gen. Prod. Posting Group",'<>%1','');
      GeneralPostingSetup.SETFILTER("Sales Account",'<>%1','');
      GeneralPostingSetup.SETFILTER("Purch. Account",'<>%1','');
      GeneralPostingSetup.SETFILTER("COGS Account",'<>%1','');
      GeneralPostingSetup.SETFILTER("COGS Account (Interim)",'<>''''');
      GeneralPostingSetup.SETFILTER("Inventory Adjmt. Account",'<>%1','');
      GeneralPostingSetup.SETFILTER("Sales Credit Memo Account",'<>%1','');
      GeneralPostingSetup.SETFILTER("Purch. Credit Memo Account",'<>%1','');
      GeneralPostingSetup.SETFILTER("Direct Cost Applied Account",'<>%1','');
      GeneralPostingSetup.SETFILTER("Overhead Applied Account",'<>%1','');
      GeneralPostingSetup.SETFILTER("Purchase Variance Account",'<>%1','');
      GeneralPostingSetup.SETFILTER("Sales Prepayments Account",'<>%1','');
      GeneralPostingSetup.SETFILTER("Purch. Prepayments Account",'<>%1','');
      GeneralPostingSetup.FINDFIRST;

Example

There are no examples available.
Member of Lib.Library - Inventory


SelectItemJournalBatchName@53 Method

The procedure SelectItemJournalBatchName is available in codeunit 132201.

Syntax

SelectItemJournalBatchName@53(
    VAR ItemJournalBatch@1000 : Record 233 ItemJournalBatch, //Reference parameter of type Record
    ItemJournalBatchTemplateType@1001 : Option ItemJournalBatchTemplateType, //Input parameter of type Option
    ItemJournalTemplateName@1002 : Code[10] ItemJournalTemplateName //Input parameter of type Code
);

Parameters

ItemJournalBatch
Reference parameter of type Record
ItemJournalBatchTemplateType
Input parameter of type Option
ItemJournalTemplateName
Input parameter of type Code

Remarks

The relevant search keywords are: Select, Item, Journal, Batch, Name.

For a clarification about how this function works, refer to the code listed below.

      // Find Name for Batch Name.
      ItemJournalBatch.SETRANGE("Template Type",ItemJournalBatchTemplateType);
      ItemJournalBatch.SETRANGE("Journal Template Name",ItemJournalTemplateName);

      // If Item Journal Batch not found then create it.
      IF NOT ItemJournalBatch.FINDFIRST THEN
        CreateItemJournalBatch(ItemJournalBatch,ItemJournalTemplateName);

Example

The below example is extracted from the test automation codeunit 134063 to show one way of using this function.

      LibraryInventory.SelectItemJournalTemplateName(ItemJournalTemplate,ItemJournalTemplate.Type::Item);
      LibraryInventory.SelectItemJournalBatchName(ItemJournalBatch,ItemJournalTemplate.Type::Item,ItemJournalTemplate.Name);
      ItemJournalBatch.VALIDATE("No. Series",LibraryUtility.GetGlobalNoSeriesCode);
      ItemJournalBatch.MODIFY(TRUE);
Member of Lib.Library - Inventory


SelectItemJournalTemplateName@54 Method

The procedure SelectItemJournalTemplateName is available in codeunit 132201.

Syntax

SelectItemJournalTemplateName@54(
    VAR ItemJournalTemplate@1000 : Record 82 ItemJournalTemplate, //Reference parameter of type Record
    ItemJournalTemplateType@1001 : Option ItemJournalTemplateType //Input parameter of type Option
);

Parameters

ItemJournalTemplate
Reference parameter of type Record
ItemJournalTemplateType
Input parameter of type Option

Remarks

The relevant search keywords are: Select, Item, Journal, Template, Name.

For a clarification about how this function works, refer to the code listed below.

      // Find Item Journal Template for the given Template Type.
      ItemJournalTemplate.SETRANGE(Type,ItemJournalTemplateType);
      ItemJournalTemplate.SETRANGE(Recurring,FALSE);
      IF NOT ItemJournalTemplate.FINDFIRST THEN
        CreateItemJournalTemplate(ItemJournalTemplate);

Example

The below example is extracted from the test automation codeunit 134063 to show one way of using this function.

      LibraryInventory.SelectItemJournalTemplateName(ItemJournalTemplate,ItemJournalTemplate.Type::Item);
      LibraryInventory.SelectItemJournalBatchName(ItemJournalBatch,ItemJournalTemplate.Type::Item,ItemJournalTemplate.Name);
      ItemJournalBatch.VALIDATE("No. Series",LibraryUtility.GetGlobalNoSeriesCode);
      ItemJournalBatch.MODIFY(TRUE);
Member of Lib.Library - Inventory


SelectVATPostingSetup@79 Method

The procedure SelectVATPostingSetup is available in codeunit 132201.

Syntax

SelectVATPostingSetup@79(
    VAR VATPostingSetup@1001 : Record 325 VATPostingSetup //Reference parameter of type Record
);

Parameters

VATPostingSetup
Reference parameter of type Record

Remarks

The relevant search keywords are: Select, VAT, Posting, Setup.

For a clarification about how this function works, refer to the code listed below.

      // Filter VAT Posting Setup so that errors are not generated due to mandatory fields.
      VATPostingSetup.SETFILTER("VAT Prod. Posting Group",'<>%1','');
      VATPostingSetup.FINDFIRST;

Example

The below example is extracted from the test automation codeunit 134551 to show one way of using this function.

      LibraryInventory.SelectVATPostingSetup(VATPostingSetup);
      CreateSalesOrder(SalesHeader,PricesInclVAT,VATPostingSetup."VAT Bus. Posting Group");
      SetPrepaymentPctOnSalesHeader(SalesHeader,SalesHeader."Prepayment %" + LibraryRandom.RandDec(10,2));
      CreateTwoSalesOrderLines(SalesHeader,SalesLine,VATPostingSetup."VAT Prod. Posting Group");
Member of Lib.Library - Inventory


SetAutomaticCostAdjmtAlways@12 Method

The procedure SetAutomaticCostAdjmtAlways is available in codeunit 132201.

Syntax

SetAutomaticCostAdjmtAlways@12(
      //param element not supplied
);

Remarks

The relevant search keywords are: Set, Automatic, Cost, Adjmt, Always.

For a clarification about how this function works, refer to the code listed below.

      InventorySetup.GET;
      InventorySetup."Automatic Cost Adjustment" := InventorySetup."Automatic Cost Adjustment"::Always;
      InventorySetup.MODIFY;

Example

The below example is extracted from the test automation codeunit 136306 to show one way of using this function.

      // [FEATURE] [Adjust Cost Item Entries] [Update Job Item Cost]
      // [SCENARIO 234898] Cost amount in job ledger entries should be updated when item cost is automatically adjusted on invoice posting, and automatic update of job item cost is enabled

      Initialize;

      // [GIVEN] Enable automatic cost adjustment and automatic update job item cost
      LibraryInventory.SetAutomaticCostAdjmtAlways;
      LibraryJob.SetAutomaticUpdateJobItemCost(TRUE);

      // [GIVEN] Item "I" with no cost amount defined
      LibraryInventory.CreateItem(Item);

      // [GIVEN] Create purchase order for item "I" and post receipt
      LibraryPurchase.CreatePurchHeader(PurchaseHeader,PurchaseHeader."Document Type"::Order,LibraryPurchase.CreateVendorNo);
      LibraryPurchase.CreatePurchaseLine(PurchaseLine,PurchaseHeader,PurchaseLine.Type::Item,Item."No.",LibraryRandom.RandInt(10));
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,FALSE);

      // [GIVEN] Post a billable job journal line for item "I"
      CreateJobWithJobTask(JobTask);
      CreatePostJobJournalLineWithItem(JobTask,Item."No.");

      // [GIVEN] Reopen the purchase order and update direct unit cost to "10"
      LibraryPurchase.ReopenPurchaseDocument(PurchaseHeader);

      UnitCost := LibraryRandom.RandInt(100);
      PurchaseLine.FIND;
      PurchaseLine.VALIDATE("Direct Unit Cost",UnitCost);
      PurchaseLine.MODIFY(TRUE);

      // [WHEN] Post the purchase invoice
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,FALSE,TRUE);

      // [THEN] "Unit Cost" in the item card "I" is "10"
      Item.FIND;
      Item.TESTFIELD("Unit Cost",UnitCost);

      // [THEN] "Unit Cost" in the job ledger entry created from the job journal is "10"
      VerifyJobLedgerEntryUnitCost(JobTask,Item."No.",UnitCost);
Member of Lib.Library - Inventory


SetAutomaticCostAdjmtNever@19 Method

The procedure SetAutomaticCostAdjmtNever is available in codeunit 132201.

Syntax

SetAutomaticCostAdjmtNever@19(
      //param element not supplied
);

Remarks

The relevant search keywords are: Set, Automatic, Cost, Adjmt, Never.

For a clarification about how this function works, refer to the code listed below.

      InventorySetup.GET;
      InventorySetup."Automatic Cost Adjustment" := InventorySetup."Automatic Cost Adjustment"::Never;
      InventorySetup.MODIFY;

Example

The below example is extracted from the test automation codeunit 137402 to show one way of using this function.

      RunAdjustCostItemEntries('');
      LibraryInventory.SetAutomaticCostPosting(FALSE);
      LibraryInventory.SetAutomaticCostAdjmtNever;
Member of Lib.Library - Inventory


SetAutomaticCostPosting@10 Method

The procedure SetAutomaticCostPosting is available in codeunit 132201.

Syntax

SetAutomaticCostPosting@10(
    AutomaticCostPosting@1000 : Boolean AutomaticCostPosting //Input parameter of type Boolean
);

Parameters

AutomaticCostPosting
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, Automatic, Cost, Posting.

For a clarification about how this function works, refer to the code listed below.

      InventorySetup.GET;
      InventorySetup."Automatic Cost Posting" := AutomaticCostPosting;
      InventorySetup.MODIFY;

Example

The below example is extracted from the test automation codeunit 134763 to show one way of using this function.

      // [FEATURE] [Posting Preview]
      // [SCENARIO 378536] Preview action can be opened for Sales Order with FIFO Item, if was before posted partially several times.
      Initialize;

      // [GIVEN] Inventory Setup: Automatic Cost Posting = TRUE, Expected Cost Posting = TRUE
      LibraryInventory.SetAutomaticCostPosting(TRUE);
      LibraryInventory.SetExpectedCostPosting(TRUE);

      // [GIVEN] Item with Lot Tracking and Costing Method FIFO
      ItemNo := CreateItemWithFIFO;
      CreateAndPostItemJournalLine(ItemNo,LibraryRandom.RandDecInRange(10,20,2));

      // [GIVEN] Create Sales Order, Ship and Invoice partially
      LibrarySales.CreateSalesHeader(SalesHeader,SalesHeader."Document Type"::Order,LibrarySales.CreateCustomerNo);
      LibrarySales.CreateSalesLine(SalesLine,SalesHeader,SalesLine.Type::Item,ItemNo,LibraryRandom.RandIntInRange(5,10));
      PostPartialQuantity(SalesHeader,TRUE);

      // [GIVEN] Ship Sales Order again partially
      PostPartialQuantity(SalesHeader,FALSE);

      // [WHEN] Open Post Preview
      GLPostingPreview.TRAP;
      ASSERTERROR SalesPostYesNo.Preview(SalesHeader);

      // [THEN] Preview is open
      Assert.AreEqual('',GETLASTERRORTEXT,WrongPostPreviewErr + GETLASTERRORTEXT);
Member of Lib.Library - Inventory


SetAverageCostSetup@16 Method

The procedure SetAverageCostSetup is available in codeunit 132201.

Syntax

SetAverageCostSetup@16(
    AverageCostCalcType@1000 : Option AverageCostCalcType, //Input parameter of type Option
    AverageCostPeriod@1001 : Option AverageCostPeriod //Input parameter of type Option
);

Parameters

AverageCostCalcType
Input parameter of type Option
AverageCostPeriod
Input parameter of type Option

Remarks

The relevant search keywords are: Set, Average, Cost, Setup.

For a clarification about how this function works, refer to the code listed below.

      InventorySetup.GET;
      InventorySetup."Average Cost Calc. Type" := AverageCostCalcType;
      InventorySetup."Average Cost Period" := AverageCostPeriod;
      InventorySetup.MODIFY;

Example

The below example is extracted from the test automation codeunit 137007 to show one way of using this function.

      // [FEATURE] [Revaluation] [Average Costing Method]
      // [SCENARIO 379224] Cost Amount of Item with Average Costing Method and big Inventory should be equal to what was posted by Revaluation Journal. Average Cost is calculated by Item.
      Initialize;

      RaiseMessageHandler;
      RaiseConfirmHandler;
      LibraryInventory.SetAverageCostSetup(AverageCostCalcType::Item,AverageCostPeriod::Week);

      // [GIVEN] Item with Average Costing Method and big Inventory.
      // [GIVEN] Calculated Inventory Value by Item in Revaluation Journal, "Inventory Value (Revalued)" field is updated to 'R'.
      CreateAndRevalueInventory(ItemJournalLine,RevaluedAmount,FALSE,FALSE);

      // [WHEN] Post Revaluation.
      LibraryInventory.PostItemJournalLine(ItemJournalLine."Journal Template Name",ItemJournalLine."Journal Batch Name");

      // [THEN] Sum of "Cost Amount (Actual)" in Value Entry is equal to 'R'.
      VerifyValueEntryCostAmount(ItemJournalLine,RevaluedAmount);
Member of Lib.Library - Inventory


SetExpectedCostPosting@15 Method

The procedure SetExpectedCostPosting is available in codeunit 132201.

Syntax

SetExpectedCostPosting@15(
    ExpectedCostPosting@1000 : Boolean ExpectedCostPosting //Input parameter of type Boolean
);

Parameters

ExpectedCostPosting
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, Expected, Cost, Posting.

For a clarification about how this function works, refer to the code listed below.

      InventorySetup.GET;
      InventorySetup."Expected Cost Posting to G/L" := ExpectedCostPosting;
      InventorySetup.MODIFY;

Example

The below example is extracted from the test automation codeunit 134763 to show one way of using this function.

      // [FEATURE] [Posting Preview]
      // [SCENARIO 378536] Preview action can be opened for Sales Order with FIFO Item, if was before posted partially several times.
      Initialize;

      // [GIVEN] Inventory Setup: Automatic Cost Posting = TRUE, Expected Cost Posting = TRUE
      LibraryInventory.SetAutomaticCostPosting(TRUE);
      LibraryInventory.SetExpectedCostPosting(TRUE);

      // [GIVEN] Item with Lot Tracking and Costing Method FIFO
      ItemNo := CreateItemWithFIFO;
      CreateAndPostItemJournalLine(ItemNo,LibraryRandom.RandDecInRange(10,20,2));

      // [GIVEN] Create Sales Order, Ship and Invoice partially
      LibrarySales.CreateSalesHeader(SalesHeader,SalesHeader."Document Type"::Order,LibrarySales.CreateCustomerNo);
      LibrarySales.CreateSalesLine(SalesLine,SalesHeader,SalesLine.Type::Item,ItemNo,LibraryRandom.RandIntInRange(5,10));
      PostPartialQuantity(SalesHeader,TRUE);

      // [GIVEN] Ship Sales Order again partially
      PostPartialQuantity(SalesHeader,FALSE);

      // [WHEN] Open Post Preview
      GLPostingPreview.TRAP;
      ASSERTERROR SalesPostYesNo.Preview(SalesHeader);

      // [THEN] Preview is open
      Assert.AreEqual('',GETLASTERRORTEXT,WrongPostPreviewErr + GETLASTERRORTEXT);
Member of Lib.Library - Inventory


SetLocationMandatory@14 Method

The procedure SetLocationMandatory is available in codeunit 132201.

Syntax

SetLocationMandatory@14(
    LocationMandatory@1000 : Boolean LocationMandatory //Input parameter of type Boolean
);

Parameters

LocationMandatory
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, Location, Mandatory.

For a clarification about how this function works, refer to the code listed below.

      InventorySetup.GET;
      InventorySetup."Location Mandatory" := LocationMandatory;
      InventorySetup.MODIFY;

Example

The below example is extracted from the test automation codeunit 136353 to show one way of using this function.

      // [FEATURE] [Order Promising] [Location Mandatory]
      // [SCENARIO 375033] If Location is set as mandatory, then it should be possible to create Order Promising from Job Planning Line with specified Location
      Initialize;

      // [GIVEN] Inventory Setup, where "Location Mondatory" is Yes
      LibraryInventory.SetLocationMandatory(TRUE);

      // [GIVEN] Job Planning Line with filled "Location Code"
      LibraryWarehouse.CreateLocation(Location);
      CreateJobPlanningLineWithLocation(JobPlanningLine,Location.Code);

      // [WHEN] Open Order Promising page from Job Planning Line
      OpenOrderPromissingPage(JobPlanningLine);

      // [THEN] Order Promising page is successfully opened
      // Is checked in OrderPromisingModalPagehandler
Member of Lib.Library - Inventory


SetPreventNegativeInventory@17 Method

The procedure SetPreventNegativeInventory is available in codeunit 132201.

Syntax

SetPreventNegativeInventory@17(
    PreventNegativeInventory@1000 : Boolean PreventNegativeInventory //Input parameter of type Boolean
);

Parameters

PreventNegativeInventory
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, Prevent, Negative, Inventory.

For a clarification about how this function works, refer to the code listed below.

      InventorySetup.GET;
      InventorySetup."Prevent Negative Inventory" := PreventNegativeInventory;
      InventorySetup.MODIFY;

Example

The below example is extracted from the test automation codeunit 136302 to show one way of using this function.

      // [FEATURE] [Purchase Order]
      // [SCENARIO 380652] Purchase Order with negative quantity and job is posted together with a paired entry of item acquisition. The Order is fully applied to this acquisition.
      Initialize;

      // [GIVEN] Negative inventory is disallowed.
      // [GIVEN] Purchase Order for negative quantity with Job No. and Job Task No. selected.
      LibraryInventory.SetPreventNegativeInventory(TRUE);
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location);
      CreatePurchaseDocumentWithLocationAndJob(
        PurchaseHeader,PurchaseLine,PurchaseHeader."Document Type"::Order,Location.Code,-1);

      // [WHEN] Post the Purchase Order.
      DocumentNo := LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,FALSE);

      // [THEN] The Purchase Order is successfully posted.
      // [THEN] Item Ledger Entry with "Negative Adjmt." type and positive quantity with the Job No. (acquisition) is created.
      VerifyItemLedgerEntry(
        ItemLedgerEntry."Entry Type"::"Negative Adjmt.",PurchaseLine."No.",
        ItemLedgerEntry."Document Type"::"Purchase Receipt",DocumentNo,
        PurchaseLine."Job No.",-PurchaseLine.Quantity,0,0,-PurchaseLine."Line Amount");
      VerifyItemLedgerEntry(
        ItemLedgerEntry."Entry Type"::Purchase,PurchaseLine."No.",
        ItemLedgerEntry."Document Type"::"Purchase Receipt",DocumentNo,
        PurchaseLine."Job No.",PurchaseLine.Quantity,0,0,PurchaseLine."Line Amount");

      // [THEN] The Order is fully applied to the acquisition.
      VerifyItemApplicationEntry(PurchaseLine);
Member of Lib.Library - Inventory


UpdateGenProdPostingSetup@56 Method

The procedure UpdateGenProdPostingSetup is available in codeunit 132201.

Syntax

UpdateGenProdPostingSetup@56(
      //param element not supplied
);

Remarks

The relevant search keywords are: Update, General, Product, Posting, Setup.

For a clarification about how this function works, refer to the code listed below.

      IF GeneralPostingSetup.FINDSET THEN
      REPEAT
        IF GeneralPostingSetup."Sales Account" = '' THEN
            GeneralPostingSetup.VALIDATE("Sales Account",LibraryERM.CreateGLAccountNo);
        IF GeneralPostingSetup."Purch. Account" = '' THEN
            GeneralPostingSetup.VALIDATE("Purch. Account",GeneralPostingSetup."Sales Account");
        IF GeneralPostingSetup."COGS Account" = '' THEN
            GeneralPostingSetup.VALIDATE("COGS Account",GeneralPostingSetup."Sales Account");
        IF GeneralPostingSetup."Inventory Adjmt. Account" = '' THEN
            GeneralPostingSetup.VALIDATE("Inventory Adjmt. Account",GeneralPostingSetup."Sales Account");
        IF GeneralPostingSetup."COGS Account (Interim)" = '' THEN
            GeneralPostingSetup.VALIDATE("COGS Account (Interim)",GeneralPostingSetup."Sales Account");
        IF GeneralPostingSetup."Direct Cost Applied Account" = '' THEN
            GeneralPostingSetup.VALIDATE("Direct Cost Applied Account",GeneralPostingSetup."Sales Account");
          IF GeneralPostingSetup."Purchase Variance Account" = '' THEN
            GeneralPostingSetup.VALIDATE("Purchase Variance Account",GeneralPostingSetup."Sales Account");
        IF GeneralPostingSetup."Purch. Credit Memo Account" = '' THEN
            GeneralPostingSetup.VALIDATE("Purch. Credit Memo Account",GeneralPostingSetup."Sales Account");
        IF GeneralPostingSetup."Sales Credit Memo Account" = '' THEN
            GeneralPostingSetup.VALIDATE("Sales Credit Memo Account",GeneralPostingSetup."Sales Account");
        IF GeneralPostingSetup."Sales Prepayments Account" = '' THEN
            GeneralPostingSetup.VALIDATE("Sales Prepayments Account",LibraryERM.CreateGLAccountWithSalesSetup);
        IF GeneralPostingSetup."Purch. Prepayments Account" = '' THEN
            GeneralPostingSetup.VALIDATE("Purch. Prepayments Account",LibraryERM.CreateGLAccountWithPurchSetup);
        GeneralPostingSetup.MODIFY(TRUE);
      UNTIL GeneralPostingSetup.NEXT = 0;

Example

The below example is extracted from the test automation codeunit 134101 to show one way of using this function.

      LibraryVariableStorage.Clear;
      IF isInitialized THEN
        EXIT;

      LibraryPurchase.SetInvoiceRounding(FALSE);
      LibrarySales.SetInvoiceRounding(FALSE);
      LibraryERMCountryData.CreateVATData;
      LibraryERMCountryData.UpdatePrepaymentAccounts;
      LibraryERMCountryData.UpdatePurchasesPayablesSetup;
      LibraryInventory.UpdateGenProdPostingSetup;
      LibraryERMCountryData.RemoveBlankGenJournalTemplate;
      LibraryERMCountryData.UpdateGeneralLedgerSetup;
      LibraryERMCountryData.UpdateGeneralPostingSetup;
      LibraryERMCountryData.UpdateSalesReceivablesSetup;
      UpdateInventorySetupCostPosting;

      isInitialized := TRUE;
      COMMIT;
Member of Lib.Library - Inventory


UpdateInventoryPostingSetup@57 Method

The procedure UpdateInventoryPostingSetup is available in codeunit 132201.

Syntax

UpdateInventoryPostingSetup@57(
    Location@1000 : Record 14 Location //Input parameter of type Record
);

Parameters

Location
Input parameter of type Record

Remarks

The relevant search keywords are: Update, Inventory, Posting, Setup.

For a clarification about how this function works, refer to the code listed below.

      IF InventoryPostingGroup.FINDSET THEN
        REPEAT
          InventoryPostingSetup.SETRANGE("Location Code",Location.Code);
          InventoryPostingSetup.SETRANGE("Invt. Posting Group Code",InventoryPostingGroup.Code);
          IF NOT InventoryPostingSetup.FINDFIRST THEN
            CreateInventoryPostingSetup(InventoryPostingSetup,Location.Code,InventoryPostingGroup.Code);
          InventoryPostingSetup.VALIDATE("Inventory Account",LibraryERM.CreateGLAccountNo);
          InventoryPostingSetup.VALIDATE("Inventory Account (Interim)",LibraryERM.CreateGLAccountNo);
          InventoryPostingSetup.VALIDATE("WIP Account",LibraryERM.CreateGLAccountNo);
          InventoryPostingSetup.VALIDATE("Material Variance Account",LibraryERM.CreateGLAccountNo);
          InventoryPostingSetup.VALIDATE("Capacity Variance Account",LibraryERM.CreateGLAccountNo);
          InventoryPostingSetup.VALIDATE("Unrealized Profit Account",LibraryERM.CreateGLAccountNo);
          InventoryPostingSetup.MODIFY(TRUE);
        UNTIL InventoryPostingGroup.NEXT = 0;

Example

The below example is extracted from the test automation codeunit 134331 to show one way of using this function.

      LibraryTimeSheet.CreateUserSetup(UserSetup,TRUE);
      LibraryService.CreateResponsibilityCenter(ResponsibilityCenter);
      ResponsibilityCenter.VALIDATE("Location Code",LibraryWarehouse.CreateLocation(Location));
      ResponsibilityCenter.MODIFY(TRUE);
      LibraryInventory.UpdateInventoryPostingSetup(Location);
      UserSetup.VALIDATE("Purchase Resp. Ctr. Filter",ResponsibilityCenter.Code);
      UserSetup.MODIFY(TRUE);
      EXIT(ResponsibilityCenter.Code);
Member of Lib.Library - Inventory


UpdateInventorySetup@49 Method

The procedure UpdateInventorySetup is available in codeunit 132201.

Syntax

UpdateInventorySetup@49(
    VAR InventorySetup@1001 : Record 313 InventorySetup, //Reference parameter of type Record
    AutomaticCostPosting@1000 : Boolean AutomaticCostPosting, //Input parameter of type Boolean
    ExpectedCostPostingtoGL@1002 : Boolean ExpectedCostPostingtoGL, //Input parameter of type Boolean
    AutomaticCostAdjustment@1003 : Option AutomaticCostAdjustment, //Input parameter of type Option
    AverageCostCalcType@1004 : Option AverageCostCalcType, //Input parameter of type Option
    AverageCostPeriod@1005 : Option AverageCostPeriod //Input parameter of type Option
);

Parameters

InventorySetup
Reference parameter of type Record
AutomaticCostPosting
Input parameter of type Boolean
ExpectedCostPostingtoGL
Input parameter of type Boolean
AutomaticCostAdjustment
Input parameter of type Option
AverageCostCalcType
Input parameter of type Option
AverageCostPeriod
Input parameter of type Option

Remarks

The relevant search keywords are: Update, Inventory, Setup.

For a clarification about how this function works, refer to the code listed below.

      InventorySetup.GET;
      InventorySetup.VALIDATE("Automatic Cost Posting",AutomaticCostPosting);
      InventorySetup.VALIDATE("Expected Cost Posting to G/L",ExpectedCostPostingtoGL);
      InventorySetup.VALIDATE("Automatic Cost Adjustment",AutomaticCostAdjustment);
      InventorySetup.VALIDATE("Average Cost Calc. Type",AverageCostCalcType);
      InventorySetup.VALIDATE("Average Cost Period",AverageCostPeriod);
      InventorySetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134387 to show one way of using this function.

      // Verify GL Entries after Post Sales Return Order (with IT) without Alpply from Item Entry after Get Posted Invoice Line to Reverse.

      // Setup: Update Setup, create Sales Order with Item Tracking and post.
      Initialize;
      InventorySetup.GET;
      SalesReceivablesSetup.GET;
      LibraryInventory.UpdateInventorySetup(
        InventorySetup,InventorySetup."Automatic Cost Posting",InventorySetup."Expected Cost Posting to G/L",
        InventorySetup."Automatic Cost Adjustment"::Always,InventorySetup."Average Cost Calc. Type",
        InventorySetup."Average Cost Period");
      UpdateSalesSetup(SalesReceivablesSetup."Return Receipt on Credit Memo",TRUE);

      CreateSalesDocumentItem(SalesHeader,SalesHeader."Document Type"::Order,CreateTrackedItem);
      FindSalesLine(SalesLine,SalesHeader."Document Type",SalesHeader."No.",SalesLine.Type::Item);
      SalesLine.OpenItemTrackingLines;
      LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      // Create Sales Return Order, update 'Apply from Item Entry'.
      CreateAndUpdateSalesRetOrder(SalesHeaderRetOrder,SalesHeader."Sell-to Customer No.");
      LibraryVariableStorage.Enqueue(AdjustCostMsg);
      SalesHeaderRetOrder.CALCFIELDS("Amount Including VAT");

      // Exercise.
      PostedCrMemoNo := LibrarySales.PostSalesDocument(SalesHeaderRetOrder,TRUE,TRUE);

      // Verify: Verify GL Entries after Post Sales Return Order (with IT) without Alpply from Item Entry.
      VerifyGLEntryForPostedInvoice(
        PostedCrMemoNo,SalesHeaderRetOrder."Document Type"::"Credit Memo",SalesHeaderRetOrder."Amount Including VAT");

      // Tear down.
      LibraryInventory.UpdateInventorySetup(
        InventorySetup,InventorySetup."Automatic Cost Posting",InventorySetup."Expected Cost Posting to G/L",
        InventorySetup."Automatic Cost Adjustment",InventorySetup."Average Cost Calc. Type",
        InventorySetup."Average Cost Period");
      UpdateSalesSetup(SalesReceivablesSetup."Return Receipt on Credit Memo",SalesReceivablesSetup."Exact Cost Reversing Mandatory");
Member of Lib.Library - Inventory


UpdateSalesLine@147 Method

The procedure UpdateSalesLine is available in codeunit 132201.

Syntax

UpdateSalesLine@147(
    VAR SalesLine@1000 : Record 37 SalesLine, //Reference parameter of type Record
    FieldNo@1001 : Integer FieldNo, //Input parameter of type Integer
    Value@1002 : Variant Value //Input parameter of type Variant
);

Parameters

SalesLine
Reference parameter of type Record
FieldNo
Input parameter of type Integer
Value
Input parameter of type Variant

Remarks

The relevant search keywords are: Update, Sales, Line.

For a clarification about how this function works, refer to the code listed below.

      // Update Sales Line base on Field and its corresponding value.
      RecRef.GETTABLE(SalesLine);
      FieldRef := RecRef.FIELD(FieldNo);
      FieldRef.VALIDATE(Value);
      RecRef.SETTABLE(SalesLine);
      SalesLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137036 to show one way of using this function.

      // Setup: Create Sales Blanket Order and Make Order.
      Initialize;
      LibrarySales.SetCreditWarningsToNoWarnings;
      LibrarySales.SetStockoutWarning(FALSE);

      BlanketOrderNo :=
        CreateSalesDocumentSetup(
          Item."Replenishment System"::Purchase,SalesHeader."Document Type"::"Blanket Order");
      CreateSalesOrderFromBlanket(BlanketOrderNo);

      // Update Sales Lines with Drop Shipment.
      SalesLine.SETRANGE("Blanket Order No.",BlanketOrderNo);
      SalesLine.FINDFIRST;
      LibraryInventory.UpdateSalesLine(SalesLine,SalesLine.FIELDNO("Drop Shipment"),TRUE);

      // Create Purchase Order from Drop Shipment - Get Sales Order.
      CreatePurchOrderDropShipment(PurchaseHeader,SalesLine);

      // Exercise: Post Purchase Order as Receive and Sales Order as Invoice.
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,FALSE);
      SalesHeader.GET(SalesHeader."Document Type"::Order,SalesLine."Document No.");
      LibrarySales.PostSalesDocument(SalesHeader,FALSE,TRUE);

      // Verify: Verification of Blanket Sales Order for Quantity Shipped.
      VerifySalesBlanketOrder(BlanketOrderNo,PurchaseHeader."No.");
Member of Lib.Library - Inventory


Library - Item Tracking Class

Lib.Library - Item Tracking

COD130502 applies to ERM,SCM,RES,W1,All.
Unsupported version tags: NA: Unable to Compile

Methods

Name | Description
AddLotNoTrackingInfo@2 | The procedure AddLotNoTrackingInfo is available in codeunit 130502.
AddSerialNoTrackingInfo@115 | The procedure AddSerialNoTrackingInfo is available in codeunit 130502.
CreateAssemblyHeaderItemTracking@98 | The procedure CreateAssemblyHeaderItemTracking is available in codeunit 130502.
CreateAssemblyLineItemTracking@99 | The procedure CreateAssemblyLineItemTracking is available in codeunit 130502.
CreateItemJournalLineItemTracking@89 | The procedure CreateItemJournalLineItemTracking is available in codeunit 130502.
CreateItemTrackingCode@1 | The procedure CreateItemTrackingCode is available in codeunit 130502.
CreateLotItem@4 | The procedure CreateLotItem is available in codeunit 130502.
CreateLotNoInformation@35 | The procedure CreateLotNoInformation is available in codeunit 130502.
CreatePlanningWkshItemTracking@91 | The procedure CreatePlanningWkshItemTracking is available in codeunit 130502.
CreateProdOrderCompItemTracking@87 | The procedure CreateProdOrderCompItemTracking is available in codeunit 130502.
CreateProdOrderItemTracking@83 | The procedure CreateProdOrderItemTracking is available in codeunit 130502.
CreatePurchOrderItemTracking@79 | The procedure CreatePurchOrderItemTracking is available in codeunit 130502.
CreateReqWkshItemTracking@93 | The procedure CreateReqWkshItemTracking is available in codeunit 130502.
CreateSalesOrderItemTracking@77 | The procedure CreateSalesOrderItemTracking is available in codeunit 130502.
CreateSerialItem@3 | The procedure CreateSerialItem is available in codeunit 130502.
CreateSerialNoInformation@33 | The procedure CreateSerialNoInformation is available in codeunit 130502.
CreateTransferOrderItemTracking@81 | The procedure CreateTransferOrderItemTracking is available in codeunit 130502.
CreateWhseInvtPickItemTracking@67 | The procedure CreateWhseInvtPickItemTracking is available in codeunit 130502.
CreateWhseInvtPutawayItemTracking@66 | The procedure CreateWhseInvtPutawayItemTracking is available in codeunit 130502.
CreateWhseJournalLineItemTracking@84 | The procedure CreateWhseJournalLineItemTracking is available in codeunit 130502.
CreateWhseReceiptItemTracking@58 | The procedure CreateWhseReceiptItemTracking is available in codeunit 130502.
CreateWhseShipmentItemTracking@55 | The procedure CreateWhseShipmentItemTracking is available in codeunit 130502.
CreateWhseWkshItemTracking@62 | The procedure CreateWhseWkshItemTracking is available in codeunit 130502.
ItemJournal_CalcWhseAdjmnt@30 | The procedure ItemJournal_CalcWhseAdjmnt is available in codeunit 130502.

See Also

Lib


AddLotNoTrackingInfo@2 Method

The procedure AddLotNoTrackingInfo is available in codeunit 130502.

Syntax

AddLotNoTrackingInfo@2(
    VAR Item@1000 : Record 27 Item //Reference parameter of type Record
);

Parameters

Item
Reference parameter of type Record

Remarks

The relevant search keywords are: Add, Lot, No, Tracking, Info.

For a clarification about how this function works, refer to the code listed below.

      CreateItemTrackingCode(ItemTrackingCode,FALSE,TRUE);
      Item.VALIDATE("Item Tracking Code",ItemTrackingCode.Code);
      Item.VALIDATE("Lot Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      Item.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137021 to show one way of using this function.

      // Setup
      Initialize;
      TestSetup;

      // Setup items and SKUs - and replenishment in a "chain" of transfers -
      // location white transfers to location 3 that transfers to location 2 that transfers to location 1
      LFLItemSetup(Item,TRUE,'','','',0,0,0);
      LibraryItemTracking.AddLotNoTrackingInfo(Item);
      CreateSKUs(Item,LocationOne.Code + '|' + LocationTwo.Code + '|' + LocationThree.Code + '|' + LocationWhite.Code,'');
      UpdateSKUAsTransfer(Item,LocationThree.Code,'',LocationWhite.Code);
      UpdateSKUAsTransfer(Item,LocationTwo.Code,'',LocationThree.Code);
      UpdateSKUAsTransfer(Item,LocationOne.Code,'',LocationTwo.Code);

      QtyOnInventory := LibraryRandom.RandDec(100,2);
      AddInventoryNonDirectLocationWithLotNo(Item,LocationTwo.Code,QtyOnInventory,Text002);

      // Exercise - transfer order, ship partial
      CreateAndShipTransfer(TransferHeader,Item."No.",LocationTwo.Code,LocationOne.Code,3 * QtyOnInventory,Text002,
        WORKDATE,QtyOnInventory);
      LibraryPlanning.CalcRegenPlanForPlanWksh(Item,WORKDATE,CALCDATE(PlanningEndDate,WORKDATE));

      // Verify planning worksheet lines - check in doc section more info on the TDS
      AssertNumberOfLinesForItem(Item,3);
      AssertPlanningLine(Item,RequisitionLine."Action Message"::New,0D,WORKDATE,0,2 * QtyOnInventory,
        RequisitionLine."Ref. Order Type"::Purchase,LocationWhite.Code,1);
      AssertPlanningLine(Item,RequisitionLine."Action Message"::New,0D,WORKDATE,0,2 * QtyOnInventory,
        RequisitionLine."Ref. Order Type"::Transfer,LocationThree.Code,1);
      AssertPlanningLine(Item,RequisitionLine."Action Message"::New,0D,WORKDATE,0,2 * QtyOnInventory,
        RequisitionLine."Ref. Order Type"::Transfer,LocationTwo.Code,1);
Member of Lib.Library - Item Tracking


AddSerialNoTrackingInfo@115 Method

The procedure AddSerialNoTrackingInfo is available in codeunit 130502.

Syntax

AddSerialNoTrackingInfo@115(
    VAR Item@1000 : Record 27 Item //Reference parameter of type Record
);

Parameters

Item
Reference parameter of type Record

Remarks

The relevant search keywords are: Add, Serial, No, Tracking, Info.

For a clarification about how this function works, refer to the code listed below.

      CreateItemTrackingCode(ItemTrackingCode,TRUE,FALSE);
      Item.VALIDATE("Item Tracking Code",ItemTrackingCode.Code);
      Item.VALIDATE("Serial Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      Item.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 136302 to show one way of using this function.

      LibraryInventory.CreateItem(Item);
      LibraryItemTracking.AddSerialNoTrackingInfo(Item);
Member of Lib.Library - Item Tracking


CreateAssemblyHeaderItemTracking@98 Method

The procedure CreateAssemblyHeaderItemTracking is available in codeunit 130502.

Syntax

CreateAssemblyHeaderItemTracking@98(
    VAR ReservEntry@1001 : Record 337 ReservEntry, //Reference parameter of type Record
    AssemblyHeader@1000 : Record 900 AssemblyHeader, //Input parameter of type Record
    SerialNo@1002 : Code[20] SerialNo, //Input parameter of type Code
    LotNo@1003 : Code[20] LotNo, //Input parameter of type Code
    QtyBase@1004 : Decimal QtyBase //Input parameter of type Decimal
);

Parameters

ReservEntry
Reference parameter of type Record
AssemblyHeader
Input parameter of type Record
SerialNo
Input parameter of type Code
LotNo
Input parameter of type Code
QtyBase
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Assembly, Header, Item, Tracking.

For a clarification about how this function works, refer to the code listed below.

      RecRef.GETTABLE(AssemblyHeader);
      ItemTracking(ReservEntry,RecRef,SerialNo,LotNo,QtyBase);

Example

The below example is extracted from the test automation codeunit 137926 to show one way of using this function.

      CreateItems(ItemParent,ItemTrackingCode,ItemChild,ItemTrackingCode);

      IF SN THEN BEGIN
        SNChild := ItemChild."No.";
        SNParent := ItemParent."No."
      END;
      IF LN THEN BEGIN
        LNChild := ItemChild."No.";
        LNParent := ItemParent."No."
      END;

      AddItemToInventory(ItemChild,1,SNChild,LNChild);

      LibraryAssembly.CreateAssemblyHeader(AssemblyHeader,WorkDate2,ItemParent."No.",'',1,'');
      LibraryAssembly.CreateAssemblyLine(
        AssemblyHeader,AssemblyLine,1,ItemChild."No.",ItemChild."Base Unit of Measure",1,1,'');
      LibraryItemTracking.CreateAssemblyHeaderItemTracking(ReservEntry,AssemblyHeader,SNParent,LNParent,1);
      LibraryItemTracking.CreateAssemblyLineItemTracking(ReservEntry,AssemblyLine,SNChild,LNChild,1);

      ValidateT337(AssemblyHeader."No.",ItemParent,SNParent,LNParent,1,TRUE,1);
      ValidateT337(AssemblyLine."Document No.",ItemChild,SNChild,LNChild,-1,TRUE,1);

      LibraryAssembly.PostAssemblyHeader(AssemblyHeader,'');

      ValidateT32(AssemblyHeader."No.",ItemParent,SNParent,LNParent,1,TRUE);
      ValidateT32(AssemblyLine."Document No.",ItemChild,SNChild,LNChild,-1,TRUE);

      ValidateT337(AssemblyHeader."No.",ItemParent,SNParent,LNParent,0,FALSE,0);
      ValidateT337(AssemblyLine."Document No.",ItemChild,SNChild,LNChild,0,FALSE,0);

      // Validate Item Tracing
      ItemTracingPage.OPENEDIT;
      ItemTracingPage.LotNoFilter.SETVALUE(LNParent);
      ItemTracingPage.SerialNoFilter.SETVALUE(SNParent);
      ItemTracingPage.TraceMethod.SETVALUE('Usage -> Origin');
      ItemTracingPage.ShowComponents.SETVALUE('All');

      ItemTracingPage.Trace.INVOKE; // Trace

      ItemTracingPage.EXPAND(TRUE);
      ValidateItemTracingLine(ItemTracingPage,'Assembly Output',SNParent,LNParent,ItemParent."No.",1);

      ItemTracingPage.NEXT;
      ItemTracingPage.EXPAND(TRUE);
      ValidateItemTracingLine(ItemTracingPage,'Assembly Consumption',SNChild,LNChild,ItemChild."No.",-1);

      ItemTracingPage.NEXT;
      ValidateItemTracingLine(ItemTracingPage,'Item Ledger Entry',SNChild,LNChild,ItemChild."No.",1);

      ItemTracingPage.TraceOppositeFromLine.INVOKE; // Trace opposite from line
      ItemTracingPage.FIRST;

      ItemTracingPage.EXPAND(TRUE);
      ValidateItemTracingLine(ItemTracingPage,'Item Ledger Entry',SNChild,LNChild,ItemChild."No.",1);

      ItemTracingPage.NEXT;
      ItemTracingPage.EXPAND(TRUE);
      ValidateItemTracingLine(ItemTracingPage,'Assembly Consumption',SNChild,LNChild,ItemChild."No.",-1);

      ItemTracingPage.NEXT;
      ValidateItemTracingLine(ItemTracingPage,'Assembly Output',SNParent,LNParent,ItemParent."No.",1);

      // Validate Navigate result parent
      NavigatePage.OPENEDIT;
      NavigatePage.SerialNoFilter.VALUE(SNParent);
      NavigatePage.LotNoFilter.VALUE(LNParent);
      NavigatePage.Find.INVOKE;
      ValidateNavigateLine(NavigatePage,'Item Ledger Entry',1);
      NavigatePage.NEXT;
      ValidateNavigateLine(NavigatePage,'Posted Assembly Header',1);

      // Validate Navigate result child
      NavigatePage.SerialNoFilter.VALUE(SNChild);
      NavigatePage.LotNoFilter.VALUE(LNChild);
      NavigatePage.Find.INVOKE;
      ValidateNavigateLine(NavigatePage,'Item Ledger Entry',2);
      NavigatePage.NEXT;
      ValidateNavigateLine(NavigatePage,'Posted Assembly Header',1);
Member of Lib.Library - Item Tracking


CreateAssemblyLineItemTracking@99 Method

The procedure CreateAssemblyLineItemTracking is available in codeunit 130502.

Syntax

CreateAssemblyLineItemTracking@99(
    VAR ReservEntry@1001 : Record 337 ReservEntry, //Reference parameter of type Record
    AssemblyLine@1000 : Record 901 AssemblyLine, //Input parameter of type Record
    SerialNo@1002 : Code[20] SerialNo, //Input parameter of type Code
    LotNo@1003 : Code[20] LotNo, //Input parameter of type Code
    QtyBase@1004 : Decimal QtyBase //Input parameter of type Decimal
);

Parameters

ReservEntry
Reference parameter of type Record
AssemblyLine
Input parameter of type Record
SerialNo
Input parameter of type Code
LotNo
Input parameter of type Code
QtyBase
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Assembly, Line, Item, Tracking.

For a clarification about how this function works, refer to the code listed below.

      RecRef.GETTABLE(AssemblyLine);
      ItemTracking(ReservEntry,RecRef,SerialNo,LotNo,QtyBase);

Example

The below example is extracted from the test automation codeunit 137926 to show one way of using this function.

      Initialize;
      LibrarySales.SetCreditWarningsToNoWarnings;

      // Create items
      CreateItemTrackingCode(ItemTrackingCode,TRUE,FALSE);
      CreateItems(ItemParent,ItemTrackingCode,ItemChild,ItemTrackingCode);
      ItemParent.VALIDATE("Replenishment System",ItemParent."Replenishment System"::Assembly);
      ItemParent.VALIDATE("Assembly Policy",ItemParent."Assembly Policy"::"Assemble-to-Order");
      ItemParent.MODIFY(TRUE);

      // Add child to parent BOM
      LibraryManufacturing.CreateBOMComponent(
        BOMComponent,ItemParent."No.",BOMComponent.Type::Item,ItemChild."No.",1,'');

      // Add component to inventory
      SNChild := ItemChild."No.";
      AddItemToInventory(ItemChild,1,SNChild,'');

      // Create Sales Quote
      LibrarySales.CreateSalesHeader(SalesHeader,SalesHeader."Document Type"::Quote,'20000');
      SalesHeader.VALIDATE("Shipment Date",WorkDate2);
      SalesHeader.MODIFY(TRUE);
      LibrarySales.CreateSalesLine(SalesLine,SalesHeader,SalesLine.Type::Item,ItemParent."No.",1);

      // Add SN to Asm Quote Comp
      ATOLink.SETRANGE("Assembly Document Type",ATOLink."Assembly Document Type"::Quote);
      ATOLink.SETRANGE(Type,ATOLink.Type::Sale);
      ATOLink.SETRANGE("Document Type",ATOLink."Document Type"::Quote);
      ATOLink.SETRANGE("Document No.",SalesHeader."No.");
      ATOLink.FINDFIRST;
      AssemblyLine.GET(AssemblyLine."Document Type"::Quote,ATOLink."Assembly Document No.",10000);
      LibraryItemTracking.CreateAssemblyLineItemTracking(ReservEntry,AssemblyLine,SNChild,'',1);

      // Validate SN on asm order comp
      ValidateQuoteSN(ItemChild."No.",SNChild,-1,0);

      // Make Sales Order from Quote
      SalesHeader.GET(SalesLine."Document Type",SalesLine."Document No.");
      SalesQuoteToOrder.RUN(SalesHeader);
      SalesQuoteToOrder.GetSalesOrderHeader(SalesOrderHeader);

      // Validate SN on asm order comp
      ValidateQuoteSN(ItemChild."No.",SNChild,-1,1);
Member of Lib.Library - Item Tracking


CreateItemJournalLineItemTracking@89 Method

The procedure CreateItemJournalLineItemTracking is available in codeunit 130502.

Syntax

CreateItemJournalLineItemTracking@89(
    VAR ReservEntry@1001 : Record 337 ReservEntry, //Reference parameter of type Record
    ItemJournalLine@1000 : Record 83 ItemJournalLine, //Input parameter of type Record
    SerialNo@1002 : Code[20] SerialNo, //Input parameter of type Code
    LotNo@1003 : Code[20] LotNo, //Input parameter of type Code
    QtyBase@1004 : Decimal QtyBase //Input parameter of type Decimal
);

Parameters

ReservEntry
Reference parameter of type Record
ItemJournalLine
Input parameter of type Record
SerialNo
Input parameter of type Code
LotNo
Input parameter of type Code
QtyBase
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Item, Journal, Line, Item, Tracking.

For a clarification about how this function works, refer to the code listed below.

      IF ItemJournalLine."Entry Type" = ItemJournalLine."Entry Type"::Transfer THEN // cannot create this type from UI
        ERROR(Text001,RecRef.NUMBER);
      RecRef.GETTABLE(ItemJournalLine);
      ItemTracking(ReservEntry,RecRef,SerialNo,LotNo,QtyBase);

Example

The below example is extracted from the test automation codeunit 137269 to show one way of using this function.

      LibraryInventory.CreateItemJournalTemplate(ItemJournalTemplate);
      ItemJournalTemplate.VALIDATE(Type,ItemJournalTemplate.Type::Output);
      ItemJournalTemplate.MODIFY(TRUE);
      LibraryInventory.CreateItemJournalBatch(ItemJournalBatch,ItemJournalTemplate.Name);
      IF TempTrackingSpecification.FINDSET THEN
        REPEAT
          LibraryInventory.CreateItemJournalLine(
            ItemJournalLine,ItemJournalTemplate.Name,ItemJournalBatch.Name,ItemJournalLine."Entry Type"::Output,'',0);
          ItemJournalLine.VALIDATE("Order Type",ItemJournalLine."Order Type"::Production);
          ItemJournalLine.VALIDATE("Order No.",ProdOrderNo);
          ItemJournalLine.VALIDATE("Item No.",ItemNo);
          ItemJournalLine.VALIDATE("Output Quantity",TempTrackingSpecification."Quantity (Base)");
          ItemJournalLine.MODIFY(TRUE);
          LibraryItemTracking.CreateItemJournalLineItemTracking(
            ReservationEntry,ItemJournalLine,
            TempTrackingSpecification."Serial No.",TempTrackingSpecification."Lot No.",TempTrackingSpecification."Quantity (Base)");
        UNTIL TempTrackingSpecification.NEXT = 0;
Member of Lib.Library - Item Tracking


CreateItemTrackingCode@1 Method

The procedure CreateItemTrackingCode is available in codeunit 130502.

Syntax

CreateItemTrackingCode@1(
    VAR ItemTrackingCode@1000 : Record 6502 ItemTrackingCode, //Reference parameter of type Record
    SNSpecific@1002 : Boolean SNSpecific, //Input parameter of type Boolean
    LNSpecific@1003 : Boolean LNSpecific //Input parameter of type Boolean
);

Parameters

ItemTrackingCode
Reference parameter of type Record
SNSpecific
Input parameter of type Boolean
LNSpecific
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, Item, Tracking, Code.

For a clarification about how this function works, refer to the code listed below.

      ItemTrackingCode.INIT;
      ItemTrackingCode.VALIDATE(Code,
        LibraryUtility.GenerateRandomCode(ItemTrackingCode.FIELDNO(Code),DATABASE::"Item Tracking Code"));
      ItemTrackingCode.VALIDATE("SN Specific Tracking",SNSpecific);
      ItemTrackingCode.VALIDATE("Lot Specific Tracking",LNSpecific);
      ItemTrackingCode.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134329 to show one way of using this function.

      LibraryItemTracking.CreateItemTrackingCode(ItemTrackingCode,FALSE,FALSE);
      EXIT(ItemTrackingCode.Code);
Member of Lib.Library - Item Tracking


CreateLotItem@4 Method

The procedure CreateLotItem is available in codeunit 130502.

Syntax

CreateLotItem@4(
    VAR Item@1001 : Record 27 Item //Reference parameter of type Record
);

Parameters

Item
Reference parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Lot, Item.

For a clarification about how this function works, refer to the code listed below.

      LibraryInventory.CreateItem(Item);
      AddLotNoTrackingInfo(Item);
      EXIT(Item."No.");

Example

The below example is extracted from the test automation codeunit 136306 to show one way of using this function.

      // [FEATURE] [Undo Receipt]
      // [SCENARIO 209289] Cost Amount is actual when undo the receipt of Purchase Order with Job and Lot tracking

      Initialize;

      // [GIVEN] Receive Purchase Order with Item "X", Lot Tracking, Job and Cost Amount = 100
      LibraryItemTracking.CreateLotItem(Item);
      PostedRcptNo := ReceivePurchOrderWithJobAndItemTracking(PurchaseHeader,Item."No.",TrackingOption::"Assign Lot No.");
      FindPurchLine(PurchLine,PurchaseHeader."Document Type",PurchaseHeader."No.");

      // [GIVEN] Undo Receipt
      FindPurchaseReceiptLine(PurchRcptLine,PostedRcptNo);
      LibraryPurchase.UndoPurchaseReceiptLine(PurchRcptLine);

      // [WHEN] Post Purchase Order (Receive & Invoice)
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

      // [THEN] All Item Ledger Entry posted with Item "X" has "Cost Amount (Expected)" = 0" and "Cost Amount (Actual)" = 100
      VerifyItemLedgEntriesInvoiced(Item."No.",PurchLine.Amount);
Member of Lib.Library - Item Tracking


CreateLotNoInformation@35 Method

The procedure CreateLotNoInformation is available in codeunit 130502.

Syntax

CreateLotNoInformation@35(
    VAR LotNoInformation@1004 : Record 6505 LotNoInformation, //Reference parameter of type Record
    ItemNo@1001 : Code[20] ItemNo, //Input parameter of type Code
    VariantCode@1002 : Code[10] VariantCode, //Input parameter of type Code
    LotNo@1003 : Code[20] LotNo //Input parameter of type Code
);

Parameters

LotNoInformation
Reference parameter of type Record
ItemNo
Input parameter of type Code
VariantCode
Input parameter of type Code
LotNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Lot, No, Information.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(LotNoInformation);
      LotNoInformation.INIT;
      LotNoInformation.VALIDATE("Item No.",ItemNo);
      LotNoInformation.VALIDATE("Variant Code",VariantCode);
      LotNoInformation.VALIDATE("Lot No.",LotNo);
      LotNoInformation.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137051 to show one way of using this function.

      LibraryItemTracking.CreateLotNoInformation(LotNoInformation,ItemNo,'',LotNos[LotNoIndex]);
      LotNoInformation.VALIDATE(Blocked,TRUE);
      LotNoInformation.MODIFY(TRUE);
Member of Lib.Library - Item Tracking


CreatePlanningWkshItemTracking@91 Method

The procedure CreatePlanningWkshItemTracking is available in codeunit 130502.

Syntax

CreatePlanningWkshItemTracking@91(
    VAR ReservEntry@1001 : Record 337 ReservEntry, //Reference parameter of type Record
    ReqLine@1000 : Record 246 ReqLine, //Input parameter of type Record
    SerialNo@1002 : Code[20] SerialNo, //Input parameter of type Code
    LotNo@1003 : Code[20] LotNo, //Input parameter of type Code
    QtyBase@1004 : Decimal QtyBase //Input parameter of type Decimal
);

Parameters

ReservEntry
Reference parameter of type Record
ReqLine
Input parameter of type Record
SerialNo
Input parameter of type Code
LotNo
Input parameter of type Code
QtyBase
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Planning, Wksh, Item, Tracking.

For a clarification about how this function works, refer to the code listed below.

      RecRef.GETTABLE(ReqLine);
      ItemTracking(ReservEntry,RecRef,SerialNo,LotNo,QtyBase);

Example

There are no examples available.
Member of Lib.Library - Item Tracking


CreateProdOrderCompItemTracking@87 Method

The procedure CreateProdOrderCompItemTracking is available in codeunit 130502.

Syntax

CreateProdOrderCompItemTracking@87(
    VAR ReservEntry@1001 : Record 337 ReservEntry, //Reference parameter of type Record
    ProdOrderComp@1000 : Record 5407 ProdOrderComp, //Input parameter of type Record
    SerialNo@1002 : Code[20] SerialNo, //Input parameter of type Code
    LotNo@1003 : Code[20] LotNo, //Input parameter of type Code
    QtyBase@1004 : Decimal QtyBase //Input parameter of type Decimal
);

Parameters

ReservEntry
Reference parameter of type Record
ProdOrderComp
Input parameter of type Record
SerialNo
Input parameter of type Code
LotNo
Input parameter of type Code
QtyBase
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Product, Order, Comp, Item, Tracking.

For a clarification about how this function works, refer to the code listed below.

      RecRef.GETTABLE(ProdOrderComp);
      ItemTracking(ReservEntry,RecRef,SerialNo,LotNo,QtyBase);

Example

The below example is extracted from the test automation codeunit 137200 to show one way of using this function.

      ProdOrderComponent.SETRANGE(Status,ProductionOrder.Status);
      ProdOrderComponent.SETRANGE("Prod. Order No.",ProductionOrder."No.");
      ProdOrderComponent.FINDFIRST;

      LibraryItemTracking.CreateProdOrderCompItemTracking(ReservationEntry,ProdOrderComponent,'S11','',1);
      LibraryItemTracking.CreateProdOrderCompItemTracking(ReservationEntry,ProdOrderComponent,'S12','',1);
      LibraryItemTracking.CreateProdOrderCompItemTracking(ReservationEntry,ProdOrderComponent,'S23','',1);
Member of Lib.Library - Item Tracking


CreateProdOrderItemTracking@83 Method

The procedure CreateProdOrderItemTracking is available in codeunit 130502.

Syntax

CreateProdOrderItemTracking@83(
    VAR ReservEntry@1001 : Record 337 ReservEntry, //Reference parameter of type Record
    ProdOrderLine@1000 : Record 5406 ProdOrderLine, //Input parameter of type Record
    SerialNo@1002 : Code[20] SerialNo, //Input parameter of type Code
    LotNo@1003 : Code[20] LotNo, //Input parameter of type Code
    QtyBase@1004 : Decimal QtyBase //Input parameter of type Decimal
);

Parameters

ReservEntry
Reference parameter of type Record
ProdOrderLine
Input parameter of type Record
SerialNo
Input parameter of type Code
LotNo
Input parameter of type Code
QtyBase
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Product, Order, Item, Tracking.

For a clarification about how this function works, refer to the code listed below.

      RecRef.GETTABLE(ProdOrderLine);
      ItemTracking(ReservEntry,RecRef,SerialNo,LotNo,QtyBase);

Example

There are no examples available.
Member of Lib.Library - Item Tracking


CreatePurchOrderItemTracking@79 Method

The procedure CreatePurchOrderItemTracking is available in codeunit 130502.

Syntax

CreatePurchOrderItemTracking@79(
    VAR ReservEntry@1001 : Record 337 ReservEntry, //Reference parameter of type Record
    PurchLine@1000 : Record 39 PurchLine, //Input parameter of type Record
    SerialNo@1002 : Code[20] SerialNo, //Input parameter of type Code
    LotNo@1003 : Code[20] LotNo, //Input parameter of type Code
    QtyBase@1004 : Decimal QtyBase //Input parameter of type Decimal
);

Parameters

ReservEntry
Reference parameter of type Record
PurchLine
Input parameter of type Record
SerialNo
Input parameter of type Code
LotNo
Input parameter of type Code
QtyBase
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Purchase, Order, Item, Tracking.

For a clarification about how this function works, refer to the code listed below.

      IF PurchLine."Document Type" = PurchLine."Document Type"::"Blanket Order" THEN // cannot create IT for this line from UI
        ERROR(Text001,RecRef.NUMBER);
      RecRef.GETTABLE(PurchLine);
      ItemTracking(ReservEntry,RecRef,SerialNo,LotNo,QtyBase);

Example

The below example is extracted from the test automation codeunit 137019 to show one way of using this function.

      Initialize;

      CreateItemWithPrice(Item,0);

      LibraryPurchase.CreatePurchaseDocumentWithItem(
        PurchaseHeader,PurchaseLine,PurchaseHeader."Document Type"::Invoice,LibraryPurchase.CreateVendorNo,Item."No.",1,'',0D);
      LibraryItemTracking.CreatePurchOrderItemTracking(ReservEntry,PurchaseLine,'','LOT1',1);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);
      GLEntry.FINDLAST;

      LibrarySales.CreateSalesDocumentWithItem(
        SalesHeader,SalesLine,SalesHeader."Document Type"::Invoice,LibrarySales.CreateCustomerNo,Item."No.",1,'',0D);
      LibraryItemTracking.CreateSalesOrderItemTracking(ReservEntry,SalesLine,'','LOT1',1);
      InvoiceNo := LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      SalesInvoiceHeader.GET(InvoiceNo);
      CorrectPostedSalesInvoice.CancelPostedInvoiceStartNewInvoice(SalesInvoiceHeader,SalesHeaderCorrection);

      // VERIFY
      Customer.GET(SalesInvoiceHeader."Sell-to Customer No.");
      CheckEverythingIsReverted(Item,Customer,GLEntry);
Member of Lib.Library - Item Tracking


CreateReqWkshItemTracking@93 Method

The procedure CreateReqWkshItemTracking is available in codeunit 130502.

Syntax

CreateReqWkshItemTracking@93(
    VAR ReservEntry@1001 : Record 337 ReservEntry, //Reference parameter of type Record
    ReqLine@1000 : Record 246 ReqLine, //Input parameter of type Record
    SerialNo@1002 : Code[20] SerialNo, //Input parameter of type Code
    LotNo@1003 : Code[20] LotNo, //Input parameter of type Code
    QtyBase@1004 : Decimal QtyBase //Input parameter of type Decimal
);

Parameters

ReservEntry
Reference parameter of type Record
ReqLine
Input parameter of type Record
SerialNo
Input parameter of type Code
LotNo
Input parameter of type Code
QtyBase
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Req, Wksh, Item, Tracking.

For a clarification about how this function works, refer to the code listed below.

      CreatePlanningWkshItemTracking(ReservEntry,ReqLine,SerialNo,LotNo,QtyBase);

Example

There are no examples available.
Member of Lib.Library - Item Tracking


CreateSalesOrderItemTracking@77 Method

The procedure CreateSalesOrderItemTracking is available in codeunit 130502.

Syntax

CreateSalesOrderItemTracking@77(
    VAR ReservEntry@1001 : Record 337 ReservEntry, //Reference parameter of type Record
    SalesLine@1000 : Record 37 SalesLine, //Input parameter of type Record
    SerialNo@1002 : Code[20] SerialNo, //Input parameter of type Code
    LotNo@1003 : Code[20] LotNo, //Input parameter of type Code
    QtyBase@1004 : Decimal QtyBase //Input parameter of type Decimal
);

Parameters

ReservEntry
Reference parameter of type Record
SalesLine
Input parameter of type Record
SerialNo
Input parameter of type Code
LotNo
Input parameter of type Code
QtyBase
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Sales, Order, Item, Tracking.

For a clarification about how this function works, refer to the code listed below.

      IF SalesLine."Document Type" = SalesLine."Document Type"::"Blanket Order" THEN // cannot create IT for this line from UI
        ERROR(Text001,RecRef.NUMBER);
      RecRef.GETTABLE(SalesLine);
      ItemTracking(ReservEntry,RecRef,SerialNo,LotNo,QtyBase);

Example

The below example is extracted from the test automation codeunit 137019 to show one way of using this function.

      Initialize;

      CreateItemWithPrice(Item,0);

      LibraryPurchase.CreatePurchaseDocumentWithItem(
        PurchaseHeader,PurchaseLine,PurchaseHeader."Document Type"::Invoice,LibraryPurchase.CreateVendorNo,Item."No.",1,'',0D);
      LibraryItemTracking.CreatePurchOrderItemTracking(ReservEntry,PurchaseLine,'','LOT1',1);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);
      GLEntry.FINDLAST;

      LibrarySales.CreateSalesDocumentWithItem(
        SalesHeader,SalesLine,SalesHeader."Document Type"::Invoice,LibrarySales.CreateCustomerNo,Item."No.",1,'',0D);
      LibraryItemTracking.CreateSalesOrderItemTracking(ReservEntry,SalesLine,'','LOT1',1);
      InvoiceNo := LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      SalesInvoiceHeader.GET(InvoiceNo);
      CorrectPostedSalesInvoice.CancelPostedInvoiceStartNewInvoice(SalesInvoiceHeader,SalesHeaderCorrection);

      // VERIFY
      Customer.GET(SalesInvoiceHeader."Sell-to Customer No.");
      CheckEverythingIsReverted(Item,Customer,GLEntry);
Member of Lib.Library - Item Tracking


CreateSerialItem@3 Method

The procedure CreateSerialItem is available in codeunit 130502.

Syntax

CreateSerialItem@3(
    VAR Item@1001 : Record 27 Item //Reference parameter of type Record
);

Parameters

Item
Reference parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Serial, Item.

For a clarification about how this function works, refer to the code listed below.

      LibraryInventory.CreateItem(Item);
      AddSerialNoTrackingInfo(Item);
      EXIT(Item."No.");

Example

The below example is extracted from the test automation codeunit 136306 to show one way of using this function.

      // [FEATURE] [Undo Receipt]
      // [SCENARIO 209289] Cost Amount is actual when undo the receipt of Purchase Order with Job and Serial No. tracking

      Initialize;

      // [GIVEN] Receive Purchase Order with Item "X", Serial No. Tracking, Job and Cost Amount = 100
      LibraryItemTracking.CreateSerialItem(Item);
      PostedRcptNo := ReceivePurchOrderWithJobAndItemTracking(PurchaseHeader,Item."No.",TrackingOption::"Assign Serial No.");

      // [GIVEN] Undo Receipt
      FindPurchaseReceiptLine(PurchRcptLine,PostedRcptNo);
      LibraryPurchase.UndoPurchaseReceiptLine(PurchRcptLine);

      // [WHEN] Post Purchase Order (Receive & Invoice)
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

      // [THEN] All Item Ledger Entry posted with Item "X" has "Cost Amount (Expected)" = 0" and "Cost Amount (Actual)" = 100
      Item.FIND;
      VerifyItemLedgEntriesInvoiced(Item."No.",Item."Unit Cost");
Member of Lib.Library - Item Tracking


CreateSerialNoInformation@33 Method

The procedure CreateSerialNoInformation is available in codeunit 130502.

Syntax

CreateSerialNoInformation@33(
    VAR SerialNoInformation@1004 : Record 6504 SerialNoInformation, //Reference parameter of type Record
    ItemNo@1001 : Code[20] ItemNo, //Input parameter of type Code
    VariantCode@1002 : Code[10] VariantCode, //Input parameter of type Code
    SerialNo@1003 : Code[20] SerialNo //Input parameter of type Code
);

Parameters

SerialNoInformation
Reference parameter of type Record
ItemNo
Input parameter of type Code
VariantCode
Input parameter of type Code
SerialNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Serial, No, Information.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(SerialNoInformation);
      SerialNoInformation.INIT;
      SerialNoInformation.VALIDATE("Item No.",ItemNo);
      SerialNoInformation.VALIDATE("Variant Code",VariantCode);
      SerialNoInformation.VALIDATE("Serial No.",SerialNo);
      SerialNoInformation.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137052 to show one way of using this function.

      // Assign Serial and Lot no based on requirments.
      IF NOT VerifyQtyToHandle THEN BEGIN
        ItemTrackingLines."Assign Serial No.".INVOKE;  // Open Enter Quantity to Create for create Serial No or with Lot No.
        ItemTrackingLines.LAST;
        IF Partial THEN
          ItemTrackingLines."Qty. to Handle (Base)".SETVALUE(0);  // Value to partially track the items.
        LibraryItemTracking.CreateSerialNoInformation(SerialNoInformation,GlobalItemNo,'',ItemTrackingLines."Serial No.".VALUE);
        UpdateSerialNoInformationAndComments(ItemTrackingLines);
        EXIT;
      END;

      // Verify: Qty to Handle- Tracking on unit quantity.
      ItemTrackingLines.LAST;
      ItemTrackingLines."Qty. to Handle (Base)".ASSERTEQUALS(1);  // For Serial No tracking - as per standard, Quantity (Base) must be -1,0,1 when Serial No. is stated.
      ItemTrackingLines.OK.INVOKE;
Member of Lib.Library - Item Tracking


CreateTransferOrderItemTracking@81 Method

The procedure CreateTransferOrderItemTracking is available in codeunit 130502.

Syntax

CreateTransferOrderItemTracking@81(
    VAR ReservEntry@1001 : Record 337 ReservEntry, //Reference parameter of type Record
    TransferLine@1000 : Record 5741 TransferLine, //Input parameter of type Record
    SerialNo@1002 : Code[20] SerialNo, //Input parameter of type Code
    LotNo@1003 : Code[20] LotNo, //Input parameter of type Code
    QtyBase@1004 : Decimal QtyBase //Input parameter of type Decimal
);

Parameters

ReservEntry
Reference parameter of type Record
TransferLine
Input parameter of type Record
SerialNo
Input parameter of type Code
LotNo
Input parameter of type Code
QtyBase
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Transfer, Order, Item, Tracking.

For a clarification about how this function works, refer to the code listed below.

      // Only creates IT lines for Transfer order shipment! IT lines for receipt cannot be added in form.
      // Note that the ReservEntry returned has two lines - one for TRANSFER-FROM and one for TRANSFER-TO
      RecRef.GETTABLE(TransferLine);
      ItemTracking(ReservEntry,RecRef,SerialNo,LotNo,QtyBase);

Example

The below example is extracted from the test automation codeunit 137150 to show one way of using this function.

      ILEQuantity := 10;

      // Setup : Create lot tracked item, with additional UOM used for put-away.
      Initialize;
      CreateItem(Item,ItemTrackingCode.Code);
      CreateItemUnitOfMeasure(ItemUnitOfMeasure,Item."No.",QtyPerUOM);
      UpdateItemUOM(Item,Item."Base Unit of Measure",Item."Base Unit of Measure",ItemUnitOfMeasure.Code);

      // Post positive adjustment in non-warehouse location.
      LotNo1 := LibraryUtility.GenerateRandomCode(WarehouseActivityLine.FIELDNO("Lot No."),DATABASE::"Warehouse Activity Line");
      LibraryPatterns.POSTPositiveAdjustmentWithItemTracking(Item,LocationBlue.Code,'',ILEQuantity,WORKDATE,'',LotNo1);
      LibraryPatterns.POSTPositiveAdjustmentWithItemTracking(Item,LocationBlue.Code,'',ILEQuantity,WORKDATE,'',LotNo1);

      LotNo2 := LibraryUtility.GenerateRandomCode(WarehouseActivityLine.FIELDNO("Lot No."),DATABASE::"Warehouse Activity Line");
      LibraryPatterns.POSTPositiveAdjustmentWithItemTracking(Item,LocationBlue.Code,'',ILEQuantity,WORKDATE,'',LotNo2);
      LibraryPatterns.POSTPositiveAdjustmentWithItemTracking(Item,LocationBlue.Code,'',ILEQuantity,WORKDATE,'',LotNo2);

      // Create transfer order to WHITE, post shipment, create whse. receipt.
      CreateAndReleaseTransferOrder(TransferHeader,LocationBlue.Code,LocationWhite.Code,Item."No.",TransferQty,ItemUnitOfMeasure.Code);
      TransferLine.SETRANGE("Document No.",TransferHeader."No.");
      TransferLine.FINDFIRST;

      // Split the transfer quantity across lots or not.
      IF TransferQty * QtyPerUOM <= 2 * ILEQuantity THEN
        LibraryItemTracking.CreateTransferOrderItemTracking(ReservEntry,TransferLine,'',LotNo1,TransferQty * QtyPerUOM)
      ELSE BEGIN
        LibraryItemTracking.CreateTransferOrderItemTracking(ReservEntry,TransferLine,'',LotNo1,2 * ILEQuantity);
        LibraryItemTracking.CreateTransferOrderItemTracking(
          ReservEntry,TransferLine,'',LotNo2,TransferQty * QtyPerUOM - 2 * ILEQuantity);
      END;
      LibraryWarehouse.PostTransferOrder(TransferHeader,TRUE,FALSE);

      LibraryWarehouse.CreateWhseReceiptFromTO(TransferHeader);

      // Force cross-dock.
      IF CrossDockQty > 0 THEN
        CreateAndReleaseSalesOrder(SalesHeader,SalesLine,Item."No.",Item."Base Unit of Measure",LocationWhite.Code,CrossDockQty,FALSE);
      FindWarehouseReceiptLine(WarehouseReceiptLine,WarehouseReceiptLine."Source Document"::"Inbound Transfer",TransferHeader."No.");
      LibraryWarehouse.CalculateCrossDockLines(
        WhseCrossDockOpportunity,'',WarehouseReceiptLine."No.",WarehouseReceiptLine."Location Code");

      // Exercise: Post receipt.
      LibraryVariableStorage.Enqueue(STRSUBSTNO(TransferOrderDeleted,TransferHeader."No."));  // Enqueue for MessageHandler.
      PostWarehouseReceipt(WarehouseReceiptLine."No.");

      // Verify: Put-away lines.
      // Put-away is not split across lots.
      IF TransferQty * QtyPerUOM <= 2 * ILEQuantity THEN BEGIN
        VerifyWhseActivityLine(
          WarehouseActivityLine,TransferHeader."No.",LotNo1,WarehouseActivityLine."Action Type"::Take,TransferQty * QtyPerUOM);

        IF CrossDockQty > 0 THEN BEGIN
          WarehouseActivityLine.SETRANGE("Bin Code",LocationWhite."Cross-Dock Bin Code");
          VerifyWhseActivityLine(
            WarehouseActivityLine,TransferHeader."No.",LotNo1,WarehouseActivityLine."Action Type"::Place,CrossDockQty);

          WarehouseActivityLine.SETFILTER("Bin Code",'<>%1',LocationWhite."Cross-Dock Bin Code");
          VerifyWhseActivityLine(
            WarehouseActivityLine,TransferHeader."No.",LotNo1,WarehouseActivityLine."Action Type"::Place,
            TransferQty * QtyPerUOM - CrossDockQty);
        END ELSE BEGIN
          WarehouseActivityLine.SETFILTER("Bin Code",'<>%1',LocationWhite."Cross-Dock Bin Code");
          VerifyWhseActivityLine(
            WarehouseActivityLine,TransferHeader."No.",LotNo1,WarehouseActivityLine."Action Type"::Place,TransferQty * QtyPerUOM);
        END;

        // Put-away is split across lots.
      END ELSE BEGIN
        VerifyWhseActivityLine(
          WarehouseActivityLine,TransferHeader."No.",LotNo1,WarehouseActivityLine."Action Type"::Take,2 * ILEQuantity);
        VerifyWhseActivityLine(
          WarehouseActivityLine,TransferHeader."No.",LotNo2,WarehouseActivityLine."Action Type"::Take,
          TransferQty * QtyPerUOM - 2 * ILEQuantity);

        // How is the cross dock qty distributed across lots?
        CASE TRUE OF
          (CrossDockQty > 0) AND (CrossDockQty <= 2 * ILEQuantity):
            // Cross dock qty consumes only from Lot 1.
            BEGIN
              WarehouseActivityLine.SETRANGE("Bin Code",LocationWhite."Cross-Dock Bin Code");
              VerifyWhseActivityLine(
                WarehouseActivityLine,TransferHeader."No.",LotNo1,WarehouseActivityLine."Action Type"::Place,CrossDockQty);

              WarehouseActivityLine.SETFILTER("Bin Code",'<>%1',LocationWhite."Cross-Dock Bin Code");
              VerifyWhseActivityLine(
                WarehouseActivityLine,TransferHeader."No.",LotNo1,WarehouseActivityLine."Action Type"::Place,
                2 * ILEQuantity - CrossDockQty);
              VerifyWhseActivityLine(
                WarehouseActivityLine,TransferHeader."No.",LotNo2,WarehouseActivityLine."Action Type"::Place,
                TransferQty * QtyPerUOM - 2 * ILEQuantity);
            END;
          (CrossDockQty > 0) AND (CrossDockQty > 2 * ILEQuantity) AND (CrossDockQty <= TransferQty * QtyPerUOM):
            // Cross dock qty consumes Lot 1 entirely and Lot 2 partially.
            BEGIN
              WarehouseActivityLine.SETRANGE("Bin Code",LocationWhite."Cross-Dock Bin Code");
              VerifyWhseActivityLine(
                WarehouseActivityLine,TransferHeader."No.",LotNo1,WarehouseActivityLine."Action Type"::Place,2 * ILEQuantity);
              VerifyWhseActivityLine(
                WarehouseActivityLine,TransferHeader."No.",LotNo2,WarehouseActivityLine."Action Type"::Place,
                CrossDockQty - 2 * ILEQuantity);

              WarehouseActivityLine.SETFILTER("Bin Code",'<>%1',LocationWhite."Cross-Dock Bin Code");
              VerifyWhseActivityLine(
                WarehouseActivityLine,TransferHeader."No.",LotNo2,WarehouseActivityLine."Action Type"::Place,
                TransferQty * QtyPerUOM - CrossDockQty);
              ASSERTERROR VerifyWhseActivityLine(
                  WarehouseActivityLine,TransferHeader."No.",LotNo1,WarehouseActivityLine."Action Type"::Place,0);
              Assert.AssertNothingInsideFilter;
            END;
          (CrossDockQty > 0) AND (CrossDockQty > 2 * ILEQuantity) AND (CrossDockQty > TransferQty * QtyPerUOM):
            // Cross dock qty consumes both Lot 1 and Lot 2.
            BEGIN
              WarehouseActivityLine.SETRANGE("Bin Code",LocationWhite."Cross-Dock Bin Code");
              VerifyWhseActivityLine(
                WarehouseActivityLine,TransferHeader."No.",LotNo1,WarehouseActivityLine."Action Type"::Place,2 * ILEQuantity);
              VerifyWhseActivityLine(
                WarehouseActivityLine,TransferHeader."No.",LotNo2,WarehouseActivityLine."Action Type"::Place,
                TransferQty * QtyPerUOM - 2 * ILEQuantity);

              WarehouseActivityLine.SETFILTER("Bin Code",'<>%1',LocationWhite."Cross-Dock Bin Code");
              ASSERTERROR VerifyWhseActivityLine(
                  WarehouseActivityLine,TransferHeader."No.",LotNo1,WarehouseActivityLine."Action Type"::Place,0);
              Assert.AssertNothingInsideFilter;
              ASSERTERROR VerifyWhseActivityLine(
                  WarehouseActivityLine,TransferHeader."No.",LotNo2,WarehouseActivityLine."Action Type"::Place,0);
              Assert.AssertNothingInsideFilter;
            END;
          CrossDockQty = 0:
            BEGIN
              VerifyWhseActivityLine(
                WarehouseActivityLine,TransferHeader."No.",LotNo1,WarehouseActivityLine."Action Type"::Place,2 * ILEQuantity);
              VerifyWhseActivityLine(
                WarehouseActivityLine,TransferHeader."No.",LotNo2,WarehouseActivityLine."Action Type"::Place,
                TransferQty * QtyPerUOM - 2 * ILEQuantity);
            END;
        END;
      END;
Member of Lib.Library - Item Tracking


CreateWhseInvtPickItemTracking@67 Method

The procedure CreateWhseInvtPickItemTracking is available in codeunit 130502.

Syntax

CreateWhseInvtPickItemTracking@67(
    VAR WhseItemTrackingLine@1004 : Record 6550 WhseItemTrackingLine, //Reference parameter of type Record
    WhseInternalPickLine@1003 : Record 7334 WhseInternalPickLine, //Input parameter of type Record
    SerialNo@1002 : Code[20] SerialNo, //Input parameter of type Code
    LotNo@1001 : Code[20] LotNo, //Input parameter of type Code
    QtyBase@1000 : Decimal QtyBase //Input parameter of type Decimal
);

Parameters

WhseItemTrackingLine
Reference parameter of type Record
WhseInternalPickLine
Input parameter of type Record
SerialNo
Input parameter of type Code
LotNo
Input parameter of type Code
QtyBase
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Warehouse, Invt, Pick, Item, Tracking.

For a clarification about how this function works, refer to the code listed below.

      RecRef.GETTABLE(WhseInternalPickLine);
      WhseItemTracking(WhseItemTrackingLine,RecRef,SerialNo,LotNo,QtyBase);

Example

There are no examples available.
Member of Lib.Library - Item Tracking


CreateWhseInvtPutawayItemTracking@66 Method

The procedure CreateWhseInvtPutawayItemTracking is available in codeunit 130502.

Syntax

CreateWhseInvtPutawayItemTracking@66(
    VAR WhseItemTrackingLine@1004 : Record 6550 WhseItemTrackingLine, //Reference parameter of type Record
    WhseInternalPutAwayLine@1003 : Record 7332 WhseInternalPutAwayLine, //Input parameter of type Record
    SerialNo@1002 : Code[20] SerialNo, //Input parameter of type Code
    LotNo@1001 : Code[20] LotNo, //Input parameter of type Code
    QtyBase@1000 : Decimal QtyBase //Input parameter of type Decimal
);

Parameters

WhseItemTrackingLine
Reference parameter of type Record
WhseInternalPutAwayLine
Input parameter of type Record
SerialNo
Input parameter of type Code
LotNo
Input parameter of type Code
QtyBase
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Warehouse, Invt, Putaway, Item, Tracking.

For a clarification about how this function works, refer to the code listed below.

      RecRef.GETTABLE(WhseInternalPutAwayLine);
      WhseItemTracking(WhseItemTrackingLine,RecRef,SerialNo,LotNo,QtyBase);

Example

There are no examples available.
Member of Lib.Library - Item Tracking


CreateWhseJournalLineItemTracking@84 Method

The procedure CreateWhseJournalLineItemTracking is available in codeunit 130502.

Syntax

CreateWhseJournalLineItemTracking@84(
    VAR WhseItemTrackingLine@1004 : Record 6550 WhseItemTrackingLine, //Reference parameter of type Record
    WhseJnlLine@1003 : Record 7311 WhseJnlLine, //Input parameter of type Record
    SerialNo@1002 : Code[20] SerialNo, //Input parameter of type Code
    LotNo@1001 : Code[20] LotNo, //Input parameter of type Code
    QtyBase@1000 : Decimal QtyBase //Input parameter of type Decimal
);

Parameters

WhseItemTrackingLine
Reference parameter of type Record
WhseJnlLine
Input parameter of type Record
SerialNo
Input parameter of type Code
LotNo
Input parameter of type Code
QtyBase
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Warehouse, Journal, Line, Item, Tracking.

For a clarification about how this function works, refer to the code listed below.

      RecRef.GETTABLE(WhseJnlLine);
      WhseItemTracking(WhseItemTrackingLine,RecRef,SerialNo,LotNo,QtyBase);

Example

The below example is extracted from the test automation codeunit 137926 to show one way of using this function.

      ItemJournalTemplate.SETRANGE(Type,ItemJournalTemplate.Type::Item);
      ItemJournalTemplate.SETRANGE(Recurring,FALSE);
      ItemJournalTemplate.FINDFIRST;
      ItemJournalBatch.SETRANGE("Journal Template Name",ItemJournalTemplate.Name);
      ItemJournalBatch.FINDFIRST;

      IF Location."Directed Put-away and Pick" THEN BEGIN
        WarehouseJournalTemplate.SETRANGE(Type,WarehouseJournalTemplate.Type::Item);
        WarehouseJournalTemplate.FINDFIRST;
        WarehouseJournalBatch.SETRANGE("Journal Template Name",WarehouseJournalTemplate.Name);
        WarehouseJournalBatch.FINDFIRST;
        LibraryWarehouse.CreateWhseJournalLine(
          WarehouseJournalLine,WarehouseJournalTemplate.Name,WarehouseJournalBatch.Name,
          Location.Code,'',BinCode,WarehouseJournalLine."Entry Type"::"Positive Adjmt.",Item."No.",Quantity);
        IF (SerialNo <> '') OR (LotNo <> '') THEN
          LibraryItemTracking.CreateWhseJournalLineItemTracking(WhseItemTrackingLine,WarehouseJournalLine,SerialNo,LotNo,Quantity);
        LibraryWarehouse.PostWhseJournalLine(WarehouseJournalTemplate.Name,WarehouseJournalBatch.Name,Location.Code);
        LibraryWarehouse.CalculateWhseAdjustmentItemJournal(Item,WorkDate2,'');
        LibraryInventory.PostItemJournalLine(ItemJournalTemplate.Name,ItemJournalBatch.Name);
      END ELSE BEGIN
        LibraryInventory.CreateItemJournalLine(ItemJournalLine,ItemJournalTemplate.Name,ItemJournalBatch.Name,
          ItemJournalLine."Entry Type"::"Positive Adjmt.",Item."No.",Quantity);
        ItemJournalLine.VALIDATE("Location Code",Location.Code);
        ItemJournalLine.VALIDATE("Bin Code",BinCode);
        ItemJournalLine.MODIFY(TRUE);
        IF (SerialNo <> '') OR (LotNo <> '') THEN
          LibraryItemTracking.CreateItemJournalLineItemTracking(ReservEntry,ItemJournalLine,SerialNo,LotNo,Quantity);
        LibraryInventory.PostItemJournalLine(ItemJournalTemplate.Name,ItemJournalBatch.Name);
      END;
Member of Lib.Library - Item Tracking


CreateWhseReceiptItemTracking@58 Method

The procedure CreateWhseReceiptItemTracking is available in codeunit 130502.

Syntax

CreateWhseReceiptItemTracking@58(
    VAR ReservEntry@1001 : Record 337 ReservEntry, //Reference parameter of type Record
    WhseRcptLine@1000 : Record 7317 WhseRcptLine, //Input parameter of type Record
    SerialNo@1002 : Code[20] SerialNo, //Input parameter of type Code
    LotNo@1003 : Code[20] LotNo, //Input parameter of type Code
    QtyBase@1004 : Decimal QtyBase //Input parameter of type Decimal
);

Parameters

ReservEntry
Reference parameter of type Record
WhseRcptLine
Input parameter of type Record
SerialNo
Input parameter of type Code
LotNo
Input parameter of type Code
QtyBase
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Warehouse, Receipt, Item, Tracking.

For a clarification about how this function works, refer to the code listed below.

      RecRef.GETTABLE(WhseRcptLine);
      ItemTracking(ReservEntry,RecRef,SerialNo,LotNo,QtyBase);

Example

There are no examples available.
Member of Lib.Library - Item Tracking


CreateWhseShipmentItemTracking@55 Method

The procedure CreateWhseShipmentItemTracking is available in codeunit 130502.

Syntax

CreateWhseShipmentItemTracking@55(
    VAR ReservEntry@1001 : Record 337 ReservEntry, //Reference parameter of type Record
    WhseShptLine@1000 : Record 7321 WhseShptLine, //Input parameter of type Record
    SerialNo@1002 : Code[20] SerialNo, //Input parameter of type Code
    LotNo@1003 : Code[20] LotNo, //Input parameter of type Code
    QtyBase@1004 : Decimal QtyBase //Input parameter of type Decimal
);

Parameters

ReservEntry
Reference parameter of type Record
WhseShptLine
Input parameter of type Record
SerialNo
Input parameter of type Code
LotNo
Input parameter of type Code
QtyBase
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Warehouse, Shipment, Item, Tracking.

For a clarification about how this function works, refer to the code listed below.

      RecRef.GETTABLE(WhseShptLine);
      ItemTracking(ReservEntry,RecRef,SerialNo,LotNo,QtyBase);

Example

There are no examples available.
Member of Lib.Library - Item Tracking


CreateWhseWkshItemTracking@62 Method

The procedure CreateWhseWkshItemTracking is available in codeunit 130502.

Syntax

CreateWhseWkshItemTracking@62(
    VAR WhseItemTrackingLine@1001 : Record 6550 WhseItemTrackingLine, //Reference parameter of type Record
    WhseWkshLine@1000 : Record 7326 WhseWkshLine, //Input parameter of type Record
    SerialNo@1002 : Code[20] SerialNo, //Input parameter of type Code
    LotNo@1003 : Code[20] LotNo, //Input parameter of type Code
    QtyBase@1004 : Decimal QtyBase //Input parameter of type Decimal
);

Parameters

WhseItemTrackingLine
Reference parameter of type Record
WhseWkshLine
Input parameter of type Record
SerialNo
Input parameter of type Code
LotNo
Input parameter of type Code
QtyBase
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Warehouse, Wksh, Item, Tracking.

For a clarification about how this function works, refer to the code listed below.

      RecRef.GETTABLE(WhseWkshLine);
      WhseItemTracking(WhseItemTrackingLine,RecRef,SerialNo,LotNo,QtyBase);

Example

The below example is extracted from the test automation codeunit 137926 to show one way of using this function.

      // Create Location
      IF WhseType = WhseType::WMS THEN
        MockLocation(Location,TRUE,TRUE,TRUE,TRUE)
      ELSE
        MockLocation(Location,TRUE,TRUE,FALSE,FALSE);

      // Create Item Tracking Code
      CreateItemTrackingCode(ItemTrackingCode,SN,LN);

      // Create Items
      MockItem(ItemParent);
      MockItem(ItemChild);
      ItemChild."Item Tracking Code" := ItemTrackingCode.Code;
      ItemChild.MODIFY(TRUE);

      // Add component to inventory
      IF SN THEN
        SerialNo := 'SN0001';
      IF LN THEN
        LotNo := 'LOT0001';

      AddItemToWhseLocation(ItemChild,Location,'BIN1',1,SerialNo,LotNo);

      // Create Asm order
      LibraryAssembly.CreateAssemblyHeader(AssemblyHeader,WorkDate2,ItemParent."No.",'',1,'');
      AssemblyHeader.VALIDATE("Location Code",Location.Code);
      AssemblyHeader.MODIFY(TRUE);
      LibraryAssembly.CreateAssemblyLine(
        AssemblyHeader,AssemblyLine,AssemblyLine.Type::Item,ItemChild."No.",ItemChild."Base Unit of Measure",1,1,'');
      AssemblyLine.VALIDATE("Location Code",Location.Code);
      AssemblyLine.VALIDATE("Bin Code",'BIN3');
      AssemblyLine.MODIFY(TRUE);

      // Assign IT on Line
      IF AssignITOn = AssignITOn::AsmLine THEN
        LibraryItemTracking.CreateAssemblyLineItemTracking(ReservEntry,AssemblyLine,SerialNo,LotNo,1);

      // Relase Asm Order
      LibraryAssembly.ReleaseAO(AssemblyHeader);
      IF WhseType = WhseType::WMS THEN
        WhsePickRequest.GET(3,1,AssemblyHeader."No.",Location.Code)
      ELSE
        WarehouseRequest.GET(1,Location.Code,DATABASE::"Assembly Line",1,AssemblyHeader."No.");

      IF UsePickWorksheet THEN BEGIN
        LibraryWarehouse.GetWhseDocsPickWorksheet(WhseWkshLine,WhsePickRequest,Location.Code);
        IF AssignITOn = AssignITOn::AsmLine THEN
          ValidateITOnPW(AssemblyHeader."No.",ItemChild."No.",SerialNo,LotNo,1,TRUE)
        ELSE
          IF AssignITOn = AssignITOn::PickWorksheet THEN BEGIN
            WhseWkshTemplate.SETRANGE(Type,WhseWkshTemplate.Type::Pick);
            WhseWkshTemplate.FINDFIRST;
            WhseWkshLine.GET(WhseWkshTemplate.Name,Location.Code,Location.Code,10000);
            LibraryItemTracking.CreateWhseWkshItemTracking(WhseItemTrackingLine,WhseWkshLine,SerialNo,LotNo,1);
          END;
      END;

      // Create whse pick or invt movement
      IF WhseType = WhseType::WMS THEN
        IF UsePickWorksheet THEN BEGIN
          CreatePick.SetWkshPickLine(WhseWkshLine);
          CreatePick.USEREQUESTPAGE(FALSE);
          CreatePick.RUNMODAL;
        END ELSE
          LibraryAssembly.CreateWhsePick(AssemblyHeader,'',0,FALSE,FALSE,FALSE) // create pick
      ELSE
        IF  WhseType = WhseType::BW THEN
          LibraryAssembly.CreateInvtMovement(AssemblyHeader."No.",FALSE,FALSE,TRUE);

      // Validate IT on Pick/invt Movement
      IF (AssignITOn = AssignITOn::PickWorksheet) OR (AssignITOn = AssignITOn::AsmLine) THEN
        CheckPick(AssemblyHeader."No.",SerialNo,LotNo);

      // Choose IT on Pick
      IF (AssignITOn = AssignITOn::Pick) OR (AssignITOn = AssignITOn::InvtMovement) THEN
        AssignITToWhseActivity(AssemblyHeader."No.",SerialNo,LotNo);

      // Register pick/Invt movement
      IF WhseType = WhseType::WMS THEN
        RegisterWhseActivity(WarehouseActivityLine."Activity Type"::Pick,AssemblyHeader."No.")
      ELSE
        RegisterWhseActivity(WarehouseActivityLine."Activity Type"::"Invt. Movement",AssemblyHeader."No.");

      // Validate IT on asm line in T337
      ValidateT337(AssemblyLine."Document No.",ItemChild,SerialNo,LotNo,-1,TRUE,1);
Member of Lib.Library - Item Tracking


ItemJournal_CalcWhseAdjmnt@30 Method

The procedure ItemJournal_CalcWhseAdjmnt is available in codeunit 130502.

Syntax

ItemJournal_CalcWhseAdjmnt@30(
    VAR Item@1004 : Record 27 Item, //Reference parameter of type Record
    NewPostingDate@1002 : Date NewPostingDate, //Input parameter of type Date
    DocumentNo@1003 : Text[20] DocumentNo //Input parameter of type Text
);

Parameters

Item
Reference parameter of type Record
NewPostingDate
Input parameter of type Date
DocumentNo
Input parameter of type Text

Remarks

The relevant search keywords are: Item, Journal_, Calc, Warehouse, Adjmnt.

For a clarification about how this function works, refer to the code listed below.

      LibraryAssembly.SetupItemJournal(ItemJournalTemplate,ItemJournalBatch);
      ItemJournalLine.VALIDATE("Journal Template Name",ItemJournalBatch."Journal Template Name");
      ItemJournalLine.VALIDATE("Journal Batch Name",ItemJournalBatch.Name);

      COMMIT;
      CalcWhseAdjmnt.SetItemJnlLine(ItemJournalLine);
      IF DocumentNo = '' THEN
        DocumentNo := NoSeriesMgt.GetNextNo(ItemJournalBatch."No. Series",NewPostingDate,FALSE);
      CalcWhseAdjmnt.InitializeRequest(NewPostingDate,DocumentNo);
      IF Item.HASFILTER THEN
        TmpItem.COPYFILTERS(Item)
      ELSE BEGIN
        Item.GET(Item."No.");
        TmpItem.SETRANGE("No.",Item."No.");
      END;

      CalcWhseAdjmnt.SETTABLEVIEW(TmpItem);
      CalcWhseAdjmnt.USEREQUESTPAGE(FALSE);
      CalcWhseAdjmnt.RUNMODAL;

Example

There are no examples available.
Member of Lib.Library - Item Tracking


Library - Job Class

Lib.Library - Job

COD131920 applies to RES,Jobs,W1,IN.

Methods

Name | Description
Attach2PurchaseLine@44 | The procedure Attach2PurchaseLine is available in codeunit 131920.
AttachJobTask2PurchaseLine@35 | The procedure AttachJobTask2PurchaseLine is available in codeunit 131920.
ConfigureGeneralPosting@51 | The procedure ConfigureGeneralPosting is available in codeunit 131920.
ConfigureVATPosting@58 | The procedure ConfigureVATPosting is available in codeunit 131920.
CopyJobJournalLines@69 | The procedure CopyJobJournalLines is available in codeunit 131920.
CopyPurchaseLines@41 | The procedure CopyPurchaseLines is available in codeunit 131920.
CreateCapitalizeCWIPHeader@1500005 | The procedure CreateCapitalizeCWIPHeader is available in codeunit 131920.
CreateConsumable@20 | The procedure CreateConsumable is available in codeunit 131920.
CreateGeneralPostingSetup@52 | The procedure CreateGeneralPostingSetup is available in codeunit 131920.
CreateGenJournalBatch@62 | The procedure CreateGenJournalBatch is available in codeunit 131920.
CreateGenJournalLineForPlan@60 | The procedure CreateGenJournalLineForPlan is available in codeunit 131920.
CreateJob@4 | The procedure CreateJob is available in codeunit 131920.
CreateJobGLAccountPrice@71 | The procedure CreateJobGLAccountPrice is available in codeunit 131920.
CreateJobGLJournalLine@50 | The procedure CreateJobGLJournalLine is available in codeunit 131920.
CreateJobItemPrice@72 | The procedure CreateJobItemPrice is available in codeunit 131920.
CreateJobJournalBatch@12 | The procedure CreateJobJournalBatch is available in codeunit 131920.
CreateJobJournalLine@6 | The procedure CreateJobJournalLine is available in codeunit 131920.
CreateJobJournalLineForPlan@39 | The procedure CreateJobJournalLineForPlan is available in codeunit 131920.
CreateJobJournalLineForType@22 | The procedure CreateJobJournalLineForType is available in codeunit 131920.
CreateJobJournalTemplate@75 | The procedure CreateJobJournalTemplate is available in codeunit 131920.
CreateJobPlanningLine@2 | The procedure CreateJobPlanningLine is available in codeunit 131920.
CreateJobPostingGroup@16 | The procedure CreateJobPostingGroup is available in codeunit 131920.
CreateJobResourcePrice@74 | The procedure CreateJobResourcePrice is available in codeunit 131920.
CreateJobTask@5 | The procedure CreateJobTask is available in codeunit 131920.
CreateJobWIPMethod@70 | The procedure CreateJobWIPMethod is available in codeunit 131920.
CreateJobWithPostingGroup@1500015 | The procedure CreateJobWithPostingGroup is available in codeunit 131920.
CreatePurchaseLineForPlan@65 | The procedure CreatePurchaseLineForPlan is available in codeunit 131920.
CreateServiceLineForPlan@54 | The procedure CreateServiceLineForPlan is available in codeunit 131920.
CreateVATPostingSetup@56 | The procedure CreateVATPostingSetup is available in codeunit 131920.
FindConsumable@3 | The procedure FindConsumable is available in codeunit 131920.
FindItem@9 | The procedure FindItem is available in codeunit 131920.
FindJobPostingGroup@8 | The procedure FindJobPostingGroup is available in codeunit 131920.
FindLocation@133 | The procedure FindLocation is available in codeunit 131920.
GenJournalConsumption@66 | The procedure GenJournalConsumption is available in codeunit 131920.
GetAmountRoundingPrecision@23 | The procedure GetAmountRoundingPrecision is available in codeunit 131920.
GetGenJournalTemplate@61 | The procedure GetGenJournalTemplate is available in codeunit 131920.
GetJobJournalTemplate@1 | The procedure GetJobJournalTemplate is available in codeunit 131920.
GetJobTestNoSeries@49 | The procedure GetJobTestNoSeries is available in codeunit 131920.
GetJobWIPMethod@76 | The procedure GetJobWIPMethod is available in codeunit 131920.
GetNextLineNo@19 | The procedure GetNextLineNo is available in codeunit 131920.
GetUnitAmountRoundingPrecision@10 | The procedure GetUnitAmountRoundingPrecision is available in codeunit 131920.
GLAccountType@14 | The procedure GLAccountType is available in codeunit 131920.
ItemType@18 | The procedure ItemType is available in codeunit 131920.
Job2PurchaseConsumableType@55 | The procedure Job2PurchaseConsumableType is available in codeunit 131920.
Job2SalesConsumableType@43 | The procedure Job2SalesConsumableType is available in codeunit 131920.
Job2ServiceConsumableType@73 | The procedure Job2ServiceConsumableType is available in codeunit 131920.
JobConsumption@64 | The procedure JobConsumption is available in codeunit 131920.
Max@47 | The procedure Max is available in codeunit 131920.
PlanningLineType@38 | The procedure PlanningLineType is available in codeunit 131920.
PlanningLineTypeBoth@36 | The procedure PlanningLineTypeBoth is available in codeunit 131920.
PlanningLineTypeContract@34 | The procedure PlanningLineTypeContract is available in codeunit 131920.
PlanningLineTypeSchedule@30 | The procedure PlanningLineTypeSchedule is available in codeunit 131920.
PostJobJournal@7 | The procedure PostJobJournal is available in codeunit 131920.
Purchase2JobConsumableType@15 | The procedure Purchase2JobConsumableType is available in codeunit 131920.
PurchaseConsumption@68 | The procedure PurchaseConsumption is available in codeunit 131920.
ResourceType@13 | The procedure ResourceType is available in codeunit 131920.
RunUpdateJobItemCost@77 | The procedure RunUpdateJobItemCost is available in codeunit 131920.
Service2JobConsumableType@17 | The procedure Service2JobConsumableType is available in codeunit 131920.
ServiceConsumption@63 | The procedure ServiceConsumption is available in codeunit 131920.
SetAutomaticUpdateJobItemCost@78 | The procedure SetAutomaticUpdateJobItemCost is available in codeunit 131920.
SetIncomeStatementGLAccounts@53 | The procedure SetIncomeStatementGLAccounts is available in codeunit 131920.
UpdateJobPostingGroup@107 | The procedure UpdateJobPostingGroup is available in codeunit 131920.
UsageLineType@37 | The procedure UsageLineType is available in codeunit 131920.
UsageLineTypeBlank@21 | The procedure UsageLineTypeBlank is available in codeunit 131920.
UsageLineTypeBoth@33 | The procedure UsageLineTypeBoth is available in codeunit 131920.
UsageLineTypeContract@32 | The procedure UsageLineTypeContract is available in codeunit 131920.
UsageLineTypeSchedule@31 | The procedure UsageLineTypeSchedule is available in codeunit 131920.
UseJobPlanningLine@11 | The procedure UseJobPlanningLine is available in codeunit 131920.
UseJobPlanningLineExplicit@25 | The procedure UseJobPlanningLineExplicit is available in codeunit 131920.
VerifyGLEntries@42 | The procedure VerifyGLEntries is available in codeunit 131920.
VerifyJobJournalPosting@67 | The procedure VerifyJobJournalPosting is available in codeunit 131920.
VerifyJobLedger@57 | The procedure VerifyJobLedger is available in codeunit 131920.
VerifyPlanningLines@46 | The procedure VerifyPlanningLines is available in codeunit 131920.
VerifyPurchaseDocPostingForJob@28 | The procedure VerifyPurchaseDocPostingForJob is available in codeunit 131920.

See Also

Lib


Attach2PurchaseLine@44 Method

The procedure Attach2PurchaseLine is available in codeunit 131920.

Syntax

Attach2PurchaseLine@44(
    ConsumableType@1001 : Option ConsumableType, //Input parameter of type Option
    VAR PurchaseLine@1000 : Record 39 PurchaseLine //Reference parameter of type Record
);

Parameters

ConsumableType
Input parameter of type Option
PurchaseLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Attach2, Purchase, Line.

For a clarification about how this function works, refer to the code listed below.

      // Attach a random number of random consumables to the purchase line.

      WITH PurchaseLine DO BEGIN
        VALIDATE(Type,ConsumableType);
        VALIDATE("No.",FindConsumable(Purchase2JobConsumableType(ConsumableType)));
        VALIDATE(Quantity,LibraryRandom.RandInt(100));
        IF Type = Type::"G/L Account" THEN
          VALIDATE("Direct Unit Cost",LibraryRandom.RandInt(100));
        MODIFY(TRUE)
      END

Example

The below example is extracted from the test automation codeunit 136300 to show one way of using this function.

      IF ConsumableType <> PurchLine.Type::Item THEN
        LibraryJob.Attach2PurchaseLine(ConsumableType,PurchLine)
      ELSE
        WITH PurchLine DO BEGIN
          CreateVATPostingSetup(VATPostingSetup,"VAT Bus. Posting Group");
          VALIDATE(Type,ConsumableType);
          LibraryInventory.CreateItem(Item);
          Item.VALIDATE("VAT Prod. Posting Group",VATPostingSetup."VAT Prod. Posting Group");
          Item.MODIFY(TRUE);
          VALIDATE("No.",Item."No.");
          VALIDATE(Quantity,LibraryRandom.RandInt(100));
          MODIFY(TRUE)
        END;
Member of Lib.Library - Job


AttachJobTask2PurchaseLine@35 Method

The procedure AttachJobTask2PurchaseLine is available in codeunit 131920.

Syntax

AttachJobTask2PurchaseLine@35(
    JobTask@1000 : Record 1001 JobTask, //Input parameter of type Record
    VAR PurchaseLine@1001 : Record 39 PurchaseLine //Reference parameter of type Record
);

Parameters

JobTask
Input parameter of type Record
PurchaseLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Attach, Job, Task2, Purchase, Line.

For a clarification about how this function works, refer to the code listed below.

      // Attach the job task to the purchase line.

      WITH PurchaseLine DO BEGIN
        VALIDATE("Job No.",JobTask."Job No.");
        VALIDATE("Job Task No.",JobTask."Job Task No.");
        MODIFY(TRUE)
      END

Example

The below example is extracted from the test automation codeunit 136300 to show one way of using this function.

      // Parameterized test

      // PurchaseDocumentType IN [Order,Invoice]
      // PurchaseLineType IN [Item,G/L Account]
      // JobLineType IN ["",Schedule,Contract,Both Schedule and Contract]

      // Setup
      Initialize;
      LibraryJob.CreateJob(Job);
      LibraryJob.CreateJobTask(Job,JobTask);

      // Exercise
      CreateSingleLinePurchaseDoc(PurchaseDocumentType,PurchaseHeader);

      // Attach requested account type to the created purchase line
      GetPurchaseLines(PurchaseHeader,PurchaseLine);

      UpdatePurchLine(PurchaseLine,LibraryJob.Job2PurchaseConsumableType(ConsumableType));
      LibraryJob.AttachJobTask2PurchaseLine(JobTask,PurchaseLine);
      PurchaseLine.VALIDATE("Job Line Type",JobLineType);
      PurchaseLine.VALIDATE(Description,LibraryUtility.GenerateGUID);
      PurchaseLine.MODIFY(TRUE);
      LibraryJob.CopyPurchaseLines(PurchaseLine,TempPurchaseLine);
      PostPurchaseDocument(PurchaseHeader,PurchInvHeader);

      // Verify (planning lines, job ledger)
      LibraryJob.VerifyPurchaseDocPostingForJob(TempPurchaseLine);
      JobLedgerEntry.SETRANGE(Description,TempPurchaseLine.Description);
      Assert.AreEqual(1,JobLedgerEntry.COUNT,'# job ledger entries');
      JobLedgerEntry.FINDFIRST;

      LibraryJob.VerifyGLEntries(JobLedgerEntry);

      TearDown;
Member of Lib.Library - Job


ConfigureGeneralPosting@51 Method

The procedure ConfigureGeneralPosting is available in codeunit 131920.

Syntax

ConfigureGeneralPosting@51(
      //param element not supplied
);

Remarks

The relevant search keywords are: Configure, General, Posting.

For a clarification about how this function works, refer to the code listed below.

      // create a posting setup for each combination of product and business group
      // including "empty" business group (in the first iteration)

      REPEAT
        GenBusinessPostingGroupCode := GenBusinessPostingGroup.Code;
        GenProductPostingGroup.FINDSET;
        REPEAT
          IF NOT GeneralPostingSetup.GET(GenBusinessPostingGroupCode,GenProductPostingGroup.Code) THEN
            CreateGeneralPostingSetup(GenBusinessPostingGroupCode,GenProductPostingGroup.Code,GeneralPostingSetup);

          RecordRef.GETTABLE(GeneralPostingSetup);
          // general posting => income statement
          SetIncomeStatementGLAccounts(RecordRef)
        UNTIL GenProductPostingGroup.NEXT = 0
      UNTIL GenBusinessPostingGroup.NEXT = 0

Example

The below example is extracted from the test automation codeunit 136300 to show one way of using this function.

      CLEAR(DocumentType);
      LibrarySetupStorage.Restore;
      IF IsInitialized THEN
        EXIT;

      // Removing special prices
      PurchasePrice.DELETEALL(TRUE);
      SalesPrice.DELETEALL(TRUE);

      LibraryJob.ConfigureGeneralPosting;
      LibraryJob.ConfigureVATPosting;
      LibraryERMCountryData.CreateGeneralPostingSetupData;
      LibraryERMCountryData.CreateVATData;
      LibraryERMCountryData.UpdateGeneralPostingSetup;
      LibrarySetupStorage.Save(DATABASE::"General Ledger Setup");
      IsInitialized := TRUE;
      COMMIT;
Member of Lib.Library - Job


ConfigureVATPosting@58 Method

The procedure ConfigureVATPosting is available in codeunit 131920.

Syntax

ConfigureVATPosting@58(
      //param element not supplied
);

Remarks

The relevant search keywords are: Configure, VAT, Posting.

For a clarification about how this function works, refer to the code listed below.

      // create a posting setup for each combination of product and business group
      // including "empty" business and product group combinations

      REPEAT
        VATBusinessPostingGroupCode := VATBusinessPostingGroup.Code;
        CLEAR(VATProductPostingGroup);
        REPEAT
          VATProductPostingGroupCode := VATProductPostingGroup.Code;
          IF NOT VATPostingSetup.GET(VATBusinessPostingGroupCode,VATProductPostingGroupCode) THEN
            CreateVATPostingSetup(VATBusinessPostingGroupCode,VATProductPostingGroupCode,VATPostingSetup);

          RecordRef.GETTABLE(VATPostingSetup);
          // VAT posting => income statement
          SetIncomeStatementGLAccounts(RecordRef)
        UNTIL VATProductPostingGroup.NEXT = 0
      UNTIL VATBusinessPostingGroup.NEXT = 0

Example

The below example is extracted from the test automation codeunit 136300 to show one way of using this function.

      CLEAR(DocumentType);
      LibrarySetupStorage.Restore;
      IF IsInitialized THEN
        EXIT;

      // Removing special prices
      PurchasePrice.DELETEALL(TRUE);
      SalesPrice.DELETEALL(TRUE);

      LibraryJob.ConfigureGeneralPosting;
      LibraryJob.ConfigureVATPosting;
      LibraryERMCountryData.CreateGeneralPostingSetupData;
      LibraryERMCountryData.CreateVATData;
      LibraryERMCountryData.UpdateGeneralPostingSetup;
      LibrarySetupStorage.Save(DATABASE::"General Ledger Setup");
      IsInitialized := TRUE;
      COMMIT;
Member of Lib.Library - Job


CopyJobJournalLines@69 Method

The procedure CopyJobJournalLines is available in codeunit 131920.

Syntax

CopyJobJournalLines@69(
    VAR FromJobJournalLine@1000 : Record 210 FromJobJournalLine, //Reference parameter of type Record
    VAR ToJobJournalLine@1001 : Record 210 ToJobJournalLine //Reference parameter of type Record
);

Parameters

FromJobJournalLine
Reference parameter of type Record
ToJobJournalLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Copy, Job, Journal, Lines.

For a clarification about how this function works, refer to the code listed below.

      FromJobJournalLine.FINDSET;
      REPEAT
        ToJobJournalLine := FromJobJournalLine;
        ToJobJournalLine.INSERT(TRUE);
      UNTIL FromJobJournalLine.NEXT = 0;
      ToJobJournalLine.COPYFILTERS(FromJobJournalLine)

Example

The below example is extracted from the test automation codeunit 136300 to show one way of using this function.

      // Parameterized test

      // LineType IN ["",Schedule,Contract,Both Schedule and Contract]
      // Type IN [Resource,G/L Account,Item]

      // Setup
      Initialize;
      LibraryJob.CreateJob(Job);
      LibraryJob.CreateJobTask(Job,JobTask);

      // Exercise
      LibraryJob.CreateJobJournalLineForType(LineType,Type,JobTask,JobJournalLine);

      // Verify
      VerifyJobJournalLineCostPrice(JobJournalLine);

      // Exercise
      LibraryJob.CopyJobJournalLines(JobJournalLine,TempJobJournalLine);
      LibraryJob.PostJobJournal(JobJournalLine);

      // Verify (planning lines and job ledger)
      LibraryJob.VerifyJobJournalPosting(FALSE,TempJobJournalLine);

      TearDown;
Member of Lib.Library - Job


CopyPurchaseLines@41 Method

The procedure CopyPurchaseLines is available in codeunit 131920.

Syntax

CopyPurchaseLines@41(
    VAR FromPurchaseLine@1000 : Record 39 FromPurchaseLine, //Reference parameter of type Record
    VAR ToPurchaseLine@1001 : Record 39 ToPurchaseLine //Reference parameter of type Record
);

Parameters

FromPurchaseLine
Reference parameter of type Record
ToPurchaseLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Copy, Purchase, Lines.

For a clarification about how this function works, refer to the code listed below.

      FromPurchaseLine.FINDSET;
      REPEAT
        ToPurchaseLine := FromPurchaseLine;
        ToPurchaseLine.INSERT;
      UNTIL FromPurchaseLine.NEXT = 0

Example

The below example is extracted from the test automation codeunit 136300 to show one way of using this function.

      // Parameterized test

      // PurchaseDocumentType IN [Order,Invoice]
      // PurchaseLineType IN [Item,G/L Account]
      // JobLineType IN ["",Schedule,Contract,Both Schedule and Contract]

      // Setup
      Initialize;
      LibraryJob.CreateJob(Job);
      LibraryJob.CreateJobTask(Job,JobTask);

      // Exercise
      CreateSingleLinePurchaseDoc(PurchaseDocumentType,PurchaseHeader);

      // Attach requested account type to the created purchase line
      GetPurchaseLines(PurchaseHeader,PurchaseLine);

      UpdatePurchLine(PurchaseLine,LibraryJob.Job2PurchaseConsumableType(ConsumableType));
      LibraryJob.AttachJobTask2PurchaseLine(JobTask,PurchaseLine);
      PurchaseLine.VALIDATE("Job Line Type",JobLineType);
      PurchaseLine.VALIDATE(Description,LibraryUtility.GenerateGUID);
      PurchaseLine.MODIFY(TRUE);
      LibraryJob.CopyPurchaseLines(PurchaseLine,TempPurchaseLine);
      PostPurchaseDocument(PurchaseHeader,PurchInvHeader);

      // Verify (planning lines, job ledger)
      LibraryJob.VerifyPurchaseDocPostingForJob(TempPurchaseLine);
      JobLedgerEntry.SETRANGE(Description,TempPurchaseLine.Description);
      Assert.AreEqual(1,JobLedgerEntry.COUNT,'# job ledger entries');
      JobLedgerEntry.FINDFIRST;

      LibraryJob.VerifyGLEntries(JobLedgerEntry);

      TearDown;
Member of Lib.Library - Job


CreateCapitalizeCWIPHeader@1500005 Method

The procedure CreateCapitalizeCWIPHeader is available in codeunit 131920.

Syntax

CreateCapitalizeCWIPHeader@1500005(
    VAR CapitalizeCWIPHeader@1500000 : Record 16597 CapitalizeCWIPHeader, //Reference parameter of type Record
    JobNo@1500001 : Code[20] JobNo //Input parameter of type Code
);

Parameters

CapitalizeCWIPHeader
Reference parameter of type Record
JobNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Capitalize, CWIP, Header.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(CapitalizeCWIPHeader);
      JobsSetup.GET;
      JobsSetup.VALIDATE("Capitalize CWIP Nos.",LibraryERM.CreateNoSeriesCode);
      JobsSetup.VALIDATE("Posted Capitalize CWIP Nos.",LibraryERM.CreateNoSeriesCode);
      JobsSetup.MODIFY(TRUE);
      CapitalizeCWIPHeader.INSERT(TRUE);
      IF JobNo = '' THEN BEGIN
        CreateJob(Job);
        JobNo := Job."No.";
      END;
      CapitalizeCWIPHeader.VALIDATE("Job No.",JobNo);
      CapitalizeCWIPHeader.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 144080 to show one way of using this function.

      // [SCENARIO 163859] Verify program behaves correctly after creating a Capitalize CWIP entry and making changes to fields "% to capitalize" and "Amount to capitalize".
      // [FEATURE] [Job Transactions]

      // [GIVEN] Created Job Posting Group,Job,Location
      LibraryJob.CreateJobWithPostingGroup(Job,JobPostingGroup);
      LibraryWarehouse.CreateLocation(Location);

      // [WHEN] Create Job Task Lines, Job Planning Lines and capitalize CWIP Document
      CreateJobTaskLines(Job,JobTask[1],JobTaskType::Heading);
      CreateJobTaskLines(Job,JobTask[2],JobTaskType::"Begin-Total");
      CreateJobTaskLines(Job,JobTask[3],JobTaskType::Posting);
      CreateJobTaskLines(Job,JobTask[4],JobTaskType::"End-Total");
      CreateAndPostJobJournalLines(JobJournalLine,JobTask[3],Location,1,LibraryRandom.RandDec(100000,2));
      CalculateAndPostWIPToGL(Job);
      LibraryJob.CreateJobPlanningLine(JobPlanningLine."Line Type"::Schedule,JobPlanningLine.Type::Item,JobTask[3],JobPlanningLine);
      LibraryJob.CreateCapitalizeCWIPHeader(CapitalizeCWIPHeader,Job."No.");
      GenerateJobTaskLines(CapitalizeCWIPHeader."No.",Job."No.");
      ChangePercentageInJobLines(CapitalizeCWIPLine,CapitalizeCWIPHeader."No.",LibraryRandom.RandDec(10,2),TRUE);
      CalculateExpectedCWIPLineAmount(
        ExpectedCapitalizeCWIPLine,CapitalizeCWIPLine."Remaining CWIP Amt (Material)",
        CapitalizeCWIPLine."Remaining CWIP Amt (Overheads)",CapitalizeCWIPLine."Remaining CWIP Amt (Overheads)",
        CapitalizeCWIPLine."% to Capitalize (Labor)");

      // [THEN] Created capitalized CWIP Lines
      VerifyCWIPLines(CapitalizeCWIPLine,ExpectedCapitalizeCWIPLine);

      // [WHEN] Create Job Task Lines, Job Planning Lines and capitalize CWIP Document
      ChangePercentageInJobLines(CapitalizeCWIPLine,CapitalizeCWIPHeader."No.",LibraryRandom.RandDec(10,2),FALSE);
      CalculateExpectedRemainingAmount(
        ExpectedCapitalizeCWIPLine2,CapitalizeCWIPLine."Amt to Capitalize (Labor)",CapitalizeCWIPLine."Remaining CWIP Amt (Labor)");

      // [THEN] Created Capitalized CWIP Lines With Capitalize Amount(Labour),Capitalize Amount(material),Capitalize Amount(Overheads)
      VerifyCWIPLinesWithPercentage(CapitalizeCWIPLine,ExpectedCapitalizeCWIPLine2);
Member of Lib.Library - Job


CreateConsumable@20 Method

The procedure CreateConsumable is available in codeunit 131920.

Syntax

CreateConsumable@20(
    Type@1000 : Integer Type //Input parameter of type Integer
);

Parameters

Type
Input parameter of type Integer

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Consumable.

For a clarification about how this function works, refer to the code listed below.

      CASE Type OF
        ResourceType:
          BEGIN
            Resource.GET(FindConsumable(Type));
            ResourceUnitOfMeasure.GET(Resource."No.",Resource."Base Unit of Measure");
            Resource."No." := '';
            Resource.INSERT(TRUE);
            ResourceUnitOfMeasure."Resource No." := Resource."No.";
            ResourceUnitOfMeasure.INSERT(TRUE);
            EXIT(Resource."No.")
          END;
        ItemType:
          BEGIN
            Item.GET(FindConsumable(Type));
            ItemUnitOfMeasure.GET(Item."No.",Item."Base Unit of Measure");
            Item."No." := '';
            Item.INSERT(TRUE);
            ItemUnitOfMeasure."Item No." := Item."No.";
            ItemUnitOfMeasure.INSERT(TRUE);
            EXIT(Item."No.")
          END;
        GLAccountType:
          BEGIN
            GLAccount.GET(FindConsumable(Type));
            GLAccount."No." := '';
            GLAccount.INSERT(TRUE);
            EXIT(GLAccount."No.")
          END;
        ELSE
          Assert.Fail('Unsupported consumable type');
      END

Example

The below example is extracted from the test automation codeunit 134381 to show one way of using this function.

      // Setup.
      Initialize;

      SetupDimensionPriorityForJobJnlSrcCode(TableIDs,Priorities);
      DimensionCode := CreateDimensionValues(DimValueArray);
      LibraryJob.CreateJob(Job);
      LibraryDimension.CreateDefaultDimension(DefaultDimension,DATABASE::Job,Job."No.",DimensionCode,DimValueArray[1]);
      LibraryJob.CreateJobTask(Job,JobTask);
      IF FillJobTaskNo THEN
        UpdateJobTaskDimension(JobTask,DimensionCode,DimValueArray[2]);
      ResourceNo := LibraryJob.CreateConsumable(0); // Use 0 for Resource
      LibraryDimension.CreateDefaultDimension(
        DefaultDimension,DATABASE::Resource,ResourceNo,DimensionCode,DimValueArray[3]);

      // Exercise.
      IF NOT FillJobTaskNo THEN
        JobTask."Job Task No." := '';
      CreateJobJnlLine(JobTask,ResourceNo);

      // Verify.
      VerifyDimValueInJobJnlLine(Job."No.",JobTask."Job Task No.",DimensionCode,DimValueArray[ExpectedDimValueIndex]);
Member of Lib.Library - Job


CreateGeneralPostingSetup@52 Method

The procedure CreateGeneralPostingSetup is available in codeunit 131920.

Syntax

CreateGeneralPostingSetup@52(
    GenBusinessPostingGroupCode@1000 : Code[10] GenBusinessPostingGroupCode, //Input parameter of type Code
    GenProductPostingGroupCode@1001 : Code[10] GenProductPostingGroupCode, //Input parameter of type Code
    VAR GeneralPostingSetup@1002 : Record 252 GeneralPostingSetup //Reference parameter of type Record
);

Parameters

GenBusinessPostingGroupCode
Input parameter of type Code
GenProductPostingGroupCode
Input parameter of type Code
GeneralPostingSetup
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, General, Posting, Setup.

For a clarification about how this function works, refer to the code listed below.

      WITH GeneralPostingSetup DO BEGIN
        "Gen. Bus. Posting Group" := GenBusinessPostingGroupCode;
        "Gen. Prod. Posting Group" := GenProductPostingGroupCode;
        INIT;
        INSERT(TRUE);
      END;

Example

The below example is extracted from the test automation codeunit 134106 to show one way of using this function.

      LibraryERM.CreateGenBusPostingGroup(GenBusPostingGroup);
      GenBusPostingGroupCode := GenBusPostingGroup.Code;
      LibraryERM.CreateGenProdPostingGroup(GenProdPostingGroup);
      GenProdPostingGroupCode := GenProdPostingGroup.Code;
      LibraryERM.CreateGeneralPostingSetup(GenPostingSetup,GenBusPostingGroupCode,GenProdPostingGroupCode);
Member of Lib.Library - Job


CreateGenJournalBatch@62 Method

The procedure CreateGenJournalBatch is available in codeunit 131920.

Syntax

CreateGenJournalBatch@62(
    GenJournalTemplateName@1002 : Code[10] GenJournalTemplateName, //Input parameter of type Code
    VAR GenJournalBatch@1000 : Record 232 GenJournalBatch //Reference parameter of type Record
);

Parameters

GenJournalTemplateName
Input parameter of type Code
GenJournalBatch
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, General, Journal, Batch.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(GenJournalBatch);

      // Find a unique name (wrt existing and previously posted batches)
      BatchName := PrefixLbl + 'B000';
      REPEAT
        BatchName := INCSTR(BatchName);
        GLEntry.SETRANGE("Journal Batch Name",BatchName);
        JobLedgerEntry.SETRANGE("Journal Batch Name",BatchName);
      UNTIL GLEntry.ISEMPTY AND JobLedgerEntry.ISEMPTY AND NOT GenJournalBatch.GET(GenJournalTemplateName,BatchName);

      GenJournalBatch.VALIDATE("Journal Template Name",GenJournalTemplateName);
      GenJournalBatch.VALIDATE(Name,BatchName);
      GenJournalBatch.SetupNewBatch;
      GenJournalBatch.INSERT(TRUE)

Example

The below example is extracted from the test automation codeunit 136300 to show one way of using this function.

      MaxVATDiff := LibraryRandom.RandDec(2,2);
      UpdateGeneralLedgerSetupMaxVATDiff(MaxVATDiff);
      LibraryERM.CreateGenJournalTemplate(GenJournalTemplate);
      GenJournalTemplate.VALIDATE(Type,GenJournalTemplate.Type::Jobs);
      GenJournalTemplate.VALIDATE("Allow VAT Difference",TRUE);
      GenJournalTemplate.MODIFY(TRUE);
      LibraryERM.CreateGenJournalBatch(GenJournalBatch,GenJournalTemplate.Name);
      GenJournalBatch.VALIDATE("Allow VAT Difference",TRUE);
      GenJournalBatch.MODIFY(TRUE);
Member of Lib.Library - Job


CreateGenJournalLineForPlan@60 Method

The procedure CreateGenJournalLineForPlan is available in codeunit 131920.

Syntax

CreateGenJournalLineForPlan@60(
    JobPlanningLine@1003 : Record 1003 JobPlanningLine, //Input parameter of type Record
    UsageLineType@1002 : Option UsageLineType, //Input parameter of type Option
    Fraction@1001 : Decimal Fraction, //Input parameter of type Decimal
    VAR GenJournalLine@1000 : Record 81 GenJournalLine //Reference parameter of type Record
);

Parameters

JobPlanningLine
Input parameter of type Record
UsageLineType
Input parameter of type Option
Fraction
Input parameter of type Decimal
GenJournalLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, General, Journal, Line, For, Plan.

For a clarification about how this function works, refer to the code listed below.

      Assert.IsTrue(JobPlanningLine."Usage Link",'Usage link should be enabled');

      JobTask.GET(JobPlanningLine."Job No.",JobPlanningLine."Job Task No.");
      CreateJobGLJournalLine(UsageLineType,JobTask,GenJournalLine);

      WITH GenJournalLine DO BEGIN
        "Account No." := JobPlanningLine."No.";
        VALIDATE(Description,LibraryUtility.GenerateGUID);
        VALIDATE("Job Planning Line No.",JobPlanningLine."Line No.");
        VALIDATE("Job Quantity",ROUND(Fraction * JobPlanningLine."Remaining Qty."));
        MODIFY(TRUE)
      END

Example

There are no examples available.
Member of Lib.Library - Job


CreateJob@4 Method

The procedure CreateJob is available in codeunit 131920.

Syntax

CreateJob@4(
    VAR Job@1002 : Record 167 Job //Reference parameter of type Record
);

Parameters

Job
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Job.

For a clarification about how this function works, refer to the code listed below.

      // create a (LCY) job for a random customer

      // Find the next available job no.
      JobNo := PrefixLbl + 'J000';
      REPEAT
        JobNo := INCSTR(JobNo);
      UNTIL NOT Job.GET(JobNo);

      Job.INIT;
      Job.VALIDATE("No.",JobNo);
      Job.INSERT(TRUE);
      Job.VALIDATE("Bill-to Customer No.",CreateCustomer);
      Job.VALIDATE("Job Posting Group",FindJobPostingGroup);
      Job.MODIFY(TRUE)

Example

The below example is extracted from the test automation codeunit 134101 to show one way of using this function.

      LibraryJob.CreateJob(Job);
      LibraryJob.CreateJobTask(Job,JobTask);
Member of Lib.Library - Job


CreateJobGLAccountPrice@71 Method

The procedure CreateJobGLAccountPrice is available in codeunit 131920.

Syntax

CreateJobGLAccountPrice@71(
    VAR JobGLAccountPrice@1001 : Record 1014 JobGLAccountPrice, //Reference parameter of type Record
    JobNo@1000 : Code[20] JobNo, //Input parameter of type Code
    JobTaskNo@1003 : Code[20] JobTaskNo, //Input parameter of type Code
    GLAccountNo@1004 : Code[20] GLAccountNo, //Input parameter of type Code
    CurrencyCode@1006 : Code[10] CurrencyCode //Input parameter of type Code
);

Parameters

JobGLAccountPrice
Reference parameter of type Record
JobNo
Input parameter of type Code
JobTaskNo
Input parameter of type Code
GLAccountNo
Input parameter of type Code
CurrencyCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Job, General Ledger, Account, Price.

For a clarification about how this function works, refer to the code listed below.

      JobGLAccountPrice.INIT;
      JobGLAccountPrice.VALIDATE("Job No.",JobNo);
      JobGLAccountPrice.VALIDATE("Job Task No.",JobTaskNo);
      JobGLAccountPrice.VALIDATE("G/L Account No.",GLAccountNo);
      JobGLAccountPrice.VALIDATE("Currency Code",CurrencyCode);
      JobGLAccountPrice.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136305 to show one way of using this function.

      // Test Job Unit Cost, Job Unit Price on Job G/L Journal Line when Unit Cost Factor is defined on Job Card.

      // 1. Setup: Create Job with Job Task and Job G/L Account Price.
      Initialize;
      CreateJobJournalBatch(GenJournalBatch);
      CreateJobWithJobTask(JobTask);
      LibraryJob.CreateJobGLAccountPrice(
        JobGLAccountPrice,JobTask."Job No.",JobTask."Job Task No.",LibraryERM.CreateGLAccountNo,'');
      UpdateUnitCostFactorOnJobGLAccountPrice(JobGLAccountPrice);

      // 2. Exercise: Create Job G/L Journal Line, Taking rounding precision as used in General Journal Line Table rounding precision.
      CreateJobGLJournalLine(
        GenJournalLine,GenJournalBatch,GenJournalLine."Bal. Account Type"::"G/L Account",JobGLAccountPrice."G/L Account No.",
        LibraryERM.CreateGLAccountNo,JobGLAccountPrice."Job No.",JobGLAccountPrice."Job Task No.",'');  // Passing Blank for Currency Code.
      JobUnitCost := GenJournalLine.Amount / GenJournalLine."Job Quantity";
      JobUnitPrice :=
        ROUND(
          (GenJournalLine.Amount / GenJournalLine."Job Quantity") * JobGLAccountPrice."Unit Cost Factor",
          LibraryJob.GetUnitAmountRoundingPrecision(GenJournalLine."Currency Code"));

      // 3. Verify: Verify values on Job G/L Journal Lines.
      VerifyJobGLJournalLine(GenJournalLine,JobUnitCost,JobUnitPrice);

      // 4. Tear Down: Delete newly created batch.
      GenJournalBatch.GET(GenJournalLine."Journal Template Name",GenJournalLine."Journal Batch Name");
      GenJournalBatch.DELETE(TRUE);
Member of Lib.Library - Job


CreateJobGLJournalLine@50 Method

The procedure CreateJobGLJournalLine is available in codeunit 131920.

Syntax

CreateJobGLJournalLine@50(
    JobLineType@1006 : Option JobLineType, //Input parameter of type Option
    JobTask@1000 : Record 1001 JobTask, //Input parameter of type Record
    VAR GenJournalLine@1001 : Record 81 GenJournalLine //Reference parameter of type Record
);

Parameters

JobLineType
Input parameter of type Option
JobTask
Input parameter of type Record
GenJournalLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Job, General Ledger, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      // Create a general journal line for a job task.
      // This helper function allows to easily create multiple journal lines in a single batch.
      // These journal lines can be traced using their document number and batch.
      LibraryERM.CreateGLAccount(GLAccount);
      WITH GenJournalLine DO BEGIN
        SETRANGE("Job No.",JobTask."Job No.");
        IF FINDLAST THEN
          VALIDATE("Line No.","Line No." + 1)
        ELSE BEGIN
          CLEAR(GenJournalLine);
          CreateGenJournalBatch(GetGenJournalTemplate(GenJournalTemplate),GenJournalBatch);
          VALIDATE("Journal Template Name",GenJournalTemplate.Name);
          VALIDATE("Journal Batch Name",GenJournalBatch.Name);
          VALIDATE("Line No.",1);
          SETRANGE("Journal Template Name","Journal Template Name");
          SETRANGE("Journal Batch Name","Journal Batch Name");
        END;

        INIT;
        INSERT(TRUE);

        VALIDATE("Posting Date",WORKDATE);
        VALIDATE("Account Type","Account Type"::"G/L Account");
        VALIDATE("Account No.",GLAccount."No.");
        VALIDATE(Description,GLAccount."No.");
        LibraryERM.CreateGLAccount(GLAccount);
        VALIDATE("Bal. Account No.",GLAccount."No.");
        VALIDATE(Amount,LibraryRandom.RandDec(100,2));
        VALIDATE("Job Line Type",JobLineType);
        VALIDATE("Job No.",JobTask."Job No.");
        VALIDATE("Job Task No.",JobTask."Job Task No.");
        VALIDATE("Job Quantity",LibraryRandom.RandInt(10));
        GenJournalBatch.GET(GetGenJournalTemplate(GenJournalTemplate),"Journal Batch Name");
        VALIDATE("Document No.",NoSeriesMgt.GetNextNo(GenJournalBatch."No. Series","Posting Date",FALSE));
        VALIDATE("Source Code",GenJournalTemplate."Source Code");
        MODIFY(TRUE)
      END

Example

The below example is extracted from the test automation codeunit 136306 to show one way of using this function.

      // SETUP
      Initialize;
      CreateJobTaskWithDimensions(JobTask);
      LibraryJob.CreateJobJournalLine(JobJnlLine.Type::"G/L Account",JobTask,JobJnlLine);

      // EXERCISE: Add Job General Line
      LibraryJob.CreateJobGLJournalLine(GenJournalLine."Job Line Type"::"Both Schedule and Contract",JobTask,GenJournalLine);

      // VERIFY
      Assert.AreEqual(JobJnlLine."Dimension Set ID",GenJournalLine."Dimension Set ID",
        STRSUBSTNO(WrongJobJnlDimensionsErr,GenJournalLine.FIELDCAPTION("Dimension Set ID")));
      Assert.AreEqual(JobJnlLine."Shortcut Dimension 1 Code",GenJournalLine."Shortcut Dimension 1 Code",
        STRSUBSTNO(WrongJobJnlDimensionsErr,GenJournalLine.FIELDCAPTION("Shortcut Dimension 1 Code")));
      Assert.AreEqual(JobJnlLine."Shortcut Dimension 2 Code",GenJournalLine."Shortcut Dimension 2 Code",
        STRSUBSTNO(WrongJobJnlDimensionsErr,GenJournalLine.FIELDCAPTION("Shortcut Dimension 2 Code")));
Member of Lib.Library - Job


CreateJobItemPrice@72 Method

The procedure CreateJobItemPrice is available in codeunit 131920.

Syntax

CreateJobItemPrice@72(
    VAR JobItemPrice@1001 : Record 1013 JobItemPrice, //Reference parameter of type Record
    JobNo@1000 : Code[20] JobNo, //Input parameter of type Code
    JobTaskNo@1003 : Code[20] JobTaskNo, //Input parameter of type Code
    ItemNo@1004 : Code[20] ItemNo, //Input parameter of type Code
    CurrencyCode@1006 : Code[10] CurrencyCode, //Input parameter of type Code
    VariantCode@1002 : Code[10] VariantCode, //Input parameter of type Code
    UnitOfMeasureCode@1005 : Code[10] UnitOfMeasureCode //Input parameter of type Code
);

Parameters

JobItemPrice
Reference parameter of type Record
JobNo
Input parameter of type Code
JobTaskNo
Input parameter of type Code
ItemNo
Input parameter of type Code
CurrencyCode
Input parameter of type Code
VariantCode
Input parameter of type Code
UnitOfMeasureCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Job, Item, Price.

For a clarification about how this function works, refer to the code listed below.

      JobItemPrice.INIT;
      JobItemPrice.VALIDATE("Job No.",JobNo);
      JobItemPrice.VALIDATE("Job Task No.",JobTaskNo);
      JobItemPrice.VALIDATE("Item No.",ItemNo);
      JobItemPrice.VALIDATE("Currency Code",CurrencyCode);
      JobItemPrice.VALIDATE("Variant Code",VariantCode);
      JobItemPrice.VALIDATE("Unit of Measure Code",UnitOfMeasureCode);
      JobItemPrice.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134327 to show one way of using this function.

      LibraryJob.CreateJob(Job);
      LibraryJob.CreateJobTask(Job,JobTask);
      LibraryJob.CreateJobItemPrice(JobItemPrice,Job."No.",'',ItemNo,'','',UnitOfMeasureCode);
      UnitCostFactor := LibraryRandom.RandDec(1,2);
      JobItemPrice.VALIDATE("Unit Cost Factor",UnitCostFactor);
      JobItemPrice.MODIFY(TRUE);
      LibraryPurchase.CreatePurchHeader(PurchaseHeader,PurchaseHeader."Document Type"::Order,CreateVendor);
      LibraryPurchase.CreatePurchaseLine(
        PurchaseLine,PurchaseHeader,PurchaseLine.Type::Item,ItemNo,LibraryRandom.RandDec(100,2));
      ModifyPurchaseLineJobNo(PurchaseLine,Job."No.",JobTask."Job Task No.",UnitOfMeasureCode);
      PurchaseLine.VALIDATE("Direct Unit Cost",LibraryRandom.RandDec(100,2));
      PurchaseLine.MODIFY(TRUE);
Member of Lib.Library - Job


CreateJobJournalBatch@12 Method

The procedure CreateJobJournalBatch is available in codeunit 131920.

Syntax

CreateJobJournalBatch@12(
    JobJournalTemplateName@1002 : Code[10] JobJournalTemplateName, //Input parameter of type Code
    VAR JobJournalBatch@1000 : Record 237 JobJournalBatch //Reference parameter of type Record
);

Parameters

JobJournalTemplateName
Input parameter of type Code
JobJournalBatch
Reference parameter of type Record

Return Value

Code[10]

Remarks

The relevant search keywords are: Create, Job, Journal, Batch.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(JobJournalBatch);

      // Find a unique batch name (wrt existing and previously posted batches)
      BatchName := PrefixLbl + 'B000';
      REPEAT
        BatchName := INCSTR(BatchName);
      UNTIL NOT JobJournalBatch.GET(JobJournalTemplateName,BatchName);

      JobJournalBatch.VALIDATE("Journal Template Name",JobJournalTemplateName);
      JobJournalBatch.VALIDATE(Name,BatchName);
      JobJournalBatch.SetupNewBatch;
      JobJournalBatch.INSERT(TRUE)

Example

The below example is extracted from the test automation codeunit 136305 to show one way of using this function.

      LibraryJob.CreateJobJournalBatch(LibraryJob.GetJobJournalTemplate(JobJournalTemplate),JobJournalBatch);
      NoSeriesCode := JobJournalBatch."No. Series";  // Assigning Batch No. Series to global variable.
      LibraryVariableStorage.Enqueue(JobJournalBatch."Journal Template Name");
      COMMIT;  // Commit required to avoid test failures.

      // Need to Run Calc. Remaining Usage Batch Job from Job Journal page due to Code Written on Page and Job Journal Lines needed to be blank before running batch job.
      JobJournal.OPENEDIT;
      JobJournal.CurrentJnlBatchName.SETVALUE(JobJournalBatch.Name);
      JobJournal.CalcRemainingUsage.INVOKE;
Member of Lib.Library - Job


CreateJobJournalLine@6 Method

The procedure CreateJobJournalLine is available in codeunit 131920.

Syntax

CreateJobJournalLine@6(
    LineType@1005 : Option LineType, //Input parameter of type Option
    JobTask@1001 : Record 1001 JobTask, //Input parameter of type Record
    VAR JobJournalLine@1000 : Record 210 JobJournalLine //Reference parameter of type Record
);

Parameters

LineType
Input parameter of type Option
JobTask
Input parameter of type Record
JobJournalLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Job, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      // Create a job journal line for a job task.
      // This helper function allows to easily create multiple journal lines in a single batch.

      WITH JobJournalLine DO BEGIN
        SETRANGE("Job No.",JobTask."Job No.");
        // Setup primary keys and filters.
        IF FINDLAST THEN
          // A job journal line for this task already exists: increase line and document nos.
          VALIDATE("Line No.","Line No." + 1)
        ELSE BEGIN
          // No job journal lines exist for this task: setup the first one.
          CreateJobJournalBatch(GetJobJournalTemplate(JobJournalTemplate),JobJournalBatch);
          VALIDATE("Journal Template Name",JobJournalTemplate.Name);
          VALIDATE("Journal Batch Name",JobJournalBatch.Name);
          VALIDATE("Line No.",1);
          // Only use these template and batch.
          SETRANGE("Journal Template Name","Journal Template Name");
          SETRANGE("Journal Batch Name","Journal Batch Name");
        END;

        INIT;
        INSERT(TRUE);

        VALIDATE("Line Type",LineType);
        VALIDATE("Posting Date",WORKDATE);
        VALIDATE("Job No.",JobTask."Job No.");
        VALIDATE("Job Task No.",JobTask."Job Task No.");
        JobJournalBatch.GET(GetJobJournalTemplate(JobJournalTemplate),"Journal Batch Name");
        VALIDATE("Document No.",NoSeriesMgt.GetNextNo(JobJournalBatch."No. Series","Posting Date",FALSE));
        MODIFY(TRUE)
      END

Example

The below example is extracted from the test automation codeunit 134381 to show one way of using this function.

      SourceCodeSetup.GET;
      WITH JobJournalLine DO BEGIN
        LibraryJob.CreateJobJournalLine("Line Type"::Schedule,JobTask,JobJournalLine);
        VALIDATE("Source Code",SourceCodeSetup."Job Journal");
        VALIDATE(Type,Type::Resource);
        VALIDATE("No.",ResourceNo);
        MODIFY(TRUE);
      END;
Member of Lib.Library - Job


CreateJobJournalLineForPlan@39 Method

The procedure CreateJobJournalLineForPlan is available in codeunit 131920.

Syntax

CreateJobJournalLineForPlan@39(
    JobPlanningLine@1000 : Record 1003 JobPlanningLine, //Input parameter of type Record
    UsageLineType@1002 : Option UsageLineType, //Input parameter of type Option
    Fraction@1004 : Decimal Fraction, //Input parameter of type Decimal
    VAR JobJournalLine@1001 : Record 210 JobJournalLine //Reference parameter of type Record
);

Parameters

JobPlanningLine
Input parameter of type Record
UsageLineType
Input parameter of type Option
Fraction
Input parameter of type Decimal
JobJournalLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Job, Journal, Line, For, Plan.

For a clarification about how this function works, refer to the code listed below.

      Assert.IsTrue(JobPlanningLine."Usage Link",'Usage link should be enabled');

      JobTask.GET(JobPlanningLine."Job No.",JobPlanningLine."Job Task No.");
      CreateJobJournalLine(UsageLineType,JobTask,JobJournalLine);
      WITH JobJournalLine DO BEGIN
        VALIDATE(Type,JobPlanningLine.Type);
        VALIDATE("No.",JobPlanningLine."No.");
        VALIDATE(Description,LibraryUtility.GenerateGUID);
        VALIDATE(Quantity,ROUND(Fraction * JobPlanningLine."Remaining Qty."));
        // unit costs, prices may change (e.g., +/- 10%)
        IF NOT IsStandardCosting(Type,"No.") THEN BEGIN
          ChangeFactor := ROUND((1 + (LibraryRandom.RandInt(21) - 11) / 100));
          VALIDATE("Unit Cost",ROUND(ChangeFactor * JobPlanningLine."Unit Cost") / JobPlanningLine.Quantity);
          VALIDATE("Unit Price",ROUND(ChangeFactor * JobPlanningLine."Unit Price") / JobPlanningLine.Quantity)
        END;
        MODIFY(TRUE)
      END

Example

The below example is extracted from the test automation codeunit 136302 to show one way of using this function.

      // [FEATURE] [Update Job Item Cost]
      // [SCENARIO] Update Job Item Cost job updates Planning Line "Posted Total Cost" after setting a different Item Cost in Purchase Order

      // 1. Setup: Create an Item, a Job, a Job Task, a Job Planning Line, a Purchase Header and a Purchase Line. In Purchase Line make sure that the "Direct Unit Cost" is
      // different form Item's Unit Cost.
      Initialize;

      // Create Item
      LibraryInventory.CreateItem(Item);
      Item.VALIDATE("Unit Cost",LibraryRandom.RandDecInRange(1,1000,2));
      Item.VALIDATE("Costing Method",Item."Costing Method"::FIFO);
      Item.MODIFY(TRUE);

      CreateJobTaskWithApplyUsageLink(JobTask);

      // Create JobPlanningLine:
      LibraryJob.CreateJobPlanningLine(JobPlanningLine."Line Type"::"Both Schedule and Contract",
        JobPlanningLine.Type::Item,JobTask,JobPlanningLine);
      JobPlanningLine.VALIDATE("No.",Item."No.");
      JobPlanningLine.VALIDATE(Quantity,LibraryRandom.RandInt(10));
      JobPlanningLine.MODIFY(TRUE);

      LibraryJob.CreateJobJournalLineForPlan(JobPlanningLine,LibraryJob.UsageLineTypeBlank,
        LibraryRandom.RandDecInRange(10,20,2),JobJournalLine);
      LibraryJob.PostJobJournal(JobJournalLine);

      // Create PurchaseHeader
      LibraryPurchase.CreatePurchHeader(PurchaseHeader,PurchaseHeader."Document Type"::Order,'');

      // Create PurchaseLine
      LibraryPurchase.CreatePurchaseLine(
        PurchaseLine,PurchaseHeader,LibraryJob.Job2PurchaseConsumableType(JobPlanningLine.Type),
        Item."No.",LibraryRandom.RandInt(10));

      WITH PurchaseLine DO BEGIN
        VALIDATE(Description,LibraryUtility.GenerateGUID);
        VALIDATE("Unit of Measure Code",JobPlanningLine."Unit of Measure Code");
        // give a different unit cost:
        VALIDATE("Direct Unit Cost",LibraryRandom.RandDecInRange(1000,2000,2));
        MODIFY(TRUE)
      END;

      // 2. Exercise: Post Purchase and then run Adjust Cost - Item Entries and Update Job Item Cost jobs.
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

      JobPlanningLine.GET(JobPlanningLine."Job No.",JobPlanningLine."Job Task No.",JobPlanningLine."Line No.");
      PlanningLineDirectUnitCostBeforeJobs := JobPlanningLine."Posted Total Cost";

      // Run the first job: AdjustCostItemEntries. Item."Unit Cost" should be updated after this
      // since unit cost is changed in PurchaseLine above:
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');

      // Run the second job: RunUpdateJobItemCost. PlanningLine."Direct Unit Cost" should be updated:
      LibraryJob.RunUpdateJobItemCost(JobTask."Job No.");

      JobPlanningLine.GET(JobPlanningLine."Job No.",JobPlanningLine."Job Task No.",JobPlanningLine."Line No.");
      PlanningLineDirectUnitCostAfterJobs := JobPlanningLine."Posted Total Cost";

      // 3. Verify: Ensure that the Planning Line's Direct Unit Cost has changed after running jobs
      Assert.AreNotEqual(
        PlanningLineDirectUnitCostBeforeJobs,
        PlanningLineDirectUnitCostAfterJobs,
        'PlanningLine."Direct Unit Cost" must be changed after running AdjustCostItemEntries and UpdateJobItemCost');
Member of Lib.Library - Job


CreateJobJournalLineForType@22 Method

The procedure CreateJobJournalLineForType is available in codeunit 131920.

Syntax

CreateJobJournalLineForType@22(
    LineType@1003 : Option LineType, //Input parameter of type Option
    ConsumableType@1002 : Option ConsumableType, //Input parameter of type Option
    JobTask@1001 : Record 1001 JobTask, //Input parameter of type Record
    VAR JobJournalLine@1000 : Record 210 JobJournalLine //Reference parameter of type Record
);

Parameters

LineType
Input parameter of type Option
ConsumableType
Input parameter of type Option
JobTask
Input parameter of type Record
JobJournalLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Job, Journal, Line, For, Type.

For a clarification about how this function works, refer to the code listed below.

      CreateJobJournalLine(LineType,JobTask,JobJournalLine);

      // Attach requested consumable type to the created job journal line
      Attach2JobJournalLine(ConsumableType,JobJournalLine);
      JobJournalLine.VALIDATE(Description,FORMAT(LibraryUtility.GenerateGUID));
      JobJournalLine.MODIFY(TRUE)

Example

The below example is extracted from the test automation codeunit 136300 to show one way of using this function.

      // Parameterized test

      // LineType IN ["",Schedule,Contract,Both Schedule and Contract]
      // Type IN [Resource,G/L Account,Item]

      // Setup
      Initialize;
      LibraryJob.CreateJob(Job);
      LibraryJob.CreateJobTask(Job,JobTask);

      // Exercise
      LibraryJob.CreateJobJournalLineForType(LineType,Type,JobTask,JobJournalLine);

      // Verify
      VerifyJobJournalLineCostPrice(JobJournalLine);

      // Exercise
      LibraryJob.CopyJobJournalLines(JobJournalLine,TempJobJournalLine);
      LibraryJob.PostJobJournal(JobJournalLine);

      // Verify (planning lines and job ledger)
      LibraryJob.VerifyJobJournalPosting(FALSE,TempJobJournalLine);

      TearDown;
Member of Lib.Library - Job


CreateJobJournalTemplate@75 Method

The procedure CreateJobJournalTemplate is available in codeunit 131920.

Syntax

CreateJobJournalTemplate@75(
    VAR JobJournalTemplate@1001 : Record 209 JobJournalTemplate //Reference parameter of type Record
);

Parameters

JobJournalTemplate
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Job, Journal, Template.

For a clarification about how this function works, refer to the code listed below.

      JobJournalTemplate.INIT;
      JobJournalTemplate.VALIDATE(
        Name,LibraryUtility.GenerateRandomCode(JobJournalTemplate.FIELDNO(Name),DATABASE::"Job Journal Template"));
      JobJournalTemplate.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136504 to show one way of using this function.

      // Check that Suggest Lines from Time Sheets exists menu of Job Journal Line.

      // Setup: Create Time Sheet and Job Task.
      Initialize;
      LibraryJob.CreateJobJournalTemplate(JobJournalTemplate);
      TimeSheetNo := CreateTimeSheet(TimeSheetLine);
      CreateJobAndJobTask(JobTask);
      COMMIT;

      // Exercise.
      JobJournal.OPENEDIT;
      JobJournal.SuggestLinesFromTimeSheets.INVOKE;

      // Verify: Verification done in JobJournalLineHandler handler.
Member of Lib.Library - Job


CreateJobPlanningLine@2 Method

The procedure CreateJobPlanningLine is available in codeunit 131920.

Syntax

CreateJobPlanningLine@2(
    LineType@1002 : Integer LineType, //Input parameter of type Integer
    Type@1003 : Integer Type, //Input parameter of type Integer
    JobTask@1000 : Record 1001 JobTask, //Input parameter of type Record
    VAR JobPlanningLine@1001 : Record 1003 JobPlanningLine //Reference parameter of type Record
);

Parameters

LineType
Input parameter of type Integer
Type
Input parameter of type Integer
JobTask
Input parameter of type Record
JobPlanningLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Job, Planning, Line.

For a clarification about how this function works, refer to the code listed below.

      // Create a job planning line for job task <JobTask> of type <LineType> for consumable type <Type>

      JobPlanningLine.INIT;
      JobPlanningLine.VALIDATE("Job No.",JobTask."Job No.");
      JobPlanningLine.VALIDATE("Job Task No.",JobTask."Job Task No.");
      JobPlanningLine.VALIDATE("Line No.",GetNextLineNo(JobPlanningLine));
      JobPlanningLine.INSERT(TRUE);

      JobPlanningLine.VALIDATE("Planning Date",WORKDATE);
      JobPlanningLine.VALIDATE("Line Type",LineType);
      JobPlanningLine.VALIDATE(Type,Type);
      JobPlanningLine.VALIDATE("No.",FindConsumable(Type));
      JobPlanningLine.VALIDATE(Quantity,LibraryRandom.RandInt(100)); // 1 <= Quantity <= 100
      IF Type = GLAccountType THEN BEGIN
        JobPlanningLine.VALIDATE("Unit Cost",LibraryRandom.RandInt(10)); // 1 <= Unit Cost <= 10
        JobPlanningLine.VALIDATE("Unit Price",JobPlanningLine."Unit Cost" * (LibraryRandom.RandIntInRange(2,10) / 10)); // 10% <= Markup <= 100%
      END;
      JobPlanningLine.VALIDATE(Description,LibraryUtility.GenerateGUID);
      JobPlanningLine.MODIFY(TRUE);

      JobPlanningLine.SETRANGE("Job No.",JobTask."Job No.");
      JobPlanningLine.SETRANGE("Job Task No.",JobTask."Job Task No.")

Example

The below example is extracted from the test automation codeunit 136131 to show one way of using this function.

      LibraryJob.CreateJob(Job);
      Job.VALIDATE("Apply Usage Link",TRUE);
      Job.VALIDATE("Description 2",DescriptionText);
      Job.MODIFY;

      // Job Task Line:
      LibraryJob.CreateJobTask(Job,JobTaskLine);
      JobTaskLine.MODIFY;

      // Job Planning Line:
      LibraryJob.CreateJobPlanningLine(JobPlanningLine."Line Type"::Schedule,
        JobPlanningLine.Type::Item,JobTaskLine,JobPlanningLine);

      JobPlanningLine.VALIDATE("Planning Date",PlanDate);
      JobPlanningLine.VALIDATE("Usage Link",TRUE);

      DocumentNo := DELCHR(FORMAT(TODAY),'=','-/') + '_' + DELCHR(FORMAT(TIME),'=',':');
      JobPlanningLine.VALIDATE("Document No.",DocumentNo);
      JobPlanningLine.VALIDATE("No.",ItemNo);
      JobPlanningLine.VALIDATE("Location Code",LocationCode);
      JobPlanningLine.VALIDATE("Variant Code",VariantCode);
      JobPlanningLine.VALIDATE(Quantity,ItemQuantity);
      JobPlanningLine.MODIFY;

      EXIT(Job."No.");
Member of Lib.Library - Job


CreateJobPostingGroup@16 Method

The procedure CreateJobPostingGroup is available in codeunit 131920.

Syntax

CreateJobPostingGroup@16(
    VAR JobPostingGroup@1000 : Record 208 JobPostingGroup //Reference parameter of type Record
);

Parameters

JobPostingGroup
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Job, Posting, Group.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(JobPostingGroup);
      JobPostingGroup.VALIDATE(Code,
        LibraryUtility.GenerateRandomCode(JobPostingGroup.FIELDNO(Code),DATABASE::"Job Posting Group"));
      JobPostingGroup.VALIDATE("WIP Costs Account",LibraryERM.CreateGLAccountNo);
      JobPostingGroup.VALIDATE("WIP Accrued Costs Account",LibraryERM.CreateGLAccountNo);
      JobPostingGroup.VALIDATE("Job Costs Applied Account",LibraryERM.CreateGLAccountNo);
      JobPostingGroup.VALIDATE("Job Costs Adjustment Account",LibraryERM.CreateGLAccountNo);
      JobPostingGroup.VALIDATE("G/L Expense Acc. (Contract)",LibraryERM.CreateGLAccountNo);
      JobPostingGroup.VALIDATE("Job Sales Adjustment Account",LibraryERM.CreateGLAccountNo);
      JobPostingGroup.VALIDATE("WIP Accrued Sales Account",LibraryERM.CreateGLAccountNo);
      JobPostingGroup.VALIDATE("WIP Invoiced Sales Account",LibraryERM.CreateGLAccountNo);
      JobPostingGroup.VALIDATE("Job Sales Applied Account",LibraryERM.CreateGLAccountNo);
      JobPostingGroup.VALIDATE("Recognized Costs Account",LibraryERM.CreateGLAccountNo);
      JobPostingGroup.VALIDATE("Recognized Sales Account",LibraryERM.CreateGLAccountNo);
      JobPostingGroup.VALIDATE("Item Costs Applied Account",LibraryERM.CreateGLAccountNo);
      JobPostingGroup.VALIDATE("Resource Costs Applied Account",LibraryERM.CreateGLAccountNo);
      JobPostingGroup.VALIDATE("G/L Costs Applied Account",LibraryERM.CreateGLAccountNo);
      JobPostingGroup.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 144078 to show one way of using this function.

      LibrarySetupStorage.Restore;
      IF isInitialized THEN
        EXIT;

      LibraryJob.CreateJobPostingGroup(JobPostingGroup);

      isInitialized := TRUE;
      COMMIT;
Member of Lib.Library - Job


CreateJobResourcePrice@74 Method

The procedure CreateJobResourcePrice is available in codeunit 131920.

Syntax

CreateJobResourcePrice@74(
    VAR JobResourcePrice@1001 : Record 1012 JobResourcePrice, //Reference parameter of type Record
    JobNo@1000 : Code[20] JobNo, //Input parameter of type Code
    JobTaskNo@1003 : Code[20] JobTaskNo, //Input parameter of type Code
    Type@1002 : Option Type, //Input parameter of type Option
    Code@1004 : Code[20] Code, //Input parameter of type Code
    WorkTypeCode@1007 : Code[10] WorkTypeCode, //Input parameter of type Code
    CurrencyCode@1006 : Code[10] CurrencyCode //Input parameter of type Code
);

Parameters

JobResourcePrice
Reference parameter of type Record
JobNo
Input parameter of type Code
JobTaskNo
Input parameter of type Code
Type
Input parameter of type Option
Code
Input parameter of type Code
WorkTypeCode
Input parameter of type Code
CurrencyCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Job, Resource, Price.

For a clarification about how this function works, refer to the code listed below.

      JobResourcePrice.INIT;
      JobResourcePrice.VALIDATE("Job No.",JobNo);
      JobResourcePrice.VALIDATE("Job Task No.",JobTaskNo);
      JobResourcePrice.VALIDATE(Type,Type);
      JobResourcePrice.VALIDATE(Code,Code);
      JobResourcePrice.VALIDATE("Work Type Code",WorkTypeCode);
      JobResourcePrice.VALIDATE("Currency Code",CurrencyCode);
      JobResourcePrice.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136303 to show one way of using this function.

      LibraryJob.CreateJobResourcePrice(
        JobResourcePrice,JobTask."Job No.",JobTask."Job Task No.",JobResourcePriceType,Code,WorkTypeCode,'');
      JobResourcePrice.VALIDATE("Unit Price",UnitPrice);
      JobResourcePrice.MODIFY(TRUE);
Member of Lib.Library - Job


CreateJobTask@5 Method

The procedure CreateJobTask is available in codeunit 131920.

Syntax

CreateJobTask@5(
    Job@1000 : Record 167 Job, //Input parameter of type Record
    VAR JobTask@1001 : Record 1001 JobTask //Reference parameter of type Record
);

Parameters

Job
Input parameter of type Record
JobTask
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Job, Task.

For a clarification about how this function works, refer to the code listed below.

      // Create a (posting) task for a job

      JobTaskNo := PrefixLbl + 'JT001';

      // Find the last task no. (as an integer)
      JobTaskLocal.SETRANGE("Job No.",Job."No.");
      IF JobTaskLocal.FINDLAST THEN
        JobTaskNo := INCSTR(JobTaskLocal."Job Task No.");

      JobTask.INIT;
      JobTask.VALIDATE("Job No.",Job."No.");
      JobTask.VALIDATE("Job Task No.",JobTaskNo);
      JobTask.INSERT(TRUE);

      JobTask.VALIDATE("Job Task Type",JobTask."Job Task Type"::Posting);
      JobTask.MODIFY(TRUE)

Example

The below example is extracted from the test automation codeunit 134101 to show one way of using this function.

      LibraryJob.CreateJob(Job);
      LibraryJob.CreateJobTask(Job,JobTask);
Member of Lib.Library - Job


CreateJobWIPMethod@70 Method

The procedure CreateJobWIPMethod is available in codeunit 131920.

Syntax

CreateJobWIPMethod@70(
    VAR JobWIPMethod@1000 : Record 1006 JobWIPMethod //Reference parameter of type Record
);

Parameters

JobWIPMethod
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Job, WIP, Method.

For a clarification about how this function works, refer to the code listed below.

      JobWIPMethod.INIT;
      JobWIPMethod.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(JobWIPMethod.FIELDNO(Code),DATABASE::"Job WIP Method"),1,
          LibraryUtility.GetFieldLength(DATABASE::"Job WIP Method",JobWIPMethod.FIELDNO(Code))));
      JobWIPMethod.INSERT(TRUE)

Example

The below example is extracted from the test automation codeunit 136307 to show one way of using this function.

      WITH JobWIPMethod DO BEGIN
        LibraryJob.CreateJobWIPMethod(JobWIPMethod);
        VALIDATE("Recognized Costs","Recognized Costs"::"Cost of Sales");
        MODIFY(TRUE);
        EXIT(Code);
      END;
Member of Lib.Library - Job


CreateJobWithPostingGroup@1500015 Method

The procedure CreateJobWithPostingGroup is available in codeunit 131920.

Syntax

CreateJobWithPostingGroup@1500015(
    VAR Job@1500000 : Record 167 Job, //Reference parameter of type Record
    VAR JobPostingGroup@1500001 : Record 208 JobPostingGroup //Reference parameter of type Record
);

Parameters

Job
Reference parameter of type Record
JobPostingGroup
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Job, Posting, Group.

For a clarification about how this function works, refer to the code listed below.

      CreateJob(Job);
      CreateJobPostingGroup(JobPostingGroup);
      Job.VALIDATE("Bill-to Customer No.",'');
      Job.VALIDATE("Job Posting Group",JobPostingGroup.Code);
      Job.VALIDATE("Job Type",Job."Job Type"::"Capital WIP");
      Job.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 144052 to show one way of using this function.

      // [SCENARIO 164111] Check if the system is calculating CVD and ADC VAT or TDS in case of CWIP Job has been selected in Purchase line
      // [FEATURE] [TDS][Purchase Order]
      Initialize;

      // [GIVEN] Created Setup for NODNOC and Assessee,Job,Job Task Code
      Amount := LibraryRandom.RandDec(100000,2);
      LibraryTDS.CreateIncomeTaxAccPeriod(IncomeTaxAccountingPeriod);
      LibraryTDS.CreateIncomeTaxPeriod(IncomeTaxPeriodSetup,IncomeTaxAccountingPeriod."No.",1);
      CreateLocationWithTAN(Location);
      LibraryJob.CreateJobWithPostingGroup(Job,JobPostingGroup);
      LibraryJob.CreateJobTask(Job,JobTask);
      LibraryJob.CreateJobTask(Job,JobTask2);
      LibraryTDS.CreateAssesseeandNODNOCSetup(NodNocHeader,TdsNatureOfDeduction,TDSSetup,'',CreateVendor,
        NodNocHeader.Type::Vendor,IncomeTaxAccountingPeriod."Starting Date");

      // [WHEN] Created Job Journal Line and Created Purchase Order and Post
      CreateMultipleJobJournalLines(JobJournalLine,JobTask,JobTask2,Location,1,Amount);
      LibraryJob.PostJobJournal(JobJournalLine);
      CalculateAndPostWIPtoGL(Job);
      CreatePurchaseHeaderforJob(PurchaseHeader,Location.Code,NodNocHeader."No.",IncomeTaxAccountingPeriod."Starting Date");
      CreatePurchaseLineforJob(PurchaseLine,PurchaseHeader,TdsNatureOfDeduction.Code,Job."No.",
        JobTask."Job Task No.");
      CalcTDSAmountsFromBase(ExpectedTDSEntry,TDSSetup,PurchaseLine.Amount);
      DocumentNo := LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

      // [THEN] Job Ledger Entry,GL Entry, TDS Entry has been created.
      VerifyJobLedgerEntryCount(Job."No.",7);
      VerifyGLEntryforTDS(DocumentNo,PurchaseLine.Amount,PurchaseLine."Document Type"::Invoice);
      VerifyTDSEntry(ExpectedTDSEntry,DocumentNo,ExpectedTDSEntry."Document Type"::Invoice);
Member of Lib.Library - Job


CreatePurchaseLineForPlan@65 Method

The procedure CreatePurchaseLineForPlan is available in codeunit 131920.

Syntax

CreatePurchaseLineForPlan@65(
    JobPlanningLine@1000 : Record 1003 JobPlanningLine, //Input parameter of type Record
    UsageLineType@1002 : Option UsageLineType, //Input parameter of type Option
    Fraction@1004 : Decimal Fraction, //Input parameter of type Decimal
    VAR PurchaseLine@1001 : Record 39 PurchaseLine //Reference parameter of type Record
);

Parameters

JobPlanningLine
Input parameter of type Record
UsageLineType
Input parameter of type Option
Fraction
Input parameter of type Decimal
PurchaseLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Purchase, Line, For, Plan.

For a clarification about how this function works, refer to the code listed below.

      Assert.IsTrue(JobPlanningLine."Usage Link",'Usage link should be enabled');

      JobTask.GET(JobPlanningLine."Job No.",JobPlanningLine."Job Task No.");
      Job.GET(JobPlanningLine."Job No.");

      LibraryPurchase.CreatePurchHeader(PurchaseHeader,PurchaseHeader."Document Type"::Order,'');
      LibraryPurchase.CreatePurchaseLine(PurchaseLine,PurchaseHeader,Job2PurchaseConsumableType(JobPlanningLine.Type),
        JobPlanningLine."No.",ROUND(Fraction * JobPlanningLine."Remaining Qty."));

      WITH PurchaseLine DO BEGIN
        VALIDATE(Description,LibraryUtility.GenerateGUID);
        VALIDATE("Unit of Measure Code",JobPlanningLine."Unit of Measure Code");
        VALIDATE("Job Line Type",UsageLineType);
        VALIDATE("Job No.",JobPlanningLine."Job No.");
        VALIDATE("Job Task No.",JobPlanningLine."Job Task No.");
        VALIDATE("Job Planning Line No.",JobPlanningLine."Line No.");
        MODIFY(TRUE)
      END

Example

The below example is extracted from the test automation codeunit 136309 to show one way of using this function.

      LibraryJob.CreatePurchaseLineForPlan(JobPlanningLine,PurchaseLine."Job Line Type"::Schedule,1,PurchaseLine);
      PurchaseLine.VALIDATE("Location Code",Bin."Location Code");
      PurchaseLine.VALIDATE("Bin Code",Bin.Code);
      PurchaseLine.MODIFY(TRUE);
Member of Lib.Library - Job


CreateServiceLineForPlan@54 Method

The procedure CreateServiceLineForPlan is available in codeunit 131920.

Syntax

CreateServiceLineForPlan@54(
    JobPlanningLine@1000 : Record 1003 JobPlanningLine, //Input parameter of type Record
    UsageLineType@1002 : Option UsageLineType, //Input parameter of type Option
    Fraction@1004 : Decimal Fraction, //Input parameter of type Decimal
    VAR ServiceLine@1001 : Record 5902 ServiceLine //Reference parameter of type Record
);

Parameters

JobPlanningLine
Input parameter of type Record
UsageLineType
Input parameter of type Option
Fraction
Input parameter of type Decimal
ServiceLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Service, Line, For, Plan.

For a clarification about how this function works, refer to the code listed below.

      Assert.IsTrue(JobPlanningLine."Usage Link",'Usage link should be enabled');

      JobTask.GET(JobPlanningLine."Job No.",JobPlanningLine."Job Task No.");
      Job.GET(JobPlanningLine."Job No.");

      LibraryService.CreateServiceHeader(ServiceHeader,ServiceHeader."Document Type"::Order,Job."Bill-to Customer No.");
      LibraryService.CreateServiceItemLine(ServiceItemLine,ServiceHeader,'');
      LibraryService.CreateServiceLine(
        ServiceLine,ServiceHeader,Job2ServiceConsumableType(JobPlanningLine.Type),JobPlanningLine."No.");

      WITH ServiceLine DO BEGIN
        VALIDATE("Service Item Line No.",ServiceItemLine."Line No.");
        VALIDATE(Description,LibraryUtility.GenerateGUID);
        VALIDATE("Location Code",FindLocationForPostingGroup(ServiceLine));
        VALIDATE(Quantity,ROUND(Fraction * JobPlanningLine."Remaining Qty."));
        VALIDATE("Unit of Measure Code",JobPlanningLine."Unit of Measure Code");
        VALIDATE("Qty. to Consume",Quantity);
        VALIDATE("Job No.",JobPlanningLine."Job No.");
        VALIDATE("Job Task No.",JobPlanningLine."Job Task No.");
        VALIDATE("Job Line Type",UsageLineType);
        VALIDATE("Job Planning Line No.",JobPlanningLine."Line No.");
        MODIFY(TRUE)
      END

Example

There are no examples available.
Member of Lib.Library - Job


CreateVATPostingSetup@56 Method

The procedure CreateVATPostingSetup is available in codeunit 131920.

Syntax

CreateVATPostingSetup@56(
    VATBusinessPostingGroupCode@1000 : Code[10] VATBusinessPostingGroupCode, //Input parameter of type Code
    VATProductPostingGroupCode@1001 : Code[10] VATProductPostingGroupCode, //Input parameter of type Code
    VAR VATPostingSetup@1002 : Record 325 VATPostingSetup //Reference parameter of type Record
);

Parameters

VATBusinessPostingGroupCode
Input parameter of type Code
VATProductPostingGroupCode
Input parameter of type Code
VATPostingSetup
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, VAT, Posting, Setup.

For a clarification about how this function works, refer to the code listed below.

      WITH VATPostingSetup DO BEGIN
        "VAT Bus. Posting Group" := VATBusinessPostingGroupCode;
        "VAT Prod. Posting Group" := VATProductPostingGroupCode;
        INIT;
        "VAT %" := LibraryRandom.RandIntInRange(10,25); // 10 <= VAT % <= 25
        "VAT Identifier" := FORMAT("VAT %");
        "Sales VAT Account" := LibraryERM.CreateGLAccountWithSalesSetup;
        "Sales VAT Unreal. Account" := "Sales VAT Account";
        "Purchase VAT Account" := "Sales VAT Account";
        "Purch. VAT Unreal. Account" := "Sales VAT Account";
        INSERT(TRUE);
      END;

Example

The below example is extracted from the test automation codeunit 134327 to show one way of using this function.

      LibraryPurchase.CreatePurchHeader(PurchaseHeader,PurchaseHeader."Document Type"::Order,CreateVendor);
      LibraryInventory.CreateItem(Item);
      IF NOT VATPostingSetup.GET(PurchaseHeader."VAT Bus. Posting Group",Item."VAT Prod. Posting Group") THEN
        LibraryERM.CreateVATPostingSetup(VATPostingSetup,PurchaseHeader."VAT Bus. Posting Group",Item."VAT Prod. Posting Group");
      LibraryPurchase.CreatePurchaseLine(PurchaseLine,PurchaseHeader,PurchaseLine.Type::Item,Item."No.",1);
Member of Lib.Library - Job


FindConsumable@3 Method

The procedure FindConsumable is available in codeunit 131920.

Syntax

FindConsumable@3(
    Type@1000 : Integer Type //Input parameter of type Integer
);

Parameters

Type
Input parameter of type Integer

Return Value

Code[20]

Remarks

The relevant search keywords are: Find, Consumable.

For a clarification about how this function works, refer to the code listed below.

      CASE Type OF
        ResourceType:
          EXIT(LibraryResource.CreateResourceNo);
        ItemType:
          EXIT(FindItem);
        GLAccountType:
          EXIT(LibraryERM.CreateGLAccountWithSalesSetup);
        ELSE
          ERROR(ErrorMsgErr);
      END

Example

The below example is extracted from the test automation codeunit 136301 to show one way of using this function.

      ServiceHeader.GET(ServiceItemLine."Document Type",ServiceItemLine."Document No.");

      ConsumableNo := LibraryJob.FindConsumable(LibraryJob.Service2JobConsumableType(Type));
      LibraryService.CreateServiceLine(ServiceLine,ServiceHeader,Type,ConsumableNo);

      ServiceLine.VALIDATE(Description,FORMAT(LibraryUtility.GenerateGUID));
      ServiceLine.VALIDATE("Service Item Line No.",ServiceItemLine."Line No.");
      ServiceLine.VALIDATE(Quantity,RANDOM(10));
      ServiceLine.VALIDATE("Location Code",'');

      // Multiply by ConsumptionFactor to determine Full/Partial Qty. to Ship and Qty. to Consume.
      ServiceLine.VALIDATE("Qty. to Ship",ServiceLine.Quantity * ConsumptionFactor);
      ServiceLine.VALIDATE("Qty. to Consume",ServiceLine."Qty. to Ship");
      ServiceLine.MODIFY(TRUE)
Member of Lib.Library - Job


FindItem@9 Method

The procedure FindItem is available in codeunit 131920.

Syntax

FindItem@9(
      //param element not supplied
);

Return Value

Code[20]

Remarks

The relevant search keywords are: Find, Item.

For a clarification about how this function works, refer to the code listed below.

      LibraryInventory.CreateItem(Item);
      Item.VALIDATE("Unit Price",LibraryRandom.RandDec(100,2));
      Item.VALIDATE("Unit Cost",LibraryRandom.RandDec(100,2));
      Item.MODIFY(TRUE);
      EXIT(Item."No.");

Example

There are no examples available.
Member of Lib.Library - Job


FindJobPostingGroup@8 Method

The procedure FindJobPostingGroup is available in codeunit 131920.

Syntax

FindJobPostingGroup@8(
      //param element not supplied
);

Return Value

Code[10]

Remarks

The relevant search keywords are: Find, Job, Posting, Group.

For a clarification about how this function works, refer to the code listed below.

      IF NOT JobPostingGroup.FINDFIRST THEN
        CreateJobPostingGroup(JobPostingGroup);
      EXIT(JobPostingGroup.Code);

Example

There are no examples available.
Member of Lib.Library - Job


FindLocation@133 Method

The procedure FindLocation is available in codeunit 131920.

Syntax

FindLocation@133(
    VAR Location@1000 : Record 14 Location //Reference parameter of type Record
);

Parameters

Location
Reference parameter of type Record

Return Value

Code[10]

Remarks

The relevant search keywords are: Find, Location.

For a clarification about how this function works, refer to the code listed below.

      Location.SETRANGE("Use As In-Transit",FALSE);
      Location.SETRANGE("Bin Mandatory",FALSE);
      Location.NEXT(LibraryRandom.RandInt(Location.COUNT));
      EXIT(Location.Code);

Example

The below example is extracted from the test automation codeunit 136303 to show one way of using this function.

      IF LibraryVariableStorage.Length < 1 THEN BEGIN
        LibraryJob.FindLocation(Location);
        LibraryInventory.UpdateInventoryPostingSetup(Location);
        LibraryVariableStorage.Enqueue(Location.Code);
        EXIT(Location.Code);
      END;
      EXIT(LibraryVariableStorage.PeekText(1));
Member of Lib.Library - Job


GenJournalConsumption@66 Method

The procedure GenJournalConsumption is available in codeunit 131920.

Syntax

GenJournalConsumption@66(
      //param element not supplied
);

Return Value

Integer

Remarks

The relevant search keywords are: General, Journal, Consumption.

For a clarification about how this function works, refer to the code listed below.

      EXIT(ConsumptionSource::GenJournal)

Example

There are no examples available.
Member of Lib.Library - Job


GetAmountRoundingPrecision@23 Method

The procedure GetAmountRoundingPrecision is available in codeunit 131920.

Syntax

GetAmountRoundingPrecision@23(
    CurrencyCode@1000 : Code[10] CurrencyCode //Input parameter of type Code
);

Parameters

CurrencyCode
Input parameter of type Code

Return Value

Decimal

Remarks

The relevant search keywords are: Get, Amount, Rounding, Precision.

For a clarification about how this function works, refer to the code listed below.

      IF CurrencyCode = '' THEN
        EXIT(LibraryERM.GetAmountRoundingPrecision);
      Currency.GET(CurrencyCode);
      EXIT(Currency."Amount Rounding Precision")

Example

The below example is extracted from the test automation codeunit 136302 to show one way of using this function.

      PurchaseLine.FINDSET;
      PurchaseHeader.GET(PurchaseLine."Document Type",PurchaseLine."Document No.");
      REPEAT
        IF CurrencyCode <> '' THEN BEGIN
          Currency.GET(CurrencyCode);
          AmountRoundingPrecision := Currency."Amount Rounding Precision";
          JobUnitCost := ROUND(
              CurrencyExchRate.ExchangeAmtLCYToFCY(
                PurchaseHeader."Posting Date",
                CurrencyCode,
                PurchaseLine."Unit Cost (LCY)",
                CurrencyExchRate.ExchangeRate(PurchaseHeader."Posting Date",CurrencyCode)),
              Currency."Unit-Amount Rounding Precision");
        END ELSE BEGIN
          AmountRoundingPrecision := LibraryERM.GetAmountRoundingPrecision;
          JobUnitCost := PurchaseLine."Unit Cost (LCY)"
        END;
        JobTotalCostLCY :=
          PurchaseLine."Qty. to Invoice" * ROUND(PurchaseLine."Unit Cost (LCY)",LibraryERM.GetUnitAmountRoundingPrecision);
        TotalCostLCY += ROUND(JobTotalCostLCY,AmountRoundingPrecision);
        TotalCost += ROUND(JobUnitCost * PurchaseLine."Qty. to Invoice",AmountRoundingPrecision);
      UNTIL PurchaseLine.NEXT = 0;
Member of Lib.Library - Job


GetGenJournalTemplate@61 Method

The procedure GetGenJournalTemplate is available in codeunit 131920.

Syntax

GetGenJournalTemplate@61(
    VAR GenJournalTemplate@1000 : Record 80 GenJournalTemplate //Reference parameter of type Record
);

Parameters

GenJournalTemplate
Reference parameter of type Record

Return Value

Code[10]

Remarks

The relevant search keywords are: Get, General, Journal, Template.

For a clarification about how this function works, refer to the code listed below.

      // In this test codeunit we always use the same gen. journal template

      CLEAR(GenJournalTemplate);
      IF NOT GenJournalTemplate.GET(PrefixLbl + TemplateNameLbl) THEN BEGIN
        GenJournalTemplate.VALIDATE(Name,PrefixLbl + TemplateNameLbl);
        GenJournalTemplate.INSERT(TRUE)
      END;

      GenJournalTemplate.VALIDATE("No. Series",GetJobTestNoSeries);
      GenJournalTemplate.MODIFY(TRUE);

      EXIT(GenJournalTemplate.Name)

Example

There are no examples available.
Member of Lib.Library - Job


GetJobJournalTemplate@1 Method

The procedure GetJobJournalTemplate is available in codeunit 131920.

Syntax

GetJobJournalTemplate@1(
    VAR JobJournalTemplate@1000 : Record 209 JobJournalTemplate //Reference parameter of type Record
);

Parameters

JobJournalTemplate
Reference parameter of type Record

Return Value

Code[10]

Remarks

The relevant search keywords are: Get, Job, Journal, Template.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(JobJournalTemplate);
      IF NOT JobJournalTemplate.GET(PrefixLbl + TemplateNameLbl) THEN BEGIN
        JobJournalTemplate.VALIDATE(Name,PrefixLbl + TemplateNameLbl);
        JobJournalTemplate.INSERT(TRUE)
      END;

      JobJournalTemplate.VALIDATE("No. Series",GetJobTestNoSeries);
      JobJournalTemplate.MODIFY(TRUE);
      EXIT(JobJournalTemplate.Name)

Example

The below example is extracted from the test automation codeunit 136305 to show one way of using this function.

      LibraryJob.CreateJobJournalBatch(LibraryJob.GetJobJournalTemplate(JobJournalTemplate),JobJournalBatch);
      NoSeriesCode := JobJournalBatch."No. Series";  // Assigning Batch No. Series to global variable.
      LibraryVariableStorage.Enqueue(JobJournalBatch."Journal Template Name");
      COMMIT;  // Commit required to avoid test failures.

      // Need to Run Calc. Remaining Usage Batch Job from Job Journal page due to Code Written on Page and Job Journal Lines needed to be blank before running batch job.
      JobJournal.OPENEDIT;
      JobJournal.CurrentJnlBatchName.SETVALUE(JobJournalBatch.Name);
      JobJournal.CalcRemainingUsage.INVOKE;
Member of Lib.Library - Job


GetJobTestNoSeries@49 Method

The procedure GetJobTestNoSeries is available in codeunit 131920.

Syntax

GetJobTestNoSeries@49(
      //param element not supplied
);

Return Value

Code[10]

Remarks

The relevant search keywords are: Get, Job, Test, No, Series.

For a clarification about how this function works, refer to the code listed below.

      IF NOT NoSeries.GET(NoSeriesCodeLbl) THEN BEGIN
        LibraryUtility.CreateNoSeries(NoSeries,TRUE,FALSE,FALSE);
        NoSeries.RENAME(NoSeriesCodeLbl);
        LibraryUtility.CreateNoSeriesLine(NoSeriesLine,NoSeries.Code,'','')
      END;

      EXIT(NoSeries.Code)

Example

There are no examples available.
Member of Lib.Library - Job


GetJobWIPMethod@76 Method

The procedure GetJobWIPMethod is available in codeunit 131920.

Syntax

GetJobWIPMethod@76(
    VAR JobWIPMethod@1000 : Record 1006 JobWIPMethod, //Reference parameter of type Record
    Method@1001 : Option Method //Input parameter of type Option
);

Parameters

JobWIPMethod
Reference parameter of type Record
Method
Input parameter of type Option

Remarks

The relevant search keywords are: Get, Job, WIP, Method.

For a clarification about how this function works, refer to the code listed below.

      WITH JobWIPMethod DO BEGIN
        CASE Method OF
          Method::"Completed Contract":
            BEGIN
              SETRANGE("Recognized Costs","Recognized Costs"::"At Completion");
              SETRANGE("Recognized Sales","Recognized Sales"::"At Completion");
            END;
          Method::"Cost of Sales":
            BEGIN
              SETRANGE("Recognized Costs","Recognized Costs"::"Cost of Sales");
              SETRANGE("Recognized Sales","Recognized Sales"::"Contract (Invoiced Price)");
            END;
          Method::"Cost Value":
            BEGIN
              SETRANGE("Recognized Costs","Recognized Costs"::"Cost Value");
              SETRANGE("Recognized Sales","Recognized Sales"::"Contract (Invoiced Price)");
            END;
          Method::POC:
            BEGIN
              SETRANGE("Recognized Costs","Recognized Costs"::"Usage (Total Cost)");
              SETRANGE("Recognized Sales","Recognized Sales"::"Percentage of Completion");
            END;
          Method::"Sales Value":
            BEGIN
              SETRANGE("Recognized Costs","Recognized Costs"::"Usage (Total Cost)");
              SETRANGE("Recognized Sales","Recognized Sales"::"Sales Value");
            END;
        END;
        FINDFIRST;
      END;

Example

The below example is extracted from the test automation codeunit 136350 to show one way of using this function.

      // Verify that Apply Usage Link is initialized correctly.

      // Verify that Apply Usage Link is not set by default, if not set in Jobs Setup.
      Initialize;
      JobsSetup.GET;
      JobsSetup.VALIDATE("Apply Usage Link by Default",FALSE);
      JobsSetup.MODIFY;
      LibraryJob.CreateJob(Job);
      Assert.IsFalse(Job."Apply Usage Link",'Apply Usage link is not FALSE by default.');

      TearDown;

      // Verify that Apply Usage Link is set by default, if set in Jobs Setup.
      Initialize;
      JobsSetup.GET;
      JobsSetup.VALIDATE("Apply Usage Link by Default",TRUE);
      JobsSetup.MODIFY;
      LibraryJob.CreateJob(Job);
      Assert.IsTrue(Job."Apply Usage Link",'Apply Usage link is not TRUE by default.');

      // Verify that the Default WIP Method is set by default, if set in Jobs Setup.
      JobsSetup.GET;
      LibraryJob.GetJobWIPMethod(JobWIPMethod,Method::"Cost Value");
      JobsSetup.VALIDATE("Default WIP Method",JobWIPMethod.Code);
      JobsSetup.VALIDATE("Default WIP Posting Method",JobsSetup."Default WIP Posting Method"::"Per Job Ledger Entry");
      JobsSetup.MODIFY;
      LibraryJob.CreateJob(Job);
      Assert.AreEqual(Job."WIP Method",JobWIPMethod.Code,'The WIP Method is not set to the correct default value.');

      // Verify that the Default WIP Posting Method is set by default, if set in Jobs Setup.
      Assert.AreEqual(Job."WIP Posting Method"::"Per Job Ledger Entry",Job."WIP Posting Method",
        'The WIP Posting Method is not set to the correct default value.');

      TearDown;
Member of Lib.Library - Job


GetNextLineNo@19 Method

The procedure GetNextLineNo is available in codeunit 131920.

Syntax

GetNextLineNo@19(
    JobPlanningLine@1000 : Record 1003 JobPlanningLine //Input parameter of type Record
);

Parameters

JobPlanningLine
Input parameter of type Record

Return Value

Integer

Remarks

The relevant search keywords are: Get, Next, Line, No.

For a clarification about how this function works, refer to the code listed below.

      JobPlanningLine.RESET;
      JobPlanningLine.SETRANGE("Job No.",JobPlanningLine."Job No.");
      JobPlanningLine.SETRANGE("Job Task No.",JobPlanningLine."Job Task No.");
      IF JobPlanningLine.FINDLAST THEN
        EXIT(JobPlanningLine."Line No." + 10000);
      EXIT(10000)

Example

The below example is extracted from the test automation codeunit 136303 to show one way of using this function.

      // Use a planning line with an explicit link
      // via job journal, gl journal, purchase, or service (Source).
      // Verify remaining quantity
      // Verify that the usage link is created.
      // Verify that the planning line's amounts and quantities are updated.

      // can only link to a planning line which type includes schedule
      Assert.IsTrue(
        LineTypeToMatch IN [LibraryJob.PlanningLineTypeSchedule,LibraryJob.PlanningLineTypeBoth],
        'Line type should include schedule.');

      // Setup
      Initialize;
      CreateJob(ApplyUsageLink,TRUE,Job);
      LibraryJob.CreateJobTask(Job,JobTask);

      // this is the planning line we want to match
      LibraryJob.CreateJobPlanningLine(LineTypeToMatch,ConsumableType,JobTask,JobPlanningLine);
      JobPlanningLine.VALIDATE("Usage Link",TRUE);
      JobPlanningLine.MODIFY(TRUE);

      AssertNoDiscounts(JobPlanningLine);
      BeforeJobPlanningLine := JobPlanningLine;

      // to make it more difficult
      CreateSimilarJobPlanningLines(JobPlanningLine);

      // with an explicit link, we can even have earlier planning lines that are identical
      NewJobPlanningLine := JobPlanningLine;
      EVALUATE(DateForm,'<-1W>');
      NewJobPlanningLine.VALIDATE("Planning Date",CALCDATE(DateForm,JobPlanningLine."Planning Date"));
      NewJobPlanningLine.VALIDATE("Line No.",LibraryJob.GetNextLineNo(JobPlanningLine));
      NewJobPlanningLine.INSERT(TRUE);
      LineCount := JobPlanningLine.COUNT;

      // Exercise
      LibraryJob.UseJobPlanningLineExplicit(JobPlanningLine,LibraryJob.UsageLineTypeBlank,1,Source,JobJournalLine);

      // refresh
      JobPlanningLine.GET(Job."No.",JobTask."Job Task No.",JobPlanningLine."Line No.");

      // Verify - the Remaining Qty. field on the journal line is correct
      JobJournalLine.TESTFIELD("Remaining Qty.",BeforeJobPlanningLine."Remaining Qty." - JobJournalLine.Quantity);

      // Verify - line type is taken from planning line
      Assert.AreEqual(
        LibraryJob.UsageLineType(JobPlanningLine."Line Type"),
        JobJournalLine."Line Type",
        'Journal line type should the same as planning line type.');

      // Verify - usage link has been created
      JobLedgerEntry.SETRANGE(Description,JobJournalLine.Description);
      JobLedgerEntry.FINDFIRST;
      VerifyUsageLink(JobPlanningLine,JobLedgerEntry);

      // Verify - no new planning lines are created
      Assert.AreEqual(LineCount,JobPlanningLine.COUNT,'No planning lines should have been created.');

      // Verify - JobPlanningLine@Pre - JobJournalLine = JobPlanningLine@Post
      VerifyJobPlanningLine(BeforeJobPlanningLine,JobPlanningLine,JobJournalLine)
Member of Lib.Library - Job


GetUnitAmountRoundingPrecision@10 Method

The procedure GetUnitAmountRoundingPrecision is available in codeunit 131920.

Syntax

GetUnitAmountRoundingPrecision@10(
    CurrencyCode@1000 : Code[10] CurrencyCode //Input parameter of type Code
);

Parameters

CurrencyCode
Input parameter of type Code

Return Value

Decimal

Remarks

The relevant search keywords are: Get, Unit, Amount, Rounding, Precision.

For a clarification about how this function works, refer to the code listed below.

      IF CurrencyCode = '' THEN
        EXIT(LibraryERM.GetUnitAmountRoundingPrecision);
      Currency.GET(CurrencyCode);
      EXIT(Currency."Unit-Amount Rounding Precision")

Example

The below example is extracted from the test automation codeunit 136305 to show one way of using this function.

      // Test Job Unit Cost, Job Unit Price on Job G/L Journal Line when Unit Cost Factor is defined on Job Card.

      // 1. Setup: Create Job with Job Task and Job G/L Account Price.
      Initialize;
      CreateJobJournalBatch(GenJournalBatch);
      CreateJobWithJobTask(JobTask);
      LibraryJob.CreateJobGLAccountPrice(
        JobGLAccountPrice,JobTask."Job No.",JobTask."Job Task No.",LibraryERM.CreateGLAccountNo,'');
      UpdateUnitCostFactorOnJobGLAccountPrice(JobGLAccountPrice);

      // 2. Exercise: Create Job G/L Journal Line, Taking rounding precision as used in General Journal Line Table rounding precision.
      CreateJobGLJournalLine(
        GenJournalLine,GenJournalBatch,GenJournalLine."Bal. Account Type"::"G/L Account",JobGLAccountPrice."G/L Account No.",
        LibraryERM.CreateGLAccountNo,JobGLAccountPrice."Job No.",JobGLAccountPrice."Job Task No.",'');  // Passing Blank for Currency Code.
      JobUnitCost := GenJournalLine.Amount / GenJournalLine."Job Quantity";
      JobUnitPrice :=
        ROUND(
          (GenJournalLine.Amount / GenJournalLine."Job Quantity") * JobGLAccountPrice."Unit Cost Factor",
          LibraryJob.GetUnitAmountRoundingPrecision(GenJournalLine."Currency Code"));

      // 3. Verify: Verify values on Job G/L Journal Lines.
      VerifyJobGLJournalLine(GenJournalLine,JobUnitCost,JobUnitPrice);

      // 4. Tear Down: Delete newly created batch.
      GenJournalBatch.GET(GenJournalLine."Journal Template Name",GenJournalLine."Journal Batch Name");
      GenJournalBatch.DELETE(TRUE);
Member of Lib.Library - Job


GLAccountType@14 Method

The procedure GLAccountType is available in codeunit 131920.

Syntax

GLAccountType@14(
      //param element not supplied
);

Return Value

Integer

Remarks

The relevant search keywords are: General Ledger, Account, Type.

For a clarification about how this function works, refer to the code listed below.

      EXIT(JobPlanningLine.Type::"G/L Account")

Example

There are no examples available.
Member of Lib.Library - Job


ItemType@18 Method

The procedure ItemType is available in codeunit 131920.

Syntax

ItemType@18(
      //param element not supplied
);

Return Value

Integer

Remarks

The relevant search keywords are: Item, Type.

For a clarification about how this function works, refer to the code listed below.

      EXIT(JobPlanningLine.Type::Item)

Example

There are no examples available.
Member of Lib.Library - Job


Job2PurchaseConsumableType@55 Method

The procedure Job2PurchaseConsumableType is available in codeunit 131920.

Syntax

Job2PurchaseConsumableType@55(
    Type@1000 : Option Type //Input parameter of type Option
);

Parameters

Type
Input parameter of type Option

Return Value

Integer

Remarks

The relevant search keywords are: Job2, Purchase, Consumable, Type.

For a clarification about how this function works, refer to the code listed below.

      CASE Type OF
        ItemType:
          EXIT(PurchaseLine.Type::Item);
        GLAccountType:
          EXIT(PurchaseLine.Type::"G/L Account");
        ELSE
          Assert.Fail('Unsupported consumable type');
      END

Example

The below example is extracted from the test automation codeunit 136300 to show one way of using this function.

      // Parameterized test

      // PurchaseDocumentType IN [Order,Invoice]
      // PurchaseLineType IN [Item,G/L Account]
      // JobLineType IN ["",Schedule,Contract,Both Schedule and Contract]

      // Setup
      Initialize;
      LibraryJob.CreateJob(Job);
      LibraryJob.CreateJobTask(Job,JobTask);

      // Exercise
      CreateSingleLinePurchaseDoc(PurchaseDocumentType,PurchaseHeader);

      // Attach requested account type to the created purchase line
      GetPurchaseLines(PurchaseHeader,PurchaseLine);

      UpdatePurchLine(PurchaseLine,LibraryJob.Job2PurchaseConsumableType(ConsumableType));
      LibraryJob.AttachJobTask2PurchaseLine(JobTask,PurchaseLine);
      PurchaseLine.VALIDATE("Job Line Type",JobLineType);
      PurchaseLine.VALIDATE(Description,LibraryUtility.GenerateGUID);
      PurchaseLine.MODIFY(TRUE);
      LibraryJob.CopyPurchaseLines(PurchaseLine,TempPurchaseLine);
      PostPurchaseDocument(PurchaseHeader,PurchInvHeader);

      // Verify (planning lines, job ledger)
      LibraryJob.VerifyPurchaseDocPostingForJob(TempPurchaseLine);
      JobLedgerEntry.SETRANGE(Description,TempPurchaseLine.Description);
      Assert.AreEqual(1,JobLedgerEntry.COUNT,'# job ledger entries');
      JobLedgerEntry.FINDFIRST;

      LibraryJob.VerifyGLEntries(JobLedgerEntry);

      TearDown;
Member of Lib.Library - Job


Job2SalesConsumableType@43 Method

The procedure Job2SalesConsumableType is available in codeunit 131920.

Syntax

Job2SalesConsumableType@43(
    Type@1000 : Option Type //Input parameter of type Option
);

Parameters

Type
Input parameter of type Option

Return Value

Integer

Remarks

The relevant search keywords are: Job2, Sales, Consumable, Type.

For a clarification about how this function works, refer to the code listed below.

      CASE Type OF
        ResourceType:
          EXIT(SalesLine.Type::Resource);
        ItemType:
          EXIT(SalesLine.Type::Item);
        GLAccountType:
          EXIT(SalesLine.Type::"G/L Account");
        ELSE
          Assert.Fail('Unsupported consumable type');
      END

Example

The below example is extracted from the test automation codeunit 136306 to show one way of using this function.

      // Verify JobPlanningLine has a corresponding sales invoice

      Job.GET(JobPlanningLine."Job No.");
      SalesHeader.TESTFIELD("Sell-to Customer No.",Job."Bill-to Customer No.");
      SalesHeader.TESTFIELD("Bill-to Customer No.",Job."Bill-to Customer No.");

      WITH SalesLine DO BEGIN
        SETRANGE("Document Type",SalesHeader."Document Type");
        SETRANGE("Document No.",SalesHeader."No.");
        FINDFIRST;
        TESTFIELD(Type,LibraryJob.Job2SalesConsumableType(JobPlanningLine.Type));
        TESTFIELD("No.",JobPlanningLine."No.");
        TESTFIELD(Quantity,JobPlanningLine."Qty. Transferred to Invoice");
        TESTFIELD("Unit Price",JobPlanningLine."Unit Price")
      END
Member of Lib.Library - Job


Job2ServiceConsumableType@73 Method

The procedure Job2ServiceConsumableType is available in codeunit 131920.

Syntax

Job2ServiceConsumableType@73(
    Type@1000 : Option Type //Input parameter of type Option
);

Parameters

Type
Input parameter of type Option

Return Value

Integer

Remarks

The relevant search keywords are: Job2, Service, Consumable, Type.

For a clarification about how this function works, refer to the code listed below.

      CASE Type OF
        ResourceType:
          EXIT(ServiceLine.Type::Resource);
        ItemType:
          EXIT(ServiceLine.Type::Item);
        GLAccountType:
          EXIT(ServiceLine.Type::"G/L Account");
        ELSE
          Assert.Fail('Unsupported consumable type');
      END

Example

There are no examples available.
Member of Lib.Library - Job


JobConsumption@64 Method

The procedure JobConsumption is available in codeunit 131920.

Syntax

JobConsumption@64(
      //param element not supplied
);

Return Value

Integer

Remarks

The relevant search keywords are: Job, Consumption.

For a clarification about how this function works, refer to the code listed below.

      EXIT(ConsumptionSource::Job)

Example

There are no examples available.
Member of Lib.Library - Job


Max@47 Method

The procedure Max is available in codeunit 131920.

Syntax

Max@47(
    Left@1000 : Decimal Left, //Input parameter of type Decimal
    Right@1001 : Decimal Right //Input parameter of type Decimal
);

Parameters

Left
Input parameter of type Decimal
Right
Input parameter of type Decimal

Return Value

Decimal

Remarks

The relevant search keywords are: Max.

For a clarification about how this function works, refer to the code listed below.

      IF Left > Right THEN
        EXIT(Left);

      EXIT(Right)

Example

There are no examples available.
Member of Lib.Library - Job


PlanningLineType@38 Method

The procedure PlanningLineType is available in codeunit 131920.

Syntax

PlanningLineType@38(
    UsageLineType@1000 : Option UsageLineType //Input parameter of type Option
);

Parameters

UsageLineType
Input parameter of type Option

Return Value

Integer

Remarks

The relevant search keywords are: Planning, Line, Type.

For a clarification about how this function works, refer to the code listed below.

      CASE UsageLineType OF
        UsageLineTypeSchedule:
          EXIT(PlanningLineTypeSchedule);
        UsageLineTypeContract:
          EXIT(PlanningLineTypeContract);
        UsageLineTypeBoth:
          EXIT(PlanningLineTypeContract);
        ELSE
          Assert.Fail(STRSUBSTNO('No matching job planning line type exists for job usage line type: %1',UsageLineType))
      END

Example

There are no examples available.
Member of Lib.Library - Job


PlanningLineTypeBoth@36 Method

The procedure PlanningLineTypeBoth is available in codeunit 131920.

Syntax

PlanningLineTypeBoth@36(
      //param element not supplied
);

Return Value

Integer

Remarks

The relevant search keywords are: Planning, Line, Type, Both.

For a clarification about how this function works, refer to the code listed below.

      EXIT(JobPlanningLine."Line Type"::"Both Schedule and Contract")

Example

There are no examples available.
Member of Lib.Library - Job


PlanningLineTypeContract@34 Method

The procedure PlanningLineTypeContract is available in codeunit 131920.

Syntax

PlanningLineTypeContract@34(
      //param element not supplied
);

Return Value

Integer

Remarks

The relevant search keywords are: Planning, Line, Type, Contract.

For a clarification about how this function works, refer to the code listed below.

      EXIT(JobPlanningLine."Line Type"::Contract)

Example

The below example is extracted from the test automation codeunit 136306 to show one way of using this function.

      IF Fraction = 0 THEN
        EXIT;

      WITH JobPlanningLine DO BEGIN
        // we cannot credit from the same line.
        "Line No." += 1;
        "Usage Link" := FALSE;
        "Line Type" := LibraryJob.PlanningLineTypeContract;
        "Qty. Posted" := 0;
        VALIDATE(Quantity,-Fraction * Quantity);
        INSERT(TRUE);

        TransferJobPlanningLine(JobPlanningLine,1,TRUE,SalesHeader);
        LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);
      END
Member of Lib.Library - Job


PlanningLineTypeSchedule@30 Method

The procedure PlanningLineTypeSchedule is available in codeunit 131920.

Syntax

PlanningLineTypeSchedule@30(
      //param element not supplied
);

Return Value

Integer

Remarks

The relevant search keywords are: Planning, Line, Type, Schedule.

For a clarification about how this function works, refer to the code listed below.

      EXIT(JobPlanningLine."Line Type"::Schedule)

Example

There are no examples available.
Member of Lib.Library - Job


PostJobJournal@7 Method

The procedure PostJobJournal is available in codeunit 131920.

Syntax

PostJobJournal@7(
    VAR JobJournalLine@1000 : Record 210 JobJournalLine //Reference parameter of type Record
);

Parameters

JobJournalLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Post, Job, Journal.

For a clarification about how this function works, refer to the code listed below.

      // Post a job journal.
      JobJournalLine2 := JobJournalLine;
      CODEUNIT.RUN(CODEUNIT::"Job Jnl.-Post",JobJournalLine2)

Example

The below example is extracted from the test automation codeunit 136300 to show one way of using this function.

      // Parameterized test

      // LineType IN ["",Schedule,Contract,Both Schedule and Contract]
      // Type IN [Resource,G/L Account,Item]

      // Setup
      Initialize;
      LibraryJob.CreateJob(Job);
      LibraryJob.CreateJobTask(Job,JobTask);

      // Exercise
      LibraryJob.CreateJobJournalLineForType(LineType,Type,JobTask,JobJournalLine);

      // Verify
      VerifyJobJournalLineCostPrice(JobJournalLine);

      // Exercise
      LibraryJob.CopyJobJournalLines(JobJournalLine,TempJobJournalLine);
      LibraryJob.PostJobJournal(JobJournalLine);

      // Verify (planning lines and job ledger)
      LibraryJob.VerifyJobJournalPosting(FALSE,TempJobJournalLine);

      TearDown;
Member of Lib.Library - Job


Purchase2JobConsumableType@15 Method

The procedure Purchase2JobConsumableType is available in codeunit 131920.

Syntax

Purchase2JobConsumableType@15(
    Type@1000 : Option Type //Input parameter of type Option
);

Parameters

Type
Input parameter of type Option

Return Value

Integer

Remarks

The relevant search keywords are: Purchase2, Job, Consumable, Type.

For a clarification about how this function works, refer to the code listed below.

      CASE Type OF
        PurchaseLine.Type::Item:
          EXIT(ItemType);
        PurchaseLine.Type::"G/L Account":
          EXIT(GLAccountType);
        ELSE
          Assert.Fail('Unsupported consumable type');
      END

Example

There are no examples available.
Member of Lib.Library - Job


PurchaseConsumption@68 Method

The procedure PurchaseConsumption is available in codeunit 131920.

Syntax

PurchaseConsumption@68(
      //param element not supplied
);

Return Value

Integer

Remarks

The relevant search keywords are: Purchase, Consumption.

For a clarification about how this function works, refer to the code listed below.

      EXIT(ConsumptionSource::Purchase)

Example

There are no examples available.
Member of Lib.Library - Job


ResourceType@13 Method

The procedure ResourceType is available in codeunit 131920.

Syntax

ResourceType@13(
      //param element not supplied
);

Return Value

Integer

Remarks

The relevant search keywords are: Resource, Type.

For a clarification about how this function works, refer to the code listed below.

      EXIT(JobPlanningLine.Type::Resource)

Example

There are no examples available.
Member of Lib.Library - Job


RunUpdateJobItemCost@77 Method

The procedure RunUpdateJobItemCost is available in codeunit 131920.

Syntax

RunUpdateJobItemCost@77(
    JobNo@1002 : Code[20] JobNo //Input parameter of type Code
);

Parameters

JobNo
Input parameter of type Code

Remarks

The relevant search keywords are: Run, Update, Job, Item, Cost.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(UpdateJobItemCost);
      Job.SETRANGE("No.",JobNo);
      UpdateJobItemCost.SETTABLEVIEW(Job);
      UpdateJobItemCost.USEREQUESTPAGE(FALSE);
      UpdateJobItemCost.RUN;

Example

The below example is extracted from the test automation codeunit 136302 to show one way of using this function.

      // [FEATURE] [Update Job Item Cost]
      // [SCENARIO] Update Job Item Cost job updates Planning Line "Posted Total Cost" after setting a different Item Cost in Purchase Order

      // 1. Setup: Create an Item, a Job, a Job Task, a Job Planning Line, a Purchase Header and a Purchase Line. In Purchase Line make sure that the "Direct Unit Cost" is
      // different form Item's Unit Cost.
      Initialize;

      // Create Item
      LibraryInventory.CreateItem(Item);
      Item.VALIDATE("Unit Cost",LibraryRandom.RandDecInRange(1,1000,2));
      Item.VALIDATE("Costing Method",Item."Costing Method"::FIFO);
      Item.MODIFY(TRUE);

      CreateJobTaskWithApplyUsageLink(JobTask);

      // Create JobPlanningLine:
      LibraryJob.CreateJobPlanningLine(JobPlanningLine."Line Type"::"Both Schedule and Contract",
        JobPlanningLine.Type::Item,JobTask,JobPlanningLine);
      JobPlanningLine.VALIDATE("No.",Item."No.");
      JobPlanningLine.VALIDATE(Quantity,LibraryRandom.RandInt(10));
      JobPlanningLine.MODIFY(TRUE);

      LibraryJob.CreateJobJournalLineForPlan(JobPlanningLine,LibraryJob.UsageLineTypeBlank,
        LibraryRandom.RandDecInRange(10,20,2),JobJournalLine);
      LibraryJob.PostJobJournal(JobJournalLine);

      // Create PurchaseHeader
      LibraryPurchase.CreatePurchHeader(PurchaseHeader,PurchaseHeader."Document Type"::Order,'');

      // Create PurchaseLine
      LibraryPurchase.CreatePurchaseLine(
        PurchaseLine,PurchaseHeader,LibraryJob.Job2PurchaseConsumableType(JobPlanningLine.Type),
        Item."No.",LibraryRandom.RandInt(10));

      WITH PurchaseLine DO BEGIN
        VALIDATE(Description,LibraryUtility.GenerateGUID);
        VALIDATE("Unit of Measure Code",JobPlanningLine."Unit of Measure Code");
        // give a different unit cost:
        VALIDATE("Direct Unit Cost",LibraryRandom.RandDecInRange(1000,2000,2));
        MODIFY(TRUE)
      END;

      // 2. Exercise: Post Purchase and then run Adjust Cost - Item Entries and Update Job Item Cost jobs.
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

      JobPlanningLine.GET(JobPlanningLine."Job No.",JobPlanningLine."Job Task No.",JobPlanningLine."Line No.");
      PlanningLineDirectUnitCostBeforeJobs := JobPlanningLine."Posted Total Cost";

      // Run the first job: AdjustCostItemEntries. Item."Unit Cost" should be updated after this
      // since unit cost is changed in PurchaseLine above:
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');

      // Run the second job: RunUpdateJobItemCost. PlanningLine."Direct Unit Cost" should be updated:
      LibraryJob.RunUpdateJobItemCost(JobTask."Job No.");

      JobPlanningLine.GET(JobPlanningLine."Job No.",JobPlanningLine."Job Task No.",JobPlanningLine."Line No.");
      PlanningLineDirectUnitCostAfterJobs := JobPlanningLine."Posted Total Cost";

      // 3. Verify: Ensure that the Planning Line's Direct Unit Cost has changed after running jobs
      Assert.AreNotEqual(
        PlanningLineDirectUnitCostBeforeJobs,
        PlanningLineDirectUnitCostAfterJobs,
        'PlanningLine."Direct Unit Cost" must be changed after running AdjustCostItemEntries and UpdateJobItemCost');
Member of Lib.Library - Job


Service2JobConsumableType@17 Method

The procedure Service2JobConsumableType is available in codeunit 131920.

Syntax

Service2JobConsumableType@17(
    Type@1000 : Option Type //Input parameter of type Option
);

Parameters

Type
Input parameter of type Option

Return Value

Integer

Remarks

The relevant search keywords are: Service2, Job, Consumable, Type.

For a clarification about how this function works, refer to the code listed below.

      CASE Type OF
        ServiceLine.Type::Item:
          EXIT(ItemType);
        ServiceLine.Type::Resource:
          EXIT(ResourceType);
        ServiceLine.Type::"G/L Account":
          EXIT(GLAccountType);
        ELSE
          Assert.Fail('Unsupported consumable type');
      END

Example

The below example is extracted from the test automation codeunit 136301 to show one way of using this function.

      ServiceHeader.GET(ServiceItemLine."Document Type",ServiceItemLine."Document No.");

      ConsumableNo := LibraryJob.FindConsumable(LibraryJob.Service2JobConsumableType(Type));
      LibraryService.CreateServiceLine(ServiceLine,ServiceHeader,Type,ConsumableNo);

      ServiceLine.VALIDATE(Description,FORMAT(LibraryUtility.GenerateGUID));
      ServiceLine.VALIDATE("Service Item Line No.",ServiceItemLine."Line No.");
      ServiceLine.VALIDATE(Quantity,RANDOM(10));
      ServiceLine.VALIDATE("Location Code",'');

      // Multiply by ConsumptionFactor to determine Full/Partial Qty. to Ship and Qty. to Consume.
      ServiceLine.VALIDATE("Qty. to Ship",ServiceLine.Quantity * ConsumptionFactor);
      ServiceLine.VALIDATE("Qty. to Consume",ServiceLine."Qty. to Ship");
      ServiceLine.MODIFY(TRUE)
Member of Lib.Library - Job


ServiceConsumption@63 Method

The procedure ServiceConsumption is available in codeunit 131920.

Syntax

ServiceConsumption@63(
      //param element not supplied
);

Return Value

Integer

Remarks

The relevant search keywords are: Service, Consumption.

For a clarification about how this function works, refer to the code listed below.

      EXIT(ConsumptionSource::Service)

Example

There are no examples available.
Member of Lib.Library - Job


SetAutomaticUpdateJobItemCost@78 Method

The procedure SetAutomaticUpdateJobItemCost is available in codeunit 131920.

Syntax

SetAutomaticUpdateJobItemCost@78(
    IsEnabled@1001 : Boolean IsEnabled //Input parameter of type Boolean
);

Parameters

IsEnabled
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, Automatic, Update, Job, Item, Cost.

For a clarification about how this function works, refer to the code listed below.

      JobsSetup.GET;
      JobsSetup.VALIDATE("Automatic Update Job Item Cost",IsEnabled);
      JobsSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 136306 to show one way of using this function.

      // [FEATURE] [Adjust Cost Item Entries] [Update Job Item Cost]
      // [SCENARIO 234898] Cost amount in job ledger entries should be updated when item cost is automatically adjusted on invoice posting, and automatic update of job item cost is enabled

      Initialize;

      // [GIVEN] Enable automatic cost adjustment and automatic update job item cost
      LibraryInventory.SetAutomaticCostAdjmtAlways;
      LibraryJob.SetAutomaticUpdateJobItemCost(TRUE);

      // [GIVEN] Item "I" with no cost amount defined
      LibraryInventory.CreateItem(Item);

      // [GIVEN] Create purchase order for item "I" and post receipt
      LibraryPurchase.CreatePurchHeader(PurchaseHeader,PurchaseHeader."Document Type"::Order,LibraryPurchase.CreateVendorNo);
      LibraryPurchase.CreatePurchaseLine(PurchaseLine,PurchaseHeader,PurchaseLine.Type::Item,Item."No.",LibraryRandom.RandInt(10));
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,FALSE);

      // [GIVEN] Post a billable job journal line for item "I"
      CreateJobWithJobTask(JobTask);
      CreatePostJobJournalLineWithItem(JobTask,Item."No.");

      // [GIVEN] Reopen the purchase order and update direct unit cost to "10"
      LibraryPurchase.ReopenPurchaseDocument(PurchaseHeader);

      UnitCost := LibraryRandom.RandInt(100);
      PurchaseLine.FIND;
      PurchaseLine.VALIDATE("Direct Unit Cost",UnitCost);
      PurchaseLine.MODIFY(TRUE);

      // [WHEN] Post the purchase invoice
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,FALSE,TRUE);

      // [THEN] "Unit Cost" in the item card "I" is "10"
      Item.FIND;
      Item.TESTFIELD("Unit Cost",UnitCost);

      // [THEN] "Unit Cost" in the job ledger entry created from the job journal is "10"
      VerifyJobLedgerEntryUnitCost(JobTask,Item."No.",UnitCost);
Member of Lib.Library - Job


SetIncomeStatementGLAccounts@53 Method

The procedure SetIncomeStatementGLAccounts is available in codeunit 131920.

Syntax

SetIncomeStatementGLAccounts@53(
    RecordRef@1000 : RecordRef RecordRef //Input parameter of type RecordRef
);

Parameters

RecordRef
Input parameter of type RecordRef

Remarks

The relevant search keywords are: Set, Income, Statement, General Ledger, Accounts.

For a clarification about how this function works, refer to the code listed below.

      // Set all GLAccount fields in RecordRef to a (different) account
      FOR Idx := 1 TO RecordRef.FIELDCOUNT DO BEGIN
        FieldRef := RecordRef.FIELDINDEX(Idx);
        IF FieldRef.RELATION = DATABASE::"G/L Account" THEN BEGIN
          GLAccount.GET(LibraryERM.CreateGLAccountWithSalesSetup);
          GLAccount."Income/Balance" := GLAccount."Income/Balance"::"Income Statement";
          GLAccount.MODIFY(TRUE);
          FieldRef.VALUE := GLAccount."No.";
          FieldRef.TESTFIELD;
          RecordRef.MODIFY;
        END
      END

Example

There are no examples available.
Member of Lib.Library - Job


UpdateJobPostingGroup@107 Method

The procedure UpdateJobPostingGroup is available in codeunit 131920.

Syntax

UpdateJobPostingGroup@107(
    VAR JobPostingGroup@1170000000 : Record 208 JobPostingGroup //Reference parameter of type Record
);

Parameters

JobPostingGroup
Reference parameter of type Record

Remarks

The relevant search keywords are: Update, Job, Posting, Group.

For a clarification about how this function works, refer to the code listed below.

      WITH JobPostingGroup DO BEGIN
        LibraryERM.CreateGLAccount(GLAccount);
        VALIDATE("WIP Costs Account",GLAccount."No.");
        VALIDATE("WIP Invoiced Sales Account",GLAccount."No.");
        VALIDATE("WIP Accrued Costs Account",GLAccount."No.");
        VALIDATE("WIP Accrued Sales Account",GLAccount."No.");
        VALIDATE("Job Costs Applied Account",GLAccount."No.");
        VALIDATE("Job Costs Adjustment Account",GLAccount."No.");
        VALIDATE("Job Sales Applied Account",GLAccount."No.");
        VALIDATE("Job Sales Adjustment Account",GLAccount."No.");
        VALIDATE("Resource Costs Applied Account",GLAccount."No.");
        VALIDATE("Recognized Costs Account",GLAccount."No.");
        VALIDATE("Recognized Sales Account",GLAccount."No.");
        VALIDATE("G/L Costs Applied Account",GLAccount."No.");
        MODIFY(TRUE);
      END;

Example

The below example is extracted from the test automation codeunit 136307 to show one way of using this function.

      LibraryJob.CreateJob(Job);
      JobPostingGroup.GET(Job."Job Posting Group");
      LibraryJob.UpdateJobPostingGroup(JobPostingGroup);
      WITH Job DO BEGIN
        VALIDATE("WIP Method",JobWIPMethodCode);
        VALIDATE("WIP Posting Method",WIPPostingMethod);
        VALIDATE("Apply Usage Link",ApplyUsageLink);
        MODIFY(TRUE);
      END;
Member of Lib.Library - Job


UsageLineType@37 Method

The procedure UsageLineType is available in codeunit 131920.

Syntax

UsageLineType@37(
    PlanningLineType@1000 : Option PlanningLineType //Input parameter of type Option
);

Parameters

PlanningLineType
Input parameter of type Option

Return Value

Integer

Remarks

The relevant search keywords are: Usage, Line, Type.

For a clarification about how this function works, refer to the code listed below.

      CASE PlanningLineType OF
        PlanningLineTypeSchedule:
          EXIT(UsageLineTypeSchedule);
        PlanningLineTypeContract:
          EXIT(UsageLineTypeContract);
        PlanningLineTypeBoth:
          EXIT(UsageLineTypeBoth);
        ELSE
          Assert.Fail(STRSUBSTNO('Invalid job planning line type: %1',PlanningLineType))
      END

Example

The below example is extracted from the test automation codeunit 136303 to show one way of using this function.

      // Use a planning line with an explicit link
      // via job journal, gl journal, purchase, or service (Source).
      // Verify remaining quantity
      // Verify that the usage link is created.
      // Verify that the planning line's amounts and quantities are updated.

      // can only link to a planning line which type includes schedule
      Assert.IsTrue(
        LineTypeToMatch IN [LibraryJob.PlanningLineTypeSchedule,LibraryJob.PlanningLineTypeBoth],
        'Line type should include schedule.');

      // Setup
      Initialize;
      CreateJob(ApplyUsageLink,TRUE,Job);
      LibraryJob.CreateJobTask(Job,JobTask);

      // this is the planning line we want to match
      LibraryJob.CreateJobPlanningLine(LineTypeToMatch,ConsumableType,JobTask,JobPlanningLine);
      JobPlanningLine.VALIDATE("Usage Link",TRUE);
      JobPlanningLine.MODIFY(TRUE);

      AssertNoDiscounts(JobPlanningLine);
      BeforeJobPlanningLine := JobPlanningLine;

      // to make it more difficult
      CreateSimilarJobPlanningLines(JobPlanningLine);

      // with an explicit link, we can even have earlier planning lines that are identical
      NewJobPlanningLine := JobPlanningLine;
      EVALUATE(DateForm,'<-1W>');
      NewJobPlanningLine.VALIDATE("Planning Date",CALCDATE(DateForm,JobPlanningLine."Planning Date"));
      NewJobPlanningLine.VALIDATE("Line No.",LibraryJob.GetNextLineNo(JobPlanningLine));
      NewJobPlanningLine.INSERT(TRUE);
      LineCount := JobPlanningLine.COUNT;

      // Exercise
      LibraryJob.UseJobPlanningLineExplicit(JobPlanningLine,LibraryJob.UsageLineTypeBlank,1,Source,JobJournalLine);

      // refresh
      JobPlanningLine.GET(Job."No.",JobTask."Job Task No.",JobPlanningLine."Line No.");

      // Verify - the Remaining Qty. field on the journal line is correct
      JobJournalLine.TESTFIELD("Remaining Qty.",BeforeJobPlanningLine."Remaining Qty." - JobJournalLine.Quantity);

      // Verify - line type is taken from planning line
      Assert.AreEqual(
        LibraryJob.UsageLineType(JobPlanningLine."Line Type"),
        JobJournalLine."Line Type",
        'Journal line type should the same as planning line type.');

      // Verify - usage link has been created
      JobLedgerEntry.SETRANGE(Description,JobJournalLine.Description);
      JobLedgerEntry.FINDFIRST;
      VerifyUsageLink(JobPlanningLine,JobLedgerEntry);

      // Verify - no new planning lines are created
      Assert.AreEqual(LineCount,JobPlanningLine.COUNT,'No planning lines should have been created.');

      // Verify - JobPlanningLine@Pre - JobJournalLine = JobPlanningLine@Post
      VerifyJobPlanningLine(BeforeJobPlanningLine,JobPlanningLine,JobJournalLine)
Member of Lib.Library - Job


UsageLineTypeBlank@21 Method

The procedure UsageLineTypeBlank is available in codeunit 131920.

Syntax

UsageLineTypeBlank@21(
      //param element not supplied
);

Return Value

Integer

Remarks

The relevant search keywords are: Usage, Line, Type, Blank.

For a clarification about how this function works, refer to the code listed below.

      EXIT(JobJournalLine."Line Type"::" ")

Example

There are no examples available.
Member of Lib.Library - Job


UsageLineTypeBoth@33 Method

The procedure UsageLineTypeBoth is available in codeunit 131920.

Syntax

UsageLineTypeBoth@33(
      //param element not supplied
);

Return Value

Integer

Remarks

The relevant search keywords are: Usage, Line, Type, Both.

For a clarification about how this function works, refer to the code listed below.

      EXIT(JobJournalLine."Line Type"::"Both Schedule and Contract")

Example

There are no examples available.
Member of Lib.Library - Job


UsageLineTypeContract@32 Method

The procedure UsageLineTypeContract is available in codeunit 131920.

Syntax

UsageLineTypeContract@32(
      //param element not supplied
);

Return Value

Integer

Remarks

The relevant search keywords are: Usage, Line, Type, Contract.

For a clarification about how this function works, refer to the code listed below.

      EXIT(JobJournalLine."Line Type"::Contract)

Example

There are no examples available.
Member of Lib.Library - Job


UsageLineTypeSchedule@31 Method

The procedure UsageLineTypeSchedule is available in codeunit 131920.

Syntax

UsageLineTypeSchedule@31(
      //param element not supplied
);

Return Value

Integer

Remarks

The relevant search keywords are: Usage, Line, Type, Schedule.

For a clarification about how this function works, refer to the code listed below.

      EXIT(JobJournalLine."Line Type"::Schedule)

Example

There are no examples available.
Member of Lib.Library - Job


UseJobPlanningLine@11 Method

The procedure UseJobPlanningLine is available in codeunit 131920.

Syntax

UseJobPlanningLine@11(
    JobPlanningLine@1000 : Record 1003 JobPlanningLine, //Input parameter of type Record
    UsageLineType@1004 : Option UsageLineType, //Input parameter of type Option
    Fraction@1001 : Decimal Fraction, //Input parameter of type Decimal
    VAR JobJournalLine@1003 : Record 210 JobJournalLine //Reference parameter of type Record
);

Parameters

JobPlanningLine
Input parameter of type Record
UsageLineType
Input parameter of type Option
Fraction
Input parameter of type Decimal
JobJournalLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Use, Job, Planning, Line.

For a clarification about how this function works, refer to the code listed below.

      CreateJobJournalLineForPlan(JobPlanningLine,UsageLineType,Fraction,JobJournalLine);
      PostJobJournal(JobJournalLine)

Example

The below example is extracted from the test automation codeunit 136303 to show one way of using this function.

      // Use a planning line via job journal that by matching.
      // Verfiy that the line type is taken from the planning line and cannot be changed.
      // Verify that the usage link is created.
      // Verify that the planning line's amounts and quantities are updated.

      // can only link to a planning line which type includes schedule
      Assert.IsTrue(
        LineTypeToMatch IN [LibraryJob.PlanningLineTypeSchedule,LibraryJob.PlanningLineTypeBoth],
        'Line type should include schedule.');

      // Setup
      Initialize;
      CreateJob(ApplyUsageLink,TRUE,Job);
      LibraryJob.CreateJobTask(Job,JobTask);

      // this is the planning line we want to match
      LibraryJob.CreateJobPlanningLine(LineTypeToMatch,ConsumableType,JobTask,JobPlanningLine);
      JobPlanningLine.VALIDATE("Usage Link",TRUE);
      JobPlanningLine.MODIFY(TRUE);

      AssertNoDiscounts(JobPlanningLine);
      BeforeJobPlanningLine := JobPlanningLine;

      // to make it more difficult
      CreateSimilarJobPlanningLines(JobPlanningLine);
      LineCount := JobPlanningLine.COUNT;

      // Exercise
      LibraryJob.UseJobPlanningLine(JobPlanningLine,UsageLineType,1,JobJournalLine);

      // refresh
      JobPlanningLine.GET(Job."No.",JobTask."Job Task No.",JobPlanningLine."Line No.");

      // Verify - usage is linked
      JobLedgerEntry.SETRANGE(Description,JobJournalLine.Description);
      JobLedgerEntry.FINDFIRST;
      VerifyUsageLink(JobPlanningLine,JobLedgerEntry);

      // Verify - no new planning line are created
      Assert.AreEqual(LineCount,JobPlanningLine.COUNT,'No planning lines should have been created.');

      // Verify - JobPlanningLine@Pre - JobJournalLine = JobPlanningLine@Post
      VerifyJobPlanningLine(BeforeJobPlanningLine,JobPlanningLine,JobJournalLine)
Member of Lib.Library - Job


UseJobPlanningLineExplicit@25 Method

The procedure UseJobPlanningLineExplicit is available in codeunit 131920.

Syntax

UseJobPlanningLineExplicit@25(
    JobPlanningLine@1000 : Record 1003 JobPlanningLine, //Input parameter of type Record
    UsageLineType@1004 : Integer UsageLineType, //Input parameter of type Integer
    Fraction@1001 : Decimal Fraction, //Input parameter of type Decimal
    Source@1002 : Option Source, //Input parameter of type Option
    VAR JobJournalLine@1003 : Record 210 JobJournalLine //Reference parameter of type Record
);

Parameters

JobPlanningLine
Input parameter of type Record
UsageLineType
Input parameter of type Integer
Fraction
Input parameter of type Decimal
Source
Input parameter of type Option
JobJournalLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Use, Job, Planning, Line, Explicit.

For a clarification about how this function works, refer to the code listed below.

      CASE Source OF
        JobConsumption:
          BEGIN
            CreateJobJournalLineForPlan(JobPlanningLine,UsageLineType,Fraction,JobJournalLine);
            JobJournalLine.VALIDATE("Job Planning Line No.",JobPlanningLine."Line No.");
            JobJournalLine.MODIFY(TRUE);
            PostJobJournal(JobJournalLine)
          END;
        ServiceConsumption:
          BEGIN
            Ship := TRUE;
            Consume := TRUE;
            Invoice := FALSE;
            CreateServiceLineForPlan(JobPlanningLine,UsageLineType,Fraction,ServiceLine);
            ServiceHeader.GET(ServiceLine."Document Type",ServiceLine."Document No.");
            ServicePost.PostWithLines(ServiceHeader,TempServiceLine,Ship,Consume,Invoice);
            WITH ServiceLine DO BEGIN
              JobJournalLine."Line Type" := "Job Line Type";
              JobJournalLine."Remaining Qty." := "Job Remaining Qty.";
              JobJournalLine.Quantity := "Qty. to Consume";
              JobJournalLine.Description := Description;
              JobJournalLine."Total Cost" := ROUND("Qty. to Consume" * "Unit Cost");
              JobJournalLine."Total Cost (LCY)" := ROUND("Qty. to Consume" * "Unit Cost (LCY)");
              JobJournalLine."Line Amount" := "Qty. to Consume" * "Unit Price"
            END
          END;
        GenJournalConsumption:
          BEGIN
            Assert.AreEqual(GLAccountType,JobPlanningLine.Type,'Can only consume G/L Account via Job Gen. Journal.');
            CreateGenJournalLineForPlan(JobPlanningLine,UsageLineType,Fraction,GenJournalLine);
            LibraryERM.PostGeneralJnlLine(GenJournalLine);
            WITH GenJournalLine DO BEGIN
              JobJournalLine."Line Type" := "Job Line Type";
              JobJournalLine."Remaining Qty." := "Job Remaining Qty.";
              JobJournalLine.Quantity := "Job Quantity";
              JobJournalLine.Description := Description;
              JobJournalLine."Total Cost" := "Job Total Cost";
              JobJournalLine."Total Cost (LCY)" := "Job Total Cost (LCY)";
              JobJournalLine."Line Amount" := "Job Line Amount";
            END
          END;
        PurchaseConsumption:
          BEGIN
            CreatePurchaseLineForPlan(JobPlanningLine,UsageLineType,Fraction,PurchaseLine);
            PurchaseHeader.GET(PurchaseLine."Document Type",PurchaseLine."Document No.");
            LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);
            WITH PurchaseLine DO BEGIN
              JobJournalLine."Line Type" := "Job Line Type";
              JobJournalLine."Remaining Qty." := "Job Remaining Qty.";
              JobJournalLine.Quantity := "Qty. to Invoice";
              JobJournalLine.Description := Description;
              JobJournalLine."Total Cost" := "Qty. to Invoice" * "Unit Cost (LCY)";
              JobJournalLine."Total Cost (LCY)" := "Qty. to Invoice" * "Unit Cost (LCY)";
              JobJournalLine."Total Price" := "Job Total Price";
              JobJournalLine."Line Amount" := "Job Line Amount";
            END
          END;
        ELSE
          Assert.Fail('Consumption method not supported')
      END

Example

The below example is extracted from the test automation codeunit 136303 to show one way of using this function.

      // Use a planning line with an explicit link
      // via job journal, gl journal, purchase, or service (Source).
      // Verify remaining quantity
      // Verify that the usage link is created.
      // Verify that the planning line's amounts and quantities are updated.

      // can only link to a planning line which type includes schedule
      Assert.IsTrue(
        LineTypeToMatch IN [LibraryJob.PlanningLineTypeSchedule,LibraryJob.PlanningLineTypeBoth],
        'Line type should include schedule.');

      // Setup
      Initialize;
      CreateJob(ApplyUsageLink,TRUE,Job);
      LibraryJob.CreateJobTask(Job,JobTask);

      // this is the planning line we want to match
      LibraryJob.CreateJobPlanningLine(LineTypeToMatch,ConsumableType,JobTask,JobPlanningLine);
      JobPlanningLine.VALIDATE("Usage Link",TRUE);
      JobPlanningLine.MODIFY(TRUE);

      AssertNoDiscounts(JobPlanningLine);
      BeforeJobPlanningLine := JobPlanningLine;

      // to make it more difficult
      CreateSimilarJobPlanningLines(JobPlanningLine);

      // with an explicit link, we can even have earlier planning lines that are identical
      NewJobPlanningLine := JobPlanningLine;
      EVALUATE(DateForm,'<-1W>');
      NewJobPlanningLine.VALIDATE("Planning Date",CALCDATE(DateForm,JobPlanningLine."Planning Date"));
      NewJobPlanningLine.VALIDATE("Line No.",LibraryJob.GetNextLineNo(JobPlanningLine));
      NewJobPlanningLine.INSERT(TRUE);
      LineCount := JobPlanningLine.COUNT;

      // Exercise
      LibraryJob.UseJobPlanningLineExplicit(JobPlanningLine,LibraryJob.UsageLineTypeBlank,1,Source,JobJournalLine);

      // refresh
      JobPlanningLine.GET(Job."No.",JobTask."Job Task No.",JobPlanningLine."Line No.");

      // Verify - the Remaining Qty. field on the journal line is correct
      JobJournalLine.TESTFIELD("Remaining Qty.",BeforeJobPlanningLine."Remaining Qty." - JobJournalLine.Quantity);

      // Verify - line type is taken from planning line
      Assert.AreEqual(
        LibraryJob.UsageLineType(JobPlanningLine."Line Type"),
        JobJournalLine."Line Type",
        'Journal line type should the same as planning line type.');

      // Verify - usage link has been created
      JobLedgerEntry.SETRANGE(Description,JobJournalLine.Description);
      JobLedgerEntry.FINDFIRST;
      VerifyUsageLink(JobPlanningLine,JobLedgerEntry);

      // Verify - no new planning lines are created
      Assert.AreEqual(LineCount,JobPlanningLine.COUNT,'No planning lines should have been created.');

      // Verify - JobPlanningLine@Pre - JobJournalLine = JobPlanningLine@Post
      VerifyJobPlanningLine(BeforeJobPlanningLine,JobPlanningLine,JobJournalLine)
Member of Lib.Library - Job


VerifyGLEntries@42 Method

The procedure VerifyGLEntries is available in codeunit 131920.

Syntax

VerifyGLEntries@42(
    VAR JobLedgerEntry@1000 : Record 169 JobLedgerEntry //Reference parameter of type Record
);

Parameters

JobLedgerEntry
Reference parameter of type Record

Remarks

The relevant search keywords are: Verify, General Ledger, Entries.

For a clarification about how this function works, refer to the code listed below.

      // Verify that each job entry has corresponding g/l entry with a job no.
      JobLedgerEntry.FINDSET;
      REPEAT
        GetGLEntry(JobLedgerEntry,GLEntry);
        Assert.AreEqual(JobLedgerEntry."Job No.",GLEntry."Job No.",JobNoErr)
      UNTIL JobLedgerEntry.NEXT = 0

Example

The below example is extracted from the test automation codeunit 136300 to show one way of using this function.

      // Parameterized test

      // PurchaseDocumentType IN [Order,Invoice]
      // PurchaseLineType IN [Item,G/L Account]
      // JobLineType IN ["",Schedule,Contract,Both Schedule and Contract]

      // Setup
      Initialize;
      LibraryJob.CreateJob(Job);
      LibraryJob.CreateJobTask(Job,JobTask);

      // Exercise
      CreateSingleLinePurchaseDoc(PurchaseDocumentType,PurchaseHeader);

      // Attach requested account type to the created purchase line
      GetPurchaseLines(PurchaseHeader,PurchaseLine);

      UpdatePurchLine(PurchaseLine,LibraryJob.Job2PurchaseConsumableType(ConsumableType));
      LibraryJob.AttachJobTask2PurchaseLine(JobTask,PurchaseLine);
      PurchaseLine.VALIDATE("Job Line Type",JobLineType);
      PurchaseLine.VALIDATE(Description,LibraryUtility.GenerateGUID);
      PurchaseLine.MODIFY(TRUE);
      LibraryJob.CopyPurchaseLines(PurchaseLine,TempPurchaseLine);
      PostPurchaseDocument(PurchaseHeader,PurchInvHeader);

      // Verify (planning lines, job ledger)
      LibraryJob.VerifyPurchaseDocPostingForJob(TempPurchaseLine);
      JobLedgerEntry.SETRANGE(Description,TempPurchaseLine.Description);
      Assert.AreEqual(1,JobLedgerEntry.COUNT,'# job ledger entries');
      JobLedgerEntry.FINDFIRST;

      LibraryJob.VerifyGLEntries(JobLedgerEntry);

      TearDown;
Member of Lib.Library - Job


VerifyJobJournalPosting@67 Method

The procedure VerifyJobJournalPosting is available in codeunit 131920.

Syntax

VerifyJobJournalPosting@67(
    UsageLink@1001 : Boolean UsageLink, //Input parameter of type Boolean
    VAR JobJournalLine@1000 : Record 210 JobJournalLine //Reference parameter of type Record
);

Parameters

UsageLink
Input parameter of type Boolean
JobJournalLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Verify, Job, Journal, Posting.

For a clarification about how this function works, refer to the code listed below.

      // Verify that the journal lines were posted correctly.

      Assert.IsFalse(JobJournalLine.ISEMPTY,'Not verifying any Job Journal Lines!');
      JobJournalLine.FINDSET;
      REPEAT
        VerifyJobLedger(JobJournalLine);
        VerifyPlanningLines(JobJournalLine,UsageLink)
      UNTIL JobJournalLine.NEXT = 0

Example

The below example is extracted from the test automation codeunit 136300 to show one way of using this function.

      // Parameterized test

      // LineType IN ["",Schedule,Contract,Both Schedule and Contract]
      // Type IN [Resource,G/L Account,Item]

      // Setup
      Initialize;
      LibraryJob.CreateJob(Job);
      LibraryJob.CreateJobTask(Job,JobTask);

      // Exercise
      LibraryJob.CreateJobJournalLineForType(LineType,Type,JobTask,JobJournalLine);

      // Verify
      VerifyJobJournalLineCostPrice(JobJournalLine);

      // Exercise
      LibraryJob.CopyJobJournalLines(JobJournalLine,TempJobJournalLine);
      LibraryJob.PostJobJournal(JobJournalLine);

      // Verify (planning lines and job ledger)
      LibraryJob.VerifyJobJournalPosting(FALSE,TempJobJournalLine);

      TearDown;
Member of Lib.Library - Job


VerifyJobLedger@57 Method

The procedure VerifyJobLedger is available in codeunit 131920.

Syntax

VerifyJobLedger@57(
    JobJournalLine@1000 : Record 210 JobJournalLine //Input parameter of type Record
);

Parameters

JobJournalLine
Input parameter of type Record

Remarks

The relevant search keywords are: Verify, Job, Ledger.

For a clarification about how this function works, refer to the code listed below.

      // A posted job journal line gives one corresponding entry in the job ledger.

      WITH JobLedgerEntry DO BEGIN
        SETRANGE(Description,JobJournalLine.Description);

        Assert.AreEqual(
          1,COUNT,
          STRSUBSTNO(
            'Invalid Job Ledger Entry for Batch %1 Document %2',JobJournalLine."Journal Batch Name",
            JobJournalLine."Document No."));

        FINDFIRST;
        Precision := Max(GetAmountRoundingPrecision(''),GetAmountRoundingPrecision(JobJournalLine."Currency Code"));
        Assert.AreEqual(JobJournalLine."Job No.","Job No.",FIELDCAPTION("Job No."));
        Assert.AreEqual(JobJournalLine."Job Task No.","Job Task No.",FIELDCAPTION("Job Task No."));
        Assert.AreNearlyEqual(JobJournalLine."Unit Cost (LCY)","Unit Cost (LCY)",Precision * 10,FIELDCAPTION("Unit Cost (LCY)"));
        Assert.AreNearlyEqual(JobJournalLine."Unit Price (LCY)","Unit Price (LCY)",Precision,FIELDCAPTION("Unit Price (LCY)"));
        Assert.AreEqual(JobJournalLine.Quantity,Quantity,FIELDCAPTION(Quantity));
      END

Example

The below example is extracted from the test automation codeunit 136303 to show one way of using this function.

      // Use more than planned by matching via job journal.
      // Verify that the usage links are created.
      // Verify that the planning line's amounts and quantities are updated.
      // Verfiy that correct planning line(s) is created for the remainder.

      // can only match a planning line which type includes schedule
      Assert.IsTrue(
        LineTypeToMatch IN [LibraryJob.PlanningLineTypeSchedule,LibraryJob.PlanningLineTypeBoth],
        'Line type should include schedule.');

      // Setup
      Initialize;
      CreateJob(ApplyUsageLink,TRUE,Job);
      LibraryJob.CreateJobTask(Job,JobTask);

      // this is the planning line we want to match
      LibraryJob.CreateJobPlanningLine(LineTypeToMatch,ConsumableType,JobTask,JobPlanningLine);
      JobPlanningLine.VALIDATE("Usage Link",TRUE);
      JobPlanningLine.MODIFY(TRUE);

      AssertNoDiscounts(JobPlanningLine);
      LineCount := JobPlanningLine.COUNT;

      // Exercise - use three (random) times the planned quantity
      BeforeJobPlanningLine := JobPlanningLine;
      LibraryJob.UseJobPlanningLine(JobPlanningLine,LibraryJob.UsageLineTypeSchedule,3,JobJournalLine);

      // refresh
      JobPlanningLine.GET(Job."No.",JobTask."Job Task No.",JobPlanningLine."Line No.");

      // Verify - usage is linked
      JobLedgerEntry.SETRANGE(Description,JobJournalLine.Description);
      JobLedgerEntry.FINDFIRST;
      VerifyUsageLink(JobPlanningLine,JobLedgerEntry);

      // Verify - the original planning line is completed
      VerifyJobPlanningLineDone(JobPlanningLine);

      // Verify - an extra planning line is created
      Assert.AreEqual(LineCount + 1,JobPlanningLine.COUNT,'One planning line should have been created.');

      // Verfiy - transaction correctly registered in ledger
      LibraryJob.VerifyJobLedger(JobJournalLine);

      // Verify - the correct planning line(s) are created
      UseFromPlan(JobJournalLine,BeforeJobPlanningLine);
      LibraryJob.VerifyPlanningLines(JobJournalLine,TRUE)
Member of Lib.Library - Job


VerifyPlanningLines@46 Method

The procedure VerifyPlanningLines is available in codeunit 131920.

Syntax

VerifyPlanningLines@46(
    JobJournalLine@1000 : Record 210 JobJournalLine, //Input parameter of type Record
    UsageLink@1002 : Boolean UsageLink //Input parameter of type Boolean
);

Parameters

JobJournalLine
Input parameter of type Record
UsageLink
Input parameter of type Boolean

Remarks

The relevant search keywords are: Verify, Planning, Lines.

For a clarification about how this function works, refer to the code listed below.

      // A posted job journal line gives
      // 0 (Blank),
      // 1 (Contract or Schedule), or
      // 2 (Both)
      // corresponding planning lines.

      WITH JobPlanningLine DO BEGIN
        SETRANGE(Description,JobJournalLine.Description);

        // Verify line count and type
        CASE JobJournalLine."Line Type" OF
          UsageLineTypeBlank:
            VerifyPlanningLineCountBlank(JobJournalLine,UsageLink);
          UsageLineTypeSchedule:
            VerifyPlanningLineCountSchedul(JobJournalLine);
          UsageLineTypeContract:
            VerifyPlanningLineCountContrac(JobJournalLine,UsageLink);
          UsageLineTypeBoth:
            VerifyPlanningLineCountBoth(JobJournalLine);
          ELSE
            Assert.Fail('Invalid line type.');
        END;

        // Verify Unit Cost, Price.
        Precision := Max(GetAmountRoundingPrecision(''),GetAmountRoundingPrecision(JobJournalLine."Currency Code"));
        IF FINDSET THEN
          REPEAT
            Assert.AreEqual(JobJournalLine.Quantity,Quantity,FIELDCAPTION(Quantity));
            Assert.AreEqual(JobJournalLine."Job No.","Job No.",FIELDCAPTION("Job No."));
            Assert.AreEqual(JobJournalLine."Job Task No.","Job Task No.",FIELDCAPTION("Job Task No."));
            Assert.AreNearlyEqual(JobJournalLine."Unit Cost (LCY)","Unit Cost (LCY)",Precision * 10,FIELDCAPTION("Unit Cost (LCY)"));
            Assert.AreNearlyEqual(JobJournalLine."Unit Price (LCY)","Unit Price (LCY)",Precision,FIELDCAPTION("Unit Price (LCY)"))
          UNTIL NEXT = 0
      END

Example

The below example is extracted from the test automation codeunit 136303 to show one way of using this function.

      // Use more than planned by matching via job journal.
      // Verify that the usage links are created.
      // Verify that the planning line's amounts and quantities are updated.
      // Verfiy that correct planning line(s) is created for the remainder.

      // can only match a planning line which type includes schedule
      Assert.IsTrue(
        LineTypeToMatch IN [LibraryJob.PlanningLineTypeSchedule,LibraryJob.PlanningLineTypeBoth],
        'Line type should include schedule.');

      // Setup
      Initialize;
      CreateJob(ApplyUsageLink,TRUE,Job);
      LibraryJob.CreateJobTask(Job,JobTask);

      // this is the planning line we want to match
      LibraryJob.CreateJobPlanningLine(LineTypeToMatch,ConsumableType,JobTask,JobPlanningLine);
      JobPlanningLine.VALIDATE("Usage Link",TRUE);
      JobPlanningLine.MODIFY(TRUE);

      AssertNoDiscounts(JobPlanningLine);
      LineCount := JobPlanningLine.COUNT;

      // Exercise - use three (random) times the planned quantity
      BeforeJobPlanningLine := JobPlanningLine;
      LibraryJob.UseJobPlanningLine(JobPlanningLine,LibraryJob.UsageLineTypeSchedule,3,JobJournalLine);

      // refresh
      JobPlanningLine.GET(Job."No.",JobTask."Job Task No.",JobPlanningLine."Line No.");

      // Verify - usage is linked
      JobLedgerEntry.SETRANGE(Description,JobJournalLine.Description);
      JobLedgerEntry.FINDFIRST;
      VerifyUsageLink(JobPlanningLine,JobLedgerEntry);

      // Verify - the original planning line is completed
      VerifyJobPlanningLineDone(JobPlanningLine);

      // Verify - an extra planning line is created
      Assert.AreEqual(LineCount + 1,JobPlanningLine.COUNT,'One planning line should have been created.');

      // Verfiy - transaction correctly registered in ledger
      LibraryJob.VerifyJobLedger(JobJournalLine);

      // Verify - the correct planning line(s) are created
      UseFromPlan(JobJournalLine,BeforeJobPlanningLine);
      LibraryJob.VerifyPlanningLines(JobJournalLine,TRUE)
Member of Lib.Library - Job


VerifyPurchaseDocPostingForJob@28 Method

The procedure VerifyPurchaseDocPostingForJob is available in codeunit 131920.

Syntax

VerifyPurchaseDocPostingForJob@28(
    VAR PurchaseLine@1000 : Record 39 PurchaseLine //Reference parameter of type Record
);

Parameters

PurchaseLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Verify, Purchase, Document, Posting, For, Job.

For a clarification about how this function works, refer to the code listed below.

      // Verify posting of a purchase line for a job.
      PurchaseLine.SETFILTER("Job No.",'<>''''');
      PurchaseLine.FINDSET;
      Job.GET(PurchaseLine."Job No.");

      REPEAT
        WITH TempJobJournalLine DO BEGIN
          "Line No." := PurchaseLine."Line No.";
          "Job No." := PurchaseLine."Job No.";
          "Job Task No." := PurchaseLine."Job Task No.";
          Description := PurchaseLine.Description;
          "Line Type" := PurchaseLine."Job Line Type";
          Quantity := PurchaseLine.Quantity;
          "Unit Cost (LCY)" := PurchaseLine."Unit Cost (LCY)";
          "Unit Price (LCY)" := PurchaseLine."Unit Price (LCY)";
          "Currency Code" := Job."Currency Code";
          INSERT
        END
      UNTIL PurchaseLine.NEXT = 0;

      VerifyJobJournalPosting(FALSE,TempJobJournalLine)

Example

The below example is extracted from the test automation codeunit 136300 to show one way of using this function.

      // Parameterized test

      // PurchaseDocumentType IN [Order,Invoice]
      // PurchaseLineType IN [Item,G/L Account]
      // JobLineType IN ["",Schedule,Contract,Both Schedule and Contract]

      // Setup
      Initialize;
      LibraryJob.CreateJob(Job);
      LibraryJob.CreateJobTask(Job,JobTask);

      // Exercise
      CreateSingleLinePurchaseDoc(PurchaseDocumentType,PurchaseHeader);

      // Attach requested account type to the created purchase line
      GetPurchaseLines(PurchaseHeader,PurchaseLine);

      UpdatePurchLine(PurchaseLine,LibraryJob.Job2PurchaseConsumableType(ConsumableType));
      LibraryJob.AttachJobTask2PurchaseLine(JobTask,PurchaseLine);
      PurchaseLine.VALIDATE("Job Line Type",JobLineType);
      PurchaseLine.VALIDATE(Description,LibraryUtility.GenerateGUID);
      PurchaseLine.MODIFY(TRUE);
      LibraryJob.CopyPurchaseLines(PurchaseLine,TempPurchaseLine);
      PostPurchaseDocument(PurchaseHeader,PurchInvHeader);

      // Verify (planning lines, job ledger)
      LibraryJob.VerifyPurchaseDocPostingForJob(TempPurchaseLine);
      JobLedgerEntry.SETRANGE(Description,TempPurchaseLine.Description);
      Assert.AreEqual(1,JobLedgerEntry.COUNT,'# job ledger entries');
      JobLedgerEntry.FINDFIRST;

      LibraryJob.VerifyGLEntries(JobLedgerEntry);

      TearDown;
Member of Lib.Library - Job


Library - Journals Class

Lib.Library - Journals

COD131306 applies to ERM,W1,All.
Library containing functions related to various Journals.

Methods

Name | Description
CreateGenJournalBatch@8 | The procedure CreateGenJournalBatch is available in codeunit 131306.
CreateGenJournalBatchWithType@7 | The procedure CreateGenJournalBatchWithType is available in codeunit 131306.
CreateGenJournalLine@1 | The procedure CreateGenJournalLine is available in codeunit 131306.
CreateGenJournalLine2@5 | The procedure CreateGenJournalLine2 is available in codeunit 131306.
CreateGenJournalLineWithBatch@6 | The procedure CreateGenJournalLineWithBatch is available in codeunit 131306.
SelectGenJournalBatch@2 | The procedure SelectGenJournalBatch is available in codeunit 131306.
SelectGenJournalTemplate@51 | The procedure SelectGenJournalTemplate is available in codeunit 131306.

See Also

Lib


CreateGenJournalBatch@8 Method

The procedure CreateGenJournalBatch is available in codeunit 131306.

Syntax

CreateGenJournalBatch@8(
    VAR GenJournalBatch@1000 : Record 232 GenJournalBatch //Reference parameter of type Record
);

Parameters

GenJournalBatch
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, General, Journal, Batch.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.CreateGenJournalTemplate(GenJournalTemplate);
      LibraryERM.CreateGenJournalBatch(GenJournalBatch,GenJournalTemplate.Name);

Example

The below example is extracted from the test automation codeunit 134001 to show one way of using this function.

      LibraryERM.CreateGenJournalTemplate(GenJournalTemplate);
      LibraryERM.CreateGenJournalBatch(GenJournalBatch,GenJournalTemplate.Name);
Member of Lib.Library - Journals


CreateGenJournalBatchWithType@7 Method

The procedure CreateGenJournalBatchWithType is available in codeunit 131306.

Syntax

CreateGenJournalBatchWithType@7(
    VAR GenJournalBatch@1000 : Record 232 GenJournalBatch, //Reference parameter of type Record
    Type@1001 : Option Type //Input parameter of type Option
);

Parameters

GenJournalBatch
Reference parameter of type Record
Type
Input parameter of type Option

Remarks

The relevant search keywords are: Create, General, Journal, Batch, Type.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.CreateGenJournalTemplate(GenJournalTemplate);
      GenJournalTemplate.VALIDATE(Type,Type);
      GenJournalTemplate.MODIFY(TRUE);
      LibraryERM.CreateGenJournalBatch(GenJournalBatch,GenJournalTemplate.Name);

Example

The below example is extracted from the test automation codeunit 134135 to show one way of using this function.

      LibraryJournals.CreateGenJournalBatchWithType(GenJournalBatch,GenJournalBatch."Template Type"::Assets);
      WITH GenJournalLine DO BEGIN
        LibraryJournals.CreateGenJournalLine(
          GenJournalLine,GenJournalBatch."Journal Template Name",GenJournalBatch.Name,
          "Document Type"::" ","Account Type"::"Fixed Asset",FANo,
          "Bal. Account Type"::"G/L Account",BalGLAccountNo,LineAmount);
        VALIDATE("FA Posting Type",FAPostingType);
        VALIDATE("Depreciation Book Code",DepreciationBookCode);
        MODIFY(TRUE);
      END;
      LibraryERM.PostGeneralJnlLine(GenJournalLine);
Member of Lib.Library - Journals


CreateGenJournalLine@1 Method

The procedure CreateGenJournalLine is available in codeunit 131306.

Syntax

CreateGenJournalLine@1(
    VAR GenJournalLine@1321 : Record 81 GenJournalLine, //Reference parameter of type Record
    JournalTemplateName@1001 : Code[10] JournalTemplateName, //Input parameter of type Code
    JournalBatchName@1003 : Code[10] JournalBatchName, //Input parameter of type Code
    DocumentType@1004 : Option DocumentType, //Input parameter of type Option
    AccountType@1005 : Option AccountType, //Input parameter of type Option
    AccountNo@1006 : Code[20] AccountNo, //Input parameter of type Code
    BalAccountType@1002 : Option BalAccountType, //Input parameter of type Option
    BalAccountNo@1000 : Code[20] BalAccountNo, //Input parameter of type Code
    Amount@1007 : Decimal Amount //Input parameter of type Decimal
);

Parameters

GenJournalLine
Reference parameter of type Record
JournalTemplateName
Input parameter of type Code
JournalBatchName
Input parameter of type Code
DocumentType
Input parameter of type Option
AccountType
Input parameter of type Option
AccountNo
Input parameter of type Code
BalAccountType
Input parameter of type Option
BalAccountNo
Input parameter of type Code
Amount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, General, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      // Find a balanced template/batch pair.
      GenJournalBatch.GET(JournalTemplateName,JournalBatchName);

      // Create a General Journal Entry.
      GenJournalLine.INIT;
      GenJournalLine.VALIDATE("Journal Template Name",JournalTemplateName);
      GenJournalLine.VALIDATE("Journal Batch Name",JournalBatchName);
      RecRef.GETTABLE(GenJournalLine);
      GenJournalLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,GenJournalLine.FIELDNO("Line No.")));
      GenJournalLine.INSERT(TRUE);
      GenJournalLine.VALIDATE("Posting Date",WORKDATE);  // Defaults to work date.
      GenJournalLine.VALIDATE("Document Type",DocumentType);
      GenJournalLine.VALIDATE("Account Type",AccountType);
      GenJournalLine.VALIDATE("Account No.",AccountNo);
      GenJournalLine.VALIDATE(Amount,Amount);
      IF NoSeries.GET(GenJournalBatch."No. Series") THEN
        GenJournalLine.VALIDATE("Document No.",NoSeriesMgt.GetNextNo(GenJournalBatch."No. Series",WORKDATE,FALSE)) // Unused but required field for posting.
      ELSE
        GenJournalLine.VALIDATE(
          "Document No.",LibraryUtility.GenerateRandomCode(GenJournalLine.FIELDNO("Document No."),DATABASE::"Gen. Journal Line"));
      GenJournalLine.VALIDATE("External Document No.",GenJournalLine."Document No.");  // Unused but required for vendor posting.
      GenJournalLine.VALIDATE("Source Code",LibraryERM.FindGeneralJournalSourceCode);  // Unused but required for AU, NZ builds
      GenJournalLine.VALIDATE("Bal. Account Type",BalAccountType);
      GenJournalLine.VALIDATE("Bal. Account No.",BalAccountNo);
      GenJournalLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134076 to show one way of using this function.

      LibraryJournals.CreateGenJournalLine(
        GenJournalLine,GenJournalBatch."Journal Template Name",GenJournalBatch.Name,
        GenJournalLine."Document Type"::Payment,AccountType,AccountNo,
        GenJournalLine."Bal. Account Type"::"G/L Account",BalAccountNo,PaymentAmount);
      GenJournalLine.VALIDATE("Applies-to Doc. Type",ApplnDocType);
      GenJournalLine.VALIDATE("Applies-to Doc. No.",ApplnDocNo);
      GenJournalLine.MODIFY(TRUE);
Member of Lib.Library - Journals


CreateGenJournalLine2@5 Method

The procedure CreateGenJournalLine2 is available in codeunit 131306.

Syntax

CreateGenJournalLine2@5(
    VAR GenJournalLine@1321 : Record 81 GenJournalLine, //Reference parameter of type Record
    JournalTemplateName@1001 : Code[10] JournalTemplateName, //Input parameter of type Code
    JournalBatchName@1003 : Code[10] JournalBatchName, //Input parameter of type Code
    DocumentType@1004 : Option DocumentType, //Input parameter of type Option
    AccountType@1005 : Option AccountType, //Input parameter of type Option
    AccountNo@1006 : Code[20] AccountNo, //Input parameter of type Code
    BalAccountType@1002 : Option BalAccountType, //Input parameter of type Option
    BalAccountNo@1000 : Code[20] BalAccountNo, //Input parameter of type Code
    Amount@1007 : Decimal Amount //Input parameter of type Decimal
);

Parameters

GenJournalLine
Reference parameter of type Record
JournalTemplateName
Input parameter of type Code
JournalBatchName
Input parameter of type Code
DocumentType
Input parameter of type Option
AccountType
Input parameter of type Option
AccountNo
Input parameter of type Code
BalAccountType
Input parameter of type Option
BalAccountNo
Input parameter of type Code
Amount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, General, Journal, Line2.

For a clarification about how this function works, refer to the code listed below.

      // This function should replace the one above, but it requires a lot of changes to existing tests so I'm keeping both for now and will refactor when time permits

      // Find a balanced template/batch pair.
      GenJournalBatch.GET(JournalTemplateName,JournalBatchName);

      // get the last Gen Jnl Line as template or insert a new doc no (to avoid CODEUNIT.RUN in WRITE transaction error)
      CLEAR(GenJournalLine);
      GenJournalLine.SETRANGE("Journal Template Name",JournalTemplateName);
      GenJournalLine.SETRANGE("Journal Batch Name",JournalBatchName);
      IF NOT GetLastGenJnlLineAndBalance(GenJournalLine,LastGenJnlLine,Balance,JournalTemplateName,JournalBatchName) THEN
        SetLastGenJnlLineFields(LastGenJnlLine,GenJournalBatch);

      // Create a General Journal Entry.
      GenJournalLine.VALIDATE("Journal Template Name",JournalTemplateName);
      GenJournalLine.VALIDATE("Journal Batch Name",JournalBatchName);
      RecRef.GETTABLE(GenJournalLine);
      GenJournalLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,GenJournalLine.FIELDNO("Line No.")));
      GenJournalLine.INSERT(TRUE);

      // Initialize the new line
      GenJournalLine.SetUpNewLine(LastGenJnlLine,Balance,TRUE);

      // fill in additional fields
      GenJournalLine.VALIDATE("Document Type",DocumentType);
      GenJournalLine.VALIDATE("Account Type",AccountType);
      GenJournalLine.VALIDATE("Account No.",AccountNo);
      GenJournalLine.VALIDATE(Amount,Amount);
      GenJournalLine.VALIDATE("External Document No.",GenJournalLine."Document No.");  // Unused but required for vendor posting.
      GenJournalLine.VALIDATE("Source Code",LibraryERM.FindGeneralJournalSourceCode);  // Unused but required for AU, NZ builds
      GenJournalLine.VALIDATE("Bal. Account Type",BalAccountType);
      GenJournalLine.VALIDATE("Bal. Account No.",BalAccountNo);
      GenJournalLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134048 to show one way of using this function.

      // [FEATURE] [Sales]
      // [SCENARIO 363478] Gen. Journal should not be posted where one transaction includes both Customer and G/L Account of Purchase Gen. Posting Type.
      Initialize;
      CreateGeneralJournalBatch(GenJournalBatch);

      // [GIVEN] General Journal Line1: "Account Type" = "G/L Account" (with "Gen. Posting Type" = Purchase)
      LibraryJournals.CreateGenJournalLine2(
        GenJournalLine,GenJournalBatch."Journal Template Name",GenJournalBatch.Name,
        GenJournalLine."Document Type"::"Credit Memo",GenJournalLine."Account Type"::"G/L Account",
        CreateGLAccountNoPurchase,0,'',LibraryRandom.RandDec(100,2));
      GenJournalLine.VALIDATE("Bill-to/Pay-to No.",'');
      GenJournalLine.MODIFY;
      DocumentNo := GenJournalLine."Document No.";

      // [GIVEN] General Journal Line2: "Account Type" = "Customer"
      LibraryJournals.CreateGenJournalLine2(
        GenJournalLine,GenJournalBatch."Journal Template Name",GenJournalBatch.Name,
        GenJournalLine."Document Type"::"Credit Memo",GenJournalLine."Account Type"::Customer,
        LibrarySales.CreateCustomerNo,0,'',-GenJournalLine.Amount);
      GenJournalLine.VALIDATE("Document No.",DocumentNo);
      GenJournalLine.MODIFY;

      // [WHEN] Post General Journal
      ASSERTERROR LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // [THEN] Error occurs: "Gen. Posting Type must not be Purchase in Gen. Journal Line..."
      Assert.ExpectedError(GenPostingTypeErr);
Member of Lib.Library - Journals


CreateGenJournalLineWithBatch@6 Method

The procedure CreateGenJournalLineWithBatch is available in codeunit 131306.

Syntax

CreateGenJournalLineWithBatch@6(
    VAR GenJournalLine@1003 : Record 81 GenJournalLine, //Reference parameter of type Record
    DocumentType@1004 : Option DocumentType, //Input parameter of type Option
    AccountType@1005 : Option AccountType, //Input parameter of type Option
    AccountNo@1006 : Code[20] AccountNo, //Input parameter of type Code
    LineAmount@1007 : Decimal LineAmount //Input parameter of type Decimal
);

Parameters

GenJournalLine
Reference parameter of type Record
DocumentType
Input parameter of type Option
AccountType
Input parameter of type Option
AccountNo
Input parameter of type Code
LineAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, General, Journal, Line, Batch.

For a clarification about how this function works, refer to the code listed below.

      CreateGenJournalBatch(GenJournalBatch);
      LibraryERM.CreateGLAccount(GLAccount);
      CreateGenJournalLine(
        GenJournalLine,
        GenJournalBatch."Journal Template Name",
        GenJournalBatch.Name,
        DocumentType,
        AccountType,
        AccountNo,
        GenJournalLine."Bal. Account Type"::"G/L Account",
        GLAccount."No.",
        LineAmount);

Example

The below example is extracted from the test automation codeunit 134001 to show one way of using this function.

      // [FEATURE] [UT]
      // [SCENARIO 381241] When calling "Get Vendor Ledger Entry", "Amount" of Gen. Journal Line should be calculated according to found Vendor Ledger Entry

      Initialize;

      // [GIVEN] Vendor Ledger Entry having -("Remaining Amount" - "Remaining Pmt. Disc. Possible") = -100 and "Document No." = AAA
      MockVendLedgEntry(VendLedgEntry);

      // [GIVEN] General Journal Line habing "Applies-to Doc. No." = AAA
      LibraryJournals.CreateGenJournalLineWithBatch(
        GenJournalLine,GenJournalLine."Document Type"::" ",
        GenJournalLine."Account Type"::Vendor,'',0);
      GenJournalLine."Applies-to Doc. No." := VendLedgEntry."Document No.";
      GenJournalLine.MODIFY;

      // [WHEN] Call "Get Vendor Ledger Entry" for General Journal Line
      GenJournalLine.GetVendLedgerEntry;

      // [THEN] General Journal Line "Amount" = -100
      GenJournalLine.TESTFIELD(Amount,-(VendLedgEntry."Remaining Amount" - VendLedgEntry."Remaining Pmt. Disc. Possible"));
Member of Lib.Library - Journals


SelectGenJournalBatch@2 Method

The procedure SelectGenJournalBatch is available in codeunit 131306.

Syntax

SelectGenJournalBatch@2(
    VAR GenJournalBatch@1000 : Record 232 GenJournalBatch, //Reference parameter of type Record
    GenJournalTemplateCode@1001 : Code[10] GenJournalTemplateCode //Input parameter of type Code
);

Parameters

GenJournalBatch
Reference parameter of type Record
GenJournalTemplateCode
Input parameter of type Code

Remarks

The relevant search keywords are: Select, General, Journal, Batch.

For a clarification about how this function works, refer to the code listed below.

      // Select General Journal Batch Name for General Journal Line.
      GenJournalBatch.SETRANGE("Journal Template Name",GenJournalTemplateCode);
      GenJournalBatch.SETRANGE("Bal. Account Type",GenJournalBatch."Bal. Account Type"::"G/L Account");
      LibraryERM.CreateGLAccount(GLAccount);

      IF NOT GenJournalBatch.FINDFIRST THEN BEGIN
        // Create New General Journal Batch.
        LibraryERM.CreateGenJournalBatch(GenJournalBatch,GenJournalTemplateCode);
        GenJournalBatch.VALIDATE("No. Series",LibraryERM.CreateNoSeriesCode);
        GenJournalBatch.VALIDATE("Bal. Account Type",GenJournalBatch."Bal. Account Type"::"G/L Account");
      END;

      GenJournalBatch.VALIDATE("Bal. Account No.",GLAccount."No.");
      GenJournalBatch.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - Journals


SelectGenJournalTemplate@51 Method

The procedure SelectGenJournalTemplate is available in codeunit 131306.

Syntax

SelectGenJournalTemplate@51(
    Type@1001 : Option Type, //Input parameter of type Option
    PageID@1002 : Integer PageID //Input parameter of type Integer
);

Parameters

Type
Input parameter of type Option
PageID
Input parameter of type Integer

Return Value

Code[10]

Remarks

The relevant search keywords are: Select, General, Journal, Template.

For a clarification about how this function works, refer to the code listed below.

      GenJournalTemplate.SETRANGE(Type,Type);
      GenJournalTemplate.SETRANGE(Recurring,FALSE);
      GenJournalTemplate.SETRANGE("Page ID",PageID);

      IF NOT GenJournalTemplate.FINDFIRST THEN BEGIN
        GenJournalTemplate.INIT;
        GenJournalTemplate.VALIDATE(
          Name,LibraryUtility.GenerateRandomCode(GenJournalTemplate.FIELDNO(Name),DATABASE::"Gen. Journal Template"));
        GenJournalTemplate.VALIDATE(Type,Type);
        GenJournalTemplate.VALIDATE("Page ID",PageID);
        GenJournalTemplate.VALIDATE(Recurring,FALSE);
        GenJournalTemplate.INSERT(TRUE);
      END;

      EXIT(GenJournalTemplate.Name);

Example

There are no examples available.
Member of Lib.Library - Journals


Library - Kitting Class

Lib.Library - Kitting

COD132205 applies to SCM,W1,All.

Methods

Name | Description
AddLine@11 | The procedure AddLine is available in codeunit 132205.
AddProdBOMItem@21 | The procedure AddProdBOMItem is available in codeunit 132205.
CreateAssemblySetup@2 | The procedure CreateAssemblySetup is available in codeunit 132205.
CreateBOMComponentLine@54 | The procedure CreateBOMComponentLine is available in codeunit 132205.
CreateInvPostGroup@28 | The procedure CreateInvPostGroup is available in codeunit 132205.
CreateItem@2001 | The procedure CreateItem is available in codeunit 132205.
CreateItemNo@3 | The procedure CreateItemNo is available in codeunit 132205.
CreateItemwithLot@17 | The procedure CreateItemwithLot is available in codeunit 132205.
CreateItemWithLotAndNewUOM@111 | The procedure CreateItemWithLotAndNewUOM is available in codeunit 132205.
CreateItemWithLotAndNewUOMUsingItemNo@5 | The procedure CreateItemWithLotAndNewUOMUsingItemNo is available in codeunit 132205.
CreateItemwithLotNo@8 | The procedure CreateItemwithLotNo is available in codeunit 132205.
CreateItemWithNewUOM@110 | The procedure CreateItemWithNewUOM is available in codeunit 132205.
CreateItemWithNewUOMUsingItemNo@16 | The procedure CreateItemWithNewUOMUsingItemNo is available in codeunit 132205.
CreateItemwithStandard@18 | The procedure CreateItemwithStandard is available in codeunit 132205.
CreateItemwithStandardNo@7 | The procedure CreateItemwithStandardNo is available in codeunit 132205.
CreateNoSeries@1 | The procedure CreateNoSeries is available in codeunit 132205.
CreateOrder@12 | The procedure CreateOrder is available in codeunit 132205.
CreateOrderNo@4 | The procedure CreateOrderNo is available in codeunit 132205.
CreateResource@6 | The procedure CreateResource is available in codeunit 132205.
CreateResourceInvPostGroup@29 | The procedure CreateResourceInvPostGroup is available in codeunit 132205.
CreateResourceWithNewUOM@114 | The procedure CreateResourceWithNewUOM is available in codeunit 132205.
CreateStdCostItemWithNewUOM@112 | The procedure CreateStdCostItemWithNewUOM is available in codeunit 132205.
CreateStdCostItemWithNewUOMUsingItemNo@113 | The procedure CreateStdCostItemWithNewUOMUsingItemNo is available in codeunit 132205.
ItemCreate@14 | The procedure ItemCreate is available in codeunit 132205.
ItemMake@19 | The procedure ItemMake is available in codeunit 132205.
ResourceMake@52 | The procedure ResourceMake is available in codeunit 132205.
SetCopyFrom@10 | The procedure SetCopyFrom is available in codeunit 132205.
SetLookahead@9 | The procedure SetLookahead is available in codeunit 132205.
TotalQuantity@13 | The procedure TotalQuantity is available in codeunit 132205.

See Also

Lib


AddLine@11 Method

The procedure AddLine is available in codeunit 132205.

Syntax

AddLine@11(
    AsmHeader@1000 : Record 900 AsmHeader, //Input parameter of type Record
    Type@1001 : Option Type, //Input parameter of type Option
    No@1002 : Code[20] No, //Input parameter of type Code
    UOMCode@1003 : Code[10] UOMCode, //Input parameter of type Code
    Quantity@1004 : Decimal Quantity, //Input parameter of type Decimal
    QtyPer@1005 : Integer QtyPer, //Input parameter of type Integer
    Desc@1006 : Text[50] Desc //Input parameter of type Text
);

Parameters

AsmHeader
Input parameter of type Record
Type
Input parameter of type Option
No
Input parameter of type Code
UOMCode
Input parameter of type Code
Quantity
Input parameter of type Decimal
QtyPer
Input parameter of type Integer
Desc
Input parameter of type Text

Remarks

The relevant search keywords are: Add, Line.

For a clarification about how this function works, refer to the code listed below.

      LibraryAssembly.CreateAssemblyLine(AsmHeader,AssemblyLine,Type,No,UOMCode,Quantity,QtyPer,Desc);

Example

The below example is extracted from the test automation codeunit 137104 to show one way of using this function.

      LibraryKitting.AddLine(AssemblyHeader,AssemblyLine.Type::Item,ItemNo,
        LibraryAssembly.GetUnitOfMeasureCode(AssemblyLine.Type::Item,ItemNo,TRUE),
        Quantity,1,'');

      IF AssignBinCode THEN BEGIN
        AssemblyLine.SETRANGE("Document Type",AssemblyHeader."Document Type");
        AssemblyLine.SETRANGE("Document No.",AssemblyHeader."No.");
        AssemblyLine.SETRANGE("No.",ItemNo);
        AssemblyLine.FINDLAST;

        AssemblyLine.VALIDATE("Bin Code",LocationAdditionalBinCode);
        AssemblyLine.VALIDATE("Quantity to Consume",Quantity);
        AssemblyLine.MODIFY;
      END;

      IF AssignIT THEN BEGIN
        AssemblyOrderPage.OPENEDIT;
        AssemblyOrderPage.FILTER.SETFILTER("No.",AssemblyHeader."No.");

        AssemblyOrderPage.Lines.LAST;

        PrepareHandleSelectEntries(FALSE);
        AssemblyOrderPage.Lines."Item Tracking Lines".INVOKE;
        AssemblyOrderPage.OK.INVOKE;
      END;
Member of Lib.Library - Kitting


AddProdBOMItem@21 Method

The procedure AddProdBOMItem is available in codeunit 132205.

Syntax

AddProdBOMItem@21(
    VAR MfgItem@1000 : Record 27 MfgItem, //Reference parameter of type Record
    SubItemNo@1001 : Code[20] SubItemNo, //Input parameter of type Code
    Qty@1002 : Decimal Qty //Input parameter of type Decimal
);

Parameters

MfgItem
Reference parameter of type Record
SubItemNo
Input parameter of type Code
Qty
Input parameter of type Decimal

Remarks

The relevant search keywords are: Add, Product, BOM, Item.

For a clarification about how this function works, refer to the code listed below.

      IF MfgItem.IsMfgItem THEN
        ProdBOMHeader.GET(MfgItem."Production BOM No.")
      ELSE BEGIN
        ProdBOMHeader."No." := COPYSTR(MfgItem."No." + 'BOM',1,MAXSTRLEN(ProdBOMHeader."No."));
        ProdBOMHeader.Status := ProdBOMHeader.Status::Certified;
        ProdBOMHeader.INSERT;
        MfgItem."Production BOM No." := ProdBOMHeader."No.";
        MfgItem."Replenishment System" := MfgItem."Replenishment System"::"Prod. Order";
        MfgItem.MODIFY
      END;
      ProdBOMLine."Production BOM No." := ProdBOMHeader."No.";
      BOMItemLineNo += 1;
      ProdBOMLine."Line No." := BOMItemLineNo;
      ProdBOMLine.Type := ProdBOMLine.Type::Item;
      ProdBOMLine."No." := SubItemNo;
      subItem.GET(SubItemNo);
      ProdBOMLine."Unit of Measure Code" := subItem."Base Unit of Measure";
      ProdBOMLine.Quantity := Qty;
      ProdBOMLine.INSERT;

Example

The below example is extracted from the test automation codeunit 137910 to show one way of using this function.

      Initialize;
      asmTopItem.GET(CreateItem('ASM TOP',0,0));
      childItem.GET(CreateItem(TEXT_PART1,1,2));
      LibraryKitting.CreateBOMComponentLine(
        asmTopItem,BOMComponent.Type::Item,childItem."No.",1,childItem."Base Unit of Measure",FALSE);
      asm1Item.GET(CreateItem('ASM 1',0,0));
      childItem.GET(CreateItem(TEXT_PART2,10,20));
      LibraryKitting.CreateBOMComponentLine(
        asm1Item,BOMComponent.Type::Item,childItem."No.",2,childItem."Base Unit of Measure",FALSE);
      LibraryKitting.CreateBOMComponentLine(
        asmTopItem,BOMComponent.Type::Item,asm1Item."No.",3,asm1Item."Base Unit of Measure",FALSE);
      prod1Item.GET(CreateItem('PROD 1',0,0));

      LibraryKitting.AddProdBOMItem(prod1Item,CreateItem('PURCH 3',100,200),4);
      LibraryKitting.AddProdBOMItem(prod1Item,TEXT_PART1,5);
      LibraryKitting.CreateBOMComponentLine(
        asmTopItem,BOMComponent.Type::Item,prod1Item."No.",6,prod1Item."Base Unit of Measure",FALSE);

      TestCost('',asmTopItem,0,0,0,0,0,0,0,0);
      TestCost('',asmTopItem,1 * 1 + 3 * 0 + 6 * 0,1,1 + 0 + 0,0,0,1,0,0);
      TestCost('',asmTopItem,1 * 1 + 3 * 2 * 10 + 6 * (4 * 100 + 5 * 1),2,1 + 60 + 2430,0,0,2491,0,0);

      TestPrice('',asmTopItem,0,0);
      TestPrice('',asmTopItem,1 * 2 + 3 * 0 + 6 * 0,1);
      TestPrice('',asmTopItem,1 * 2 + 3 * 2 * 20 + 6 * 0,2); // Prod item price is not rolled up and stays 0

      ASSERTERROR ERROR('') // roll back
Member of Lib.Library - Kitting


CreateAssemblySetup@2 Method

The procedure CreateAssemblySetup is available in codeunit 132205.

Syntax

CreateAssemblySetup@2(
      //param element not supplied
);

Remarks

The relevant search keywords are: Create, Assembly, Setup.

For a clarification about how this function works, refer to the code listed below.

      AssemblySetup.INIT;
      AssemblySetup."Primary Key" := '';
      AssemblySetup."Assembly Order Nos." := CreateNoSeries;
      IF NOT AssemblySetup.INSERT THEN;

Example

There are no examples available.
Member of Lib.Library - Kitting


CreateBOMComponentLine@54 Method

The procedure CreateBOMComponentLine is available in codeunit 132205.

Syntax

CreateBOMComponentLine@54(
    VAR ParentItem@1000 : Record 27 ParentItem, //Reference parameter of type Record
    Type@1001 : Option Type, //Input parameter of type Option
    No@1002 : Code[20] No, //Input parameter of type Code
    Quantity@1003 : Decimal Quantity, //Input parameter of type Decimal
    UOMCode@1004 : Code[10] UOMCode, //Input parameter of type Code
    Fixed@1005 : Boolean Fixed //Input parameter of type Boolean
);

Parameters

ParentItem
Reference parameter of type Record
Type
Input parameter of type Option
No
Input parameter of type Code
Quantity
Input parameter of type Decimal
UOMCode
Input parameter of type Code
Fixed
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, BOM, Component, Line.

For a clarification about how this function works, refer to the code listed below.

      CreateUnitOfMeasure(UOMCode);
      LibraryManufacturing.CreateBOMComponent(BOMComponent,ParentItem."No.",Type,No,Quantity,UOMCode);
      IF (Type = BOMComponent.Type::Resource) AND Fixed THEN BEGIN
        BOMComponent.VALIDATE("Resource Usage Type",BOMComponent."Resource Usage Type"::Fixed);
        BOMComponent.MODIFY(TRUE);
      END;
      ParentItem.VALIDATE("Replenishment System",ParentItem."Replenishment System"::Assembly);
      ParentItem.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137909 to show one way of using this function.

      Initialize;
      ParentItem.GET(LibraryKitting.CreateItemWithLotAndNewUOM(500,700,1));
      resource.GET(LibraryKitting.CreateResourceWithNewUOM(100,0));
      LibraryKitting.CreateBOMComponentLine(
        ParentItem,BOMComp.Type::Resource,resource."No.",1,resource."Base Unit of Measure",FALSE);
      calcThenValidateCost(ParentItem."No.",100,2);
      ASSERTERROR ERROR('') // roll back
Member of Lib.Library - Kitting


CreateInvPostGroup@28 Method

The procedure CreateInvPostGroup is available in codeunit 132205.

Syntax

CreateInvPostGroup@28(
    VAR InventoryPostingGroup@1000 : Record 94 InventoryPostingGroup //Reference parameter of type Record
);

Parameters

InventoryPostingGroup
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Invoice, Post, Group.

For a clarification about how this function works, refer to the code listed below.

      IF InventoryPostingGroup.FINDFIRST THEN
        EXIT;
      InventoryPostingGroup.Code := 'A';
      InventoryPostingGroup.Description := POSTING_GRP_DESC;
      InventoryPostingGroup.INSERT;

Example

There are no examples available.
Member of Lib.Library - Kitting


CreateItem@2001 Method

The procedure CreateItem is available in codeunit 132205.

Syntax

CreateItem@2001(
    Cost@1000 : Decimal Cost, //Input parameter of type Decimal
    Price@1001 : Decimal Price, //Input parameter of type Decimal
    UOM@1002 : Code[10] UOM //Input parameter of type Code
);

Parameters

Cost
Input parameter of type Decimal
Price
Input parameter of type Decimal
UOM
Input parameter of type Code

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Item.

For a clarification about how this function works, refer to the code listed below.

      Item.GET(ItemCreate(noSeriesMgt.GetNextNo(CreateNoSeries,WORKDATE,TRUE),ITEM_DESC,UOM,Price,Cost));
      CreateInvPostGroup(InvtPostingGroup);
      Item.VALIDATE("Inventory Posting Group",InvtPostingGroup.Code);
      Item.MODIFY;
      EXIT(Item."No.");

Example

The below example is extracted from the test automation codeunit 137104 to show one way of using this function.

      // [FEATURE] [Pick] [Warehouse pick request]
      // [SCENARIO 382261] Warehouse pick request created from an assembly order should be deleted when the assembly is posted after partial pick and consumption

      Initialize;

      CreateLocationWithAssemblyBin(Location);
      LibraryWarehouse.CreateBin(Bin,Location.Code,LibraryUtility.GenerateRandomCode(Bin.FIELDNO(Code),DATABASE::Bin),'','');

      LibraryInventory.CreateItem(AsmItem);
      LibraryInventory.CreateItem(ComponentItem);

      Qty := LibraryRandom.RandIntInRange(10,20);
      QtyToHandle := LibraryRandom.RandIntInRange(1,Qty - 1);
      LibraryAssembly.CreateAssemblyListComponent(BOMComponent.Type::Item,ComponentItem."No.",AsmItem."No.",'',0,1,TRUE);
      PostPositiveAdjmtItemJournal(ComponentItem."No.",Qty,Location.Code,Bin.Code);

      // [GIVEN] Assembly order with Quantity = 10
      LibraryAssembly.CreateAssemblyHeader(AssemblyHeader,WorkDate2,AsmItem."No.",Location.Code,Qty,'');
      LibraryAssembly.ReleaseAO(AssemblyHeader);

      // [GIVEN] Create warehouse pick from the assembly
      LibraryAssembly.CreateWhsePick(AssemblyHeader,'',0,FALSE,TRUE,FALSE);
      UpdateWhseActivityQtyToHandle(DATABASE::"Assembly Line",AssemblyHeader."No.",QtyToHandle);

      // [GIVEN] Set "Qty. to Handle" = 5 in the pick line and register the pick
      FindWhseActivity(WarehouseActivityHeader,Location.Code);
      LibraryWarehouse.RegisterWhseActivity(WarehouseActivityHeader);

      // [GIVEN] Delete the pick
      WarehouseActivityHeader.FIND;
      WarehouseActivityHeader.DELETE(TRUE);

      // [GIVEN] Set "Quantity to Consume" = 5 in the assembly line
      FindAssemblyLine(AssemblyLine,AssemblyHeader."Document Type",AssemblyHeader."No.");
      AssemblyLine.VALIDATE("Quantity to Consume",QtyToHandle);
      AssemblyLine.MODIFY(TRUE);

      // [WHEN] Post the assembly order
      LibraryAssembly.PostAssemblyHeader(AssemblyHeader,'');

      // [THEN] Warehouse pick request does not exist
      VerifyWhsePickRequestEmpty(AssemblyHeader."Document Type",AssemblyHeader."No.");
Member of Lib.Library - Kitting


CreateItemNo@3 Method

The procedure CreateItemNo is available in codeunit 132205.

Syntax

CreateItemNo@3(
    Number@1006 : Code[20] Number, //Input parameter of type Code
    Cost@1000 : Decimal Cost, //Input parameter of type Decimal
    Price@1001 : Decimal Price, //Input parameter of type Decimal
    UOM@1002 : Code[10] UOM //Input parameter of type Code
);

Parameters

Number
Input parameter of type Code
Cost
Input parameter of type Decimal
Price
Input parameter of type Decimal
UOM
Input parameter of type Code

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Item, No.

For a clarification about how this function works, refer to the code listed below.

      IF Number = '' THEN
        Number := noSeriesMgt.GetNextNo(CreateNoSeries,WORKDATE,TRUE);
      Item.GET(ItemCreate(Number,ITEM_DESC,UOM,Price,Cost));
      CreateInvPostGroup(InvtPostingGroup);
      Item.VALIDATE("Inventory Posting Group",InvtPostingGroup.Code);
      Item.MODIFY;
      EXIT(Item."No.");

Example

There are no examples available.
Member of Lib.Library - Kitting


CreateItemwithLot@17 Method

The procedure CreateItemwithLot is available in codeunit 132205.

Syntax

CreateItemwithLot@17(
    Cost@1000 : Decimal Cost, //Input parameter of type Decimal
    Price@1001 : Decimal Price, //Input parameter of type Decimal
    UOM@1002 : Code[10] UOM, //Input parameter of type Code
    Lot@1006 : Decimal Lot //Input parameter of type Decimal
);

Parameters

Cost
Input parameter of type Decimal
Price
Input parameter of type Decimal
UOM
Input parameter of type Code
Lot
Input parameter of type Decimal

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Itemwith, Lot.

For a clarification about how this function works, refer to the code listed below.

      Item.GET(ItemCreate(noSeriesMgt.GetNextNo(CreateNoSeries,WORKDATE,TRUE),ITEM_DESC,UOM,Price,Cost));
      Item."Lot Size" := Lot;
      CreateInvPostGroup(InvtPostingGroup);
      Item.VALIDATE("Inventory Posting Group",InvtPostingGroup.Code);
      Item.MODIFY;
      EXIT(Item."No.");

Example

There are no examples available.
Member of Lib.Library - Kitting


CreateItemWithLotAndNewUOM@111 Method

The procedure CreateItemWithLotAndNewUOM is available in codeunit 132205.

Syntax

CreateItemWithLotAndNewUOM@111(
    Cost@1000 : Decimal Cost, //Input parameter of type Decimal
    Price@1001 : Decimal Price, //Input parameter of type Decimal
    LotSize@1006 : Decimal LotSize //Input parameter of type Decimal
);

Parameters

Cost
Input parameter of type Decimal
Price
Input parameter of type Decimal
LotSize
Input parameter of type Decimal

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Item, Lot, New, UOM.

For a clarification about how this function works, refer to the code listed below.

      LibraryInventory.CreateUnitOfMeasureCode(UOM);
      EXIT(CreateItemwithLot(Cost,Price,UOM.Code,LotSize));

Example

The below example is extracted from the test automation codeunit 137906 to show one way of using this function.

      Initialize;
      ParentItemNo := LibraryKitting.CreateItemWithLotAndNewUOM(500,700,1);

      LibraryAssembly.CreateAssemblyHeader(AssemblyHeader,WorkDate2,ParentItemNo,'',1,'');
      AssemblyHeader.VALIDATE("Location Code",'');
      AssemblyHeader.VALIDATE("Due Date",WorkDate2);
      AssemblyHeader.VALIDATE("Item No.");

      ASSERTERROR ERROR('') // roll back
Member of Lib.Library - Kitting


CreateItemWithLotAndNewUOMUsingItemNo@5 Method

The procedure CreateItemWithLotAndNewUOMUsingItemNo is available in codeunit 132205.

Syntax

CreateItemWithLotAndNewUOMUsingItemNo@5(
    ItemNo@1007 : Code[20] ItemNo, //Input parameter of type Code
    Cost@1000 : Decimal Cost, //Input parameter of type Decimal
    Price@1001 : Decimal Price, //Input parameter of type Decimal
    LotSize@1006 : Decimal LotSize //Input parameter of type Decimal
);

Parameters

ItemNo
Input parameter of type Code
Cost
Input parameter of type Decimal
Price
Input parameter of type Decimal
LotSize
Input parameter of type Decimal

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Item, Lot, New, UOM, Using, Item, No.

For a clarification about how this function works, refer to the code listed below.

      LibraryInventory.CreateUnitOfMeasureCode(UOM);
      EXIT(CreateItemwithLotNo(ItemNo,Cost,Price,UOM.Code,LotSize));

Example

The below example is extracted from the test automation codeunit 137906 to show one way of using this function.

      Initialize;
      LibraryKitting.SetLookahead('<1Y>');
      QTYParent := 2;
      QTYChild := 1;
      parentItem.GET(LibraryKitting.CreateItemWithLotAndNewUOMUsingItemNo('Parent',500,700,1));
      childItem.GET(LibraryKitting.CreateItemWithNewUOMUsingItemNo('Child1',500,700));
      childItem2.GET(LibraryKitting.CreateItemWithNewUOMUsingItemNo('Child2',500,700));

      LibraryManufacturing.CreateBOMComponent(
        BOMComp,parentItem."No.",BOMComp.Type::Item,childItem."No.",QTYChild,childItem."Base Unit of Measure");
      LibraryManufacturing.CreateBOMComponent(
        BOMComp,parentItem."No.",BOMComp.Type::Item,childItem2."No.",QTYChild,childItem2."Base Unit of Measure");

      AssemblyHeader.GET(AssemblyHeader."Document Type"::Order,
        LibraryKitting.CreateOrderNo(010210D,'testAvailField',parentItem."No.",QTYParent));
      AssemblyHeader.VALIDATE("Due Date",010210D);

      MockItemLedgerEntry(childItem."No.",2,AssemblyHeader."Location Code",010108D);
      MockItemLedgerEntry(childItem2."No.",1,AssemblyHeader."Location Code",010108D);

      ExpectedDate := 0D; // Anydate with a year of due date of line=due date of header
      MockPurchaseOrder(childItem."No.",1,AssemblyHeader."Location Code",010110D); // any date before due date

      ValidateQtyAvailableToMake(AssemblyHeader,1);
      ValidateEarliestDate(AssemblyHeader,ExpectedDate);
      ValidateOrderRatio(AssemblyHeader,1);
      ASSERTERROR ERROR('') // roll back
Member of Lib.Library - Kitting


CreateItemwithLotNo@8 Method

The procedure CreateItemwithLotNo is available in codeunit 132205.

Syntax

CreateItemwithLotNo@8(
    Number@1007 : Code[20] Number, //Input parameter of type Code
    Cost@1000 : Decimal Cost, //Input parameter of type Decimal
    Price@1001 : Decimal Price, //Input parameter of type Decimal
    UOM@1002 : Code[10] UOM, //Input parameter of type Code
    Lot@1006 : Decimal Lot //Input parameter of type Decimal
);

Parameters

Number
Input parameter of type Code
Cost
Input parameter of type Decimal
Price
Input parameter of type Decimal
UOM
Input parameter of type Code
Lot
Input parameter of type Decimal

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Itemwith, Lot, No.

For a clarification about how this function works, refer to the code listed below.

      IF Number = '' THEN
        Number := noSeriesMgt.GetNextNo(CreateNoSeries,WORKDATE,TRUE);
      Item.GET(ItemCreate(Number,ITEM_DESC,UOM,Price,Cost));
      Item."Lot Size" := Lot;
      CreateInvPostGroup(InventoryPostingGroup);
      Item.VALIDATE("Inventory Posting Group",InventoryPostingGroup.Code);
      Item.MODIFY;
      EXIT(Item."No.");

Example

There are no examples available.
Member of Lib.Library - Kitting


CreateItemWithNewUOM@110 Method

The procedure CreateItemWithNewUOM is available in codeunit 132205.

Syntax

CreateItemWithNewUOM@110(
    Cost@1000 : Decimal Cost, //Input parameter of type Decimal
    Price@1001 : Decimal Price //Input parameter of type Decimal
);

Parameters

Cost
Input parameter of type Decimal
Price
Input parameter of type Decimal

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Item, New, UOM.

For a clarification about how this function works, refer to the code listed below.

      LibraryInventory.CreateUnitOfMeasureCode(UOM);
      EXIT(CreateItem(Cost,Price,UOM.Code));

Example

The below example is extracted from the test automation codeunit 137906 to show one way of using this function.

      Initialize;
      ChildItem.GET(LibraryKitting.CreateItemWithNewUOM(500,700));
      MockItemLedgerEntry(ChildItem."No.",10,LibraryWarehouse.CreateLocation(Location),010110D);
      ChildItem.CALCFIELDS(Inventory);
      Assert.AreEqual(10,ChildItem.Inventory,'Wrong Inventory');

      ASSERTERROR ERROR('') // roll back
Member of Lib.Library - Kitting


CreateItemWithNewUOMUsingItemNo@16 Method

The procedure CreateItemWithNewUOMUsingItemNo is available in codeunit 132205.

Syntax

CreateItemWithNewUOMUsingItemNo@16(
    ItemNo@1006 : Code[20] ItemNo, //Input parameter of type Code
    Cost@1000 : Decimal Cost, //Input parameter of type Decimal
    Price@1001 : Decimal Price //Input parameter of type Decimal
);

Parameters

ItemNo
Input parameter of type Code
Cost
Input parameter of type Decimal
Price
Input parameter of type Decimal

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Item, New, UOM, Using, Item, No.

For a clarification about how this function works, refer to the code listed below.

      LibraryInventory.CreateUnitOfMeasureCode(UOM);
      EXIT(CreateItemNo(ItemNo,Cost,Price,UOM.Code));

Example

The below example is extracted from the test automation codeunit 137906 to show one way of using this function.

      Initialize;
      LibraryKitting.SetLookahead('<1Y>');
      QTYParent := 2;
      QTYChild := 1;
      parentItem.GET(LibraryKitting.CreateItemWithLotAndNewUOMUsingItemNo('Parent',500,700,1));
      childItem.GET(LibraryKitting.CreateItemWithNewUOMUsingItemNo('Child1',500,700));
      childItem2.GET(LibraryKitting.CreateItemWithNewUOMUsingItemNo('Child2',500,700));

      LibraryManufacturing.CreateBOMComponent(
        BOMComp,parentItem."No.",BOMComp.Type::Item,childItem."No.",QTYChild,childItem."Base Unit of Measure");
      LibraryManufacturing.CreateBOMComponent(
        BOMComp,parentItem."No.",BOMComp.Type::Item,childItem2."No.",QTYChild,childItem2."Base Unit of Measure");

      AssemblyHeader.GET(AssemblyHeader."Document Type"::Order,
        LibraryKitting.CreateOrderNo(010210D,'testAvailField',parentItem."No.",QTYParent));
      AssemblyHeader.VALIDATE("Due Date",010210D);

      MockItemLedgerEntry(childItem."No.",2,AssemblyHeader."Location Code",010108D);
      MockItemLedgerEntry(childItem2."No.",1,AssemblyHeader."Location Code",010108D);

      ExpectedDate := 0D; // Anydate with a year of due date of line=due date of header
      MockPurchaseOrder(childItem."No.",1,AssemblyHeader."Location Code",010110D); // any date before due date

      ValidateQtyAvailableToMake(AssemblyHeader,1);
      ValidateEarliestDate(AssemblyHeader,ExpectedDate);
      ValidateOrderRatio(AssemblyHeader,1);
      ASSERTERROR ERROR('') // roll back
Member of Lib.Library - Kitting


CreateItemwithStandard@18 Method

The procedure CreateItemwithStandard is available in codeunit 132205.

Syntax

CreateItemwithStandard@18(
    Cost@1000 : Decimal Cost, //Input parameter of type Decimal
    Price@1001 : Decimal Price, //Input parameter of type Decimal
    UOM@1002 : Code[10] UOM, //Input parameter of type Code
    Lot@1006 : Decimal Lot //Input parameter of type Decimal
);

Parameters

Cost
Input parameter of type Decimal
Price
Input parameter of type Decimal
UOM
Input parameter of type Code
Lot
Input parameter of type Decimal

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Itemwith, Standard.

For a clarification about how this function works, refer to the code listed below.

      Item.GET(ItemCreate(noSeriesMgt.GetNextNo(CreateNoSeries,WORKDATE,TRUE),ITEM_DESC,UOM,Price,Cost));
      Item."Lot Size" := Lot;
      CreateInvPostGroup(InvtPostingGroup);
      Item.VALIDATE("Inventory Posting Group",InvtPostingGroup.Code);
      Item.VALIDATE("Costing Method",Item."Costing Method"::Standard);
      Item.MODIFY;
      EXIT(Item."No.");

Example

There are no examples available.
Member of Lib.Library - Kitting


CreateItemwithStandardNo@7 Method

The procedure CreateItemwithStandardNo is available in codeunit 132205.

Syntax

CreateItemwithStandardNo@7(
    Number@1007 : Code[20] Number, //Input parameter of type Code
    Cost@1000 : Decimal Cost, //Input parameter of type Decimal
    Price@1001 : Decimal Price, //Input parameter of type Decimal
    UOM@1002 : Code[10] UOM, //Input parameter of type Code
    Lot@1006 : Decimal Lot //Input parameter of type Decimal
);

Parameters

Number
Input parameter of type Code
Cost
Input parameter of type Decimal
Price
Input parameter of type Decimal
UOM
Input parameter of type Code
Lot
Input parameter of type Decimal

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Itemwith, Standard, No.

For a clarification about how this function works, refer to the code listed below.

      IF Number = '' THEN
        Number := noSeriesMgt.GetNextNo(CreateNoSeries,WORKDATE,TRUE);
      Item.GET(ItemCreate(Number,ITEM_DESC,UOM,Price,Cost));
      Item."Lot Size" := Lot;
      CreateInvPostGroup(InvtPostingGroup);
      Item.VALIDATE("Inventory Posting Group",InvtPostingGroup.Code);
      Item.VALIDATE("Costing Method",Item."Costing Method"::Standard);
      Item.MODIFY;
      EXIT(Item."No.");

Example

There are no examples available.
Member of Lib.Library - Kitting


CreateNoSeries@1 Method

The procedure CreateNoSeries is available in codeunit 132205.

Syntax

CreateNoSeries@1(
      //param element not supplied
);

Return Value

Code[10]

Remarks

The relevant search keywords are: Create, No, Series.

For a clarification about how this function works, refer to the code listed below.

      NoSeries.INIT;
      NoSeries.Code := COPYSTR(CREATEGUID,1,10);    // todo: use the last instead of the first charackters
      NoSeries."Default Nos." := TRUE;
      NoSeries."Manual Nos." := TRUE;
      IF NOT NoSeries.INSERT THEN;

      noSeriesLine.INIT;
      noSeriesLine."Series Code" := NoSeries.Code;
      noSeriesLine."Starting No." := NoSeries.Code + '0000000001';
      noSeriesLine."Increment-by No." := 1;
      IF NOT noSeriesLine.INSERT THEN;

      EXIT(NoSeries.Code);

Example

There are no examples available.
Member of Lib.Library - Kitting


CreateOrder@12 Method

The procedure CreateOrder is available in codeunit 132205.

Syntax

CreateOrder@12(
    DueDate@1004 : Date DueDate, //Input parameter of type Date
    ItemNo@1000 : Code[20] ItemNo, //Input parameter of type Code
    Quantity@1001 : Decimal Quantity //Input parameter of type Decimal
);

Parameters

DueDate
Input parameter of type Date
ItemNo
Input parameter of type Code
Quantity
Input parameter of type Decimal

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Order.

For a clarification about how this function works, refer to the code listed below.

      CreateAssemblySetup;
      LibraryAssembly.CreateAssemblyHeader(AssemblyHeader,DueDate,ItemNo,'',Quantity,'');
      EXIT(AssemblyHeader."No.");

Example

The below example is extracted from the test automation codeunit 137906 to show one way of using this function.

      Initialize;
      parentItem.GET(LibraryKitting.CreateItemWithLotAndNewUOM(500,700,1));
      AssemblyHeader.GET(AssemblyHeader."Document Type"::Order,LibraryKitting.CreateOrder(WorkDate2,parentItem."No.",1));
      childItem.GET(LibraryKitting.CreateItemWithNewUOM(500,700));
      LibraryManufacturing.CreateBOMComponent(
        BOMComp,parentItem."No.",BOMComp.Type::Item,childItem."No.",1,childItem."Base Unit of Measure");

      AssemblyHeader.RefreshBOM;
      AssemblyLine.SETRANGE("Document Type",AssemblyLine."Document Type"::Order);
      AssemblyLine.SETRANGE("Document No.",AssemblyHeader."No.");
      AssemblyLine.FINDFIRST;
      ValidateremainingQty(AssemblyLine,1);
      ValidateremainingQtyBase(AssemblyLine,1);
      ASSERTERROR ERROR('') // roll back
Member of Lib.Library - Kitting


CreateOrderNo@4 Method

The procedure CreateOrderNo is available in codeunit 132205.

Syntax

CreateOrderNo@4(
    DueDate@1003 : Date DueDate, //Input parameter of type Date
    Number@1004 : Code[20] Number, //Input parameter of type Code
    Item@1000 : Code[20] Item, //Input parameter of type Code
    Quantity@1001 : Decimal Quantity //Input parameter of type Decimal
);

Parameters

DueDate
Input parameter of type Date
Number
Input parameter of type Code
Item
Input parameter of type Code
Quantity
Input parameter of type Decimal

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Order, No.

For a clarification about how this function works, refer to the code listed below.

      CreateAssemblySetup;
      CLEAR(AssemblyHeader);
      AssemblyHeader."Document Type" := AssemblyHeader."Document Type"::Order;
      AssemblyHeader."No." := Number;
      AssemblyHeader.INSERT(TRUE);
      AssemblyHeader.VALIDATE("Due Date",DueDate);
      AssemblyHeader.VALIDATE("Item No.",Item);
      AssemblyHeader.VALIDATE(Quantity,Quantity);
      AssemblyHeader.MODIFY(TRUE);
      EXIT(AssemblyHeader."No.");

Example

The below example is extracted from the test automation codeunit 137906 to show one way of using this function.

      Initialize;
      LibraryKitting.SetLookahead('<1Y>');
      QTYParent := 2;
      QTYChild := 1;
      parentItem.GET(LibraryKitting.CreateItemWithLotAndNewUOMUsingItemNo('Parent',500,700,1));
      childItem.GET(LibraryKitting.CreateItemWithNewUOMUsingItemNo('Child1',500,700));
      childItem2.GET(LibraryKitting.CreateItemWithNewUOMUsingItemNo('Child2',500,700));

      LibraryManufacturing.CreateBOMComponent(
        BOMComp,parentItem."No.",BOMComp.Type::Item,childItem."No.",QTYChild,childItem."Base Unit of Measure");
      LibraryManufacturing.CreateBOMComponent(
        BOMComp,parentItem."No.",BOMComp.Type::Item,childItem2."No.",QTYChild,childItem2."Base Unit of Measure");

      AssemblyHeader.GET(AssemblyHeader."Document Type"::Order,
        LibraryKitting.CreateOrderNo(010210D,'testAvailField',parentItem."No.",QTYParent));
      AssemblyHeader.VALIDATE("Due Date",010210D);

      MockItemLedgerEntry(childItem."No.",2,AssemblyHeader."Location Code",010108D);
      MockItemLedgerEntry(childItem2."No.",1,AssemblyHeader."Location Code",010108D);

      ExpectedDate := 0D; // Anydate with a year of due date of line=due date of header
      MockPurchaseOrder(childItem."No.",1,AssemblyHeader."Location Code",010110D); // any date before due date

      ValidateQtyAvailableToMake(AssemblyHeader,1);
      ValidateEarliestDate(AssemblyHeader,ExpectedDate);
      ValidateOrderRatio(AssemblyHeader,1);
      ASSERTERROR ERROR('') // roll back
Member of Lib.Library - Kitting


CreateResource@6 Method

The procedure CreateResource is available in codeunit 132205.

Syntax

CreateResource@6(
    Cost@1004 : Decimal Cost, //Input parameter of type Decimal
    Price@1003 : Decimal Price, //Input parameter of type Decimal
    UOM@1002 : Code[10] UOM //Input parameter of type Code
);

Parameters

Cost
Input parameter of type Decimal
Price
Input parameter of type Decimal
UOM
Input parameter of type Code

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Resource.

For a clarification about how this function works, refer to the code listed below.

      CreateUnitOfMeasure(UOM);
      ResourceMake(Resource,LibraryUtility.GenerateGUID);
      Resource.VALIDATE("Unit Cost",Cost);
      Resource.VALIDATE("Unit Price",Price);
      LibraryResource.CreateResourceUnitOfMeasure(ResourceUnitOfMeasure,Resource."No.",UOM,1);
      ResourceUnitOfMeasure.VALIDATE("Related to Base Unit of Meas.",TRUE);
      ResourceUnitOfMeasure.MODIFY(TRUE);
      Resource.VALIDATE("Base Unit of Measure",UOM);
      CreateResourceInvPostGroup(GenProductPostingGroup);
      Resource.VALIDATE("Gen. Prod. Posting Group",GenProductPostingGroup.Code);
      Resource.MODIFY;
      EXIT(Resource."No.");

Example

The below example is extracted from the test automation codeunit 137907 to show one way of using this function.

      // [FEATURE] [Assembly BOM]
      // [SCENARIO 381865] Field "Description 2" should not be populated in assembly line with Type = "Resource". For a line with Type = "Item", it should be copied from the component item.
      Initialize;

      // [GIVEN] Parent Assembly Item PAI with populated Description 2.
      LibraryInventory.CreateItem(ParentItem);
      WITH ParentItem DO BEGIN
        VALIDATE("Replenishment System","Replenishment System"::Assembly);
        VALIDATE("Description 2",LibraryUtility.GenerateRandomCode(FIELDNO("Description 2"),DATABASE::Item));
        MODIFY(TRUE);
      END;

      // [GIVEN] Child Item CI with populated Description 2 as a BOM Component of type Item for PAI.
      LibraryInventory.CreateItem(ChildItem);
      WITH ChildItem DO BEGIN
        VALIDATE("Description 2",LibraryUtility.GenerateRandomCode(FIELDNO("Description 2"),DATABASE::Item));
        MODIFY(TRUE);
      END;
      LibraryManufacturing.CreateBOMComponent(
        BOMComponent,ParentItem."No.",BOMComponent.Type::Item,ChildItem."No.",1,'');

      // [GIVEN] A BOM Component of type Resource for PAI.
      LibraryManufacturing.CreateBOMComponent(
        BOMComponent,ParentItem."No.",BOMComponent.Type::Resource,LibraryAssembly.CreateResource(Resource,TRUE,''),1,'');

      // [WHEN] Create Assembly Header for PAI and populate Quantity
      LibraryAssembly.CreateAssemblyHeader(AssemblyHeader,WORKDATE,ParentItem."No.",'',LibraryRandom.RandInt(10),'');

      WITH AssemblyLine DO BEGIN
        SETRANGE("Document Type",AssemblyHeader."Document Type");
        SETRANGE("Document No.",AssemblyHeader."No.");
        SETRANGE(Type,Type::Resource);
        FINDFIRST;

        // [THEN] the field "Description 2" of related Assembly Line of Type Resource is blank.
        Assert.AreEqual('',"Description 2",Description2AssemblyLineResourceNotBlankErr);

        SETRANGE(Type,Type::Item);
        FINDFIRST;

        // [THEN] the field "Description 2" of related Assembly Line of Type Item is equal to CI."Description 2".
        Assert.AreEqual(ChildItem."Description 2","Description 2",Description2AssemblyLineItemDoesntMatchErr);
      END;
Member of Lib.Library - Kitting


CreateResourceInvPostGroup@29 Method

The procedure CreateResourceInvPostGroup is available in codeunit 132205.

Syntax

CreateResourceInvPostGroup@29(
    VAR GenProductPostingGroup@1000 : Record 251 GenProductPostingGroup //Reference parameter of type Record
);

Parameters

GenProductPostingGroup
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Resource, Invoice, Post, Group.

For a clarification about how this function works, refer to the code listed below.

      IF GenProductPostingGroup.FINDFIRST THEN
        EXIT;
      GenProductPostingGroup.Code := 'A';
      GenProductPostingGroup.Description := POSTING_GRP_DESC;
      GenProductPostingGroup.INSERT;

Example

There are no examples available.
Member of Lib.Library - Kitting


CreateResourceWithNewUOM@114 Method

The procedure CreateResourceWithNewUOM is available in codeunit 132205.

Syntax

CreateResourceWithNewUOM@114(
    Cost@1004 : Decimal Cost, //Input parameter of type Decimal
    Price@1003 : Decimal Price //Input parameter of type Decimal
);

Parameters

Cost
Input parameter of type Decimal
Price
Input parameter of type Decimal

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Resource, New, UOM.

For a clarification about how this function works, refer to the code listed below.

      LibraryInventory.CreateUnitOfMeasureCode(UOM);
      EXIT(CreateResource(Cost,Price,UOM.Code));

Example

The below example is extracted from the test automation codeunit 137907 to show one way of using this function.

      // SETUP
      // Make the BOM tree
      Initialize;
      LibraryInventory.CreateItem(ChildChildItem);

      // Create child assembly item
      LibraryInventory.CreateItem(ChildItem);
      ChildItem."Replenishment System" := ChildItem."Replenishment System"::Assembly;
      ChildItem.MODIFY;
      LibraryManufacturing.CreateBOMComponent(BOMComponent,ChildItem."No.",BOMComponent.Type::" ",'',1,'');
      ChildItemDesc1 := LibraryUtility.GenerateRandomCode(BOMComponent.FIELDNO(Description),DATABASE::"BOM Component");
      BOMComponent.VALIDATE(Description,ChildItemDesc1);
      BOMComponent.MODIFY;
      LibraryManufacturing.CreateBOMComponent(BOMComponent,ChildItem."No.",BOMComponent.Type::Item,ChildChildItem."No.",1,'');
      ResourceNo := LibraryKitting.CreateResourceWithNewUOM(1,1); // Any resource price/cost
      LibraryManufacturing.CreateBOMComponent(BOMComponent,ChildItem."No.",BOMComponent.Type::Resource,ResourceNo,1,'');
      LibraryManufacturing.CreateBOMComponent(BOMComponent,ChildItem."No.",BOMComponent.Type::" ",'',1,'');
      ChildItemDesc2 := LibraryUtility.GenerateRandomCode(BOMComponent.FIELDNO(Description),DATABASE::"BOM Component");
      BOMComponent.VALIDATE(Description,ChildItemDesc2);
      BOMComponent.MODIFY;

      // Create parent assembly item
      LibraryInventory.CreateItem(ParentItem);
      ParentItem."Replenishment System" := ParentItem."Replenishment System"::Assembly;
      ParentItem.MODIFY;
      LibraryManufacturing.CreateBOMComponent(BOMComponent,ParentItem."No.",BOMComponent.Type::" ",'',1,'');
      ParentItemDesc1 := LibraryUtility.GenerateRandomCode(BOMComponent.FIELDNO(Description),DATABASE::"BOM Component");
      BOMComponent.VALIDATE(Description,ParentItemDesc1);
      BOMComponent.MODIFY;
      LibraryManufacturing.CreateBOMComponent(BOMComponent,ParentItem."No.",BOMComponent.Type::Item,ChildItem."No.",1,'');
      LibraryManufacturing.CreateBOMComponent(BOMComponent,ParentItem."No.",BOMComponent.Type::" ",'',1,'');
      ParentItemDesc2 := LibraryUtility.GenerateRandomCode(BOMComponent.FIELDNO(Description),DATABASE::"BOM Component");
      BOMComponent.VALIDATE(Description,ParentItemDesc2);
      BOMComponent.MODIFY;

      // Make Asm header and lines
      LibraryAssembly.CreateAssemblyHeader(AsmHeader,DueDate,ParentItem."No.",'',LibraryRandom.RandInt(10),'');

      // EXERCISE
      // Call the explode BOM function
      IF ExplodeBOMFromPage THEN BEGIN
        AsmOrderTestPage.OPENEDIT;
        AsmOrderTestPage.FILTER.SETFILTER("Document Type",FORMAT(AsmHeader."Document Type"::Order));
        AsmOrderTestPage.FILTER.SETFILTER("No.",AsmHeader."No.");
        AsmOrderTestPage.Lines.FILTER.SETFILTER(Type,FORMAT(AsmLine.Type::Item));
        AsmOrderTestPage.Lines.FILTER.SETFILTER("No.",ChildItem."No.");
        AsmOrderTestPage.FIRST;
        AsmOrderTestPage.Lines.ExplodeBOM.INVOKE
      END ELSE BEGIN
        AsmLine.SETRANGE("Document Type",AsmHeader."Document Type");
        AsmLine.SETRANGE("Document No.",AsmHeader."No.");
        AsmLine.SETRANGE(Type,AsmLine.Type::Item);
        AsmLine.SETRANGE("No.",ChildItem."No.");
        AsmLine.FINDSET;
        AsmLineMgt.ExplodeAsmList(AsmLine);
      END;

      // VERIFY
      AsmLine.RESET;
      FindAssemblyLine(AsmLine,AsmHeader);
      LineCount := 0;
      ExpectedNoLines := 7;
      REPEAT
        LineCount += 1;
        CASE LineCount OF
          1: // line 1
            BEGIN
              AsmLine.TESTFIELD(Type,AsmLine.Type::" ");
              AsmLine.TESTFIELD("No.",'');
              AsmLine.TESTFIELD(Description,ParentItemDesc1);
            END;
          2: // line 2
            BEGIN
              AsmLine.TESTFIELD(Type,AsmLine.Type::" ");
              AsmLine.TESTFIELD("No.",ChildItem."No.");
            END;
          3: // line 3
            BEGIN
              AsmLine.TESTFIELD(Type,AsmLine.Type::" ");
              AsmLine.TESTFIELD("No.",'');
              AsmLine.TESTFIELD(Description,ChildItemDesc1);
            END;
          4: // line 4
            BEGIN
              AsmLine.TESTFIELD(Type,AsmLine.Type::Item);
              AsmLine.TESTFIELD("No.",ChildChildItem."No.");
              AsmLine.TESTFIELD("Avail. Warning",TRUE); // Availability warning after explosion
            END;
          5: // line 5 - VSTF333535
            BEGIN
              AsmLine.TESTFIELD(Type,AsmLine.Type::Resource);
              AsmLine.TESTFIELD("No.",ResourceNo);
            END;
          6: // line 6
            BEGIN
              AsmLine.TESTFIELD(Type,AsmLine.Type::" ");
              AsmLine.TESTFIELD("No.",'');
              AsmLine.TESTFIELD(Description,ChildItemDesc2);
            END;
          7: // line 7
            BEGIN
              AsmLine.TESTFIELD(Type,AsmLine.Type::" ");
              AsmLine.TESTFIELD("No.",'');
              AsmLine.TESTFIELD(Description,ParentItemDesc2);
            END;
        END;
      UNTIL AsmLine.NEXT = 0;

      Assert.AreEqual(
        ExpectedNoLines,
        LineCount,
        STRSUBSTNO(MSGAssertLineCount,AsmHeader."No.",ExpectedNoLines,LineCount));
Member of Lib.Library - Kitting


CreateStdCostItemWithNewUOM@112 Method

The procedure CreateStdCostItemWithNewUOM is available in codeunit 132205.

Syntax

CreateStdCostItemWithNewUOM@112(
    Cost@1000 : Decimal Cost, //Input parameter of type Decimal
    Price@1001 : Decimal Price, //Input parameter of type Decimal
    LotSize@1006 : Decimal LotSize //Input parameter of type Decimal
);

Parameters

Cost
Input parameter of type Decimal
Price
Input parameter of type Decimal
LotSize
Input parameter of type Decimal

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Std, Cost, Item, New, UOM.

For a clarification about how this function works, refer to the code listed below.

      LibraryInventory.CreateUnitOfMeasureCode(UOM);
      EXIT(CreateItemwithStandard(Cost,Price,UOM.Code,LotSize));

Example

The below example is extracted from the test automation codeunit 137908 to show one way of using this function.

      Initialize;
      parent := LibraryKitting.CreateStdCostItemWithNewUOM(500,700,1);
      Costprice := 500;
      childItem.GET(LibraryKitting.CreateItemWithNewUOM(Costprice,700));
      LibraryManufacturing.CreateBOMComponent(
        BOMComp,parent,BOMComp.Type::Item,childItem."No.",1,childItem."Base Unit of Measure");
      AssemblyHeader.GET(AssemblyHeader."Document Type"::Order,LibraryKitting.CreateOrder(WorkDate2,parent,1));
      validateCount(AssemblyHeader."No.",1);
      AsmLineFindFirst(AssemblyHeader,AssemblyLine);
      ValidateLineUnitCost(AssemblyLine,Costprice);

      ASSERTERROR AssemblyLine.VALIDATE("Unit Cost",100);
Member of Lib.Library - Kitting


CreateStdCostItemWithNewUOMUsingItemNo@113 Method

The procedure CreateStdCostItemWithNewUOMUsingItemNo is available in codeunit 132205.

Syntax

CreateStdCostItemWithNewUOMUsingItemNo@113(
    ItemNo@1007 : Code[20] ItemNo, //Input parameter of type Code
    Cost@1000 : Decimal Cost, //Input parameter of type Decimal
    Price@1001 : Decimal Price, //Input parameter of type Decimal
    LotSize@1006 : Decimal LotSize //Input parameter of type Decimal
);

Parameters

ItemNo
Input parameter of type Code
Cost
Input parameter of type Decimal
Price
Input parameter of type Decimal
LotSize
Input parameter of type Decimal

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Std, Cost, Item, New, UOM, Using, Item, No.

For a clarification about how this function works, refer to the code listed below.

      LibraryInventory.CreateUnitOfMeasureCode(UOM);
      EXIT(CreateItemwithStandardNo(ItemNo,Cost,Price,UOM.Code,LotSize));

Example

The below example is extracted from the test automation codeunit 137911 to show one way of using this function.

      Initialize;
      // Kitting - D2: Cost amount is not updated when using SKU unit cost
      Variant := '1';
      VArCost := 20;
      ParentItem.GET(LibraryKitting.CreateStdCostItemWithNewUOMUsingItemNo(TEXT_PARENT,10,20,1));
      ChildItem.GET(LibraryKitting.CreateStdCostItemWithNewUOMUsingItemNo(TEXT_CHILD,10,20,1));
      LibraryManufacturing.CreateBOMComponent(
        BomComponent,ParentItem."No.",BomComponent.Type::Item,ChildItem."No.",1,ChildItem."Base Unit of Measure");
      ParentItem.VALIDATE("Replenishment System",ParentItem."Replenishment System"::Assembly);
      ParentItem.MODIFY;
      CalculateAssemblyStandardCost(ParentItem."No.");
      ValidateUnitCost(ParentItem."No.",10);

      CalculateAssemblyStandardCost(ParentItem."No.");

      AsmHeader.GET(AsmHeader."Document Type"::Order,LibraryKitting.CreateOrder(WorkDate2,ParentItem."No.",1));

      ItemVariant.INIT;
      ItemVariant."Item No." := ParentItem."No.";
      ItemVariant.Code := Variant;
      IF NOT ItemVariant.INSERT THEN
        ItemVariant.MODIFY;

      StockkeepingUnit.INIT;
      StockkeepingUnit."Item No." := ParentItem."No.";
      StockkeepingUnit."Variant Code" := Variant;
      StockkeepingUnit."Location Code" := AsmHeader."Location Code";
      StockkeepingUnit."Standard Cost" := VArCost;
      StockkeepingUnit."Unit Cost" := VArCost;
      IF NOT StockkeepingUnit.INSERT THEN
        StockkeepingUnit.MODIFY;

      AsmHeader.VALIDATE("Variant Code",Variant);

      ValidateHeaderCostAmount(AsmHeader,20);

      ASSERTERROR ERROR('') // cleanup
Member of Lib.Library - Kitting


ItemCreate@14 Method

The procedure ItemCreate is available in codeunit 132205.

Syntax

ItemCreate@14(
    ItemName@1001 : Code[20] ItemName, //Input parameter of type Code
    Description@1002 : Text[30] Description, //Input parameter of type Text
    BaseUOM@1003 : Code[10] BaseUOM, //Input parameter of type Code
    UnitPrice@1004 : Decimal UnitPrice, //Input parameter of type Decimal
    StdCost@1005 : Decimal StdCost //Input parameter of type Decimal
);

Parameters

ItemName
Input parameter of type Code
Description
Input parameter of type Text
BaseUOM
Input parameter of type Code
UnitPrice
Input parameter of type Decimal
StdCost
Input parameter of type Decimal

Return Value

Code[20]

Remarks

The relevant search keywords are: Item, Create.

For a clarification about how this function works, refer to the code listed below.

      ItemMake(Item,ItemName);
      Item.VALIDATE(Description,Description);
      ItemUOM.GET(Item."No.",Item."Base Unit of Measure");
      Item.VALIDATE("Base Unit of Measure",'');
      Item.MODIFY(TRUE);
      ItemUOM.DELETE(TRUE);
      LibraryInventory.CreateItemUnitOfMeasure(ItemUOM,Item."No.",BaseUOM,1);
      Item.VALIDATE("Base Unit of Measure",BaseUOM);
      Item.VALIDATE("Unit Price",UnitPrice);
      Item.VALIDATE("Standard Cost",StdCost);
      Item.VALIDATE("Costing Method",Item."Costing Method"::Standard);
      Item.VALIDATE("Unit Cost",StdCost);
      Item.VALIDATE("Single-Level Material Cost",StdCost);
      Item.VALIDATE("Rolled-up Material Cost",StdCost);
      Item.MODIFY(TRUE);
      EXIT(Item."No.");

Example

The below example is extracted from the test automation codeunit 137910 to show one way of using this function.

      LibraryInventory.CreateUnitOfMeasureCode(UOM);
      EXIT(LibraryKitting.ItemCreate(No,ITEM_DESC,UOM.Code,Price,Cost))
Member of Lib.Library - Kitting


ItemMake@19 Method

The procedure ItemMake is available in codeunit 132205.

Syntax

ItemMake@19(
    VAR Item@1002 : Record 27 Item, //Reference parameter of type Record
    ItemName@1000 : Code[20] ItemName //Input parameter of type Code
);

Parameters

Item
Reference parameter of type Record
ItemName
Input parameter of type Code

Remarks

The relevant search keywords are: Item, Make.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(Item);
      Item.VALIDATE("No.",ItemName);
      Item.INSERT(TRUE);
      ItemUnitOfMeasure.INIT;
      ItemUnitOfMeasure.VALIDATE("Item No.",Item."No.");
      UnitOfMeasure.FINDFIRST;
      ItemUnitOfMeasure.VALIDATE(Code,UnitOfMeasure.Code);
      ItemUnitOfMeasure.VALIDATE("Qty. per Unit of Measure",1);
      ItemUnitOfMeasure.INSERT(TRUE);
      Item.VALIDATE("Base Unit of Measure",ItemUnitOfMeasure.Code);
      LibraryERM.FindGeneralPostingSetup(GeneralPostingSetup);
      Item.VALIDATE("Gen. Prod. Posting Group",GeneralPostingSetup."Gen. Prod. Posting Group");
      VATProdPostingGroup.FINDLAST;
      Item.VALIDATE("VAT Prod. Posting Group",VATProdPostingGroup.Code);
      InventoryPostingGroup.FINDFIRST;
      Item.VALIDATE("Inventory Posting Group",InventoryPostingGroup.Code);

      IF TaxGroup.FINDFIRST THEN
        Item.VALIDATE("Tax Group Code",TaxGroup.Code);

      Item.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - Kitting


ResourceMake@52 Method

The procedure ResourceMake is available in codeunit 132205.

Syntax

ResourceMake@52(
    VAR Resource@1000 : Record 156 Resource, //Reference parameter of type Record
    ResourceNo@1001 : Code[20] ResourceNo //Input parameter of type Code
);

Parameters

Resource
Reference parameter of type Record
ResourceNo
Input parameter of type Code

Remarks

The relevant search keywords are: Resource, Make.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(Resource);
      Resource.VALIDATE("No.",ResourceNo);
      Resource.INSERT(TRUE);
      UnitOfMeasure.FINDFIRST;
      LibraryResource.CreateResourceUnitOfMeasure(ResUnitOfMeasure,ResourceNo,UnitOfMeasure.Code,1);
      Resource.VALIDATE("Base Unit of Measure",ResUnitOfMeasure.Code);
      GenProdPostingGroup.FINDLAST;
      Resource.VALIDATE("Gen. Prod. Posting Group",GenProdPostingGroup.Code);
      VATProdPostingGroup.FINDFIRST;
      Resource.VALIDATE("VAT Prod. Posting Group",VATProdPostingGroup.Code);
      Resource.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - Kitting


SetCopyFrom@10 Method

The procedure SetCopyFrom is available in codeunit 132205.

Syntax

SetCopyFrom@10(
    CopyFrom@1001 : Option CopyFrom //Input parameter of type Option
);

Parameters

CopyFrom
Input parameter of type Option

Remarks

The relevant search keywords are: Set, Copy, From.

For a clarification about how this function works, refer to the code listed below.

      AssemblySetup.GET;
      AssemblySetup."Copy Component Dimensions from" := CopyFrom;
      AssemblySetup.MODIFY;

Example

The below example is extracted from the test automation codeunit 137907 to show one way of using this function.

      Initialize;
      LibraryKitting.SetCopyFrom(0); // Header

      // Setup dimensions
      LibraryDimension.CreateDimension(Dimension1);
      LibraryDimension.CreateDimensionValue(DimValue1,Dimension1.Code);
      LibraryDimension.CreateDimensionValue(DimValue2,Dimension1.Code);

      LibraryDimension.CreateDimension(Dimension2);
      LibraryDimension.CreateDimensionValue(DimValue21,Dimension2.Code);
      LibraryDimension.CreateDimensionValue(DimValue22,Dimension2.Code);
      LibraryDimension.CreateDimension(Dimension3);
      LibraryDimension.CreateDimensionValue(DimValue3,Dimension3.Code);

      // Add dimension to Dim Set
      TempDimSetEntry."Dimension Code" := Dimension1.Code;
      TempDimSetEntry."Dimension Value Code" := DimValue1.Code;
      TempDimSetEntry."Dimension Value ID" := DimValue1."Dimension Value ID";
      TempDimSetEntry.INSERT;
      TempDimSetEntry."Dimension Code" := Dimension2.Code;
      TempDimSetEntry."Dimension Value Code" := DimValue21.Code;
      TempDimSetEntry."Dimension Value ID" := DimValue21."Dimension Value ID";
      TempDimSetEntry.INSERT;

      DimSetID1 := DimMgt.GetDimensionSetID(TempDimSetEntry);

      TempDimSetEntry.DELETEALL;
      TempDimSetEntry."Dimension Code" := Dimension1.Code;
      TempDimSetEntry."Dimension Value Code" := DimValue2.Code;
      TempDimSetEntry."Dimension Value ID" := DimValue2."Dimension Value ID";
      TempDimSetEntry.INSERT;
      TempDimSetEntry."Dimension Code" := Dimension2.Code;
      TempDimSetEntry."Dimension Value Code" := DimValue22.Code;
      TempDimSetEntry."Dimension Value ID" := DimValue22."Dimension Value ID";
      TempDimSetEntry.INSERT;
      TempDimSetEntry."Dimension Code" := Dimension3.Code;
      TempDimSetEntry."Dimension Value Code" := DimValue3.Code;
      TempDimSetEntry."Dimension Value ID" := DimValue3."Dimension Value ID";
      TempDimSetEntry.INSERT;

      DimSetID2 := DimMgt.GetDimensionSetID(TempDimSetEntry);
      parent := LibraryKitting.CreateItemWithLotAndNewUOM(500,700,1);
      child := LibraryKitting.CreateItemWithNewUOM(500,700);
      ParentItem.GET(parent);
      ChildItem.GET(child);

      DefaultDim.INIT;
      DefaultDim.VALIDATE("Table ID",DATABASE::Item);
      DefaultDim.VALIDATE("No.",ParentItem."No.");
      DefaultDim.VALIDATE("Dimension Code",Dimension1.Code);
      DefaultDim.VALIDATE("Dimension Value Code",DimValue1.Code);
      DefaultDim.INSERT;
      DefaultDim.VALIDATE("Table ID",DATABASE::Item);
      DefaultDim.VALIDATE("No.",ParentItem."No.");
      DefaultDim.VALIDATE("Dimension Code",Dimension2.Code);
      DefaultDim.VALIDATE("Dimension Value Code",DimValue21.Code);
      DefaultDim.INSERT;

      DefaultDim.INIT;
      DefaultDim.VALIDATE("Table ID",DATABASE::Item);
      DefaultDim.VALIDATE("No.",ChildItem."No.");
      DefaultDim.VALIDATE("Dimension Code",Dimension1.Code);
      DefaultDim.VALIDATE("Dimension Value Code",DimValue2.Code);
      DefaultDim.INSERT;
      DefaultDim.VALIDATE("Table ID",DATABASE::Item);
      DefaultDim.VALIDATE("No.",ChildItem."No.");
      DefaultDim.VALIDATE("Dimension Code",Dimension2.Code);
      DefaultDim.VALIDATE("Dimension Value Code",DimValue22.Code);
      DefaultDim.INSERT;
      DefaultDim.VALIDATE("Table ID",DATABASE::Item);
      DefaultDim.VALIDATE("No.",ChildItem."No.");
      DefaultDim.VALIDATE("Dimension Code",Dimension3.Code);
      DefaultDim.VALIDATE("Dimension Value Code",DimValue3.Code);
      DefaultDim.INSERT;

      LibraryManufacturing.CreateBOMComponent(
        BOMComp,parent,BOMComp.Type::Item,child,1,ChildItem."Base Unit of Measure");
      AssemblyHeader.GET(AssemblyHeader."Document Type"::Order,LibraryKitting.CreateOrder(WorkDate2,parent,1));

      // Set the refreshBom Method
      // TEST WITH THE ASM setup option Copy Component Dimensions from := Order Header
      AsmSetup.FINDFIRST;
      AsmSetup.VALIDATE("Copy Component Dimensions from",AsmSetup."Copy Component Dimensions from"::"Order Header");
      AsmSetup.MODIFY;

      AssemblyHeader.VALIDATE("Dimension Set ID",DimSetID1);
      AssemblyHeader.MODIFY(TRUE);

      LibraryAssembly.SetLinkToLines(AssemblyHeader,AssemblyLine);

      AssemblyLine.FINDFIRST;
      AssemblyLine.VALIDATE("Dimension Set ID",DimSetID2);
      AssemblyHeader.RefreshBOM;
      // find children lines and verify dimensions
      LibraryAssembly.SetLinkToLines(AssemblyHeader,AssemblyLine);
      AssemblyLine.FINDFIRST;
      Assert.AreNotEqual(AssemblyLine."Dimension Set ID",0,'AssemblyLine.Dimension Set ID must not be Zero');

      // Test the refreshBOM using AsmSetup."Copy Component Dimensions from"::"Order Header"
      DimMgt.GetDimensionSet(TempDimSetEntryLinePost,AssemblyLine."Dimension Set ID");

      // VERIFY
      Assert.AreEqual(AssemblyHeader."Dimension Set ID",DimSetID1,'Asm Header.Dimension Set ID changed');
      Assert.AreNotEqual(AssemblyLine."Dimension Set ID",DimSetID2,
        STRSUBSTNO(
          'AssemblyLine.Dimension Set ID did NOT change, which it is expected to Initital %1 after update %2',DimSetID2,
          AssemblyLine."Dimension Set ID"));

      TempDimSetEntryLinePost.SETFILTER("Dimension Code",Dimension1.Code);
      TempDimSetEntryLinePost.FINDFIRST;
      Assert.AreEqual(TempDimSetEntryLinePost."Dimension Value Code",DimValue1.Code,
        STRSUBSTNO('Wrong Dimension Value in Line, expected %1, got %2',DimValue1.Code,TempDimSetEntryLinePost."Dimension Value Code"));

      // TEST WITH THE OTHER ASM setup option Copy Component Dimensions from := Item/Resource Card
      AsmSetup.VALIDATE("Copy Component Dimensions from",AsmSetup."Copy Component Dimensions from"::"Item/Resource Card");
      AsmSetup.MODIFY;

      DimSetID2 := AssemblyLine."Dimension Set ID";
      AssemblyHeader.RefreshBOM;
      LibraryAssembly.SetLinkToLines(AssemblyHeader,AssemblyLine);
      AssemblyLine.FINDFIRST;
      // VERIFY
      Assert.AreEqual(AssemblyHeader."Dimension Set ID",DimSetID1,'Asm Header.Dimension Set ID changed');
      Assert.AreNotEqual(AssemblyLine."Dimension Set ID",DimSetID2,
        STRSUBSTNO(
          'AssemblyLine.Dimension Set ID did NOT change, which it is expected to Initital %1 after update %2',DimSetID2,
          AssemblyLine."Dimension Set ID"));

      DimMgt.GetDimensionSet(TempDimSetEntryLinePost,AssemblyLine."Dimension Set ID");
      TempDimSetEntryLinePost.SETFILTER("Dimension Code",Dimension1.Code);
      TempDimSetEntryLinePost.FINDFIRST;
      Assert.AreEqual(TempDimSetEntryLinePost."Dimension Value Code",DimValue2.Code,
        STRSUBSTNO('Wrong Dimension Value in Line, expected %1, got %2',DimValue2.Code,TempDimSetEntryLinePost."Dimension Value Code"));
      ASSERTERROR ERROR('') // roll back
Member of Lib.Library - Kitting


SetLookahead@9 Method

The procedure SetLookahead is available in codeunit 132205.

Syntax

SetLookahead@9(
    LookahedFormula@1000 : Text[30] LookahedFormula //Input parameter of type Text
);

Parameters

LookahedFormula
Input parameter of type Text

Remarks

The relevant search keywords are: Set, Lookahead.

For a clarification about how this function works, refer to the code listed below.

      IF CompanyInfo.GET THEN;
      EVALUATE(CompanyInfo."Check-Avail. Period Calc.",LookahedFormula);
      CompanyInfo."Check-Avail. Time Bucket" := CompanyInfo."Check-Avail. Time Bucket"::Day;
      IF NOT CompanyInfo.INSERT THEN
        CompanyInfo.MODIFY;

Example

The below example is extracted from the test automation codeunit 137906 to show one way of using this function.

      Initialize;
      LibraryKitting.SetLookahead('<1Y>');
      QTYParent := 2;
      QTYChild := 1;
      parentItem.GET(LibraryKitting.CreateItemWithLotAndNewUOMUsingItemNo('Parent',500,700,1));
      childItem.GET(LibraryKitting.CreateItemWithNewUOMUsingItemNo('Child1',500,700));
      childItem2.GET(LibraryKitting.CreateItemWithNewUOMUsingItemNo('Child2',500,700));

      LibraryManufacturing.CreateBOMComponent(
        BOMComp,parentItem."No.",BOMComp.Type::Item,childItem."No.",QTYChild,childItem."Base Unit of Measure");
      LibraryManufacturing.CreateBOMComponent(
        BOMComp,parentItem."No.",BOMComp.Type::Item,childItem2."No.",QTYChild,childItem2."Base Unit of Measure");

      AssemblyHeader.GET(AssemblyHeader."Document Type"::Order,
        LibraryKitting.CreateOrderNo(010210D,'testAvailField',parentItem."No.",QTYParent));
      AssemblyHeader.VALIDATE("Due Date",010210D);

      MockItemLedgerEntry(childItem."No.",2,AssemblyHeader."Location Code",010108D);
      MockItemLedgerEntry(childItem2."No.",1,AssemblyHeader."Location Code",010108D);

      ExpectedDate := 0D; // Anydate with a year of due date of line=due date of header
      MockPurchaseOrder(childItem."No.",1,AssemblyHeader."Location Code",010110D); // any date before due date

      ValidateQtyAvailableToMake(AssemblyHeader,1);
      ValidateEarliestDate(AssemblyHeader,ExpectedDate);
      ValidateOrderRatio(AssemblyHeader,1);
      ASSERTERROR ERROR('') // roll back
Member of Lib.Library - Kitting


TotalQuantity@13 Method

The procedure TotalQuantity is available in codeunit 132205.

Syntax

TotalQuantity@13(
    AssemblyHeader@1000 : Record 900 AssemblyHeader //Input parameter of type Record
);

Parameters

AssemblyHeader
Input parameter of type Record

Return Value

Decimal

Remarks

The relevant search keywords are: Total, Quantity.

For a clarification about how this function works, refer to the code listed below.

      LibraryAssembly.SetLinkToLines(AssemblyHeader,AssemblyLine);
      TempCount := 0;
      IF AssemblyLine.FINDSET THEN
        REPEAT
          TempCount += AssemblyLine.Quantity;
        UNTIL AssemblyLine.NEXT = 0;
      EXIT(TempCount);

Example

The below example is extracted from the test automation codeunit 137907 to show one way of using this function.

      AssemblyHeader.GET(AssemblyHeader."Document Type"::Order,OrderNo);
      Assert.AreEqual(Count,LibraryKitting.TotalQuantity(AssemblyHeader),
        STRSUBSTNO('Bad Line Quantity of Order: %1 expected %2, got %3',OrderNo,Count,LibraryKitting.TotalQuantity(AssemblyHeader)));
Member of Lib.Library - Kitting


Library - Location Class

Lib.Library - Location

COD132209 applies to SCM,W1,IN.

Methods

Name | Description
CreateLocation@1 | The procedure CreateLocation is available in codeunit 132209.
CreateTradingLocation@1500004 | The procedure CreateTradingLocation is available in codeunit 132209.
SetupTradingLocation@1500001 | The procedure SetupTradingLocation is available in codeunit 132209.

See Also

Lib


CreateLocation@1 Method

The procedure CreateLocation is available in codeunit 132209.

Syntax

CreateLocation@1(
    VAR Location@1000 : Record 14 Location //Reference parameter of type Record
);

Parameters

Location
Reference parameter of type Record

Return Value

Code[10]

Remarks

The relevant search keywords are: Create, Location.

For a clarification about how this function works, refer to the code listed below.

      WITH Location DO BEGIN
        INIT;
        VALIDATE(Code,LibraryUtility.GenerateRandomCode(FIELDNO(Code),DATABASE::Location));
        VALIDATE(Name,Code);
        INSERT(TRUE);
        VALIDATE("E.C.C. No.",FindECCNo);
        MODIFY(TRUE);
        EXIT(Code)
      END;

Example

The below example is extracted from the test automation codeunit 144052 to show one way of using this function.

      // [SCENARIO 164350] Verify Program updates correct TDS Base Amount and TDS Line Amount  when TDS and VAT Rounding are included
      // [FEATURE] [TDS][Purchase Invoice]
      Initialize;

      // [GIVEN] Created Setup for NODNOC and Assessee Code
      LibraryTDS.CreateIncomeTaxAccPeriod(IncomeTaxAccountingPeriod);
      LibraryTDS.CreateIncomeTaxPeriod(IncomeTaxPeriodSetup,IncomeTaxAccountingPeriod."No.",1);
      UpdateTANNoOnCompanyInformation;
      CreateTaxDetail(TaxDetail);
      CreateStructureIncludingTDSBase(StructureHeader,DummyStructureDetails,FALSE);
      Quantity := LibraryRandom.RandInt(5);
      LibraryLocation.CreateLocation(Location);
      Location.VALIDATE("T.A.N. No.",LibraryTDS.CreateTANNo);
      Location.MODIFY(TRUE);
      LibraryTDS.CreateAssesseeandNODNOCSetup(NODNOCHeader,TDSNatureofDeduction,TDSSetup,'',CreateVendor,
        NODNOCHeader.Type::Vendor,IncomeTaxAccountingPeriod."Starting Date");

      // [WHEN] Created Purchase Invoice With Structure
      LibraryPurchase.CreatePurchHeader(PurchaseHeader,PurchaseHeader."Document Type"::Invoice,NODNOCHeader."No.");
      PurchaseHeader.VALIDATE(Structure,StructureHeader.Code);
      PurchaseHeader.VALIDATE("Location Code",Location.Code);
      PurchaseHeader.VALIDATE("Posting Date",IncomeTaxAccountingPeriod."Starting Date");
      PurchaseHeader.MODIFY(TRUE);
      CreatePurchaseLineWithTDSNatureOfDeduction(
        PurchaseLine,PurchaseHeader,PurchaseLine.Type::"G/L Account",FindGLAccountNo,Quantity,LibraryRandom.RandDec(10,2),
        TDSNatureofDeduction.Code,
        0);
      Amount2 := PurchaseLine.Amount;
      CreatePurchaseLineWithTDSNatureOfDeduction(
        PurchaseLine,PurchaseHeader,PurchaseLine.Type::"G/L Account",FindGLAccountNo,Quantity,LibraryRandom.RandDec(10,2),
        TDSNatureofDeduction.Code,
        0);
      Amount2 += PurchaseLine.Amount;
      CalcTDSAmountsFromBase(ExpectedTDSEntry,TDSSetup,Amount2);
      DocumentNo := LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

      // [THEN] GL & TDS Entry has been created
      VerifyGLEntryCount(DocumentNo,4);
      VerifyGLEntryforTDS(DocumentNo,Amount2,PurchaseHeader."Document Type"::Invoice);
      VerifyTDSEntry(ExpectedTDSEntry,DocumentNo,ExpectedTDSEntry."Document Type"::Invoice);
Member of Lib.Library - Location


CreateTradingLocation@1500004 Method

The procedure CreateTradingLocation is available in codeunit 132209.

Syntax

CreateTradingLocation@1500004(
    ECCNo@1500001 : Code[20] ECCNo //Input parameter of type Code
);

Parameters

ECCNo
Input parameter of type Code

Return Value

Code[10]

Remarks

The relevant search keywords are: Create, Trading, Location.

For a clarification about how this function works, refer to the code listed below.

      EXIT(SetupTradingLocation(CreateLocation(Location),TRUE,ECCNo))

Example

The below example is extracted from the test automation codeunit 144001 to show one way of using this function.

      CreateStructureCVDEnabled(StructureHeader);
      LocationCode :=
        LibraryLocation.CreateTradingLocation(
          ServiceTaxAsExciseHelper.CreateECCNoAndSeries(ExciseNoSeries.Type::RG23D,LibraryERM.CreateNoSeriesCode));
      ItemNo := CreateItemWithoutTaxGroup(ExcisePostingSetup."Excise Prod. Posting Group",FALSE);

      LibraryPurchase.CreatePurchHeader(
        PurchaseHeader,
        DocumentType,
        CreateVendorForeign(
          ExcisePostingSetup."Excise Bus. Posting Group",
          CurrencyFactor,
          LocationCode));
      PurchaseHeader.VALIDATE(Structure,StructureHeader.Code);
      PurchaseHeader.MODIFY(TRUE);

      LibraryPurchase.CreatePurchaseLine(
        PurchaseLine,
        PurchaseHeader,
        PurchaseLine.Type::Item,
        ItemNo,
        LibraryRandom.RandDecInRange(1000,2000,2));

      PurchaseLine.VALIDATE("Direct Unit Cost",LibraryRandom.RandDecInRange(10,20,2));
      PurchaseLine.VALIDATE("BCD Amount",BCDAmount);
      PurchaseLine.MODIFY(TRUE);

      CalculatePurchaseLines(PurchaseHeader);
      // Create Inventory Posting Setup for new item
      ServiceTaxAsExciseHelper.CreateInventoryPostingSetup(PurchaseLine."No.",LocationCode);
Member of Lib.Library - Location


SetupTradingLocation@1500001 Method

The procedure SetupTradingLocation is available in codeunit 132209.

Syntax

SetupTradingLocation@1500001(
    LocationCode@1000 : Code[10] LocationCode, //Input parameter of type Code
    Trade@1500000 : Boolean Trade, //Input parameter of type Boolean
    ECCNo@1500002 : Code[20] ECCNo //Input parameter of type Code
);

Parameters

LocationCode
Input parameter of type Code
Trade
Input parameter of type Boolean
ECCNo
Input parameter of type Code

Return Value

Code[10]

Remarks

The relevant search keywords are: Setup, Trading, Location.

For a clarification about how this function works, refer to the code listed below.

      WITH Location DO BEGIN
        GET(LocationCode);
        VALIDATE("Trading Location",Trade);
        VALIDATE("Country/Region Code",'IN');
        VALIDATE("E.C.C. No.",ECCNo);
        MODIFY(TRUE);
      END;
      EXIT(Location.Code)

Example

There are no examples available.
Member of Lib.Library - Location


Library - Manufacturing Class

Lib.Library - Manufacturing

COD132202 applies to SCM,COSTING,W1,All.
Unsupported version tags:
Contains all utility functions related to Manufacturing.

Methods

Name | Description
CalculateConsumption@39 | The procedure CalculateConsumption is available in codeunit 132202.
CalculateConsumptionForJournal@29 | The procedure CalculateConsumptionForJournal is available in codeunit 132202.
CalculateMachCenterCalendar@19 | The procedure CalculateMachCenterCalendar is available in codeunit 132202.
CalculateSubcontractOrder@36 | The procedure CalculateSubcontractOrder is available in codeunit 132202.
CalculateSubcontractOrderWithProdOrderRoutingLine@17 | The procedure CalculateSubcontractOrderWithProdOrderRoutingLine is available in codeunit 132202.
CalculateWorkCenterCalendar@12 | The procedure CalculateWorkCenterCalendar is available in codeunit 132202.
CalculateWorksheetPlan@32 | The procedure CalculateWorksheetPlan is available in codeunit 132202.
ChangeProdOrderStatus@35 | The procedure ChangeProdOrderStatus is available in codeunit 132202.
ChangeStatusFirmPlanToReleased@124 | The procedure ChangeStatusFirmPlanToReleased is available in codeunit 132202.
ChangeStatusPlannedToFinished@30 | The procedure ChangeStatusPlannedToFinished is available in codeunit 132202.
ChangeStatusReleasedToFinished@48 | The procedure ChangeStatusReleasedToFinished is available in codeunit 132202.
ChangeStatusSimulatedToReleased@18 | The procedure ChangeStatusSimulatedToReleased is available in codeunit 132202.
CreateAndRefreshProductionOrder@46 | The procedure CreateAndRefreshProductionOrder is available in codeunit 132202.
CreateBOMComponent@1 | The procedure CreateBOMComponent is available in codeunit 132202.
CreateCalendarAbsenceEntry@9 | The procedure CreateCalendarAbsenceEntry is available in codeunit 132202.
CreateCapacityConstrainedResource@131 | The procedure CreateCapacityConstrainedResource is available in codeunit 132202.
CreateCapacityUnitOfMeasure@28 | The procedure CreateCapacityUnitOfMeasure is available in codeunit 132202.
CreateCertifiedProductionBOM@139 | The procedure CreateCertifiedProductionBOM is available in codeunit 132202.
CreateCertifProdBOMWithTwoComp@11 | The procedure CreateCertifProdBOMWithTwoComp is available in codeunit 132202.
CreateFamily@115 | The procedure CreateFamily is available in codeunit 132202.
CreateFamilyLine@113 | The procedure CreateFamilyLine is available in codeunit 132202.
CreateItemManufacturing@10 | The procedure CreateItemManufacturing is available in codeunit 132202.
CreateMachineCenter@38 | The procedure CreateMachineCenter is available in codeunit 132202.
CreateMachineCenterWithCalendar@37 | The procedure CreateMachineCenterWithCalendar is available in codeunit 132202.
CreateOutputJournal@51 | The procedure CreateOutputJournal is available in codeunit 132202.
CreateProdOrderLine@88 | The procedure CreateProdOrderLine is available in codeunit 132202.
CreateProductionBOMCommentLine@152 | The procedure CreateProductionBOMCommentLine is available in codeunit 132202.
CreateProductionBOMHeader@40 | The procedure CreateProductionBOMHeader is available in codeunit 132202.
CreateProductionBOMLine@60 | The procedure CreateProductionBOMLine is available in codeunit 132202.
CreateProductionBOMVersion@31 | The procedure CreateProductionBOMVersion is available in codeunit 132202.
CreateProductionForecastEntry@140 | The procedure CreateProductionForecastEntry is available in codeunit 132202.
CreateProductionForecastName@71 | The procedure CreateProductionForecastName is available in codeunit 132202.
CreateProductionOrder@86 | The procedure CreateProductionOrder is available in codeunit 132202.
CreateProductionOrderComponent@109 | The procedure CreateProductionOrderComponent is available in codeunit 132202.
CreateProductionOrderFromSalesOrder@59 | The procedure CreateProductionOrderFromSalesOrder is available in codeunit 132202.
CreateRegisteredAbsence@8 | The procedure CreateRegisteredAbsence is available in codeunit 132202.
CreateRoutingHeader@77 | The procedure CreateRoutingHeader is available in codeunit 132202.
CreateRoutingLine@72 | The procedure CreateRoutingLine is available in codeunit 132202.
CreateRoutingLineSetup@4 | The procedure CreateRoutingLineSetup is available in codeunit 132202.
CreateRoutingLink@79 | The procedure CreateRoutingLink is available in codeunit 132202.
CreateRoutingVersion@7 | The procedure CreateRoutingVersion is available in codeunit 132202.
CreateShopCalendarCode@6 | The procedure CreateShopCalendarCode is available in codeunit 132202.
CreateShopCalendarWorkingDays@3 | The procedure CreateShopCalendarWorkingDays is available in codeunit 132202.
CreateStandardTask@23 | The procedure CreateStandardTask is available in codeunit 132202.
CreateWorkCenter@5 | The procedure CreateWorkCenter is available in codeunit 132202.
CreateWorkCenterCustomTime@105 | The procedure CreateWorkCenterCustomTime is available in codeunit 132202.
CreateWorkCenterFullWorkingWeek@14 | The procedure CreateWorkCenterFullWorkingWeek is available in codeunit 132202.
CreateWorkCenterGroup@16 | The procedure CreateWorkCenterGroup is available in codeunit 132202.
CreateWorkCenterWithCalendar@53 | The procedure CreateWorkCenterWithCalendar is available in codeunit 132202.
CreateWorkShiftCode@27 | The procedure CreateWorkShiftCode is available in codeunit 132202.
OpenProductionJournal@20 | The procedure OpenProductionJournal is available in codeunit 132202.
OutputJournalExplodeOrderLineRouting@33 | The procedure OutputJournalExplodeOrderLineRouting is available in codeunit 132202.
OutputJournalExplodeRouting@34 | The procedure OutputJournalExplodeRouting is available in codeunit 132202.
PostConsumptionJournal@26 | The procedure PostConsumptionJournal is available in codeunit 132202.
PostOutputJournal@25 | The procedure PostOutputJournal is available in codeunit 132202.
RefreshProdOrder@24 | The procedure RefreshProdOrder is available in codeunit 132202.
RunReplanProductionOrder@141 | The procedure RunReplanProductionOrder is available in codeunit 132202.
RunRollUpStandardCost@22 | The procedure RunRollUpStandardCost is available in codeunit 132202.
UpdateManufacturingSetup@2 | The procedure UpdateManufacturingSetup is available in codeunit 132202.
UpdateOutputJournal@13 | The procedure UpdateOutputJournal is available in codeunit 132202.
UpdateProdOrderComp@57 | The procedure UpdateProdOrderComp is available in codeunit 132202.
UpdateProdOrderLine@58 | The procedure UpdateProdOrderLine is available in codeunit 132202.
UpdateProductionBOMStatus@44 | The procedure UpdateProductionBOMStatus is available in codeunit 132202.
UpdateRoutingStatus@45 | The procedure UpdateRoutingStatus is available in codeunit 132202.
UpdateShopCalendarFullWorkingWeekCustomTime@41 | The procedure UpdateShopCalendarFullWorkingWeekCustomTime is available in codeunit 132202.
UpdateShopCalendarWorkingDays@15 | The procedure UpdateShopCalendarWorkingDays is available in codeunit 132202.
UpdateShopCalendarWorkingDaysCustomTime@125 | The procedure UpdateShopCalendarWorkingDaysCustomTime is available in codeunit 132202.

See Also

Lib


CalculateConsumption@39 Method

The procedure CalculateConsumption is available in codeunit 132202.

Syntax

CalculateConsumption@39(
    ProductionOrderNo@1001 : Code[20] ProductionOrderNo, //Input parameter of type Code
    ItemJournalTemplateName@1004 : Code[10] ItemJournalTemplateName, //Input parameter of type Code
    ItemJournalBatchName@1005 : Code[10] ItemJournalBatchName //Input parameter of type Code
);

Parameters

ProductionOrderNo
Input parameter of type Code
ItemJournalTemplateName
Input parameter of type Code
ItemJournalBatchName
Input parameter of type Code

Remarks

The relevant search keywords are: Calculate, Consumption.

For a clarification about how this function works, refer to the code listed below.

      CalcConsumption.InitializeRequest(WORKDATE,CalcBasedOn::"Expected Output");
      CalcConsumption.SetTemplateAndBatchName(ItemJournalTemplateName,ItemJournalBatchName);
      ProductionOrder.SETRANGE(Status,ProductionOrder.Status::Released);
      ProductionOrder.SETRANGE("No.",ProductionOrderNo);
      CalcConsumption.SETTABLEVIEW(ProductionOrder);
      CalcConsumption.USEREQUESTPAGE(FALSE);
      CalcConsumption.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 137001 to show one way of using this function.

      LibraryInventory.SelectItemJournalTemplateName(ItemJournalTemplate,Type);
      LibraryInventory.SelectItemJournalBatchName(
        ItemJournalBatch,ItemJournalBatch."Template Type"::Consumption,ItemJournalTemplate.Name);

      CASE Type OF
        ItemJournalTemplate.Type::Consumption:
          LibraryManufacturing.CalculateConsumption(ProductionOrderNo,ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name);
        ItemJournalTemplate.Type::Output:
          BEGIN
            LibraryInventory.ClearItemJournal(ItemJournalTemplate,ItemJournalBatch);
            LibraryManufacturing.CreateOutputJournal(ItemJournalLine,ItemJournalTemplate,ItemJournalBatch,'',ProductionOrderNo);
            LibraryInventory.OutputJnlExplRoute(ItemJournalLine);
          END;
      END;

      ItemJournalLine.SETRANGE("Journal Template Name",ItemJournalBatch."Journal Template Name");
      ItemJournalLine.SETRANGE("Journal Batch Name",ItemJournalBatch.Name);
      ItemJournalLine.FINDSET;
      REPEAT
        TempItemJournalLine := ItemJournalLine;
        TempItemJournalLine.INSERT;
      UNTIL ItemJournalLine.NEXT = 0;

      LibraryInventory.PostItemJournalLine(ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name);
Member of Lib.Library - Manufacturing


CalculateConsumptionForJournal@29 Method

The procedure CalculateConsumptionForJournal is available in codeunit 132202.

Syntax

CalculateConsumptionForJournal@29(
    VAR ProductionOrder@1005 : Record 5405 ProductionOrder, //Reference parameter of type Record
    VAR ProdOrderComponent@1006 : Record 5407 ProdOrderComponent, //Reference parameter of type Record
    PostingDate@1000 : Date PostingDate, //Input parameter of type Date
    ActualOutput@1001 : Boolean ActualOutput //Input parameter of type Boolean
);

Parameters

ProductionOrder
Reference parameter of type Record
ProdOrderComponent
Reference parameter of type Record
PostingDate
Input parameter of type Date
ActualOutput
Input parameter of type Boolean

Remarks

The relevant search keywords are: Calculate, Consumption, For, Journal.

For a clarification about how this function works, refer to the code listed below.

      COMMIT;
      IF ActualOutput THEN
        CalcBasedOn := CalcBasedOn::"Actual Output"
      ELSE
        CalcBasedOn := CalcBasedOn::"Expected Output";
      CalcConsumption.InitializeRequest(PostingDate,CalcBasedOn);
      ItemJournalTemplate.SETRANGE(Type,ItemJournalTemplate.Type::Consumption);
      ItemJournalTemplate.FINDFIRST;
      ItemJournalBatch.SETRANGE("Journal Template Name",ItemJournalTemplate.Name);
      ItemJournalBatch.FINDFIRST;
      CalcConsumption.SetTemplateAndBatchName(ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name);
      IF ProductionOrder.HASFILTER THEN
        TmpProductionOrder.COPYFILTERS(ProductionOrder)
      ELSE BEGIN
        ProductionOrder.GET(ProductionOrder.Status,ProductionOrder."No.");
        TmpProductionOrder.SETRANGE(Status,ProductionOrder.Status);
        TmpProductionOrder.SETRANGE("No.",ProductionOrder."No.");
      END;
      CalcConsumption.SETTABLEVIEW(TmpProductionOrder);
      IF ProdOrderComponent.HASFILTER THEN
        TmpProdOrderComponent.COPYFILTERS(ProdOrderComponent)
      ELSE BEGIN
        ProdOrderComponent.GET(ProdOrderComponent.Status,ProdOrderComponent."Prod. Order No.",
          ProdOrderComponent."Prod. Order Line No.",ProdOrderComponent."Line No.");
        TmpProdOrderComponent.SETRANGE(Status,ProdOrderComponent.Status);
        TmpProdOrderComponent.SETRANGE("Prod. Order No.",ProdOrderComponent."Prod. Order No.");
        TmpProdOrderComponent.SETRANGE("Prod. Order Line No.",ProdOrderComponent."Prod. Order Line No.");
        TmpProdOrderComponent.SETRANGE("Line No.",ProdOrderComponent."Line No.");
      END;
      CalcConsumption.SETTABLEVIEW(TmpProdOrderComponent);
      CalcConsumption.USEREQUESTPAGE(FALSE);
      CalcConsumption.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 137066 to show one way of using this function.

      ProdOrderComponent.SETRANGE(Status,ProductionOrder.Status);
      ProdOrderComponent.SETRANGE("Prod. Order No.",ProductionOrder."No.");
      LibraryManufacturing.CalculateConsumptionForJournal(ProductionOrder,ProdOrderComponent,WORKDATE,FALSE);

      WITH ItemJournalLine DO BEGIN
        SETRANGE("Order Type","Order Type"::Production);
        SETRANGE("Order No.",ProductionOrder."No.");
        SETRANGE("Entry Type","Entry Type"::Consumption);
        FINDFIRST;
        VALIDATE(Quantity,ConsumptionQty);
        VALIDATE("Applies-to Entry",AppliedToEntryNo);
        MODIFY(TRUE);
      END;
      LibraryManufacturing.PostConsumptionJournal;
Member of Lib.Library - Manufacturing


CalculateMachCenterCalendar@19 Method

The procedure CalculateMachCenterCalendar is available in codeunit 132202.

Syntax

CalculateMachCenterCalendar@19(
    VAR MachineCenter@1000 : Record 99000758 MachineCenter, //Reference parameter of type Record
    StartingDate@1001 : Date StartingDate, //Input parameter of type Date
    EndingDate@1002 : Date EndingDate //Input parameter of type Date
);

Parameters

MachineCenter
Reference parameter of type Record
StartingDate
Input parameter of type Date
EndingDate
Input parameter of type Date

Remarks

The relevant search keywords are: Calculate, Mach, Center, Calendar.

For a clarification about how this function works, refer to the code listed below.

      COMMIT;
      CalcMachineCenterCalendar.InitializeRequest(StartingDate,EndingDate);
      IF MachineCenter.HASFILTER THEN
        TmpMachineCenter.COPYFILTERS(MachineCenter)
      ELSE BEGIN
        MachineCenter.GET(MachineCenter."No.");
        TmpMachineCenter.SETRANGE("No.",MachineCenter."No.");
      END;
      CalcMachineCenterCalendar.SETTABLEVIEW(TmpMachineCenter);
      CalcMachineCenterCalendar.USEREQUESTPAGE(FALSE);
      CalcMachineCenterCalendar.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 137003 to show one way of using this function.

      // Calculate Calendar for Machine Center with dates having a difference of 1 Month.
      MachineCenter.GET(MachineCenterNo);
      LibraryManufacturing.CalculateMachCenterCalendar(MachineCenter,CALCDATE('<-1M>',WORKDATE),CALCDATE('<1M>',WORKDATE));
Member of Lib.Library - Manufacturing


CalculateSubcontractOrder@36 Method

The procedure CalculateSubcontractOrder is available in codeunit 132202.

Syntax

CalculateSubcontractOrder@36(
    VAR WorkCenter@1000 : Record 99000754 WorkCenter //Reference parameter of type Record
);

Parameters

WorkCenter
Reference parameter of type Record

Remarks

The relevant search keywords are: Calculate, Subcontract, Order.

For a clarification about how this function works, refer to the code listed below.

      RequisitionLineForSubcontractOrder(RequisitionLine);
      CalculateSubcontracts.SetWkShLine(RequisitionLine);
      CalculateSubcontracts.SETTABLEVIEW(WorkCenter);
      CalculateSubcontracts.USEREQUESTPAGE(FALSE);
      CalculateSubcontracts.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 137004 to show one way of using this function.

      // Steps describing the sequence of actions for Test Case.

      // 1. Create required WIP setups with Flushing method as Manual with Subcontract.
      // Update Manufacturing Setup, Inventory Setup and Update Shop Calendar Working Days based on Work Shift code.
      Initialize;
      RaiseConfirmHandler;
      LibraryManufacturing.CreateWorkCenterGroup(WorkCenterGroup);
      LibraryManufacturing.CreateCapacityUnitOfMeasure(CapacityUnitOfMeasure,Type::Minutes);
      LibraryInventory.UpdateInventorySetup(
        InventorySetup,TRUE,FALSE,AutomaticCostAdjustment::Never,AverageCostCalcType::Item,AverageCostPeriod::Day);
      LibraryManufacturing.UpdateManufacturingSetup(ManufacturingSetup,'','',TRUE,TRUE,TRUE);
      ShopCalendarCode := LibraryManufacturing.UpdateShopCalendarWorkingDays;
      IF AdditionalCurrencyExist THEN
        CurrencyCode := UpdateAddnlReportingCurrency
      ELSE
        LibraryERM.SetAddReportingCurrency('');

      // Create Work Center and Machine Center with Flushing method -Manual.
      // Create Work Center for Subcontractor with Flushing method -Manual.
      // Create Routing.
      CreateWorkCenter(WorkCenterNo,ShopCalendarCode,FlushingMethod,FALSE,UnitCostCalculation,'');
      CreateMachineCenter(MachineCenterNo,WorkCenterNo,FlushingMethod);
      CreateMachineCenter(MachineCenterNo2,WorkCenterNo,FlushingMethod);
      IF UpdateProdOrderRouting THEN
        CreateMachineCenter(MachineCenterNo3,WorkCenterNo,FlushingMethod);
      IF Subcontract THEN
        CreateWorkCenter(WorkCenterNo2,ShopCalendarCode,SubcontractFlushingMethod,TRUE,UnitCostCalculation,CurrencyCode)
      ELSE
        CreateWorkCenter(WorkCenterNo2,ShopCalendarCode,FlushingMethod,FALSE,UnitCostCalculation,CurrencyCode);
      RoutingNo := NoSeriesManagement.GetNextNo(ManufacturingSetup."Routing Nos.",WORKDATE,TRUE);
      CreateRouting(RoutingNo,MachineCenterNo,MachineCenterNo2,WorkCenterNo,WorkCenterNo2);

      // Create Items with Flushing method - Manual with the Parent Item containing Routing No. and Production BOM No.
      CreateItem(Item,CostingMethod,Item."Reordering Policy"::"Lot-for-Lot",FlushingMethod,'','');
      ItemNo := Item."No.";
      CLEAR(Item);
      CreateItem(Item,CostingMethod,Item."Reordering Policy"::"Lot-for-Lot",FlushingMethod,'','');
      ItemNo2 := Item."No.";
      CLEAR(Item);
      IF UpdateProductionComponent THEN BEGIN
        CreateItem(Item,Item."Costing Method"::Standard,Item."Reordering Policy"::"Lot-for-Lot",FlushingMethod,'','');
        ItemNo3 := Item."No.";
        CLEAR(Item);
      END;
      ProductionBOMNo :=
        LibraryManufacturing.CreateCertifProdBOMWithTwoComp(
          ProductionBOMHeader,ItemNo,ItemNo2,1); // value imporatant.
      CreateItem(Item,CostingMethod,Item."Reordering Policy"::"Lot-for-Lot",FlushingMethod,RoutingNo,ProductionBOMNo);

      // Calculate Standard Cost for Parent Item, if Costing Method is Standard.
      // Calculate Calendar for Work Center with dates having a difference of 5 weeks.
      // Create and Post Purchase Order as Receive and Invoice.
      IF  Item."Costing Method" = Item."Costing Method"::Standard THEN
        CalculateStandardCost.CalcItem(Item."No.",FALSE);
      CalculateCalendar(MachineCenterNo,MachineCenterNo2,WorkCenterNo,WorkCenterNo2);
      IF NOT AdditionalCurrencyExist THEN
        CreatePurchaseOrder(
          PurchaseHeader,PurchaseLine,ItemNo,ItemNo2,ItemNo3,LibraryRandom.RandInt(100) + 10,
          LibraryRandom.RandInt(100) + 10,LibraryRandom.RandInt(100) + 50,UpdateProductionComponent)
      ELSE
        CreatePurchaseOrderAddnlCurr(PurchaseHeader,PurchaseLine,CurrencyCode,ItemNo,ItemNo2,ItemNo3,
          LibraryRandom.RandInt(100) + 10,UpdateProductionComponent);

      IF AdjustExchangeRatesGLSetup THEN BEGIN
        UpdateExchangeRate(CurrencyCode);
        LibraryERM.RunAdjustExchangeRates(
          CurrencyCode,WORKDATE,WORKDATE,PurchaseHeader."No.",WORKDATE,LibraryUtility.GenerateGUID,TRUE);
      END;

      // Create and Refresh Production Order.
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);
      LibraryManufacturing.CreateProductionOrder(
        ProductionOrder,ProductionOrderStatus,ProductionOrder."Source Type"::Item,Item."No.",LibraryRandom.RandInt(10) + 5);
      LibraryManufacturing.RefreshProdOrder(ProductionOrder,FALSE,TRUE,TRUE,TRUE,FALSE);
      IF UpdateProdOrderRouting THEN BEGIN
        MachineCenter.GET(MachineCenterNo3);
        LibraryManufacturing.CalculateMachCenterCalendar(MachineCenter,CALCDATE('<-1M>',WORKDATE),CALCDATE('<1M>',WORKDATE));
        AddProdOrderRoutingLine(ProductionOrder,ProductionOrderRoutingType::"Machine Center",MachineCenterNo3);
        LibraryManufacturing.RefreshProdOrder(ProductionOrder,FALSE,FALSE,FALSE,TRUE,FALSE);
      END;

      // Create Subcontracting Worksheet, Make order and Post Subcontracting Purchase Order.
      IF Subcontract THEN BEGIN
        LibraryManufacturing.CalculateSubcontractOrder(WorkCenter);
        MakeSubconPurchOrder(ProductionOrder."No.",WorkCenterNo2);
        PostSubconPurchOrder(TempPurchaseLine,ProductionOrder."No.",SubcontractCostDiff);
      END;

      // Remove one component from Production Order and Replace it with a New Component.
      IF UpdateProductionComponent THEN
        ReplaceProdOrderComponent(ProductionOrder."No.",ItemNo2,Item."No.",ItemNo3);

      // Create, Calculate and Post Consumption Journal, Explode Routing and Post Output Journal.
      IF Item."Flushing Method" = Item."Flushing Method"::Manual THEN BEGIN
        LibraryInventory.CreateItemJournal(
          ItemJournalBatch,ItemNo,ItemJournalBatch."Template Type"::Consumption,ProductionOrder."No.");
        IF DeleteConsumptionJrnl THEN
          RemoveProdOrderComponent(ProductionOrder."No.",ItemNo);
        IF ConsumptionCostDiff THEN
          UpdateQtyConsumptionJournal(ProductionOrder."No.",ItemNo2);
        LibraryInventory.PostItemJournalLine(ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name);
        LibraryInventory.CreateItemJournal(ItemJournalBatch,ItemNo3,ItemJournalBatch."Template Type"::Output,ProductionOrder."No.");
        IF OutputCostDiff THEN
          UpdateLessQtyOutputJournal(ProductionOrder."No.",ProductionOrder.Quantity);
        IF RunSetupTimeCostDiff THEN BEGIN
          SetupTime := 1;
          RunTime := 1;
          UpdateSetupRunTime(ProductionOrder."No.",SetupTime,RunTime);
        END;
        LibraryInventory.PostItemJournalLine(ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name);
      END;

      // Change Production Order Status.
      IF ProductionOrder.Status = ProductionOrder.Status::Planned THEN
        ProductionOrderNo :=
          LibraryManufacturing.ChangeStatusPlannedToFinished(ProductionOrder."No.") // Change Status from Planned to Finished.
      ELSE
        LibraryManufacturing.ChangeStatusReleasedToFinished(ProductionOrder."No.");
      // Change Status of Production Order from Released to Finished.

      // 2. Execute Adjust Cost Item Entries report and Post Inventory Cost to G/L report.
      ProductionOrder.SETRANGE(Status,ProductionOrder.Status::Finished);
      IF ProductionOrderNo <> '' THEN
        ProductionOrder.SETRANGE("No.",ProductionOrderNo)
      ELSE
        ProductionOrder.SETRANGE("No.",ProductionOrder."No.");
      ProductionOrder.FINDFIRST;
      AdjustCostPostInventoryCostGL(ItemNo + '..' + ItemNo3);

      // 3. Verify GL Entry : Total amount and Positive amount entries for WIP Account.
      VerifyGLEntryForWIPAccounts(
        TempPurchaseLine,ItemNo,ProductionOrder."No.",CurrencyCode,SetupTime,RunTime,AdditionalCurrencyExist);

      // 4.Tear Down.
      TearDown(AdditionalCurrencyExist,Subcontract,Item."No.");
Member of Lib.Library - Manufacturing


CalculateSubcontractOrderWithProdOrderRoutingLine@17 Method

The procedure CalculateSubcontractOrderWithProdOrderRoutingLine is available in codeunit 132202.

Syntax

CalculateSubcontractOrderWithProdOrderRoutingLine@17(
    VAR ProdOrderRoutingLine@1003 : Record 5409 ProdOrderRoutingLine //Reference parameter of type Record
);

Parameters

ProdOrderRoutingLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Calculate, Subcontract, Order, Product, Order, Routing, Line.

For a clarification about how this function works, refer to the code listed below.

      IF ProdOrderRoutingLine.HASFILTER THEN
        TmpProdOrderRoutingLine.COPYFILTERS(ProdOrderRoutingLine)
      ELSE BEGIN
        ProdOrderRoutingLine.GET(ProdOrderRoutingLine."No.");
        TmpProdOrderRoutingLine.SETRANGE("No.",ProdOrderRoutingLine."No.");
      END;

      RequisitionLineForSubcontractOrder(RequisitionLine);
      CalculateSubcontracts.SetWkShLine(RequisitionLine);
      CalculateSubcontracts.SETTABLEVIEW(TmpProdOrderRoutingLine);
      CalculateSubcontracts.USEREQUESTPAGE(FALSE);
      CalculateSubcontracts.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 137077 to show one way of using this function.

      ProdOrderRoutingLine.SETRANGE("Prod. Order No.",ProductionOrderNo);
      ProdOrderRoutingLine.SETRANGE("Starting Date",StartingDate);
      LibraryManufacturing.CalculateSubcontractOrderWithProdOrderRoutingLine(ProdOrderRoutingLine);
Member of Lib.Library - Manufacturing


CalculateWorkCenterCalendar@12 Method

The procedure CalculateWorkCenterCalendar is available in codeunit 132202.

Syntax

CalculateWorkCenterCalendar@12(
    VAR WorkCenter@1000 : Record 99000754 WorkCenter, //Reference parameter of type Record
    StartingDate@1001 : Date StartingDate, //Input parameter of type Date
    EndingDate@1002 : Date EndingDate //Input parameter of type Date
);

Parameters

WorkCenter
Reference parameter of type Record
StartingDate
Input parameter of type Date
EndingDate
Input parameter of type Date

Remarks

The relevant search keywords are: Calculate, Work, Center, Calendar.

For a clarification about how this function works, refer to the code listed below.

      COMMIT;
      CalculateWorkCenterCalendar.InitializeRequest(StartingDate,EndingDate);
      IF WorkCenter.HASFILTER THEN
        TmpWorkCenter.COPYFILTERS(WorkCenter)
      ELSE BEGIN
        WorkCenter.GET(WorkCenter."No.");
        TmpWorkCenter.SETRANGE("No.",WorkCenter."No.");
      END;
      CalculateWorkCenterCalendar.SETTABLEVIEW(TmpWorkCenter);
      CalculateWorkCenterCalendar.USEREQUESTPAGE(FALSE);
      CalculateWorkCenterCalendar.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 137003 to show one way of using this function.

      // Calculate Calendar for Work Center with dates having a difference of 1 Month.
      WorkCenter.GET(WorkCenterNo);
      LibraryManufacturing.CalculateWorkCenterCalendar(WorkCenter,CALCDATE('<-1M>',WORKDATE),CALCDATE('<1M>',WORKDATE));
Member of Lib.Library - Manufacturing


CalculateWorksheetPlan@32 Method

The procedure CalculateWorksheetPlan is available in codeunit 132202.

Syntax

CalculateWorksheetPlan@32(
    VAR Item@1002 : Record 27 Item, //Reference parameter of type Record
    OrderDate@1001 : Date OrderDate, //Input parameter of type Date
    ToDate@1000 : Date ToDate //Input parameter of type Date
);

Parameters

Item
Reference parameter of type Record
OrderDate
Input parameter of type Date
ToDate
Input parameter of type Date

Remarks

The relevant search keywords are: Calculate, Worksheet, Plan.

For a clarification about how this function works, refer to the code listed below.

      COMMIT;
      CalculatePlanPlanWksh.InitializeRequest(OrderDate,ToDate,FALSE);
      ReqWkshTemplate.SETRANGE(Type,ReqWkshTemplate.Type::Planning);
      ReqWkshTemplate.FINDFIRST;
      RequisitionWkshName.SETRANGE("Worksheet Template Name",ReqWkshTemplate.Name);
      RequisitionWkshName.FINDFIRST;
      CalculatePlanPlanWksh.SetTemplAndWorksheet(RequisitionWkshName."Worksheet Template Name",RequisitionWkshName.Name,TRUE);
      IF Item.HASFILTER THEN
        TempItem.COPYFILTERS(Item)
      ELSE BEGIN
        Item.GET(Item."No.");
        TempItem.SETRANGE("No.",Item."No.");
      END;
      CalculatePlanPlanWksh.SETTABLEVIEW(TempItem);
      CalculatePlanPlanWksh.USEREQUESTPAGE(FALSE);
      CalculatePlanPlanWksh.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 137009 to show one way of using this function.

      Initialize;

      LibraryInventory.CreateItem(Item);
      Item.VALIDATE("Reordering Policy",Item."Reordering Policy"::"Lot-for-Lot");
      EVALUATE(Item."Rescheduling Period",'<5D>');
      Item.MODIFY(TRUE);

      CreatePurchaseOrder(PurchaseLine,Item."No.",8,CALCDATE('<+5D>',WORKDATE));
      CreateSalesOrder(SalesLine,Item."No.",7,CALCDATE('<+11D>',WORKDATE));
      LibraryManufacturing.CalculateWorksheetPlan(Item,CALCDATE('<+2D>',WORKDATE),CALCDATE('<+16D>',WORKDATE));

      // Should give 2 lines + Cancel + New from Planning plus one per Period Type, no excess inventory
      RunPage(Item,'',FALSE,TRUE,0,6,0);
Member of Lib.Library - Manufacturing


ChangeProdOrderStatus@35 Method

The procedure ChangeProdOrderStatus is available in codeunit 132202.

Syntax

ChangeProdOrderStatus@35(
    VAR ProductionOrder@1000 : Record 5405 ProductionOrder, //Reference parameter of type Record
    NewStatus@1001 : Option NewStatus, //Input parameter of type Option
    PostingDate@1002 : Date PostingDate, //Input parameter of type Date
    UpdateUnitCost@1003 : Boolean UpdateUnitCost //Input parameter of type Boolean
);

Parameters

ProductionOrder
Reference parameter of type Record
NewStatus
Input parameter of type Option
PostingDate
Input parameter of type Date
UpdateUnitCost
Input parameter of type Boolean

Remarks

The relevant search keywords are: Change, Product, Order, Status.

For a clarification about how this function works, refer to the code listed below.

      ProdOrderStatusMgt.ChangeStatusOnProdOrder(ProductionOrder,NewStatus,PostingDate,UpdateUnitCost);

Example

The below example is extracted from the test automation codeunit 137200 to show one way of using this function.

      ProductionOrder.FIND('=');
      LibraryManufacturing.ChangeProdOrderStatus(
        ProductionOrder,ProductionOrder.Status::Released,ProductionOrder."Due Date",TRUE);

      ProductionOrder.SETRANGE("Source No.",ProductionOrder."Source No.");
      ProductionOrder.SETRANGE(Status,ProductionOrder.Status::Released);
      ProductionOrder.SETRANGE("Location Code",LocationCode);
      ProductionOrder.FINDLAST;
Member of Lib.Library - Manufacturing


ChangeStatusFirmPlanToReleased@124 Method

The procedure ChangeStatusFirmPlanToReleased is available in codeunit 132202.

Syntax

ChangeStatusFirmPlanToReleased@124(
    ProductionOrderNo@1003 : Code[20] ProductionOrderNo, //Input parameter of type Code
    FromStatus@1001 : Option FromStatus, //Input parameter of type Option
    ToStatus@1004 : Option ToStatus //Input parameter of type Option
);

Parameters

ProductionOrderNo
Input parameter of type Code
FromStatus
Input parameter of type Option
ToStatus
Input parameter of type Option

Return Value

Code[20]

Remarks

The relevant search keywords are: Change, Status, Firm, Plan, To, Released.

For a clarification about how this function works, refer to the code listed below.

      ProductionOrder.GET(FromStatus,ProductionOrderNo);
      ProdOrderStatusManagement.ChangeStatusOnProdOrder(ProductionOrder,ToStatus,WORKDATE,TRUE);
      ProductionOrder.SETRANGE(Status,ToStatus);
      ProductionOrder.SETRANGE("Source No.",ProductionOrder."Source No.");
      ProductionOrder.FINDFIRST;
      EXIT(ProductionOrder."No.");

Example

The below example is extracted from the test automation codeunit 137003 to show one way of using this function.

      // [FEATURE] [Manufacturing] [Planning] [Adjust Cost - Item Entries]
      // [SCENARIO 376035] "Last Direct Cost" is updated for Top Item in complex Production Order after running "Adjust Cost - Item Entries".

      // [GIVEN] Production Item "T", with Production BOM which includes production Items "C1" (Production BOM with component "CC1") and "C2" (Production BOM with component "CC2").
      Initialize;
      PrepareItemsOfComplexProdBOM(ItemNo);

      // [GIVEN] Purchase "CC1" and "CC2".
      CreatePurchaseOrder(PurchaseHeader,PurchaseLine,ItemNo[1],ItemNo[2],1,1,FALSE); // specific values needed for test
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

      // [GIVEN] Create Sales Order for Item "T", run planning calculation, make supply Production Order and release it.
      CreateSalesOrder(SalesHeader,ItemNo[5],1); // specific value needed for test
      LibraryPlanning.CalculateOrderPlanSales(ReqLine);
      MakeSupplyOrdersActiveOrder(SalesHeader."No.");
      FindProdOrder(ProdOrder,ProdOrder.Status::"Firm Planned",ItemNo[5]);
      ReleasedProdOrderNo :=
        LibraryManufacturing.ChangeStatusFirmPlanToReleased(
          ProdOrder."No.",ProdOrder.Status,ProdOrder.Status::Released);

      // [GIVEN] Post Production Journal for Production Order Lines: "C2", "C1" and "T" in that sequence, then finish Production Order.
      FindProdOrder(ProdOrder,ProdOrder.Status::Released,ItemNo[5]);
      PostProdJournal(ProdOrder,ItemNo[3]);
      PostProdJournal(ProdOrder,ItemNo[4]);
      PostProdJournal(ProdOrder,ItemNo[5]);
      LibraryManufacturing.ChangeStatusReleasedToFinished(ReleasedProdOrderNo);

      // [GIVEN] Add Item Charge to received components "CC1" and "CC2".
      AddItemCharge(ItemNo[1],LibraryRandom.RandDecInRange(5,10,2));
      AddItemCharge(ItemNo[2],LibraryRandom.RandDecInRange(5,10,2));

      // [GIVEN] Cost of components "CC1", "CC2" and production Items "C1", "C2" is adjusted.
      LibraryCosting.AdjustCostItemEntries(STRSUBSTNO('%1|%2|%3|%4',ItemNo[1],ItemNo[2],ItemNo[3],ItemNo[4]),'');

      // [WHEN] Run "Adjust Cost - Item Entries" for the production Item "T".
      LibraryCosting.AdjustCostItemEntries(ItemNo[5],'');

      // [THEN] For Item "T": "Last Direct Cost" is updated and equals to "Unit Cost".
      Item.GET(ItemNo[5]);
      Item.TESTFIELD("Last Direct Cost",Item."Unit Cost");
Member of Lib.Library - Manufacturing


ChangeStatusPlannedToFinished@30 Method

The procedure ChangeStatusPlannedToFinished is available in codeunit 132202.

Syntax

ChangeStatusPlannedToFinished@30(
    ProductionOrderNo@1000 : Code[20] ProductionOrderNo //Input parameter of type Code
);

Parameters

ProductionOrderNo
Input parameter of type Code

Return Value

Code[20]

Remarks

The relevant search keywords are: Change, Status, Planned, To, Finished.

For a clarification about how this function works, refer to the code listed below.

      ProductionOrder.GET(ProductionOrder.Status::Planned,ProductionOrderNo);
      ProdOrderStatusManagement.ChangeStatusOnProdOrder(ProductionOrder,ProductionOrder.Status::Released,WORKDATE,FALSE);
      ProductionOrder.SETRANGE(Status,ProductionOrder.Status::Released);
      ProductionOrder.SETRANGE("Source No.",ProductionOrder."Source No.");
      ProductionOrder.FINDFIRST;
      ProdOrderStatusManagement.ChangeStatusOnProdOrder(ProductionOrder,ProductionOrder.Status::Finished,WORKDATE,FALSE);
      EXIT(ProductionOrder."No.");

Example

The below example is extracted from the test automation codeunit 137004 to show one way of using this function.

      // Steps describing the sequence of actions for Test Case.

      // 1. Create required WIP setups with Flushing method as Manual with Subcontract.
      // Update Manufacturing Setup, Inventory Setup and Update Shop Calendar Working Days based on Work Shift code.
      Initialize;
      RaiseConfirmHandler;
      LibraryManufacturing.CreateWorkCenterGroup(WorkCenterGroup);
      LibraryManufacturing.CreateCapacityUnitOfMeasure(CapacityUnitOfMeasure,Type::Minutes);
      LibraryInventory.UpdateInventorySetup(
        InventorySetup,TRUE,FALSE,AutomaticCostAdjustment::Never,AverageCostCalcType::Item,AverageCostPeriod::Day);
      LibraryManufacturing.UpdateManufacturingSetup(ManufacturingSetup,'','',TRUE,TRUE,TRUE);
      ShopCalendarCode := LibraryManufacturing.UpdateShopCalendarWorkingDays;
      IF AdditionalCurrencyExist THEN
        CurrencyCode := UpdateAddnlReportingCurrency
      ELSE
        LibraryERM.SetAddReportingCurrency('');

      // Create Work Center and Machine Center with Flushing method -Manual.
      // Create Work Center for Subcontractor with Flushing method -Manual.
      // Create Routing.
      CreateWorkCenter(WorkCenterNo,ShopCalendarCode,FlushingMethod,FALSE,UnitCostCalculation,'');
      CreateMachineCenter(MachineCenterNo,WorkCenterNo,FlushingMethod);
      CreateMachineCenter(MachineCenterNo2,WorkCenterNo,FlushingMethod);
      IF UpdateProdOrderRouting THEN
        CreateMachineCenter(MachineCenterNo3,WorkCenterNo,FlushingMethod);
      IF Subcontract THEN
        CreateWorkCenter(WorkCenterNo2,ShopCalendarCode,SubcontractFlushingMethod,TRUE,UnitCostCalculation,CurrencyCode)
      ELSE
        CreateWorkCenter(WorkCenterNo2,ShopCalendarCode,FlushingMethod,FALSE,UnitCostCalculation,CurrencyCode);
      RoutingNo := NoSeriesManagement.GetNextNo(ManufacturingSetup."Routing Nos.",WORKDATE,TRUE);
      CreateRouting(RoutingNo,MachineCenterNo,MachineCenterNo2,WorkCenterNo,WorkCenterNo2);

      // Create Items with Flushing method - Manual with the Parent Item containing Routing No. and Production BOM No.
      CreateItem(Item,CostingMethod,Item."Reordering Policy"::"Lot-for-Lot",FlushingMethod,'','');
      ItemNo := Item."No.";
      CLEAR(Item);
      CreateItem(Item,CostingMethod,Item."Reordering Policy"::"Lot-for-Lot",FlushingMethod,'','');
      ItemNo2 := Item."No.";
      CLEAR(Item);
      IF UpdateProductionComponent THEN BEGIN
        CreateItem(Item,Item."Costing Method"::Standard,Item."Reordering Policy"::"Lot-for-Lot",FlushingMethod,'','');
        ItemNo3 := Item."No.";
        CLEAR(Item);
      END;
      ProductionBOMNo :=
        LibraryManufacturing.CreateCertifProdBOMWithTwoComp(
          ProductionBOMHeader,ItemNo,ItemNo2,1); // value imporatant.
      CreateItem(Item,CostingMethod,Item."Reordering Policy"::"Lot-for-Lot",FlushingMethod,RoutingNo,ProductionBOMNo);

      // Calculate Standard Cost for Parent Item, if Costing Method is Standard.
      // Calculate Calendar for Work Center with dates having a difference of 5 weeks.
      // Create and Post Purchase Order as Receive and Invoice.
      IF  Item."Costing Method" = Item."Costing Method"::Standard THEN
        CalculateStandardCost.CalcItem(Item."No.",FALSE);
      CalculateCalendar(MachineCenterNo,MachineCenterNo2,WorkCenterNo,WorkCenterNo2);
      IF NOT AdditionalCurrencyExist THEN
        CreatePurchaseOrder(
          PurchaseHeader,PurchaseLine,ItemNo,ItemNo2,ItemNo3,LibraryRandom.RandInt(100) + 10,
          LibraryRandom.RandInt(100) + 10,LibraryRandom.RandInt(100) + 50,UpdateProductionComponent)
      ELSE
        CreatePurchaseOrderAddnlCurr(PurchaseHeader,PurchaseLine,CurrencyCode,ItemNo,ItemNo2,ItemNo3,
          LibraryRandom.RandInt(100) + 10,UpdateProductionComponent);

      IF AdjustExchangeRatesGLSetup THEN BEGIN
        UpdateExchangeRate(CurrencyCode);
        LibraryERM.RunAdjustExchangeRates(
          CurrencyCode,WORKDATE,WORKDATE,PurchaseHeader."No.",WORKDATE,LibraryUtility.GenerateGUID,TRUE);
      END;

      // Create and Refresh Production Order.
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);
      LibraryManufacturing.CreateProductionOrder(
        ProductionOrder,ProductionOrderStatus,ProductionOrder."Source Type"::Item,Item."No.",LibraryRandom.RandInt(10) + 5);
      LibraryManufacturing.RefreshProdOrder(ProductionOrder,FALSE,TRUE,TRUE,TRUE,FALSE);
      IF UpdateProdOrderRouting THEN BEGIN
        MachineCenter.GET(MachineCenterNo3);
        LibraryManufacturing.CalculateMachCenterCalendar(MachineCenter,CALCDATE('<-1M>',WORKDATE),CALCDATE('<1M>',WORKDATE));
        AddProdOrderRoutingLine(ProductionOrder,ProductionOrderRoutingType::"Machine Center",MachineCenterNo3);
        LibraryManufacturing.RefreshProdOrder(ProductionOrder,FALSE,FALSE,FALSE,TRUE,FALSE);
      END;

      // Create Subcontracting Worksheet, Make order and Post Subcontracting Purchase Order.
      IF Subcontract THEN BEGIN
        LibraryManufacturing.CalculateSubcontractOrder(WorkCenter);
        MakeSubconPurchOrder(ProductionOrder."No.",WorkCenterNo2);
        PostSubconPurchOrder(TempPurchaseLine,ProductionOrder."No.",SubcontractCostDiff);
      END;

      // Remove one component from Production Order and Replace it with a New Component.
      IF UpdateProductionComponent THEN
        ReplaceProdOrderComponent(ProductionOrder."No.",ItemNo2,Item."No.",ItemNo3);

      // Create, Calculate and Post Consumption Journal, Explode Routing and Post Output Journal.
      IF Item."Flushing Method" = Item."Flushing Method"::Manual THEN BEGIN
        LibraryInventory.CreateItemJournal(
          ItemJournalBatch,ItemNo,ItemJournalBatch."Template Type"::Consumption,ProductionOrder."No.");
        IF DeleteConsumptionJrnl THEN
          RemoveProdOrderComponent(ProductionOrder."No.",ItemNo);
        IF ConsumptionCostDiff THEN
          UpdateQtyConsumptionJournal(ProductionOrder."No.",ItemNo2);
        LibraryInventory.PostItemJournalLine(ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name);
        LibraryInventory.CreateItemJournal(ItemJournalBatch,ItemNo3,ItemJournalBatch."Template Type"::Output,ProductionOrder."No.");
        IF OutputCostDiff THEN
          UpdateLessQtyOutputJournal(ProductionOrder."No.",ProductionOrder.Quantity);
        IF RunSetupTimeCostDiff THEN BEGIN
          SetupTime := 1;
          RunTime := 1;
          UpdateSetupRunTime(ProductionOrder."No.",SetupTime,RunTime);
        END;
        LibraryInventory.PostItemJournalLine(ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name);
      END;

      // Change Production Order Status.
      IF ProductionOrder.Status = ProductionOrder.Status::Planned THEN
        ProductionOrderNo :=
          LibraryManufacturing.ChangeStatusPlannedToFinished(ProductionOrder."No.") // Change Status from Planned to Finished.
      ELSE
        LibraryManufacturing.ChangeStatusReleasedToFinished(ProductionOrder."No.");
      // Change Status of Production Order from Released to Finished.

      // 2. Execute Adjust Cost Item Entries report and Post Inventory Cost to G/L report.
      ProductionOrder.SETRANGE(Status,ProductionOrder.Status::Finished);
      IF ProductionOrderNo <> '' THEN
        ProductionOrder.SETRANGE("No.",ProductionOrderNo)
      ELSE
        ProductionOrder.SETRANGE("No.",ProductionOrder."No.");
      ProductionOrder.FINDFIRST;
      AdjustCostPostInventoryCostGL(ItemNo + '..' + ItemNo3);

      // 3. Verify GL Entry : Total amount and Positive amount entries for WIP Account.
      VerifyGLEntryForWIPAccounts(
        TempPurchaseLine,ItemNo,ProductionOrder."No.",CurrencyCode,SetupTime,RunTime,AdditionalCurrencyExist);

      // 4.Tear Down.
      TearDown(AdditionalCurrencyExist,Subcontract,Item."No.");
Member of Lib.Library - Manufacturing


ChangeStatusReleasedToFinished@48 Method

The procedure ChangeStatusReleasedToFinished is available in codeunit 132202.

Syntax

ChangeStatusReleasedToFinished@48(
    ProductionOrderNo@1000 : Code[20] ProductionOrderNo //Input parameter of type Code
);

Parameters

ProductionOrderNo
Input parameter of type Code

Remarks

The relevant search keywords are: Change, Status, Released, To, Finished.

For a clarification about how this function works, refer to the code listed below.

      ProductionOrder.GET(ProductionOrder.Status::Released,ProductionOrderNo);
      ProdOrderStatusManagement.ChangeStatusOnProdOrder(ProductionOrder,ProductionOrder.Status::Finished,WORKDATE,FALSE);

Example

The below example is extracted from the test automation codeunit 137001 to show one way of using this function.

      // [FEATURE] [Adjust Cost Item Entries] [Item Charges] [Production] [Purchase] [Cost Average]
      // [SCENARIO] Check Unit cost and Value entries for Item with Average costing method after purchase, production and Adjust Cost

      // [GIVEN] Demo data, "Automatic Cost Adjustment": Month, "Average Cost Calc. Type": Item.
      Initialize;

      SetupParameters(InventorySetup."Automatic Cost Adjustment"::Month,InventorySetup."Average Cost Calc. Type"::Item);

      // [GIVEN] Component item with costing method Average.
      CreateItem(Item1,Item1."Costing Method"::Average,Item1."Replenishment System"::Purchase);

      // [GIVEN] Posted purchase order for component item.
      CreateSingleLinePurchaseOrder(PurchaseHeader,Item1."No.",PurchaseLine.Type::Item);
      PostPurchaseOrder(PurchInvHeader,PurchaseHeader);

      // [GIVEN] BOM with component item on line.
      CreateSingleLineBOM(ProductionBOMHeader,Item1);
      // [GIVEN] Single line routing for a random work center.
      CreateSingleLineRouting(RoutingHeader);

      // [GIVEN] Parent item with costing method Average.
      CreateItem(Item,Item."Costing Method"::Average,Item."Replenishment System"::"Prod. Order");
      // [GIVEN] Routing and BOM assigned to parent item.
      Item.VALIDATE("Routing No.",RoutingHeader."No.");
      Item.VALIDATE("Production BOM No.",ProductionBOMHeader."No.");
      Item.VALIDATE("Flushing Method",Item."Flushing Method"::Manual);
      Item.MODIFY(TRUE);

      Item1.CALCFIELDS(Inventory);
      ProductionOrder.DELETEALL;

      // [GIVEN] Created and refreshed production order for parent item.
      LibraryManufacturing.CreateProductionOrder(ProductionOrder,ProductionOrder.Status::Released,ProductionOrder."Source Type"::Item,
        Item."No.",Item1.Inventory);
      LibraryManufacturing.RefreshProdOrder(ProductionOrder,FALSE,TRUE,TRUE,TRUE,FALSE);

      // [GIVEN] Consumption and output posted.
      PostProductionOrder(TempItemJournalLine,ProductionOrder."No.",ItemJournalTemplate.Type::Consumption);
      PostProductionOrder(TempItemJournalLine,ProductionOrder."No.",ItemJournalTemplate.Type::Output);
      // [GIVEN] Production order finished.
      LibraryManufacturing.ChangeStatusReleasedToFinished(ProductionOrder."No.");

      // [GIVEN] Item charge added to production order through a purchase order.
      LibraryInventory.CreateItemCharge(ItemCharge);
      CreateSingleLinePurchaseOrder(PurchaseHeader,ItemCharge."No.",PurchaseLine.Type::"Charge (Item)");
      AssignItemCharges(PurchaseHeader,Item1."No.");
      PostPurchaseOrder(PurchInvHeader1,PurchaseHeader);

      // [WHEN] Adjust cost-item entries is run.
      LibraryCosting.AdjustCostItemEntries(ProductionOrder."Source No.",'');

      // [THEN] Unit cost and value entries for parent item are correct.
      CheckOutputValueEntries(PurchInvHeader,PurchInvHeader1,ProductionOrder,TempItemJournalLine);
      CheckAverageCost(Item."No.");

      // [THEN] Number of entries for parent item are correct.
      Assert.AreEqual(
        GetNoOfEntries(
          Item."No.",
          ValueEntry."Item Ledger Entry Type"::Output,
          ValueEntry."Entry Type"::"Direct Cost",
          ValueEntry."Document Type"::" "),3,STRSUBSTNO(ErrorValueEntries,2,'Output','Direct Cost','',Item."No."));

      // Tear Down.
      SetupParameters(InventorySetup."Automatic Cost Adjustment"::Never,InventorySetup."Average Cost Calc. Type"::Item);
Member of Lib.Library - Manufacturing


ChangeStatusSimulatedToReleased@18 Method

The procedure ChangeStatusSimulatedToReleased is available in codeunit 132202.

Syntax

ChangeStatusSimulatedToReleased@18(
    ProductionOrderNo@1003 : Code[20] ProductionOrderNo //Input parameter of type Code
);

Parameters

ProductionOrderNo
Input parameter of type Code

Return Value

Code[20]

Remarks

The relevant search keywords are: Change, Status, Simulated, To, Released.

For a clarification about how this function works, refer to the code listed below.

      EXIT(ChangeStatusFirmPlanToReleased(ProductionOrderNo,ProductionOrder.Status::Simulated,ProductionOrder.Status::Released));

Example

The below example is extracted from the test automation codeunit 137069 to show one way of using this function.

      // Create Production Item with dimension and update dimension on Production Order Line and Production Order Component.
      CreateProductionItemWithDimensionSetup(Item,Item2,DimensionValue,DimensionValue2);
      CreateAndRefreshSimulatedProductionOrder(ProductionOrder,Item."No.",LibraryRandom.RandDec(10,2));

      IF DimensionUpdateOnProductionOrderLine THEN
        UpdateDimensionOnProductionOrderLine(DimensionValue3,ProductionOrder)
      ELSE
        UpdateDimensionOnProdOrderComponent(DimensionValue3,ProductionOrder,Item2."No.");

      // Exercise: Change Status of the Production Order - Simulated to Released.
      ProductionOrderNo := LibraryManufacturing.ChangeStatusSimulatedToReleased(ProductionOrder."No.");

      // Verify: Verify Dimension on Production Order Line and Production Order Component.
      VerifyDimensionOnProductionOrderLine(ProductionOrder.Status::Released,ProductionOrderNo,DimensionValue);
      VerifyDimensionOnProdOrderComponent(ProductionOrder.Status::Released,ProductionOrderNo,Item2."No.",DimensionValue); // TFS 322868 and 322869

      IF DimensionUpdateOnProductionOrderLine THEN
        VerifyDimensionOnProductionOrderLine(ProductionOrder.Status::Released,ProductionOrderNo,DimensionValue3)
      ELSE
        VerifyDimensionOnProdOrderComponent(ProductionOrder.Status::Released,ProductionOrderNo,Item2."No.",DimensionValue3);
Member of Lib.Library - Manufacturing


CreateAndRefreshProductionOrder@46 Method

The procedure CreateAndRefreshProductionOrder is available in codeunit 132202.

Syntax

CreateAndRefreshProductionOrder@46(
    VAR ProductionOrder@1000 : Record 5405 ProductionOrder, //Reference parameter of type Record
    ProdOrderStatus@1001 : Option ProdOrderStatus, //Input parameter of type Option
    SourceType@1002 : Option SourceType, //Input parameter of type Option
    SourceNo@1003 : Code[20] SourceNo, //Input parameter of type Code
    Quantity@1004 : Decimal Quantity //Input parameter of type Decimal
);

Parameters

ProductionOrder
Reference parameter of type Record
ProdOrderStatus
Input parameter of type Option
SourceType
Input parameter of type Option
SourceNo
Input parameter of type Code
Quantity
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Refresh, Production, Order.

For a clarification about how this function works, refer to the code listed below.

      CreateProductionOrder(ProductionOrder,ProdOrderStatus,SourceType,SourceNo,Quantity);
      RefreshProdOrder(ProductionOrder,FALSE,TRUE,TRUE,TRUE,FALSE);

Example

The below example is extracted from the test automation codeunit 137082 to show one way of using this function.

      // [FEATURE] [Parallel Routing] [Capacity]
      // [SCENARIO 272988] Production order routing line is recalculated when the work center is changed for the parallel routing

      Initialize;

      // [GIVEN] Two work centers: "W1" with "Unit Cost" = 10, and "W2" with "Unit Cost" = 20 and "Overhead Rate" = 5
      CreateWorkCenterWithCost(WorkCenter[1],LibraryRandom.RandInt(10),0);
      CreateWorkCenterWithCost(WorkCenter[2],LibraryRandom.RandIntInRange(15,25),LibraryRandom.RandInt(5));

      // [GIVEN] Parallel routing with a single line on the work center "W1", "Run Time" = 30 min
      LibraryManufacturing.CreateRoutingHeader(RoutingHeader,RoutingHeader.Type::Parallel);
      LibraryManufacturing.CreateRoutingLine(RoutingHeader,RoutingLine,'','100',RoutingLine.Type::"Work Center",WorkCenter[1]."No.");
      RoutingLine.VALIDATE("Run Time",LibraryRandom.RandInt(100));
      RoutingLine.MODIFY(TRUE);
      LibraryManufacturing.UpdateRoutingStatus(RoutingHeader,RoutingHeader.Status::Certified);

      // [GIVEN] Item with the parallel routing assigned
      CreateItemWithRouting(Item,RoutingHeader."No.");

      // [GIVEN] Create and refresh a released production order for 3 pcs of the manufactured item
      LibraryManufacturing.CreateAndRefreshProductionOrder(
        ProductionOrder,ProductionOrder.Status::Released,ProductionOrder."Source Type"::Item,Item."No.",LibraryRandom.RandInt(100));
      ProdOrderRoutingLine.SETRANGE("Prod. Order No.",ProductionOrder."No.");
      ProdOrderRoutingLine.SETRANGE("Operation No.",'100');
      ProdOrderRoutingLine.FINDFIRST;

      // [WHEN] Open the prod. order routing and change the work center from "W1" to "W2"
      ProdOrderRoutingLine.VALIDATE("No.",WorkCenter[2]."No.");
      ProdOrderRoutingLine.MODIFY(TRUE);

      // [THEN] Capacity requirements and costs are recalculated for the production order.
      // [THEN] Expected operation cost is 3 * 30 * 20 = 1800; Expected capacity overhead is 3 * 30 * 5 = 450
      ProdOrderRoutingLine.FIND;
      ProdOrderRoutingLine.TESTFIELD(
        "Expected Operation Cost Amt.",ProductionOrder.Quantity * RoutingLine."Run Time" * WorkCenter[2]."Unit Cost");
      ProdOrderRoutingLine.TESTFIELD(
        "Expected Capacity Ovhd. Cost",ProductionOrder.Quantity * RoutingLine."Run Time" * WorkCenter[2]."Overhead Rate");
Member of Lib.Library - Manufacturing


CreateBOMComponent@1 Method

The procedure CreateBOMComponent is available in codeunit 132202.

Syntax

CreateBOMComponent@1(
    VAR BOMComponent@1000 : Record 90 BOMComponent, //Reference parameter of type Record
    ParentItemNo@1001 : Code[20] ParentItemNo, //Input parameter of type Code
    Type@1003 : Option Type, //Input parameter of type Option
    No@1004 : Code[20] No, //Input parameter of type Code
    QuantityPer@1006 : Decimal QuantityPer, //Input parameter of type Decimal
    UnitOfMeasureCode@1005 : Code[10] UnitOfMeasureCode //Input parameter of type Code
);

Parameters

BOMComponent
Reference parameter of type Record
ParentItemNo
Input parameter of type Code
Type
Input parameter of type Option
No
Input parameter of type Code
QuantityPer
Input parameter of type Decimal
UnitOfMeasureCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, BOM, Component.

For a clarification about how this function works, refer to the code listed below.

      BOMComponent.INIT;
      BOMComponent.VALIDATE("Parent Item No.",ParentItemNo);
      RecRef.GETTABLE(BOMComponent);
      BOMComponent.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,BOMComponent.FIELDNO("Line No.")));
      BOMComponent.INSERT(TRUE);
      BOMComponent.VALIDATE(Type,Type);
      IF BOMComponent.Type <> BOMComponent.Type::" " THEN BEGIN
        BOMComponent.VALIDATE("No.",No);
        BOMComponent.VALIDATE("Quantity per",QuantityPer);
        IF UnitOfMeasureCode <> '' THEN
          BOMComponent.VALIDATE("Unit of Measure Code",UnitOfMeasureCode);
      END;
      BOMComponent.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 136103 to show one way of using this function.

      // Create BOM Component with random Unit of Measure.
      ItemUnitOfMeasure.INIT;
      ItemUnitOfMeasure.SETRANGE("Item No.",ItemNo);
      RecRef.GETTABLE(ItemUnitOfMeasure);
      LibraryUtility.FindRecord(RecRef);
      RecRef.SETTABLE(ItemUnitOfMeasure);

      LibraryManufacturing.CreateBOMComponent(
        BOMComponent,ParentItemNo,BOMComponent.Type::Item,ItemNo,RANDOM(10),ItemUnitOfMeasure.Code);
Member of Lib.Library - Manufacturing


CreateCalendarAbsenceEntry@9 Method

The procedure CreateCalendarAbsenceEntry is available in codeunit 132202.

Syntax

CreateCalendarAbsenceEntry@9(
    VAR CalendarAbsenceEntry@1000 : Record 99000760 CalendarAbsenceEntry, //Reference parameter of type Record
    CapacityType@1001 : Option CapacityType, //Input parameter of type Option
    No@1002 : Code[20] No, //Input parameter of type Code
    Date@1003 : Date Date, //Input parameter of type Date
    StartingTime@1004 : Time StartingTime, //Input parameter of type Time
    EndingTime@1005 : Time EndingTime, //Input parameter of type Time
    Capacity@1006 : Decimal Capacity //Input parameter of type Decimal
);

Parameters

CalendarAbsenceEntry
Reference parameter of type Record
CapacityType
Input parameter of type Option
No
Input parameter of type Code
Date
Input parameter of type Date
StartingTime
Input parameter of type Time
EndingTime
Input parameter of type Time
Capacity
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Calendar, Absence, Entry.

For a clarification about how this function works, refer to the code listed below.

      CalendarAbsenceEntry.INIT;
      CalendarAbsenceEntry.VALIDATE("Capacity Type",CapacityType);
      CalendarAbsenceEntry.VALIDATE("No.",No);
      CalendarAbsenceEntry.VALIDATE(Date,Date);
      CalendarAbsenceEntry.VALIDATE("Starting Time",StartingTime);
      CalendarAbsenceEntry.VALIDATE("Ending Time",EndingTime);
      CalendarAbsenceEntry.INSERT(TRUE);
      CalendarAbsenceEntry.VALIDATE(Capacity,Capacity);
      CalendarAbsenceEntry.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137080 to show one way of using this function.

      LibraryManufacturing.CreateCalendarAbsenceEntry(
        CalendarAbsenceEntry,CalendarAbsenceEntry."Capacity Type"::"Work Center",WorkCenter."No.",
        AbsenceDate,AbsenceFromTime,AbsenceToTime,1);
      LibraryManufacturing.CalculateWorkCenterCalendar(WorkCenter,CalendarFromDate,CalendarToDate);
Member of Lib.Library - Manufacturing


CreateCapacityConstrainedResource@131 Method

The procedure CreateCapacityConstrainedResource is available in codeunit 132202.

Syntax

CreateCapacityConstrainedResource@131(
    VAR CapacityConstrainedResource@1000 : Record 99000866 CapacityConstrainedResource, //Reference parameter of type Record
    CapacityType@1001 : Option CapacityType, //Input parameter of type Option
    CapacityNo@1002 : Code[20] CapacityNo //Input parameter of type Code
);

Parameters

CapacityConstrainedResource
Reference parameter of type Record
CapacityType
Input parameter of type Option
CapacityNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Capacity, Constrained, Resource.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(CapacityConstrainedResource);
      CapacityConstrainedResource.INIT;
      CapacityConstrainedResource.VALIDATE("Capacity Type",CapacityType);
      CapacityConstrainedResource.VALIDATE("Capacity No.",CapacityNo);
      CapacityConstrainedResource.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137063 to show one way of using this function.

      LibraryManufacturing.CreateCapacityConstrainedResource(
        CapacityConstrainedResource,CapacityConstrainedResource."Capacity Type"::"Work Center",WorkCenterNo);
      CapacityConstrainedResource.VALIDATE("Critical Load %",100);  // Value important for Test.
      CapacityConstrainedResource.MODIFY(TRUE);
Member of Lib.Library - Manufacturing


CreateCapacityUnitOfMeasure@28 Method

The procedure CreateCapacityUnitOfMeasure is available in codeunit 132202.

Syntax

CreateCapacityUnitOfMeasure@28(
    VAR CapacityUnitOfMeasure@1000 : Record 99000780 CapacityUnitOfMeasure, //Reference parameter of type Record
    Type@1001 : Integer Type //Input parameter of type Integer
);

Parameters

CapacityUnitOfMeasure
Reference parameter of type Record
Type
Input parameter of type Integer

Remarks

The relevant search keywords are: Create, Capacity, Unit, Of, Measure.

For a clarification about how this function works, refer to the code listed below.

      CapacityUnitOfMeasure.INIT;
      CapacityUnitOfMeasure.VALIDATE(
        Code,LibraryUtility.GenerateRandomCode(CapacityUnitOfMeasure.FIELDNO(Code),DATABASE::"Capacity Unit of Measure"));
      CapacityUnitOfMeasure.INSERT(TRUE);
      CapacityUnitOfMeasure.VALIDATE(Type,Type);
      CapacityUnitOfMeasure.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137004 to show one way of using this function.

      // Steps describing the sequence of actions for Test Case.

      // 1. Create required WIP setups with Flushing method as Manual with Subcontract.
      // Update Manufacturing Setup, Inventory Setup and Update Shop Calendar Working Days based on Work Shift code.
      Initialize;
      RaiseConfirmHandler;
      LibraryManufacturing.CreateWorkCenterGroup(WorkCenterGroup);
      LibraryManufacturing.CreateCapacityUnitOfMeasure(CapacityUnitOfMeasure,Type::Minutes);
      LibraryInventory.UpdateInventorySetup(
        InventorySetup,TRUE,FALSE,AutomaticCostAdjustment::Never,AverageCostCalcType::Item,AverageCostPeriod::Day);
      LibraryManufacturing.UpdateManufacturingSetup(ManufacturingSetup,'','',TRUE,TRUE,TRUE);
      ShopCalendarCode := LibraryManufacturing.UpdateShopCalendarWorkingDays;
      IF AdditionalCurrencyExist THEN
        CurrencyCode := UpdateAddnlReportingCurrency
      ELSE
        LibraryERM.SetAddReportingCurrency('');

      // Create Work Center and Machine Center with Flushing method -Manual.
      // Create Work Center for Subcontractor with Flushing method -Manual.
      // Create Routing.
      CreateWorkCenter(WorkCenterNo,ShopCalendarCode,FlushingMethod,FALSE,UnitCostCalculation,'');
      CreateMachineCenter(MachineCenterNo,WorkCenterNo,FlushingMethod);
      CreateMachineCenter(MachineCenterNo2,WorkCenterNo,FlushingMethod);
      IF UpdateProdOrderRouting THEN
        CreateMachineCenter(MachineCenterNo3,WorkCenterNo,FlushingMethod);
      IF Subcontract THEN
        CreateWorkCenter(WorkCenterNo2,ShopCalendarCode,SubcontractFlushingMethod,TRUE,UnitCostCalculation,CurrencyCode)
      ELSE
        CreateWorkCenter(WorkCenterNo2,ShopCalendarCode,FlushingMethod,FALSE,UnitCostCalculation,CurrencyCode);
      RoutingNo := NoSeriesManagement.GetNextNo(ManufacturingSetup."Routing Nos.",WORKDATE,TRUE);
      CreateRouting(RoutingNo,MachineCenterNo,MachineCenterNo2,WorkCenterNo,WorkCenterNo2);

      // Create Items with Flushing method - Manual with the Parent Item containing Routing No. and Production BOM No.
      CreateItem(Item,CostingMethod,Item."Reordering Policy"::"Lot-for-Lot",FlushingMethod,'','');
      ItemNo := Item."No.";
      CLEAR(Item);
      CreateItem(Item,CostingMethod,Item."Reordering Policy"::"Lot-for-Lot",FlushingMethod,'','');
      ItemNo2 := Item."No.";
      CLEAR(Item);
      IF UpdateProductionComponent THEN BEGIN
        CreateItem(Item,Item."Costing Method"::Standard,Item."Reordering Policy"::"Lot-for-Lot",FlushingMethod,'','');
        ItemNo3 := Item."No.";
        CLEAR(Item);
      END;
      ProductionBOMNo :=
        LibraryManufacturing.CreateCertifProdBOMWithTwoComp(
          ProductionBOMHeader,ItemNo,ItemNo2,1); // value imporatant.
      CreateItem(Item,CostingMethod,Item."Reordering Policy"::"Lot-for-Lot",FlushingMethod,RoutingNo,ProductionBOMNo);

      // Calculate Standard Cost for Parent Item, if Costing Method is Standard.
      // Calculate Calendar for Work Center with dates having a difference of 5 weeks.
      // Create and Post Purchase Order as Receive and Invoice.
      IF  Item."Costing Method" = Item."Costing Method"::Standard THEN
        CalculateStandardCost.CalcItem(Item."No.",FALSE);
      CalculateCalendar(MachineCenterNo,MachineCenterNo2,WorkCenterNo,WorkCenterNo2);
      IF NOT AdditionalCurrencyExist THEN
        CreatePurchaseOrder(
          PurchaseHeader,PurchaseLine,ItemNo,ItemNo2,ItemNo3,LibraryRandom.RandInt(100) + 10,
          LibraryRandom.RandInt(100) + 10,LibraryRandom.RandInt(100) + 50,UpdateProductionComponent)
      ELSE
        CreatePurchaseOrderAddnlCurr(PurchaseHeader,PurchaseLine,CurrencyCode,ItemNo,ItemNo2,ItemNo3,
          LibraryRandom.RandInt(100) + 10,UpdateProductionComponent);

      IF AdjustExchangeRatesGLSetup THEN BEGIN
        UpdateExchangeRate(CurrencyCode);
        LibraryERM.RunAdjustExchangeRates(
          CurrencyCode,WORKDATE,WORKDATE,PurchaseHeader."No.",WORKDATE,LibraryUtility.GenerateGUID,TRUE);
      END;

      // Create and Refresh Production Order.
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);
      LibraryManufacturing.CreateProductionOrder(
        ProductionOrder,ProductionOrderStatus,ProductionOrder."Source Type"::Item,Item."No.",LibraryRandom.RandInt(10) + 5);
      LibraryManufacturing.RefreshProdOrder(ProductionOrder,FALSE,TRUE,TRUE,TRUE,FALSE);
      IF UpdateProdOrderRouting THEN BEGIN
        MachineCenter.GET(MachineCenterNo3);
        LibraryManufacturing.CalculateMachCenterCalendar(MachineCenter,CALCDATE('<-1M>',WORKDATE),CALCDATE('<1M>',WORKDATE));
        AddProdOrderRoutingLine(ProductionOrder,ProductionOrderRoutingType::"Machine Center",MachineCenterNo3);
        LibraryManufacturing.RefreshProdOrder(ProductionOrder,FALSE,FALSE,FALSE,TRUE,FALSE);
      END;

      // Create Subcontracting Worksheet, Make order and Post Subcontracting Purchase Order.
      IF Subcontract THEN BEGIN
        LibraryManufacturing.CalculateSubcontractOrder(WorkCenter);
        MakeSubconPurchOrder(ProductionOrder."No.",WorkCenterNo2);
        PostSubconPurchOrder(TempPurchaseLine,ProductionOrder."No.",SubcontractCostDiff);
      END;

      // Remove one component from Production Order and Replace it with a New Component.
      IF UpdateProductionComponent THEN
        ReplaceProdOrderComponent(ProductionOrder."No.",ItemNo2,Item."No.",ItemNo3);

      // Create, Calculate and Post Consumption Journal, Explode Routing and Post Output Journal.
      IF Item."Flushing Method" = Item."Flushing Method"::Manual THEN BEGIN
        LibraryInventory.CreateItemJournal(
          ItemJournalBatch,ItemNo,ItemJournalBatch."Template Type"::Consumption,ProductionOrder."No.");
        IF DeleteConsumptionJrnl THEN
          RemoveProdOrderComponent(ProductionOrder."No.",ItemNo);
        IF ConsumptionCostDiff THEN
          UpdateQtyConsumptionJournal(ProductionOrder."No.",ItemNo2);
        LibraryInventory.PostItemJournalLine(ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name);
        LibraryInventory.CreateItemJournal(ItemJournalBatch,ItemNo3,ItemJournalBatch."Template Type"::Output,ProductionOrder."No.");
        IF OutputCostDiff THEN
          UpdateLessQtyOutputJournal(ProductionOrder."No.",ProductionOrder.Quantity);
        IF RunSetupTimeCostDiff THEN BEGIN
          SetupTime := 1;
          RunTime := 1;
          UpdateSetupRunTime(ProductionOrder."No.",SetupTime,RunTime);
        END;
        LibraryInventory.PostItemJournalLine(ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name);
      END;

      // Change Production Order Status.
      IF ProductionOrder.Status = ProductionOrder.Status::Planned THEN
        ProductionOrderNo :=
          LibraryManufacturing.ChangeStatusPlannedToFinished(ProductionOrder."No.") // Change Status from Planned to Finished.
      ELSE
        LibraryManufacturing.ChangeStatusReleasedToFinished(ProductionOrder."No.");
      // Change Status of Production Order from Released to Finished.

      // 2. Execute Adjust Cost Item Entries report and Post Inventory Cost to G/L report.
      ProductionOrder.SETRANGE(Status,ProductionOrder.Status::Finished);
      IF ProductionOrderNo <> '' THEN
        ProductionOrder.SETRANGE("No.",ProductionOrderNo)
      ELSE
        ProductionOrder.SETRANGE("No.",ProductionOrder."No.");
      ProductionOrder.FINDFIRST;
      AdjustCostPostInventoryCostGL(ItemNo + '..' + ItemNo3);

      // 3. Verify GL Entry : Total amount and Positive amount entries for WIP Account.
      VerifyGLEntryForWIPAccounts(
        TempPurchaseLine,ItemNo,ProductionOrder."No.",CurrencyCode,SetupTime,RunTime,AdditionalCurrencyExist);

      // 4.Tear Down.
      TearDown(AdditionalCurrencyExist,Subcontract,Item."No.");
Member of Lib.Library - Manufacturing


CreateCertifiedProductionBOM@139 Method

The procedure CreateCertifiedProductionBOM is available in codeunit 132202.

Syntax

CreateCertifiedProductionBOM@139(
    VAR ProductionBOMHeader@1006 : Record 99000771 ProductionBOMHeader, //Reference parameter of type Record
    ItemNo@1000 : Code[20] ItemNo, //Input parameter of type Code
    QuantityPer@1004 : Decimal QuantityPer //Input parameter of type Decimal
);

Parameters

ProductionBOMHeader
Reference parameter of type Record
ItemNo
Input parameter of type Code
QuantityPer
Input parameter of type Decimal

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Certified, Production, BOM.

For a clarification about how this function works, refer to the code listed below.

      Item.GET(ItemNo);
      CreateProductionBOMHeader(ProductionBOMHeader,Item."Base Unit of Measure");
      CreateProductionBOMLine(ProductionBOMHeader,ProductionBOMLine,'',ProductionBOMLine.Type::Item,ItemNo,QuantityPer);
      UpdateProductionBOMStatus(ProductionBOMHeader,ProductionBOMHeader.Status::Certified);
      EXIT(ProductionBOMHeader."No.");

Example

The below example is extracted from the test automation codeunit 137003 to show one way of using this function.

      CompItemNo := LibraryInventory.CreateItemNo;
      LibraryInventory.CreateItem(ProdItem);
      LibraryManufacturing.CreateCertifiedProductionBOM(ProductionBOMHeader,CompItemNo,1);
      LibraryManufacturing.CreateItemManufacturing(
        ProdItem,CostingMethod::FIFO,0,ProdItem."Reordering Policy"::" ",FlushingMethod::Manual,'',ProductionBOMHeader."No.");
Member of Lib.Library - Manufacturing


CreateCertifProdBOMWithTwoComp@11 Method

The procedure CreateCertifProdBOMWithTwoComp is available in codeunit 132202.

Syntax

CreateCertifProdBOMWithTwoComp@11(
    VAR ProductionBOMHeader@1001 : Record 99000771 ProductionBOMHeader, //Reference parameter of type Record
    ItemNo@1002 : Code[20] ItemNo, //Input parameter of type Code
    ItemNo2@1003 : Code[20] ItemNo2, //Input parameter of type Code
    QuantityPer@1005 : Decimal QuantityPer //Input parameter of type Decimal
);

Parameters

ProductionBOMHeader
Reference parameter of type Record
ItemNo
Input parameter of type Code
ItemNo2
Input parameter of type Code
QuantityPer
Input parameter of type Decimal

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Certif, Product, BOM, Two, Comp.

For a clarification about how this function works, refer to the code listed below.

      // Create Production BOM.
      Item.GET(ItemNo);
      CreateProductionBOMHeader(ProductionBOMHeader,Item."Base Unit of Measure");
      CreateProductionBOMLine(ProductionBOMHeader,ProductionBOMLine,'',ProductionBOMLine.Type::Item,ItemNo,QuantityPer);
      CreateProductionBOMLine(ProductionBOMHeader,ProductionBOMLine,'',ProductionBOMLine.Type::Item,ItemNo2,QuantityPer);
      UpdateProductionBOMStatus(ProductionBOMHeader,ProductionBOMHeader.Status::Certified);
      EXIT(ProductionBOMHeader."No.");

Example

The below example is extracted from the test automation codeunit 137003 to show one way of using this function.

      // Update Manufacturing Setup, Inventory Setup and Update Shop Calendar Working Days based on Work Shift code.
      Initialize;
      LibraryManufacturing.UpdateManufacturingSetup(ManufacturingSetup,'','',TRUE,TRUE,TRUE);
      LibraryInventory.UpdateInventorySetup(
        InventorySetup,AutoCostPosting,FALSE,AutomaticCostAdjustment::Never,AverageCostCalcType::Item,AverageCostPeriod::Day);

      // Create Work Center and Machine Center with required Flushing method and Create Routing.
      CreateWorkCenter(WorkCenterNo,FlushingMethod);
      CreateMachineCenter(
        MachineCenter,WorkCenterNo,FlushingMethod,1,
        LibraryRandom.RandDec(10,2),LibraryRandom.RandDec(5,2),
        LibraryRandom.RandDec(5,2));  // Capacity important for Test.
      IF NewRouting THEN
        CreateMachineCenter(
          MachineCenter2,WorkCenterNo,FlushingMethod::Manual,1,
          LibraryRandom.RandDec(10,2),LibraryRandom.RandDec(5,2),
          LibraryRandom.RandDec(5,2));
      RoutingNo := NoSeriesManagement.GetNextNo(ManufacturingSetup."Routing Nos.",WORKDATE,TRUE);
      CreateRouting(WorkCenterNo,MachineCenter."No.",RoutingNo);

      // Create Items with the required Flushing method with the main Item containing Routing No. and Production BOM No.
      CreateComponentItems(ItemNo,ItemNo2,CostingMethod,FlushingMethod,GetAmtPrecFromGLSetup);
      ProductionBOMNo :=
        LibraryManufacturing.CreateCertifProdBOMWithTwoComp(
          ProductionBOMHeader,ItemNo,ItemNo2,1);  // Quantity Per important for Test.
      CreateItem(
        Item,CostingMethod,Item."Reordering Policy"::"Lot-for-Lot",FlushingMethod,
        RoutingNo,ProductionBOMNo,GetAmtPrecFromGLSetup);
      ItemNo3 := Item."No.";
      CLEAR(Item);
      IF NewProdComponent THEN BEGIN
        CreateItem(
          Item,CostingMethod,Item."Reordering Policy"::"Lot-for-Lot",FlushingMethod,'','',GetAmtPrecFromGLSetup);
        ItemNo4 := Item."No.";
      END;

      // Calculate Standard Cost for the main Item and calculate Calendar for Machine Center and Work Center.
      IF CostingMethod = CostingMethod::Standard THEN
        CalculateStandardCost.CalcItem(ItemNo3,FALSE);
      CalculateMachineCntrCalendar(MachineCenter."No.");
      IF NewRouting THEN
        CalculateMachineCntrCalendar(MachineCenter2."No.");
      CalculateWorkCntrCalendar(WorkCenterNo);

      Qty := LibraryRandom.RandInt(10) + 50;
      IF NOT PartialPurchasePosting THEN
        CreatePurchaseOrder(PurchaseHeader,PurchaseLine,ItemNo,ItemNo2,Qty,Qty,DirectUnitCost)
      ELSE
        CreatePurchaseOrder(PurchaseHeader,PurchaseLine,ItemNo,ItemNo2,Qty,Qty - 1,DirectUnitCost);
      IF NewProdComponent THEN
        CreatePurchaseLine(PurchaseLine,PurchaseHeader,ItemNo4,Qty,Qty,TRUE);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,Invoice);

      // If only Purchase Order required then exit this function.
      IF PurchaseOnly THEN
        EXIT;

      IF NOT NewProdComponent THEN
        LibraryManufacturing.CreateProductionOrder(
          ProductionOrder,ProductionOrder.Status::Released,ProductionOrder."Source Type"::Item,ItemNo3,
          LibraryRandom.RandInt(9) + 1)
      ELSE
        LibraryManufacturing.CreateProductionOrder(
          ProductionOrder,ProductionOrder.Status::Planned,ProductionOrder."Source Type"::Item,ItemNo3,
          LibraryRandom.RandInt(9) + 1);
      LibraryManufacturing.RefreshProdOrder(ProductionOrder,FALSE,TRUE,TRUE,TRUE,FALSE);
      ProductionOrderNo := ProductionOrder."No.";
      IF NewRouting THEN BEGIN
        AddProdOrderRoutingLine(ProductionOrder,ProdOrderRoutingLineType::"Machine Center",MachineCenter2."No.");
        LibraryManufacturing.RefreshProdOrder(ProductionOrder,FALSE,FALSE,FALSE,TRUE,FALSE);  // Calculate Lines & Routings are FALSE
      END;

      IF NewProdComponent THEN
        ReplaceProdOrderComponent(ProductionOrderNo,ItemNo2,ItemNo3,ItemNo4);
Member of Lib.Library - Manufacturing


CreateFamily@115 Method

The procedure CreateFamily is available in codeunit 132202.

Syntax

CreateFamily@115(
    VAR Family@1000 : Record 99000773 Family //Reference parameter of type Record
);

Parameters

Family
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Family.

For a clarification about how this function works, refer to the code listed below.

      Family.INIT;
      Family.VALIDATE("No.",LibraryUtility.GenerateRandomCode(Family.FIELDNO("No."),DATABASE::Family));
      Family.INSERT(TRUE);
      Family.VALIDATE(Description,Family."No.");
      Family.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137034 to show one way of using this function.

      // Random values not important for test.
      LibraryManufacturing.CreateFamily(Family);
      Family.VALIDATE("Routing No.",RoutingNo);
      Family.MODIFY(TRUE);
      LibraryManufacturing.CreateFamilyLine(FamilyLine,Family."No.",ItemNo,LibraryRandom.RandInt(5));
      LibraryManufacturing.CreateFamilyLine(FamilyLine,Family."No.",ItemNo2,LibraryRandom.RandInt(5));
Member of Lib.Library - Manufacturing


CreateFamilyLine@113 Method

The procedure CreateFamilyLine is available in codeunit 132202.

Syntax

CreateFamilyLine@113(
    VAR FamilyLine@1001 : Record 99000774 FamilyLine, //Reference parameter of type Record
    FamilyNo@1000 : Code[20] FamilyNo, //Input parameter of type Code
    ItemNo@1002 : Code[20] ItemNo, //Input parameter of type Code
    Qty@1004 : Decimal Qty //Input parameter of type Decimal
);

Parameters

FamilyLine
Reference parameter of type Record
FamilyNo
Input parameter of type Code
ItemNo
Input parameter of type Code
Qty
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Family, Line.

For a clarification about how this function works, refer to the code listed below.

      FamilyLine.INIT;
      FamilyLine.VALIDATE("Family No.",FamilyNo);
      RecRef.GETTABLE(FamilyLine);
      FamilyLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,FamilyLine.FIELDNO("Line No.")));
      FamilyLine.INSERT(TRUE);
      FamilyLine.VALIDATE("Item No.",ItemNo);
      FamilyLine.VALIDATE(Quantity,Qty);
      FamilyLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137034 to show one way of using this function.

      // Random values not important for test.
      LibraryManufacturing.CreateFamily(Family);
      Family.VALIDATE("Routing No.",RoutingNo);
      Family.MODIFY(TRUE);
      LibraryManufacturing.CreateFamilyLine(FamilyLine,Family."No.",ItemNo,LibraryRandom.RandInt(5));
      LibraryManufacturing.CreateFamilyLine(FamilyLine,Family."No.",ItemNo2,LibraryRandom.RandInt(5));
Member of Lib.Library - Manufacturing


CreateItemManufacturing@10 Method

The procedure CreateItemManufacturing is available in codeunit 132202.

Syntax

CreateItemManufacturing@10(
    VAR Item@1008 : Record 27 Item, //Reference parameter of type Record
    CostingMethod@1001 : Option CostingMethod, //Input parameter of type Option
    UnitCost@1000 : Decimal UnitCost, //Input parameter of type Decimal
    ReorderPolicy@1002 : Option ReorderPolicy, //Input parameter of type Option
    FlushingMethod@1003 : Option FlushingMethod, //Input parameter of type Option
    RoutingNo@1004 : Code[20] RoutingNo, //Input parameter of type Code
    ProductionBOMNo@1005 : Code[20] ProductionBOMNo //Input parameter of type Code
);

Parameters

Item
Reference parameter of type Record
CostingMethod
Input parameter of type Option
UnitCost
Input parameter of type Decimal
ReorderPolicy
Input parameter of type Option
FlushingMethod
Input parameter of type Option
RoutingNo
Input parameter of type Code
ProductionBOMNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Item, Manufacturing.

For a clarification about how this function works, refer to the code listed below.

      // Create Item extended for Manufacturing.
      LibraryInventory.CreateItemManufacturing(Item);
      Item.VALIDATE("Costing Method",CostingMethod);
      IF Item."Costing Method" = Item."Costing Method"::Standard THEN
        Item.VALIDATE("Standard Cost",UnitCost)
      ELSE BEGIN
        Item.VALIDATE("Unit Cost",UnitCost);
        Item.VALIDATE("Last Direct Cost",Item."Unit Cost");
      END;

      Item.VALIDATE("Reordering Policy",ReorderPolicy);
      Item.VALIDATE("Flushing Method",FlushingMethod);

      IF ProductionBOMNo <> '' THEN BEGIN
        InventoryPostingSetup.FINDLAST;
        Item.VALIDATE("Replenishment System",Item."Replenishment System"::"Prod. Order");
        Item.VALIDATE("Routing No.",RoutingNo);
        Item.VALIDATE("Production BOM No.",ProductionBOMNo);
        Item.VALIDATE("Inventory Posting Group",InventoryPostingSetup."Invt. Posting Group Code");
      END;
      Item.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137002 to show one way of using this function.

      LibraryManufacturing.CreateItemManufacturing(
        Item,ItemCostingMethod,RANDOM(10),Item."Reordering Policy"::"Lot-for-Lot",FlushingMethod::Manual,'','');
      EXIT(Item."No.");
Member of Lib.Library - Manufacturing


CreateMachineCenter@38 Method

The procedure CreateMachineCenter is available in codeunit 132202.

Syntax

CreateMachineCenter@38(
    VAR MachineCenter@1002 : Record 99000758 MachineCenter, //Reference parameter of type Record
    WorkCenterNo@1000 : Code[20] WorkCenterNo, //Input parameter of type Code
    Capacity@1008 : Decimal Capacity //Input parameter of type Decimal
);

Parameters

MachineCenter
Reference parameter of type Record
WorkCenterNo
Input parameter of type Code
Capacity
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Machine, Center.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.FindGeneralPostingSetupInvtToGL(GeneralPostingSetup);
      LibraryUtility.UpdateSetupNoSeriesCode(
        DATABASE::"Manufacturing Setup",ManufacturingSetup.FIELDNO("Machine Center Nos."));

      CLEAR(MachineCenter);
      MachineCenter.INSERT(TRUE);
      MachineCenter.VALIDATE("Work Center No.",WorkCenterNo);
      MachineCenter.VALIDATE(Capacity,Capacity);
      MachineCenter.VALIDATE("Gen. Prod. Posting Group",GeneralPostingSetup."Gen. Prod. Posting Group");
      MachineCenter.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137003 to show one way of using this function.

      // Create Machine Center with required fields.
      LibraryManufacturing.CreateMachineCenter(MachineCenter,WorkCenterNo,Capacity);
      MachineCenter.VALIDATE(Name,MachineCenter."No.");
      MachineCenter.VALIDATE("Direct Unit Cost",DirectUnitCost);
      MachineCenter.VALIDATE("Indirect Cost %",IndirectCostPercentage);
      MachineCenter.VALIDATE("Overhead Rate",OverheadRate);
      MachineCenter.VALIDATE("Flushing Method",FlushingMethod);
      MachineCenter.MODIFY(TRUE);
Member of Lib.Library - Manufacturing


CreateMachineCenterWithCalendar@37 Method

The procedure CreateMachineCenterWithCalendar is available in codeunit 132202.

Syntax

CreateMachineCenterWithCalendar@37(
    VAR MachineCenter@1002 : Record 99000758 MachineCenter, //Reference parameter of type Record
    WorkCenterNo@1000 : Code[20] WorkCenterNo, //Input parameter of type Code
    Capacity@1001 : Decimal Capacity //Input parameter of type Decimal
);

Parameters

MachineCenter
Reference parameter of type Record
WorkCenterNo
Input parameter of type Code
Capacity
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Machine, Center, Calendar.

For a clarification about how this function works, refer to the code listed below.

      CreateMachineCenter(MachineCenter,WorkCenterNo,Capacity);
      CalculateMachCenterCalendar(MachineCenter,CALCDATE('<-1M>',WORKDATE),CALCDATE('<1M>',WORKDATE));

Example

The below example is extracted from the test automation codeunit 137023 to show one way of using this function.

      // Random value important for test.
      LibraryManufacturing.CreateMachineCenterWithCalendar(MachineCenter,WorkCenterNo,LibraryRandom.RandDec(105,1));
Member of Lib.Library - Manufacturing


CreateOutputJournal@51 Method

The procedure CreateOutputJournal is available in codeunit 132202.

Syntax

CreateOutputJournal@51(
    VAR ItemJournalLine@1002 : Record 83 ItemJournalLine, //Reference parameter of type Record
    ItemJournalTemplate@1004 : Record 82 ItemJournalTemplate, //Input parameter of type Record
    ItemJournalBatch@1000 : Record 233 ItemJournalBatch, //Input parameter of type Record
    ItemNo@1003 : Code[20] ItemNo, //Input parameter of type Code
    ProductionOrderNo@1006 : Code[20] ProductionOrderNo //Input parameter of type Code
);

Parameters

ItemJournalLine
Reference parameter of type Record
ItemJournalTemplate
Input parameter of type Record
ItemJournalBatch
Input parameter of type Record
ItemNo
Input parameter of type Code
ProductionOrderNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Output, Journal.

For a clarification about how this function works, refer to the code listed below.

      // Create Output Journal.
      IF ItemJournalTemplate.Type <> ItemJournalTemplate.Type::Output THEN
        EXIT;
      ItemJournalLine."Entry Type" := ItemJournalLine."Entry Type"::Output;

      LibraryInventory.CreateItemJnlLineWithNoItem(
        ItemJournalLine,ItemJournalBatch,ItemJournalTemplate.Name,ItemJournalBatch.Name,ItemJournalLine."Entry Type");
      ItemJournalLine.VALIDATE("Order Type",ItemJournalLine."Order Type"::Production);
      ItemJournalLine.VALIDATE("Order No.",ProductionOrderNo);
      ItemJournalLine.VALIDATE("Item No.",ItemNo);
      ItemJournalLine.MODIFY(TRUE);
      COMMIT;

Example

The below example is extracted from the test automation codeunit 137001 to show one way of using this function.

      LibraryInventory.SelectItemJournalTemplateName(ItemJournalTemplate,Type);
      LibraryInventory.SelectItemJournalBatchName(
        ItemJournalBatch,ItemJournalBatch."Template Type"::Consumption,ItemJournalTemplate.Name);

      CASE Type OF
        ItemJournalTemplate.Type::Consumption:
          LibraryManufacturing.CalculateConsumption(ProductionOrderNo,ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name);
        ItemJournalTemplate.Type::Output:
          BEGIN
            LibraryInventory.ClearItemJournal(ItemJournalTemplate,ItemJournalBatch);
            LibraryManufacturing.CreateOutputJournal(ItemJournalLine,ItemJournalTemplate,ItemJournalBatch,'',ProductionOrderNo);
            LibraryInventory.OutputJnlExplRoute(ItemJournalLine);
          END;
      END;

      ItemJournalLine.SETRANGE("Journal Template Name",ItemJournalBatch."Journal Template Name");
      ItemJournalLine.SETRANGE("Journal Batch Name",ItemJournalBatch.Name);
      ItemJournalLine.FINDSET;
      REPEAT
        TempItemJournalLine := ItemJournalLine;
        TempItemJournalLine.INSERT;
      UNTIL ItemJournalLine.NEXT = 0;

      LibraryInventory.PostItemJournalLine(ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name);
Member of Lib.Library - Manufacturing


CreateProdOrderLine@88 Method

The procedure CreateProdOrderLine is available in codeunit 132202.

Syntax

CreateProdOrderLine@88(
    VAR ProdOrderLine@1000 : Record 5406 ProdOrderLine, //Reference parameter of type Record
    ProdOrderStatus@1001 : Option ProdOrderStatus, //Input parameter of type Option
    ProdOrderNo@1002 : Code[20] ProdOrderNo, //Input parameter of type Code
    ItemNo@1003 : Code[20] ItemNo, //Input parameter of type Code
    VariantCode@1005 : Code[10] VariantCode, //Input parameter of type Code
    LocationCode@1006 : Code[10] LocationCode, //Input parameter of type Code
    Qty@1004 : Decimal Qty //Input parameter of type Decimal
);

Parameters

ProdOrderLine
Reference parameter of type Record
ProdOrderStatus
Input parameter of type Option
ProdOrderNo
Input parameter of type Code
ItemNo
Input parameter of type Code
VariantCode
Input parameter of type Code
LocationCode
Input parameter of type Code
Qty
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Product, Order, Line.

For a clarification about how this function works, refer to the code listed below.

      WITH ProdOrderLine DO BEGIN
        INIT;
        VALIDATE(Status,ProdOrderStatus);
        VALIDATE("Prod. Order No.",ProdOrderNo);
        VALIDATE("Line No.",LibraryUtility.GetNewRecNo(ProdOrderLine,FIELDNO("Line No.")));
        VALIDATE("Item No.",ItemNo);
        VALIDATE("Variant Code",VariantCode);
        VALIDATE("Location Code",LocationCode);
        VALIDATE(Quantity,Qty);

        INSERT(TRUE);
      END;

Example

The below example is extracted from the test automation codeunit 137079 to show one way of using this function.

      // [FEATURE] [Item Tracking]
      // [SCENARIO 266675] When a user posts reversed output with item tracking, the program does not populate "Applies-to Entry" automatically in case the original output was posted for a different prod. order line.
      Initialize;

      // [GIVEN] Lot-tracked item "I".
      CreateItemWithItemTrackingCode(Item);
      CreateRoutingAndUpdateItem(Item,WorkCenter);

      // [GIVEN] Released production order for "2Q" pcs of the "I".
      // [GIVEN] The production order has two prod. order lines "POL1", "POL2", each for "Q" pcs.
      LibraryManufacturing.CreateProductionOrder(
        ProductionOrder,ProductionOrder.Status::Released,ProductionOrder."Source Type"::Item,Item."No.",2 * LibraryRandom.RandInt(10));
      FOR i := 1 TO ARRAYLEN(ProdOrderLine) DO
        LibraryManufacturing.CreateProdOrderLine(
          ProdOrderLine[i],ProductionOrder.Status,ProductionOrder."No.",Item."No.",'','',ProductionOrder.Quantity / 2);
      LibraryManufacturing.RefreshProdOrder(ProductionOrder,FALSE,FALSE,TRUE,FALSE,FALSE);

      // [GIVEN] Open the output journal and explode the routing.
      // [GIVEN] Define the item tracking on the journal line representing prod. order line "POL1". Lot No. = "L".
      CreateOutputJournal(ItemJournalLine,ProductionOrder."No.",Item."No.");
      LibraryInventory.OutputJnlExplRoute(ItemJournalLine);
      SelectItemJournalLine(ItemJournalLine,OutputItemJournalBatch."Journal Template Name",OutputItemJournalBatch.Name);
      ItemJournalLine.VALIDATE(Quantity,ProductionOrder.Quantity / 2);
      ItemJournalLine.MODIFY(TRUE);
      LibraryVariableStorage.Enqueue(ItemTrackingMode::AssignLotNo);
      ItemJournalLine.OpenItemTrackingLines(FALSE);

      // [GIVEN] Delete the output journal lines representing prod. order line "POL2".
      ItemJournalLine.SETRANGE("Order Line No.",ProdOrderLine[2]."Line No.");
      ItemJournalLine.DELETEALL(TRUE);

      // [GIVEN] Post the output.
      LibraryInventory.PostItemJournalLine(ItemJournalLine."Journal Template Name",ItemJournalLine."Journal Batch Name");

      // [GIVEN] Create a reversed line in the output journal with item = "I", lot no. = "L", quantity = "-Q" and blank "Applies-to Entry".
      // [GIVEN] Set "Order Line No." = "POL2" on the reversed output line.
      LibraryVariableStorage.Enqueue(ItemTrackingMode::SelectEntries);
      CreateOutputJournal(ItemJournalLine,ProductionOrder."No.",Item."No.");
      ItemJournalLine.VALIDATE("Output Quantity",-ProductionOrder.Quantity / 2);
      ItemJournalLine.VALIDATE("Order Line No.",ProdOrderLine[2]."Line No.");
      ItemJournalLine.VALIDATE("Operation No.",FindLastOperationNo(Item."Routing No."));
      ItemJournalLine.MODIFY(TRUE);
      ItemJournalLine.OpenItemTrackingLines(FALSE);

      // [WHEN] Post the output correction.
      ASSERTERROR LibraryInventory.PostItemJournalLine(ItemJournalLine."Journal Template Name",ItemJournalLine."Journal Batch Name");

      // [THEN] "Applies-to Entry must have a value" error message is raised. The program could not find an original output for prod. order line "POL2".
      Assert.ExpectedError(AppliesToEntryErr);

      // Tear down.
      DeleteReservationEntry(Item."No.");
Member of Lib.Library - Manufacturing


CreateProductionBOMCommentLine@152 Method

The procedure CreateProductionBOMCommentLine is available in codeunit 132202.

Syntax

CreateProductionBOMCommentLine@152(
    ProductionBOMLine@1000 : Record 99000772 ProductionBOMLine //Input parameter of type Record
);

Parameters

ProductionBOMLine
Input parameter of type Record

Remarks

The relevant search keywords are: Create, Production, BOM, Comment, Line.

For a clarification about how this function works, refer to the code listed below.

      ProductionBOMCommentLine.INIT;
      ProductionBOMCommentLine.VALIDATE("Production BOM No.",ProductionBOMLine."Production BOM No.");
      ProductionBOMCommentLine.VALIDATE("BOM Line No.",ProductionBOMLine."Line No.");
      ProductionBOMCommentLine.VALIDATE("Version Code",ProductionBOMLine."Version Code");
      ProductionBOMCommentLine.VALIDATE(Comment,ProductionBOMLine."Version Code");
      ProductionBOMCommentLine.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137404 to show one way of using this function.

      ProductionBOMLine.SETRANGE("Production BOM No.",ProductionBOMNo);
      ProductionBOMLine.FINDFIRST;
      LibraryManufacturing.CreateProductionBOMCommentLine(ProductionBOMLine);
Member of Lib.Library - Manufacturing


CreateProductionBOMHeader@40 Method

The procedure CreateProductionBOMHeader is available in codeunit 132202.

Syntax

CreateProductionBOMHeader@40(
    VAR ProductionBOMHeader@1000 : Record 99000771 ProductionBOMHeader, //Reference parameter of type Record
    UnitOfMeasureCode@1002 : Code[10] UnitOfMeasureCode //Input parameter of type Code
);

Parameters

ProductionBOMHeader
Reference parameter of type Record
UnitOfMeasureCode
Input parameter of type Code

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Production, BOM, Header.

For a clarification about how this function works, refer to the code listed below.

      LibraryUtility.UpdateSetupNoSeriesCode(
        DATABASE::"Manufacturing Setup",ManufacturingSetup.FIELDNO("Production BOM Nos."));

      CLEAR(ProductionBOMHeader);
      ProductionBOMHeader.INSERT(TRUE);
      ProductionBOMHeader.VALIDATE("Unit of Measure Code",UnitOfMeasureCode);
      ProductionBOMHeader.VALIDATE(Status,ProductionBOMHeader.Status::New);
      ProductionBOMHeader.MODIFY(TRUE);
      EXIT(ProductionBOMHeader."No.");

Example

The below example is extracted from the test automation codeunit 137001 to show one way of using this function.

      LibraryManufacturing.CreateProductionBOMHeader(ProductionBOMHeader,Item."Base Unit of Measure");
      LibraryManufacturing.CreateProductionBOMLine(ProductionBOMHeader,ProductionBOMLine,'',ProductionBOMLine.Type::Item,Item."No.",1);

      ProductionBOMHeader.VALIDATE(Status,ProductionBOMHeader.Status::Certified);
      ProductionBOMHeader.MODIFY(TRUE);
      EXIT(ProductionBOMHeader."No.");
Member of Lib.Library - Manufacturing


CreateProductionBOMLine@60 Method

The procedure CreateProductionBOMLine is available in codeunit 132202.

Syntax

CreateProductionBOMLine@60(
    VAR ProductionBOMHeader@1002 : Record 99000771 ProductionBOMHeader, //Reference parameter of type Record
    VAR ProductionBOMLine@1000 : Record 99000772 ProductionBOMLine, //Reference parameter of type Record
    VersionCode@1003 : Code[20] VersionCode, //Input parameter of type Code
    Type@1001 : Option Type, //Input parameter of type Option
    No@1004 : Code[20] No, //Input parameter of type Code
    QuantityPer@1006 : Decimal QuantityPer //Input parameter of type Decimal
);

Parameters

ProductionBOMHeader
Reference parameter of type Record
ProductionBOMLine
Reference parameter of type Record
VersionCode
Input parameter of type Code
Type
Input parameter of type Option
No
Input parameter of type Code
QuantityPer
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Production, BOM, Line.

For a clarification about how this function works, refer to the code listed below.

      ProductionBOMLine.INIT;
      ProductionBOMLine.VALIDATE("Production BOM No.",ProductionBOMHeader."No.");
      ProductionBOMLine.VALIDATE("Version Code",VersionCode);
      RecRef.GETTABLE(ProductionBOMLine);
      ProductionBOMLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,ProductionBOMLine.FIELDNO("Line No.")));
      ProductionBOMLine.INSERT(TRUE);
      ProductionBOMLine.VALIDATE(Type,Type);
      ProductionBOMLine.VALIDATE("No.",No);
      ProductionBOMLine.VALIDATE("Quantity per",QuantityPer);
      ProductionBOMLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137001 to show one way of using this function.

      LibraryManufacturing.CreateProductionBOMHeader(ProductionBOMHeader,Item."Base Unit of Measure");
      LibraryManufacturing.CreateProductionBOMLine(ProductionBOMHeader,ProductionBOMLine,'',ProductionBOMLine.Type::Item,Item."No.",1);

      ProductionBOMHeader.VALIDATE(Status,ProductionBOMHeader.Status::Certified);
      ProductionBOMHeader.MODIFY(TRUE);
      EXIT(ProductionBOMHeader."No.");
Member of Lib.Library - Manufacturing


CreateProductionBOMVersion@31 Method

The procedure CreateProductionBOMVersion is available in codeunit 132202.

Syntax

CreateProductionBOMVersion@31(
    VAR ProductionBomVersion@1000 : Record 99000779 ProductionBomVersion, //Reference parameter of type Record
    BomNo@1001 : Code[20] BomNo, //Input parameter of type Code
    Version@1002 : Code[20] Version, //Input parameter of type Code
    UOMCode@1003 : Code[10] UOMCode //Input parameter of type Code
);

Parameters

ProductionBomVersion
Reference parameter of type Record
BomNo
Input parameter of type Code
Version
Input parameter of type Code
UOMCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Production, BOM, Version.

For a clarification about how this function works, refer to the code listed below.

      ProductionBomVersion.INIT;
      ProductionBomVersion.VALIDATE("Production BOM No.",BomNo);
      ProductionBomVersion.VALIDATE("Version Code",Version);
      ProductionBomVersion.INSERT(TRUE);
      ProductionBomVersion.VALIDATE("Unit of Measure Code",UOMCode);
      ProductionBomVersion.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137007 to show one way of using this function.

      LibraryManufacturing.CreateProductionBOMVersion(ProductionBOMVersion,ProductionBOMHeader."No.",
        COPYSTR(
          LibraryUtility.GenerateRandomCode(ProductionBOMVersion.FIELDNO("Version Code"),DATABASE::"Production BOM Version"),1,
          LibraryUtility.GetFieldLength(DATABASE::"Production BOM Version",ProductionBOMVersion.FIELDNO("Version Code"))),
        ItemBaseUnitOfMeasure);
      LibraryManufacturing.CreateProductionBOMLine(
        ProductionBOMHeader,ProductionBOMLine,ProductionBOMVersion."Version Code",ProductionBOMLine.Type::Item,ItemNo,
        LibraryRandom.RandInt(10)); // Random Quantity.
Member of Lib.Library - Manufacturing


CreateProductionForecastEntry@140 Method

The procedure CreateProductionForecastEntry is available in codeunit 132202.

Syntax

CreateProductionForecastEntry@140(
    VAR ProductionForecastEntry@1000 : Record 99000852 ProductionForecastEntry, //Reference parameter of type Record
    ProductionForecastName@1001 : Code[10] ProductionForecastName, //Input parameter of type Code
    ItemNo@1002 : Code[20] ItemNo, //Input parameter of type Code
    LocationCode@1003 : Code[10] LocationCode, //Input parameter of type Code
    ForecastDate@1004 : Date ForecastDate, //Input parameter of type Date
    ComponentForecast@1005 : Boolean ComponentForecast //Input parameter of type Boolean
);

Parameters

ProductionForecastEntry
Reference parameter of type Record
ProductionForecastName
Input parameter of type Code
ItemNo
Input parameter of type Code
LocationCode
Input parameter of type Code
ForecastDate
Input parameter of type Date
ComponentForecast
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, Production, Forecast, Entry.

For a clarification about how this function works, refer to the code listed below.

      ProductionForecastEntry.INIT;
      ProductionForecastEntry.VALIDATE("Production Forecast Name",ProductionForecastName);
      ProductionForecastEntry.VALIDATE("Item No.",ItemNo);
      ProductionForecastEntry.VALIDATE("Location Code",LocationCode);
      ProductionForecastEntry.VALIDATE("Forecast Date",ForecastDate);
      ProductionForecastEntry.VALIDATE("Component Forecast",ComponentForecast);
      ProductionForecastEntry.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137023 to show one way of using this function.

      LibraryManufacturing.CreateProductionForecastName(ProductionForecastName);
      LibraryManufacturing.CreateProductionForecastEntry(
        ProductionForecastEntry,ProductionForecastName.Name,Item."No.",Location.Code,Date,FALSE);
      ProductionForecastEntry.VALIDATE("Forecast Quantity (Base)",Quantity);
      ProductionForecastEntry.MODIFY(TRUE);
Member of Lib.Library - Manufacturing


CreateProductionForecastName@71 Method

The procedure CreateProductionForecastName is available in codeunit 132202.

Syntax

CreateProductionForecastName@71(
    VAR ProductionForecastName@1000 : Record 99000851 ProductionForecastName //Reference parameter of type Record
);

Parameters

ProductionForecastName
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Production, Forecast, Name.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(ProductionForecastName);
      ProductionForecastName.INIT;
      ProductionForecastName.VALIDATE(
        Name,LibraryUtility.GenerateRandomCode(ProductionForecastName.FIELDNO(Name),DATABASE::"Production Forecast Name"));
      ProductionForecastName.VALIDATE(Description,ProductionForecastName.Name);
      ProductionForecastName.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137023 to show one way of using this function.

      LibraryManufacturing.CreateProductionForecastName(ProductionForecastName);
      LibraryManufacturing.CreateProductionForecastEntry(
        ProductionForecastEntry,ProductionForecastName.Name,Item."No.",Location.Code,Date,FALSE);
      ProductionForecastEntry.VALIDATE("Forecast Quantity (Base)",Quantity);
      ProductionForecastEntry.MODIFY(TRUE);
Member of Lib.Library - Manufacturing


CreateProductionOrder@86 Method

The procedure CreateProductionOrder is available in codeunit 132202.

Syntax

CreateProductionOrder@86(
    VAR ProductionOrder@1000 : Record 5405 ProductionOrder, //Reference parameter of type Record
    Status@1001 : Option Status, //Input parameter of type Option
    SourceType@1004 : Option SourceType, //Input parameter of type Option
    SourceNo@1003 : Code[20] SourceNo, //Input parameter of type Code
    Quantity@1002 : Decimal Quantity //Input parameter of type Decimal
);

Parameters

ProductionOrder
Reference parameter of type Record
Status
Input parameter of type Option
SourceType
Input parameter of type Option
SourceNo
Input parameter of type Code
Quantity
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Production, Order.

For a clarification about how this function works, refer to the code listed below.

      CASE Status OF
        ProductionOrder.Status::Simulated:
          LibraryUtility.UpdateSetupNoSeriesCode(
            DATABASE::"Manufacturing Setup",ManufacturingSetup.FIELDNO("Simulated Order Nos."));
        ProductionOrder.Status::Planned:
          LibraryUtility.UpdateSetupNoSeriesCode(
            DATABASE::"Manufacturing Setup",ManufacturingSetup.FIELDNO("Planned Order Nos."));
        ProductionOrder.Status::"Firm Planned":
          LibraryUtility.UpdateSetupNoSeriesCode(
            DATABASE::"Manufacturing Setup",ManufacturingSetup.FIELDNO("Firm Planned Order Nos."));
        ProductionOrder.Status::Released:
          LibraryUtility.UpdateSetupNoSeriesCode(
            DATABASE::"Manufacturing Setup",ManufacturingSetup.FIELDNO("Released Order Nos."));
      END;

      CLEAR(ProductionOrder);
      ProductionOrder.INIT;
      ProductionOrder.VALIDATE(Status,Status);
      ProductionOrder.INSERT(TRUE);
      ProductionOrder.VALIDATE("Source Type",SourceType);
      ProductionOrder.VALIDATE("Source No.",SourceNo);
      ProductionOrder.VALIDATE(Quantity,Quantity);
      ProductionOrder.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 136118 to show one way of using this function.

      SourceCodeSetup.GET;
      SetPairedDefaultDimPrioritiesForSourceCode(TableOfHighPriority,TableOfLowPriority,SourceCodeSetup."Production Journal");

      CreateCertifiedRoutingForWorkCenter(RoutingHeader,RoutingHeader.Type::Serial,WorkCenterNo);
      ItemNo := LibraryInventory.CreateItem(Item);
      Item.VALIDATE("Routing No.",RoutingHeader."No.");
      Item.MODIFY(TRUE);

      SetDifferentDefaultDimForItemAndWorkCenter(ItemNo,WorkCenterNo,ItemDimValueCode,WorkCenterDimValueCode);

      LibraryManufacturing.CreateProductionOrder(
        ProductionOrder,ProductionOrder.Status::Released,
        ProductionOrder."Source Type"::Item,ItemNo,LibraryRandom.RandDec(100,2));
      LibraryManufacturing.RefreshProdOrder(ProductionOrder,FALSE,TRUE,TRUE,TRUE,FALSE);
Member of Lib.Library - Manufacturing


CreateProductionOrderComponent@109 Method

The procedure CreateProductionOrderComponent is available in codeunit 132202.

Syntax

CreateProductionOrderComponent@109(
    VAR ProdOrderComponent@1000 : Record 5407 ProdOrderComponent, //Reference parameter of type Record
    Status@1003 : Option Status, //Input parameter of type Option
    ProdOrderNo@1001 : Code[20] ProdOrderNo, //Input parameter of type Code
    ProdOrderLineNo@1002 : Integer ProdOrderLineNo //Input parameter of type Integer
);

Parameters

ProdOrderComponent
Reference parameter of type Record
Status
Input parameter of type Option
ProdOrderNo
Input parameter of type Code
ProdOrderLineNo
Input parameter of type Integer

Remarks

The relevant search keywords are: Create, Production, Order, Component.

For a clarification about how this function works, refer to the code listed below.

      ProdOrderComponent.INIT;
      ProdOrderComponent.VALIDATE(Status,Status);
      ProdOrderComponent.VALIDATE("Prod. Order No.",ProdOrderNo);
      ProdOrderComponent.VALIDATE("Prod. Order Line No.",ProdOrderLineNo);
      RecRef.GETTABLE(ProdOrderComponent);
      ProdOrderComponent.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,ProdOrderComponent.FIELDNO("Line No.")));
      ProdOrderComponent.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137054 to show one way of using this function.

      SelectProdOrderLine(ProdOrderLine,ProductionOrder."No.",ProductionOrder.Status);
      LibraryManufacturing.CreateProductionOrderComponent(
        ProdOrderComponent,ProductionOrder.Status,ProductionOrder."No.",ProdOrderLine."Line No.");
      ProdOrderComponent.VALIDATE("Item No.",ItemNo);
      ProdOrderComponent.VALIDATE("Quantity per",1);  // Used One for Quantity per.
      ProdOrderComponent.MODIFY(TRUE);
Member of Lib.Library - Manufacturing


CreateProductionOrderFromSalesOrder@59 Method

The procedure CreateProductionOrderFromSalesOrder is available in codeunit 132202.

Syntax

CreateProductionOrderFromSalesOrder@59(
    SalesHeader@1002 : Record 36 SalesHeader, //Input parameter of type Record
    ProdOrderStatus@1001 : Option ProdOrderStatus, //Input parameter of type Option
    OrderType@1000 : Option OrderType //Input parameter of type Option
);

Parameters

SalesHeader
Input parameter of type Record
ProdOrderStatus
Input parameter of type Option
OrderType
Input parameter of type Option

Remarks

The relevant search keywords are: Create, Production, Order, From, Sales, Order.

For a clarification about how this function works, refer to the code listed below.

      SalesLine.SETRANGE("Document Type",SalesHeader."Document Type");
      SalesLine.SETRANGE("Document No.",SalesHeader."No.");
      SalesLine.FINDSET;
      REPEAT
        CreateProdOrderFromSale.CreateProdOrder(SalesLine,ProdOrderStatus,OrderType);
        IF OrderType = OrderType::ProjectOrder THEN
          EndLoop := TRUE;
      UNTIL (SalesLine.NEXT = 0) OR EndLoop;

Example

The below example is extracted from the test automation codeunit 137049 to show one way of using this function.

      LibraryVariableStorage.Enqueue(ProdOrderCreatedMsg); // Enqueue variable for created Production Order message in MessageHandler.
      LibraryManufacturing.CreateProductionOrderFromSalesOrder(SalesHeader,ProductionOrder.Status::Released,OrderType::ItemOrder);
Member of Lib.Library - Manufacturing


CreateRegisteredAbsence@8 Method

The procedure CreateRegisteredAbsence is available in codeunit 132202.

Syntax

CreateRegisteredAbsence@8(
    VAR RegisteredAbsence@1001 : Record 99000848 RegisteredAbsence, //Reference parameter of type Record
    CapacityType@1002 : Option CapacityType, //Input parameter of type Option
    No@1000 : Code[20] No, //Input parameter of type Code
    Date@1003 : Date Date, //Input parameter of type Date
    StartingTime@1004 : Time StartingTime, //Input parameter of type Time
    EndingTime@1005 : Time EndingTime //Input parameter of type Time
);

Parameters

RegisteredAbsence
Reference parameter of type Record
CapacityType
Input parameter of type Option
No
Input parameter of type Code
Date
Input parameter of type Date
StartingTime
Input parameter of type Time
EndingTime
Input parameter of type Time

Remarks

The relevant search keywords are: Create, Registered, Absence.

For a clarification about how this function works, refer to the code listed below.

      RegisteredAbsence.INIT;
      RegisteredAbsence.VALIDATE("Capacity Type",CapacityType);
      RegisteredAbsence.VALIDATE("No.",No);
      RegisteredAbsence.VALIDATE(Date,Date);
      RegisteredAbsence.VALIDATE("Starting Time",StartingTime);
      RegisteredAbsence.VALIDATE("Ending Time",EndingTime);
      RegisteredAbsence.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137404 to show one way of using this function.

      // Check the functionality of Report Implement Registered Absence.

      // Setup: Create Work Center Group, Work Center and Registered Absence for the new Work Center.
      Initialize;
      CreateWorkCenterWithWorkCenterGroup(WorkCenter,'');
      LibraryManufacturing.CreateRegisteredAbsence(
        RegisteredAbsence,RegisteredAbsence."Capacity Type"::"Work Center",WorkCenter."No.",WORKDATE,GetRoundedTime(WORKDATE),
        GetRoundedTime(WORKDATE));
      RegisteredAbsence.VALIDATE(Capacity,LibraryRandom.RandDec(10,2));  // Taking Random value for Capacity.
      RegisteredAbsence.MODIFY(TRUE);

      // Exercise: Run the Report Implement Registered Absence using the Handler.
      RunImplementRegisteredAbsenceReport(RegisteredAbsence);

      // Verify: Verify that the Calendar Absence entry gets created for the new Work Center.
      VerifyCalendarAbsenceEntry(WorkCenter."No.",RegisteredAbsence);
Member of Lib.Library - Manufacturing


CreateRoutingHeader@77 Method

The procedure CreateRoutingHeader is available in codeunit 132202.

Syntax

CreateRoutingHeader@77(
    VAR RoutingHeader@1000 : Record 99000763 RoutingHeader, //Reference parameter of type Record
    Type@1002 : Option Type //Input parameter of type Option
);

Parameters

RoutingHeader
Reference parameter of type Record
Type
Input parameter of type Option

Remarks

The relevant search keywords are: Create, Routing, Header.

For a clarification about how this function works, refer to the code listed below.

      LibraryUtility.UpdateSetupNoSeriesCode(
        DATABASE::"Manufacturing Setup",ManufacturingSetup.FIELDNO("Routing Nos."));

      CLEAR(RoutingHeader);
      RoutingHeader.INSERT(TRUE);
      RoutingHeader.VALIDATE(Type,Type);
      RoutingHeader.VALIDATE(Status,RoutingHeader.Status::New);
      RoutingHeader.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 136118 to show one way of using this function.

      LibraryManufacturing.CreateWorkCenter(WorkCenter);

      LibraryManufacturing.CreateRoutingHeader(RoutingHeader,RoutingType);
      LibraryManufacturing.CreateRoutingLineSetup(RoutingLine,RoutingHeader,WorkCenter."No.",LibraryUtility.GenerateGUID,0,0);
      RoutingHeader.VALIDATE(Status,RoutingHeader.Status::Certified);
      RoutingHeader.MODIFY(TRUE);
      WorkCenterNo := WorkCenter."No.";
Member of Lib.Library - Manufacturing


CreateRoutingLine@72 Method

The procedure CreateRoutingLine is available in codeunit 132202.

Syntax

CreateRoutingLine@72(
    VAR RoutingHeader@1003 : Record 99000763 RoutingHeader, //Reference parameter of type Record
    VAR RoutingLine@1002 : Record 99000764 RoutingLine, //Reference parameter of type Record
    VersionCode@1001 : Code[20] VersionCode, //Input parameter of type Code
    OperationNo@1000 : Code[10] OperationNo, //Input parameter of type Code
    Type@1005 : Option Type, //Input parameter of type Option
    No@1004 : Code[20] No //Input parameter of type Code
);

Parameters

RoutingHeader
Reference parameter of type Record
RoutingLine
Reference parameter of type Record
VersionCode
Input parameter of type Code
OperationNo
Input parameter of type Code
Type
Input parameter of type Option
No
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Routing, Line.

For a clarification about how this function works, refer to the code listed below.

      RoutingLine.INIT;
      RoutingLine.VALIDATE("Routing No.",RoutingHeader."No.");
      RoutingLine.VALIDATE("Version Code",VersionCode);
      IF OperationNo = '' THEN
        OperationNo := LibraryUtility.GenerateRandomCode(RoutingLine.FIELDNO("Operation No."),DATABASE::"Routing Line");
      RoutingLine.VALIDATE("Operation No.",OperationNo);
      RoutingLine.INSERT(TRUE);
      RoutingLine.VALIDATE(Type,Type);
      RoutingLine.VALIDATE("No.",No);
      RoutingLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137001 to show one way of using this function.

      LibraryManufacturing.CreateWorkCenterWithCalendar(WorkCenter);
      WorkCenter.VALIDATE("Flushing Method",WorkCenter."Flushing Method"::Manual);
      WorkCenter.MODIFY(TRUE);

      LibraryManufacturing.CreateRoutingHeader(RoutingHeader,RoutingHeader.Type::Serial);
      LibraryManufacturing.CreateRoutingLine(RoutingHeader,RoutingLine,'','100',RoutingLine.Type::"Work Center",WorkCenter."No.");

      RoutingLine.VALIDATE("Run Time",RANDOM(100));
      RoutingLine.MODIFY(TRUE);

      RoutingHeader.VALIDATE(Status,RoutingHeader.Status::Certified);
      RoutingHeader.MODIFY(TRUE);
      EXIT(RoutingHeader."No.");
Member of Lib.Library - Manufacturing


CreateRoutingLineSetup@4 Method

The procedure CreateRoutingLineSetup is available in codeunit 132202.

Syntax

CreateRoutingLineSetup@4(
    VAR RoutingLine@1003 : Record 99000764 RoutingLine, //Reference parameter of type Record
    RoutingHeader@1000 : Record 99000763 RoutingHeader, //Input parameter of type Record
    CenterNo@1002 : Code[20] CenterNo, //Input parameter of type Code
    OperationNo@1005 : Code[10] OperationNo, //Input parameter of type Code
    SetupTime@1004 : Decimal SetupTime, //Input parameter of type Decimal
    RunTime@1001 : Decimal RunTime //Input parameter of type Decimal
);

Parameters

RoutingLine
Reference parameter of type Record
RoutingHeader
Input parameter of type Record
CenterNo
Input parameter of type Code
OperationNo
Input parameter of type Code
SetupTime
Input parameter of type Decimal
RunTime
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Routing, Line, Setup.

For a clarification about how this function works, refer to the code listed below.

      // Create Routing Lines with required fields.
      CreateRoutingLine(
        RoutingHeader,RoutingLine,'',OperationNo,RoutingLine.Type,CenterNo);
      RoutingLine.VALIDATE("Setup Time",SetupTime);
      RoutingLine.VALIDATE("Run Time",RunTime);
      RoutingLine.VALIDATE("Concurrent Capacities",1);
      RoutingLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 136118 to show one way of using this function.

      LibraryManufacturing.CreateWorkCenter(WorkCenter);

      LibraryManufacturing.CreateRoutingHeader(RoutingHeader,RoutingType);
      LibraryManufacturing.CreateRoutingLineSetup(RoutingLine,RoutingHeader,WorkCenter."No.",LibraryUtility.GenerateGUID,0,0);
      RoutingHeader.VALIDATE(Status,RoutingHeader.Status::Certified);
      RoutingHeader.MODIFY(TRUE);
      WorkCenterNo := WorkCenter."No.";
Member of Lib.Library - Manufacturing


CreateRoutingLink@79 Method

The procedure CreateRoutingLink is available in codeunit 132202.

Syntax

CreateRoutingLink@79(
    VAR RoutingLink@1000 : Record 99000777 RoutingLink //Reference parameter of type Record
);

Parameters

RoutingLink
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Routing, Link.

For a clarification about how this function works, refer to the code listed below.

      RoutingLink.INIT;
      RoutingLink.VALIDATE(Code,LibraryUtility.GenerateRandomCode(RoutingLink.FIELDNO(Code),DATABASE::"Routing Link"));
      RoutingLink.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137069 to show one way of using this function.

      // Setup: Create Routing Links. Create Production Item setup with Routing and Production BOM using Routing Link Code.
      Initialize;
      LibraryManufacturing.CreateRoutingLink(RoutingLink);
      LibraryManufacturing.CreateRoutingLink(RoutingLink2);
      ChildItemNo := CreateProductionItemsSetupWithRoutingLinkCode(Item,RoutingLink.Code,RoutingLink2.Code);

      // Exercise.
      CreateAndRefreshReleasedProductionOrder(ProductionOrder,Item."No.",LibraryRandom.RandDec(10,2));

      // Verify: Verify Production Order Component for Routing Link Code.
      VerifyProdOrderComponent(ProductionOrder.Status,ProductionOrder."No.",ChildItemNo,RoutingLink.Code);
      VerifyProdOrderComponent(ProductionOrder.Status,ProductionOrder."No.",ChildItemNo,RoutingLink2.Code);
Member of Lib.Library - Manufacturing


CreateRoutingVersion@7 Method

The procedure CreateRoutingVersion is available in codeunit 132202.

Syntax

CreateRoutingVersion@7(
    VAR RoutingVersion@1000 : Record 99000786 RoutingVersion, //Reference parameter of type Record
    RoutingNo@1001 : Code[20] RoutingNo, //Input parameter of type Code
    VersionCode@1002 : Code[20] VersionCode //Input parameter of type Code
);

Parameters

RoutingVersion
Reference parameter of type Record
RoutingNo
Input parameter of type Code
VersionCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Routing, Version.

For a clarification about how this function works, refer to the code listed below.

      RoutingVersion.INIT;
      RoutingVersion.VALIDATE("Routing No.",RoutingNo);
      RoutingVersion.VALIDATE("Version Code",VersionCode);
      RoutingVersion.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137007 to show one way of using this function.

      LibraryManufacturing.CreateRoutingVersion(RoutingVersion,RoutingHeader."No.",FORMAT(LibraryRandom.RandInt(10)));  // Use Random Version Code.
      RoutingLineCopyLines.CopyRouting(RoutingVersion."Routing No.",'',RoutingHeader,RoutingVersion."Version Code");
      UpdateStatusOnRoutingVersion(RoutingVersion,Status);
Member of Lib.Library - Manufacturing


CreateShopCalendarCode@6 Method

The procedure CreateShopCalendarCode is available in codeunit 132202.

Syntax

CreateShopCalendarCode@6(
    VAR ShopCalendar@1000 : Record 99000751 ShopCalendar //Reference parameter of type Record
);

Parameters

ShopCalendar
Reference parameter of type Record

Return Value

Code[10]

Remarks

The relevant search keywords are: Create, Shop, Calendar, Code.

For a clarification about how this function works, refer to the code listed below.

      ShopCalendar.INIT;
      ShopCalendar.VALIDATE(Code,LibraryUtility.GenerateRandomCode(ShopCalendar.FIELDNO(Code),DATABASE::"Shop Calendar"));
      ShopCalendar.INSERT(TRUE);
      EXIT(ShopCalendar.Code);

Example

The below example is extracted from the test automation codeunit 137063 to show one way of using this function.

      // Create Shop Calendar Working Days using with boundary values daily work shift.
      ShopCalendarCode := LibraryManufacturing.CreateShopCalendarCode(ShopCalendar);
      WorkShiftCode := LibraryManufacturing.CreateWorkShiftCode(WorkShift);
      ShopCalendarWorkingDays.SETRANGE("Shop Calendar Code",ShopCalendarCode);

      LibraryManufacturing.CreateShopCalendarWorkingDays(
        ShopCalendarWorkingDays,ShopCalendarCode,ShopCalendarWorkingDays.Day::Monday,WorkShiftCode,StartTime,EndTime);
      LibraryManufacturing.CreateShopCalendarWorkingDays(
        ShopCalendarWorkingDays,ShopCalendarCode,ShopCalendarWorkingDays.Day::Tuesday,WorkShiftCode,StartTime,EndTime);
      LibraryManufacturing.CreateShopCalendarWorkingDays(
        ShopCalendarWorkingDays,ShopCalendarCode,ShopCalendarWorkingDays.Day::Wednesday,WorkShiftCode,StartTime,EndTime);
      LibraryManufacturing.CreateShopCalendarWorkingDays(
        ShopCalendarWorkingDays,ShopCalendarCode,ShopCalendarWorkingDays.Day::Thursday,WorkShiftCode,StartTime,EndTime);
      LibraryManufacturing.CreateShopCalendarWorkingDays(
        ShopCalendarWorkingDays,ShopCalendarCode,ShopCalendarWorkingDays.Day::Friday,WorkShiftCode,StartTime,EndTime);

      EXIT(ShopCalendarCode);
Member of Lib.Library - Manufacturing


CreateShopCalendarWorkingDays@3 Method

The procedure CreateShopCalendarWorkingDays is available in codeunit 132202.

Syntax

CreateShopCalendarWorkingDays@3(
    VAR ShopCalendarWorkingDays@1000 : Record 99000752 ShopCalendarWorkingDays, //Reference parameter of type Record
    ShopCalendarCode@1001 : Code[10] ShopCalendarCode, //Input parameter of type Code
    Day@1002 : Option Day, //Input parameter of type Option
    WorkShiftCode@1003 : Code[10] WorkShiftCode, //Input parameter of type Code
    StartingTime@1004 : Time StartingTime, //Input parameter of type Time
    EndingTime@1005 : Time EndingTime //Input parameter of type Time
);

Parameters

ShopCalendarWorkingDays
Reference parameter of type Record
ShopCalendarCode
Input parameter of type Code
Day
Input parameter of type Option
WorkShiftCode
Input parameter of type Code
StartingTime
Input parameter of type Time
EndingTime
Input parameter of type Time

Remarks

The relevant search keywords are: Create, Shop, Calendar, Working, Days.

For a clarification about how this function works, refer to the code listed below.

      ShopCalendarWorkingDays.INIT;
      ShopCalendarWorkingDays.VALIDATE("Shop Calendar Code",ShopCalendarCode);
      ShopCalendarWorkingDays.VALIDATE(Day,Day);
      ShopCalendarWorkingDays.VALIDATE("Starting Time",StartingTime);
      ShopCalendarWorkingDays.VALIDATE("Ending Time",EndingTime);
      ShopCalendarWorkingDays.VALIDATE("Work Shift Code",WorkShiftCode);
      ShopCalendarWorkingDays.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137063 to show one way of using this function.

      // Create Shop Calendar Working Days using with boundary values daily work shift.
      ShopCalendarCode := LibraryManufacturing.CreateShopCalendarCode(ShopCalendar);
      WorkShiftCode := LibraryManufacturing.CreateWorkShiftCode(WorkShift);
      ShopCalendarWorkingDays.SETRANGE("Shop Calendar Code",ShopCalendarCode);

      LibraryManufacturing.CreateShopCalendarWorkingDays(
        ShopCalendarWorkingDays,ShopCalendarCode,ShopCalendarWorkingDays.Day::Monday,WorkShiftCode,StartTime,EndTime);
      LibraryManufacturing.CreateShopCalendarWorkingDays(
        ShopCalendarWorkingDays,ShopCalendarCode,ShopCalendarWorkingDays.Day::Tuesday,WorkShiftCode,StartTime,EndTime);
      LibraryManufacturing.CreateShopCalendarWorkingDays(
        ShopCalendarWorkingDays,ShopCalendarCode,ShopCalendarWorkingDays.Day::Wednesday,WorkShiftCode,StartTime,EndTime);
      LibraryManufacturing.CreateShopCalendarWorkingDays(
        ShopCalendarWorkingDays,ShopCalendarCode,ShopCalendarWorkingDays.Day::Thursday,WorkShiftCode,StartTime,EndTime);
      LibraryManufacturing.CreateShopCalendarWorkingDays(
        ShopCalendarWorkingDays,ShopCalendarCode,ShopCalendarWorkingDays.Day::Friday,WorkShiftCode,StartTime,EndTime);

      EXIT(ShopCalendarCode);
Member of Lib.Library - Manufacturing


CreateStandardTask@23 Method

The procedure CreateStandardTask is available in codeunit 132202.

Syntax

CreateStandardTask@23(
    VAR StandardTask@1000 : Record 99000778 StandardTask //Reference parameter of type Record
);

Parameters

StandardTask
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Standard, Task.

For a clarification about how this function works, refer to the code listed below.

      StandardTask.INIT;
      StandardTask.VALIDATE(Code,LibraryUtility.GenerateRandomCode(StandardTask.FIELDNO(Code),DATABASE::"Standard Task"));
      StandardTask.INSERT(TRUE);

Example

There are no examples available.
Member of Lib.Library - Manufacturing


CreateWorkCenter@5 Method

The procedure CreateWorkCenter is available in codeunit 132202.

Syntax

CreateWorkCenter@5(
    VAR WorkCenter@1000 : Record 99000754 WorkCenter //Reference parameter of type Record
);

Parameters

WorkCenter
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Work, Center.

For a clarification about how this function works, refer to the code listed below.

      CreateWorkCenterCustomTime(WorkCenter,080000T,160000T);

Example

The below example is extracted from the test automation codeunit 136118 to show one way of using this function.

      LibraryManufacturing.CreateWorkCenter(WorkCenter);

      LibraryManufacturing.CreateRoutingHeader(RoutingHeader,RoutingType);
      LibraryManufacturing.CreateRoutingLineSetup(RoutingLine,RoutingHeader,WorkCenter."No.",LibraryUtility.GenerateGUID,0,0);
      RoutingHeader.VALIDATE(Status,RoutingHeader.Status::Certified);
      RoutingHeader.MODIFY(TRUE);
      WorkCenterNo := WorkCenter."No.";
Member of Lib.Library - Manufacturing


CreateWorkCenterCustomTime@105 Method

The procedure CreateWorkCenterCustomTime is available in codeunit 132202.

Syntax

CreateWorkCenterCustomTime@105(
    VAR WorkCenter@1000 : Record 99000754 WorkCenter, //Reference parameter of type Record
    FromTime@1007 : Time FromTime, //Input parameter of type Time
    ToTime@1008 : Time ToTime //Input parameter of type Time
);

Parameters

WorkCenter
Reference parameter of type Record
FromTime
Input parameter of type Time
ToTime
Input parameter of type Time

Remarks

The relevant search keywords are: Create, Work, Center, Custom, Time.

For a clarification about how this function works, refer to the code listed below.

      CreateWorkCenterWithoutShopCalendar(WorkCenter);
      WorkCenter.VALIDATE(
        "Shop Calendar Code",UpdateShopCalendarWorkingDaysCustomTime(FromTime,ToTime));
      WorkCenter.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137069 to show one way of using this function.

      LibraryManufacturing.CreateWorkCenterCustomTime(WorkCenter,FromTime,ToTime);
Member of Lib.Library - Manufacturing


CreateWorkCenterFullWorkingWeek@14 Method

The procedure CreateWorkCenterFullWorkingWeek is available in codeunit 132202.

Syntax

CreateWorkCenterFullWorkingWeek@14(
    VAR WorkCenter@1002 : Record 99000754 WorkCenter, //Reference parameter of type Record
    FromTime@1001 : Time FromTime, //Input parameter of type Time
    ToTime@1000 : Time ToTime //Input parameter of type Time
);

Parameters

WorkCenter
Reference parameter of type Record
FromTime
Input parameter of type Time
ToTime
Input parameter of type Time

Remarks

The relevant search keywords are: Create, Work, Center, Full, Working, Week.

For a clarification about how this function works, refer to the code listed below.

      CreateWorkCenterWithoutShopCalendar(WorkCenter);
      WorkCenter.VALIDATE(
        "Shop Calendar Code",UpdateShopCalendarFullWorkingWeekCustomTime(FromTime,ToTime));
      WorkCenter.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137069 to show one way of using this function.

      // [FEATURE] [Routing] [Production Order Routing Line]
      // [SCENARIO 375635] Production Order refreshed "Back" should keep Starting Date-Time on Replan "Back"
      Initialize;

      // [GIVEN] Item "I" with routing, having 2 lines:
      LibraryManufacturing.CreateRoutingHeader(RoutingHeader,RoutingHeader.Type::Serial);

      // [GIVEN] Line 1: "WC1", run time 1 minutes
      CreateWorkCenter(WorkCenter,080000T,160000T); // time values needed for test
      LibraryManufacturing.CalculateWorkCenterCalendar(WorkCenter,CALCDATE('<-1M>',WORKDATE),CALCDATE('<1M>',WORKDATE));
      CreateWorkCenterRoutingLine(RoutingLine,RoutingHeader,WorkCenter."No.",0,0,0,0);

      // [GIVEN] Line 2: "WC2", wait time 1 day
      LibraryManufacturing.CreateWorkCenterFullWorkingWeek(WorkCenter,080000T,230000T); // time values needed for test
      LibraryManufacturing.CalculateWorkCenterCalendar(WorkCenter,CALCDATE('<-1M>',WORKDATE),CALCDATE('<1M>',WORKDATE));
      CapacityUnitOfMeasure.SETRANGE(Type,CapacityUnitOfMeasure.Type::Days);
      CapacityUnitOfMeasure.FINDFIRST;
      WorkCenter.VALIDATE("Queue Time",1);
      WorkCenter.VALIDATE("Queue Time Unit of Meas. Code",CapacityUnitOfMeasure.Code);
      WorkCenter.MODIFY(TRUE);
      CreateWorkCenterRoutingLine(RoutingLine,RoutingHeader,WorkCenter."No.",0,0,0,0);

      ChangeStatusOfProductionRoutingHeader(RoutingHeader,RoutingHeader.Status::Certified);

      CreateItem(Item,Item."Replenishment System"::"Prod. Order");
      UpdateRoutingAndBOMOnItem(Item,'',RoutingHeader."No.");

      // [GIVEN] Create Released Production Order "PO" with item "I"
      LibraryManufacturing.CreateProductionOrder(
        ProductionOrder,ProductionOrder.Status::Released,ProductionOrder."Source Type"::Item,Item."No.",1);

      // [GIVEN] "PO"."Due Date" = 17/02/2017
      ProductionOrder.VALIDATE("Due Date",WORKDATE);
      ProductionOrder.VALIDATE("Location Code",LocationBlue.Code);
      ProductionOrder.MODIFY(TRUE);

      // [GIVEN] Refresh "PO" back
      LibraryManufacturing.RefreshProdOrder(ProductionOrder,FALSE,TRUE,TRUE,FALSE,FALSE);

      // [GIVEN] "PO"."Starting DateTime" = 15/02/2017
      VerifyProdOrderLineStartingDateTime(ProductionOrder,'Wrong starting date-time on Refresh');

      // [WHEN] Replan "PO" with "Back" and "No Levels" options
      LibraryManufacturing.RunReplanProductionOrder(ProductionOrder,Direction::Backward,CalcMethod::"No Levels");

      // [THEN] "PO"."Starting DateTime" = 15/02/2017
      VerifyProdOrderLineStartingDateTime(ProductionOrder,'Wrong starting date-time on Replan');
Member of Lib.Library - Manufacturing


CreateWorkCenterGroup@16 Method

The procedure CreateWorkCenterGroup is available in codeunit 132202.

Syntax

CreateWorkCenterGroup@16(
    VAR WorkCenterGroup@1000 : Record 99000756 WorkCenterGroup //Reference parameter of type Record
);

Parameters

WorkCenterGroup
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Work, Center, Group.

For a clarification about how this function works, refer to the code listed below.

      WorkCenterGroup.INIT;
      WorkCenterGroup.VALIDATE(Code,LibraryUtility.GenerateRandomCode(WorkCenterGroup.FIELDNO(Code),DATABASE::"Work Center Group"));
      WorkCenterGroup.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137004 to show one way of using this function.

      // Steps describing the sequence of actions for Test Case.

      // 1. Create required WIP setups with Flushing method as Manual with Subcontract.
      // Update Manufacturing Setup, Inventory Setup and Update Shop Calendar Working Days based on Work Shift code.
      Initialize;
      RaiseConfirmHandler;
      LibraryManufacturing.CreateWorkCenterGroup(WorkCenterGroup);
      LibraryManufacturing.CreateCapacityUnitOfMeasure(CapacityUnitOfMeasure,Type::Minutes);
      LibraryInventory.UpdateInventorySetup(
        InventorySetup,TRUE,FALSE,AutomaticCostAdjustment::Never,AverageCostCalcType::Item,AverageCostPeriod::Day);
      LibraryManufacturing.UpdateManufacturingSetup(ManufacturingSetup,'','',TRUE,TRUE,TRUE);
      ShopCalendarCode := LibraryManufacturing.UpdateShopCalendarWorkingDays;
      IF AdditionalCurrencyExist THEN
        CurrencyCode := UpdateAddnlReportingCurrency
      ELSE
        LibraryERM.SetAddReportingCurrency('');

      // Create Work Center and Machine Center with Flushing method -Manual.
      // Create Work Center for Subcontractor with Flushing method -Manual.
      // Create Routing.
      CreateWorkCenter(WorkCenterNo,ShopCalendarCode,FlushingMethod,FALSE,UnitCostCalculation,'');
      CreateMachineCenter(MachineCenterNo,WorkCenterNo,FlushingMethod);
      CreateMachineCenter(MachineCenterNo2,WorkCenterNo,FlushingMethod);
      IF UpdateProdOrderRouting THEN
        CreateMachineCenter(MachineCenterNo3,WorkCenterNo,FlushingMethod);
      IF Subcontract THEN
        CreateWorkCenter(WorkCenterNo2,ShopCalendarCode,SubcontractFlushingMethod,TRUE,UnitCostCalculation,CurrencyCode)
      ELSE
        CreateWorkCenter(WorkCenterNo2,ShopCalendarCode,FlushingMethod,FALSE,UnitCostCalculation,CurrencyCode);
      RoutingNo := NoSeriesManagement.GetNextNo(ManufacturingSetup."Routing Nos.",WORKDATE,TRUE);
      CreateRouting(RoutingNo,MachineCenterNo,MachineCenterNo2,WorkCenterNo,WorkCenterNo2);

      // Create Items with Flushing method - Manual with the Parent Item containing Routing No. and Production BOM No.
      CreateItem(Item,CostingMethod,Item."Reordering Policy"::"Lot-for-Lot",FlushingMethod,'','');
      ItemNo := Item."No.";
      CLEAR(Item);
      CreateItem(Item,CostingMethod,Item."Reordering Policy"::"Lot-for-Lot",FlushingMethod,'','');
      ItemNo2 := Item."No.";
      CLEAR(Item);
      IF UpdateProductionComponent THEN BEGIN
        CreateItem(Item,Item."Costing Method"::Standard,Item."Reordering Policy"::"Lot-for-Lot",FlushingMethod,'','');
        ItemNo3 := Item."No.";
        CLEAR(Item);
      END;
      ProductionBOMNo :=
        LibraryManufacturing.CreateCertifProdBOMWithTwoComp(
          ProductionBOMHeader,ItemNo,ItemNo2,1); // value imporatant.
      CreateItem(Item,CostingMethod,Item."Reordering Policy"::"Lot-for-Lot",FlushingMethod,RoutingNo,ProductionBOMNo);

      // Calculate Standard Cost for Parent Item, if Costing Method is Standard.
      // Calculate Calendar for Work Center with dates having a difference of 5 weeks.
      // Create and Post Purchase Order as Receive and Invoice.
      IF  Item."Costing Method" = Item."Costing Method"::Standard THEN
        CalculateStandardCost.CalcItem(Item."No.",FALSE);
      CalculateCalendar(MachineCenterNo,MachineCenterNo2,WorkCenterNo,WorkCenterNo2);
      IF NOT AdditionalCurrencyExist THEN
        CreatePurchaseOrder(
          PurchaseHeader,PurchaseLine,ItemNo,ItemNo2,ItemNo3,LibraryRandom.RandInt(100) + 10,
          LibraryRandom.RandInt(100) + 10,LibraryRandom.RandInt(100) + 50,UpdateProductionComponent)
      ELSE
        CreatePurchaseOrderAddnlCurr(PurchaseHeader,PurchaseLine,CurrencyCode,ItemNo,ItemNo2,ItemNo3,
          LibraryRandom.RandInt(100) + 10,UpdateProductionComponent);

      IF AdjustExchangeRatesGLSetup THEN BEGIN
        UpdateExchangeRate(CurrencyCode);
        LibraryERM.RunAdjustExchangeRates(
          CurrencyCode,WORKDATE,WORKDATE,PurchaseHeader."No.",WORKDATE,LibraryUtility.GenerateGUID,TRUE);
      END;

      // Create and Refresh Production Order.
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);
      LibraryManufacturing.CreateProductionOrder(
        ProductionOrder,ProductionOrderStatus,ProductionOrder."Source Type"::Item,Item."No.",LibraryRandom.RandInt(10) + 5);
      LibraryManufacturing.RefreshProdOrder(ProductionOrder,FALSE,TRUE,TRUE,TRUE,FALSE);
      IF UpdateProdOrderRouting THEN BEGIN
        MachineCenter.GET(MachineCenterNo3);
        LibraryManufacturing.CalculateMachCenterCalendar(MachineCenter,CALCDATE('<-1M>',WORKDATE),CALCDATE('<1M>',WORKDATE));
        AddProdOrderRoutingLine(ProductionOrder,ProductionOrderRoutingType::"Machine Center",MachineCenterNo3);
        LibraryManufacturing.RefreshProdOrder(ProductionOrder,FALSE,FALSE,FALSE,TRUE,FALSE);
      END;

      // Create Subcontracting Worksheet, Make order and Post Subcontracting Purchase Order.
      IF Subcontract THEN BEGIN
        LibraryManufacturing.CalculateSubcontractOrder(WorkCenter);
        MakeSubconPurchOrder(ProductionOrder."No.",WorkCenterNo2);
        PostSubconPurchOrder(TempPurchaseLine,ProductionOrder."No.",SubcontractCostDiff);
      END;

      // Remove one component from Production Order and Replace it with a New Component.
      IF UpdateProductionComponent THEN
        ReplaceProdOrderComponent(ProductionOrder."No.",ItemNo2,Item."No.",ItemNo3);

      // Create, Calculate and Post Consumption Journal, Explode Routing and Post Output Journal.
      IF Item."Flushing Method" = Item."Flushing Method"::Manual THEN BEGIN
        LibraryInventory.CreateItemJournal(
          ItemJournalBatch,ItemNo,ItemJournalBatch."Template Type"::Consumption,ProductionOrder."No.");
        IF DeleteConsumptionJrnl THEN
          RemoveProdOrderComponent(ProductionOrder."No.",ItemNo);
        IF ConsumptionCostDiff THEN
          UpdateQtyConsumptionJournal(ProductionOrder."No.",ItemNo2);
        LibraryInventory.PostItemJournalLine(ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name);
        LibraryInventory.CreateItemJournal(ItemJournalBatch,ItemNo3,ItemJournalBatch."Template Type"::Output,ProductionOrder."No.");
        IF OutputCostDiff THEN
          UpdateLessQtyOutputJournal(ProductionOrder."No.",ProductionOrder.Quantity);
        IF RunSetupTimeCostDiff THEN BEGIN
          SetupTime := 1;
          RunTime := 1;
          UpdateSetupRunTime(ProductionOrder."No.",SetupTime,RunTime);
        END;
        LibraryInventory.PostItemJournalLine(ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name);
      END;

      // Change Production Order Status.
      IF ProductionOrder.Status = ProductionOrder.Status::Planned THEN
        ProductionOrderNo :=
          LibraryManufacturing.ChangeStatusPlannedToFinished(ProductionOrder."No.") // Change Status from Planned to Finished.
      ELSE
        LibraryManufacturing.ChangeStatusReleasedToFinished(ProductionOrder."No.");
      // Change Status of Production Order from Released to Finished.

      // 2. Execute Adjust Cost Item Entries report and Post Inventory Cost to G/L report.
      ProductionOrder.SETRANGE(Status,ProductionOrder.Status::Finished);
      IF ProductionOrderNo <> '' THEN
        ProductionOrder.SETRANGE("No.",ProductionOrderNo)
      ELSE
        ProductionOrder.SETRANGE("No.",ProductionOrder."No.");
      ProductionOrder.FINDFIRST;
      AdjustCostPostInventoryCostGL(ItemNo + '..' + ItemNo3);

      // 3. Verify GL Entry : Total amount and Positive amount entries for WIP Account.
      VerifyGLEntryForWIPAccounts(
        TempPurchaseLine,ItemNo,ProductionOrder."No.",CurrencyCode,SetupTime,RunTime,AdditionalCurrencyExist);

      // 4.Tear Down.
      TearDown(AdditionalCurrencyExist,Subcontract,Item."No.");
Member of Lib.Library - Manufacturing


CreateWorkCenterWithCalendar@53 Method

The procedure CreateWorkCenterWithCalendar is available in codeunit 132202.

Syntax

CreateWorkCenterWithCalendar@53(
    VAR WorkCenter@1004 : Record 99000754 WorkCenter //Reference parameter of type Record
);

Parameters

WorkCenter
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Work, Center, Calendar.

For a clarification about how this function works, refer to the code listed below.

      CreateWorkCenter(WorkCenter);
      CalculateWorkCenterCalendar(WorkCenter,CALCDATE('<-1M>',WORKDATE),CALCDATE('<1M>',WORKDATE));

Example

The below example is extracted from the test automation codeunit 137001 to show one way of using this function.

      LibraryManufacturing.CreateWorkCenterWithCalendar(WorkCenter);
      WorkCenter.VALIDATE("Flushing Method",WorkCenter."Flushing Method"::Manual);
      WorkCenter.MODIFY(TRUE);

      LibraryManufacturing.CreateRoutingHeader(RoutingHeader,RoutingHeader.Type::Serial);
      LibraryManufacturing.CreateRoutingLine(RoutingHeader,RoutingLine,'','100',RoutingLine.Type::"Work Center",WorkCenter."No.");

      RoutingLine.VALIDATE("Run Time",RANDOM(100));
      RoutingLine.MODIFY(TRUE);

      RoutingHeader.VALIDATE(Status,RoutingHeader.Status::Certified);
      RoutingHeader.MODIFY(TRUE);
      EXIT(RoutingHeader."No.");
Member of Lib.Library - Manufacturing


CreateWorkShiftCode@27 Method

The procedure CreateWorkShiftCode is available in codeunit 132202.

Syntax

CreateWorkShiftCode@27(
    VAR WorkShift@1000 : Record 99000750 WorkShift //Reference parameter of type Record
);

Parameters

WorkShift
Reference parameter of type Record

Return Value

Code[10]

Remarks

The relevant search keywords are: Create, Work, Shift, Code.

For a clarification about how this function works, refer to the code listed below.

      WorkShift.INIT;
      WorkShift.VALIDATE(Code,LibraryUtility.GenerateRandomCode(WorkShift.FIELDNO(Code),DATABASE::"Work Shift"));
      WorkShift.INSERT(TRUE);
      EXIT(WorkShift.Code);

Example

The below example is extracted from the test automation codeunit 137063 to show one way of using this function.

      // Create Shop Calendar Working Days using with boundary values daily work shift.
      ShopCalendarCode := LibraryManufacturing.CreateShopCalendarCode(ShopCalendar);
      WorkShiftCode := LibraryManufacturing.CreateWorkShiftCode(WorkShift);
      ShopCalendarWorkingDays.SETRANGE("Shop Calendar Code",ShopCalendarCode);

      LibraryManufacturing.CreateShopCalendarWorkingDays(
        ShopCalendarWorkingDays,ShopCalendarCode,ShopCalendarWorkingDays.Day::Monday,WorkShiftCode,StartTime,EndTime);
      LibraryManufacturing.CreateShopCalendarWorkingDays(
        ShopCalendarWorkingDays,ShopCalendarCode,ShopCalendarWorkingDays.Day::Tuesday,WorkShiftCode,StartTime,EndTime);
      LibraryManufacturing.CreateShopCalendarWorkingDays(
        ShopCalendarWorkingDays,ShopCalendarCode,ShopCalendarWorkingDays.Day::Wednesday,WorkShiftCode,StartTime,EndTime);
      LibraryManufacturing.CreateShopCalendarWorkingDays(
        ShopCalendarWorkingDays,ShopCalendarCode,ShopCalendarWorkingDays.Day::Thursday,WorkShiftCode,StartTime,EndTime);
      LibraryManufacturing.CreateShopCalendarWorkingDays(
        ShopCalendarWorkingDays,ShopCalendarCode,ShopCalendarWorkingDays.Day::Friday,WorkShiftCode,StartTime,EndTime);

      EXIT(ShopCalendarCode);
Member of Lib.Library - Manufacturing


OpenProductionJournal@20 Method

The procedure OpenProductionJournal is available in codeunit 132202.

Syntax

OpenProductionJournal@20(
    ProductionOrder@1001 : Record 5405 ProductionOrder, //Input parameter of type Record
    ProductionOrderLineNo@1002 : Integer ProductionOrderLineNo //Input parameter of type Integer
);

Parameters

ProductionOrder
Input parameter of type Record
ProductionOrderLineNo
Input parameter of type Integer

Remarks

The relevant search keywords are: Open, Production, Journal.

For a clarification about how this function works, refer to the code listed below.

      ProductionJournalMgt.Handling(ProductionOrder,ProductionOrderLineNo);

Example

The below example is extracted from the test automation codeunit 136118 to show one way of using this function.

      // [FEATURE] [Default Dimension Priority] [Production Journal]
      // [SCENARIO 378966] Default Dimension with high priority in Work Center should be inherited by Production Journal.
      Initialize;

      // [GIVEN] Default Dimension Priorities are high for Work Center and low for Item.
      // [GIVEN] Item with Routing "R" for Work Center.
      // [GIVEN] Default Dimension Value Codes are equal to "A1" for Item and "A2" for Work Center.
      // [GIVEN] Released Production Order for Item with Routing "R".
      CreateAndRefreshReleasedProdOrder(
        ProductionOrder,ItemNo,ItemDimValueCode,WorkCenterDimValueCode,DATABASE::"Work Center",DATABASE::Item);

      // [WHEN] Open Production Journal
      LibraryVariableStorage.Enqueue(ItemNo); // Enqueue for ModalPageHandlerForDim handler
      LibraryVariableStorage.Enqueue(WorkCenterDimValueCode); // Enqueue for ModalPageHandlerForDim handler
      LibraryManufacturing.OpenProductionJournal(ProductionOrder,FindProdOrderLineNo(ProductionOrder,ItemNo));

      // [THEN] Dimension Value Code in Production Journal Line is equal to "A2".
      // Checked on PageHandler named ModalPageHandlerForDim.
Member of Lib.Library - Manufacturing


OutputJournalExplodeOrderLineRouting@33 Method

The procedure OutputJournalExplodeOrderLineRouting is available in codeunit 132202.

Syntax

OutputJournalExplodeOrderLineRouting@33(
    VAR ItemJournalBatch@1000 : Record 233 ItemJournalBatch, //Reference parameter of type Record
    ProdOrderLine@1003 : Record 5406 ProdOrderLine, //Input parameter of type Record
    PostingDate@1006 : Date PostingDate //Input parameter of type Date
);

Parameters

ItemJournalBatch
Reference parameter of type Record
ProdOrderLine
Input parameter of type Record
PostingDate
Input parameter of type Date

Remarks

The relevant search keywords are: Output, Journal, Explode, Order, Line, Routing.

For a clarification about how this function works, refer to the code listed below.

      ItemJournalTemplate.SETRANGE(Type,ItemJournalTemplate.Type::Output);
      ItemJournalTemplate.FINDFIRST;
      ItemJournalBatch.SETRANGE("Journal Template Name",ItemJournalTemplate.Name);
      ItemJournalBatch.FINDFIRST;
      LibraryInventory.CreateItemJournalLine(
        ItemJournalLine,ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name,
        ItemJournalLine."Entry Type"::Output,'',0);
      ItemJournalLine.VALIDATE("Posting Date",PostingDate);
      ItemJournalLine.VALIDATE("Order Type",ItemJournalLine."Order Type"::Production);
      ItemJournalLine.VALIDATE("Order No.",ProdOrderLine."Prod. Order No.");
      ItemJournalLine.VALIDATE("Order Line No.",ProdOrderLine."Line No.");
      ItemJournalLine.MODIFY(TRUE);
      CODEUNIT.RUN(CODEUNIT::"Output Jnl.-Expl. Route",ItemJournalLine);

Example

The below example is extracted from the test automation codeunit 137353 to show one way of using this function.

      LibraryManufacturing.OutputJournalExplodeOrderLineRouting(ItemJournalBatch,ProdOrderLine,PostingDate);
      WITH ItemJournalLine DO BEGIN
        SETRANGE("Journal Template Name",ItemJournalBatch."Journal Template Name");
        SETRANGE("Journal Batch Name",ItemJournalBatch.Name);
        SETRANGE("Entry Type","Entry Type"::Output);
        SETRANGE("Order Type","Order Type"::Production);
        SETRANGE("Order No.",ProdOrderLine."Prod. Order No.");
        SETRANGE("Order Line No.",ProdOrderLine."Line No.");
        IF FINDSET THEN
          REPEAT
            ProdOrderRoutingLine.SETRANGE(Status,ProdOrderLine.Status);
            ProdOrderRoutingLine.SETRANGE("Prod. Order No.",ProdOrderLine."Prod. Order No.");
            ProdOrderRoutingLine.SETRANGE("Operation No.","Operation No.");
            IF ProdOrderRoutingLine.FINDFIRST THEN BEGIN
              VALIDATE("Setup Time",ProdOrderRoutingLine."Setup Time");
              VALIDATE("Run Time",ProdOrderRoutingLine."Run Time");
              VALIDATE("Output Quantity",OutputQty);
              IF OutputQty < 0 THEN
                VALIDATE("Applies-to Entry",AppliesToEntry);
              MODIFY;
            END;
          UNTIL NEXT = 0;
      END;
      LibraryInventory.PostItemJournalBatch(ItemJournalBatch);
Member of Lib.Library - Manufacturing


OutputJournalExplodeRouting@34 Method

The procedure OutputJournalExplodeRouting is available in codeunit 132202.

Syntax

OutputJournalExplodeRouting@34(
    ProductionOrder@1000 : Record 5405 ProductionOrder //Input parameter of type Record
);

Parameters

ProductionOrder
Input parameter of type Record

Remarks

The relevant search keywords are: Output, Journal, Explode, Routing.

For a clarification about how this function works, refer to the code listed below.

      ItemJournalTemplate.SETRANGE(Type,ItemJournalTemplate.Type::Output);
      ItemJournalTemplate.FINDFIRST;
      ItemJournalBatch.SETRANGE("Journal Template Name",ItemJournalTemplate.Name);
      ItemJournalBatch.FINDFIRST;
      LibraryInventory.CreateItemJournalLine(
        ItemJournalLine,ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name,
        ItemJournalLine."Entry Type"::Output,'',0);
      ItemJournalLine.VALIDATE("Order Type",ItemJournalLine."Order Type"::Production);
      ItemJournalLine.VALIDATE("Order No.",ProductionOrder."No.");
      ItemJournalLine.MODIFY(TRUE);
      CODEUNIT.RUN(CODEUNIT::"Output Jnl.-Expl. Route",ItemJournalLine);

Example

The below example is extracted from the test automation codeunit 137066 to show one way of using this function.

      LibraryManufacturing.OutputJournalExplodeRouting(ProductionOrder);

      WITH ItemJournalLine DO BEGIN
        SETRANGE("Order Type","Order Type"::Production);
        SETRANGE("Order No.",ProductionOrder."No.");
        SETRANGE("Entry Type","Entry Type"::Output);
        FINDFIRST;
        VALIDATE("Output Quantity",OutputQty);
        MODIFY(TRUE);
      END;
      LibraryManufacturing.PostOutputJournal;

      WITH ItemLedgerEntry DO BEGIN
        SETRANGE("Entry Type","Entry Type"::Output);
        SETRANGE("Order Type","Order Type"::Production);
        SETRANGE("Order No.",ProductionOrder."No.");
        FINDLAST;
        EXIT("Entry No.");
      END;
Member of Lib.Library - Manufacturing


PostConsumptionJournal@26 Method

The procedure PostConsumptionJournal is available in codeunit 132202.

Syntax

PostConsumptionJournal@26(
      //param element not supplied
);

Remarks

The relevant search keywords are: Post, Consumption, Journal.

For a clarification about how this function works, refer to the code listed below.

      ItemJournalTemplate.SETRANGE(Type,ItemJournalTemplate.Type::Consumption);
      ItemJournalTemplate.FINDFIRST;
      ItemJournalBatch.SETRANGE("Journal Template Name",ItemJournalTemplate.Name);
      ItemJournalBatch.FINDFIRST;
      LibraryInventory.PostItemJournalLine(ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name);

Example

The below example is extracted from the test automation codeunit 137066 to show one way of using this function.

      ProdOrderComponent.SETRANGE(Status,ProductionOrder.Status);
      ProdOrderComponent.SETRANGE("Prod. Order No.",ProductionOrder."No.");
      LibraryManufacturing.CalculateConsumptionForJournal(ProductionOrder,ProdOrderComponent,WORKDATE,FALSE);

      WITH ItemJournalLine DO BEGIN
        SETRANGE("Order Type","Order Type"::Production);
        SETRANGE("Order No.",ProductionOrder."No.");
        SETRANGE("Entry Type","Entry Type"::Consumption);
        FINDFIRST;
        VALIDATE(Quantity,ConsumptionQty);
        VALIDATE("Applies-to Entry",AppliedToEntryNo);
        MODIFY(TRUE);
      END;
      LibraryManufacturing.PostConsumptionJournal;
Member of Lib.Library - Manufacturing


PostOutputJournal@25 Method

The procedure PostOutputJournal is available in codeunit 132202.

Syntax

PostOutputJournal@25(
      //param element not supplied
);

Remarks

The relevant search keywords are: Post, Output, Journal.

For a clarification about how this function works, refer to the code listed below.

      ItemJournalTemplate.SETRANGE(Type,ItemJournalTemplate.Type::Output);
      ItemJournalTemplate.FINDFIRST;
      ItemJournalBatch.SETRANGE("Journal Template Name",ItemJournalTemplate.Name);
      ItemJournalBatch.FINDFIRST;
      LibraryInventory.PostItemJournalLine(ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name);

Example

The below example is extracted from the test automation codeunit 137066 to show one way of using this function.

      LibraryManufacturing.OutputJournalExplodeRouting(ProductionOrder);

      WITH ItemJournalLine DO BEGIN
        SETRANGE("Order Type","Order Type"::Production);
        SETRANGE("Order No.",ProductionOrder."No.");
        SETRANGE("Entry Type","Entry Type"::Output);
        FINDFIRST;
        VALIDATE("Output Quantity",OutputQty);
        MODIFY(TRUE);
      END;
      LibraryManufacturing.PostOutputJournal;

      WITH ItemLedgerEntry DO BEGIN
        SETRANGE("Entry Type","Entry Type"::Output);
        SETRANGE("Order Type","Order Type"::Production);
        SETRANGE("Order No.",ProductionOrder."No.");
        FINDLAST;
        EXIT("Entry No.");
      END;
Member of Lib.Library - Manufacturing


RefreshProdOrder@24 Method

The procedure RefreshProdOrder is available in codeunit 132202.

Syntax

RefreshProdOrder@24(
    VAR ProductionOrder@1000 : Record 5405 ProductionOrder, //Reference parameter of type Record
    Forward@1002 : Boolean Forward, //Input parameter of type Boolean
    CalcLines@1009 : Boolean CalcLines, //Input parameter of type Boolean
    CalcRoutings@1006 : Boolean CalcRoutings, //Input parameter of type Boolean
    CalcComponents@1007 : Boolean CalcComponents, //Input parameter of type Boolean
    CreateInbRqst@1008 : Boolean CreateInbRqst //Input parameter of type Boolean
);

Parameters

ProductionOrder
Reference parameter of type Record
Forward
Input parameter of type Boolean
CalcLines
Input parameter of type Boolean
CalcRoutings
Input parameter of type Boolean
CalcComponents
Input parameter of type Boolean
CreateInbRqst
Input parameter of type Boolean

Remarks

The relevant search keywords are: Refresh, Product, Order.

For a clarification about how this function works, refer to the code listed below.

      COMMIT;
      TempTransactionType := CURRENTTRANSACTIONTYPE;
      CURRENTTRANSACTIONTYPE(TRANSACTIONTYPE::Update);

      IF Forward THEN
        Direction := Direction::Forward
      ELSE
        Direction := Direction::Backward;
      IF ProductionOrder.HASFILTER THEN
        TmpProductionOrder.COPYFILTERS(ProductionOrder)
      ELSE BEGIN
        ProductionOrder.GET(ProductionOrder.Status,ProductionOrder."No.");
        TmpProductionOrder.SETRANGE(Status,ProductionOrder.Status);
        TmpProductionOrder.SETRANGE("No.",ProductionOrder."No.");
      END;
      RefreshProductionOrder.InitializeRequest(Direction,CalcLines,CalcRoutings,CalcComponents,CreateInbRqst);
      RefreshProductionOrder.SETTABLEVIEW(TmpProductionOrder);
      RefreshProductionOrder.USEREQUESTPAGE := FALSE;
      RefreshProductionOrder.RUNMODAL;

      COMMIT;
      CURRENTTRANSACTIONTYPE(TempTransactionType);

Example

The below example is extracted from the test automation codeunit 136118 to show one way of using this function.

      SourceCodeSetup.GET;
      SetPairedDefaultDimPrioritiesForSourceCode(TableOfHighPriority,TableOfLowPriority,SourceCodeSetup."Production Journal");

      CreateCertifiedRoutingForWorkCenter(RoutingHeader,RoutingHeader.Type::Serial,WorkCenterNo);
      ItemNo := LibraryInventory.CreateItem(Item);
      Item.VALIDATE("Routing No.",RoutingHeader."No.");
      Item.MODIFY(TRUE);

      SetDifferentDefaultDimForItemAndWorkCenter(ItemNo,WorkCenterNo,ItemDimValueCode,WorkCenterDimValueCode);

      LibraryManufacturing.CreateProductionOrder(
        ProductionOrder,ProductionOrder.Status::Released,
        ProductionOrder."Source Type"::Item,ItemNo,LibraryRandom.RandDec(100,2));
      LibraryManufacturing.RefreshProdOrder(ProductionOrder,FALSE,TRUE,TRUE,TRUE,FALSE);
Member of Lib.Library - Manufacturing


RunReplanProductionOrder@141 Method

The procedure RunReplanProductionOrder is available in codeunit 132202.

Syntax

RunReplanProductionOrder@141(
    VAR ProductionOrder@1000 : Record 5405 ProductionOrder, //Reference parameter of type Record
    NewDirection@1002 : Option NewDirection, //Input parameter of type Option
    NewCalcMethod@1003 : Option NewCalcMethod //Input parameter of type Option
);

Parameters

ProductionOrder
Reference parameter of type Record
NewDirection
Input parameter of type Option
NewCalcMethod
Input parameter of type Option

Remarks

The relevant search keywords are: Run, Replan, Production, Order.

For a clarification about how this function works, refer to the code listed below.

      COMMIT;
      ReplanProductionOrder.InitializeRequest(NewDirection,NewCalcMethod);
      IF ProductionOrder.HASFILTER THEN
        TmpProductionOrder.COPYFILTERS(ProductionOrder)
      ELSE BEGIN
        ProductionOrder.GET(ProductionOrder.Status,ProductionOrder."No.");
        TmpProductionOrder.SETRANGE(Status,ProductionOrder.Status);
        TmpProductionOrder.SETRANGE("No.",ProductionOrder."No.");
      END;
      ReplanProductionOrder.SETTABLEVIEW(TmpProductionOrder);
      ReplanProductionOrder.USEREQUESTPAGE(FALSE);
      ReplanProductionOrder.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 137063 to show one way of using this function.

      // Verify Variant Code on Production Order Line after Replan Production Order.
      // Setup: Create Items, Production BOM and Production Order.
      Initialize;
      CreateMultipleItems(
        Item,Item2,Item3,Item."Replenishment System"::"Prod. Order",Item."Replenishment System"::Purchase,
        Item."Reordering Policy"::" ",FALSE);
      LibraryInventory.CreateItemVariant(ItemVariant,Item2."No.");

      CreateProductionBOMAndCertify(
        ProductionBOMHeader,Item."Base Unit of Measure",ProductionBOMLine.Type::Item,Item2."No.",LibraryRandom.RandInt(5));  // Using Random for Quantity Per.
      UpdateItem(Item,Item.FIELDNO("Production BOM No."),ProductionBOMHeader."No.");

      CreateAndRefreshProdOrder(
        ProductionOrder,ProductionOrder.Status::"Firm Planned",Item."No.",LibraryRandom.RandInt(5),
        ProductionOrder."Source Type"::Item,FALSE);
      UpdateVariantCodeOnProdOrderComponent(Item2."No.",ItemVariant.Code);

      // Exercise: Replan Production Order.
      LibraryManufacturing.RunReplanProductionOrder(ProductionOrder,Direction::Backward,CalcMethod::"All levels");

      // Verify: Verify Variant Code on Production Order Line.
      ProdOrderLine.SETRANGE("Item No.",Item2."No.");
      ProdOrderLine.FINDFIRST;
      ProdOrderLine.TESTFIELD(Status,ProdOrderLine.Status::"Firm Planned");
      ProdOrderLine.TESTFIELD("Variant Code",ItemVariant.Code)
Member of Lib.Library - Manufacturing


RunRollUpStandardCost@22 Method

The procedure RunRollUpStandardCost is available in codeunit 132202.

Syntax

RunRollUpStandardCost@22(
    VAR Item@1001 : Record 27 Item, //Reference parameter of type Record
    StandardCostWorksheetName@1002 : Code[10] StandardCostWorksheetName //Input parameter of type Code
);

Parameters

Item
Reference parameter of type Record
StandardCostWorksheetName
Input parameter of type Code

Remarks

The relevant search keywords are: Run, Roll, Up, Standard, Cost.

For a clarification about how this function works, refer to the code listed below.

      COMMIT;
      IF Item.HASFILTER THEN
        Item2.COPYFILTERS(Item)
      ELSE BEGIN
        Item2.GET(Item."No.");
        Item2.SETRANGE("No.",Item."No.");
      END;
      RollUpStandardCost.SETTABLEVIEW(Item2);
      RollUpStandardCost.SetStdCostWksh(StandardCostWorksheetName);
      RollUpStandardCost.USEREQUESTPAGE(FALSE);
      RollUpStandardCost.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 137007 to show one way of using this function.

      // Create Item and Production BOM.
      CreateItemsSetup(Item,ChildItem);
      UpdateStandardCostOnItem(Item);

      // Create Production BOM Version and update Status or create Routing Setup, Routing Version and update Status.
      IF ProdBOMVersion THEN
        CreateProductionBOMVersionAndUpdateStatus(Item."Production BOM No.",VersionStatus)
      ELSE BEGIN
        CreateRoutingSetup(RoutingHeader);
        UpdateRoutingNoOnItem(Item,RoutingHeader."No.");
        CreateRoutingVersionAndUpdateStatus(RoutingHeader,VersionStatus);
      END;

      // Create Standard Cost Worksheet Name. Run Suggest Item Standard Cost and update New Standard Cost value.
      StandardCostWkshName := CreateAndUpdateStandardCostWorksheet(Item);
      LibraryVariableStorage.Enqueue(StandardCostRolledUpMessage);

      // Exercise: Run Roll Up Standard Cost.
      LibraryManufacturing.RunRollUpStandardCost(Item,StandardCostWkshName);

      // Verify: Verify that Roll Up Standard Cost run without any error and verify New Standard Cost on Standard Cost Worksheet.
      FindStandardCostWorksheet(StandardCostWorksheet,StandardCostWkshName,Item."No.");
      StandardCostWorksheet.TESTFIELD("New Standard Cost",0);  // Value required.
Member of Lib.Library - Manufacturing


UpdateManufacturingSetup@2 Method

The procedure UpdateManufacturingSetup is available in codeunit 132202.

Syntax

UpdateManufacturingSetup@2(
    VAR ManufacturingSetup@1000 : Record 99000765 ManufacturingSetup, //Reference parameter of type Record
    ShowCapacityIn@1002 : Code[10] ShowCapacityIn, //Input parameter of type Code
    ComponentsAtLocation@1001 : Code[10] ComponentsAtLocation, //Input parameter of type Code
    DocNoIsProdOrderNo@1004 : Boolean DocNoIsProdOrderNo, //Input parameter of type Boolean
    CostInclSetup@1005 : Boolean CostInclSetup, //Input parameter of type Boolean
    DynamicLowLevelCode@1008 : Boolean DynamicLowLevelCode //Input parameter of type Boolean
);

Parameters

ManufacturingSetup
Reference parameter of type Record
ShowCapacityIn
Input parameter of type Code
ComponentsAtLocation
Input parameter of type Code
DocNoIsProdOrderNo
Input parameter of type Boolean
CostInclSetup
Input parameter of type Boolean
DynamicLowLevelCode
Input parameter of type Boolean

Remarks

The relevant search keywords are: Update, Manufacturing, Setup.

For a clarification about how this function works, refer to the code listed below.

      // Update Manufacturing Setup.
      ManufacturingSetup.GET;
      ManufacturingSetup.VALIDATE("Doc. No. Is Prod. Order No.",DocNoIsProdOrderNo);
      ManufacturingSetup.VALIDATE("Cost Incl. Setup",CostInclSetup);
      ManufacturingSetup.VALIDATE("Show Capacity In",ShowCapacityIn);
      ManufacturingSetup.VALIDATE("Components at Location",ComponentsAtLocation);
      ManufacturingSetup.VALIDATE("Dynamic Low-Level Code",DynamicLowLevelCode);
      ManufacturingSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137001 to show one way of using this function.

      ExecuteUIHandlers;

      // Setup Sales and Purchases.
      LibrarySales.SetCreditWarningsToNoWarnings;
      PurchasesPayablesSetup.GET;
      PurchasesPayablesSetup.VALIDATE("Ext. Doc. No. Mandatory",FALSE);
      PurchasesPayablesSetup.VALIDATE("Exact Cost Reversing Mandatory",FALSE);
      PurchasesPayablesSetup.MODIFY(TRUE);

      // Setup Inventory.
      LibraryInventory.UpdateInventorySetup(
        InventorySetup,TRUE,TRUE,AutCostAdjustment,CalcType,InventorySetup."Average Cost Period"::Day);

      // Setup Manufacturing.
      LibraryManufacturing.UpdateManufacturingSetup(
        ManufacturingSetup,ManufacturingSetup."Show Capacity In",'',TRUE,TRUE,TRUE);
Member of Lib.Library - Manufacturing


UpdateOutputJournal@13 Method

The procedure UpdateOutputJournal is available in codeunit 132202.

Syntax

UpdateOutputJournal@13(
    ProductionOrderNo@1002 : Code[20] ProductionOrderNo //Input parameter of type Code
);

Parameters

ProductionOrderNo
Input parameter of type Code

Remarks

The relevant search keywords are: Update, Output, Journal.

For a clarification about how this function works, refer to the code listed below.

      ItemJournalLine.SETRANGE("Order Type",ItemJournalLine."Order Type"::Production);
      ItemJournalLine.SETRANGE("Order No.",ProductionOrderNo);
      ItemJournalLine.FINDSET;
      REPEAT
        ProdOrderRoutingLine.SETRANGE("Routing No.",ItemJournalLine."Routing No.");
        CASE ItemJournalLine.Type OF
          ItemJournalLine.Type::"Work Center":
            ProdOrderRoutingLine.SETRANGE(Type,ProdOrderRoutingLine.Type::"Work Center");
          ItemJournalLine.Type::"Machine Center":
            ProdOrderRoutingLine.SETRANGE(Type,ProdOrderRoutingLine.Type::"Machine Center");
        END;
        ProdOrderRoutingLine.SETRANGE("No.",ItemJournalLine."No.");
        ProdOrderRoutingLine.FINDFIRST;
        ItemJournalLine.VALIDATE("Setup Time",ProdOrderRoutingLine."Setup Time");
        ItemJournalLine.VALIDATE("Run Time",ProdOrderRoutingLine."Run Time");
        ItemJournalLine.MODIFY(TRUE);
      UNTIL ItemJournalLine.NEXT = 0;

Example

There are no examples available.
Member of Lib.Library - Manufacturing


UpdateProdOrderComp@57 Method

The procedure UpdateProdOrderComp is available in codeunit 132202.

Syntax

UpdateProdOrderComp@57(
    VAR ProdOrderComponent@1000 : Record 5407 ProdOrderComponent, //Reference parameter of type Record
    FieldNo@1001 : Integer FieldNo, //Input parameter of type Integer
    Value@1004 : Variant Value //Input parameter of type Variant
);

Parameters

ProdOrderComponent
Reference parameter of type Record
FieldNo
Input parameter of type Integer
Value
Input parameter of type Variant

Remarks

The relevant search keywords are: Update, Product, Order, Comp.

For a clarification about how this function works, refer to the code listed below.

      RecRef.GETTABLE(ProdOrderComponent);
      FieldRef := RecRef.FIELD(FieldNo);
      FieldRef.VALIDATE(Value);
      RecRef.SETTABLE(ProdOrderComponent);
      ProdOrderComponent.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137392 to show one way of using this function.

      SetupAbleToMake(BOMBuffer,FALSE,SupplyType::Inventory,1,TRUE,'<0D>',1,2,0.4,GLBDateInterval::Day);
      EVALUATE(DueDateDelayDateFormula,DueDateDelay);
      AbleToMake := BOMBuffer."Able to Make Top Item";
      LibraryManufacturing.CreateProductionOrder(
        ProductionOrder,ProductionOrder.Status::Released,ProductionOrder."Source Type"::Item,BOMBuffer."No.",
        RANDOM(ROUND(AbleToMake * 0.4,1,'<')));
      ProductionOrder.VALIDATE("Due Date",CALCDATE(DueDateDelayDateFormula,WORKDATE));
      ProductionOrder.MODIFY(TRUE);
      LibraryManufacturing.RefreshProdOrder(ProductionOrder,FALSE,TRUE,FALSE,TRUE,FALSE);
      ProductionOrder.FIND;
      FindProdOrderLine(ProdOrderLine,ProductionOrder);
      LibraryManufacturing.CreateProductionOrderComponent(
        ProdOrderComponent,ProductionOrder.Status,ProductionOrder."No.",ProdOrderLine."Line No.");
      LibraryInventory.CreateItem(Item);
      LibraryWarehouse.CreateLocation(Location);

      CASE ProdOrderFilterType OF
        FilterType::"Header Location":
          LibraryManufacturing.UpdateProdOrderLine(ProdOrderLine,ProdOrderLine.FIELDNO("Location Code"),Location.Code);
        FilterType::"Header Variant":
          LibraryManufacturing.UpdateProdOrderLine(ProdOrderLine,ProdOrderLine.FIELDNO("Variant Code"),'');
        FilterType::"Component Location":
          BEGIN
            ProdOrderComponent.VALIDATE("Item No.",Item."No.");
            ProdOrderComponent.VALIDATE("Quantity per",RANDOM(5));
            ProdOrderComponent.MODIFY(TRUE);
            LibraryTrees.CreateSupply(
              Item."No.",'',BOMBuffer."Location Code",WORKDATE,SupplyType::Inventory,
              ProductionOrder.Quantity * ProdOrderComponent."Quantity per");
            LibraryManufacturing.UpdateProdOrderComp(ProdOrderComponent,ProdOrderComponent.FIELDNO("Location Code"),Location.Code);
            LibraryManufacturing.UpdateProdOrderLine(ProdOrderLine,ProdOrderLine.FIELDNO("Location Code"),BOMBuffer."Location Code");
          END;
        ELSE
          LibraryManufacturing.UpdateProdOrderLine(ProdOrderLine,ProdOrderLine.FIELDNO("Location Code"),BOMBuffer."Location Code");
      END;

      // Exercise: Run Able To Make codeunit.
      CalculateBOMTree.SetShowTotalAvailability(TRUE);
      CalculateBOMTree.GenerateTreeForProdLine(ProdOrderLine,BOMBuffer,TreeType::Availability);

      // Verify: Able to make report.
      VerifyAbleToMakeReport(BOMBuffer,WORKDATE,GLBDateInterval::Day,ProdOrderLine."Location Code",'',ProductionOrder."No.");
Member of Lib.Library - Manufacturing


UpdateProdOrderLine@58 Method

The procedure UpdateProdOrderLine is available in codeunit 132202.

Syntax

UpdateProdOrderLine@58(
    VAR ProdOrderLine@1000 : Record 5406 ProdOrderLine, //Reference parameter of type Record
    FieldNo@1001 : Integer FieldNo, //Input parameter of type Integer
    Value@1004 : Variant Value //Input parameter of type Variant
);

Parameters

ProdOrderLine
Reference parameter of type Record
FieldNo
Input parameter of type Integer
Value
Input parameter of type Variant

Remarks

The relevant search keywords are: Update, Product, Order, Line.

For a clarification about how this function works, refer to the code listed below.

      RecRef.GETTABLE(ProdOrderLine);
      FieldRef := RecRef.FIELD(FieldNo);
      FieldRef.VALIDATE(Value);
      RecRef.SETTABLE(ProdOrderLine);
      ProdOrderLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137107 to show one way of using this function.

      SetupAbleToMake(BOMBuffer,FALSE,FALSE,SupplyType::Purchase,1,TRUE,'<0D>',1,1,0.4);
      EVALUATE(DueDateDelayDateFormula,DueDateDelay);
      LibraryManufacturing.CreateProductionOrder(
        ProductionOrder,ProductionOrder.Status::Released,ProductionOrder."Source Type"::Item,BOMBuffer."No.",
        BOMBuffer."Able to Make Top Item");
      LibraryManufacturing.RefreshProdOrder(ProductionOrder,FALSE,TRUE,FALSE,TRUE,FALSE);

      FindProdOrderLine(ProdOrderLine,ProductionOrder);
      LibraryManufacturing.UpdateProdOrderLine(ProdOrderLine,ProdOrderLine.FIELDNO("Location Code"),BOMBuffer."Location Code");
      LibraryManufacturing.UpdateProdOrderLine(ProdOrderLine,ProdOrderLine.FIELDNO("Variant Code"),BOMBuffer."Variant Code");
      LibraryManufacturing.UpdateProdOrderLine(
        ProdOrderLine,ProdOrderLine.FIELDNO("Due Date"),CALCDATE(DueDateDelayDateFormula,WORKDATE));

      LibraryManufacturing.CreateProductionOrderComponent(
        ProdOrderComponent,ProductionOrder.Status,ProductionOrder."No.",ProdOrderLine."Line No.");
      LibraryInventory.CreateItem(Item);
      ProdOrderComponent.VALIDATE("Item No.",Item."No.");
      ProdOrderComponent.VALIDATE("Quantity per",RANDOM(5));
      ProdOrderComponent.MODIFY(TRUE);
      LibraryTrees.CreateSupply(
        Item."No.",'',BOMBuffer."Location Code",WORKDATE,SupplyType::Inventory,
        ProductionOrder.Quantity * ProdOrderComponent."Quantity per");

      IF TestLocation THEN BEGIN
        LibraryWarehouse.CreateLocation(Location);
        LibraryManufacturing.UpdateProdOrderLine(ProdOrderLine,ProdOrderLine.FIELDNO("Location Code"),Location.Code);
      END;

      AbleToMake := ProductionOrder.Quantity;

      // Exercise.
      CalculateBOMTree.SetShowTotalAvailability(TRUE);
      CalculateBOMTree.GenerateTreeForProdLine(ProdOrderLine,BOMBuffer,TreeType::Availability);

      // Verify: Check top item.
      VerifyTopItem(BOMBuffer,ProdOrderLine."Item No.",AbleToMake,0,TRUE);

      // Verify: BOM Level - Able to Make page.
      ReleasedProductionOrder.OPENEDIT;
      ReleasedProductionOrder.FILTER.SETFILTER("No.",ProductionOrder."No.");

      ReleasedProductionOrder.ProdOrderLines.ItemAvailabilityByBOMLevel.INVOKE;
      ReleasedProductionOrder.OK.INVOKE;
Member of Lib.Library - Manufacturing


UpdateProductionBOMStatus@44 Method

The procedure UpdateProductionBOMStatus is available in codeunit 132202.

Syntax

UpdateProductionBOMStatus@44(
    VAR ProductionBOMHeader@1000 : Record 99000771 ProductionBOMHeader, //Reference parameter of type Record
    NewStatus@1001 : Option NewStatus //Input parameter of type Option
);

Parameters

ProductionBOMHeader
Reference parameter of type Record
NewStatus
Input parameter of type Option

Remarks

The relevant search keywords are: Update, Production, BOM, Status.

For a clarification about how this function works, refer to the code listed below.

      ProductionBOMHeader.VALIDATE(Status,NewStatus);
      ProductionBOMHeader.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137036 to show one way of using this function.

      LibraryManufacturing.CreateProductionBOMHeader(ProductionBOMHeader,UoMCode);
      CreateProductionBOMLineInSpecifiedPosition(
        ProductionBOMHeader,ProductionBOMLine,ComponentItemNo,QtyPer,LibraryUtility.GenerateGUID);
      CreateProductionBOMLineInSpecifiedPosition(
        ProductionBOMHeader,ProductionBOMLine,ComponentItemNo,QtyPer,LibraryUtility.GenerateGUID);
      LibraryManufacturing.UpdateProductionBOMStatus(ProductionBOMHeader,ProductionBOMHeader.Status::Certified);
Member of Lib.Library - Manufacturing


UpdateRoutingStatus@45 Method

The procedure UpdateRoutingStatus is available in codeunit 132202.

Syntax

UpdateRoutingStatus@45(
    VAR RoutingHeader@1000 : Record 99000763 RoutingHeader, //Reference parameter of type Record
    NewStatus@1001 : Option NewStatus //Input parameter of type Option
);

Parameters

RoutingHeader
Reference parameter of type Record
NewStatus
Input parameter of type Option

Remarks

The relevant search keywords are: Update, Routing, Status.

For a clarification about how this function works, refer to the code listed below.

      RoutingHeader.VALIDATE(Status,NewStatus);
      RoutingHeader.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137034 to show one way of using this function.

      // [FEATURE] [Routing] [Production Order]
      // [SCENARIO 230130] Finished operations should not be excluded when recalculating the production order routing, routing type is Serial

      Initialize;
      LibraryManufacturing.CreateWorkCenterWithCalendar(WorkCenter);

      OperationNo[1] := '100';
      OperationNo[2] := '200';
      OperationNo[3] := '150';

      // [GIVEN] Serial routing "R" with 2 operations: "100" and "200"
      LibraryManufacturing.CreateRoutingHeader(RoutingHeader,RoutingHeader.Type::Serial);
      LibraryManufacturing.CreateRoutingLine(
        RoutingHeader,RoutingLine,'',OperationNo[1],RoutingLine.Type::"Work Center",WorkCenter."No.");
      LibraryManufacturing.CreateRoutingLine(
        RoutingHeader,RoutingLine,'',OperationNo[2],RoutingLine.Type::"Work Center",WorkCenter."No.");
      LibraryManufacturing.UpdateRoutingStatus(RoutingHeader,RoutingHeader.Status::Certified);

      // [GIVEN] Item with the routing "R", released production order for that item
      ItemNo := CreateItemWithRouting(RoutingHeader."No.");
      CreateAndRefreshRelProdOrder(ProductionOrder,ProductionOrder."Source Type"::Item,ItemNo);

      // [GIVEN] Change the status of the operation "200" in the production order routing to "Finished"
      FindProdOrderRoutingLine(ProdOrderRoutingLine,ProductionOrder.Status,ProductionOrder."No.",OperationNo[2]);
      UpdateProdOrderRoutingLineStatus(
        ProductionOrder.Status,ProductionOrder."No.",OperationNo[2],ProdOrderRoutingLine."Routing Status"::Finished);

      // [WHEN] Insert a new operation "150" in the prod. order routing, it is sequenced between operations 100 and 200
      CreateProdOrderRoutingLine(
        ProdOrderRoutingLine,ProductionOrder,ProdOrderRoutingLine."Routing Reference No.",ProdOrderRoutingLine."Routing No.",
        OperationNo[3],WorkCenter."No.");
      ProdOrderRoutingLine.VALIDATE("Run Time",LibraryRandom.RandInt(10));

      // [THEN] Routing is recalculated, all operations have "Next Operation No." and "Previous Operation No."
      // [THEN] Operations sequence is 100 -> 150 -> 200
      VerifyProdOrderRtngLineNextPrevOperation(ProductionOrder.Status,ProductionOrder."No.",OperationNo[1],OperationNo[3],'');
      VerifyProdOrderRtngLineNextPrevOperation(ProductionOrder.Status,ProductionOrder."No.",OperationNo[2],'',OperationNo[3]);
      VerifyProdOrderRtngLineNextPrevOperation(
        ProductionOrder.Status,ProductionOrder."No.",OperationNo[3],OperationNo[2],OperationNo[1]);
Member of Lib.Library - Manufacturing


UpdateShopCalendarFullWorkingWeekCustomTime@41 Method

The procedure UpdateShopCalendarFullWorkingWeekCustomTime is available in codeunit 132202.

Syntax

UpdateShopCalendarFullWorkingWeekCustomTime@41(
    FromTime@1001 : Time FromTime, //Input parameter of type Time
    ToTime@1000 : Time ToTime //Input parameter of type Time
);

Parameters

FromTime
Input parameter of type Time
ToTime
Input parameter of type Time

Return Value

Code[10]

Remarks

The relevant search keywords are: Update, Shop, Calendar, Full, Working, Week, Custom, Time.

For a clarification about how this function works, refer to the code listed below.

      EXIT(CreateShopCalendarCustomTime(ShopCalendarWorkingDays.Day::Monday,ShopCalendarWorkingDays.Day::Sunday,FromTime,ToTime));

Example

The below example is extracted from the test automation codeunit 137004 to show one way of using this function.

      ShopCalendarCode := LibraryManufacturing.UpdateShopCalendarFullWorkingWeekCustomTime(080000T,160000T);
      CreateWorkCenterWithFixedCost(WorkCenter,ShopCalendarCode,DirectUnitCost);
      LibraryManufacturing.CalculateWorkCenterCalendar(WorkCenter,CALCDATE('<-1W>',WORKDATE),WORKDATE);
Member of Lib.Library - Manufacturing


UpdateShopCalendarWorkingDays@15 Method

The procedure UpdateShopCalendarWorkingDays is available in codeunit 132202.

Syntax

UpdateShopCalendarWorkingDays@15(
      //param element not supplied
);

Return Value

Code[10]

Remarks

The relevant search keywords are: Update, Shop, Calendar, Working, Days.

For a clarification about how this function works, refer to the code listed below.

      // Create Shop Calendar Working Days using 8 hrs daily work shift.
      EXIT(UpdateShopCalendarWorkingDaysCustomTime(080000T,160000T));

Example

The below example is extracted from the test automation codeunit 137004 to show one way of using this function.

      // Steps describing the sequence of actions for Test Case.

      // 1. Create required WIP setups with Flushing method as Manual with Subcontract.
      // Update Manufacturing Setup, Inventory Setup and Update Shop Calendar Working Days based on Work Shift code.
      Initialize;
      RaiseConfirmHandler;
      LibraryManufacturing.CreateWorkCenterGroup(WorkCenterGroup);
      LibraryManufacturing.CreateCapacityUnitOfMeasure(CapacityUnitOfMeasure,Type::Minutes);
      LibraryInventory.UpdateInventorySetup(
        InventorySetup,TRUE,FALSE,AutomaticCostAdjustment::Never,AverageCostCalcType::Item,AverageCostPeriod::Day);
      LibraryManufacturing.UpdateManufacturingSetup(ManufacturingSetup,'','',TRUE,TRUE,TRUE);
      ShopCalendarCode := LibraryManufacturing.UpdateShopCalendarWorkingDays;
      IF AdditionalCurrencyExist THEN
        CurrencyCode := UpdateAddnlReportingCurrency
      ELSE
        LibraryERM.SetAddReportingCurrency('');

      // Create Work Center and Machine Center with Flushing method -Manual.
      // Create Work Center for Subcontractor with Flushing method -Manual.
      // Create Routing.
      CreateWorkCenter(WorkCenterNo,ShopCalendarCode,FlushingMethod,FALSE,UnitCostCalculation,'');
      CreateMachineCenter(MachineCenterNo,WorkCenterNo,FlushingMethod);
      CreateMachineCenter(MachineCenterNo2,WorkCenterNo,FlushingMethod);
      IF UpdateProdOrderRouting THEN
        CreateMachineCenter(MachineCenterNo3,WorkCenterNo,FlushingMethod);
      IF Subcontract THEN
        CreateWorkCenter(WorkCenterNo2,ShopCalendarCode,SubcontractFlushingMethod,TRUE,UnitCostCalculation,CurrencyCode)
      ELSE
        CreateWorkCenter(WorkCenterNo2,ShopCalendarCode,FlushingMethod,FALSE,UnitCostCalculation,CurrencyCode);
      RoutingNo := NoSeriesManagement.GetNextNo(ManufacturingSetup."Routing Nos.",WORKDATE,TRUE);
      CreateRouting(RoutingNo,MachineCenterNo,MachineCenterNo2,WorkCenterNo,WorkCenterNo2);

      // Create Items with Flushing method - Manual with the Parent Item containing Routing No. and Production BOM No.
      CreateItem(Item,CostingMethod,Item."Reordering Policy"::"Lot-for-Lot",FlushingMethod,'','');
      ItemNo := Item."No.";
      CLEAR(Item);
      CreateItem(Item,CostingMethod,Item."Reordering Policy"::"Lot-for-Lot",FlushingMethod,'','');
      ItemNo2 := Item."No.";
      CLEAR(Item);
      IF UpdateProductionComponent THEN BEGIN
        CreateItem(Item,Item."Costing Method"::Standard,Item."Reordering Policy"::"Lot-for-Lot",FlushingMethod,'','');
        ItemNo3 := Item."No.";
        CLEAR(Item);
      END;
      ProductionBOMNo :=
        LibraryManufacturing.CreateCertifProdBOMWithTwoComp(
          ProductionBOMHeader,ItemNo,ItemNo2,1); // value imporatant.
      CreateItem(Item,CostingMethod,Item."Reordering Policy"::"Lot-for-Lot",FlushingMethod,RoutingNo,ProductionBOMNo);

      // Calculate Standard Cost for Parent Item, if Costing Method is Standard.
      // Calculate Calendar for Work Center with dates having a difference of 5 weeks.
      // Create and Post Purchase Order as Receive and Invoice.
      IF  Item."Costing Method" = Item."Costing Method"::Standard THEN
        CalculateStandardCost.CalcItem(Item."No.",FALSE);
      CalculateCalendar(MachineCenterNo,MachineCenterNo2,WorkCenterNo,WorkCenterNo2);
      IF NOT AdditionalCurrencyExist THEN
        CreatePurchaseOrder(
          PurchaseHeader,PurchaseLine,ItemNo,ItemNo2,ItemNo3,LibraryRandom.RandInt(100) + 10,
          LibraryRandom.RandInt(100) + 10,LibraryRandom.RandInt(100) + 50,UpdateProductionComponent)
      ELSE
        CreatePurchaseOrderAddnlCurr(PurchaseHeader,PurchaseLine,CurrencyCode,ItemNo,ItemNo2,ItemNo3,
          LibraryRandom.RandInt(100) + 10,UpdateProductionComponent);

      IF AdjustExchangeRatesGLSetup THEN BEGIN
        UpdateExchangeRate(CurrencyCode);
        LibraryERM.RunAdjustExchangeRates(
          CurrencyCode,WORKDATE,WORKDATE,PurchaseHeader."No.",WORKDATE,LibraryUtility.GenerateGUID,TRUE);
      END;

      // Create and Refresh Production Order.
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);
      LibraryManufacturing.CreateProductionOrder(
        ProductionOrder,ProductionOrderStatus,ProductionOrder."Source Type"::Item,Item."No.",LibraryRandom.RandInt(10) + 5);
      LibraryManufacturing.RefreshProdOrder(ProductionOrder,FALSE,TRUE,TRUE,TRUE,FALSE);
      IF UpdateProdOrderRouting THEN BEGIN
        MachineCenter.GET(MachineCenterNo3);
        LibraryManufacturing.CalculateMachCenterCalendar(MachineCenter,CALCDATE('<-1M>',WORKDATE),CALCDATE('<1M>',WORKDATE));
        AddProdOrderRoutingLine(ProductionOrder,ProductionOrderRoutingType::"Machine Center",MachineCenterNo3);
        LibraryManufacturing.RefreshProdOrder(ProductionOrder,FALSE,FALSE,FALSE,TRUE,FALSE);
      END;

      // Create Subcontracting Worksheet, Make order and Post Subcontracting Purchase Order.
      IF Subcontract THEN BEGIN
        LibraryManufacturing.CalculateSubcontractOrder(WorkCenter);
        MakeSubconPurchOrder(ProductionOrder."No.",WorkCenterNo2);
        PostSubconPurchOrder(TempPurchaseLine,ProductionOrder."No.",SubcontractCostDiff);
      END;

      // Remove one component from Production Order and Replace it with a New Component.
      IF UpdateProductionComponent THEN
        ReplaceProdOrderComponent(ProductionOrder."No.",ItemNo2,Item."No.",ItemNo3);

      // Create, Calculate and Post Consumption Journal, Explode Routing and Post Output Journal.
      IF Item."Flushing Method" = Item."Flushing Method"::Manual THEN BEGIN
        LibraryInventory.CreateItemJournal(
          ItemJournalBatch,ItemNo,ItemJournalBatch."Template Type"::Consumption,ProductionOrder."No.");
        IF DeleteConsumptionJrnl THEN
          RemoveProdOrderComponent(ProductionOrder."No.",ItemNo);
        IF ConsumptionCostDiff THEN
          UpdateQtyConsumptionJournal(ProductionOrder."No.",ItemNo2);
        LibraryInventory.PostItemJournalLine(ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name);
        LibraryInventory.CreateItemJournal(ItemJournalBatch,ItemNo3,ItemJournalBatch."Template Type"::Output,ProductionOrder."No.");
        IF OutputCostDiff THEN
          UpdateLessQtyOutputJournal(ProductionOrder."No.",ProductionOrder.Quantity);
        IF RunSetupTimeCostDiff THEN BEGIN
          SetupTime := 1;
          RunTime := 1;
          UpdateSetupRunTime(ProductionOrder."No.",SetupTime,RunTime);
        END;
        LibraryInventory.PostItemJournalLine(ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name);
      END;

      // Change Production Order Status.
      IF ProductionOrder.Status = ProductionOrder.Status::Planned THEN
        ProductionOrderNo :=
          LibraryManufacturing.ChangeStatusPlannedToFinished(ProductionOrder."No.") // Change Status from Planned to Finished.
      ELSE
        LibraryManufacturing.ChangeStatusReleasedToFinished(ProductionOrder."No.");
      // Change Status of Production Order from Released to Finished.

      // 2. Execute Adjust Cost Item Entries report and Post Inventory Cost to G/L report.
      ProductionOrder.SETRANGE(Status,ProductionOrder.Status::Finished);
      IF ProductionOrderNo <> '' THEN
        ProductionOrder.SETRANGE("No.",ProductionOrderNo)
      ELSE
        ProductionOrder.SETRANGE("No.",ProductionOrder."No.");
      ProductionOrder.FINDFIRST;
      AdjustCostPostInventoryCostGL(ItemNo + '..' + ItemNo3);

      // 3. Verify GL Entry : Total amount and Positive amount entries for WIP Account.
      VerifyGLEntryForWIPAccounts(
        TempPurchaseLine,ItemNo,ProductionOrder."No.",CurrencyCode,SetupTime,RunTime,AdditionalCurrencyExist);

      // 4.Tear Down.
      TearDown(AdditionalCurrencyExist,Subcontract,Item."No.");
Member of Lib.Library - Manufacturing


UpdateShopCalendarWorkingDaysCustomTime@125 Method

The procedure UpdateShopCalendarWorkingDaysCustomTime is available in codeunit 132202.

Syntax

UpdateShopCalendarWorkingDaysCustomTime@125(
    FromTime@1005 : Time FromTime, //Input parameter of type Time
    ToTime@1006 : Time ToTime //Input parameter of type Time
);

Parameters

FromTime
Input parameter of type Time
ToTime
Input parameter of type Time

Return Value

Code[10]

Remarks

The relevant search keywords are: Update, Shop, Calendar, Working, Days, Custom, Time.

For a clarification about how this function works, refer to the code listed below.

      EXIT(CreateShopCalendarCustomTime(ShopCalendarWorkingDays.Day::Monday,ShopCalendarWorkingDays.Day::Friday,FromTime,ToTime));

Example

There are no examples available.
Member of Lib.Library - Manufacturing


Library - Marketing Class

Lib.Library - Marketing

COD131900 applies to RES,ERM,SCM,W1,All.
Contains all utility functions related to Marketing.

Methods

Name | Description
CreateActivity@27 | The procedure CreateActivity is available in codeunit 131900.
CreateActivityStep@36 | The procedure CreateActivityStep is available in codeunit 131900.
CreateAttachment@40 | The procedure CreateAttachment is available in codeunit 131900.
CreateBusinessRelation@14 | The procedure CreateBusinessRelation is available in codeunit 131900.
CreateCampaign@1 | The procedure CreateCampaign is available in codeunit 131900.
CreateCampaignStatus@2 | The procedure CreateCampaignStatus is available in codeunit 131900.
CreateCloseOpportunityCode@21 | The procedure CreateCloseOpportunityCode is available in codeunit 131900.
CreateCompanyContact@44 | The procedure CreateCompanyContact is available in codeunit 131900.
CreateContact@6 | The procedure CreateContact is available in codeunit 131900.
CreateContactAltAddrDateRange@11 | The procedure CreateContactAltAddrDateRange is available in codeunit 131900.
CreateContactAltAddress@10 | The procedure CreateContactAltAddress is available in codeunit 131900.
CreateContactBusinessRelation@13 | The procedure CreateContactBusinessRelation is available in codeunit 131900.
CreateContactIndustryGroup@12 | The procedure CreateContactIndustryGroup is available in codeunit 131900.
CreateContactJobResponsibility@26 | The procedure CreateContactJobResponsibility is available in codeunit 131900.
CreateContactMailingGroup@19 | The procedure CreateContactMailingGroup is available in codeunit 131900.
CreateContactWebSource@20 | The procedure CreateContactWebSource is available in codeunit 131900.
CreateInteractionGroup@30 | The procedure CreateInteractionGroup is available in codeunit 131900.
CreateInteractionTemplate@3 | The procedure CreateInteractionTemplate is available in codeunit 131900.
CreateIntrastatContact@51 | The procedure CreateIntrastatContact is available in codeunit 131900.
CreateJobResponsibility@17 | The procedure CreateJobResponsibility is available in codeunit 131900.
CreateMailingGroup@15 | The procedure CreateMailingGroup is available in codeunit 131900.
CreateOpportunity@7 | The procedure CreateOpportunity is available in codeunit 131900.
CreatePersonContact@45 | The procedure CreatePersonContact is available in codeunit 131900.
CreateProfileQuestionnaireLine@28 | The procedure CreateProfileQuestionnaireLine is available in codeunit 131900.
CreateQuestionnaireHeader@29 | The procedure CreateQuestionnaireHeader is available in codeunit 131900.
CreateRlshpMgtCommentContact@22 | The procedure CreateRlshpMgtCommentContact is available in codeunit 131900.
CreateRlshpMgtCommentLine@18 | The procedure CreateRlshpMgtCommentLine is available in codeunit 131900.
CreateRlshpMgtCommentSales@32 | The procedure CreateRlshpMgtCommentSales is available in codeunit 131900.
CreateSalesCycle@23 | The procedure CreateSalesCycle is available in codeunit 131900.
CreateSalesCycleStage@31 | The procedure CreateSalesCycleStage is available in codeunit 131900.
CreateSalesHeaderWithContact@39 | The procedure CreateSalesHeaderWithContact is available in codeunit 131900.
CreateSalesLineDiscount@9 | The procedure CreateSalesLineDiscount is available in codeunit 131900.
CreateSalesPriceForCampaign@8 | The procedure CreateSalesPriceForCampaign is available in codeunit 131900.
CreateSalutation@33 | The procedure CreateSalutation is available in codeunit 131900.
CreateSalutationFormula@34 | The procedure CreateSalutationFormula is available in codeunit 131900.
CreateSegmentHeader@4 | The procedure CreateSegmentHeader is available in codeunit 131900.
CreateSegmentLine@5 | The procedure CreateSegmentLine is available in codeunit 131900.
CreateTeam@25 | The procedure CreateTeam is available in codeunit 131900.
CreateTeamSalesperson@24 | The procedure CreateTeamSalesperson is available in codeunit 131900.
CreateToDo@38 | The procedure CreateToDo is available in codeunit 131900.
CreateWebSource@16 | The procedure CreateWebSource is available in codeunit 131900.
FindContact@35 | The procedure FindContact is available in codeunit 131900.
FindCustomerTemplate@37 | The procedure FindCustomerTemplate is available in codeunit 131900.

See Also

Lib


CreateActivity@27 Method

The procedure CreateActivity is available in codeunit 131900.

Syntax

CreateActivity@27(
    VAR Activity@1000 : Record 5081 Activity //Reference parameter of type Record
);

Parameters

Activity
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Activity.

For a clarification about how this function works, refer to the code listed below.

      Activity.INIT;
      Activity.VALIDATE(Code,LibraryUtility.GenerateRandomCode(Activity.FIELDNO(Code),DATABASE::Activity));
      Activity.VALIDATE(Description,Activity.Code);  // Validating Code as Description because value is not important.
      Activity.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136203 to show one way of using this function.

      // Covers document number TC0006 - refer to TFS ID 21732.
      // Test To-Do for Contact, Salesperson and Team after Assign activity through Assign Activity wizard for Contact.

      // 1. Setup: Create Team, Salesperson, attach Salesperson to Team and Create Activity.
      CreateTeamWithSalesperson(Team,SalespersonPurchaser);
      LibraryMarketing.CreateActivity(Activity);
      CreateActivityStep(Activity.Code,ActivityStep.Type::" ",ActivityStep.Priority::Low,'');
      CreateActivityStep(Activity.Code,ActivityStep.Type::"Phone Call",ActivityStep.Priority::Normal,DateFormula2);
      CreateActivityStep(Activity.Code,ActivityStep.Type::Meeting,ActivityStep.Priority::High,DateFormula3);

      // Set global variable for Form Handler.
      InitializeGlobalVariable;
      ActivityCode := Activity.Code;
      SalespersonCode2 := SalespersonPurchaser.Code;
      TeamCode := Team.Code;

      // 2. Exercise: Select Contact with type Company and assign Activity to Contact.
      Contact.SETRANGE(Type,Contact.Type::Company);
      Contact.FINDFIRST;
      ContactNo := Contact."No.";
      TempToDo.AssignActivityFromToDo(ToDo);

      // 3. Verify: Verify To-Do for Contact, Salesperson and Team after Assign activity.
      VerifyContactActivity(Contact."No.",Activity.Code,Team.Code);
      VerifyTeamActivity(Activity.Code,Team.Code);
      VerifySalespersonActivity(SalespersonPurchaser.Code,Activity.Code,Team.Code);
Member of Lib.Library - Marketing


CreateActivityStep@36 Method

The procedure CreateActivityStep is available in codeunit 131900.

Syntax

CreateActivityStep@36(
    VAR ActivityStep@1000 : Record 5082 ActivityStep, //Reference parameter of type Record
    ActivityCode@1001 : Code[10] ActivityCode //Input parameter of type Code
);

Parameters

ActivityStep
Reference parameter of type Record
ActivityCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Activity, Step.

For a clarification about how this function works, refer to the code listed below.

      ActivityStep.INIT;
      ActivityStep.VALIDATE("Activity Code",ActivityCode);
      RecRef.GETTABLE(ActivityStep);
      ActivityStep.VALIDATE("Step No.",LibraryUtility.GetNewLineNo(RecRef,ActivityStep.FIELDNO("Step No.")));
      ActivityStep.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136203 to show one way of using this function.

      LibraryMarketing.CreateActivityStep(ActivityStep,ActivityCode);
      ActivityStep.VALIDATE(Type,Type);
      ActivityStep.VALIDATE(Priority,Priority);
      EVALUATE(ActivityStep."Date Formula",DateFormula);
      ActivityStep.MODIFY(TRUE);
Member of Lib.Library - Marketing


CreateAttachment@40 Method

The procedure CreateAttachment is available in codeunit 131900.

Syntax

CreateAttachment@40(
    VAR Attachment@1000 : Record 5062 Attachment //Reference parameter of type Record
);

Parameters

Attachment
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Attachment.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(Attachment);

      IF Attachment.FINDLAST THEN
        No := Attachment."No." + 1;

      Attachment.INIT;
      Attachment."No." := No;
      Attachment.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136450 to show one way of using this function.

      // Setup:
      Initialize;

      RelocateAttachments(MarketingSetup."Attachment Storage Type"::"Disk File",
        CreateOrClearTempDirectory(NewDirName));

      // Exercise: Create & Import attachment
      ImportFromFile := CreateServerTxtFile('TXT');

      LibraryMarketing.CreateAttachment(Attachment);
      Attachment.ImportAttachmentFromServerFile(ImportFromFile,FALSE,FALSE);

      // Verify attachment
      Assert.IsTrue(EXISTS(Attachment.ConstDiskFileName),'Attachment file not imported to disk.');
      Assert.IsTrue(Attachment."Storage Type" = Attachment."Storage Type"::"Disk File",'Wrong storage type');

      // Rollback
      Rollback(NewDirName);
Member of Lib.Library - Marketing


CreateBusinessRelation@14 Method

The procedure CreateBusinessRelation is available in codeunit 131900.

Syntax

CreateBusinessRelation@14(
    VAR BusinessRelation@1000 : Record 5053 BusinessRelation //Reference parameter of type Record
);

Parameters

BusinessRelation
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Business, Relation.

For a clarification about how this function works, refer to the code listed below.

      BusinessRelation.INIT;
      BusinessRelation.VALIDATE(Code,LibraryUtility.GenerateRandomCode(BusinessRelation.FIELDNO(Code),DATABASE::"Business Relation"));
      BusinessRelation.VALIDATE(Description,BusinessRelation.Code);  // Validating Code as Description because value is not important.
      BusinessRelation.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134325 to show one way of using this function.

      // Test that a Purchase Quote can be created for a Contact.

      // Setup:  Find a Contact Business Relation.
      Initialize;
      LibraryMarketing.CreateContact(Contact);
      LibraryMarketing.CreateBusinessRelation(BusinessRelation);
      LibraryMarketing.CreateContactBusinessRelation(ContactBusinessRelation,Contact."No.",BusinessRelation.Code);
      ContactBusinessRelation.VALIDATE("Link to Table",ContactBusinessRelation."Link to Table"::Vendor);
      ContactBusinessRelation.VALIDATE("No.",LibraryPurchase.CreateVendorNo);
      ContactBusinessRelation.MODIFY(TRUE);

      // Exercise: Create a Purchase Quote for the Contact.
      PurchaseHeader.INSERT(TRUE);
      PurchaseHeader.VALIDATE("Buy-from Contact No.",ContactBusinessRelation."Contact No.");
      PurchaseHeader.MODIFY(TRUE);

      // Verify: Verify that the Purchase Header Contains the correct Contact.
      Assert.AreEqual(
        ContactBusinessRelation."Contact No.",
        PurchaseHeader."Buy-from Contact No.",STRSUBSTNO(FieldError,PurchaseHeader.FIELDCAPTION("Buy-from Contact No.")));
Member of Lib.Library - Marketing


CreateCampaign@1 Method

The procedure CreateCampaign is available in codeunit 131900.

Syntax

CreateCampaign@1(
    VAR Campaign@1000 : Record 5071 Campaign //Reference parameter of type Record
);

Parameters

Campaign
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Campaign.

For a clarification about how this function works, refer to the code listed below.

      MarketingSetup.GET;
      IF MarketingSetup."Campaign Nos." = '' THEN BEGIN
        MarketingSetup.VALIDATE("Campaign Nos.",LibraryUtility.GetGlobalNoSeriesCode);
        MarketingSetup.MODIFY(TRUE);
      END;

      CLEAR(Campaign);
      Campaign.INIT;
      Campaign.INSERT(TRUE);
      Campaign.VALIDATE(Description,Campaign."No.");  // Validating No. as Description because value is not important.
      Campaign.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 136200 to show one way of using this function.

      // Covers document number TC0064 - refer to TFS ID 21741.
      // Test creation of a campaign and the interactions linked to the campaign.

      // 1. Setup: Create new Campaign Status and Campaign. Link the Campaign Status to the Campaign. Create new Interaction Template
      // with Unit Cost (LCY) and Unit Duration (Min.).
      Initialize;
      LibraryMarketing.CreateCampaignStatus(CampaignStatus);
      LibraryMarketing.CreateCampaign(Campaign);
      Campaign.VALIDATE("Status Code",CampaignStatus.Code);
      Campaign.MODIFY(TRUE);
      CampaignNo2 := Campaign."No.";  // Set global variable for form handler.
      CreateInteractionTemplate(InteractionTemplate);

      // 2. Exercise: Create Interaction for a Contact.
      Contact.FINDFIRST;
      Contact.CreateInteraction;

      // 3. Verify: Check that the Interaction Log Entry and Campaign Entry are created correctly.
      VerifyInteractionLogEntry(InteractionTemplate,Contact."No.",Campaign."No.");
      VerifyCampaignEntry(InteractionTemplate,Campaign."No.");
Member of Lib.Library - Marketing


CreateCampaignStatus@2 Method

The procedure CreateCampaignStatus is available in codeunit 131900.

Syntax

CreateCampaignStatus@2(
    VAR CampaignStatus@1000 : Record 5073 CampaignStatus //Reference parameter of type Record
);

Parameters

CampaignStatus
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Campaign, Status.

For a clarification about how this function works, refer to the code listed below.

      CampaignStatus.INIT;
      CampaignStatus.VALIDATE(Code,LibraryUtility.GenerateRandomCode(CampaignStatus.FIELDNO(Code),DATABASE::"Campaign Status"));
      CampaignStatus.VALIDATE(Description,CampaignStatus.Code);  // Validating Code as Description because value is not important.
      CampaignStatus.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136200 to show one way of using this function.

      // Covers document number TC0064 - refer to TFS ID 21741.
      // Test creation of a campaign and the interactions linked to the campaign.

      // 1. Setup: Create new Campaign Status and Campaign. Link the Campaign Status to the Campaign. Create new Interaction Template
      // with Unit Cost (LCY) and Unit Duration (Min.).
      Initialize;
      LibraryMarketing.CreateCampaignStatus(CampaignStatus);
      LibraryMarketing.CreateCampaign(Campaign);
      Campaign.VALIDATE("Status Code",CampaignStatus.Code);
      Campaign.MODIFY(TRUE);
      CampaignNo2 := Campaign."No.";  // Set global variable for form handler.
      CreateInteractionTemplate(InteractionTemplate);

      // 2. Exercise: Create Interaction for a Contact.
      Contact.FINDFIRST;
      Contact.CreateInteraction;

      // 3. Verify: Check that the Interaction Log Entry and Campaign Entry are created correctly.
      VerifyInteractionLogEntry(InteractionTemplate,Contact."No.",Campaign."No.");
      VerifyCampaignEntry(InteractionTemplate,Campaign."No.");
Member of Lib.Library - Marketing


CreateCloseOpportunityCode@21 Method

The procedure CreateCloseOpportunityCode is available in codeunit 131900.

Syntax

CreateCloseOpportunityCode@21(
    VAR CloseOpportunityCode@1000 : Record 5094 CloseOpportunityCode //Reference parameter of type Record
);

Parameters

CloseOpportunityCode
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Close, Opportunity, Code.

For a clarification about how this function works, refer to the code listed below.

      CloseOpportunityCode.INIT;
      CloseOpportunityCode.VALIDATE(
        Code,LibraryUtility.GenerateRandomCode(CloseOpportunityCode.FIELDNO(Code),DATABASE::"Close Opportunity Code"));
      // Validating Code as Description because value is not important.
      CloseOpportunityCode.VALIDATE(Description,CloseOpportunityCode.Code);
      CloseOpportunityCode.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136201 to show one way of using this function.

      // Covers document number TC0061 - refer to TFS ID 21740.
      // Test the Opportunity statistics information on the Contact card after Closing the Opportunity.

      // 1. Setup: Create a new Contact and Sales Cycle. Create a new Opportunity for Contact. Set global variables for Form Handler with
      // any random decimal values. Create a new Close Opportunity Code.
      Initialize;
      LibraryMarketing.CreateContact(Contact);
      LibraryMarketing.CreateSalesCycle(SalesCycle);

      // Set global variables for form handler with any random decimal values.
      WizardEstimatedValueLCY := LibraryRandom.RandDec(100,2);
      WizardChancesofSuccessPercent := LibraryRandom.RandDec(100,2);
      LibraryVariableStorage.Enqueue(SalesCycle.Code);
      LibraryVariableStorage.Enqueue(WizardEstimatedValueLCY);
      LibraryVariableStorage.Enqueue(WizardChancesofSuccessPercent);

      Opportunity.SETRANGE("Contact No.",Contact."No.");
      TempOpportunity.CreateOppFromOpp(Opportunity);
      LibraryMarketing.CreateCloseOpportunityCode(CloseOpportunityCode);

      // Set global variable for form handler with any random decimal value.
      CalcCurrentValueLCY := LibraryRandom.RandDec(100,2);
      LibraryVariableStorage.Enqueue(CloseOpportunityCode.Code);
      LibraryVariableStorage.Enqueue(CalcCurrentValueLCY);

      // 2. Exercise: Close the Opportunity.
      Opportunity.SETRANGE("Contact No.",Contact."No.");
      Opportunity.FINDFIRST;
      Opportunity.CloseOpportunity;

      // 3. Verify: Check that the Statistics for Opportunity has been updated on Contact.
      Contact.CALCFIELDS("Estimated Value (LCY)","Calcd. Current Value (LCY)","No. of Opportunities");
      Contact.TESTFIELD("No. of Opportunities",1);  // Since one opportunity has been closed as Won.
      TempOpportunity.TESTFIELD("Calcd. Current Value (LCY)",TempOpportunity."Estimated Value (LCY)");
      // Verify: Check that the Opportunity Entry field "Calcd. Current Value" was updated with (Sales (LCY)) value.
      VerifyOpportunityEntry(Opportunity."No.",CalcCurrentValueLCY);
Member of Lib.Library - Marketing


CreateCompanyContact@44 Method

The procedure CreateCompanyContact is available in codeunit 131900.

Syntax

CreateCompanyContact@44(
    VAR Contact@1000 : Record 5050 Contact //Reference parameter of type Record
);

Parameters

Contact
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Company, Contact.

For a clarification about how this function works, refer to the code listed below.

      CreateContactInternal(Contact,Contact.Type::Company);

Example

The below example is extracted from the test automation codeunit 134150 to show one way of using this function.

      // [FEATURE] [Intrastat Setup] [UT]
      // [SCENARIO 255730] "Intrastat Contact No." is blanked when change "Intrastat Contact Type" field value
      Initialize;
      CompanyInformation.GET;

      LibraryMarketing.CreateCompanyContact(Contact);
      LibraryPurchase.CreateVendor(Vendor);
      WITH CompanyInformation DO BEGIN
        VALIDATE("Intrastat Contact Type","Intrastat Contact Type"::Contact);
        VALIDATE("Intrastat Contact No.",Contact."No.");
        VALIDATE("Intrastat Contact Type","Intrastat Contact Type"::Vendor);
        TESTFIELD("Intrastat Contact No.",'');
        VALIDATE("Intrastat Contact No.",Vendor."No.");
        VALIDATE("Intrastat Contact Type","Intrastat Contact Type"::Contact);
        TESTFIELD("Intrastat Contact No.",'');
        VALIDATE("Intrastat Contact No.",Contact."No.");
        VALIDATE("Intrastat Contact Type","Intrastat Contact Type"::" ");
        TESTFIELD("Intrastat Contact No.",'');
        VALIDATE("Intrastat Contact Type","Intrastat Contact Type"::Vendor);
        VALIDATE("Intrastat Contact No.",Vendor."No.");
        VALIDATE("Intrastat Contact Type","Intrastat Contact Type"::" ");
        TESTFIELD("Intrastat Contact No.",'');
      END;
Member of Lib.Library - Marketing


CreateContact@6 Method

The procedure CreateContact is available in codeunit 131900.

Syntax

CreateContact@6(
    VAR Contact@1000 : Record 5050 Contact //Reference parameter of type Record
);

Parameters

Contact
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Contact.

For a clarification about how this function works, refer to the code listed below.

      CreateCompanyContact(Contact);

Example

The below example is extracted from the test automation codeunit 134047 to show one way of using this function.

      // Verify VAT Registration No. for a new contact without Country Code and with Valid VAT Format.

      // Setup: Create new Country/Region, VAT Registration No. Format. Modify Company Information and Create Contact.
      // Take Random Values to create a valid VAT Registration No.
      Initialize;
      CreateCountryVATRegistration(CountryRegionCode);
      CountryRegionCodeOld := ModifyCompanyInformation(CompanyInformation,CountryRegionCode);
      LibraryMarketing.CreateContact(Contact);
      VATRegistrationNo := 'TEST.' + FORMAT(100 + LibraryRandom.RandInt(899));

      // Exercise: Put a valid VAT Registration No. in Contact Card.
      Contact.VALIDATE("VAT Registration No.",VATRegistrationNo);
      Contact.MODIFY(TRUE);

      // Verify: Verify that correct VAT Registration No. updated on Contact.
      Assert.AreEqual(
        VATRegistrationNo,Contact."VAT Registration No.",STRSUBSTNO(VATFormatError,VATRegistrationNo,Contact.TABLECAPTION,
          Contact."No."));

      // Tear Down: Rollback Company Information, Delete Contact, Country Code.
      Contact.DELETE(TRUE);
      ModifyCompanyInformation(CompanyInformation,CountryRegionCodeOld);
      DeleteCountryRegion(CountryRegionCode);
Member of Lib.Library - Marketing


CreateContactAltAddrDateRange@11 Method

The procedure CreateContactAltAddrDateRange is available in codeunit 131900.

Syntax

CreateContactAltAddrDateRange@11(
    VAR ContactAltAddrDateRange@1000 : Record 5052 ContactAltAddrDateRange, //Reference parameter of type Record
    ContactNo@1001 : Code[20] ContactNo, //Input parameter of type Code
    StartingDate@1002 : Date StartingDate //Input parameter of type Date
);

Parameters

ContactAltAddrDateRange
Reference parameter of type Record
ContactNo
Input parameter of type Code
StartingDate
Input parameter of type Date

Remarks

The relevant search keywords are: Create, Contact, Alt, Addr, Date, Range.

For a clarification about how this function works, refer to the code listed below.

      ContactAltAddrDateRange.INIT;
      ContactAltAddrDateRange.VALIDATE("Contact No.",ContactNo);
      ContactAltAddrDateRange.VALIDATE("Starting Date",StartingDate);
      ContactAltAddrDateRange.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136201 to show one way of using this function.

      // Covers document number TC0054 - refer to TFS ID 21740.
      // Test assignment and activation of Alternative Address linked to a Contact.

      // 1. Setup: Create a new Contact, Contact Alternative Address and Contact Alternative Address Date Range.
      Initialize;
      LibraryMarketing.CreateContact(Contact);
      Contact.VALIDATE(
        Address,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(Contact.FIELDNO(Address),DATABASE::Contact),
          1,
          LibraryUtility.GetFieldLength(DATABASE::Contact,Contact.FIELDNO(Address))));
      Contact.MODIFY(TRUE);

      LibraryMarketing.CreateContactAltAddress(ContactAltAddress,Contact."No.");
      LibraryMarketing.CreateContactAltAddrDateRange(ContactAltAddrDateRange,Contact."No.",WORKDATE);
      ContactAltAddrDateRange.VALIDATE("Contact Alt. Address Code",ContactAltAddress.Code);
      ContactAltAddrDateRange.MODIFY(TRUE);

      // 2. Exercise: Create a new Segment Header for the date range in which alternative address is activated, Segment Line and link the
      // Contact to the Segment Line.
      LibraryMarketing.CreateSegmentHeader(SegmentHeader);
      LibraryMarketing.CreateSegmentLine(SegmentLine,SegmentHeader."No.");
      SegmentLine.VALIDATE("Contact No.",Contact."No.");
      SegmentLine.MODIFY(TRUE);

      // 3. Verify: Check that the Contact Alternative Address Code on the Segment Line is the same as that created earlier.
      SegmentLine.TESTFIELD("Contact Alt. Address Code",ContactAltAddress.Code);
Member of Lib.Library - Marketing


CreateContactAltAddress@10 Method

The procedure CreateContactAltAddress is available in codeunit 131900.

Syntax

CreateContactAltAddress@10(
    VAR ContactAltAddress@1000 : Record 5051 ContactAltAddress, //Reference parameter of type Record
    ContactNo@1001 : Code[20] ContactNo //Input parameter of type Code
);

Parameters

ContactAltAddress
Reference parameter of type Record
ContactNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Contact, Alt, Address.

For a clarification about how this function works, refer to the code listed below.

      ContactAltAddress.INIT;
      ContactAltAddress.VALIDATE("Contact No.",ContactNo);
      ContactAltAddress.VALIDATE(
        Code,LibraryUtility.GenerateRandomCode(ContactAltAddress.FIELDNO(Code),DATABASE::"Contact Alt. Address"));
      ContactAltAddress.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136201 to show one way of using this function.

      // Covers document number TC0054 - refer to TFS ID 21740.
      // Test assignment and activation of Alternative Address linked to a Contact.

      // 1. Setup: Create a new Contact, Contact Alternative Address and Contact Alternative Address Date Range.
      Initialize;
      LibraryMarketing.CreateContact(Contact);
      Contact.VALIDATE(
        Address,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(Contact.FIELDNO(Address),DATABASE::Contact),
          1,
          LibraryUtility.GetFieldLength(DATABASE::Contact,Contact.FIELDNO(Address))));
      Contact.MODIFY(TRUE);

      LibraryMarketing.CreateContactAltAddress(ContactAltAddress,Contact."No.");
      LibraryMarketing.CreateContactAltAddrDateRange(ContactAltAddrDateRange,Contact."No.",WORKDATE);
      ContactAltAddrDateRange.VALIDATE("Contact Alt. Address Code",ContactAltAddress.Code);
      ContactAltAddrDateRange.MODIFY(TRUE);

      // 2. Exercise: Create a new Segment Header for the date range in which alternative address is activated, Segment Line and link the
      // Contact to the Segment Line.
      LibraryMarketing.CreateSegmentHeader(SegmentHeader);
      LibraryMarketing.CreateSegmentLine(SegmentLine,SegmentHeader."No.");
      SegmentLine.VALIDATE("Contact No.",Contact."No.");
      SegmentLine.MODIFY(TRUE);

      // 3. Verify: Check that the Contact Alternative Address Code on the Segment Line is the same as that created earlier.
      SegmentLine.TESTFIELD("Contact Alt. Address Code",ContactAltAddress.Code);
Member of Lib.Library - Marketing


CreateContactBusinessRelation@13 Method

The procedure CreateContactBusinessRelation is available in codeunit 131900.

Syntax

CreateContactBusinessRelation@13(
    VAR ContactBusinessRelation@1000 : Record 5054 ContactBusinessRelation, //Reference parameter of type Record
    ContactNo@1001 : Code[20] ContactNo, //Input parameter of type Code
    BusinessRelationCode@1002 : Code[10] BusinessRelationCode //Input parameter of type Code
);

Parameters

ContactBusinessRelation
Reference parameter of type Record
ContactNo
Input parameter of type Code
BusinessRelationCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Contact, Business, Relation.

For a clarification about how this function works, refer to the code listed below.

      ContactBusinessRelation.INIT;
      ContactBusinessRelation.VALIDATE("Contact No.",ContactNo);
      ContactBusinessRelation.VALIDATE("Business Relation Code",BusinessRelationCode);
      ContactBusinessRelation.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134325 to show one way of using this function.

      // Test that a Purchase Quote can be created for a Contact.

      // Setup:  Find a Contact Business Relation.
      Initialize;
      LibraryMarketing.CreateContact(Contact);
      LibraryMarketing.CreateBusinessRelation(BusinessRelation);
      LibraryMarketing.CreateContactBusinessRelation(ContactBusinessRelation,Contact."No.",BusinessRelation.Code);
      ContactBusinessRelation.VALIDATE("Link to Table",ContactBusinessRelation."Link to Table"::Vendor);
      ContactBusinessRelation.VALIDATE("No.",LibraryPurchase.CreateVendorNo);
      ContactBusinessRelation.MODIFY(TRUE);

      // Exercise: Create a Purchase Quote for the Contact.
      PurchaseHeader.INSERT(TRUE);
      PurchaseHeader.VALIDATE("Buy-from Contact No.",ContactBusinessRelation."Contact No.");
      PurchaseHeader.MODIFY(TRUE);

      // Verify: Verify that the Purchase Header Contains the correct Contact.
      Assert.AreEqual(
        ContactBusinessRelation."Contact No.",
        PurchaseHeader."Buy-from Contact No.",STRSUBSTNO(FieldError,PurchaseHeader.FIELDCAPTION("Buy-from Contact No.")));
Member of Lib.Library - Marketing


CreateContactIndustryGroup@12 Method

The procedure CreateContactIndustryGroup is available in codeunit 131900.

Syntax

CreateContactIndustryGroup@12(
    VAR ContactIndustryGroup@1000 : Record 5058 ContactIndustryGroup, //Reference parameter of type Record
    ContactNo@1001 : Code[20] ContactNo, //Input parameter of type Code
    IndustryGroupCode@1002 : Code[10] IndustryGroupCode //Input parameter of type Code
);

Parameters

ContactIndustryGroup
Reference parameter of type Record
ContactNo
Input parameter of type Code
IndustryGroupCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Contact, Industry, Group.

For a clarification about how this function works, refer to the code listed below.

      ContactIndustryGroup.INIT;
      ContactIndustryGroup.VALIDATE("Contact No.",ContactNo);
      ContactIndustryGroup.VALIDATE("Industry Group Code",IndustryGroupCode);
      ContactIndustryGroup.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136201 to show one way of using this function.

      // Covers document number TC0054 - refer to TFS ID 21740.
      // Test creation and linking of Industry Group for Contact.

      // 1. Setup: Create a new Contact. Find an Industry Group.
      Initialize;
      LibraryMarketing.CreateContact(Contact);
      IndustryGroup.FINDFIRST;

      // 2. Exercise: Create a Contact Industry Group for the Contact created earlier.
      LibraryMarketing.CreateContactIndustryGroup(ContactIndustryGroup,Contact."No.",IndustryGroup.Code);

      // 3. Verify: Check that the field No. of Industry Groups on Contact is updated.
      Contact.CALCFIELDS("No. of Industry Groups");
      Contact.TESTFIELD("No. of Industry Groups",1);  // Value 1 is important to test case since one Industry Group has been linked.
Member of Lib.Library - Marketing


CreateContactJobResponsibility@26 Method

The procedure CreateContactJobResponsibility is available in codeunit 131900.

Syntax

CreateContactJobResponsibility@26(
    VAR ContactJobResponsibility@1000 : Record 5067 ContactJobResponsibility, //Reference parameter of type Record
    ContactNo@1001 : Code[20] ContactNo, //Input parameter of type Code
    JobResponsibilityCode@1002 : Code[10] JobResponsibilityCode //Input parameter of type Code
);

Parameters

ContactJobResponsibility
Reference parameter of type Record
ContactNo
Input parameter of type Code
JobResponsibilityCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Contact, Job, Responsibility.

For a clarification about how this function works, refer to the code listed below.

      ContactJobResponsibility.INIT;
      ContactJobResponsibility.VALIDATE("Contact No.",ContactNo);
      ContactJobResponsibility.VALIDATE("Job Responsibility Code",JobResponsibilityCode);
      ContactJobResponsibility.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136201 to show one way of using this function.

      // Covers document number TC0055 - refer to TFS ID 21740.
      // Test creation and linking of Job Responsibility for Contact.
      Initialize;

      // 1. Setup: Create a new Contact and input Type as Person. Create a new Job Responsibility.
      CreateContactAsPerson(Contact);
      LibraryMarketing.CreateJobResponsibility(JobResponsibility);

      // 2. Exercise: Create Contact Job Responsibility for Contact and Job Responsibility created earlier.
      LibraryMarketing.CreateContactJobResponsibility(ContactJobResponsibility,Contact."No.",JobResponsibility.Code);

      // 3. Verify: Check that the field No. of Job Responsibilities on Contact is updated.
      Contact.CALCFIELDS("No. of Job Responsibilities");
      // Value 1 is important to test case since one Job Responsibility has been linked.
      Contact.TESTFIELD("No. of Job Responsibilities",1);
Member of Lib.Library - Marketing


CreateContactMailingGroup@19 Method

The procedure CreateContactMailingGroup is available in codeunit 131900.

Syntax

CreateContactMailingGroup@19(
    VAR ContactMailingGroup@1000 : Record 5056 ContactMailingGroup, //Reference parameter of type Record
    ContactNo@1001 : Code[20] ContactNo, //Input parameter of type Code
    MailingGroupCode@1002 : Code[10] MailingGroupCode //Input parameter of type Code
);

Parameters

ContactMailingGroup
Reference parameter of type Record
ContactNo
Input parameter of type Code
MailingGroupCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Contact, Mailing, Group.

For a clarification about how this function works, refer to the code listed below.

      ContactMailingGroup.INIT;
      ContactMailingGroup.VALIDATE("Contact No.",ContactNo);
      ContactMailingGroup.VALIDATE("Mailing Group Code",MailingGroupCode);
      ContactMailingGroup.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136201 to show one way of using this function.

      // Covers document number TC0054 - refer to TFS ID 21740.
      // Test creation and linking of Mailing Group for Contact.

      // 1. Setup: Create a new Contact, Mailing Group.
      Initialize;
      LibraryMarketing.CreateContact(Contact);
      LibraryMarketing.CreateMailingGroup(MailingGroup);

      // 2. Exercise: Create a new Contact Mailing Group for the Contact and Mailing Group created earlier.
      LibraryMarketing.CreateContactMailingGroup(ContactMailingGroup,Contact."No.",MailingGroup.Code);

      // 3. Verify: Check that the field No. of Mailing Groups on Contact is updated.
      Contact.CALCFIELDS("No. of Mailing Groups");
      Contact.TESTFIELD("No. of Mailing Groups",1);  // Value 1 is important to test case since one Mailing Group has been linked.
Member of Lib.Library - Marketing


CreateContactWebSource@20 Method

The procedure CreateContactWebSource is available in codeunit 131900.

Syntax

CreateContactWebSource@20(
    VAR ContactWebSource@1000 : Record 5060 ContactWebSource, //Reference parameter of type Record
    ContactNo@1001 : Code[20] ContactNo, //Input parameter of type Code
    WebSourceCode@1002 : Code[10] WebSourceCode //Input parameter of type Code
);

Parameters

ContactWebSource
Reference parameter of type Record
ContactNo
Input parameter of type Code
WebSourceCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Contact, Web, Source.

For a clarification about how this function works, refer to the code listed below.

      ContactWebSource.INIT;
      ContactWebSource.VALIDATE("Contact No.",ContactNo);
      ContactWebSource.VALIDATE("Web Source Code",WebSourceCode);
      ContactWebSource.INSERT(TRUE);

Example

There are no examples available.
Member of Lib.Library - Marketing


CreateInteractionGroup@30 Method

The procedure CreateInteractionGroup is available in codeunit 131900.

Syntax

CreateInteractionGroup@30(
    VAR InteractionGroup@1000 : Record 5063 InteractionGroup //Reference parameter of type Record
);

Parameters

InteractionGroup
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Interaction, Group.

For a clarification about how this function works, refer to the code listed below.

      InteractionGroup.INIT;
      InteractionGroup.VALIDATE(Code,LibraryUtility.GenerateRandomCode(InteractionGroup.FIELDNO(Code),DATABASE::"Interaction Group"));
      InteractionGroup.VALIDATE(Description,InteractionGroup.Code);  // Validating Code as Description because value is not important.
      InteractionGroup.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136208 to show one way of using this function.

      // Test that it is possible to create a new Interaction Group.

      // 1. Setup:
      Initialize;

      // 2. Exercise: Create Interaction Group.
      LibraryMarketing.CreateInteractionGroup(InteractionGroup);

      // 3. Verify: Check that Interaction Group created.
      InteractionGroup.GET(InteractionGroup.Code);
Member of Lib.Library - Marketing


CreateInteractionTemplate@3 Method

The procedure CreateInteractionTemplate is available in codeunit 131900.

Syntax

CreateInteractionTemplate@3(
    VAR InteractionTemplate@1000 : Record 5064 InteractionTemplate //Reference parameter of type Record
);

Parameters

InteractionTemplate
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Interaction, Template.

For a clarification about how this function works, refer to the code listed below.

      InteractionGroup.FINDFIRST;
      InteractionTemplate.INIT;
      InteractionTemplate.VALIDATE(
        Code,LibraryUtility.GenerateRandomCode(InteractionTemplate.FIELDNO(Code),DATABASE::"Interaction Template"));
      // Validating Code as Description because value is not important.
      InteractionTemplate.VALIDATE(Description,InteractionTemplate.Code);
      InteractionTemplate.VALIDATE("Interaction Group Code",InteractionGroup.Code);
      InteractionTemplate.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136200 to show one way of using this function.

      LibraryMarketing.CreateInteractionTemplate(InteractionTemplate);
      InteractionTemplateSetup.GET;
      InteractionTemplateSetup.VALIDATE("Sales Invoices",InteractionTemplate.Code);
      InteractionTemplateSetup.MODIFY(TRUE);
      LibraryMarketing.CreateCampaign(Campaign);
      UpdateCampaign(Campaign);
      CustomerNo := LibrarySales.CreateCustomerNo;
      CreateSegmentWithCampaign(Campaign."No.",ContactBusinessRelation."Link to Table"::Customer,CustomerNo);
      CreateSalesPrice(SalesPrice,Campaign."No.");
      CampaignTargetGroupMgt.ActivateCampaign(Campaign);
      Campaign.FIND; // get latest version after activation
Member of Lib.Library - Marketing


CreateIntrastatContact@51 Method

The procedure CreateIntrastatContact is available in codeunit 131900.

Syntax

CreateIntrastatContact@51(
    CountryRegionCode@1000 : Code[10] CountryRegionCode //Input parameter of type Code
);

Parameters

CountryRegionCode
Input parameter of type Code

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Intrastat, Contact.

For a clarification about how this function works, refer to the code listed below.

      CreateCompanyContact(Contact);
      Contact.VALIDATE(Address,LibraryUtility.GenerateGUID);
      Contact.VALIDATE("Post Code",LibraryUtility.GenerateGUID);
      Contact.VALIDATE(City,LibraryUtility.GenerateGUID);
      Contact.VALIDATE("Country/Region Code",CountryRegionCode);
      Contact.VALIDATE("Phone No.",LibraryUtility.GenerateGUID);
      Contact.VALIDATE("Fax No.",LibraryUtility.GenerateGUID);
      Contact.VALIDATE("E-Mail",LibraryUtility.GenerateGUID + '@' + LibraryUtility.GenerateGUID);
      Contact.MODIFY(TRUE);
      EXIT(Contact."No.");

Example

The below example is extracted from the test automation codeunit 134150 to show one way of using this function.

      // [FEATURE] [Intrastat Setup] [UT] [UI]
      // [SCENARIO 255730] Set "Intrastat Contact Type" and "Intrastat Contact No." fields via "Intrastat Setup" page
      Initialize;

      // Set "Intrastat Contact Type" = "Contact"
      IntrastatContactNo := LibraryERM.CreateIntrastatContact(CompanyInformation."Intrastat Contact Type"::Contact);
      SetIntrastatContactViaPage(CompanyInformation."Intrastat Contact Type"::Contact,IntrastatContactNo);
      VerifyIntrastatContact(CompanyInformation."Intrastat Contact Type"::Contact,IntrastatContactNo);

      // Set "Intrastat Contact Type" = "Vendor"
      IntrastatContactNo := LibraryERM.CreateIntrastatContact(CompanyInformation."Intrastat Contact Type"::Vendor);
      SetIntrastatContactViaPage(CompanyInformation."Intrastat Contact Type"::Vendor,IntrastatContactNo);
      VerifyIntrastatContact(CompanyInformation."Intrastat Contact Type"::Vendor,IntrastatContactNo);

      // Trying to set "Intrastat Contact Type" = "Contact" with vendor
      Vendor.GET(LibraryPurchase.CreateIntrastatContact(''));
      ASSERTERROR SetIntrastatContactViaPage(CompanyInformation."Intrastat Contact Type"::Contact,Vendor."No.");
      Assert.ExpectedErrorCode('TestValidation');
      Assert.ExpectedError(Contact.TABLECAPTION);

      // Trying to set "Intrastat Contact Type" = "Vendor" with contact
      Contact.GET(LibraryMarketing.CreateIntrastatContact(''));
      ASSERTERROR SetIntrastatContactViaPage(CompanyInformation."Intrastat Contact Type"::Vendor,Contact."No.");
      Assert.ExpectedErrorCode('TestValidation');
      Assert.ExpectedError(Vendor.TABLECAPTION);
Member of Lib.Library - Marketing


CreateJobResponsibility@17 Method

The procedure CreateJobResponsibility is available in codeunit 131900.

Syntax

CreateJobResponsibility@17(
    VAR JobResponsibility@1000 : Record 5066 JobResponsibility //Reference parameter of type Record
);

Parameters

JobResponsibility
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Job, Responsibility.

For a clarification about how this function works, refer to the code listed below.

      JobResponsibility.INIT;
      JobResponsibility.VALIDATE(
        Code,LibraryUtility.GenerateRandomCode(JobResponsibility.FIELDNO(Code),DATABASE::"Job Responsibility"));
      JobResponsibility.VALIDATE(Description,JobResponsibility.Code);  // Validating Code as Description because value is not important.
      JobResponsibility.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136201 to show one way of using this function.

      // Covers document number TC0055 - refer to TFS ID 21740.
      // Test creation and linking of Job Responsibility for Contact.
      Initialize;

      // 1. Setup: Create a new Contact and input Type as Person. Create a new Job Responsibility.
      CreateContactAsPerson(Contact);
      LibraryMarketing.CreateJobResponsibility(JobResponsibility);

      // 2. Exercise: Create Contact Job Responsibility for Contact and Job Responsibility created earlier.
      LibraryMarketing.CreateContactJobResponsibility(ContactJobResponsibility,Contact."No.",JobResponsibility.Code);

      // 3. Verify: Check that the field No. of Job Responsibilities on Contact is updated.
      Contact.CALCFIELDS("No. of Job Responsibilities");
      // Value 1 is important to test case since one Job Responsibility has been linked.
      Contact.TESTFIELD("No. of Job Responsibilities",1);
Member of Lib.Library - Marketing


CreateMailingGroup@15 Method

The procedure CreateMailingGroup is available in codeunit 131900.

Syntax

CreateMailingGroup@15(
    VAR MailingGroup@1000 : Record 5055 MailingGroup //Reference parameter of type Record
);

Parameters

MailingGroup
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Mailing, Group.

For a clarification about how this function works, refer to the code listed below.

      MailingGroup.INIT;
      MailingGroup.VALIDATE(Code,LibraryUtility.GenerateRandomCode(MailingGroup.FIELDNO(Code),DATABASE::"Mailing Group"));
      MailingGroup.VALIDATE(Description,MailingGroup.Code);  // Validating Code as Description because value is not important.
      MailingGroup.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136200 to show one way of using this function.

      // Covers document number TC0001 - refer to TFS ID 160766.
      // Test that on Apply Mailing Group from the segment the Mailing Group is attached to the Contact.

      // 1. Setup: Create new Segment Header, Segment Line.
      Initialize;
      LibraryMarketing.CreateSegmentHeader(SegmentHeader);
      CreateSegmentLineWithContact(SegmentLine,SegmentHeader."No.");

      // 2. Exercise: Create Mailing Group and Apply Mailing Group to the Segment.
      LibraryMarketing.CreateMailingGroup(MailingGroup);
      ApplyMailingGroupToSegment(SegmentHeader,MailingGroup.Code);

      // 3. Verify: Check that Mailing group is attached to the Contact.
      ContactMailingGroup.SETRANGE("Mailing Group Code",MailingGroup.Code);
      ContactMailingGroup.FINDFIRST;
      ContactMailingGroup.TESTFIELD("Contact No.",SegmentLine."Contact No.");
Member of Lib.Library - Marketing


CreateOpportunity@7 Method

The procedure CreateOpportunity is available in codeunit 131900.

Syntax

CreateOpportunity@7(
    VAR Opportunity@1000 : Record 5092 Opportunity, //Reference parameter of type Record
    ContactNo@1002 : Code[20] ContactNo //Input parameter of type Code
);

Parameters

Opportunity
Reference parameter of type Record
ContactNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Opportunity.

For a clarification about how this function works, refer to the code listed below.

      MarketingSetup.GET;
      IF MarketingSetup."Opportunity Nos." = '' THEN BEGIN
        MarketingSetup.VALIDATE("Opportunity Nos.",LibraryUtility.GetGlobalNoSeriesCode);
        MarketingSetup.MODIFY(TRUE);
      END;

      SalespersonPurchaser.FINDFIRST;
      SalesCycle.FINDFIRST;
      Opportunity.INIT;
      Opportunity.INSERT(TRUE);
      Opportunity.VALIDATE(Description,Opportunity."No.");  // Validating No. as Description because value is not important.
      Opportunity.VALIDATE("Contact No.",ContactNo);
      Opportunity.VALIDATE("Salesperson Code",SalespersonPurchaser.Code);
      Opportunity.VALIDATE("Sales Cycle Code",SalesCycle.Code);
      Opportunity.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 136200 to show one way of using this function.

      // Covers document number TC0066 - refer to TFS ID 21741.
      // Test the Very Positive Evaluation option in Make Phone Call wizard, called from the Segment window.

      // 1. Setup: Create new Segment Header, Segment Line, Campaign, Opportunity for Contact in Segment Line.
      Initialize;
      LibraryMarketing.CreateSegmentHeader(SegmentHeader);
      CreateSegmentLineWithContact(SegmentLine,SegmentHeader."No.");
      LibraryMarketing.CreateCampaign(Campaign);
      CampaignNo3 := Campaign."No.";  // Set global variable for form handler.
      LibraryMarketing.CreateOpportunity(Opportunity,SegmentLine."Contact No.");

      // 2. Exercise: Run Make Phone Call wizard.
      SegmentLine.CreateCall;

      // 3. Verify: Check that the Interaction Log Entry created contains Evaluation as Very Positive, Attempt Failed as FALSE and
      // Opportunity No. as that of opportunity created.
      VerifyPositiveInteractionLog(SegmentHeader."No.",Opportunity."No.");
Member of Lib.Library - Marketing


CreatePersonContact@45 Method

The procedure CreatePersonContact is available in codeunit 131900.

Syntax

CreatePersonContact@45(
    VAR Contact@1000 : Record 5050 Contact //Reference parameter of type Record
);

Parameters

Contact
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Person, Contact.

For a clarification about how this function works, refer to the code listed below.

      CreateContactInternal(Contact,Contact.Type::Person);

Example

The below example is extracted from the test automation codeunit 134777 to show one way of using this function.

      LibraryMarketing.CreatePersonContact(Contact);
      ContactCard.OPENEDIT;
      ContactCard.FILTER.SETFILTER("No.",Contact."No.");
      ContactCard.FIRST;
      ContactCard.Minor.SETVALUE(TRUE);
      ContactCard.CLOSE;
      Contact.GET(Contact."No.");
      Assert.AreEqual(
        TRUE,Contact."Privacy Blocked",'Expected Privacy Blocked to be TRUE when Minor is TRUE and parental consent is FALSE');
      CLEAR(Contact);
Member of Lib.Library - Marketing


CreateProfileQuestionnaireLine@28 Method

The procedure CreateProfileQuestionnaireLine is available in codeunit 131900.

Syntax

CreateProfileQuestionnaireLine@28(
    VAR ProfileQuestionnaireLine@1000 : Record 5088 ProfileQuestionnaireLine, //Reference parameter of type Record
    ProfileQuestionnaireCode@1001 : Code[10] ProfileQuestionnaireCode //Input parameter of type Code
);

Parameters

ProfileQuestionnaireLine
Reference parameter of type Record
ProfileQuestionnaireCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Profile, Questionnaire, Line.

For a clarification about how this function works, refer to the code listed below.

      ProfileQuestionnaireLine.INIT;
      ProfileQuestionnaireLine.VALIDATE("Profile Questionnaire Code",ProfileQuestionnaireCode);
      RecRef.GETTABLE(ProfileQuestionnaireLine);
      // Use the function GetLastLineNo to get the value of the Line No. field.
      ProfileQuestionnaireLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,ProfileQuestionnaireLine.FIELDNO("Line No.")));
      ProfileQuestionnaireLine.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136206 to show one way of using this function.

      // Covers document number TC0020 - refer to TFS ID 21734.
      // Test that profile questionnaires Test Report generates correct output.

      // 1. Setup: Create Profile Questionnaires - Questionnaires Header and Questionnaires Line.
      Initialize;
      ProfileQuestionnaireCode := CreateQuestionnairesHeader;

      LibraryMarketing.CreateProfileQuestionnaireLine(ProfileQuestionnaireLine,ProfileQuestionnaireCode);
      UpdateQuestionnairesLineType(ProfileQuestionnaireLine,ProfileQuestionnaireLine.Type::Question,0);
      LibraryMarketing.CreateProfileQuestionnaireLine(ProfileQuestionnaireLine,ProfileQuestionnaireCode);
      UpdateQuestionnairesLineType(ProfileQuestionnaireLine,ProfileQuestionnaireLine.Type::Answer,0);

      // 2. Exercise: Save Test Report as XML and XLSX in local Temp folder.
      ProfileQuestionnaireHeader.SETRANGE(Code,ProfileQuestionnaireHeader.Code);
      QuestionnaireTest.SETTABLEVIEW(ProfileQuestionnaireHeader);
      FilePath := TEMPORARYPATH + ProfileQuestionnaireHeader.Code + '.xlsx';
      QuestionnaireTest.SAVEASEXCEL(FilePath);

      // 3. Verify: Verify that saved file has some data.
      LibraryUtility.CheckFileNotEmpty(FilePath);
Member of Lib.Library - Marketing


CreateQuestionnaireHeader@29 Method

The procedure CreateQuestionnaireHeader is available in codeunit 131900.

Syntax

CreateQuestionnaireHeader@29(
    VAR ProfileQuestionnaireHeader@1000 : Record 5087 ProfileQuestionnaireHeader //Reference parameter of type Record
);

Parameters

ProfileQuestionnaireHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Questionnaire, Header.

For a clarification about how this function works, refer to the code listed below.

      ProfileQuestionnaireHeader.INIT;
      ProfileQuestionnaireHeader.VALIDATE(
        Code,LibraryUtility.GenerateRandomCode(ProfileQuestionnaireHeader.FIELDNO(Code),DATABASE::"Profile Questionnaire Header"));

      // Validating Code as Description because value is not important.
      ProfileQuestionnaireHeader.VALIDATE(Description,ProfileQuestionnaireHeader.Code);
      ProfileQuestionnaireHeader.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136206 to show one way of using this function.

      // [FEATURE] [UT] [UI]
      // [SCENARIO 375354] When finish "Create Rating" wizard with multiple profile questionnaire lines all the lines are added to Questionnaire setup

      Initialize;
      // [GIVEN] Questionnaire with one heading line and two answers
      LibraryMarketing.CreateQuestionnaireHeader(ProfileQuestionnaireHeader);
      ProfileQuestionnaireLine."Profile Questionnaire Code" := ProfileQuestionnaireHeader.Code;
      ProfileQuestionnaireLine."Answer Option" := ProfileQuestionnaireLine."Answer Option"::HighLow;
      ProfileQuestionnaireLine.ValidateAnswerOption;

      // [GIVEN] Handled answers by the last Wizard step
      ProfileQuestionnaireLine."Wizard Step" := 3;
      ProfileQuestionnaireLine.PerformNextWizardStatus;

      // [WHEN] Finish "Create Rating" Wizard
      ProfileQuestionnaireLine.FinishWizard;

      // [THEN] The count of questionnaire lines added is 3 (heading + two answers)
      ProfileQuestionnaireLine.SETRANGE("Profile Questionnaire Code",ProfileQuestionnaireLine."Profile Questionnaire Code");
      Assert.AreEqual(3,ProfileQuestionnaireLine.COUNT,IncorrectQuestionnaireLineCountErr);
Member of Lib.Library - Marketing


CreateRlshpMgtCommentContact@22 Method

The procedure CreateRlshpMgtCommentContact is available in codeunit 131900.

Syntax

CreateRlshpMgtCommentContact@22(
    VAR RlshpMgtCommentLine@1000 : Record 5061 RlshpMgtCommentLine, //Reference parameter of type Record
    ContactNo@1001 : Code[20] ContactNo //Input parameter of type Code
);

Parameters

RlshpMgtCommentLine
Reference parameter of type Record
ContactNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Rlshp, Management, Comment, Contact.

For a clarification about how this function works, refer to the code listed below.

      CreateRlshpMgtCommentLine(RlshpMgtCommentLine,RlshpMgtCommentLine."Table Name"::Contact,ContactNo,0);
      // Sub No. is 0 for Contact.

Example

The below example is extracted from the test automation codeunit 136201 to show one way of using this function.

      // Covers document number TC0054 - refer to TFS ID 21740.
      // Test creation and linking of Comment for Contact.

      // 1. Setup: Create a new Contact.
      Initialize;
      LibraryMarketing.CreateContact(Contact);

      // 2. Exercise: Create Comment for Contact.
      LibraryMarketing.CreateRlshpMgtCommentContact(RlshpMgtCommentLine,Contact."No.");
      Comment :=
        COPYSTR(
          LibraryUtility.GenerateRandomCode(RlshpMgtCommentLine.FIELDNO(Comment),DATABASE::"Rlshp. Mgt. Comment Line"),
          1,
          LibraryUtility.GetFieldLength(DATABASE::"Rlshp. Mgt. Comment Line",RlshpMgtCommentLine.FIELDNO(Comment)));
      RlshpMgtCommentLine.VALIDATE(Comment,Comment);
      RlshpMgtCommentLine.MODIFY(TRUE);

      // 3. Verify: Verify that the Comment has been linked correctly with Contact.
      RlshpMgtCommentLine.SETRANGE("Table Name",RlshpMgtCommentLine."Table Name"::Contact);
      RlshpMgtCommentLine.SETRANGE("No.",Contact."No.");
      RlshpMgtCommentLine.FINDFIRST;
      RlshpMgtCommentLine.TESTFIELD(Comment,Comment);
Member of Lib.Library - Marketing


CreateRlshpMgtCommentLine@18 Method

The procedure CreateRlshpMgtCommentLine is available in codeunit 131900.

Syntax

CreateRlshpMgtCommentLine@18(
    VAR RlshpMgtCommentLine@1000 : Record 5061 RlshpMgtCommentLine, //Reference parameter of type Record
    TableName@1001 : Option TableName, //Input parameter of type Option
    No@1002 : Code[20] No, //Input parameter of type Code
    SubNo@1003 : Integer SubNo //Input parameter of type Integer
);

Parameters

RlshpMgtCommentLine
Reference parameter of type Record
TableName
Input parameter of type Option
No
Input parameter of type Code
SubNo
Input parameter of type Integer

Remarks

The relevant search keywords are: Create, Rlshp, Management, Comment, Line.

For a clarification about how this function works, refer to the code listed below.

      RlshpMgtCommentLine.INIT;
      RlshpMgtCommentLine.VALIDATE("Table Name",TableName);
      RlshpMgtCommentLine.VALIDATE("No.",No);
      RlshpMgtCommentLine.VALIDATE("Sub No.",SubNo);
      RecRef.GETTABLE(RlshpMgtCommentLine);
      RlshpMgtCommentLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,RlshpMgtCommentLine.FIELDNO("Line No.")));
      RlshpMgtCommentLine.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137158 to show one way of using this function.

      // [FEATURE] [To-Do] [UI]
      // [SCENARIO 363277] Open comments from the To-do Card page the link is set to the organizer to-do.
      Initialize;
      // [GIVEN] Contact and To-Do for the Contact.
      LibraryMarketing.CreateContact(Contact);
      CreateAndUpdateToDo(ToDo,Contact);

      // [GIVEN] Comment "X" for To-Do.
      LibraryMarketing.CreateRlshpMgtCommentLine(RlshpMgtCommentLine,RlshpMgtCommentLine."Table Name"::"To-do",ToDo."No.",0);
      RlshpMgtCommentLine.VALIDATE(Comment,LibraryUtility.GenerateGUID);
      RlshpMgtCommentLine.MODIFY(TRUE);

      // [WHEN] Open page Comment from To-Do Page.
      OpenCommentPageFromToDoCard(ToDo,RlshpMgtCommentLine.Comment);
      // [THEN] Page Comment from To-Do Page shows comment "X".
Member of Lib.Library - Marketing


CreateRlshpMgtCommentSales@32 Method

The procedure CreateRlshpMgtCommentSales is available in codeunit 131900.

Syntax

CreateRlshpMgtCommentSales@32(
    VAR RlshpMgtCommentLine@1000 : Record 5061 RlshpMgtCommentLine, //Reference parameter of type Record
    SalesCycleCode@1001 : Code[10] SalesCycleCode //Input parameter of type Code
);

Parameters

RlshpMgtCommentLine
Reference parameter of type Record
SalesCycleCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Rlshp, Management, Comment, Sales.

For a clarification about how this function works, refer to the code listed below.

      CreateRlshpMgtCommentLine(RlshpMgtCommentLine,RlshpMgtCommentLine."Table Name"::"Sales Cycle",SalesCycleCode,0);
      // Sub No. is 0 for Sales Cycle.

Example

The below example is extracted from the test automation codeunit 136209 to show one way of using this function.

      // Covers document number TC0021 - refer to TFS ID 21735.
      // Test Sales Cycle update on Creation of Comment for Sales Cycle.

      // 1. Setup: Create Sales Cycle.
      Initialize;
      LibraryMarketing.CreateSalesCycle(SalesCycle);

      // 2. Exercise: Create Comment for Created Sales Cycle.
      LibraryMarketing.CreateRlshpMgtCommentSales(RlshpMgtCommentLine,SalesCycle.Code);

      // 3. Verify: Verify Sales Cycle update on Creation of Comment for Sales Cycle.
      SalesCycle.GET(SalesCycle.Code);
      SalesCycle.CALCFIELDS(Comment);
      SalesCycle.TESTFIELD(Comment,TRUE);
Member of Lib.Library - Marketing


CreateSalesCycle@23 Method

The procedure CreateSalesCycle is available in codeunit 131900.

Syntax

CreateSalesCycle@23(
    VAR SalesCycle@1000 : Record 5090 SalesCycle //Reference parameter of type Record
);

Parameters

SalesCycle
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Sales, Cycle.

For a clarification about how this function works, refer to the code listed below.

      SalesCycle.INIT;
      SalesCycle.VALIDATE(Code,LibraryUtility.GenerateRandomCode(SalesCycle.FIELDNO(Code),DATABASE::"Sales Cycle"));
      SalesCycle.VALIDATE(Description,SalesCycle.Code);
      SalesCycle.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136201 to show one way of using this function.

      // Covers document number TC0061 - refer to TFS ID 21740.
      // Test the Opportunity statistics information on the Contact card.

      // 1. Setup: Create a new Contact and Sales Cycle.
      Initialize;
      LibraryMarketing.CreateContact(Contact);
      LibraryMarketing.CreateSalesCycle(SalesCycle);

      // 2. Exercise: Create a new Opportunity for Contact. Set global variables for Form Handler with any random decimal values.
      WizardEstimatedValueLCY := LibraryRandom.RandDec(100,2);
      WizardChancesofSuccessPercent := LibraryRandom.RandDec(100,2);
      Opportunity.SETRANGE("Contact No.",Contact."No.");
      LibraryVariableStorage.Enqueue(SalesCycle.Code);
      LibraryVariableStorage.Enqueue(WizardEstimatedValueLCY);
      LibraryVariableStorage.Enqueue(WizardChancesofSuccessPercent);
      TempOpportunity.CreateOppFromOpp(Opportunity);

      // 3. Verify: Check that the Statistics for Opportunity has been updated on Contact.
      Contact.CALCFIELDS("Estimated Value (LCY)","Calcd. Current Value (LCY)","No. of Opportunities");
      Contact.TESTFIELD("No. of Opportunities",1);  // Since one opportunity has been created and linked.
      Contact.TESTFIELD("Estimated Value (LCY)",WizardEstimatedValueLCY);
      TempOpportunity.TESTFIELD(
        "Calcd. Current Value (LCY)",TempOpportunity."Estimated Value (LCY)" * TempOpportunity."Probability %" / 100);
Member of Lib.Library - Marketing


CreateSalesCycleStage@31 Method

The procedure CreateSalesCycleStage is available in codeunit 131900.

Syntax

CreateSalesCycleStage@31(
    VAR SalesCycleStage@1000 : Record 5091 SalesCycleStage, //Reference parameter of type Record
    SalesCycleCode@1001 : Code[10] SalesCycleCode //Input parameter of type Code
);

Parameters

SalesCycleStage
Reference parameter of type Record
SalesCycleCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Sales, Cycle, Stage.

For a clarification about how this function works, refer to the code listed below.

      SalesCycleStage.SETRANGE("Sales Cycle Code",SalesCycleCode);
      // Use 1 to Increase Stage.
      IF SalesCycleStage.FINDLAST THEN
        Stage := SalesCycleStage.Stage + 1
      ELSE
        Stage := 1;
      SalesCycleStage.INIT;
      SalesCycleStage.VALIDATE("Sales Cycle Code",SalesCycleCode);
      SalesCycleStage.VALIDATE(Stage,Stage);
      SalesCycleStage.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136209 to show one way of using this function.

      // [FEATURE] [UT]
      // [SCENARIO 208552] Value of "Sales Cycle Stage Description" of Opportunity Entry have to be filled after Validation of "Sales Cycle Stage"
      Initialize;

      // [GIVEN] "Sales Cycle Stage" with Description = "DESCR1" and "Sales Cycle Code" = "SCC"
      LibraryMarketing.CreateSalesCycle(SalesCycle);
      LibraryMarketing.CreateSalesCycleStage(SalesCycleStage,SalesCycle.Code);
      LibraryUtility.FillMaxText(SalesCycle,SalesCycle.FIELDNO(Description));
      SalesCycleStage.GET(SalesCycleStage."Sales Cycle Code",SalesCycleStage.Stage);

      // [GIVEN] "Opportunity Entry" with "Sales Cycle Stage Description" = "DESCR2" and "Sales Cycle Code" = "SCC"
      OpportunityEntry.INIT;
      OpportunityEntry."Entry No." := LibraryUtility.GetNewRecNo(OpportunityEntry,OpportunityEntry.FIELDNO("Entry No."));
      OpportunityEntry."Sales Cycle Code" := SalesCycleStage."Sales Cycle Code";
      OpportunityEntry.INSERT;
      LibraryUtility.FillMaxText(OpportunityEntry,OpportunityEntry.FIELDNO("Sales Cycle Stage Description"));
      OpportunityEntry.GET(OpportunityEntry."Entry No.");

      // [WHEN] Validate "Opportunity Entry"."Sales Cycle Stage"
      OpportunityEntry.VALIDATE("Sales Cycle Stage",SalesCycleStage.Stage);

      // [THEN] "Opportunity Entry"."Sales Cycle Stage Description" = "DESCR1"
      OpportunityEntry.TESTFIELD("Sales Cycle Stage Description",SalesCycleStage.Description);
Member of Lib.Library - Marketing


CreateSalesHeaderWithContact@39 Method

The procedure CreateSalesHeaderWithContact is available in codeunit 131900.

Syntax

CreateSalesHeaderWithContact@39(
    VAR SalesHeader@1000 : Record 36 SalesHeader, //Reference parameter of type Record
    SellToContactNo@1001 : Code[20] SellToContactNo, //Input parameter of type Code
    SellToCustomerTemplateCode@1002 : Code[10] SellToCustomerTemplateCode //Input parameter of type Code
);

Parameters

SalesHeader
Reference parameter of type Record
SellToContactNo
Input parameter of type Code
SellToCustomerTemplateCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Sales, Header, Contact.

For a clarification about how this function works, refer to the code listed below.

      SalesHeader.INIT;
      SalesHeader.INSERT(TRUE);
      SalesHeader.VALIDATE("Sell-to Contact No.",SellToContactNo);
      SalesHeader.VALIDATE("Sell-to Customer Template Code",SellToCustomerTemplateCode);
      SalesHeader.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 136202 to show one way of using this function.

      // Test Create a Sales Quote from Contact.

      // 1. Setup: Create Contact, Customer Template.
      LibraryMarketing.FindContact(Contact);
      LibraryMarketing.FindCustomerTemplate(CustomerTemplate);

      // 2. Exercise: Create Sales Quote Header from Contact with Customer Template.
      LibraryMarketing.CreateSalesHeaderWithContact(SalesHeader,Contact."No.",CustomerTemplate.Code);

      // 3. Verify: Verify Values on Sales Header with Document Type Quote.
      VerifySalesHeaderQuoteValues(SalesHeader,Contact."No.",CustomerTemplate.Code);
Member of Lib.Library - Marketing


CreateSalesLineDiscount@9 Method

The procedure CreateSalesLineDiscount is available in codeunit 131900.

Syntax

CreateSalesLineDiscount@9(
    VAR SalesLineDiscount@1000 : Record 7004 SalesLineDiscount, //Reference parameter of type Record
    CampaignNo@1001 : Code[20] CampaignNo, //Input parameter of type Code
    ItemNo@1002 : Code[20] ItemNo //Input parameter of type Code
);

Parameters

SalesLineDiscount
Reference parameter of type Record
CampaignNo
Input parameter of type Code
ItemNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Sales, Line, Discount.

For a clarification about how this function works, refer to the code listed below.

      SalesLineDiscount.INIT;
      SalesLineDiscount.VALIDATE(Type,SalesLineDiscount.Type::Item);
      SalesLineDiscount.VALIDATE(Code,ItemNo);
      SalesLineDiscount.VALIDATE("Sales Type",SalesLineDiscount."Sales Type"::Campaign);
      SalesLineDiscount.VALIDATE("Sales Code",CampaignNo);
      SalesLineDiscount.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136200 to show one way of using this function.

      LibraryMarketing.CreateSalesLineDiscount(SalesLineDiscount,SalesPrice."Sales Code",SalesPrice."Item No.");
      // Add random number to input Minimum Quantity greater than Minimum Quantity of Sales Price.
      SalesLineDiscount.RENAME(
        SalesLineDiscount.Type,SalesLineDiscount.Code,SalesLineDiscount."Sales Type",SalesLineDiscount."Sales Code",
        SalesLineDiscount."Starting Date",SalesLineDiscount."Currency Code",SalesLineDiscount."Variant Code",
        SalesPrice."Unit of Measure Code",SalesPrice."Minimum Quantity" + RANDOM(10));
      SalesLineDiscount.VALIDATE("Line Discount %",RANDOM(99));  // Any percentage between 1 and 99.
      SalesLineDiscount.MODIFY(TRUE);
Member of Lib.Library - Marketing


CreateSalesPriceForCampaign@8 Method

The procedure CreateSalesPriceForCampaign is available in codeunit 131900.

Syntax

CreateSalesPriceForCampaign@8(
    VAR SalesPrice@1000 : Record 7002 SalesPrice, //Reference parameter of type Record
    ItemNo@1002 : Code[20] ItemNo, //Input parameter of type Code
    CampaignNo@1001 : Code[20] CampaignNo //Input parameter of type Code
);

Parameters

SalesPrice
Reference parameter of type Record
ItemNo
Input parameter of type Code
CampaignNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Sales, Price, For, Campaign.

For a clarification about how this function works, refer to the code listed below.

      SalesPrice.INIT;
      SalesPrice.VALIDATE("Item No.",ItemNo);
      SalesPrice.VALIDATE("Sales Type",SalesPrice."Sales Type"::Campaign);
      SalesPrice.VALIDATE("Sales Code",CampaignNo);
      SalesPrice.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136200 to show one way of using this function.

      LibraryInventory.CreateItem(Item);
      Item.VALIDATE("Unit Price",RANDOM(1000) + LibraryUtility.GenerateRandomFraction);  // To generate large decimal value.
      Item.MODIFY(TRUE);
      LibraryMarketing.CreateSalesPriceForCampaign(SalesPrice,Item."No.",CampaignNo);
      SalesPrice.RENAME(
        SalesPrice."Item No.",SalesPrice."Sales Type",SalesPrice."Sales Code",SalesPrice."Starting Date",SalesPrice."Currency Code",
        SalesPrice."Variant Code",Item."Base Unit of Measure",RANDOM(10) + 1);
      // Addition by 1 ensures that Quantity is greater than 1.
      SalesPrice.VALIDATE("Unit Price",RANDOM(10000) + LibraryUtility.GenerateRandomFraction);  // To generate large decimal value.
      SalesPrice.MODIFY(TRUE);
Member of Lib.Library - Marketing


CreateSalutation@33 Method

The procedure CreateSalutation is available in codeunit 131900.

Syntax

CreateSalutation@33(
    VAR Salutation@1000 : Record 5068 Salutation //Reference parameter of type Record
);

Parameters

Salutation
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Salutation.

For a clarification about how this function works, refer to the code listed below.

      Salutation.INIT;
      Salutation.VALIDATE(Code,LibraryUtility.GenerateRandomCode(Salutation.FIELDNO(Code),DATABASE::Salutation));
      Salutation.VALIDATE(Description,Salutation.Code);  // Validating Code as Description because value is not important.
      Salutation.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136205 to show one way of using this function.

      // Covers document number TC0027 - refer to TFS ID 123227.
      // Test Salutation Successfully Created.

      // 1. Setup:
      Initialize;

      // 2. Exercise: Create Salutation.
      LibraryMarketing.CreateSalutation(Salutation);

      // 3. Verify: Verify Salutation created.
      Salutation.GET(Salutation.Code);
Member of Lib.Library - Marketing


CreateSalutationFormula@34 Method

The procedure CreateSalutationFormula is available in codeunit 131900.

Syntax

CreateSalutationFormula@34(
    VAR SalutationFormula@1000 : Record 5069 SalutationFormula, //Reference parameter of type Record
    SalutationCode@1001 : Code[10] SalutationCode, //Input parameter of type Code
    LanguageCode@1002 : Code[10] LanguageCode, //Input parameter of type Code
    SalutationType@1003 : Option SalutationType //Input parameter of type Option
);

Parameters

SalutationFormula
Reference parameter of type Record
SalutationCode
Input parameter of type Code
LanguageCode
Input parameter of type Code
SalutationType
Input parameter of type Option

Remarks

The relevant search keywords are: Create, Salutation, Formula.

For a clarification about how this function works, refer to the code listed below.

      SalutationFormula.INIT;
      SalutationFormula.VALIDATE("Salutation Code",SalutationCode);
      SalutationFormula.VALIDATE("Language Code",LanguageCode);
      SalutationFormula.VALIDATE("Salutation Type",SalutationType);
      SalutationFormula.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136205 to show one way of using this function.

      // 1. Setup: Create Salutation.
      Initialize;
      LibraryMarketing.CreateSalutation(Salutation);

      // 2. Exercise: Create and Update Salutation Formula with Specified SalutationType.
      LibraryMarketing.CreateSalutationFormula(SalutationFormula,Salutation.Code,LanguageCode,SalutationType);
      UpdateSalutationFormula(SalutationFormula);

      // 3. Verify: Verify Salutation Formula created with Specified SalutationType.
      SalutationFormula.GET(Salutation.Code,LanguageCode,SalutationType);
Member of Lib.Library - Marketing


CreateSegmentHeader@4 Method

The procedure CreateSegmentHeader is available in codeunit 131900.

Syntax

CreateSegmentHeader@4(
    VAR SegmentHeader@1000 : Record 5076 SegmentHeader //Reference parameter of type Record
);

Parameters

SegmentHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Segment, Header.

For a clarification about how this function works, refer to the code listed below.

      MarketingSetup.GET;
      IF MarketingSetup."Segment Nos." = '' THEN BEGIN
        MarketingSetup.VALIDATE("Segment Nos.",LibraryUtility.GetGlobalNoSeriesCode);
        MarketingSetup.MODIFY(TRUE);
      END;

      SegmentHeader.INIT;
      SegmentHeader.INSERT(TRUE);
      SegmentHeader.VALIDATE(Description,SegmentHeader."No.");  // Validating No. as Description because value is not important.
      SegmentHeader.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 136200 to show one way of using this function.

      // Covers document number TC0065 - refer to TFS ID 21741.
      // Test adding Contacts to Segments.

      // 1. Setup: Create new Segment Header.
      Initialize;
      LibraryMarketing.CreateSegmentHeader(SegmentHeader);

      // 2. Exercise: Add Contact to Segment by running Add Contacts.
      Contact.FINDFIRST;
      Contact.SETRANGE("No.",Contact."No.");
      AddContactsToSegment(Contact,SegmentHeader);

      // 3. Verify: Check that the Contact was added successfully to the Segment Line.
      VerifyContactAddedSegmentLine(Contact,SegmentHeader."No.");
      SegmentHeader.CALCFIELDS("No. of Lines");
      SegmentHeader.TESTFIELD("No. of Lines",1);
Member of Lib.Library - Marketing


CreateSegmentLine@5 Method

The procedure CreateSegmentLine is available in codeunit 131900.

Syntax

CreateSegmentLine@5(
    VAR SegmentLine@1000 : Record 5077 SegmentLine, //Reference parameter of type Record
    SegmentHeaderNo@1001 : Code[20] SegmentHeaderNo //Input parameter of type Code
);

Parameters

SegmentLine
Reference parameter of type Record
SegmentHeaderNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Segment, Line.

For a clarification about how this function works, refer to the code listed below.

      SegmentLine.INIT;
      SegmentLine.VALIDATE("Segment No.",SegmentHeaderNo);
      RecRef.GETTABLE(SegmentLine);
      SegmentLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,SegmentLine.FIELDNO("Line No.")));
      SegmentLine.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136200 to show one way of using this function.

      LibraryMarketing.CreateContact(Contact);
      IF Contact."Phone No." = '' THEN BEGIN
        Contact.VALIDATE("Phone No.",FORMAT(RANDOM(10000)));  // Required field - value is not important to test case.
        Contact.MODIFY(TRUE);
      END;

      LibraryMarketing.CreateSegmentLine(SegmentLine,SegmentHeaderNo);
      SegmentLine.VALIDATE("Contact No.",Contact."No.");
      SegmentLine.MODIFY(TRUE);
Member of Lib.Library - Marketing


CreateTeam@25 Method

The procedure CreateTeam is available in codeunit 131900.

Syntax

CreateTeam@25(
    VAR Team@1000 : Record 5083 Team //Reference parameter of type Record
);

Parameters

Team
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Team.

For a clarification about how this function works, refer to the code listed below.

      Team.INIT;
      Team.VALIDATE(Code,LibraryUtility.GenerateRandomCode(Team.FIELDNO(Code),DATABASE::Team));
      Team.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136203 to show one way of using this function.

      // Covers document number TC0002 - refer to TFS ID 21732.
      // Test error occurs on Creating To-do for Team with Salespeople without E-mail address.

      // 1. Setup: Create Team, Salespeople and attach Salespeople to Team.
      Initialize;
      LibraryMarketing.CreateTeam(Team);
      LibrarySales.CreateSalesperson(SalespersonPurchaser);
      LibraryMarketing.CreateTeamSalesperson(TeamSalesperson,Team.Code,SalespersonPurchaser.Code);
      COMMIT;

      // Set global variable for Form Handler.
      InitializeGlobalVariable;
      TeamCode := Team.Code;

      // 2. Exercise: Create To-Do for Team.
      ASSERTERROR TempToDo.CreateToDoFromToDo(ToDo);

      // 3. Verify: Verify error occurs on Creating To-do for Team with Salespeople without E-mail address.
      Assert.AreEqual(STRSUBSTNO(EMailError,SalespersonPurchaser.Code),GETLASTERRORTEXT,UnknownError);
Member of Lib.Library - Marketing


CreateTeamSalesperson@24 Method

The procedure CreateTeamSalesperson is available in codeunit 131900.

Syntax

CreateTeamSalesperson@24(
    VAR TeamSalesperson@1000 : Record 5084 TeamSalesperson, //Reference parameter of type Record
    TeamCode@1001 : Code[10] TeamCode, //Input parameter of type Code
    SalespersonCode@1002 : Code[20] SalespersonCode //Input parameter of type Code
);

Parameters

TeamSalesperson
Reference parameter of type Record
TeamCode
Input parameter of type Code
SalespersonCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Team, Salesperson.

For a clarification about how this function works, refer to the code listed below.

      TeamSalesperson.INIT;
      TeamSalesperson.VALIDATE("Team Code",TeamCode);
      TeamSalesperson.VALIDATE("Salesperson Code",SalespersonCode);
      TeamSalesperson.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136203 to show one way of using this function.

      // Covers document number TC0002 - refer to TFS ID 21732.
      // Test error occurs on Creating To-do for Team with Salespeople without E-mail address.

      // 1. Setup: Create Team, Salespeople and attach Salespeople to Team.
      Initialize;
      LibraryMarketing.CreateTeam(Team);
      LibrarySales.CreateSalesperson(SalespersonPurchaser);
      LibraryMarketing.CreateTeamSalesperson(TeamSalesperson,Team.Code,SalespersonPurchaser.Code);
      COMMIT;

      // Set global variable for Form Handler.
      InitializeGlobalVariable;
      TeamCode := Team.Code;

      // 2. Exercise: Create To-Do for Team.
      ASSERTERROR TempToDo.CreateToDoFromToDo(ToDo);

      // 3. Verify: Verify error occurs on Creating To-do for Team with Salespeople without E-mail address.
      Assert.AreEqual(STRSUBSTNO(EMailError,SalespersonPurchaser.Code),GETLASTERRORTEXT,UnknownError);
Member of Lib.Library - Marketing


CreateToDo@38 Method

The procedure CreateToDo is available in codeunit 131900.

Syntax

CreateToDo@38(
    VAR ToDo@1000 : Record 5080 ToDo //Reference parameter of type Record
);

Parameters

ToDo
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, To, Do.

For a clarification about how this function works, refer to the code listed below.

      ToDo.INIT;
      ToDo.INSERT(TRUE);
      ToDo.VALIDATE(Description,ToDo."No.");
      ToDo.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 136201 to show one way of using this function.

      LibraryMarketing.CreateToDo(ToDo);
      ToDo.VALIDATE(Date,WORKDATE);
      ToDo.VALIDATE("Contact No.",Contact."No.");
      ToDo.VALIDATE("Salesperson Code",Contact."Salesperson Code");
      ToDo.MODIFY(TRUE);
Member of Lib.Library - Marketing


CreateWebSource@16 Method

The procedure CreateWebSource is available in codeunit 131900.

Syntax

CreateWebSource@16(
    VAR WebSource@1000 : Record 5059 WebSource //Reference parameter of type Record
);

Parameters

WebSource
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Web, Source.

For a clarification about how this function works, refer to the code listed below.

      WebSource.INIT;
      WebSource.VALIDATE(Code,LibraryUtility.GenerateRandomCode(WebSource.FIELDNO(Code),DATABASE::"Web Source"));
      WebSource.VALIDATE(Description,WebSource.Code);  // Validating Code as Description because value is not important.
      WebSource.INSERT(TRUE);

Example

There are no examples available.
Member of Lib.Library - Marketing


FindContact@35 Method

The procedure FindContact is available in codeunit 131900.

Syntax

FindContact@35(
    VAR Contact@1000 : Record 5050 Contact //Reference parameter of type Record
);

Parameters

Contact
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Contact.

For a clarification about how this function works, refer to the code listed below.

      Contact.FINDSET;

Example

The below example is extracted from the test automation codeunit 134047 to show one way of using this function.

      // Verify Error Message for a Contact after entering wrong VAT Registration No.

      // Setup: Create new Country/Region, VAT Registration No. Format. Find a Contact and Update Country Code on it.
      Initialize;
      VATFormat := CreateCountryVATRegistration(CountryRegionCode);
      LibraryMarketing.FindContact(Contact);
      UpdateCountryOnContact(Contact,CountryRegionCode);

      // Exercise: Put an invalid VAT Registration No. in Contact Card. Use Random Values to create it.
      ASSERTERROR Contact.VALIDATE("VAT Registration No.",'Test' + FORMAT(LibraryRandom.RandInt(100)));

      // Verify: Verify the Error Message appeared while changing VAT Registration No.
      Assert.AreEqual(STRSUBSTNO(FormatError,CountryRegionCode,VATFormat),ConvertMessage(GETLASTERRORTEXT),ErrorMustAppear);
Member of Lib.Library - Marketing


FindCustomerTemplate@37 Method

The procedure FindCustomerTemplate is available in codeunit 131900.

Syntax

FindCustomerTemplate@37(
    VAR CustomerTemplate@1000 : Record 5105 CustomerTemplate //Reference parameter of type Record
);

Parameters

CustomerTemplate
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Customer, Template.

For a clarification about how this function works, refer to the code listed below.

      CustomerTemplate.FINDFIRST;

Example

The below example is extracted from the test automation codeunit 136202 to show one way of using this function.

      // Test Create a Sales Quote from Contact.

      // 1. Setup: Create Contact, Customer Template.
      LibraryMarketing.FindContact(Contact);
      LibraryMarketing.FindCustomerTemplate(CustomerTemplate);

      // 2. Exercise: Create Sales Quote Header from Contact with Customer Template.
      LibraryMarketing.CreateSalesHeaderWithContact(SalesHeader,Contact."No.",CustomerTemplate.Code);

      // 3. Verify: Verify Values on Sales Header with Document Type Quote.
      VerifySalesHeaderQuoteValues(SalesHeader,Contact."No.",CustomerTemplate.Code);
Member of Lib.Library - Marketing


Library - Patterns Class

Lib.Library - Patterns

COD132212 applies to SCM,W1,All.

Methods

Name | Description
ADDSerialNoTrackingInfo@115 | The procedure ADDSerialNoTrackingInfo is available in codeunit 132212.
ASSIGNPurchChargeToPurchaseLine@17 | The procedure ASSIGNPurchChargeToPurchaseLine is available in codeunit 132212.
ASSIGNPurchChargeToPurchInvoiceLine@105 | The procedure ASSIGNPurchChargeToPurchInvoiceLine is available in codeunit 132212.
ASSIGNPurchChargeToPurchRcptLine@13 | The procedure ASSIGNPurchChargeToPurchRcptLine is available in codeunit 132212.
ASSIGNPurchChargeToPurchReturnLine@44 | The procedure ASSIGNPurchChargeToPurchReturnLine is available in codeunit 132212.
ASSIGNSalesChargeToSalesLine@22 | The procedure ASSIGNSalesChargeToSalesLine is available in codeunit 132212.
ASSIGNSalesChargeToSalesReturnLine@80 | The procedure ASSIGNSalesChargeToSalesReturnLine is available in codeunit 132212.
ASSIGNSalesChargeToSalesShptLine@14 | The procedure ASSIGNSalesChargeToSalesShptLine is available in codeunit 132212.
CalculateInventoryValueRun@57 | The procedure CalculateInventoryValueRun is available in codeunit 132212.
CHECKCalcInvPost@74 | The procedure CHECKCalcInvPost is available in codeunit 132212.
CHECKItemLedgerEntry@32 | The procedure CHECKItemLedgerEntry is available in codeunit 132212.
CHECKValueEntry@29 | The procedure CHECKValueEntry is available in codeunit 132212.
ExecutePostRevalueInboundILE@60 | The procedure ExecutePostRevalueInboundILE is available in codeunit 132212.
GRPH1Outbound1PurchInvd@36 | The procedure GRPH1Outbound1PurchInvd is available in codeunit 132212.
GRPH1Outbound1PurchRcvd@33 | The procedure GRPH1Outbound1PurchRcvd is available in codeunit 132212.
GRPH3Purch1SalesItemTracked@35 | The procedure GRPH3Purch1SalesItemTracked is available in codeunit 132212.
GRPHApplyInboundToUnappliedOutbound@52 | The procedure GRPHApplyInboundToUnappliedOutbound is available in codeunit 132212.
GRPHPurchItemTracked@41 | The procedure GRPHPurchItemTracked is available in codeunit 132212.
GRPHPurchPartialRcvd1PurchReturn@43 | The procedure GRPHPurchPartialRcvd1PurchReturn is available in codeunit 132212.
GRPHSalesFromReturnReceipts@55 | The procedure GRPHSalesFromReturnReceipts is available in codeunit 132212.
GRPHSalesItemTracked@42 | The procedure GRPHSalesItemTracked is available in codeunit 132212.
GRPHSalesOnly@54 | The procedure GRPHSalesOnly is available in codeunit 132212.
GRPHSalesReturnOnly@53 | The procedure GRPHSalesReturnOnly is available in codeunit 132212.
GRPHSeveralSplitApplication@76 | The procedure GRPHSeveralSplitApplication is available in codeunit 132212.
GRPHSeveralSplitApplicationWithCosts@75 | The procedure GRPHSeveralSplitApplicationWithCosts is available in codeunit 132212.
GRPHSimpleApplication@66 | The procedure GRPHSimpleApplication is available in codeunit 132212.
GRPHSplitApplication@51 | The procedure GRPHSplitApplication is available in codeunit 132212.
GRPHSplitJoinApplication@65 | The procedure GRPHSplitJoinApplication is available in codeunit 132212.
InsertTempILEFromLast@28 | The procedure InsertTempILEFromLast is available in codeunit 132212.
MAKEAdditionalItemUOM@91 | The procedure MAKEAdditionalItemUOM is available in codeunit 132212.
MAKEConsumptionJournalLine@448 | The procedure MAKEConsumptionJournalLine is available in codeunit 132212.
MAKEItem@1 | The procedure MAKEItem is available in codeunit 132212.
MAKEItemChargePurchaseLine@18 | The procedure MAKEItemChargePurchaseLine is available in codeunit 132212.
MAKEItemChargeSalesLine@23 | The procedure MAKEItemChargeSalesLine is available in codeunit 132212.
MAKEItemJournalLine@25 | The procedure MAKEItemJournalLine is available in codeunit 132212.
MAKEItemJournalLineWithApplication@87 | The procedure MAKEItemJournalLineWithApplication is available in codeunit 132212.
MAKEItemReclassificationJournalLine@86 | The procedure MAKEItemReclassificationJournalLine is available in codeunit 132212.
MAKEItemSimple@50 | The procedure MAKEItemSimple is available in codeunit 132212.
MAKEItemWithExtendedText@92 | The procedure MAKEItemWithExtendedText is available in codeunit 132212.
MAKEOutputJournalLine@553 | The procedure MAKEOutputJournalLine is available in codeunit 132212.
MAKEProductionBOM@555 | The procedure MAKEProductionBOM is available in codeunit 132212.
MAKEProductionOrder@24 | The procedure MAKEProductionOrder is available in codeunit 132212.
MAKEPurchaseBlanketOrder@101 | The procedure MAKEPurchaseBlanketOrder is available in codeunit 132212.
MAKEPurchaseCreditMemo@98 | The procedure MAKEPurchaseCreditMemo is available in codeunit 132212.
MAKEPurchaseDoc@27 | The procedure MAKEPurchaseDoc is available in codeunit 132212.
MAKEPurchaseInvoice@45 | The procedure MAKEPurchaseInvoice is available in codeunit 132212.
MAKEPurchaseOrder@11 | The procedure MAKEPurchaseOrder is available in codeunit 132212.
MAKEPurchaseQuote@100 | The procedure MAKEPurchaseQuote is available in codeunit 132212.
MAKEPurchaseReturnOrder@21 | The procedure MAKEPurchaseReturnOrder is available in codeunit 132212.
MAKERevaluationJournalLine@79 | The procedure MAKERevaluationJournalLine is available in codeunit 132212.
MAKERouting@83 | The procedure MAKERouting is available in codeunit 132212.
MAKERoutingforWorkCenter@88 | The procedure MAKERoutingforWorkCenter is available in codeunit 132212.
MAKESalesBlanketOrder@103 | The procedure MAKESalesBlanketOrder is available in codeunit 132212.
MAKESalesCreditMemo@95 | The procedure MAKESalesCreditMemo is available in codeunit 132212.
MAKESalesDoc@30 | The procedure MAKESalesDoc is available in codeunit 132212.
MAKESalesInvoice@104 | The procedure MAKESalesInvoice is available in codeunit 132212.
MAKESalesOrder@12 | The procedure MAKESalesOrder is available in codeunit 132212.
MAKESalesQuote@102 | The procedure MAKESalesQuote is available in codeunit 132212.
MAKESalesReturnOrder@20 | The procedure MAKESalesReturnOrder is available in codeunit 132212.
MAKEStockkeepingUnit@15 | The procedure MAKEStockkeepingUnit is available in codeunit 132212.
MAKETransferOrder@84 | The procedure MAKETransferOrder is available in codeunit 132212.
Minimum@47 | The procedure Minimum is available in codeunit 132212.
ModifyAppliesToPostRevaluation@106 | The procedure ModifyAppliesToPostRevaluation is available in codeunit 132212.
ModifyPostRevaluation@78 | The procedure ModifyPostRevaluation is available in codeunit 132212.
POSTConsumption@5 | The procedure POSTConsumption is available in codeunit 132212.
POSTItemJournalLine@7 | The procedure POSTItemJournalLine is available in codeunit 132212.
POSTItemJournalLineWithApplication@89 | The procedure POSTItemJournalLineWithApplication is available in codeunit 132212.
POSTNegativeAdjustment@3 | The procedure POSTNegativeAdjustment is available in codeunit 132212.
POSTNegativeAdjustmentAmount@1020 | The procedure POSTNegativeAdjustmentAmount is available in codeunit 132212.
POSTNegativeAdjustmentWithItemTracking@97 | The procedure POSTNegativeAdjustmentWithItemTracking is available in codeunit 132212.
POSTOutput@4 | The procedure POSTOutput is available in codeunit 132212.
POSTOutputWithItemTracking@90 | The procedure POSTOutputWithItemTracking is available in codeunit 132212.
POSTPositiveAdjustment@2 | The procedure POSTPositiveAdjustment is available in codeunit 132212.
POSTPositiveAdjustmentAmount@1021 | The procedure POSTPositiveAdjustmentAmount is available in codeunit 132212.
POSTPositiveAdjustmentWithItemTracking@99 | The procedure POSTPositiveAdjustmentWithItemTracking is available in codeunit 132212.
POSTPurchaseJournal@6 | The procedure POSTPurchaseJournal is available in codeunit 132212.
POSTPurchaseOrder@9 | The procedure POSTPurchaseOrder is available in codeunit 132212.
POSTPurchaseOrderPartially@46 | The procedure POSTPurchaseOrderPartially is available in codeunit 132212.
POSTPurchaseOrderWithItemTracking@96 | The procedure POSTPurchaseOrderWithItemTracking is available in codeunit 132212.
POSTReclassificationJournalLine@82 | The procedure POSTReclassificationJournalLine is available in codeunit 132212.
POSTSaleJournal@8 | The procedure POSTSaleJournal is available in codeunit 132212.
POSTSalesLine@64 | The procedure POSTSalesLine is available in codeunit 132212.
POSTSalesOrder@10 | The procedure POSTSalesOrder is available in codeunit 132212.
POSTSalesOrderPartially@61 | The procedure POSTSalesOrderPartially is available in codeunit 132212.
POSTTransferOrder@85 | The procedure POSTTransferOrder is available in codeunit 132212.
RandCost@77 | The procedure RandCost is available in codeunit 132212.
RandDec@56 | The procedure RandDec is available in codeunit 132212.
RevaluationJournalCalcInventory@107 | The procedure RevaluationJournalCalcInventory is available in codeunit 132212.
SETInventorySetup@16 | The procedure SETInventorySetup is available in codeunit 132212.
SETNoSeries@19 | The procedure SETNoSeries is available in codeunit 132212.

See Also

Lib


ADDSerialNoTrackingInfo@115 Method

The procedure ADDSerialNoTrackingInfo is available in codeunit 132212.

Syntax

ADDSerialNoTrackingInfo@115(
    ItemNo@1000 : Code[20] ItemNo //Input parameter of type Code
);

Parameters

ItemNo
Input parameter of type Code

Remarks

The relevant search keywords are: ADD, Serial, No, Tracking, Info.

For a clarification about how this function works, refer to the code listed below.

      Item.GET(ItemNo);

      LibraryInventory.CreateItemTrackingCode(ItemTrackingCode);
      Item.VALIDATE("Item Tracking Code",ItemTrackingCode.Code);
      Item.VALIDATE("Serial Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      Item.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137070 to show one way of using this function.

      // [FEATURE] [Job]
      // [SCENARIO 262595] Job consumption item ledger entry should be posted with fixed application to the purchase entry with item tracking

      Initialize;

      // [GIVEN] Item "I" tracked by serial number
      CreateItem(Item);
      LibraryPatterns.ADDSerialNoTrackingInfo(Item."No.");
      Item.FIND;

      // [GIVEN] Purchase 10 pcs of item "I", "Unit Cost" = 100
      LibraryInventory.CreateItemJournalLineInItemTemplate(ItemJournalLine,Item."No.",'','',LibraryRandom.RandIntInRange(10,20));
      ItemJournalLine.VALIDATE("Unit Amount",LibraryRandom.RandIntInRange(100,200));
      ItemJournalLine.MODIFY(TRUE);
      ItemJournalLine.OpenItemTrackingLines(FALSE);
      LibraryInventory.PostItemJournalLine(ItemJournalLine."Journal Template Name",ItemJournalLine."Journal Batch Name");

      // [GIVEN] Post a purchase order with linked job for the same item "I", "Unit Cost" = 300
      LibraryPurchase.CreatePurchHeader(PurchaseHeader,PurchaseHeader."Document Type"::Order,LibraryPurchase.CreateVendorNo);
      CreatePurchaseLineWithJob(
        PurchaseLine,PurchaseHeader,Item."No.",LibraryRandom.RandIntInRange(10,20),LibraryRandom.RandIntInRange(300,400));
      PurchaseLine.OpenItemTrackingLines;

      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

      // [WHEN] Run "Adjust Cost - Item Entries"
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');

      // [THEN] All job consumption entries are posted with fixed cost application
      // [THEN] Unit cost in job consumption is 300
      ItemLedgerEntry.SETRANGE("Item No.",Item."No.");
      ItemLedgerEntry.SETRANGE("Entry Type",ItemLedgerEntry."Entry Type"::"Negative Adjmt.");
      ItemLedgerEntry.FINDSET;
      REPEAT
        VerifyItemLedgEntryActualCost(ItemLedgerEntry,-PurchaseLine."Direct Unit Cost");
        VerifyCostApplication(ItemLedgerEntry."Entry No.");
      UNTIL ItemLedgerEntry.NEXT = 0;
Member of Lib.Library - Patterns


ASSIGNPurchChargeToPurchaseLine@17 Method

The procedure ASSIGNPurchChargeToPurchaseLine is available in codeunit 132212.

Syntax

ASSIGNPurchChargeToPurchaseLine@17(
    PurchaseHeader@1003 : Record 38 PurchaseHeader, //Input parameter of type Record
    PurchaseLine@1000 : Record 39 PurchaseLine, //Input parameter of type Record
    Qty@1002 : Decimal Qty, //Input parameter of type Decimal
    DirectUnitCost@1001 : Decimal DirectUnitCost //Input parameter of type Decimal
);

Parameters

PurchaseHeader
Input parameter of type Record
PurchaseLine
Input parameter of type Record
Qty
Input parameter of type Decimal
DirectUnitCost
Input parameter of type Decimal

Remarks

The relevant search keywords are: ASSIGN, Purchase, Charge, To, Purchasease, Line.

For a clarification about how this function works, refer to the code listed below.

      MAKEItemChargePurchaseLine(PurchaseLine1,ItemCharge,PurchaseHeader,Qty,DirectUnitCost);

      PurchaseLine.TESTFIELD(Type,PurchaseLine.Type::Item);

      LibraryPurchase.CreateItemChargeAssignment(ItemChargeAssignmentPurch,PurchaseLine1,ItemCharge,
        ItemChargeAssignmentPurch."Applies-to Doc. Type"::Order,
        PurchaseLine."Document No.",PurchaseLine."Line No.",
        PurchaseLine."No.",Qty,DirectUnitCost);
      ItemChargeAssignmentPurch.INSERT;

Example

The below example is extracted from the test automation codeunit 134150 to show one way of using this function.

      // [FEATURE] [Purchase] [Item Charge]
      // [SCENARIO] GetEntries for Intrastat should not create line for National Purchase order with Item Charge posted on StartDate of Period
      Initialize;

      // [GIVEN] Purchase Order with empty Country/Region Code on 01.Jan with Item "X"
      LibraryPurchase.CreatePurchHeader(
        PurchaseHeader,PurchaseHeader."Document Type"::Order,CreateVendor(GetCountryRegionCode));
      WITH PurchaseHeader DO BEGIN
        VALIDATE("Posting Date",CALCDATE('<+1Y-CM>',WORKDATE));
        VALIDATE("Buy-from Country/Region Code",'');
        MODIFY(TRUE);
      END;
      CreatePurchaseLine(PurchaseHeader,PurchaseLine,PurchaseLine.Type::Item,CreateItem);

      // [GIVEN] Item Charge Purchase Line
      LibraryPatterns.ASSIGNPurchChargeToPurchaseLine(PurchaseHeader,PurchaseLine,1,LibraryRandom.RandDecInRange(100,200,2));

      // [GIVEN] Purchase Order is Received and Invoiced on 01.Jan
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);
      LibraryERM.CreateIntrastatJnlTemplateAndBatch(IntrastatJnlBatch,PurchaseHeader."Posting Date");
      LibraryVariableStorage.Enqueue(IntrastatJnlBatch."Journal Template Name");
      LibraryVariableStorage.Enqueue(TRUE); // Show Item Charge entries

      // [WHEN] Run Get Entries on Intrastat Journal with "Show item charge entries" options set to TRUE
      // [THEN] No Intrastat Journal Lines should be created for Item "X"
      OpenAndVerifyIntrastatJournalLine(IntrastatJnlBatch.Name,PurchaseLine."No.",FALSE);

      IntrastatJnlBatch.DELETE(TRUE);
Member of Lib.Library - Patterns


ASSIGNPurchChargeToPurchInvoiceLine@105 Method

The procedure ASSIGNPurchChargeToPurchInvoiceLine is available in codeunit 132212.

Syntax

ASSIGNPurchChargeToPurchInvoiceLine@105(
    PurchaseHeader@1000 : Record 38 PurchaseHeader, //Input parameter of type Record
    PurchInvLine@1006 : Record 123 PurchInvLine, //Input parameter of type Record
    Qty@1002 : Decimal Qty, //Input parameter of type Decimal
    DirectUnitCost@1003 : Decimal DirectUnitCost //Input parameter of type Decimal
);

Parameters

PurchaseHeader
Input parameter of type Record
PurchInvLine
Input parameter of type Record
Qty
Input parameter of type Decimal
DirectUnitCost
Input parameter of type Decimal

Remarks

The relevant search keywords are: ASSIGN, Purchasease, Charge, To, Purchasease, Invoice, Line.

For a clarification about how this function works, refer to the code listed below.

      MAKEItemChargePurchaseLine(PurchaseLine,ItemCharge,PurchaseHeader,Qty,DirectUnitCost);

      PurchInvLine.TESTFIELD(Type,PurchInvLine.Type::Item);

      LibraryPurchase.CreateItemChargeAssignment(ItemChargeAssignmentPurch,PurchaseLine,ItemCharge,
        ItemChargeAssignmentPurch."Applies-to Doc. Type"::Invoice,
        PurchInvLine."Document No.",PurchInvLine."Line No.",
        PurchInvLine."No.",Qty,DirectUnitCost);
      ItemChargeAssignmentPurch.INSERT;

Example

The below example is extracted from the test automation codeunit 137609 to show one way of using this function.

      Initialize;
      IF CONFIRM('') THEN; // workaround for ES.

      // Setup: purchase invoice with and without variant.
      Day1 := WORKDATE;
      Qty := LibraryRandom.RandIntInRange(3,100);
      LibraryPatterns.MAKEItemSimple(Item,CostingMethod,LibraryRandom.RandDec(100,2));
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(ToLocation);
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(InTransitLocation);
      InTransitLocation."Use As In-Transit" := TRUE;
      InTransitLocation.MODIFY;
      LibraryPatterns.MAKEStockkeepingUnit(StockkeepingUnit,Item);

      LibraryPatterns.MAKEPurchaseDoc(PurchaseHeader1,PurchaseLine,PurchDocType,Item,StockkeepingUnit."Location Code",
        StockkeepingUnit."Variant Code",2 * Qty,Day1,LibraryRandom.RandDec(100,2));
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader1,TRUE,Invoice);
      LibraryPatterns.MAKEPurchaseDoc(PurchaseHeader2,PurchaseLine,PurchDocType,Item,StockkeepingUnit."Location Code",
        '',2 * Qty,Day1,LibraryRandom.RandDec(100,2));
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader2,TRUE,Invoice);

      // Assign charge to purchase and invoice if necessary.
      Vendor.GET(PurchaseHeader1."Buy-from Vendor No.");
      LibraryPurchase.CreatePurchHeader(PurchaseHeader,PurchaseHeader."Document Type"::Order,Vendor."No.");
      PurchaseHeader.VALIDATE("Posting Date",Day1);
      PurchaseHeader.MODIFY(TRUE);

      CASE PurchDocType OF
        PurchaseHeader."Document Type"::Invoice:
          BEGIN
            PurchInvLine.SETRANGE(Type,PurchaseLine.Type);
            PurchInvLine.SETRANGE("No.",Item."No.");
            PurchInvLine.FINDFIRST;

            LibraryPatterns.ASSIGNPurchChargeToPurchInvoiceLine(PurchaseHeader,PurchInvLine,Qty,
              LibraryRandom.RandDec(100,2));
          END;
        PurchaseHeader."Document Type"::Order:
          BEGIN
            PurchRcptLine.SETRANGE("Order No.",PurchaseHeader1."No.");
            PurchRcptLine.FINDFIRST;

            LibraryPatterns.ASSIGNPurchChargeToPurchRcptLine(PurchaseHeader,PurchRcptLine,Qty,
              LibraryRandom.RandDec(100,2));
            LibraryPurchase.PostPurchaseDocument(PurchaseHeader1,TRUE,TRUE);
            LibraryPurchase.PostPurchaseDocument(PurchaseHeader2,TRUE,TRUE);
          END;
      END;

      LibraryPatterns.MAKEItemChargePurchaseLine(PurchaseLine,ItemCharge,PurchaseHeader,Qty,
        LibraryRandom.RandDec(100,2));
      PurchaseLine."Qty. to Invoice" := 0;
      PurchaseLine.MODIFY;
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

      // Sales credit memo with and without variant.
      LibraryPatterns.MAKESalesDoc(SalesHeader1,SalesLine,SalesDocType,Item,StockkeepingUnit."Location Code",
        StockkeepingUnit."Variant Code",Qty,Day1 + 5,LibraryRandom.RandDec(100,2));
      LibrarySales.PostSalesDocument(SalesHeader1,TRUE,Invoice);
      LibraryPatterns.MAKESalesDoc(SalesHeader2,SalesLine,SalesDocType,Item,StockkeepingUnit."Location Code",
        '',Qty,Day1 + 5,LibraryRandom.RandDec(100,2));
      LibrarySales.PostSalesDocument(SalesHeader2,TRUE,Invoice);

      // Revalue inventory.
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');
      LibraryPatterns.MAKERevaluationJournalLine(ItemJournalBatch,Item,Day1 + 2,
        CalculatePer::Item,FALSE,FALSE,TRUE,CalculationBase::" ");
      ItemJournalLine.SETRANGE("Journal Template Name",ItemJournalBatch."Journal Template Name");
      ItemJournalLine.SETRANGE("Journal Batch Name",ItemJournalBatch.Name);
      ItemJournalLine.FINDFIRST;
      ItemJournalLine.VALIDATE("Inventory Value (Revalued)",
        ItemJournalLine."Inventory Value (Calculated)" + LibraryRandom.RandDec(100,2));
      LibraryInventory.PostItemJournalBatch(ItemJournalBatch);

      // Sales invoice with and without variant.
      LibraryPatterns.MAKESalesInvoice(SalesHeader,SalesLine,Item,StockkeepingUnit."Location Code",
        StockkeepingUnit."Variant Code",Qty,Day1 + 10,LibraryRandom.RandDec(100,2));
      LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      LibraryPatterns.MAKESalesInvoice(SalesHeader,SalesLine,Item,StockkeepingUnit."Location Code",
        '',Qty,Day1 + 10,LibraryRandom.RandDec(100,2));
      LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      // Purchase credit memo with and without variant.
      LibraryPatterns.MAKEPurchaseDoc(PurchaseHeader1,PurchaseLine,PurchReturnDocType,Item,
        StockkeepingUnit."Location Code",StockkeepingUnit."Variant Code",Qty,Day1 + 11,
        LibraryRandom.RandDec(100,2));
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader1,TRUE,Invoice);

      LibraryPatterns.MAKEPurchaseDoc(PurchaseHeader2,PurchaseLine,PurchReturnDocType,Item,
        StockkeepingUnit."Location Code",'',Qty,Day1 + 11,LibraryRandom.RandDec(100,2));
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader2,TRUE,Invoice);

      IF NOT Invoice THEN BEGIN
        LibraryPurchase.PostPurchaseDocument(PurchaseHeader1,TRUE,TRUE);
        LibraryPurchase.PostPurchaseDocument(PurchaseHeader2,TRUE,TRUE);
        SalesHeader1.GET(SalesHeader1."Document Type",SalesHeader1."No.");
        LibrarySales.PostSalesDocument(SalesHeader1,TRUE,TRUE);
        SalesHeader2.GET(SalesHeader2."Document Type",SalesHeader2."No.");
        LibrarySales.PostSalesDocument(SalesHeader2,TRUE,TRUE);
      END;

      // Exercise.
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');

      // Verify.
      LibraryCosting.CheckAdjustment(Item);
Member of Lib.Library - Patterns


ASSIGNPurchChargeToPurchRcptLine@13 Method

The procedure ASSIGNPurchChargeToPurchRcptLine is available in codeunit 132212.

Syntax

ASSIGNPurchChargeToPurchRcptLine@13(
    PurchaseHeader@1000 : Record 38 PurchaseHeader, //Input parameter of type Record
    PurchRcptLine@1006 : Record 121 PurchRcptLine, //Input parameter of type Record
    Qty@1002 : Decimal Qty, //Input parameter of type Decimal
    DirectUnitCost@1003 : Decimal DirectUnitCost //Input parameter of type Decimal
);

Parameters

PurchaseHeader
Input parameter of type Record
PurchRcptLine
Input parameter of type Record
Qty
Input parameter of type Decimal
DirectUnitCost
Input parameter of type Decimal

Remarks

The relevant search keywords are: ASSIGN, Purchasease, Charge, To, Purchasease, Rcpt, Line.

For a clarification about how this function works, refer to the code listed below.

      MAKEItemChargePurchaseLine(PurchaseLine,ItemCharge,PurchaseHeader,Qty,DirectUnitCost);

      PurchRcptLine.TESTFIELD(Type,PurchRcptLine.Type::Item);

      LibraryPurchase.CreateItemChargeAssignment(ItemChargeAssignmentPurch,PurchaseLine,ItemCharge,
        ItemChargeAssignmentPurch."Applies-to Doc. Type"::Receipt,
        PurchRcptLine."Document No.",PurchRcptLine."Line No.",
        PurchRcptLine."No.",Qty,DirectUnitCost);
      ItemChargeAssignmentPurch.INSERT;

Example

The below example is extracted from the test automation codeunit 137018 to show one way of using this function.

      Vendor.GET(PurchaseHeader."Buy-from Vendor No.");

      PurchRcptLine.SETCURRENTKEY("Buy-from Vendor No.");
      PurchRcptLine.SETRANGE("Buy-from Vendor No.",PurchaseHeader."Buy-from Vendor No.");
      PurchRcptLine.SETRANGE(Type,PurchRcptLine.Type::Item);
      PurchRcptLine.FINDFIRST;

      // Purchase Order for Item Charge
      LibraryPurchase.CreatePurchHeader(PurchaseHeaderItemCharge,PurchaseHeader."Document Type",Vendor."No.");

      // Line for Item Charge
      LibraryPatterns.ASSIGNPurchChargeToPurchRcptLine(PurchaseHeaderItemCharge,PurchRcptLine,1,DirectUnitCost);

      LibraryPurchase.PostPurchaseDocument(PurchaseHeaderItemCharge,TRUE,TRUE);
Member of Lib.Library - Patterns


ASSIGNPurchChargeToPurchReturnLine@44 Method

The procedure ASSIGNPurchChargeToPurchReturnLine is available in codeunit 132212.

Syntax

ASSIGNPurchChargeToPurchReturnLine@44(
    PurchaseHeader@1003 : Record 38 PurchaseHeader, //Input parameter of type Record
    PurchaseLine@1000 : Record 39 PurchaseLine, //Input parameter of type Record
    Qty@1002 : Decimal Qty, //Input parameter of type Decimal
    DirectUnitCost@1001 : Decimal DirectUnitCost //Input parameter of type Decimal
);

Parameters

PurchaseHeader
Input parameter of type Record
PurchaseLine
Input parameter of type Record
Qty
Input parameter of type Decimal
DirectUnitCost
Input parameter of type Decimal

Remarks

The relevant search keywords are: ASSIGN, Purchasease, Charge, To, Purchasease, Return, Line.

For a clarification about how this function works, refer to the code listed below.

      MAKEItemChargePurchaseLine(PurchaseLine1,ItemCharge,PurchaseHeader,Qty,DirectUnitCost);

      PurchaseLine.TESTFIELD(Type,PurchaseLine.Type::Item);

      LibraryPurchase.CreateItemChargeAssignment(ItemChargeAssignmentPurch,PurchaseLine1,ItemCharge,
        ItemChargeAssignmentPurch."Applies-to Doc. Type"::"Return Order",
        PurchaseLine."Document No.",PurchaseLine."Line No.",
        PurchaseLine."No.",Qty,DirectUnitCost);
      ItemChargeAssignmentPurch.INSERT;

Example

The below example is extracted from the test automation codeunit 137287 to show one way of using this function.

      // Setup: Create Purchase Document with Item Line and Charge Item Line
      CreatePurchaseHeader(PurchaseHeader,DocumentType,CreateVendor);
      CreatePurchaseLine(
        PurchaseLine,PurchaseHeader,PurchaseLine.Type::Item,CreateItem,LibraryRandom.RandDec(10,2),
        LibraryRandom.RandDec(100,2));

      CASE DocumentType OF
        PurchaseLine."Document Type"::Order:
          LibraryPatterns.ASSIGNPurchChargeToPurchaseLine(PurchaseHeader,PurchaseLine,
            LibraryRandom.RandDec(10,2),LibraryRandom.RandDec(100,2));
        PurchaseLine."Document Type"::"Return Order":
          LibraryPatterns.ASSIGNPurchChargeToPurchReturnLine(PurchaseHeader,PurchaseLine,
            LibraryRandom.RandDec(10,2),LibraryRandom.RandDec(100,2));
      END;

      // Get the item charge line
      PurchaseLine2.SETRANGE("Document Type",PurchaseHeader."Document Type");
      PurchaseLine2.SETRANGE("Document No.",PurchaseHeader."No.");
      PurchaseLine2.SETRANGE(Type,PurchaseLine.Type::"Charge (Item)");
      PurchaseLine2.FINDFIRST;

      // Set the "Qty. to Invoice" of Charge Item Line to 0 and Post the document
      // After the post, "Qty. to Invoice" of Charge Item Line will be set to "Qty. Rcd. Not Invoiced" automatically
      IF DocumentType = PurchaseLine."Document Type"::"Return Order" THEN
        PurchaseLine2.VALIDATE("Return Qty. to Ship",0)
      ELSE
        PurchaseLine2.VALIDATE("Qty. to Invoice",0);
      PurchaseLine2.MODIFY(TRUE);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);
      PurchaseHeader.GET(PurchaseHeader."Document Type",PurchaseHeader."No.");

      // Update Vendor Invoice No. and Vendor Cr. Memo No.
      UpdatePurchaseHeader(PurchaseHeader);

      // Exercise: Post Invoice for the invalidated item charge assignment
      ASSERTERROR LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

      // Verify: Post failed
      Assert.ExpectedError(STRSUBSTNO(InvalidatedAssignmentErr));
Member of Lib.Library - Patterns


ASSIGNSalesChargeToSalesLine@22 Method

The procedure ASSIGNSalesChargeToSalesLine is available in codeunit 132212.

Syntax

ASSIGNSalesChargeToSalesLine@22(
    SalesHeader@1003 : Record 36 SalesHeader, //Input parameter of type Record
    SalesLine@1002 : Record 37 SalesLine, //Input parameter of type Record
    Qty@1001 : Decimal Qty, //Input parameter of type Decimal
    UnitCost@1000 : Decimal UnitCost //Input parameter of type Decimal
);

Parameters

SalesHeader
Input parameter of type Record
SalesLine
Input parameter of type Record
Qty
Input parameter of type Decimal
UnitCost
Input parameter of type Decimal

Remarks

The relevant search keywords are: ASSIGN, Sales, Charge, To, Sales, Line.

For a clarification about how this function works, refer to the code listed below.

      MAKEItemChargeSalesLine(SalesLine1,ItemCharge,SalesHeader,Qty,UnitCost);

      SalesLine.TESTFIELD(Type,SalesLine.Type::Item);

      LibrarySales.CreateItemChargeAssignment(ItemChargeAssignmentSales,SalesLine1,ItemCharge,
        ItemChargeAssignmentSales."Applies-to Doc. Type"::Order,
        SalesLine."Document No.",SalesLine."Line No.",
        SalesLine."No.",Qty,UnitCost);
      ItemChargeAssignmentSales.INSERT;

Example

The below example is extracted from the test automation codeunit 137287 to show one way of using this function.

      // Setup: Create Sales Document with Item Line and Charge Item Line
      LibrarySales.CreateSalesHeader(SalesHeader,DocumentType,CreateCustomer);
      CreateSalesLine(
        SalesLine,SalesHeader,SalesLine.Type::Item,CreateItem,LibraryRandom.RandDec(10,2),
        LibraryRandom.RandDec(100,2));

      // Assign item charge to current document
      CASE DocumentType OF
        SalesLine."Document Type"::Order:
          LibraryPatterns.ASSIGNSalesChargeToSalesLine(SalesHeader,SalesLine,
            LibraryRandom.RandDec(10,2),LibraryRandom.RandDec(100,2));
        SalesLine."Document Type"::"Return Order":
          LibraryPatterns.ASSIGNSalesChargeToSalesReturnLine(SalesHeader,SalesLine,
            LibraryRandom.RandDec(10,2),LibraryRandom.RandDec(100,2));
      END;

      // Get the item charge line
      SalesLine2.SETRANGE("Document No.",SalesHeader."No.");
      SalesLine2.SETRANGE(Type,SalesLine.Type::"Charge (Item)");
      SalesLine2.FINDFIRST;

      // Set the "Qty. to Invoice" of Charge Item Line to 0 and Post the document
      // After the post, "Qty. to Invoice" of Charge Item Line will be set to "Qty. Rcd. Not Invoiced" automatically
      IF DocumentType = SalesLine."Document Type"::Order THEN
        SalesLine2.VALIDATE("Qty. to Ship",0)
      ELSE
        SalesLine2.VALIDATE("Qty. to Invoice",0);
      SalesLine2.MODIFY(TRUE);
      LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      // Exercise: Post Invoice for the invalidated item charge assignment
      ASSERTERROR LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      // Verify: Post failed
      Assert.ExpectedError(STRSUBSTNO(InvalidatedAssignmentErr));
Member of Lib.Library - Patterns


ASSIGNSalesChargeToSalesReturnLine@80 Method

The procedure ASSIGNSalesChargeToSalesReturnLine is available in codeunit 132212.

Syntax

ASSIGNSalesChargeToSalesReturnLine@80(
    SalesHeader@1003 : Record 36 SalesHeader, //Input parameter of type Record
    SalesLine@1002 : Record 37 SalesLine, //Input parameter of type Record
    Qty@1001 : Decimal Qty, //Input parameter of type Decimal
    UnitCost@1000 : Decimal UnitCost //Input parameter of type Decimal
);

Parameters

SalesHeader
Input parameter of type Record
SalesLine
Input parameter of type Record
Qty
Input parameter of type Decimal
UnitCost
Input parameter of type Decimal

Remarks

The relevant search keywords are: ASSIGN, Sales, Charge, To, Sales, Return, Line.

For a clarification about how this function works, refer to the code listed below.

      MAKEItemChargeSalesLine(SalesLine1,ItemCharge,SalesHeader,Qty,UnitCost);

      SalesLine.TESTFIELD(Type,SalesLine.Type::Item);

      LibrarySales.CreateItemChargeAssignment(ItemChargeAssignmentSales,SalesLine1,ItemCharge,
        ItemChargeAssignmentSales."Applies-to Doc. Type"::"Return Order",
        SalesLine."Document No.",SalesLine."Line No.",
        SalesLine."No.",Qty,UnitCost);
      ItemChargeAssignmentSales.INSERT;

Example

The below example is extracted from the test automation codeunit 137287 to show one way of using this function.

      // Setup: Create Sales Document with Item Line and Charge Item Line
      LibrarySales.CreateSalesHeader(SalesHeader,DocumentType,CreateCustomer);
      CreateSalesLine(
        SalesLine,SalesHeader,SalesLine.Type::Item,CreateItem,LibraryRandom.RandDec(10,2),
        LibraryRandom.RandDec(100,2));

      // Assign item charge to current document
      CASE DocumentType OF
        SalesLine."Document Type"::Order:
          LibraryPatterns.ASSIGNSalesChargeToSalesLine(SalesHeader,SalesLine,
            LibraryRandom.RandDec(10,2),LibraryRandom.RandDec(100,2));
        SalesLine."Document Type"::"Return Order":
          LibraryPatterns.ASSIGNSalesChargeToSalesReturnLine(SalesHeader,SalesLine,
            LibraryRandom.RandDec(10,2),LibraryRandom.RandDec(100,2));
      END;

      // Get the item charge line
      SalesLine2.SETRANGE("Document No.",SalesHeader."No.");
      SalesLine2.SETRANGE(Type,SalesLine.Type::"Charge (Item)");
      SalesLine2.FINDFIRST;

      // Set the "Qty. to Invoice" of Charge Item Line to 0 and Post the document
      // After the post, "Qty. to Invoice" of Charge Item Line will be set to "Qty. Rcd. Not Invoiced" automatically
      IF DocumentType = SalesLine."Document Type"::Order THEN
        SalesLine2.VALIDATE("Qty. to Ship",0)
      ELSE
        SalesLine2.VALIDATE("Qty. to Invoice",0);
      SalesLine2.MODIFY(TRUE);
      LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      // Exercise: Post Invoice for the invalidated item charge assignment
      ASSERTERROR LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      // Verify: Post failed
      Assert.ExpectedError(STRSUBSTNO(InvalidatedAssignmentErr));
Member of Lib.Library - Patterns


ASSIGNSalesChargeToSalesShptLine@14 Method

The procedure ASSIGNSalesChargeToSalesShptLine is available in codeunit 132212.

Syntax

ASSIGNSalesChargeToSalesShptLine@14(
    SalesHeader@1003 : Record 36 SalesHeader, //Input parameter of type Record
    SalesShptLine@1002 : Record 111 SalesShptLine, //Input parameter of type Record
    Qty@1001 : Decimal Qty, //Input parameter of type Decimal
    UnitCost@1006 : Decimal UnitCost //Input parameter of type Decimal
);

Parameters

SalesHeader
Input parameter of type Record
SalesShptLine
Input parameter of type Record
Qty
Input parameter of type Decimal
UnitCost
Input parameter of type Decimal

Remarks

The relevant search keywords are: ASSIGN, Sales, Charge, To, Sales, Shpt, Line.

For a clarification about how this function works, refer to the code listed below.

      MAKEItemChargeSalesLine(SalesLine,ItemCharge,SalesHeader,Qty,UnitCost);

      SalesShptLine.TESTFIELD(Type,SalesShptLine.Type::Item);

      LibrarySales.CreateItemChargeAssignment(ItemChargeAssignmentSales,SalesLine,ItemCharge,
        ItemChargeAssignmentSales."Applies-to Doc. Type"::Shipment,
        SalesShptLine."Document No.",SalesShptLine."Line No.",
        SalesShptLine."No.",Qty,UnitCost);
      ItemChargeAssignmentSales.INSERT;

Example

The below example is extracted from the test automation codeunit 137602 to show one way of using this function.

      LibraryPatterns.ASSIGNSalesChargeToSalesShptLine(
        SalesHeader,SalesShptLineApplyTo,LibraryPatterns.RandDec(0,SalesShptLineApplyTo.Quantity,5),LibraryPatterns.RandDec(0,100,5));
Member of Lib.Library - Patterns


CalculateInventoryValueRun@57 Method

The procedure CalculateInventoryValueRun is available in codeunit 132212.

Syntax

CalculateInventoryValueRun@57(
    VAR ItemJnlBatch@1000 : Record 233 ItemJnlBatch, //Reference parameter of type Record
    VAR Item@1001 : Record 27 Item, //Reference parameter of type Record
    PostingDate@1003 : Date PostingDate, //Input parameter of type Date
    CalculatePer@1009 : Option CalculatePer, //Input parameter of type Option
    ByLocation@1008 : Boolean ByLocation, //Input parameter of type Boolean
    ByVariant@1007 : Boolean ByVariant, //Input parameter of type Boolean
    UpdStdCost@1006 : Boolean UpdStdCost, //Input parameter of type Boolean
    CalcBase@1005 : Option CalcBase, //Input parameter of type Option
    ShowDialog@1004 : Boolean ShowDialog, //Input parameter of type Boolean
    LocationFilter@1011 : Code[20] LocationFilter, //Input parameter of type Code
    VariantFilter@1012 : Code[20] VariantFilter //Input parameter of type Code
);

Parameters

ItemJnlBatch
Reference parameter of type Record
Item
Reference parameter of type Record
PostingDate
Input parameter of type Date
CalculatePer
Input parameter of type Option
ByLocation
Input parameter of type Boolean
ByVariant
Input parameter of type Boolean
UpdStdCost
Input parameter of type Boolean
CalcBase
Input parameter of type Option
ShowDialog
Input parameter of type Boolean
LocationFilter
Input parameter of type Code
VariantFilter
Input parameter of type Code

Remarks

The relevant search keywords are: Calculate, Inventory, Value, Run.

For a clarification about how this function works, refer to the code listed below.

      LibraryInventory.CreateItemJournalBatchByType(ItemJnlBatch,ItemJnlBatch."Template Type"::Revaluation);
      DocumentNo := LibraryUtility.GenerateRandomCode(ItemJournalLine.FIELDNO("Document No."),DATABASE::"Item Journal Line");
      ItemJournalLine.VALIDATE("Journal Template Name",ItemJnlBatch."Journal Template Name");
      ItemJournalLine.VALIDATE("Journal Batch Name",ItemJnlBatch.Name);
      Item.SETFILTER("Location Filter",LocationFilter);
      Item.SETFILTER("Variant Filter",VariantFilter);
      CalculateInventoryValue.USEREQUESTPAGE(FALSE);
      CalculateInventoryValue.SetItemJnlLine(ItemJournalLine);
      RevalueItem.COPY(Item);
      IF Item."No." <> '' THEN
        RevalueItem.SETRANGE("No.",Item."No.");
      CalculateInventoryValue.SETTABLEVIEW(RevalueItem);
      CalculateInventoryValue.InitializeRequest(
        PostingDate,DocumentNo,TRUE,CalculatePer,ByLocation,ByVariant,UpdStdCost,CalcBase,ShowDialog);
      CalculateInventoryValue.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 137053 to show one way of using this function.

      // [SCENARIO] Verify ILE "Cost Amount (Actual)" after posting: purchase (full receive, part invoice) - sales - adjust cost - revaluation - adjust cost - sales - purchase (remaining invoice) - sales - adjust cost.

      CreateItemWithAvg(Item);

      PostingDate := WORKDATE;

      // Purchase Receive 3, Invoice 1
      LibraryPatterns.MAKEPurchaseOrder(PurchaseHeader,PurchaseLine,Item,'','',3,PostingDate,10);
      PurchaseLine.VALIDATE("Qty. to Invoice",2);
      PurchaseLine.MODIFY;
      PurchaseHeader.VALIDATE("Vendor Invoice No.",LibraryUtility.GenerateGUID);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

      // Sell 1
      LibraryPatterns.POSTSalesOrder(SalesHeader,Item,'','',1,PostingDate,0,TRUE,TRUE);
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');

      // Revalue
      LibraryPatterns.CalculateInventoryValueRun(ItemJnlBatch,Item,PostingDate,1,FALSE,FALSE,FALSE,0,FALSE,'','');
      LibraryPatterns.ModifyPostRevaluation(ItemJnlBatch,2);
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');

      PostingDate += 1;

      // Sell 1
      LibraryPatterns.POSTSalesOrder(SalesHeader,Item,'','',1,PostingDate,0,TRUE,TRUE);

      PostingDate += 1;
      // Purchase Invoice Remaining 2
      PurchaseHeader.FIND;
      PurchaseHeader.VALIDATE("Posting Date",PostingDate);
      PurchaseHeader.MODIFY;
      PurchaseLine.FIND;
      PurchaseLine.VALIDATE("Direct Unit Cost",12);
      PurchaseLine.MODIFY;
      PurchaseHeader.VALIDATE("Vendor Invoice No.",LibraryUtility.GenerateGUID);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

      PostingDate += 1;
      // Sell 1
      LibraryPatterns.POSTSalesOrder(SalesHeader,Item,'','',1,PostingDate,0,TRUE,TRUE);

      LibraryCosting.AdjustCostItemEntries(Item."No.",'');
      LibraryCosting.CheckAdjustment(Item);
Member of Lib.Library - Patterns


CHECKCalcInvPost@74 Method

The procedure CHECKCalcInvPost is available in codeunit 132212.

Syntax

CHECKCalcInvPost@74(
    Item@1006 : Record 27 Item, //Input parameter of type Record
    ItemJnlBatch@1008 : Record 233 ItemJnlBatch, //Input parameter of type Record
    PostingDate@1005 : Date PostingDate, //Input parameter of type Date
    CalculatePer@1004 : Option CalculatePer, //Input parameter of type Option
    ByLocation@1003 : Boolean ByLocation, //Input parameter of type Boolean
    ByVariant@1002 : Boolean ByVariant, //Input parameter of type Boolean
    LocationFilter@1001 : Code[20] LocationFilter, //Input parameter of type Code
    VariantFilter@1000 : Code[20] VariantFilter //Input parameter of type Code
);

Parameters

Item
Input parameter of type Record
ItemJnlBatch
Input parameter of type Record
PostingDate
Input parameter of type Date
CalculatePer
Input parameter of type Option
ByLocation
Input parameter of type Boolean
ByVariant
Input parameter of type Boolean
LocationFilter
Input parameter of type Code
VariantFilter
Input parameter of type Code

Remarks

The relevant search keywords are: CHECK, Calc, Invoice, Post.

For a clarification about how this function works, refer to the code listed below.

      // Verify journal lines created by Calculate Inventory Value report
      CreateRefJnlforCalcInvPost(Item,TempRefItemJnlLine,PostingDate,CalculatePer,ByLocation,ByVariant,LocationFilter,VariantFilter);

      ItemJnlLine.SETRANGE("Journal Template Name",ItemJnlBatch."Journal Template Name");
      ItemJnlLine.SETRANGE("Journal Batch Name",ItemJnlBatch.Name);
      ItemJnlLine.SETRANGE("Item No.",Item."No.");

      Assert.AreEqual(TempRefItemJnlLine.COUNT,ItemJnlLine.COUNT,STRSUBSTNO(TXTLineCountMismatch,Item."No."));

      IF CalculatePer = CalculatePer::Item THEN BEGIN
        IF ItemJnlLine.FINDSET THEN
          REPEAT
            TempRefItemJnlLine.SETRANGE("Location Code",ItemJnlLine."Location Code");
            TempRefItemJnlLine.SETRANGE("Variant Code",ItemJnlLine."Variant Code");
            TempRefItemJnlLine.FINDFIRST;
            Assert.AreEqual(
              TempRefItemJnlLine.Quantity,ItemJnlLine.Quantity,
              STRSUBSTNO(TXTIncorrectEntry,TempRefItemJnlLine.FIELDNAME(Quantity),ItemJnlLine."Line No."));
            Assert.AreEqual(TempRefItemJnlLine."Inventory Value (Calculated)",ItemJnlLine."Inventory Value (Calculated)",
              STRSUBSTNO(TXTIncorrectEntry,TempRefItemJnlLine.FIELDNAME("Inventory Value (Calculated)"),ItemJnlLine."Line No."));
          UNTIL ItemJnlLine.NEXT = 0;
      END ELSE BEGIN
        IF ItemJnlLine.FINDSET THEN
          REPEAT
            TempRefItemJnlLine.SETRANGE("Applies-to Entry",ItemJnlLine."Applies-to Entry");
            TempRefItemJnlLine.FINDFIRST;
            Assert.AreEqual(
              TempRefItemJnlLine."Location Code",ItemJnlLine."Location Code",
              STRSUBSTNO(TXTIncorrectEntry,TempRefItemJnlLine.FIELDNAME("Location Code"),ItemJnlLine."Applies-to Entry"));
            Assert.AreEqual(
              TempRefItemJnlLine."Variant Code",ItemJnlLine."Variant Code",
              STRSUBSTNO(TXTIncorrectEntry,TempRefItemJnlLine.FIELDNAME("Variant Code"),ItemJnlLine."Applies-to Entry"));
            Assert.AreEqual(
              TempRefItemJnlLine.Quantity,ItemJnlLine.Quantity,
              STRSUBSTNO(TXTIncorrectEntry,TempRefItemJnlLine.FIELDNAME(Quantity),ItemJnlLine."Applies-to Entry"));
            Assert.AreEqual(
              TempRefItemJnlLine."Inventory Value (Calculated)",ItemJnlLine."Inventory Value (Calculated)",
              STRSUBSTNO(TXTIncorrectEntry,TempRefItemJnlLine.FIELDNAME("Inventory Value (Calculated)"),ItemJnlLine."Applies-to Entry"));
          UNTIL ItemJnlLine.NEXT = 0;
      END;

Example

The below example is extracted from the test automation codeunit 137603 to show one way of using this function.

      // Test to reproduce Bug311425
      Initialize;
      Day1 := WORKDATE;

      // Make item
      LibraryPatterns.MAKEItem(FIFOItem,FIFOItem."Costing Method"::FIFO,LibraryRandom.RandInt(10),0,0,'');
      LibraryPatterns.MAKEItem(LIFOItem,LIFOItem."Costing Method"::LIFO,LibraryRandom.RandInt(10),0,0,'');

      // Post Item Journals
      Qty := LibraryRandom.RandInt(100);
      LibraryPatterns.POSTItemJournalLine(
        ItemJournalBatch."Template Type"::Item,ItemJournalLine."Entry Type"::"Positive Adjmt.",FIFOItem,'','','',Qty,Day1,
        FIFOItem."Unit Cost");
      LibraryPatterns.POSTItemJournalLine(
        ItemJournalBatch."Template Type"::Item,ItemJournalLine."Entry Type"::"Positive Adjmt.",LIFOItem,'','','',Qty,Day1,
        LIFOItem."Unit Cost");

      // Do Revaluation and Verify
      RevalueItem.SETFILTER("No.",'%1|%2',FIFOItem."No.",LIFOItem."No.");
      RevalueItem.SETFILTER("Costing Method",'%1|%2',RevalueItem."Costing Method"::FIFO,RevalueItem."Costing Method"::LIFO);

      LibraryPatterns.CalculateInventoryValueRun(
        ItemJournalBatch,RevalueItem,Day1,CalculatePer::"Item Ledger Entry",FALSE,FALSE,FALSE,CalculationBase::" ",FALSE,'','');
      LibraryPatterns.CHECKCalcInvPost(FIFOItem,ItemJournalBatch,Day1,CalculatePer::"Item Ledger Entry",FALSE,FALSE,'','');
      LibraryPatterns.CHECKCalcInvPost(LIFOItem,ItemJournalBatch,Day1,CalculatePer::"Item Ledger Entry",FALSE,FALSE,'','');
Member of Lib.Library - Patterns


CHECKItemLedgerEntry@32 Method

The procedure CHECKItemLedgerEntry is available in codeunit 132212.

Syntax

CHECKItemLedgerEntry@32(
    VAR RefItemLedgerEntry@1001 : Record 32 RefItemLedgerEntry //Reference parameter of type Record
);

Parameters

RefItemLedgerEntry
Reference parameter of type Record

Remarks

The relevant search keywords are: CHECK, Item, Ledger, Entry.

For a clarification about how this function works, refer to the code listed below.

      WITH ItemLedgerEntry DO BEGIN
        RefItemLedgerEntry.FINDSET;
        SETRANGE("Item No.",RefItemLedgerEntry."Item No.");
        SETRANGE("Location Code",RefItemLedgerEntry."Location Code");
        SETRANGE("Variant Code",RefItemLedgerEntry."Variant Code");
        FINDSET;
        REPEAT
          TESTFIELD("Cost Amount (Expected)",RefItemLedgerEntry."Cost Amount (Expected)");
          TESTFIELD("Cost Amount (Actual)",RefItemLedgerEntry."Cost Amount (Actual)");
          TESTFIELD("Remaining Quantity",RefItemLedgerEntry."Remaining Quantity");
          TESTFIELD("Invoiced Quantity",RefItemLedgerEntry."Invoiced Quantity");
          TESTFIELD("Applies-to Entry",RefItemLedgerEntry."Applies-to Entry");
          RefItemLedgerEntry.NEXT;
        UNTIL NEXT = 0;
      END;

Example

There are no examples available.
Member of Lib.Library - Patterns


CHECKValueEntry@29 Method

The procedure CHECKValueEntry is available in codeunit 132212.

Syntax

CHECKValueEntry@29(
    VAR RefValueEntry@1002 : Record 5802 RefValueEntry, //Reference parameter of type Record
    ValueEntry@1001 : Record 5802 ValueEntry //Input parameter of type Record
);

Parameters

RefValueEntry
Reference parameter of type Record
ValueEntry
Input parameter of type Record

Remarks

The relevant search keywords are: CHECK, Value, Entry.

For a clarification about how this function works, refer to the code listed below.

      ValueEntry.TESTFIELD("Cost Amount (Expected)",RefValueEntry."Cost Amount (Expected)");
      ValueEntry.TESTFIELD("Cost Amount (Actual)",RefValueEntry."Cost Amount (Actual)");
      ValueEntry.TESTFIELD("Valued Quantity",RefValueEntry."Valued Quantity");
      ValueEntry.TESTFIELD("Cost per Unit",RefValueEntry."Cost per Unit");
      ValueEntry.TESTFIELD("Valuation Date",RefValueEntry."Valuation Date");
      ValueEntry.TESTFIELD("Entry Type",RefValueEntry."Entry Type");
      ValueEntry.TESTFIELD("Variance Type",RefValueEntry."Variance Type");

Example

The below example is extracted from the test automation codeunit 137603 to show one way of using this function.

      LibraryPatterns.MAKEItem(Item,CostingMethod,3.33333,0,0,'');
      CreateSetupEntriesRounding(Item,TempItemLedgerEntry,WORKDATE);
      TempItemLedgerEntry.FINDFIRST;
      IF CostingMethod = Item."Costing Method"::Average THEN BEGIN
        ExecuteRevalueExistingInventory(Item,ItemJnlBatch,WORKDATE,CalculatePer::Item,FALSE,FALSE,FALSE,CalculationBase::" ",'','');
        ModifyPostRevaluation(ItemJnlBatch,Item."No.",1.2);
      END ELSE
        LibraryPatterns.ExecutePostRevalueInboundILE(Item,TempItemLedgerEntry,1.2);
      LibraryCosting.CheckAdjustment(Item);

      IF CostingMethod <> Item."Costing Method"::Average THEN BEGIN
        ValueEntry.SETRANGE("Item No.",Item."No.");
        ValueEntry.SETRANGE("Entry Type",ValueEntry."Entry Type"::Rounding);
        ValueEntry.FINDSET;

        TempRefValueEntry."Cost Amount (Expected)" := 0;
        TempRefValueEntry."Cost Amount (Actual)" := -0.01;
        TempRefValueEntry."Valued Quantity" := 3;
        TempRefValueEntry."Cost per Unit" := 0;
        TempRefValueEntry."Valuation Date" := TempItemLedgerEntry."Posting Date";
        TempRefValueEntry."Entry Type" := TempRefValueEntry."Entry Type"::Rounding;
        TempRefValueEntry."Variance Type" := TempRefValueEntry."Variance Type"::" ";

        LibraryPatterns.CHECKValueEntry(TempRefValueEntry,ValueEntry);

        ValueEntry.NEXT;
        TempRefValueEntry."Cost Amount (Actual)" := 0.01;
        LibraryPatterns.CHECKValueEntry(TempRefValueEntry,ValueEntry);
      END;
Member of Lib.Library - Patterns


ExecutePostRevalueInboundILE@60 Method

The procedure ExecutePostRevalueInboundILE is available in codeunit 132212.

Syntax

ExecutePostRevalueInboundILE@60(
    Item@1002 : Record 27 Item, //Input parameter of type Record
    VAR TempItemLedgerEntry@1004 : TEMPORARY Record 32 TempItemLedgerEntry, //Reference Temporary parameter of type Record
    Factor@1005 : Decimal Factor //Input parameter of type Decimal
);

Parameters

Item
Input parameter of type Record
TempItemLedgerEntry
Reference Temporary parameter of type Record
Factor
Input parameter of type Decimal

Remarks

The relevant search keywords are: Execute, Post, Revalue, Inbound, ILE.

For a clarification about how this function works, refer to the code listed below.

      LibraryCosting.AdjustCostItemEntries(Item."No.",'');
      LibraryCosting.CheckAdjustment(Item);

      LibraryInventory.CreateItemJournalBatchByType(ItemJnlBatch,ItemJnlBatch."Template Type"::Revaluation);
      LibraryInventory.MakeItemJournalLine(ItemJnlLine,ItemJnlBatch,Item,WORKDATE,ItemJnlLine."Entry Type"::Purchase,0);
      TempItemLedgerEntry.FINDFIRST;
      EntryNo := TempItemLedgerEntry."Entry No.";
      ItemJnlLine.VALIDATE("Applies-to Entry",EntryNo);
      ItemJnlLine.VALIDATE("Inventory Value (Revalued)",ItemJnlLine."Inventory Value (Revalued)" * Factor);
      ItemJnlLine.INSERT;

      LibraryInventory.PostItemJournalBatch(ItemJnlBatch);
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');

Example

The below example is extracted from the test automation codeunit 137603 to show one way of using this function.

      LibraryPatterns.MAKEItem(Item,CostingMethod,StandardCost,0,0,'');
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location1);
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location2);
      LocationCode[1] := Location1.Code;
      LocationCode[2] := Location2.Code;
      CreateSetupEntrieswLocInbndandOutbnd(Item,LocationCode,TempItemLedgerEntry,WORKDATE);
      TempItemLedgerEntry.FINDFIRST;
      LibraryPatterns.ExecutePostRevalueInboundILE(Item,TempItemLedgerEntry,1.1);
Member of Lib.Library - Patterns


GRPH1Outbound1PurchInvd@36 Method

The procedure GRPH1Outbound1PurchInvd is available in codeunit 132212.

Syntax

GRPH1Outbound1PurchInvd@36(
    VAR TempItemLedgerEntry@1005 : TEMPORARY Record 32 TempItemLedgerEntry, //Reference Temporary parameter of type Record
    VAR PurchaseLine@1004 : Record 39 PurchaseLine, //Reference parameter of type Record
    Item@1003 : Record 27 Item, //Input parameter of type Record
    LocationCode@1002 : Code[10] LocationCode, //Input parameter of type Code
    VariantCode@1001 : Code[10] VariantCode //Input parameter of type Code
);

Parameters

TempItemLedgerEntry
Reference Temporary parameter of type Record
PurchaseLine
Reference parameter of type Record
Item
Input parameter of type Record
LocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code

Remarks

The relevant search keywords are: GRPH1, Outbound1, Purchase, Invd.

For a clarification about how this function works, refer to the code listed below.

      GRPH1Outbound1Purchase(TempItemLedgerEntry,PurchaseLine,Item,LocationCode,VariantCode,TRUE);

Example

There are no examples available.
Member of Lib.Library - Patterns


GRPH1Outbound1PurchRcvd@33 Method

The procedure GRPH1Outbound1PurchRcvd is available in codeunit 132212.

Syntax

GRPH1Outbound1PurchRcvd@33(
    VAR TempItemLedgerEntry@1005 : TEMPORARY Record 32 TempItemLedgerEntry, //Reference Temporary parameter of type Record
    VAR PurchaseLine@1004 : Record 39 PurchaseLine, //Reference parameter of type Record
    Item@1003 : Record 27 Item, //Input parameter of type Record
    LocationCode@1002 : Code[10] LocationCode, //Input parameter of type Code
    VariantCode@1001 : Code[10] VariantCode //Input parameter of type Code
);

Parameters

TempItemLedgerEntry
Reference Temporary parameter of type Record
PurchaseLine
Reference parameter of type Record
Item
Input parameter of type Record
LocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code

Remarks

The relevant search keywords are: GRPH1, Outbound1, Purchase, Rcvd.

For a clarification about how this function works, refer to the code listed below.

      GRPH1Outbound1Purchase(TempItemLedgerEntry,PurchaseLine,Item,LocationCode,VariantCode,FALSE);

Example

The below example is extracted from the test automation codeunit 137601 to show one way of using this function.

      Initialize;

      // Setup Item and SKU.
      LibraryPatterns.MAKEItem(Item,CostingMethod,0,0,0,'');
      IF MakeSKU THEN
        LibraryPatterns.MAKEStockkeepingUnit(StockkeepingUnit,Item);

      // Inventory Flow.
      LibraryPatterns.GRPH1Outbound1PurchRcvd(
        TempItemLedgerEntry,PurchaseLine,Item,StockkeepingUnit."Location Code",StockkeepingUnit."Variant Code");

      // Extract the Purchase Receipt No. from the ILEs.
      TempItemLedgerEntry.SETRANGE(Positive,TRUE);
      TempItemLedgerEntry.FINDFIRST;
      PurchRcptLine.GET(TempItemLedgerEntry."Document No.",TempItemLedgerEntry."Document Line No.");

      // Cost modification.
      PurchaseHeader.GET(PurchaseLine."Document Type",PurchaseLine."Document No.");
      LibraryPatterns.ASSIGNPurchChargeToPurchRcptLine(
        PurchaseHeader,PurchRcptLine,LibraryRandom.RandInt(10),LibraryRandom.RandDec(100,5));
      LibraryPatterns.ASSIGNPurchChargeToPurchaseLine(
        PurchaseHeader,PurchaseLine,LibraryRandom.RandInt(10),LibraryRandom.RandDec(100,5));
      PurchaseHeader.VALIDATE("Vendor Invoice No.",LibraryUtility.GenerateGUID);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

      // Exercise.
      PurchaseHeader.GET(PurchaseHeader."Document Type"::Order,PurchRcptLine."Order No.");
      PurchaseHeader.VALIDATE("Vendor Invoice No.",LibraryUtility.GenerateGUID);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,FALSE,TRUE);
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');

      // Verify.
      LibraryCosting.CheckAdjustment(Item);
Member of Lib.Library - Patterns


GRPH3Purch1SalesItemTracked@35 Method

The procedure GRPH3Purch1SalesItemTracked is available in codeunit 132212.

Syntax

GRPH3Purch1SalesItemTracked@35(
    VAR SalesLine@1000 : Record 37 SalesLine, //Reference parameter of type Record
    Item@1001 : Record 27 Item, //Input parameter of type Record
    LocationCode@1002 : Code[10] LocationCode, //Input parameter of type Code
    VariantCode@1003 : Code[10] VariantCode, //Input parameter of type Code
    InvoicePurchase@1004 : Boolean InvoicePurchase, //Input parameter of type Boolean
    InvoiceSales@1005 : Boolean InvoiceSales //Input parameter of type Boolean
);

Parameters

SalesLine
Reference parameter of type Record
Item
Input parameter of type Record
LocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code
InvoicePurchase
Input parameter of type Boolean
InvoiceSales
Input parameter of type Boolean

Remarks

The relevant search keywords are: GRPH3, Purch1, Sales, Item, Tracked.

For a clarification about how this function works, refer to the code listed below.

      // Purchase 3 times.
      GRPHPurchItemTracked(TempItemLedgerEntry,PurchaseLine,ReservEntry2,Item,LocationCode,VariantCode,InvoicePurchase);
      GRPHPurchItemTracked(TempItemLedgerEntry,PurchaseLine,ReservEntry,Item,LocationCode,VariantCode,InvoicePurchase);
      GRPHPurchItemTracked(TempItemLedgerEntry,PurchaseLine,ReservEntry2,Item,LocationCode,VariantCode,InvoicePurchase);

      // Make the sales for the item tracking in 2nd purchase line
      GRPHSalesItemTracked(TempItemLedgerEntry,SalesLine,ReservEntry,Item,LocationCode,VariantCode,InvoiceSales);

Example

The below example is extracted from the test automation codeunit 137601 to show one way of using this function.

      // Setup Item Tracking Code, Item and SKU.
      Initialize;
      LibraryItemTracking.CreateItemTrackingCode(ItemTrackingCode,FALSE,TRUE);
      LibraryPatterns.MAKEItem(Item,CostingMethod,0,0,0,ItemTrackingCode.Code);
      IF MakeSKU THEN
        LibraryPatterns.MAKEStockkeepingUnit(StockkeepingUnit,Item);

      // Inventory flow.
      LibraryPatterns.GRPH3Purch1SalesItemTracked(
        SalesLine,Item,StockkeepingUnit."Location Code",StockkeepingUnit."Variant Code",FALSE,FALSE);
      SalesHeader.GET(SalesLine."Document Type",SalesLine."Document No.");

      // Exercise.
      LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');

      // Verify.
      LibraryCosting.CheckAdjustment(Item);
Member of Lib.Library - Patterns


GRPHApplyInboundToUnappliedOutbound@52 Method

The procedure GRPHApplyInboundToUnappliedOutbound is available in codeunit 132212.

Syntax

GRPHApplyInboundToUnappliedOutbound@52(
    VAR Item@1000 : Record 27 Item, //Reference parameter of type Record
    VAR SalesLine@1002 : Record 37 SalesLine //Reference parameter of type Record
);

Parameters

Item
Reference parameter of type Record
SalesLine
Reference parameter of type Record

Remarks

The relevant search keywords are: GRPH, Apply, Inbound, To, Unapplied, Outbound.

For a clarification about how this function works, refer to the code listed below.

      QtyOut := RandDec(10,20,2);
      QtyIn1 := RandDec(0,QtyOut / 2,2);
      QtyIn2 := QtyOut - QtyIn1 + RandDec(0,10,2);

      SHIPSales(SalesLine,Item,QtyOut,WORKDATE);

      MAKEInbound(Item,QtyIn1,WORKDATE - 1,TempItemJournalLine);
      MAKEInbound(Item,QtyIn2,WORKDATE - 2,TempItemJournalLine);

Example

The below example is extracted from the test automation codeunit 137602 to show one way of using this function.

      // Setup
      Initialize;

      LibraryPatterns.MAKEItemSimple(Item,CostingMethod,LibraryPatterns.RandCost(Item));
      LibraryPatterns.GRPHApplyInboundToUnappliedOutbound(Item,SalesLine);

      GetSalesHeader(SalesLine,SalesHeader);
      LibrarySales.ReopenSalesDocument(SalesHeader);
      AssignItemCharge(SalesHeader,SalesLine);
      Invoice(SalesLine);

      // Execute
      Adjust(Item);

      // Validate
      LibraryCosting.CheckAdjustment(Item);
Member of Lib.Library - Patterns


GRPHPurchItemTracked@41 Method

The procedure GRPHPurchItemTracked is available in codeunit 132212.

Syntax

GRPHPurchItemTracked@41(
    VAR TempItemLedgerEntry@1005 : TEMPORARY Record 32 TempItemLedgerEntry, //Reference Temporary parameter of type Record
    VAR PurchaseLine@1004 : Record 39 PurchaseLine, //Reference parameter of type Record
    VAR ReservEntry@1007 : Record 337 ReservEntry, //Reference parameter of type Record
    Item@1003 : Record 27 Item, //Input parameter of type Record
    LocationCode@1002 : Code[10] LocationCode, //Input parameter of type Code
    VariantCode@1001 : Code[10] VariantCode, //Input parameter of type Code
    Invoice@1000 : Boolean Invoice //Input parameter of type Boolean
);

Parameters

TempItemLedgerEntry
Reference Temporary parameter of type Record
PurchaseLine
Reference parameter of type Record
ReservEntry
Reference parameter of type Record
Item
Input parameter of type Record
LocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code
Invoice
Input parameter of type Boolean

Remarks

The relevant search keywords are: GRPH, Purchase, Item, Tracked.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(TempItemLedgerEntry);
      Day1 := WORKDATE;

      InboundQty := LibraryRandom.RandInt(10);
      MAKEPurchaseOrder(
        PurchaseHeader,PurchaseLine,Item,LocationCode,VariantCode,InboundQty,Day1,LibraryRandom.RandDec(100,2));
      LibraryItemTracking.CreatePurchOrderItemTracking(ReservEntry,PurchaseLine,'',
        COPYSTR(LibraryUtility.GenerateRandomCode(ReservEntry.FIELDNO("Lot No."),DATABASE::"Reservation Entry"),1,10),InboundQty);
      IF Invoice THEN
        SetVendorDocNo(PurchaseHeader);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,Invoice);
      InsertTempILEFromLast(TempItemLedgerEntry);

Example

There are no examples available.
Member of Lib.Library - Patterns


GRPHPurchPartialRcvd1PurchReturn@43 Method

The procedure GRPHPurchPartialRcvd1PurchReturn is available in codeunit 132212.

Syntax

GRPHPurchPartialRcvd1PurchReturn@43(
    VAR TempItemLedgerEntry@1001 : TEMPORARY Record 32 TempItemLedgerEntry, //Reference Temporary parameter of type Record
    VAR PurchaseLine@1002 : Record 39 PurchaseLine, //Reference parameter of type Record
    VAR PurchaseLine1@1010 : Record 39 PurchaseLine1, //Reference parameter of type Record
    Item@1000 : Record 27 Item, //Input parameter of type Record
    LocationCode@1003 : Code[10] LocationCode, //Input parameter of type Code
    VariantCode@1004 : Code[10] VariantCode, //Input parameter of type Code
    InvoicePurchase@1008 : Boolean InvoicePurchase //Input parameter of type Boolean
);

Parameters

TempItemLedgerEntry
Reference Temporary parameter of type Record
PurchaseLine
Reference parameter of type Record
PurchaseLine1
Reference parameter of type Record
Item
Input parameter of type Record
LocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code
InvoicePurchase
Input parameter of type Boolean

Remarks

The relevant search keywords are: GRPH, Purchasease, Partial, Rcvd1, Purchasease, Return.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(TempItemLedgerEntry);
      Day1 := WORKDATE;

      // Receive partially the Purchase Line, with or without invoicing.
      InboundQty := LibraryRandom.RandIntInRange(10,20);
      MAKEPurchaseOrder(
        PurchaseHeader,PurchaseLine,Item,LocationCode,VariantCode,InboundQty,Day1 + 2,LibraryRandom.RandDec(100,2));
      PurchaseLine.VALIDATE("Qty. to Receive",LibraryRandom.RandInt(PurchaseLine."Outstanding Quantity" - 5));
      PurchaseLine.MODIFY;
      IF InvoicePurchase THEN
        SetVendorDocNo(PurchaseHeader);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,InvoicePurchase);
      InsertTempILEFromLast(TempItemLedgerEntry);

      // Repeat the receipt.
      PurchaseLine.GET(PurchaseLine."Document Type",PurchaseLine."Document No.",PurchaseLine."Line No.");
      PurchaseLine.VALIDATE("Qty. to Receive",LibraryRandom.RandInt(PurchaseLine."Outstanding Quantity" - 1));
      PurchaseLine.VALIDATE("Direct Unit Cost",PurchaseLine."Direct Unit Cost" + LibraryRandom.RandDec(10,2));
      PurchaseLine.MODIFY;
      PurchaseHeader.GET(PurchaseHeader."Document Type",PurchaseHeader."No.");
      IF InvoicePurchase THEN
        SetVendorDocNo(PurchaseHeader);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,InvoicePurchase);
      InsertTempILEFromLast(TempItemLedgerEntry);

      // Create Purchase Return Header and Line with 0 quantity. Actual qty to be added in calling test.
      MAKEPurchaseReturnOrder(
        PurchaseHeader1,PurchaseLine1,Item,LocationCode,VariantCode,0,Day1 + 2,LibraryRandom.RandDec(100,5));

Example

The below example is extracted from the test automation codeunit 137601 to show one way of using this function.

      // Setup Item and SKU.
      Initialize;
      LibraryPatterns.MAKEItem(Item,CostingMethod,0,0,0,'');
      IF MakeSKU THEN
        LibraryPatterns.MAKEStockkeepingUnit(StockkeepingUnit,Item);

      // Inventory Flow.
      LibraryPatterns.GRPHPurchPartialRcvd1PurchReturn(
        TempItemLedgerEntry,PurchaseLine,PurchaseLine1,Item,StockkeepingUnit."Location Code",StockkeepingUnit."Variant Code",
        InvoicePartialReceipt);
      PurchaseLine1.VALIDATE(Quantity,PurchaseLine.Quantity);
      PurchaseLine1.MODIFY;

      // Extract the Purchase Receipt No. from the ILEs.
      TempItemLedgerEntry.SETRANGE(Positive,TRUE);
      TempItemLedgerEntry.FINDFIRST;
      PurchRcptLine.GET(TempItemLedgerEntry."Document No.",TempItemLedgerEntry."Document Line No.");

      // Cost modification.
      // for Purchase.
      PurchaseHeader.GET(PurchaseLine."Document Type",PurchaseLine."Document No.");
      LibraryPurchase.ReopenPurchaseDocument(PurchaseHeader);
      LibraryPatterns.ASSIGNPurchChargeToPurchRcptLine(
        PurchaseHeader,PurchRcptLine,LibraryRandom.RandInt(10),LibraryRandom.RandDec(100,5));
      LibraryPatterns.ASSIGNPurchChargeToPurchaseLine(
        PurchaseHeader,PurchaseLine,LibraryRandom.RandInt(10),LibraryRandom.RandDec(100,5));
      PurchaseHeader.VALIDATE("Vendor Invoice No.",LibraryUtility.GenerateGUID);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);
      // for Purchase Return.
      PurchaseHeader1.GET(PurchaseLine1."Document Type",PurchaseLine1."Document No.");
      LibraryPurchase.ReopenPurchaseDocument(PurchaseHeader1);
      LibraryPatterns.ASSIGNPurchChargeToPurchReturnLine(
        PurchaseHeader1,PurchaseLine1,LibraryRandom.RandInt(10),LibraryRandom.RandDec(100,5));

      // Exercise.
      PurchaseHeader1.VALIDATE("Vendor Cr. Memo No.",LibraryUtility.GenerateGUID);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader1,TRUE,TRUE);
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');

      // Verify.
      LibraryCosting.CheckAdjustment(Item);
Member of Lib.Library - Patterns


GRPHSalesFromReturnReceipts@55 Method

The procedure GRPHSalesFromReturnReceipts is available in codeunit 132212.

Syntax

GRPHSalesFromReturnReceipts@55(
    VAR Item@1000 : Record 27 Item, //Reference parameter of type Record
    VAR SalesLine@1006 : Record 37 SalesLine //Reference parameter of type Record
);

Parameters

Item
Reference parameter of type Record
SalesLine
Reference parameter of type Record

Remarks

The relevant search keywords are: GRPH, Sales, From, Return, Receipts.

For a clarification about how this function works, refer to the code listed below.

      GRPHSalesReturnOnly(Item,ReturnReceiptLine1);
      GRPHSalesReturnOnly(Item,ReturnReceiptLine2);
      SHIPSales(SalesLine,Item,ReturnReceiptLine1.Quantity + RandDec(0,ReturnReceiptLine2.Quantity,2),WORKDATE);

Example

The below example is extracted from the test automation codeunit 137602 to show one way of using this function.

      Initialize;

      LibraryPatterns.MAKEItem(Item,CostingMethod,LibraryPatterns.RandCost(Item),0,0,'');
      LibraryPatterns.GRPHSalesFromReturnReceipts(Item,SalesLine);

      Invoice(SalesLine);

      Adjust(Item);
      LibraryCosting.CheckAdjustment(Item);
Member of Lib.Library - Patterns


GRPHSalesItemTracked@42 Method

The procedure GRPHSalesItemTracked is available in codeunit 132212.

Syntax

GRPHSalesItemTracked@42(
    VAR TempItemLedgerEntry@1005 : TEMPORARY Record 32 TempItemLedgerEntry, //Reference Temporary parameter of type Record
    VAR SalesLine@1004 : Record 37 SalesLine, //Reference parameter of type Record
    VAR ReservEntry@1008 : Record 337 ReservEntry, //Reference parameter of type Record
    Item@1003 : Record 27 Item, //Input parameter of type Record
    LocationCode@1002 : Code[10] LocationCode, //Input parameter of type Code
    VariantCode@1001 : Code[10] VariantCode, //Input parameter of type Code
    Invoice@1000 : Boolean Invoice //Input parameter of type Boolean
);

Parameters

TempItemLedgerEntry
Reference Temporary parameter of type Record
SalesLine
Reference parameter of type Record
ReservEntry
Reference parameter of type Record
Item
Input parameter of type Record
LocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code
Invoice
Input parameter of type Boolean

Remarks

The relevant search keywords are: GRPH, Sales, Item, Tracked.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(TempItemLedgerEntry);
      Day1 := WORKDATE;

      OutboundQty := LibraryRandom.RandInt(ReservEntry.Quantity);
      MAKESalesOrder(SalesHeader,SalesLine,Item,LocationCode,VariantCode,OutboundQty,Day1,LibraryRandom.RandDec(100,2));
      LibraryItemTracking.CreateSalesOrderItemTracking(ReservEntry2,SalesLine,'',ReservEntry."Lot No.",OutboundQty);

      LibrarySales.PostSalesDocument(SalesHeader,TRUE,Invoice);
      ReservEntry := ReservEntry2;
      InsertTempILEFromLast(TempItemLedgerEntry);

Example

There are no examples available.
Member of Lib.Library - Patterns


GRPHSalesOnly@54 Method

The procedure GRPHSalesOnly is available in codeunit 132212.

Syntax

GRPHSalesOnly@54(
    Item@1000 : Record 27 Item, //Input parameter of type Record
    VAR SalesLine@1001 : Record 37 SalesLine //Reference parameter of type Record
);

Parameters

Item
Input parameter of type Record
SalesLine
Reference parameter of type Record

Remarks

The relevant search keywords are: GRPH, Sales, Only.

For a clarification about how this function works, refer to the code listed below.

      SHIPSales(SalesLine,Item,RandDec(10,20,2),WORKDATE);

Example

The below example is extracted from the test automation codeunit 137602 to show one way of using this function.

      // Setup
      Initialize;

      LibraryPatterns.MAKEItemSimple(Item,CostingMethod,LibraryPatterns.RandCost(Item));
      LibraryPatterns.GRPHSalesOnly(Item,SalesLine);

      GetSalesHeader(SalesLine,SalesHeader);
      LibrarySales.ReopenSalesDocument(SalesHeader);
      AssignItemCharge(SalesHeader,SalesLine);
      Invoice(SalesLine);

      // Execute
      Adjust(Item);

      // Validate
      ItemLedgerEntry.SETRANGE("Item No.",Item."No.");
      ItemLedgerEntry.FINDFIRST;
      Assert.AreEqual(1,ItemLedgerEntry.COUNT,
        'Expected exactly one item ledger entry after posting sales order');

      ItemApplicationEntry.SETRANGE("Outbound Item Entry No.",ItemLedgerEntry."Entry No.");
      Assert.IsTrue(ItemApplicationEntry.ISEMPTY,
        'Expected no application entries after posting sales order only.');
Member of Lib.Library - Patterns


GRPHSalesReturnOnly@53 Method

The procedure GRPHSalesReturnOnly is available in codeunit 132212.

Syntax

GRPHSalesReturnOnly@53(
    VAR Item@1000 : Record 27 Item, //Reference parameter of type Record
    VAR ReturnReceiptLine@1001 : Record 6661 ReturnReceiptLine //Reference parameter of type Record
);

Parameters

Item
Reference parameter of type Record
ReturnReceiptLine
Reference parameter of type Record

Remarks

The relevant search keywords are: GRPH, Sales, Return, Only.

For a clarification about how this function works, refer to the code listed below.

      LibrarySales.CreateSalesHeader(SalesHeader,SalesHeader."Document Type"::"Return Order",'');
      LibrarySales.CreateSalesLine(SalesLine,SalesHeader,SalesLine.Type::Item,Item."No.",RandDec(10,20,2));
      COMMIT;

      LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      ReturnReceiptLine.SETFILTER("No.",Item."No.");
      ReturnReceiptLine.FINDLAST;

Example

The below example is extracted from the test automation codeunit 137602 to show one way of using this function.

      Initialize;

      LibraryPatterns.MAKEItem(Item,CostingMethod,LibraryPatterns.RandCost(Item),0,0,'');
      LibraryPatterns.GRPHSalesReturnOnly(Item,ReturnReceiptLine);

      Adjust(Item);
      LibraryCosting.CheckAdjustment(Item);
Member of Lib.Library - Patterns


GRPHSeveralSplitApplication@76 Method

The procedure GRPHSeveralSplitApplication is available in codeunit 132212.

Syntax

GRPHSeveralSplitApplication@76(
    Item@1000 : Record 27 Item, //Input parameter of type Record
    VAR SalesLine@1011 : Record 37 SalesLine, //Reference parameter of type Record
    VAR TempItemJournalLine@1008 : TEMPORARY Record 83 TempItemJournalLine //Reference Temporary parameter of type Record
);

Parameters

Item
Input parameter of type Record
SalesLine
Reference parameter of type Record
TempItemJournalLine
Reference Temporary parameter of type Record

Remarks

The relevant search keywords are: GRPH, Several, Split, Application.

For a clarification about how this function works, refer to the code listed below.

      GRPHSeveralSplitApplicationWithCosts(Item,SalesLine,TempItemJournalLine,Unused,Unused,Unused);

Example

The below example is extracted from the test automation codeunit 137602 to show one way of using this function.

      // From: Costing suite - CETAF 51
      // Costing: Standard; Inventory: Several splits; Modifications: None
      Initialize;

      StandardItem(Item);
      LibraryPatterns.GRPHSeveralSplitApplication(Item,SalesLine,TempItemJournalLine);

      // Execute: Run adjust cost batch job
      Adjust(Item);

      // Validate
      COMMIT;
      GetEntries(Item,ItemLedgerEntry,ValueEntry);

      ValidateValueEntry_StandardInbound(Item,ItemLedgerEntry,ValueEntry,TempItemJournalLine);
      ValidateValueEntry_StandardInbound(Item,ItemLedgerEntry,ValueEntry,TempItemJournalLine);
      ValidateValueEntry_StandardInbound(Item,ItemLedgerEntry,ValueEntry,TempItemJournalLine);

      ValidateValueEntry_StandardOutbound(Item,ItemLedgerEntry,ValueEntry);
      ValidateValueEntry_StandardOutbound(Item,ItemLedgerEntry,ValueEntry);
      ValidateValueEntry_StandardOutboundExpected(Item,ItemLedgerEntry,ValueEntry);

      LibraryCosting.CheckAdjustment(Item);
Member of Lib.Library - Patterns


GRPHSeveralSplitApplicationWithCosts@75 Method

The procedure GRPHSeveralSplitApplicationWithCosts is available in codeunit 132212.

Syntax

GRPHSeveralSplitApplicationWithCosts@75(
    Item@1000 : Record 27 Item, //Input parameter of type Record
    VAR SalesLine@1011 : Record 37 SalesLine, //Reference parameter of type Record
    VAR TempItemJournalLine@1009 : TEMPORARY Record 83 TempItemJournalLine, //Reference Temporary parameter of type Record
    VAR Cost1@1012 : Decimal Cost1, //Reference parameter of type Decimal
    VAR Cost2@1015 : Decimal Cost2, //Reference parameter of type Decimal
    VAR Cost3@1016 : Decimal Cost3 //Reference parameter of type Decimal
);

Parameters

Item
Input parameter of type Record
SalesLine
Reference parameter of type Record
TempItemJournalLine
Reference Temporary parameter of type Record
Cost1
Reference parameter of type Decimal
Cost2
Reference parameter of type Decimal
Cost3
Reference parameter of type Decimal

Remarks

The relevant search keywords are: GRPH, Several, Split, Application, Costs.

For a clarification about how this function works, refer to the code listed below.

      Qty1 := RandDec(10,20,2);
      Qty2 := RandDec(10,20,2);
      Qty3 := RandDec(10,20,2);

      MAKEInbound(Item,Qty1,WORKDATE,TempItemJournalLine);
      UnitCost1 := TempItemJournalLine."Unit Amount";
      MAKEInbound(Item,Qty2,WORKDATE + 1,TempItemJournalLine);
      UnitCost2 := TempItemJournalLine."Unit Amount";
      MAKEInbound(Item,Qty3,WORKDATE + 2,TempItemJournalLine);
      UnitCost3 := TempItemJournalLine."Unit Amount";

      QtyOut1 := Qty1 + RandDec(0,Qty2 / 2,2);
      RemainingQty2 := Qty2 + Qty1 - QtyOut1;
      QtyOut2 := RandDec(0,RemainingQty2,2);

      MAKEOutbound(Item,QtyOut1,WORKDATE + 3,TempItemJournalLine);
      Cost1 := (Qty1 * UnitCost1 + (QtyOut1 - Qty1) * UnitCost2) / QtyOut1;
      MAKEOutbound(Item,QtyOut2,WORKDATE + 4,TempItemJournalLine);
      Cost2 := UnitCost2;

      RemainingQty2 -= QtyOut2;
      SHIPSales(SalesLine,Item,RemainingQty2 + RandDec(0,Qty3,2),WORKDATE + 5);
      Cost3 := (RemainingQty2 * UnitCost2 + (SalesLine.Quantity - RemainingQty2) * UnitCost3) / SalesLine.Quantity;

      TempItemJournalLine.FINDSET;

Example

The below example is extracted from the test automation codeunit 137602 to show one way of using this function.

      // From: Costing suite - CETAF 53
      // Costing: FIFO; Inventory: Several splits; Modifications: None
      Initialize;

      FIFOItem(Item);

      LibraryPatterns.GRPHSeveralSplitApplicationWithCosts(Item,SalesLine,TempItemJournalLine,FIFOCost1,FIFOCost2,FIFOCost3);

      // Execute
      Adjust(Item);

      // Validate
      GetEntries(Item,ItemLedgerEntry,ValueEntry);

      ValidateValueEntry_Inbound(TempItemJournalLine,ItemLedgerEntry,ValueEntry,ACTUALCOST);
      ValidateValueEntry_Inbound(TempItemJournalLine,ItemLedgerEntry,ValueEntry,ACTUALCOST);
      ValidateValueEntry_Inbound(TempItemJournalLine,ItemLedgerEntry,ValueEntry,ACTUALCOST);

      TempItemJournalLine.FINDFIRST;
      ValidateValueEntry_Outbound(ItemLedgerEntry,ValueEntry,FIFOCost1,TempItemJournalLine."Unit Amount",ACTUALCOST);
      ValidateValueEntry_Outbound(ItemLedgerEntry,ValueEntry,FIFOCost2,TempItemJournalLine."Unit Amount",ACTUALCOST);
      ValidateValueEntry_Outbound(ItemLedgerEntry,ValueEntry,FIFOCost3,TempItemJournalLine."Unit Amount",EXPECTEDCOST);

      LibraryCosting.CheckAdjustment(Item);
Member of Lib.Library - Patterns


GRPHSimpleApplication@66 Method

The procedure GRPHSimpleApplication is available in codeunit 132212.

Syntax

GRPHSimpleApplication@66(
    Item@1000 : Record 27 Item, //Input parameter of type Record
    VAR SalesLine@1002 : Record 37 SalesLine, //Reference parameter of type Record
    VAR TempItemJournalLine@1001 : TEMPORARY Record 83 TempItemJournalLine //Reference Temporary parameter of type Record
);

Parameters

Item
Input parameter of type Record
SalesLine
Reference parameter of type Record
TempItemJournalLine
Reference Temporary parameter of type Record

Remarks

The relevant search keywords are: GRPH, Simple, Application.

For a clarification about how this function works, refer to the code listed below.

      QtyIn := RandDec(10,20,2);
      MAKEInbound(Item,QtyIn,WORKDATE,TempItemJournalLine);
      SHIPSales(SalesLine,Item,RandDec(0,QtyIn,2),WORKDATE + 1);

Example

The below example is extracted from the test automation codeunit 137602 to show one way of using this function.

      // From: Costing suite - CETAF 54
      // Costing: Standard; Inventory: Simple application; Modifications: None
      Initialize;
      StandardItem(Item);
      LibraryPatterns.GRPHSimpleApplication(Item,SalesLine,TempItemJournalLine);
      Invoice(SalesLine);

      // Execute
      Adjust(Item);

      // Validate
      LibraryCosting.CheckAdjustment(Item);
Member of Lib.Library - Patterns


GRPHSplitApplication@51 Method

The procedure GRPHSplitApplication is available in codeunit 132212.

Syntax

GRPHSplitApplication@51(
    Item@1004 : Record 27 Item, //Input parameter of type Record
    SalesLine@1006 : Record 37 SalesLine, //Input parameter of type Record
    SalesLineSplit@1007 : Record 37 SalesLineSplit //Input parameter of type Record
);

Parameters

Item
Input parameter of type Record
SalesLine
Input parameter of type Record
SalesLineSplit
Input parameter of type Record

Remarks

The relevant search keywords are: GRPH, Split, Application.

For a clarification about how this function works, refer to the code listed below.

      QtyPurch1 := RandDec(10,20,2);
      QtyPurch2 := RandDec(10,20,2);
      QtySales1 := RandDec(0,QtyPurch1,2);
      QtySales2 := RandDec(QtyPurch1 - QtySales1,QtyPurch1 - QtySales1 + QtyPurch2,2);

      MAKEInbound(Item,QtyPurch1,WORKDATE,TempItemJournalLine);
      MAKEInbound(Item,QtyPurch2,WORKDATE,TempItemJournalLine);

      SHIPSales(SalesLine,Item,QtySales1,WORKDATE);
      SHIPSales(SalesLineSplit,Item,QtySales2,WORKDATE + 1);

Example

There are no examples available.
Member of Lib.Library - Patterns


GRPHSplitJoinApplication@65 Method

The procedure GRPHSplitJoinApplication is available in codeunit 132212.

Syntax

GRPHSplitJoinApplication@65(
    Item@1002 : Record 27 Item, //Input parameter of type Record
    VAR SalesLine@1001 : Record 37 SalesLine, //Reference parameter of type Record
    VAR SalesLineReturn@1004 : Record 37 SalesLineReturn, //Reference parameter of type Record
    VAR TempItemJournalLine@1003 : TEMPORARY Record 83 TempItemJournalLine //Reference Temporary parameter of type Record
);

Parameters

Item
Input parameter of type Record
SalesLine
Reference parameter of type Record
SalesLineReturn
Reference parameter of type Record
TempItemJournalLine
Reference Temporary parameter of type Record

Remarks

The relevant search keywords are: GRPH, Split, Join, Application.

For a clarification about how this function works, refer to the code listed below.

      Qty := RandDec(10,20,2);

      MAKEInbound(Item,Qty,WORKDATE,TempItemJournalLine);

      SHIPSales(SalesLine,Item,Qty / 2,WORKDATE);
      POSTSalesLine(SalesLine,TRUE,TRUE);

      RECEIVESalesReturn(SalesLineReturn,SalesLine,WORKDATE);
      SHIPSales(SalesLine,Item,Qty,WORKDATE);

Example

The below example is extracted from the test automation codeunit 137602 to show one way of using this function.

      // From: Costing suite - CETAF 55
      // Costing: Standard; Inventory: Sales Return Split/Join application; Modifications: Sales Item Charge
      Initialize;
      StandardItem(Item);
      LibraryPatterns.GRPHSplitJoinApplication(Item,SalesLine,SalesLineReturn,TempItemJournalLine);

      // Execute: Assign Sales Item Charge
      GetSalesHeader(SalesLine,SalesHeader);
      LibrarySales.ReopenSalesDocument(SalesHeader);
      AssignItemChargeReturn(SalesHeader,SalesLineReturn);

      Invoice(SalesLineReturn);
      Invoice(SalesLine); // Also posts item charge
      Adjust(Item);

      // Validate
      LibraryCosting.CheckAdjustment(Item);
Member of Lib.Library - Patterns


InsertTempILEFromLast@28 Method

The procedure InsertTempILEFromLast is available in codeunit 132212.

Syntax

InsertTempILEFromLast@28(
    VAR TempItemLedgerEntry@1001 : TEMPORARY Record 32 TempItemLedgerEntry //Reference Temporary parameter of type Record
);

Parameters

TempItemLedgerEntry
Reference Temporary parameter of type Record

Remarks

The relevant search keywords are: Insert, Temp, ILE, From, Last.

For a clarification about how this function works, refer to the code listed below.

      ItemLedgerEntry.FINDLAST;
      TempItemLedgerEntry := ItemLedgerEntry;
      TempItemLedgerEntry.INSERT;

Example

The below example is extracted from the test automation codeunit 137603 to show one way of using this function.

      // Test to reproduce Bug245517 in TFS
      Initialize;

      // Setup Item.
      LibraryPatterns.MAKEItem(Item,Item."Costing Method"::Average,0,0,0,'');
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location);

      Day1 := WORKDATE;
      Qty := LibraryRandom.RandIntInRange(2,10);
      // Post positive adjustment for item.
      LibraryPatterns.POSTPositiveAdjustment(Item,Location.Code,'','',Qty,Day1,LibraryRandom.RandDec(100,2));
      LibraryPatterns.InsertTempILEFromLast(TempItemLedgerEntry);

      // Adjust.
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');

      // Revalue.
      LibraryPatterns.CalculateInventoryValueRun(
        ItemJournalBatch,Item,Day1,CalculatePer::Item,FALSE,FALSE,FALSE,CalculationBase::" ",FALSE,'','');
      LibraryPatterns.ModifyPostRevaluation(ItemJournalBatch,LibraryRandom.RandDecInRange(1,3,2));

      // Post positive adjustment at different location.
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location);
      LibraryPatterns.POSTPositiveAdjustment(Item,Location.Code,'','',Qty,Day1,0);
      LibraryPatterns.InsertTempILEFromLast(TempItemLedgerEntry);

      // Adjust.
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');

      // Revalue to a lesser unit cost.
      LibraryPatterns.CalculateInventoryValueRun(
        ItemJournalBatch,Item,Day1,CalculatePer::Item,FALSE,FALSE,FALSE,CalculationBase::" ",FALSE,'','');
      LibraryPatterns.ModifyPostRevaluation(ItemJournalBatch,LibraryRandom.RandDecInRange(0,1,2));

      // Adjust.
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');

      // Verify.
      LibraryCosting.CheckAdjustment(Item);
      Item.GET(Item."No.");
      REPEAT
        ItemLedgerEntry.GET(TempItemLedgerEntry."Entry No.");
        ItemLedgerEntry.CALCFIELDS("Cost Amount (Actual)");
        Assert.AreEqual(
          ROUND(TempItemLedgerEntry.Quantity * Item."Unit Cost",LibraryERM.GetAmountRoundingPrecision),
          ItemLedgerEntry."Cost Amount (Actual)",'Wrong revalued cost amount in entry ' + FORMAT(ItemLedgerEntry."Entry No."));
      UNTIL TempItemLedgerEntry.NEXT = 0;
Member of Lib.Library - Patterns


MAKEAdditionalItemUOM@91 Method

The procedure MAKEAdditionalItemUOM is available in codeunit 132212.

Syntax

MAKEAdditionalItemUOM@91(
    VAR NewItemUOM@1000 : Record 5404 NewItemUOM, //Reference parameter of type Record
    ItemNo@1001 : Code[20] ItemNo, //Input parameter of type Code
    QtyPer@1002 : Decimal QtyPer //Input parameter of type Decimal
);

Parameters

NewItemUOM
Reference parameter of type Record
ItemNo
Input parameter of type Code
QtyPer
Input parameter of type Decimal

Remarks

The relevant search keywords are: MAKE, Additional, Item, UOM.

For a clarification about how this function works, refer to the code listed below.

      LibraryInventory.CreateItemUnitOfMeasureCode(NewItemUOM,ItemNo,QtyPer);

Example

The below example is extracted from the test automation codeunit 137262 to show one way of using this function.

      Item.GET(
        CreateTrackedItem(
          LibraryUtility.GetGlobalNoSeriesCode,LibraryUtility.GetGlobalNoSeriesCode,CreateItemTrackingCode(SNTracking,LotNoTracking)));
      LibraryPatterns.MAKEAdditionalItemUOM(ItemUnitOfMeasure,Item."No.",QtyPerUOM);
Member of Lib.Library - Patterns


MAKEConsumptionJournalLine@448 Method

The procedure MAKEConsumptionJournalLine is available in codeunit 132212.

Syntax

MAKEConsumptionJournalLine@448(
    VAR ItemJournalBatch@1000 : Record 233 ItemJournalBatch, //Reference parameter of type Record
    ProdOrderLine@1001 : Record 5406 ProdOrderLine, //Input parameter of type Record
    ComponentItem@1002 : Record 27 ComponentItem, //Input parameter of type Record
    PostingDate@1003 : Date PostingDate, //Input parameter of type Date
    LocationCode@1004 : Code[10] LocationCode, //Input parameter of type Code
    VariantCode@1005 : Code[10] VariantCode, //Input parameter of type Code
    Qty@1006 : Decimal Qty, //Input parameter of type Decimal
    UnitCost@1007 : Decimal UnitCost //Input parameter of type Decimal
);

Parameters

ItemJournalBatch
Reference parameter of type Record
ProdOrderLine
Input parameter of type Record
ComponentItem
Input parameter of type Record
PostingDate
Input parameter of type Date
LocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code
Qty
Input parameter of type Decimal
UnitCost
Input parameter of type Decimal

Remarks

The relevant search keywords are: MAKE, Consumption, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      LibraryInventory.CreateItemJournalBatchByType(ItemJournalBatch,ItemJournalBatch."Template Type"::Consumption);
      MAKEItemJournalLine(
        ItemJournalLine,ItemJournalBatch,ComponentItem,LocationCode,VariantCode,PostingDate,
        ItemJournalLine."Entry Type"::"Negative Adjmt.",Qty,0);
      ItemJournalLine.VALIDATE("Entry Type",ItemJournalLine."Entry Type"::Consumption);
      ItemJournalLine.VALIDATE("Order Type",ItemJournalLine."Order Type"::Production);
      ItemJournalLine.VALIDATE("Order No.",ProdOrderLine."Prod. Order No.");
      ItemJournalLine.VALIDATE("Order Line No.",ProdOrderLine."Line No.");
      IF ItemJournalLine."Location Code" <> LocationCode THEN // required for CH
        ItemJournalLine.VALIDATE("Location Code",LocationCode);
      ItemJournalLine.VALIDATE("Unit Cost",UnitCost);
      ItemJournalLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137069 to show one way of using this function.

      LibraryPatterns.MAKEConsumptionJournalLine(
        ConsumptionItemJournalBatch,ProdOrderLine,Item,PostingDate,LocationCode,'',Qty,LibraryRandom.RandDec(1000,2));
      UpdateBinCodeOnItemJournalLine(ConsumptionItemJournalTemplate.Name,ConsumptionItemJournalBatch.Name,BinCode);
Member of Lib.Library - Patterns


MAKEItem@1 Method

The procedure MAKEItem is available in codeunit 132212.

Syntax

MAKEItem@1(
    VAR Item@1000 : Record 27 Item, //Reference parameter of type Record
    CostingMethod@1001 : Option CostingMethod, //Input parameter of type Option
    UnitCost@1002 : Decimal UnitCost, //Input parameter of type Decimal
    OverheadRate@1003 : Decimal OverheadRate, //Input parameter of type Decimal
    IndirectCostPercent@1004 : Decimal IndirectCostPercent, //Input parameter of type Decimal
    ItemTrackingCode@1005 : Code[10] ItemTrackingCode //Input parameter of type Code
);

Parameters

Item
Reference parameter of type Record
CostingMethod
Input parameter of type Option
UnitCost
Input parameter of type Decimal
OverheadRate
Input parameter of type Decimal
IndirectCostPercent
Input parameter of type Decimal
ItemTrackingCode
Input parameter of type Code

Remarks

The relevant search keywords are: MAKE, Item.

For a clarification about how this function works, refer to the code listed below.

      LibraryInventory.CreateItem(Item);
      Item."Costing Method" := CostingMethod;
      IF Item."Costing Method" = Item."Costing Method"::Standard THEN
        Item."Standard Cost" := UnitCost;
      Item."Unit Cost" := UnitCost;
      Item."Overhead Rate" := OverheadRate;
      Item."Indirect Cost %" := IndirectCostPercent;
      Item."Item Tracking Code" := ItemTrackingCode;
      Item.Description := Item."No.";
      Item.MODIFY;

Example

The below example is extracted from the test automation codeunit 137601 to show one way of using this function.

      Initialize;

      // Setup Item and SKU.
      LibraryPatterns.MAKEItem(Item,CostingMethod,0,0,0,'');
      IF MakeSKU THEN
        LibraryPatterns.MAKEStockkeepingUnit(StockkeepingUnit,Item);

      // Inventory Flow.
      LibraryPatterns.GRPH1Outbound1PurchRcvd(
        TempItemLedgerEntry,PurchaseLine,Item,StockkeepingUnit."Location Code",StockkeepingUnit."Variant Code");

      // Extract the Purchase Receipt No. from the ILEs.
      TempItemLedgerEntry.SETRANGE(Positive,TRUE);
      TempItemLedgerEntry.FINDFIRST;
      PurchRcptLine.GET(TempItemLedgerEntry."Document No.",TempItemLedgerEntry."Document Line No.");

      // Cost modification.
      PurchaseHeader.GET(PurchaseLine."Document Type",PurchaseLine."Document No.");
      LibraryPatterns.ASSIGNPurchChargeToPurchRcptLine(
        PurchaseHeader,PurchRcptLine,LibraryRandom.RandInt(10),LibraryRandom.RandDec(100,5));
      LibraryPatterns.ASSIGNPurchChargeToPurchaseLine(
        PurchaseHeader,PurchaseLine,LibraryRandom.RandInt(10),LibraryRandom.RandDec(100,5));
      PurchaseHeader.VALIDATE("Vendor Invoice No.",LibraryUtility.GenerateGUID);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

      // Exercise.
      PurchaseHeader.GET(PurchaseHeader."Document Type"::Order,PurchRcptLine."Order No.");
      PurchaseHeader.VALIDATE("Vendor Invoice No.",LibraryUtility.GenerateGUID);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,FALSE,TRUE);
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');

      // Verify.
      LibraryCosting.CheckAdjustment(Item);
Member of Lib.Library - Patterns


MAKEItemChargePurchaseLine@18 Method

The procedure MAKEItemChargePurchaseLine is available in codeunit 132212.

Syntax

MAKEItemChargePurchaseLine@18(
    VAR PurchaseLine@1000 : Record 39 PurchaseLine, //Reference parameter of type Record
    VAR ItemCharge@1005 : Record 5800 ItemCharge, //Reference parameter of type Record
    PurchaseHeader@1004 : Record 38 PurchaseHeader, //Input parameter of type Record
    Qty@1001 : Decimal Qty, //Input parameter of type Decimal
    DirectUnitCost@1002 : Decimal DirectUnitCost //Input parameter of type Decimal
);

Parameters

PurchaseLine
Reference parameter of type Record
ItemCharge
Reference parameter of type Record
PurchaseHeader
Input parameter of type Record
Qty
Input parameter of type Decimal
DirectUnitCost
Input parameter of type Decimal

Remarks

The relevant search keywords are: MAKE, Item, Charge, Purchase, Line.

For a clarification about how this function works, refer to the code listed below.

      LibraryInventory.CreateItemCharge(ItemCharge);
      LibraryPurchase.CreatePurchaseLine(PurchaseLine,PurchaseHeader,PurchaseLine.Type::"Charge (Item)",ItemCharge."No.",Qty);
      PurchaseLine.VALIDATE("Direct Unit Cost",DirectUnitCost);
      PurchaseLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137609 to show one way of using this function.

      Initialize;
      IF CONFIRM('') THEN; // workaround for ES.

      // Setup: purchase invoice with and without variant.
      Day1 := WORKDATE;
      Qty := LibraryRandom.RandIntInRange(3,100);
      LibraryPatterns.MAKEItemSimple(Item,CostingMethod,LibraryRandom.RandDec(100,2));
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(ToLocation);
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(InTransitLocation);
      InTransitLocation."Use As In-Transit" := TRUE;
      InTransitLocation.MODIFY;
      LibraryPatterns.MAKEStockkeepingUnit(StockkeepingUnit,Item);

      LibraryPatterns.MAKEPurchaseDoc(PurchaseHeader1,PurchaseLine,PurchDocType,Item,StockkeepingUnit."Location Code",
        StockkeepingUnit."Variant Code",2 * Qty,Day1,LibraryRandom.RandDec(100,2));
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader1,TRUE,Invoice);
      LibraryPatterns.MAKEPurchaseDoc(PurchaseHeader2,PurchaseLine,PurchDocType,Item,StockkeepingUnit."Location Code",
        '',2 * Qty,Day1,LibraryRandom.RandDec(100,2));
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader2,TRUE,Invoice);

      // Assign charge to purchase and invoice if necessary.
      Vendor.GET(PurchaseHeader1."Buy-from Vendor No.");
      LibraryPurchase.CreatePurchHeader(PurchaseHeader,PurchaseHeader."Document Type"::Order,Vendor."No.");
      PurchaseHeader.VALIDATE("Posting Date",Day1);
      PurchaseHeader.MODIFY(TRUE);

      CASE PurchDocType OF
        PurchaseHeader."Document Type"::Invoice:
          BEGIN
            PurchInvLine.SETRANGE(Type,PurchaseLine.Type);
            PurchInvLine.SETRANGE("No.",Item."No.");
            PurchInvLine.FINDFIRST;

            LibraryPatterns.ASSIGNPurchChargeToPurchInvoiceLine(PurchaseHeader,PurchInvLine,Qty,
              LibraryRandom.RandDec(100,2));
          END;
        PurchaseHeader."Document Type"::Order:
          BEGIN
            PurchRcptLine.SETRANGE("Order No.",PurchaseHeader1."No.");
            PurchRcptLine.FINDFIRST;

            LibraryPatterns.ASSIGNPurchChargeToPurchRcptLine(PurchaseHeader,PurchRcptLine,Qty,
              LibraryRandom.RandDec(100,2));
            LibraryPurchase.PostPurchaseDocument(PurchaseHeader1,TRUE,TRUE);
            LibraryPurchase.PostPurchaseDocument(PurchaseHeader2,TRUE,TRUE);
          END;
      END;

      LibraryPatterns.MAKEItemChargePurchaseLine(PurchaseLine,ItemCharge,PurchaseHeader,Qty,
        LibraryRandom.RandDec(100,2));
      PurchaseLine."Qty. to Invoice" := 0;
      PurchaseLine.MODIFY;
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

      // Sales credit memo with and without variant.
      LibraryPatterns.MAKESalesDoc(SalesHeader1,SalesLine,SalesDocType,Item,StockkeepingUnit."Location Code",
        StockkeepingUnit."Variant Code",Qty,Day1 + 5,LibraryRandom.RandDec(100,2));
      LibrarySales.PostSalesDocument(SalesHeader1,TRUE,Invoice);
      LibraryPatterns.MAKESalesDoc(SalesHeader2,SalesLine,SalesDocType,Item,StockkeepingUnit."Location Code",
        '',Qty,Day1 + 5,LibraryRandom.RandDec(100,2));
      LibrarySales.PostSalesDocument(SalesHeader2,TRUE,Invoice);

      // Revalue inventory.
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');
      LibraryPatterns.MAKERevaluationJournalLine(ItemJournalBatch,Item,Day1 + 2,
        CalculatePer::Item,FALSE,FALSE,TRUE,CalculationBase::" ");
      ItemJournalLine.SETRANGE("Journal Template Name",ItemJournalBatch."Journal Template Name");
      ItemJournalLine.SETRANGE("Journal Batch Name",ItemJournalBatch.Name);
      ItemJournalLine.FINDFIRST;
      ItemJournalLine.VALIDATE("Inventory Value (Revalued)",
        ItemJournalLine."Inventory Value (Calculated)" + LibraryRandom.RandDec(100,2));
      LibraryInventory.PostItemJournalBatch(ItemJournalBatch);

      // Sales invoice with and without variant.
      LibraryPatterns.MAKESalesInvoice(SalesHeader,SalesLine,Item,StockkeepingUnit."Location Code",
        StockkeepingUnit."Variant Code",Qty,Day1 + 10,LibraryRandom.RandDec(100,2));
      LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      LibraryPatterns.MAKESalesInvoice(SalesHeader,SalesLine,Item,StockkeepingUnit."Location Code",
        '',Qty,Day1 + 10,LibraryRandom.RandDec(100,2));
      LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      // Purchase credit memo with and without variant.
      LibraryPatterns.MAKEPurchaseDoc(PurchaseHeader1,PurchaseLine,PurchReturnDocType,Item,
        StockkeepingUnit."Location Code",StockkeepingUnit."Variant Code",Qty,Day1 + 11,
        LibraryRandom.RandDec(100,2));
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader1,TRUE,Invoice);

      LibraryPatterns.MAKEPurchaseDoc(PurchaseHeader2,PurchaseLine,PurchReturnDocType,Item,
        StockkeepingUnit."Location Code",'',Qty,Day1 + 11,LibraryRandom.RandDec(100,2));
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader2,TRUE,Invoice);

      IF NOT Invoice THEN BEGIN
        LibraryPurchase.PostPurchaseDocument(PurchaseHeader1,TRUE,TRUE);
        LibraryPurchase.PostPurchaseDocument(PurchaseHeader2,TRUE,TRUE);
        SalesHeader1.GET(SalesHeader1."Document Type",SalesHeader1."No.");
        LibrarySales.PostSalesDocument(SalesHeader1,TRUE,TRUE);
        SalesHeader2.GET(SalesHeader2."Document Type",SalesHeader2."No.");
        LibrarySales.PostSalesDocument(SalesHeader2,TRUE,TRUE);
      END;

      // Exercise.
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');

      // Verify.
      LibraryCosting.CheckAdjustment(Item);
Member of Lib.Library - Patterns


MAKEItemChargeSalesLine@23 Method

The procedure MAKEItemChargeSalesLine is available in codeunit 132212.

Syntax

MAKEItemChargeSalesLine@23(
    VAR SalesLine@1004 : Record 37 SalesLine, //Reference parameter of type Record
    VAR ItemCharge@1003 : Record 5800 ItemCharge, //Reference parameter of type Record
    SalesHeader@1002 : Record 36 SalesHeader, //Input parameter of type Record
    Qty@1001 : Decimal Qty, //Input parameter of type Decimal
    UnitCost@1000 : Decimal UnitCost //Input parameter of type Decimal
);

Parameters

SalesLine
Reference parameter of type Record
ItemCharge
Reference parameter of type Record
SalesHeader
Input parameter of type Record
Qty
Input parameter of type Decimal
UnitCost
Input parameter of type Decimal

Remarks

The relevant search keywords are: MAKE, Item, Charge, Sales, Line.

For a clarification about how this function works, refer to the code listed below.

      LibraryInventory.CreateItemCharge(ItemCharge);
      LibrarySales.CreateSalesLine(SalesLine,SalesHeader,SalesLine.Type::"Charge (Item)",ItemCharge."No.",Qty);
      SalesLine.VALIDATE("Unit Price",UnitCost);
      SalesLine.VALIDATE("Unit Cost",UnitCost);
      SalesLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137609 to show one way of using this function.

      Initialize;

      // Setup. Ship 2 orders.
      Day1 := WORKDATE;
      Qty := LibraryRandom.RandIntInRange(3,100);
      QtyPer := LibraryRandom.RandIntInRange(3,10);
      LibraryPatterns.MAKEItemSimple(Item,CostingMethod,LibraryRandom.RandDec(100,2));
      LibraryPatterns.MAKEAdditionalItemUOM(ItemUnitOfMeasure,Item."No.",LibraryRandom.RandIntInRange(2,10));

      LibraryPatterns.POSTPositiveAdjustment(Item,'','','',2 * Qty * QtyPer,Day1,LibraryRandom.RandDec(100,2));

      LibraryPatterns.POSTSalesOrderPartially(SalesHeader1,Item,'','',Qty * QtyPer,Day1 + 1,0,TRUE,
        Qty * (QtyPer - ShipDelta),Invoice,Qty * (QtyPer - InvoiceDelta));
      LibraryPatterns.InsertTempILEFromLast(TempItemLedgerEntry);
      SalesShptLine1.GET(TempItemLedgerEntry."Document No.",TempItemLedgerEntry."Document Line No.");

      LibraryPatterns.MAKESalesOrder(SalesHeader2,SalesLine,Item,'','',Qty,Day1 + 2,LibraryRandom.RandDec(100,2));
      SalesLine.VALIDATE("Qty. to Ship",Qty - ShipDelta);
      SalesLine.VALIDATE("Qty. to Invoice",Qty - InvoiceDelta);
      SalesLine."Unit of Measure Code" := ItemUnitOfMeasure.Code;
      SalesLine.MODIFY;
      LibrarySales.PostSalesDocument(SalesHeader2,TRUE,Invoice);

      LibraryPatterns.InsertTempILEFromLast(TempItemLedgerEntry);
      SalesShptLine2.GET(TempItemLedgerEntry."Document No.",TempItemLedgerEntry."Document Line No.");

      // Assign charges to the 2 shipment lines.
      Customer.GET(SalesHeader1."Sell-to Customer No.");
      LibrarySales.CreateSalesHeader(SalesHeader,SalesHeader."Document Type"::Invoice,Customer."No.");
      SalesHeader.VALIDATE("Posting Date",Day1 + 4);
      SalesHeader.MODIFY(TRUE);

      IF SplitChargeLine THEN BEGIN
        LibraryPatterns.MAKEItemChargeSalesLine(SalesLine,ItemCharge,SalesHeader,2 * Qty,LibraryRandom.RandDec(100,2));
        LibrarySales.CreateItemChargeAssignment(ItemChargeAssignmentSales,SalesLine,ItemCharge,
          ItemChargeAssignmentSales."Applies-to Doc. Type"::Shipment,
          SalesShptLine1."Document No.",SalesShptLine1."Line No.",
          SalesShptLine1."No.",Qty,LibraryRandom.RandDec(100,2));
        ItemChargeAssignmentSales.INSERT;

        LibrarySales.CreateItemChargeAssignment(ItemChargeAssignmentSales,SalesLine,ItemCharge,
          ItemChargeAssignmentSales."Applies-to Doc. Type"::Shipment,
          SalesShptLine2."Document No.",SalesShptLine2."Line No.",
          SalesShptLine2."No.",Qty,LibraryRandom.RandDec(100,2));
        ItemChargeAssignmentSales.INSERT;
      END ELSE BEGIN
        LibraryPatterns.ASSIGNSalesChargeToSalesShptLine(SalesHeader,SalesShptLine1,Qty,LibraryRandom.RandDec(100,2));
        LibraryPatterns.ASSIGNSalesChargeToSalesShptLine(SalesHeader,SalesShptLine2,Qty,LibraryRandom.RandDec(100,2));
      END;

      LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      // Exercise.
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');

      // Verify.
      LibraryCosting.CheckAdjustment(Item);
Member of Lib.Library - Patterns


MAKEItemJournalLine@25 Method

The procedure MAKEItemJournalLine is available in codeunit 132212.

Syntax

MAKEItemJournalLine@25(
    VAR ItemJournalLine@1000 : Record 83 ItemJournalLine, //Reference parameter of type Record
    ItemJournalBatch@1001 : Record 233 ItemJournalBatch, //Input parameter of type Record
    Item@1002 : Record 27 Item, //Input parameter of type Record
    LocationCode@1003 : Code[10] LocationCode, //Input parameter of type Code
    VariantCode@1004 : Code[10] VariantCode, //Input parameter of type Code
    PostingDate@1005 : Date PostingDate, //Input parameter of type Date
    EntryType@1007 : Option EntryType, //Input parameter of type Option
    Qty@1008 : Decimal Qty, //Input parameter of type Decimal
    UnitAmount@1006 : Decimal UnitAmount //Input parameter of type Decimal
);

Parameters

ItemJournalLine
Reference parameter of type Record
ItemJournalBatch
Input parameter of type Record
Item
Input parameter of type Record
LocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code
PostingDate
Input parameter of type Date
EntryType
Input parameter of type Option
Qty
Input parameter of type Decimal
UnitAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: MAKE, Item, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      LibraryInventory.MakeItemJournalLine(ItemJournalLine,ItemJournalBatch,Item,PostingDate,EntryType,Qty);
      ItemJournalLine."Location Code" := LocationCode;
      ItemJournalLine."Variant Code" := VariantCode;
      ItemJournalLine.VALIDATE("Unit Amount",UnitAmount);
      ItemJournalLine.INSERT;

Example

The below example is extracted from the test automation codeunit 137405 to show one way of using this function.

      LotCount := ARRAYLEN(LotQty);

      FOR iLot := 1 TO LotCount DO BEGIN
        LotNo[iLot] := LibraryUtility.GenerateGUID;
        LotQty[iLot] := LibraryRandom.RandInt(10);
        TempQty += LotQty[iLot]; // LotQty[3] > SUM(LotQty[1 .. LotQty - 1])
      END;
      LotQty[LotCount] := TempQty;

      // QtyPurchase > QtySale > SUM(LotQty[1 .. LotQty - 1])
      QtySale := LotQty[LotCount];
      QtyPurchase := LotQty[1] + LotQty[2] + LotQty[3];

      LibraryInventory.CreateItemJournalBatchByType(ItemJournalBatch,ItemJournalBatch."Template Type"::Item);
      LibraryPatterns.MAKEItemJournalLine(
        ItemJournalLine,ItemJournalBatch,Item,LocationCode,'',WORKDATE,ItemJournalLine."Entry Type"::"Positive Adjmt.",QtyPurchase,0);
      LibraryVariableStorage.Enqueue(LotCount);
      FOR iLot := 1 TO LotCount DO BEGIN
        LibraryVariableStorage.Enqueue(LotNo[iLot]);
        LibraryVariableStorage.Enqueue(LotQty[iLot]);
      END;

      ItemJournalLine.OpenItemTrackingLines(FALSE);
      LibraryInventory.PostItemJournalLine(ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name);
Member of Lib.Library - Patterns


MAKEItemJournalLineWithApplication@87 Method

The procedure MAKEItemJournalLineWithApplication is available in codeunit 132212.

Syntax

MAKEItemJournalLineWithApplication@87(
    VAR ItemJournalLine@1000 : Record 83 ItemJournalLine, //Reference parameter of type Record
    ItemJournalBatch@1001 : Record 233 ItemJournalBatch, //Input parameter of type Record
    Item@1002 : Record 27 Item, //Input parameter of type Record
    LocationCode@1003 : Code[10] LocationCode, //Input parameter of type Code
    VariantCode@1004 : Code[10] VariantCode, //Input parameter of type Code
    PostingDate@1005 : Date PostingDate, //Input parameter of type Date
    EntryType@1007 : Option EntryType, //Input parameter of type Option
    Qty@1008 : Decimal Qty, //Input parameter of type Decimal
    UnitAmount@1006 : Decimal UnitAmount, //Input parameter of type Decimal
    AppltoEntryNo@1009 : Integer AppltoEntryNo //Input parameter of type Integer
);

Parameters

ItemJournalLine
Reference parameter of type Record
ItemJournalBatch
Input parameter of type Record
Item
Input parameter of type Record
LocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code
PostingDate
Input parameter of type Date
EntryType
Input parameter of type Option
Qty
Input parameter of type Decimal
UnitAmount
Input parameter of type Decimal
AppltoEntryNo
Input parameter of type Integer

Remarks

The relevant search keywords are: MAKE, Item, Journal, Line, Application.

For a clarification about how this function works, refer to the code listed below.

      LibraryInventory.MakeItemJournalLine(ItemJournalLine,ItemJournalBatch,Item,PostingDate,EntryType,Qty);
      ItemJournalLine."Location Code" := LocationCode;
      ItemJournalLine."Variant Code" := VariantCode;
      ItemJournalLine.VALIDATE("Unit Amount",UnitAmount);
      ItemJournalLine.VALIDATE("Applies-to Entry",AppltoEntryNo);
      ItemJournalLine.INSERT;

Example

The below example is extracted from the test automation codeunit 137608 to show one way of using this function.

      Initialize;
      Day1 := WORKDATE;
      IF CONFIRM('') THEN; // ES workaround.

      // Setup the item.
      LibraryPatterns.MAKEItem(Item,CostingMethod,0,0,0,'');

      // Post purchase, sales, sales cr. memo.
      Qty := 3 + LibraryRandom.RandInt(20);
      LibraryPatterns.MAKEPurchaseInvoice(PurchaseHeader,PurchaseLine,Item,'','',Qty - 3,Day1,LibraryRandom.RandDec(100,2));
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

      LibraryPatterns.MAKESalesInvoice(SalesHeader,SalesLine,Item,'','',Qty - 3,Day1 + 5,LibraryRandom.RandDec(100,2));
      LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);
      LibraryPatterns.InsertTempILEFromLast(TempItemLedgerEntry);

      LibraryPatterns.MAKESalesCreditMemo(SalesHeader,SalesLine,Item,'','',Qty - 3,Day1 + 5,0,0);
      SalesLine.VALIDATE("Appl.-from Item Entry",TempItemLedgerEntry."Entry No.");
      SalesLine.MODIFY;

      LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);
      LibraryPatterns.InsertTempILEFromLast(TempItemLedgerEntry);
      TempItemLedgerEntry.FINDLAST;

      // Adjust.
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');

      // Post revaluation.
      LibraryInventory.CreateItemJournalBatchByType(ItemJournalBatch,ItemJournalBatch."Template Type"::Revaluation);
      LibraryPatterns.MAKEItemJournalLineWithApplication(ItemJournalLine,ItemJournalBatch,Item,'','',Day1 + 2,
        ItemJournalLine."Entry Type"::"Positive Adjmt.",Qty - 3,0,TempItemLedgerEntry."Entry No.");
      ItemJournalLine.VALIDATE("Inventory Value (Revalued)",
        ItemJournalLine."Inventory Value (Calculated)" + LibraryRandom.RandDec(10,2));
      ItemJournalLine.MODIFY;
      LibraryInventory.PostItemJournalBatch(ItemJournalBatch);

      // Adjust.
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');

      // Verify.
      LibraryCosting.CheckAdjustment(Item);
Member of Lib.Library - Patterns


MAKEItemReclassificationJournalLine@86 Method

The procedure MAKEItemReclassificationJournalLine is available in codeunit 132212.

Syntax

MAKEItemReclassificationJournalLine@86(
    VAR ItemJournalLine@1000 : Record 83 ItemJournalLine, //Reference parameter of type Record
    ItemJournalBatch@1001 : Record 233 ItemJournalBatch, //Input parameter of type Record
    Item@1002 : Record 27 Item, //Input parameter of type Record
    VariantCode@1004 : Code[10] VariantCode, //Input parameter of type Code
    LocationCode@1003 : Code[10] LocationCode, //Input parameter of type Code
    NewLocationCode@1005 : Code[10] NewLocationCode, //Input parameter of type Code
    BinCode@1006 : Code[20] BinCode, //Input parameter of type Code
    NewBinCode@1009 : Code[20] NewBinCode, //Input parameter of type Code
    PostingDate@1007 : Date PostingDate, //Input parameter of type Date
    Quantity@1008 : Decimal Quantity //Input parameter of type Decimal
);

Parameters

ItemJournalLine
Reference parameter of type Record
ItemJournalBatch
Input parameter of type Record
Item
Input parameter of type Record
VariantCode
Input parameter of type Code
LocationCode
Input parameter of type Code
NewLocationCode
Input parameter of type Code
BinCode
Input parameter of type Code
NewBinCode
Input parameter of type Code
PostingDate
Input parameter of type Date
Quantity
Input parameter of type Decimal

Remarks

The relevant search keywords are: MAKE, Item, Reclassification, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      LibraryInventory.MakeItemJournalLine(
        ItemJournalLine,ItemJournalBatch,Item,PostingDate,ItemJournalLine."Entry Type"::Transfer,Quantity);
      ItemJournalLine."Location Code" := LocationCode;
      ItemJournalLine."Variant Code" := VariantCode;
      ItemJournalLine."New Location Code" := NewLocationCode;
      ItemJournalLine."Bin Code" := BinCode;
      ItemJournalLine."New Bin Code" := NewBinCode;
      ItemJournalLine.INSERT;

Example

The below example is extracted from the test automation codeunit 137603 to show one way of using this function.

      LibraryInventory.CreateItemJournalBatchByType(ItemJnlBatch,ItemJnlBatch."Template Type"::Item);

      Qty1 := LibraryRandom.RandDecInDecimalRange(100,200,2);
      Qty2 := LibraryRandom.RandDecInDecimalRange(10,Qty1,2);

      Cost1 := LibraryRandom.RandDecInDecimalRange(100,200,2);

      LibraryPatterns.MAKEItemJournalLine(
        ItemJnlLine,ItemJnlBatch,Item,'','',StartDate,ItemJnlLine."Entry Type"::"Positive Adjmt.",Qty1,Cost1);
      LibraryInventory.PostItemJournalBatch(ItemJnlBatch);

      ItemLedgerEntry.SETCURRENTKEY("Item No.");
      ItemLedgerEntry.SETRANGE("Item No.",Item."No.");
      ItemLedgerEntry.FINDFIRST;

      LibraryInventory.CreateItemJournalBatchByType(ItemJnlBatchTransfer,ItemJnlBatch."Template Type"::Transfer);

      LibraryPatterns.MAKEItemReclassificationJournalLine(ItemJnlLine,ItemJnlBatchTransfer,Item,'','',LocationCode,
        '','',StartDate + 2,Qty2);
      ItemJnlLine.VALIDATE("Applies-to Entry",ItemLedgerEntry."Entry No.");
      ItemJnlLine.MODIFY;

      LibraryInventory.PostItemJournalBatch(ItemJnlBatchTransfer);

      LibraryPatterns.POSTReclassificationJournalLine(Item,StartDate + 3,LocationCode,'','','','',Qty2);

      ItemLedgerEntry.FINDSET;

      REPEAT
        TempItemLedgerEntry := ItemLedgerEntry;
        TempItemLedgerEntry.INSERT;
      UNTIL ItemLedgerEntry.NEXT = 0;
Member of Lib.Library - Patterns


MAKEItemSimple@50 Method

The procedure MAKEItemSimple is available in codeunit 132212.

Syntax

MAKEItemSimple@50(
    VAR Item@1000 : Record 27 Item, //Reference parameter of type Record
    CostingMethod@1001 : Option CostingMethod, //Input parameter of type Option
    UnitCost@1002 : Decimal UnitCost //Input parameter of type Decimal
);

Parameters

Item
Reference parameter of type Record
CostingMethod
Input parameter of type Option
UnitCost
Input parameter of type Decimal

Remarks

The relevant search keywords are: MAKE, Item, Simple.

For a clarification about how this function works, refer to the code listed below.

      MAKEItem(Item,CostingMethod,UnitCost,0,0,'');

Example

The below example is extracted from the test automation codeunit 137009 to show one way of using this function.

      // [SCENARIO 361672] "Reserved Receipt" in Item Availability by Event is equal to Purchase Line qty. when sales order is reserved against purch. order
      Initialize;
      LibraryWarehouse.CreateLocation(Location);
      LibraryPatterns.MAKEItemSimple(Item,Item."Costing Method"::Standard,LibraryPatterns.RandCost(Item));

      // [GIVEN] Purchase order for item "X", quantity = "Q"
      LibraryPatterns.MAKEPurchaseOrder(
        PurchaseHeader,PurchaseLine,Item,Location.Code,'',LibraryRandom.RandInt(100),WORKDATE,Item."Unit Cost");
      LibraryPurchase.ReleasePurchaseDocument(PurchaseHeader);

      // [GIVEN] Sales order with reservation against purchase order, reserved quantity = "Q"
      LibraryPatterns.MAKESalesOrder(SalesHeader,SalesLine,Item,Location.Code,'',PurchaseLine.Quantity,WORKDATE,Item."Unit Price");

      SalesLine.VALIDATE("Shipment Date",PurchaseLine."Expected Receipt Date");
      SalesLine.MODIFY(TRUE);
      AutoReserveSalesLine(SalesLine);

      // [WHEN] Item availability by event is calculated
      CalculateAvailabilityByEvent(TempInvtPageData,Item);

      // [THEN] "Reserved Receipt" = "Q"
      FindInvtPageData(TempInvtPageData,TempInvtPageData.Type::Purchase);
      Assert.AreEqual(PurchaseLine.Quantity,TempInvtPageData."Reserved Receipt",WrongReservedQtyErr);
Member of Lib.Library - Patterns


MAKEItemWithExtendedText@92 Method

The procedure MAKEItemWithExtendedText is available in codeunit 132212.

Syntax

MAKEItemWithExtendedText@92(
    VAR Item@1000 : Record 27 Item, //Reference parameter of type Record
    ExtText@1004 : Text ExtText, //Input parameter of type Text
    CostingMethod@1002 : Option CostingMethod, //Input parameter of type Option
    UnitCost@1001 : Decimal UnitCost //Input parameter of type Decimal
);

Parameters

Item
Reference parameter of type Record
ExtText
Input parameter of type Text
CostingMethod
Input parameter of type Option
UnitCost
Input parameter of type Decimal

Remarks

The relevant search keywords are: MAKE, Item, Extended, Text.

For a clarification about how this function works, refer to the code listed below.

      // Create Item.
      MAKEItem(Item,CostingMethod,UnitCost,0,0,'');
      Item.VALIDATE("Automatic Ext. Texts",TRUE);
      Item.MODIFY;

      // Create Extended Text Header and Line.
      LibraryService.CreateExtendedTextHeaderItem(ExtendedTextHeader,Item."No.");
      ExtendedTextHeader.VALIDATE("All Language Codes",TRUE);
      ExtendedTextHeader.MODIFY;
      LibraryService.CreateExtendedTextLineItem(ExtendedTextLine,ExtendedTextHeader);
      ExtendedTextLine.VALIDATE(Text,COPYSTR(ExtText,1,MAXSTRLEN(ExtendedTextLine.Text)));
      ExtendedTextLine.MODIFY;

Example

The below example is extracted from the test automation codeunit 137158 to show one way of using this function.

      LibraryPatterns.MAKEItemWithExtendedText(CompItem,ExtendedTxt,CompItem."Costing Method"::FIFO,0);
      LibraryAssembly.CreateItem(CompItem2,CompItem2."Costing Method",CompItem."Replenishment System"::Purchase,'','');
      CreateAssemblyItemWithAsseblyBOM(AssemblyItem,CompItem."No.",LibraryRandom.RandDec(10,2));
      LibraryAssembly.CreateAssemblyListComponent(
        BOMComponent.Type::Item,CompItem2."No.",AssemblyItem."No.",'',
        BOMComponent."Resource Usage Type",LibraryRandom.RandDec(10,2),TRUE);
      EXIT(AssemblyItem."No.");
Member of Lib.Library - Patterns


MAKEOutputJournalLine@553 Method

The procedure MAKEOutputJournalLine is available in codeunit 132212.

Syntax

MAKEOutputJournalLine@553(
    VAR ItemJournalBatch@1000 : Record 233 ItemJournalBatch, //Reference parameter of type Record
    ProdOrderLine@1001 : Record 5406 ProdOrderLine, //Input parameter of type Record
    PostingDate@1003 : Date PostingDate, //Input parameter of type Date
    Qty@1006 : Decimal Qty, //Input parameter of type Decimal
    UnitCost@1007 : Decimal UnitCost //Input parameter of type Decimal
);

Parameters

ItemJournalBatch
Reference parameter of type Record
ProdOrderLine
Input parameter of type Record
PostingDate
Input parameter of type Date
Qty
Input parameter of type Decimal
UnitCost
Input parameter of type Decimal

Remarks

The relevant search keywords are: MAKE, Output, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      LibraryInventory.CreateItemJournalBatchByType(ItemJournalBatch,ItemJournalBatch."Template Type"::Output);
      Item.GET(ProdOrderLine."Item No.");
      MAKEItemJournalLine(
        ItemJournalLine,ItemJournalBatch,Item,ProdOrderLine."Location Code",ProdOrderLine."Variant Code",PostingDate,
        ItemJournalLine."Entry Type"::"Positive Adjmt.",0,0);
      ItemJournalLine.VALIDATE("Entry Type",ItemJournalLine."Entry Type"::Output);
      ItemJournalLine.VALIDATE("Order Type",ItemJournalLine."Order Type"::Production);
      ItemJournalLine.VALIDATE("Order No.",ProdOrderLine."Prod. Order No.");
      ItemJournalLine.VALIDATE("Order Line No.",ProdOrderLine."Line No.");
      ItemJournalLine.VALIDATE("Item No.",ProdOrderLine."Item No.");
      RoutingLine.SETRANGE("Routing No.",ProdOrderLine."Routing No.");
      IF RoutingLine.FINDFIRST THEN
        ItemJournalLine.VALIDATE("Operation No.",RoutingLine."Operation No.");
      ItemJournalLine.VALIDATE("Output Quantity",Qty);
      ItemJournalLine.VALIDATE("Unit Cost",UnitCost);
      ItemJournalLine.MODIFY;

Example

The below example is extracted from the test automation codeunit 137069 to show one way of using this function.

      LibraryPatterns.MAKEOutputJournalLine(ItemJournalBatch,ProdOrderLine,ProdOrderLine."Due Date",ProdOrderLine.Quantity,300);
      FindItemJournalLine(ItemJournalLine,ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name);

      WITH ItemJournalLine DO BEGIN
        VALIDATE("Item No.");
        VALIDATE("Setup Time",NewSetupTime);
        MODIFY(TRUE);
      END;
Member of Lib.Library - Patterns


MAKEProductionBOM@555 Method

The procedure MAKEProductionBOM is available in codeunit 132212.

Syntax

MAKEProductionBOM@555(
    VAR ProductionBOMHeader@1000 : Record 99000771 ProductionBOMHeader, //Reference parameter of type Record
    VAR ParentItem@1001 : Record 27 ParentItem, //Reference parameter of type Record
    ChildItem@1002 : Record 27 ChildItem, //Input parameter of type Record
    ChildItemQtyPer@1003 : Decimal ChildItemQtyPer, //Input parameter of type Decimal
    RoutingLinkCode@1004 : Code[10] RoutingLinkCode //Input parameter of type Code
);

Parameters

ProductionBOMHeader
Reference parameter of type Record
ParentItem
Reference parameter of type Record
ChildItem
Input parameter of type Record
ChildItemQtyPer
Input parameter of type Decimal
RoutingLinkCode
Input parameter of type Code

Remarks

The relevant search keywords are: MAKE, Production, BOM.

For a clarification about how this function works, refer to the code listed below.

      LibraryManufacturing.CreateProductionBOMHeader(ProductionBOMHeader,ParentItem."Base Unit of Measure");
      LibraryManufacturing.CreateProductionBOMLine(
        ProductionBOMHeader,ProductionBOMLine,'',ProductionBOMLine.Type::Item,ChildItem."No.",ChildItemQtyPer);
      ProductionBOMLine.VALIDATE("Routing Link Code",RoutingLinkCode);
      ProductionBOMLine.MODIFY;

      ProductionBOMHeader.VALIDATE(Status,ProductionBOMHeader.Status::Certified);
      ProductionBOMHeader.MODIFY;

      ParentItem.VALIDATE("Production BOM No.",ProductionBOMHeader."No.");
      ParentItem.MODIFY;

Example

The below example is extracted from the test automation codeunit 137067 to show one way of using this function.

      LibraryPatterns.MAKEProductionBOM(ProdBOMHeader,ProdItem,CompItem,1,'');
      LibraryPatterns.MAKEProductionOrder(ProdOrder,ProdOrder.Status::Released,ProdItem,'','',Qty,WORKDATE);
Member of Lib.Library - Patterns


MAKEProductionOrder@24 Method

The procedure MAKEProductionOrder is available in codeunit 132212.

Syntax

MAKEProductionOrder@24(
    VAR ProductionOrder@1000 : Record 5405 ProductionOrder, //Reference parameter of type Record
    ProdOrderStatus@1001 : Option ProdOrderStatus, //Input parameter of type Option
    Item@1002 : Record 27 Item, //Input parameter of type Record
    LocationCode@1003 : Code[10] LocationCode, //Input parameter of type Code
    VariantCode@1007 : Code[10] VariantCode, //Input parameter of type Code
    Qty@1005 : Decimal Qty, //Input parameter of type Decimal
    DueDate@1006 : Date DueDate //Input parameter of type Date
);

Parameters

ProductionOrder
Reference parameter of type Record
ProdOrderStatus
Input parameter of type Option
Item
Input parameter of type Record
LocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code
Qty
Input parameter of type Decimal
DueDate
Input parameter of type Date

Remarks

The relevant search keywords are: MAKE, Production, Order.

For a clarification about how this function works, refer to the code listed below.

      ProdNoSeries := LibraryUtility.GetGlobalNoSeriesCode;
      ManufacturingSetup.GET;
      CASE ProdOrderStatus OF
        ProductionOrder.Status::Simulated:
          IF ManufacturingSetup."Simulated Order Nos." <> ProdNoSeries THEN BEGIN
            ManufacturingSetup."Simulated Order Nos." := ProdNoSeries;
            ManufacturingSetup.MODIFY;
          END;
        ProductionOrder.Status::Planned:
          IF ManufacturingSetup."Planned Order Nos." <> ProdNoSeries THEN BEGIN
            ManufacturingSetup."Planned Order Nos." := ProdNoSeries;
            ManufacturingSetup.MODIFY;
          END;
        ProductionOrder.Status::"Firm Planned":
          IF ManufacturingSetup."Firm Planned Order Nos." <> ProdNoSeries THEN BEGIN
            ManufacturingSetup."Firm Planned Order Nos." := ProdNoSeries;
            ManufacturingSetup.MODIFY;
          END;
        ProductionOrder.Status::Released:
          IF ManufacturingSetup."Released Order Nos." <> ProdNoSeries THEN BEGIN
            ManufacturingSetup."Released Order Nos." := ProdNoSeries;
            ManufacturingSetup.MODIFY;
          END;
      END;

      CLEAR(ProductionOrder);
      ProductionOrder."No." := NoSeriesManagement.GetNextNo(ProdNoSeries,0D,TRUE);
      ProductionOrder.Status := ProdOrderStatus;
      ProductionOrder.VALIDATE("Source Type",ProductionOrder."Source Type"::Item);
      ProductionOrder.VALIDATE("Source No.",Item."No.");
      ProductionOrder.VALIDATE(Quantity,Qty);
      ProductionOrder.VALIDATE("Location Code",LocationCode);
      ProductionOrder.VALIDATE("Due Date",DueDate);
      ProductionOrder.INSERT(TRUE);
      LibraryManufacturing.RefreshProdOrder(ProductionOrder,FALSE,TRUE,TRUE,TRUE,TRUE);
      ProdOrderLine.SETRANGE(Status,ProductionOrder.Status);
      ProdOrderLine.SETRANGE("Prod. Order No.",ProductionOrder."No.");
      ProdOrderLine.MODIFYALL("Variant Code",VariantCode);

Example

The below example is extracted from the test automation codeunit 137067 to show one way of using this function.

      LibraryPatterns.MAKEProductionBOM(ProdBOMHeader,ProdItem,CompItem,1,'');
      LibraryPatterns.MAKEProductionOrder(ProdOrder,ProdOrder.Status::Released,ProdItem,'','',Qty,WORKDATE);
Member of Lib.Library - Patterns


MAKEPurchaseBlanketOrder@101 Method

The procedure MAKEPurchaseBlanketOrder is available in codeunit 132212.

Syntax

MAKEPurchaseBlanketOrder@101(
    VAR PurchaseHeader@1006 : Record 38 PurchaseHeader, //Reference parameter of type Record
    VAR PurchaseLine@1009 : Record 39 PurchaseLine, //Reference parameter of type Record
    Item@1005 : Record 27 Item, //Input parameter of type Record
    LocationCode@1004 : Code[10] LocationCode, //Input parameter of type Code
    VariantCode@1003 : Code[10] VariantCode, //Input parameter of type Code
    Qty@1002 : Decimal Qty, //Input parameter of type Decimal
    PostingDate@1001 : Date PostingDate, //Input parameter of type Date
    DirectUnitCost@1000 : Decimal DirectUnitCost //Input parameter of type Decimal
);

Parameters

PurchaseHeader
Reference parameter of type Record
PurchaseLine
Reference parameter of type Record
Item
Input parameter of type Record
LocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code
Qty
Input parameter of type Decimal
PostingDate
Input parameter of type Date
DirectUnitCost
Input parameter of type Decimal

Remarks

The relevant search keywords are: MAKE, Purchase, Blanket, Order.

For a clarification about how this function works, refer to the code listed below.

      MAKEPurchaseDoc(
        PurchaseHeader,PurchaseLine,PurchaseHeader."Document Type"::"Blanket Order",
        Item,LocationCode,VariantCode,Qty,PostingDate,DirectUnitCost);

Example

The below example is extracted from the test automation codeunit 137410 to show one way of using this function.

      // Setup
      Initialize;
      Quantity := LibraryRandom.RandIntInRange(1,10);
      LibraryPatterns.MAKEItemWithExtendedText(Item,ExtendedTxt,Item."Costing Method"::FIFO,0);
      LibraryPatterns.MAKEPurchaseBlanketOrder(PurchaseHeader,PurchaseLine,
        Item,'','',Quantity,WORKDATE,LibraryRandom.RandIntInRange(1,10));
      IF TransferExtendedText.PurchCheckIfAnyExtText(PurchaseLine,FALSE) THEN
        TransferExtendedText.InsertPurchExtText(PurchaseLine);

      // Exercise: Create Sales Order form Purchase Blanket Order.
      CODEUNIT.RUN(CODEUNIT::"Blnkt Purch Ord. to Ord. (Y/N)",PurchaseHeader);

      // Verify
      VerifyPurchOrder(PurchaseLine."No.",ExtendedTxt);
Member of Lib.Library - Patterns


MAKEPurchaseCreditMemo@98 Method

The procedure MAKEPurchaseCreditMemo is available in codeunit 132212.

Syntax

MAKEPurchaseCreditMemo@98(
    VAR PurchaseHeader@1006 : Record 38 PurchaseHeader, //Reference parameter of type Record
    VAR PurchaseLine@1009 : Record 39 PurchaseLine, //Reference parameter of type Record
    Item@1005 : Record 27 Item, //Input parameter of type Record
    LocationCode@1004 : Code[10] LocationCode, //Input parameter of type Code
    VariantCode@1003 : Code[10] VariantCode, //Input parameter of type Code
    Qty@1002 : Decimal Qty, //Input parameter of type Decimal
    PostingDate@1001 : Date PostingDate, //Input parameter of type Date
    DirectUnitCost@1000 : Decimal DirectUnitCost //Input parameter of type Decimal
);

Parameters

PurchaseHeader
Reference parameter of type Record
PurchaseLine
Reference parameter of type Record
Item
Input parameter of type Record
LocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code
Qty
Input parameter of type Decimal
PostingDate
Input parameter of type Date
DirectUnitCost
Input parameter of type Decimal

Remarks

The relevant search keywords are: MAKE, Purchase, Credit, Memo.

For a clarification about how this function works, refer to the code listed below.

      MAKEPurchaseDoc(PurchaseHeader,PurchaseLine,PurchaseHeader."Document Type"::"Credit Memo",
        Item,LocationCode,VariantCode,Qty,PostingDate,DirectUnitCost);

Example

There are no examples available.
Member of Lib.Library - Patterns


MAKEPurchaseDoc@27 Method

The procedure MAKEPurchaseDoc is available in codeunit 132212.

Syntax

MAKEPurchaseDoc@27(
    VAR PurchaseHeader@1006 : Record 38 PurchaseHeader, //Reference parameter of type Record
    VAR PurchaseLine@1009 : Record 39 PurchaseLine, //Reference parameter of type Record
    DocType@1007 : Option DocType, //Input parameter of type Option
    Item@1005 : Record 27 Item, //Input parameter of type Record
    LocationCode@1004 : Code[10] LocationCode, //Input parameter of type Code
    VariantCode@1003 : Code[10] VariantCode, //Input parameter of type Code
    Qty@1002 : Decimal Qty, //Input parameter of type Decimal
    PostingDate@1001 : Date PostingDate, //Input parameter of type Date
    DirectUnitCost@1000 : Decimal DirectUnitCost //Input parameter of type Decimal
);

Parameters

PurchaseHeader
Reference parameter of type Record
PurchaseLine
Reference parameter of type Record
DocType
Input parameter of type Option
Item
Input parameter of type Record
LocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code
Qty
Input parameter of type Decimal
PostingDate
Input parameter of type Date
DirectUnitCost
Input parameter of type Decimal

Remarks

The relevant search keywords are: MAKE, Purchase, Document.

For a clarification about how this function works, refer to the code listed below.

      LibraryPurchase.CreatePurchHeader(PurchaseHeader,DocType,'');
      PurchaseHeader.VALIDATE("Posting Date",PostingDate);
      PurchaseHeader.MODIFY(TRUE);
      LibraryPurchase.CreatePurchaseLine(PurchaseLine,PurchaseHeader,PurchaseLine.Type::Item,Item."No.",Qty);
      PurchaseLine."Location Code" := LocationCode;
      PurchaseLine."Variant Code" := VariantCode;
      PurchaseLine.VALIDATE("Direct Unit Cost",DirectUnitCost);
      PurchaseLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137609 to show one way of using this function.

      Initialize;

      // Setup: purchase invoice/order with and without variant.
      Day1 := WORKDATE;
      Qty := LibraryRandom.RandIntInRange(3,100);
      LibraryPatterns.MAKEItemSimple(Item,CostingMethod,LibraryRandom.RandDec(100,2));
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(ToLocation);
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(InTransitLocation);
      InTransitLocation."Use As In-Transit" := TRUE;
      InTransitLocation.MODIFY;
      LibraryPatterns.MAKEStockkeepingUnit(StockkeepingUnit,Item);

      LibraryPatterns.MAKEPurchaseDoc(PurchaseHeader,PurchaseLine,PurchDocType,Item,
        StockkeepingUnit."Location Code",StockkeepingUnit."Variant Code",2 * Qty,Day1,LibraryRandom.RandDec(100,2));
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

      LibraryPatterns.MAKEPurchaseDoc(PurchaseHeader,PurchaseLine,PurchDocType,Item,
        StockkeepingUnit."Location Code",'',2 * Qty,Day1,LibraryRandom.RandDec(100,2));
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

      // Transfer with and without variant.
      FromLocation.GET(StockkeepingUnit."Location Code");
      LibraryPatterns.POSTTransferOrder(TransferHeader,Item,FromLocation,
        ToLocation,InTransitLocation,StockkeepingUnit."Variant Code",Qty,Day1 + 4,Day1 + 4,TRUE,TRUE);
      LibraryPatterns.POSTTransferOrder(TransferHeader,Item,FromLocation,
        ToLocation,InTransitLocation,'',Qty,Day1 + 4,Day1 + 4,TRUE,TRUE);

      // Sell with and without variant.
      LibraryPatterns.MAKESalesInvoice(SalesHeader,SalesLine,Item,FromLocation.Code,StockkeepingUnit."Variant Code",Qty,Day1 + 5,
        LibraryRandom.RandDec(100,2));
      LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      LibraryPatterns.MAKESalesInvoice(SalesHeader,SalesLine,Item,FromLocation.Code,'',Qty,Day1 + 5,
        LibraryRandom.RandDec(100,2));
      LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      // Exercise.
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');

      // Verify.
      LibraryCosting.CheckAdjustment(Item);
Member of Lib.Library - Patterns


MAKEPurchaseInvoice@45 Method

The procedure MAKEPurchaseInvoice is available in codeunit 132212.

Syntax

MAKEPurchaseInvoice@45(
    VAR PurchaseHeader@1006 : Record 38 PurchaseHeader, //Reference parameter of type Record
    VAR PurchaseLine@1009 : Record 39 PurchaseLine, //Reference parameter of type Record
    Item@1005 : Record 27 Item, //Input parameter of type Record
    LocationCode@1004 : Code[10] LocationCode, //Input parameter of type Code
    VariantCode@1003 : Code[10] VariantCode, //Input parameter of type Code
    Qty@1002 : Decimal Qty, //Input parameter of type Decimal
    PostingDate@1001 : Date PostingDate, //Input parameter of type Date
    DirectUnitCost@1000 : Decimal DirectUnitCost //Input parameter of type Decimal
);

Parameters

PurchaseHeader
Reference parameter of type Record
PurchaseLine
Reference parameter of type Record
Item
Input parameter of type Record
LocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code
Qty
Input parameter of type Decimal
PostingDate
Input parameter of type Date
DirectUnitCost
Input parameter of type Decimal

Remarks

The relevant search keywords are: MAKE, Purchase, Invoice.

For a clarification about how this function works, refer to the code listed below.

      MAKEPurchaseDoc(
        PurchaseHeader,PurchaseLine,PurchaseHeader."Document Type"::Invoice,Item,LocationCode,VariantCode,Qty,PostingDate,
        DirectUnitCost);

Example

The below example is extracted from the test automation codeunit 137601 to show one way of using this function.

      // Setup Item and SKU.
      Initialize;
      LibraryPatterns.MAKEItem(Item,CostingMethod,0,0,0,'');
      IF MakeSKU THEN
        LibraryPatterns.MAKEStockkeepingUnit(StockkeepingUnit,Item);

      // Inventory Flow.
      LibraryPatterns.MAKEPurchaseInvoice(
        PurchaseHeader,PurchaseLine,Item,StockkeepingUnit."Location Code",StockkeepingUnit."Variant Code",
        LibraryRandom.RandInt(10),WORKDATE,LibraryRandom.RandDec(100,5));
      LibraryPatterns.MAKEPurchaseReturnOrder(
        PurchaseHeader1,PurchaseLine1,Item,StockkeepingUnit."Location Code",StockkeepingUnit."Variant Code",PurchaseLine.Quantity,
        WORKDATE + 1,LibraryRandom.RandDec(100,5));

      // Cost modification.
      // for Purchase.
      PurchaseHeader.GET(PurchaseLine."Document Type",PurchaseLine."Document No.");
      LibraryPatterns.ASSIGNPurchChargeToPurchaseLine(
        PurchaseHeader,PurchaseLine,LibraryRandom.RandInt(10),LibraryRandom.RandDec(100,5));
      PurchaseHeader.VALIDATE("Vendor Invoice No.",LibraryUtility.GenerateGUID);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);
      // for Purchase Return.
      PurchaseHeader1.GET(PurchaseLine1."Document Type",PurchaseLine1."Document No.");
      LibraryPatterns.ASSIGNPurchChargeToPurchReturnLine(
        PurchaseHeader1,PurchaseLine1,LibraryRandom.RandInt(10),LibraryRandom.RandDec(100,5));

      // Exercise.
      PurchaseHeader1.VALIDATE("Vendor Cr. Memo No.",LibraryUtility.GenerateGUID);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader1,TRUE,TRUE);
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');

      // Verify.
      LibraryCosting.CheckAdjustment(Item);
Member of Lib.Library - Patterns


MAKEPurchaseOrder@11 Method

The procedure MAKEPurchaseOrder is available in codeunit 132212.

Syntax

MAKEPurchaseOrder@11(
    VAR PurchaseHeader@1006 : Record 38 PurchaseHeader, //Reference parameter of type Record
    VAR PurchaseLine@1009 : Record 39 PurchaseLine, //Reference parameter of type Record
    Item@1005 : Record 27 Item, //Input parameter of type Record
    LocationCode@1004 : Code[10] LocationCode, //Input parameter of type Code
    VariantCode@1003 : Code[10] VariantCode, //Input parameter of type Code
    Qty@1002 : Decimal Qty, //Input parameter of type Decimal
    PostingDate@1001 : Date PostingDate, //Input parameter of type Date
    DirectUnitCost@1000 : Decimal DirectUnitCost //Input parameter of type Decimal
);

Parameters

PurchaseHeader
Reference parameter of type Record
PurchaseLine
Reference parameter of type Record
Item
Input parameter of type Record
LocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code
Qty
Input parameter of type Decimal
PostingDate
Input parameter of type Date
DirectUnitCost
Input parameter of type Decimal

Remarks

The relevant search keywords are: MAKE, Purchase, Order.

For a clarification about how this function works, refer to the code listed below.

      MAKEPurchaseDoc(
        PurchaseHeader,PurchaseLine,PurchaseHeader."Document Type"::Order,Item,LocationCode,VariantCode,Qty,PostingDate,
        DirectUnitCost);

Example

The below example is extracted from the test automation codeunit 137009 to show one way of using this function.

      // [SCENARIO 361672] "Reserved Receipt" in Item Availability by Event is equal to Purchase Line qty. when sales order is reserved against purch. order
      Initialize;
      LibraryWarehouse.CreateLocation(Location);
      LibraryPatterns.MAKEItemSimple(Item,Item."Costing Method"::Standard,LibraryPatterns.RandCost(Item));

      // [GIVEN] Purchase order for item "X", quantity = "Q"
      LibraryPatterns.MAKEPurchaseOrder(
        PurchaseHeader,PurchaseLine,Item,Location.Code,'',LibraryRandom.RandInt(100),WORKDATE,Item."Unit Cost");
      LibraryPurchase.ReleasePurchaseDocument(PurchaseHeader);

      // [GIVEN] Sales order with reservation against purchase order, reserved quantity = "Q"
      LibraryPatterns.MAKESalesOrder(SalesHeader,SalesLine,Item,Location.Code,'',PurchaseLine.Quantity,WORKDATE,Item."Unit Price");

      SalesLine.VALIDATE("Shipment Date",PurchaseLine."Expected Receipt Date");
      SalesLine.MODIFY(TRUE);
      AutoReserveSalesLine(SalesLine);

      // [WHEN] Item availability by event is calculated
      CalculateAvailabilityByEvent(TempInvtPageData,Item);

      // [THEN] "Reserved Receipt" = "Q"
      FindInvtPageData(TempInvtPageData,TempInvtPageData.Type::Purchase);
      Assert.AreEqual(PurchaseLine.Quantity,TempInvtPageData."Reserved Receipt",WrongReservedQtyErr);
Member of Lib.Library - Patterns


MAKEPurchaseQuote@100 Method

The procedure MAKEPurchaseQuote is available in codeunit 132212.

Syntax

MAKEPurchaseQuote@100(
    VAR PurchaseHeader@1006 : Record 38 PurchaseHeader, //Reference parameter of type Record
    VAR PurchaseLine@1009 : Record 39 PurchaseLine, //Reference parameter of type Record
    Item@1005 : Record 27 Item, //Input parameter of type Record
    LocationCode@1004 : Code[10] LocationCode, //Input parameter of type Code
    VariantCode@1003 : Code[10] VariantCode, //Input parameter of type Code
    Qty@1002 : Decimal Qty, //Input parameter of type Decimal
    PostingDate@1001 : Date PostingDate, //Input parameter of type Date
    DirectUnitCost@1000 : Decimal DirectUnitCost //Input parameter of type Decimal
);

Parameters

PurchaseHeader
Reference parameter of type Record
PurchaseLine
Reference parameter of type Record
Item
Input parameter of type Record
LocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code
Qty
Input parameter of type Decimal
PostingDate
Input parameter of type Date
DirectUnitCost
Input parameter of type Decimal

Remarks

The relevant search keywords are: MAKE, Purchase, Quote.

For a clarification about how this function works, refer to the code listed below.

      MAKEPurchaseDoc(
        PurchaseHeader,PurchaseLine,PurchaseHeader."Document Type"::Quote,
        Item,LocationCode,VariantCode,Qty,PostingDate,DirectUnitCost);

Example

The below example is extracted from the test automation codeunit 137410 to show one way of using this function.

      // Setup
      Initialize;
      Quantity := LibraryRandom.RandIntInRange(1,10);
      LibraryPatterns.MAKEItemWithExtendedText(Item,ExtendedTxt,Item."Costing Method"::FIFO,0);
      LibraryPatterns.MAKEPurchaseQuote(PurchaseHeader,PurchaseLine,
        Item,'','',Quantity,WORKDATE,LibraryRandom.RandIntInRange(1,10));
      IF TransferExtendedText.PurchCheckIfAnyExtText(PurchaseLine,FALSE) THEN
        TransferExtendedText.InsertPurchExtText(PurchaseLine);

      // Exercise: Create Sales Order form Purchase Quote.
      CODEUNIT.RUN(CODEUNIT::"Purch.-Quote to Order (Yes/No)",PurchaseHeader);

      // Verify
      VerifyPurchOrder(PurchaseLine."No.",ExtendedTxt);
Member of Lib.Library - Patterns


MAKEPurchaseReturnOrder@21 Method

The procedure MAKEPurchaseReturnOrder is available in codeunit 132212.

Syntax

MAKEPurchaseReturnOrder@21(
    VAR PurchaseHeader@1006 : Record 38 PurchaseHeader, //Reference parameter of type Record
    VAR PurchaseLine@1009 : Record 39 PurchaseLine, //Reference parameter of type Record
    Item@1005 : Record 27 Item, //Input parameter of type Record
    LocationCode@1004 : Code[10] LocationCode, //Input parameter of type Code
    VariantCode@1003 : Code[10] VariantCode, //Input parameter of type Code
    Qty@1002 : Decimal Qty, //Input parameter of type Decimal
    PostingDate@1001 : Date PostingDate, //Input parameter of type Date
    DirectUnitCost@1000 : Decimal DirectUnitCost //Input parameter of type Decimal
);

Parameters

PurchaseHeader
Reference parameter of type Record
PurchaseLine
Reference parameter of type Record
Item
Input parameter of type Record
LocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code
Qty
Input parameter of type Decimal
PostingDate
Input parameter of type Date
DirectUnitCost
Input parameter of type Decimal

Remarks

The relevant search keywords are: MAKE, Purchase, Return, Order.

For a clarification about how this function works, refer to the code listed below.

      MAKEPurchaseDoc(
        PurchaseHeader,PurchaseLine,PurchaseHeader."Document Type"::"Return Order",Item,LocationCode,VariantCode,Qty,PostingDate,
        DirectUnitCost);

Example

The below example is extracted from the test automation codeunit 137009 to show one way of using this function.

      // [SCENARIO 361672] "Reserved Requirement" in Item Availability by Event is equal to negative Purchase Return qty. when return is reserved against inventory
      Initialize;
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location);
      LibraryPatterns.MAKEItemSimple(Item,Item."Costing Method"::Standard,LibraryPatterns.RandCost(Item));

      // [GIVEN] "Q" units of item "X" on inventory
      Quantity := LibraryRandom.RandInt(100);
      LibraryPatterns.POSTPositiveAdjustment(Item,Location.Code,'','',Quantity,WORKDATE,Item."Unit Cost");

      // [GIVEN] Purchase return order with "Q" units of item "X" reserved on inventory
      LibraryPatterns.MAKEPurchaseReturnOrder(PurchaseHeader,PurchaseLine,Item,Location.Code,'',Quantity,WORKDATE,Item."Unit Cost");
      AutoReservePurchaseLine(PurchaseLine);

      // [WHEN] Item availability by event is calculated
      CalculateAvailabilityByEvent(TempInvtPageData,Item);

      // [THEN] "Reserved Requirement" = -"Q"
      FindInvtPageData(TempInvtPageData,TempInvtPageData.Type::"Purch. Return");
      Assert.AreEqual(-PurchaseLine.Quantity,TempInvtPageData."Reserved Requirement",WrongReservedQtyErr);
Member of Lib.Library - Patterns


MAKERevaluationJournalLine@79 Method

The procedure MAKERevaluationJournalLine is available in codeunit 132212.

Syntax

MAKERevaluationJournalLine@79(
    VAR ItemJournalBatch@1000 : Record 233 ItemJournalBatch, //Reference parameter of type Record
    VAR Item@1001 : Record 27 Item, //Reference parameter of type Record
    NewPostingDate@1002 : Date NewPostingDate, //Input parameter of type Date
    NewCalculatePer@1004 : Option NewCalculatePer, //Input parameter of type Option
    NewByLocation@1005 : Boolean NewByLocation, //Input parameter of type Boolean
    NewByVariant@1006 : Boolean NewByVariant, //Input parameter of type Boolean
    NewUpdStdCost@1007 : Boolean NewUpdStdCost, //Input parameter of type Boolean
    NewCalcBase@1008 : Option NewCalcBase //Input parameter of type Option
);

Parameters

ItemJournalBatch
Reference parameter of type Record
Item
Reference parameter of type Record
NewPostingDate
Input parameter of type Date
NewCalculatePer
Input parameter of type Option
NewByLocation
Input parameter of type Boolean
NewByVariant
Input parameter of type Boolean
NewUpdStdCost
Input parameter of type Boolean
NewCalcBase
Input parameter of type Option

Remarks

The relevant search keywords are: MAKE, Revaluation, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      NewDocNo := LibraryUtility.GenerateRandomCode(ItemJournalLine.FIELDNO("Document No."),DATABASE::"Item Journal Line");
      RevaluationJournalCalcInventory(
        ItemJournalBatch,Item,NewPostingDate,NewDocNo,NewCalculatePer,NewByLocation,NewByVariant,NewUpdStdCost,NewCalcBase);

Example

The below example is extracted from the test automation codeunit 137603 to show one way of using this function.

      // Test to reproduce Bug265306
      Initialize;

      // Make item
      LibraryPatterns.MAKEItem(Item,Item."Costing Method"::Average,LibraryRandom.RandInt(10),0,0,'');

      Day1 := 030311D;
      Qty := LibraryRandom.RandInt(100);

      // Post item journals
      LibraryPatterns.POSTItemJournalLine(
        ItemJournalBatch."Template Type"::Item,ItemJournalLine."Entry Type"::"Positive Adjmt.",Item,'','','',Qty,Day1,
        LibraryRandom.RandInt(10));
      Item.GET(Item."No.");
      LibraryPatterns.POSTItemJournalLine(
        ItemJournalBatch."Template Type"::Item,ItemJournalLine."Entry Type"::"Negative Adjmt.",Item,'','','',Qty,Day1 + 4,
        Item."Last Direct Cost");
      LibraryPatterns.POSTItemJournalLine(
        ItemJournalBatch."Template Type"::Item,ItemJournalLine."Entry Type"::"Positive Adjmt.",Item,'','','',Qty,Day1 + 4,
        LibraryRandom.RandInt(10));
      ItemLedgerEntry.FINDLAST; // store the ILE for last posistive adjustment

      // Adjust cost
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');

      // Revaluation journal
      LibraryPatterns.MAKERevaluationJournalLine(
        ItemJournalBatch,Item,Day1 + 4,CalculatePer::Item,FALSE,FALSE,FALSE,CalculationBase::" ");
      FindFirstItemJnlLine(ItemJournalLine,ItemJournalBatch);
      ItemJournalLine.VALIDATE("Unit Cost (Revalued)",LibraryRandom.RandInt(10));
      ItemJournalLine.MODIFY;
      LibraryInventory.PostItemJournalBatch(ItemJournalBatch);

      // Post negative adjustment
      LibraryInventory.CreateItemJournalBatchByType(ItemJournalBatch,ItemJournalBatch."Template Type"::Item);
      Item.GET(Item."No.");
      LibraryPatterns.MAKEItemJournalLine(
        ItemJournalLine,ItemJournalBatch,Item,'','',Day1 + 4,ItemJournalLine."Entry Type"::"Negative Adjmt.",Qty,Item."Unit Cost");
      ItemJournalLine.VALIDATE("Applies-to Entry",ItemLedgerEntry."Entry No.");
      ItemJournalLine.MODIFY;
      LibraryInventory.PostItemJournalBatch(ItemJournalBatch);

      // Adjust cost
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');

      // Verify
      LibraryCosting.CheckAdjustment(Item);
Member of Lib.Library - Patterns


MAKERouting@83 Method

The procedure MAKERouting is available in codeunit 132212.

Syntax

MAKERouting@83(
    VAR RoutingHeader@1000 : Record 99000763 RoutingHeader, //Reference parameter of type Record
    VAR Item@1001 : Record 27 Item, //Reference parameter of type Record
    RoutingLinkCode@1002 : Code[10] RoutingLinkCode, //Input parameter of type Code
    DirectUnitCost@1003 : Decimal DirectUnitCost //Input parameter of type Decimal
);

Parameters

RoutingHeader
Reference parameter of type Record
Item
Reference parameter of type Record
RoutingLinkCode
Input parameter of type Code
DirectUnitCost
Input parameter of type Decimal

Remarks

The relevant search keywords are: MAKE, Routing.

For a clarification about how this function works, refer to the code listed below.

      LibraryManufacturing.CreateRoutingHeader(RoutingHeader,RoutingHeader.Type::Serial);

      WorkCenter.FINDFIRST;
      WorkCenter.VALIDATE("Direct Unit Cost",DirectUnitCost);
      WorkCenter.MODIFY;

      LibraryManufacturing.CreateRoutingLine(RoutingHeader,RoutingLine,'','',RoutingLine.Type::"Work Center",WorkCenter."No.");
      RoutingLine.VALIDATE("Routing Link Code",RoutingLinkCode);
      RoutingLine.VALIDATE("Run Time",1);
      RoutingLine.MODIFY;

      RoutingHeader.VALIDATE(Status,RoutingHeader.Status::Certified);
      RoutingHeader.MODIFY;

      Item.VALIDATE("Routing No.",RoutingHeader."No.");
      Item.MODIFY;

Example

The below example is extracted from the test automation codeunit 137353 to show one way of using this function.

      // Also for SICILY 46166, 48268
      Initialize;
      LibraryERM.SetAllowPostingFromTo(0D,0D);
      Qty := LibraryRandom.RandDec(100,2);
      QtyPer := LibraryRandom.RandDec(5,2);
      DirectUnitCost := LibraryRandom.RandDec(5,2);
      LibraryInventory.UpdateInventorySetup(InventorySetup,TRUE,TRUE,
        InventorySetup."Automatic Cost Adjustment",InventorySetup."Average Cost Calc. Type",InventorySetup."Average Cost Period");

      // Setup. Make BOM structure.
      SetupInventoryForReport(ParentItem,ChildItem,PurchaseHeader,ProductionOrder,ProdOrderLine,ParentItem."Costing Method"::Standard,
        ChildItem."Costing Method"::FIFO,FALSE,Qty,QtyPer,WORKDATE);
      LibraryPatterns.MAKERouting(RoutingHeader,ParentItem,'',DirectUnitCost);
      CalcStandardCost.CalcItem(ParentItem."No.",FALSE);

      // Setup. Finish production order.
      LibraryManufacturing.RefreshProdOrder(ProductionOrder,FALSE,TRUE,TRUE,TRUE,TRUE);
      LibraryPatterns.POSTConsumption(ProdOrderLine,ChildItem,'','',Qty * QtyPer,WORKDATE,ChildItem."Unit Cost");
      PostExplodedOutput(ProdOrderLine,WORKDATE,ProdOrderLine.Quantity,0);
      LibraryManufacturing.ChangeProdOrderStatus(ProductionOrder,ProductionOrder.Status::Finished,WORKDATE,TRUE);

      // Exercise. Adjust, change G/L Setup and invoice the purchase at a different cost.
      LibraryCosting.AdjustCostItemEntries(ParentItem."No." + '|' + ChildItem."No.",'');
      InvoiceDate := CALCDATE('<+2M>',WORKDATE);
      TempDate := CALCDATE('<-CM>',InvoiceDate);
      LibraryERM.SetAllowPostingFromTo(TempDate,CALCDATE('<CM>',TempDate));
      InvoiceDiffPurchaseCost(PurchaseHeader,InvoiceDate);
      LibraryCosting.AdjustCostItemEntries(ParentItem."No." + '|' + ChildItem."No.",'');

      // Exercise. Verify Inventory Valuation - WIP report for the month containing the prod. order output.
      TempDate := CALCDATE('<-CM>',WORKDATE);
      RunInventoryValuationWIPReport(ProductionOrder."No.",TempDate,CALCDATE('<CM>',TempDate));
      ASSERTERROR BEGIN
        VerifyInventoryValuationWIPReport(ProductionOrder,TempDate,CALCDATE('<CM>',TempDate),TRUE);
        Assert.KnownFailure('ValueOfOutput',48268);
      END;

      // Exercise. Verify Inventory Valuation - WIP report for the month between the prod. output and the purchase invoicing.
      TempDate := CALCDATE('<CM-1M>',WORKDATE);
      RunInventoryValuationWIPReport(ProductionOrder."No.",TempDate,CALCDATE('<CM>',TempDate));
      VerifyInventoryValuationWIPReport(ProductionOrder,TempDate,CALCDATE('<CM>',TempDate),TRUE);

      // Exercise. Verify Inventory Valuation - WIP report for the month containing the purchase invoicing.
      TempDate := CALCDATE('<-CM>',InvoiceDate);
      RunInventoryValuationWIPReport(ProductionOrder."No.",TempDate,CALCDATE('<CM>',TempDate));
      ASSERTERROR BEGIN
        VerifyInventoryValuationWIPReport(ProductionOrder,TempDate,CALCDATE('<CM>',TempDate),TRUE);
        Assert.KnownFailure('ValueOfOutput',48268);
      END;

      // Exercise. Verify Inventory Valuation - WIP report for the month after the purchase invoicing.
      TempDate := CALCDATE('<+1M>',CALCDATE('<+1M>',InvoiceDate));
      RunInventoryValuationWIPReport(ProductionOrder."No.",TempDate,CALCDATE('<CM>',TempDate));
      VerifyInventoryValuationWIPReport(ProductionOrder,TempDate,CALCDATE('<CM>',TempDate),TRUE);

      // Tear down.
      LibraryInventory.UpdateInventorySetup(InventorySetup,FALSE,FALSE,
        InventorySetup."Automatic Cost Adjustment",InventorySetup."Average Cost Calc. Type",InventorySetup."Average Cost Period");
Member of Lib.Library - Patterns


MAKERoutingforWorkCenter@88 Method

The procedure MAKERoutingforWorkCenter is available in codeunit 132212.

Syntax

MAKERoutingforWorkCenter@88(
    VAR RoutingHeader@1003 : Record 99000763 RoutingHeader, //Reference parameter of type Record
    VAR Item@1002 : Record 27 Item, //Reference parameter of type Record
    WorkCenterNo@1001 : Code[20] WorkCenterNo //Input parameter of type Code
);

Parameters

RoutingHeader
Reference parameter of type Record
Item
Reference parameter of type Record
WorkCenterNo
Input parameter of type Code

Remarks

The relevant search keywords are: MAKE, Routingfor, Work, Center.

For a clarification about how this function works, refer to the code listed below.

      LibraryManufacturing.CreateRoutingHeader(RoutingHeader,RoutingHeader.Type::Serial);

      LibraryManufacturing.CreateRoutingLine(RoutingHeader,RoutingLine,'','',RoutingLine.Type::"Work Center",WorkCenterNo);
      RoutingLine.VALIDATE("Run Time",1);
      RoutingLine.MODIFY;

      RoutingHeader.VALIDATE(Status,RoutingHeader.Status::Certified);
      RoutingHeader.MODIFY;

      Item.VALIDATE("Routing No.",RoutingHeader."No.");
      Item.MODIFY;

Example

The below example is extracted from the test automation codeunit 137612 to show one way of using this function.

      // This test automates the exact bug repro
      // Numbers have not been randomized because they introduce instability in the test

      // Create component
      CreateItemWithAdditionalUOM_FixedVal(CompItem,CompSecItemUnitOfMeasure,CompItem."Costing Method"::FIFO,0.01188,8.77193);

      // Create parent
      CreateItemWithAdditionalUOM_FixedVal(ParentItem,ParSecItemUnitOfMeasure,CompItem."Costing Method"::Standard,0,200);
      LibraryItemTracking.CreateItemTrackingCode(ItemTrackingCode,FALSE,TRUE);
      ParentItem."Replenishment System" := ParentItem."Replenishment System"::"Prod. Order";
      ParentItem.MODIFY;

      // Create Production BOM with Scrap
      CreateProductionBOM(ProductionBOMHeader,ParentItem,CompItem,ParentItem."Base Unit of Measure",'',1,10);

      // Create Work Center
      CreateWorkCenter_FixedCost(WorkCenter,0.07174,0.00381);

      // Create Routing
      LibraryPatterns.MAKERoutingforWorkCenter(RoutingHeader,ParentItem,WorkCenter."No.");

      // Standard Cost calculate
      CalculateStdCost.CalcItem(ParentItem."No.",FALSE);

      // Receive Purchase Order
      LibraryPatterns.MAKEPurchaseOrder(PurchaseHeader,PurchaseLine,CompItem,'','',2600,WORKDATE,0.47754);
      PurchaseLine.VALIDATE("Unit of Measure Code",CompSecItemUnitOfMeasure.Code);
      PurchaseLine.VALIDATE("Direct Unit Cost",0.47754);
      PurchaseLine.MODIFY(TRUE);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,FALSE);

      // Create Released Production Order
      LibraryPatterns.MAKEProductionOrder(
        ProductionOrder,ProductionOrder.Status::Released,ParentItem,'','',10000,WORKDATE);
      ProdOrderLine.SETRANGE(Status,ProductionOrder.Status);
      ProdOrderLine.SETRANGE("Prod. Order No.",ProductionOrder."No.");
      ProdOrderLine.FINDFIRST;

      // Post Output
      LibraryPatterns.POSTOutputWithItemTracking(ProdOrderLine,2400,2400,WORKDATE,ParentItem."Standard Cost",'','A');
      LibraryPatterns.POSTOutputWithItemTracking(ProdOrderLine,1200,1200,WORKDATE,ParentItem."Standard Cost",'','A');
      LibraryPatterns.POSTOutputWithItemTracking(ProdOrderLine,3600,3600,WORKDATE,ParentItem."Standard Cost",'','B');
      LibraryPatterns.POSTOutputWithItemTracking(ProdOrderLine,2600,2600,WORKDATE,ParentItem."Standard Cost",'','C');
      LibraryPatterns.POSTOutputWithItemTracking(ProdOrderLine,33,33,WORKDATE,ParentItem."Standard Cost",'','D');
      LibraryPatterns.POSTOutputWithItemTracking(ProdOrderLine,69,69,WORKDATE,ParentItem."Standard Cost",'','E');

      // Post Consumption
      LibraryPatterns.POSTConsumption(ProdOrderLine,CompItem,'','',ProductionOrder.Quantity,WORKDATE,CompItem."Unit Cost");

      // Change Prod. Order status
      LibraryManufacturing.ChangeStatusReleasedToFinished(ProductionOrder."No.");

      // Create and post sales order
      CreateAndPostSalesOrderWithItemTracking(ParentItem,ParSecItemUnitOfMeasure.Code);
      IF NOT AutoCostAdjustAlways THEN
        LibraryCosting.AdjustCostItemEntries(STRSUBSTNO('%1|%2',ParentItem."No.",CompItem."No."),'');

      // Change Cost and invoice purch. order
      PurchaseHeader.FIND('=');
      LibraryPurchase.ReopenPurchaseDocument(PurchaseHeader);
      PurchaseLine.FIND('=');
      PurchaseLine.VALIDATE("Direct Unit Cost",PurchaseLine."Direct Unit Cost" - 0.00001);
      PurchaseLine.MODIFY(TRUE);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);
      IF NOT AutoCostAdjustAlways THEN
        LibraryCosting.AdjustCostItemEntries(STRSUBSTNO('%1|%2',ParentItem."No.",CompItem."No."),'');

      LibraryCosting.CheckAdjustment(ParentItem);
      LibraryCosting.CheckAdjustment(CompItem);
Member of Lib.Library - Patterns


MAKESalesBlanketOrder@103 Method

The procedure MAKESalesBlanketOrder is available in codeunit 132212.

Syntax

MAKESalesBlanketOrder@103(
    VAR SalesHeader@1007 : Record 36 SalesHeader, //Reference parameter of type Record
    VAR SalesLine@1006 : Record 37 SalesLine, //Reference parameter of type Record
    Item@1005 : Record 27 Item, //Input parameter of type Record
    LocationCode@1004 : Code[10] LocationCode, //Input parameter of type Code
    VariantCode@1003 : Code[10] VariantCode, //Input parameter of type Code
    Qty@1002 : Decimal Qty, //Input parameter of type Decimal
    PostingDate@1001 : Date PostingDate, //Input parameter of type Date
    UnitPrice@1000 : Decimal UnitPrice //Input parameter of type Decimal
);

Parameters

SalesHeader
Reference parameter of type Record
SalesLine
Reference parameter of type Record
Item
Input parameter of type Record
LocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code
Qty
Input parameter of type Decimal
PostingDate
Input parameter of type Date
UnitPrice
Input parameter of type Decimal

Remarks

The relevant search keywords are: MAKE, Sales, Blanket, Order.

For a clarification about how this function works, refer to the code listed below.

      MAKESalesDoc(
        SalesHeader,SalesLine,SalesHeader."Document Type"::"Blanket Order",Item,LocationCode,VariantCode,Qty,PostingDate,UnitPrice);

Example

The below example is extracted from the test automation codeunit 137410 to show one way of using this function.

      // Setup
      Initialize;
      Quantity := LibraryRandom.RandIntInRange(1,10);
      CreateItemwithStock(Item,ExtendedTxt,Quantity);
      LibraryPatterns.MAKESalesBlanketOrder(SalesHeader,SalesLine,Item,'','',
        Quantity,WORKDATE,LibraryRandom.RandIntInRange(1,10));
      IF TransferExtendedText.SalesCheckIfAnyExtText(SalesLine,FALSE) THEN
        TransferExtendedText.InsertSalesExtText(SalesLine);

      // Exercise: Create Sales Order form Sales Blanket Order.
      CODEUNIT.RUN(CODEUNIT::"Blnkt Sales Ord. to Ord. (Y/N)",SalesHeader);

      // Verify
      VerifySalesOrder(SalesLine."No.",ExtendedTxt);
Member of Lib.Library - Patterns


MAKESalesCreditMemo@95 Method

The procedure MAKESalesCreditMemo is available in codeunit 132212.

Syntax

MAKESalesCreditMemo@95(
    VAR SalesHeader@1008 : Record 36 SalesHeader, //Reference parameter of type Record
    VAR SalesLine@1007 : Record 37 SalesLine, //Reference parameter of type Record
    Item@1006 : Record 27 Item, //Input parameter of type Record
    LocationCode@1005 : Code[10] LocationCode, //Input parameter of type Code
    VariantCode@1004 : Code[10] VariantCode, //Input parameter of type Code
    Qty@1003 : Decimal Qty, //Input parameter of type Decimal
    PostingDate@1002 : Date PostingDate, //Input parameter of type Date
    UnitCost@1001 : Decimal UnitCost, //Input parameter of type Decimal
    UnitPrice@1000 : Decimal UnitPrice //Input parameter of type Decimal
);

Parameters

SalesHeader
Reference parameter of type Record
SalesLine
Reference parameter of type Record
Item
Input parameter of type Record
LocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code
Qty
Input parameter of type Decimal
PostingDate
Input parameter of type Date
UnitCost
Input parameter of type Decimal
UnitPrice
Input parameter of type Decimal

Remarks

The relevant search keywords are: MAKE, Sales, Credit, Memo.

For a clarification about how this function works, refer to the code listed below.

      MAKESalesDoc(SalesHeader,SalesLine,SalesHeader."Document Type"::"Credit Memo",Item,
        LocationCode,VariantCode,Qty,PostingDate,UnitPrice);
      SalesLine.VALIDATE("Unit Cost (LCY)",UnitCost);
      SalesLine.MODIFY;

Example

The below example is extracted from the test automation codeunit 137608 to show one way of using this function.

      Initialize;
      Day1 := WORKDATE;
      IF CONFIRM('') THEN; // ES workaround.

      // Setup the item.
      LibraryPatterns.MAKEItem(Item,CostingMethod,0,0,0,'');
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location);

      // Post sales and credit memo.
      Qty := LibraryRandom.RandInt(20);
      LibraryPatterns.POSTSalesOrder(SalesHeader,Item,Location.Code,'',Qty,Day1,LibraryRandom.RandDec(100,2),TRUE,TRUE);
      LibraryPatterns.InsertTempILEFromLast(TempItemLedgerEntry);

      LibraryPatterns.MAKESalesCreditMemo(SalesHeader,SalesLine,Item,Location.Code,'',Qty,Day1,0,0);
      SalesLine.VALIDATE("Appl.-from Item Entry",TempItemLedgerEntry."Entry No.");
      SalesLine.MODIFY;

      LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      // Post positive adj.
      LibraryPatterns.POSTPositiveAdjustment(Item,'','','',Qty,Day1 + 2,LibraryRandom.RandDec(100,2));

      // Adjust.
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');

      // Verify.
      LibraryCosting.CheckAdjustment(Item);
Member of Lib.Library - Patterns


MAKESalesDoc@30 Method

The procedure MAKESalesDoc is available in codeunit 132212.

Syntax

MAKESalesDoc@30(
    VAR SalesHeader@1007 : Record 36 SalesHeader, //Reference parameter of type Record
    VAR SalesLine@1006 : Record 37 SalesLine, //Reference parameter of type Record
    DocType@1009 : Option DocType, //Input parameter of type Option
    Item@1005 : Record 27 Item, //Input parameter of type Record
    LocationCode@1004 : Code[10] LocationCode, //Input parameter of type Code
    VariantCode@1003 : Code[10] VariantCode, //Input parameter of type Code
    Qty@1002 : Decimal Qty, //Input parameter of type Decimal
    PostingDate@1001 : Date PostingDate, //Input parameter of type Date
    UnitPrice@1000 : Decimal UnitPrice //Input parameter of type Decimal
);

Parameters

SalesHeader
Reference parameter of type Record
SalesLine
Reference parameter of type Record
DocType
Input parameter of type Option
Item
Input parameter of type Record
LocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code
Qty
Input parameter of type Decimal
PostingDate
Input parameter of type Date
UnitPrice
Input parameter of type Decimal

Remarks

The relevant search keywords are: MAKE, Sales, Document.

For a clarification about how this function works, refer to the code listed below.

      LibrarySales.CreateSalesHeader(SalesHeader,DocType,'');
      SalesHeader.VALIDATE("Posting Date",PostingDate);
      SalesHeader.MODIFY(TRUE);
      LibrarySales.CreateSalesLine(SalesLine,SalesHeader,SalesLine.Type::Item,Item."No.",Qty);
      SalesLine."Location Code" := LocationCode;
      SalesLine."Variant Code" := VariantCode;
      SalesLine.VALIDATE("Unit Price",UnitPrice);
      SalesLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137609 to show one way of using this function.

      Initialize;
      IF CONFIRM('') THEN; // workaround for ES.

      // Setup: purchase invoice with and without variant.
      Day1 := WORKDATE;
      Qty := LibraryRandom.RandIntInRange(3,100);
      LibraryPatterns.MAKEItemSimple(Item,CostingMethod,LibraryRandom.RandDec(100,2));
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(ToLocation);
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(InTransitLocation);
      InTransitLocation."Use As In-Transit" := TRUE;
      InTransitLocation.MODIFY;
      LibraryPatterns.MAKEStockkeepingUnit(StockkeepingUnit,Item);

      LibraryPatterns.MAKEPurchaseDoc(PurchaseHeader1,PurchaseLine,PurchDocType,Item,StockkeepingUnit."Location Code",
        StockkeepingUnit."Variant Code",2 * Qty,Day1,LibraryRandom.RandDec(100,2));
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader1,TRUE,Invoice);
      LibraryPatterns.MAKEPurchaseDoc(PurchaseHeader2,PurchaseLine,PurchDocType,Item,StockkeepingUnit."Location Code",
        '',2 * Qty,Day1,LibraryRandom.RandDec(100,2));
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader2,TRUE,Invoice);

      // Assign charge to purchase and invoice if necessary.
      Vendor.GET(PurchaseHeader1."Buy-from Vendor No.");
      LibraryPurchase.CreatePurchHeader(PurchaseHeader,PurchaseHeader."Document Type"::Order,Vendor."No.");
      PurchaseHeader.VALIDATE("Posting Date",Day1);
      PurchaseHeader.MODIFY(TRUE);

      CASE PurchDocType OF
        PurchaseHeader."Document Type"::Invoice:
          BEGIN
            PurchInvLine.SETRANGE(Type,PurchaseLine.Type);
            PurchInvLine.SETRANGE("No.",Item."No.");
            PurchInvLine.FINDFIRST;

            LibraryPatterns.ASSIGNPurchChargeToPurchInvoiceLine(PurchaseHeader,PurchInvLine,Qty,
              LibraryRandom.RandDec(100,2));
          END;
        PurchaseHeader."Document Type"::Order:
          BEGIN
            PurchRcptLine.SETRANGE("Order No.",PurchaseHeader1."No.");
            PurchRcptLine.FINDFIRST;

            LibraryPatterns.ASSIGNPurchChargeToPurchRcptLine(PurchaseHeader,PurchRcptLine,Qty,
              LibraryRandom.RandDec(100,2));
            LibraryPurchase.PostPurchaseDocument(PurchaseHeader1,TRUE,TRUE);
            LibraryPurchase.PostPurchaseDocument(PurchaseHeader2,TRUE,TRUE);
          END;
      END;

      LibraryPatterns.MAKEItemChargePurchaseLine(PurchaseLine,ItemCharge,PurchaseHeader,Qty,
        LibraryRandom.RandDec(100,2));
      PurchaseLine."Qty. to Invoice" := 0;
      PurchaseLine.MODIFY;
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

      // Sales credit memo with and without variant.
      LibraryPatterns.MAKESalesDoc(SalesHeader1,SalesLine,SalesDocType,Item,StockkeepingUnit."Location Code",
        StockkeepingUnit."Variant Code",Qty,Day1 + 5,LibraryRandom.RandDec(100,2));
      LibrarySales.PostSalesDocument(SalesHeader1,TRUE,Invoice);
      LibraryPatterns.MAKESalesDoc(SalesHeader2,SalesLine,SalesDocType,Item,StockkeepingUnit."Location Code",
        '',Qty,Day1 + 5,LibraryRandom.RandDec(100,2));
      LibrarySales.PostSalesDocument(SalesHeader2,TRUE,Invoice);

      // Revalue inventory.
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');
      LibraryPatterns.MAKERevaluationJournalLine(ItemJournalBatch,Item,Day1 + 2,
        CalculatePer::Item,FALSE,FALSE,TRUE,CalculationBase::" ");
      ItemJournalLine.SETRANGE("Journal Template Name",ItemJournalBatch."Journal Template Name");
      ItemJournalLine.SETRANGE("Journal Batch Name",ItemJournalBatch.Name);
      ItemJournalLine.FINDFIRST;
      ItemJournalLine.VALIDATE("Inventory Value (Revalued)",
        ItemJournalLine."Inventory Value (Calculated)" + LibraryRandom.RandDec(100,2));
      LibraryInventory.PostItemJournalBatch(ItemJournalBatch);

      // Sales invoice with and without variant.
      LibraryPatterns.MAKESalesInvoice(SalesHeader,SalesLine,Item,StockkeepingUnit."Location Code",
        StockkeepingUnit."Variant Code",Qty,Day1 + 10,LibraryRandom.RandDec(100,2));
      LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      LibraryPatterns.MAKESalesInvoice(SalesHeader,SalesLine,Item,StockkeepingUnit."Location Code",
        '',Qty,Day1 + 10,LibraryRandom.RandDec(100,2));
      LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      // Purchase credit memo with and without variant.
      LibraryPatterns.MAKEPurchaseDoc(PurchaseHeader1,PurchaseLine,PurchReturnDocType,Item,
        StockkeepingUnit."Location Code",StockkeepingUnit."Variant Code",Qty,Day1 + 11,
        LibraryRandom.RandDec(100,2));
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader1,TRUE,Invoice);

      LibraryPatterns.MAKEPurchaseDoc(PurchaseHeader2,PurchaseLine,PurchReturnDocType,Item,
        StockkeepingUnit."Location Code",'',Qty,Day1 + 11,LibraryRandom.RandDec(100,2));
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader2,TRUE,Invoice);

      IF NOT Invoice THEN BEGIN
        LibraryPurchase.PostPurchaseDocument(PurchaseHeader1,TRUE,TRUE);
        LibraryPurchase.PostPurchaseDocument(PurchaseHeader2,TRUE,TRUE);
        SalesHeader1.GET(SalesHeader1."Document Type",SalesHeader1."No.");
        LibrarySales.PostSalesDocument(SalesHeader1,TRUE,TRUE);
        SalesHeader2.GET(SalesHeader2."Document Type",SalesHeader2."No.");
        LibrarySales.PostSalesDocument(SalesHeader2,TRUE,TRUE);
      END;

      // Exercise.
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');

      // Verify.
      LibraryCosting.CheckAdjustment(Item);
Member of Lib.Library - Patterns


MAKESalesInvoice@104 Method

The procedure MAKESalesInvoice is available in codeunit 132212.

Syntax

MAKESalesInvoice@104(
    VAR SalesHeader@1007 : Record 36 SalesHeader, //Reference parameter of type Record
    VAR SalesLine@1006 : Record 37 SalesLine, //Reference parameter of type Record
    Item@1005 : Record 27 Item, //Input parameter of type Record
    LocationCode@1004 : Code[10] LocationCode, //Input parameter of type Code
    VariantCode@1003 : Code[10] VariantCode, //Input parameter of type Code
    Qty@1002 : Decimal Qty, //Input parameter of type Decimal
    PostingDate@1001 : Date PostingDate, //Input parameter of type Date
    UnitPrice@1000 : Decimal UnitPrice //Input parameter of type Decimal
);

Parameters

SalesHeader
Reference parameter of type Record
SalesLine
Reference parameter of type Record
Item
Input parameter of type Record
LocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code
Qty
Input parameter of type Decimal
PostingDate
Input parameter of type Date
UnitPrice
Input parameter of type Decimal

Remarks

The relevant search keywords are: MAKE, Sales, Invoice.

For a clarification about how this function works, refer to the code listed below.

      MAKESalesDoc(SalesHeader,SalesLine,SalesHeader."Document Type"::Invoice,Item,LocationCode,VariantCode,Qty,PostingDate,UnitPrice);

Example

The below example is extracted from the test automation codeunit 137608 to show one way of using this function.

      Initialize;
      Day1 := WORKDATE;
      IF CONFIRM('') THEN; // ES workaround.

      // Setup the item.
      LibraryPatterns.MAKEItem(Item,CostingMethod,0,0,0,'');

      // Post purchase, sales, sales cr. memo.
      Qty := 3 + LibraryRandom.RandInt(20);
      LibraryPatterns.MAKEPurchaseInvoice(PurchaseHeader,PurchaseLine,Item,'','',Qty - 3,Day1,LibraryRandom.RandDec(100,2));
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

      LibraryPatterns.MAKESalesInvoice(SalesHeader,SalesLine,Item,'','',Qty - 3,Day1 + 5,LibraryRandom.RandDec(100,2));
      LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);
      LibraryPatterns.InsertTempILEFromLast(TempItemLedgerEntry);

      LibraryPatterns.MAKESalesCreditMemo(SalesHeader,SalesLine,Item,'','',Qty - 3,Day1 + 5,0,0);
      SalesLine.VALIDATE("Appl.-from Item Entry",TempItemLedgerEntry."Entry No.");
      SalesLine.MODIFY;

      LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);
      LibraryPatterns.InsertTempILEFromLast(TempItemLedgerEntry);
      TempItemLedgerEntry.FINDLAST;

      // Adjust.
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');

      // Post revaluation.
      LibraryInventory.CreateItemJournalBatchByType(ItemJournalBatch,ItemJournalBatch."Template Type"::Revaluation);
      LibraryPatterns.MAKEItemJournalLineWithApplication(ItemJournalLine,ItemJournalBatch,Item,'','',Day1 + 2,
        ItemJournalLine."Entry Type"::"Positive Adjmt.",Qty - 3,0,TempItemLedgerEntry."Entry No.");
      ItemJournalLine.VALIDATE("Inventory Value (Revalued)",
        ItemJournalLine."Inventory Value (Calculated)" + LibraryRandom.RandDec(10,2));
      ItemJournalLine.MODIFY;
      LibraryInventory.PostItemJournalBatch(ItemJournalBatch);

      // Adjust.
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');

      // Verify.
      LibraryCosting.CheckAdjustment(Item);
Member of Lib.Library - Patterns


MAKESalesOrder@12 Method

The procedure MAKESalesOrder is available in codeunit 132212.

Syntax

MAKESalesOrder@12(
    VAR SalesHeader@1007 : Record 36 SalesHeader, //Reference parameter of type Record
    VAR SalesLine@1006 : Record 37 SalesLine, //Reference parameter of type Record
    Item@1005 : Record 27 Item, //Input parameter of type Record
    LocationCode@1004 : Code[10] LocationCode, //Input parameter of type Code
    VariantCode@1003 : Code[10] VariantCode, //Input parameter of type Code
    Qty@1002 : Decimal Qty, //Input parameter of type Decimal
    PostingDate@1001 : Date PostingDate, //Input parameter of type Date
    UnitPrice@1000 : Decimal UnitPrice //Input parameter of type Decimal
);

Parameters

SalesHeader
Reference parameter of type Record
SalesLine
Reference parameter of type Record
Item
Input parameter of type Record
LocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code
Qty
Input parameter of type Decimal
PostingDate
Input parameter of type Date
UnitPrice
Input parameter of type Decimal

Remarks

The relevant search keywords are: MAKE, Sales, Order.

For a clarification about how this function works, refer to the code listed below.

      MAKESalesDoc(SalesHeader,SalesLine,SalesHeader."Document Type"::Order,Item,LocationCode,VariantCode,Qty,PostingDate,UnitPrice);

Example

The below example is extracted from the test automation codeunit 137009 to show one way of using this function.

      // [SCENARIO 361672] "Reserved Receipt" in Item Availability by Event is equal to Purchase Line qty. when sales order is reserved against purch. order
      Initialize;
      LibraryWarehouse.CreateLocation(Location);
      LibraryPatterns.MAKEItemSimple(Item,Item."Costing Method"::Standard,LibraryPatterns.RandCost(Item));

      // [GIVEN] Purchase order for item "X", quantity = "Q"
      LibraryPatterns.MAKEPurchaseOrder(
        PurchaseHeader,PurchaseLine,Item,Location.Code,'',LibraryRandom.RandInt(100),WORKDATE,Item."Unit Cost");
      LibraryPurchase.ReleasePurchaseDocument(PurchaseHeader);

      // [GIVEN] Sales order with reservation against purchase order, reserved quantity = "Q"
      LibraryPatterns.MAKESalesOrder(SalesHeader,SalesLine,Item,Location.Code,'',PurchaseLine.Quantity,WORKDATE,Item."Unit Price");

      SalesLine.VALIDATE("Shipment Date",PurchaseLine."Expected Receipt Date");
      SalesLine.MODIFY(TRUE);
      AutoReserveSalesLine(SalesLine);

      // [WHEN] Item availability by event is calculated
      CalculateAvailabilityByEvent(TempInvtPageData,Item);

      // [THEN] "Reserved Receipt" = "Q"
      FindInvtPageData(TempInvtPageData,TempInvtPageData.Type::Purchase);
      Assert.AreEqual(PurchaseLine.Quantity,TempInvtPageData."Reserved Receipt",WrongReservedQtyErr);
Member of Lib.Library - Patterns


MAKESalesQuote@102 Method

The procedure MAKESalesQuote is available in codeunit 132212.

Syntax

MAKESalesQuote@102(
    VAR SalesHeader@1007 : Record 36 SalesHeader, //Reference parameter of type Record
    VAR SalesLine@1006 : Record 37 SalesLine, //Reference parameter of type Record
    Item@1005 : Record 27 Item, //Input parameter of type Record
    LocationCode@1004 : Code[10] LocationCode, //Input parameter of type Code
    VariantCode@1003 : Code[10] VariantCode, //Input parameter of type Code
    Qty@1002 : Decimal Qty, //Input parameter of type Decimal
    PostingDate@1001 : Date PostingDate, //Input parameter of type Date
    UnitPrice@1000 : Decimal UnitPrice //Input parameter of type Decimal
);

Parameters

SalesHeader
Reference parameter of type Record
SalesLine
Reference parameter of type Record
Item
Input parameter of type Record
LocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code
Qty
Input parameter of type Decimal
PostingDate
Input parameter of type Date
UnitPrice
Input parameter of type Decimal

Remarks

The relevant search keywords are: MAKE, Sales, Quote.

For a clarification about how this function works, refer to the code listed below.

      MAKESalesDoc(
        SalesHeader,SalesLine,SalesHeader."Document Type"::Quote,Item,LocationCode,VariantCode,Qty,PostingDate,UnitPrice);

Example

The below example is extracted from the test automation codeunit 137410 to show one way of using this function.

      // Setup
      Initialize;
      Quantity := LibraryRandom.RandIntInRange(1,10);
      CreateItemwithStock(Item,ExtendedTxt,Quantity);
      LibraryPatterns.MAKESalesQuote(SalesHeader,SalesLine,Item,'','',
        Quantity,WORKDATE,LibraryRandom.RandIntInRange(1,10));
      IF TransferExtendedText.SalesCheckIfAnyExtText(SalesLine,FALSE) THEN
        TransferExtendedText.InsertSalesExtText(SalesLine);

      // Exercise: Create Sales Order form Sales Quote.
      CODEUNIT.RUN(CODEUNIT::"Sales-Quote to Order (Yes/No)",SalesHeader);

      // Verify
      VerifySalesOrder(SalesLine."No.",ExtendedTxt);
Member of Lib.Library - Patterns


MAKESalesReturnOrder@20 Method

The procedure MAKESalesReturnOrder is available in codeunit 132212.

Syntax

MAKESalesReturnOrder@20(
    VAR SalesHeader@1007 : Record 36 SalesHeader, //Reference parameter of type Record
    VAR SalesLine@1006 : Record 37 SalesLine, //Reference parameter of type Record
    Item@1005 : Record 27 Item, //Input parameter of type Record
    LocationCode@1004 : Code[10] LocationCode, //Input parameter of type Code
    VariantCode@1003 : Code[10] VariantCode, //Input parameter of type Code
    Qty@1002 : Decimal Qty, //Input parameter of type Decimal
    PostingDate@1001 : Date PostingDate, //Input parameter of type Date
    UnitCost@1000 : Decimal UnitCost, //Input parameter of type Decimal
    UnitPrice@1008 : Decimal UnitPrice //Input parameter of type Decimal
);

Parameters

SalesHeader
Reference parameter of type Record
SalesLine
Reference parameter of type Record
Item
Input parameter of type Record
LocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code
Qty
Input parameter of type Decimal
PostingDate
Input parameter of type Date
UnitCost
Input parameter of type Decimal
UnitPrice
Input parameter of type Decimal

Remarks

The relevant search keywords are: MAKE, Sales, Return, Order.

For a clarification about how this function works, refer to the code listed below.

      MAKESalesDoc(
        SalesHeader,SalesLine,SalesHeader."Document Type"::"Return Order",Item,LocationCode,VariantCode,Qty,PostingDate,UnitPrice);
      SalesLine.VALIDATE("Unit Cost (LCY)",UnitCost);
      SalesLine.MODIFY;

Example

The below example is extracted from the test automation codeunit 137612 to show one way of using this function.

      // Verify Value Entries for an Item which have zero Inventory after run the Adjust Cost Item Entries.
      // Fixed values are used to test for rounding error

      // Setup: Update Inventory Setup and Sales Receivable Setup.
      Initialize;
      InventorySetup.GET;
      UpdateInventorySetup(
        InventorySetup,TRUE,InventorySetup."Expected Cost Posting to G/L",InventorySetup."Automatic Cost Adjustment",
        InventorySetup."Average Cost Calc. Type",InventorySetup."Average Cost Period"::Month);
      SalesReceivablesSetup.GET;
      UpdateSalesReceivablesSetup(TRUE,SalesReceivablesSetup."Stockout Warning");

      LibraryPatterns.MAKEItemSimple(Item,Item."Costing Method"::Average,966.26829);

      // Exercise
      PostingDate := WORKDATE;
      LibraryPatterns.POSTPurchaseOrder(PurchaseHeader,Item,'','',41,PostingDate,966.26829,TRUE,TRUE);

      PostingDate += 7;
      LibraryPatterns.POSTSalesOrder(SalesHeader,Item,'','',41,PostingDate,10000,TRUE,TRUE);
      ItemLedgerEntry.SETRANGE("Item No.",Item."No.");
      ItemLedgerEntry.FINDLAST;

      LibraryPatterns.MAKESalesReturnOrder(SalesHeader,SalesLine,Item,'','',41,PostingDate,966.26829,10000);
      SalesLine.VALIDATE("Appl.-from Item Entry",ItemLedgerEntry."Entry No.");
      SalesLine.MODIFY(TRUE);
      LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      PostingDate += 7;
      LibraryPatterns.POSTSalesOrder(SalesHeader,Item,'','',41,PostingDate,10000,TRUE,TRUE);

      PostingDate += 7;
      LibraryPatterns.POSTPurchaseOrder(PurchaseHeader,Item,'','',41,PostingDate,966.26829,TRUE,TRUE);

      PostingDate += 7;
      LibraryPatterns.POSTSalesOrder(SalesHeader,Item,'','',41,PostingDate,10000,TRUE,TRUE);

      LibraryCosting.AdjustCostItemEntries(Item."No.",'');

      // Verify
      LibraryCosting.CheckAdjustment(Item);

      // Teardown:
      UpdateInventorySetup(
        InventorySetup,InventorySetup."Automatic Cost Posting",InventorySetup."Expected Cost Posting to G/L",
        InventorySetup."Automatic Cost Adjustment",InventorySetup."Average Cost Calc. Type",InventorySetup."Average Cost Period");
      UpdateSalesReceivablesSetup(SalesReceivablesSetup."Exact Cost Reversing Mandatory",SalesReceivablesSetup."Stockout Warning");
Member of Lib.Library - Patterns


MAKEStockkeepingUnit@15 Method

The procedure MAKEStockkeepingUnit is available in codeunit 132212.

Syntax

MAKEStockkeepingUnit@15(
    VAR StockkeepingUnit@1000 : Record 5700 StockkeepingUnit, //Reference parameter of type Record
    Item@1001 : Record 27 Item //Input parameter of type Record
);

Parameters

StockkeepingUnit
Reference parameter of type Record
Item
Input parameter of type Record

Remarks

The relevant search keywords are: MAKE, Stockkeeping, Unit.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(StockkeepingUnit);
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location);
      LibraryInventory.CreateItemVariant(ItemVariant,Item."No.");
      LibraryInventory.CreateStockkeepingUnitForLocationAndVariant(StockkeepingUnit,Location.Code,Item."No.",ItemVariant.Code);
      StockkeepingUnit."Unit Cost" := Item."Unit Cost";
      StockkeepingUnit."Standard Cost" := Item."Standard Cost";
      StockkeepingUnit.MODIFY;

Example

The below example is extracted from the test automation codeunit 137601 to show one way of using this function.

      Initialize;

      // Setup Item and SKU.
      LibraryPatterns.MAKEItem(Item,CostingMethod,0,0,0,'');
      IF MakeSKU THEN
        LibraryPatterns.MAKEStockkeepingUnit(StockkeepingUnit,Item);

      // Inventory Flow.
      LibraryPatterns.GRPH1Outbound1PurchRcvd(
        TempItemLedgerEntry,PurchaseLine,Item,StockkeepingUnit."Location Code",StockkeepingUnit."Variant Code");

      // Extract the Purchase Receipt No. from the ILEs.
      TempItemLedgerEntry.SETRANGE(Positive,TRUE);
      TempItemLedgerEntry.FINDFIRST;
      PurchRcptLine.GET(TempItemLedgerEntry."Document No.",TempItemLedgerEntry."Document Line No.");

      // Cost modification.
      PurchaseHeader.GET(PurchaseLine."Document Type",PurchaseLine."Document No.");
      LibraryPatterns.ASSIGNPurchChargeToPurchRcptLine(
        PurchaseHeader,PurchRcptLine,LibraryRandom.RandInt(10),LibraryRandom.RandDec(100,5));
      LibraryPatterns.ASSIGNPurchChargeToPurchaseLine(
        PurchaseHeader,PurchaseLine,LibraryRandom.RandInt(10),LibraryRandom.RandDec(100,5));
      PurchaseHeader.VALIDATE("Vendor Invoice No.",LibraryUtility.GenerateGUID);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

      // Exercise.
      PurchaseHeader.GET(PurchaseHeader."Document Type"::Order,PurchRcptLine."Order No.");
      PurchaseHeader.VALIDATE("Vendor Invoice No.",LibraryUtility.GenerateGUID);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,FALSE,TRUE);
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');

      // Verify.
      LibraryCosting.CheckAdjustment(Item);
Member of Lib.Library - Patterns


MAKETransferOrder@84 Method

The procedure MAKETransferOrder is available in codeunit 132212.

Syntax

MAKETransferOrder@84(
    VAR TransferHeader@1007 : Record 5740 TransferHeader, //Reference parameter of type Record
    VAR TransferLine@1006 : Record 5741 TransferLine, //Reference parameter of type Record
    Item@1005 : Record 27 Item, //Input parameter of type Record
    FromLocation@1004 : Record 14 FromLocation, //Input parameter of type Record
    ToLocation@1008 : Record 14 ToLocation, //Input parameter of type Record
    InTransitLocation@1009 : Record 14 InTransitLocation, //Input parameter of type Record
    VariantCode@1003 : Code[10] VariantCode, //Input parameter of type Code
    Qty@1002 : Decimal Qty, //Input parameter of type Decimal
    PostingDate@1000 : Date PostingDate, //Input parameter of type Date
    ShipmentDate@1001 : Date ShipmentDate //Input parameter of type Date
);

Parameters

TransferHeader
Reference parameter of type Record
TransferLine
Reference parameter of type Record
Item
Input parameter of type Record
FromLocation
Input parameter of type Record
ToLocation
Input parameter of type Record
InTransitLocation
Input parameter of type Record
VariantCode
Input parameter of type Code
Qty
Input parameter of type Decimal
PostingDate
Input parameter of type Date
ShipmentDate
Input parameter of type Date

Remarks

The relevant search keywords are: MAKE, Transfer, Order.

For a clarification about how this function works, refer to the code listed below.

      LibraryWarehouse.CreateTransferHeader(TransferHeader,FromLocation.Code,ToLocation.Code,InTransitLocation.Code);
      TransferHeader.VALIDATE("Posting Date",PostingDate);
      TransferHeader.VALIDATE("Shipment Date",ShipmentDate);
      TransferHeader.MODIFY;
      LibraryWarehouse.CreateTransferLine(TransferHeader,TransferLine,Item."No.",Qty);
      TransferLine.VALIDATE("Shipment Date",ShipmentDate);
      TransferLine.VALIDATE("Variant Code",VariantCode);
      TransferLine.MODIFY;

Example

The below example is extracted from the test automation codeunit 137009 to show one way of using this function.

      // [FEATURE] [Transfer] [Reservation]
      // [SCENARIO 213103] Shipped and reserved quantity on transfer line should be included in Reserved Receipt in Item Availability by Event.
      Initialize;

      // [GIVEN] Locations "L1", "L2" and an in-transit location.
      CreateLocationsForTransfer(FromLocation,ToLocation,InTransitLocation);

      // [GIVEN] "Q" pcs of item "I" is is stock on "L1".
      LibraryPatterns.MAKEItemSimple(Item,Item."Costing Method"::Standard,LibraryPatterns.RandCost(Item));
      Qty := LibraryRandom.RandIntInRange(50,100);
      LibraryPatterns.POSTPositiveAdjustment(Item,FromLocation.Code,'','',Qty,WORKDATE,Item."Unit Cost");

      // [GIVEN] Transfer Order from "L1" to "L2". Quantity = "Q", "Qty. to Ship" = "q" < "Q".
      LibraryPatterns.MAKETransferOrder(
        TransferHeader,TransferLine,Item,FromLocation,ToLocation,InTransitLocation,'',Qty,WORKDATE,WORKDATE);
      TransferLine.VALIDATE("Qty. to Ship",LibraryRandom.RandInt(20));
      TransferLine.MODIFY(TRUE);

      // [GIVEN] Sales Order for "Q" pcs is reserved from Transfer Order.
      LibraryPatterns.MAKESalesOrder(SalesHeader,SalesLine,Item,ToLocation.Code,'',Qty,WORKDATE,Item."Unit Price");
      SalesLine.VALIDATE("Shipment Date",LibraryRandom.RandDate(10));
      SalesLine.MODIFY(TRUE);
      AutoReserveSalesLine(SalesLine);

      // [GIVEN] Transfer Order is shipped.
      // [GIVEN] Reserved Qty. Inbnd. (Base) becomes equal to "Q" - "q", Reserved Qty. Shipped (Base) = "q".
      LibraryInventory.PostTransferHeader(TransferHeader,TRUE,FALSE);
      TransferLine.FIND;
      TransferLine.CALCFIELDS("Reserved Qty. Inbnd. (Base)","Reserved Qty. Shipped (Base)");

      // [WHEN] Calculate item availability by event.
      CalculateAvailabilityByEvent(TempInvtPageData,Item);

      // [THEN] "Reserved Receipt" on the availability line representing the transfer is equal to "Q".
      FindInvtPageData(TempInvtPageData,TempInvtPageData.Type::Transfer);
      Assert.AreEqual(
        TransferLine."Reserved Qty. Inbnd. (Base)" + TransferLine."Reserved Qty. Shipped (Base)",
        TempInvtPageData."Reserved Receipt",WrongReservedQtyErr);
Member of Lib.Library - Patterns


Minimum@47 Method

The procedure Minimum is available in codeunit 132212.

Syntax

Minimum@47(
    Value1@1000 : Decimal Value1, //Input parameter of type Decimal
    Value2@1001 : Decimal Value2 //Input parameter of type Decimal
);

Parameters

Value1
Input parameter of type Decimal
Value2
Input parameter of type Decimal

Return Value

Decimal

Remarks

The relevant search keywords are: Minimum.

For a clarification about how this function works, refer to the code listed below.

      IF Value1 < Value2 THEN
        EXIT(Value1);

      EXIT(Value2);

Example

There are no examples available.
Member of Lib.Library - Patterns


ModifyAppliesToPostRevaluation@106 Method

The procedure ModifyAppliesToPostRevaluation is available in codeunit 132212.

Syntax

ModifyAppliesToPostRevaluation@106(
    VAR ItemJnlBatch@1000 : Record 233 ItemJnlBatch, //Reference parameter of type Record
    Factor@1004 : Decimal Factor, //Input parameter of type Decimal
    AppliesToEntry@1002 : Integer AppliesToEntry //Input parameter of type Integer
);

Parameters

ItemJnlBatch
Reference parameter of type Record
Factor
Input parameter of type Decimal
AppliesToEntry
Input parameter of type Integer

Remarks

The relevant search keywords are: Modify, Applies, To, Post, Revaluation.

For a clarification about how this function works, refer to the code listed below.

      ItemJnlLine.SETRANGE("Journal Template Name",ItemJnlBatch."Journal Template Name");
      ItemJnlLine.SETRANGE("Journal Batch Name",ItemJnlBatch.Name);
      IF ItemJnlLine.FINDSET THEN
        REPEAT
          ItemJnlLine.VALIDATE("Inventory Value (Revalued)",
            ROUND(ItemJnlLine."Inventory Value (Revalued)" * Factor,LibraryERM.GetAmountRoundingPrecision));
          ItemJnlLine.VALIDATE("Applies-to Entry",AppliesToEntry);
          ItemJnlLine.MODIFY;
        UNTIL ItemJnlLine.NEXT = 0;
      LibraryInventory.PostItemJournalBatch(ItemJnlBatch);

Example

The below example is extracted from the test automation codeunit 137353 to show one way of using this function.

      LibraryCosting.AdjustCostItemEntries(ParentItem."No." + '|' + ChildItem."No.",'');
      LibraryPatterns.CalculateInventoryValueRun(
        ItemJournalBatch,ParentItem,RevalDate,CalculatePer,FALSE,FALSE,FALSE,CalculationBase::" ",FALSE,'','');
      LibraryPatterns.ModifyAppliesToPostRevaluation(ItemJournalBatch,LibraryRandom.RandIntInRange(3,10),AppliesToEntry);
      LibraryCosting.AdjustCostItemEntries(ParentItem."No." + '|' + ChildItem."No.",'');
Member of Lib.Library - Patterns


ModifyPostRevaluation@78 Method

The procedure ModifyPostRevaluation is available in codeunit 132212.

Syntax

ModifyPostRevaluation@78(
    VAR ItemJnlBatch@1000 : Record 233 ItemJnlBatch, //Reference parameter of type Record
    Factor@1004 : Decimal Factor //Input parameter of type Decimal
);

Parameters

ItemJnlBatch
Reference parameter of type Record
Factor
Input parameter of type Decimal

Remarks

The relevant search keywords are: Modify, Post, Revaluation.

For a clarification about how this function works, refer to the code listed below.

      ItemJnlLine.SETRANGE("Journal Template Name",ItemJnlBatch."Journal Template Name");
      ItemJnlLine.SETRANGE("Journal Batch Name",ItemJnlBatch.Name);
      IF ItemJnlLine.FINDSET THEN
        REPEAT
          ItemJnlLine.VALIDATE("Inventory Value (Revalued)",
            ROUND(ItemJnlLine."Inventory Value (Revalued)" * Factor,LibraryERM.GetAmountRoundingPrecision));
          ItemJnlLine.MODIFY;
        UNTIL ItemJnlLine.NEXT = 0;
      LibraryInventory.PostItemJournalBatch(ItemJnlBatch);

Example

The below example is extracted from the test automation codeunit 137053 to show one way of using this function.

      // [SCENARIO] Verify ILE "Cost Amount (Actual)" after posting: purchase (full receive, part invoice) - sales - adjust cost - revaluation - adjust cost - sales - purchase (remaining invoice) - sales - adjust cost.

      CreateItemWithAvg(Item);

      PostingDate := WORKDATE;

      // Purchase Receive 3, Invoice 1
      LibraryPatterns.MAKEPurchaseOrder(PurchaseHeader,PurchaseLine,Item,'','',3,PostingDate,10);
      PurchaseLine.VALIDATE("Qty. to Invoice",2);
      PurchaseLine.MODIFY;
      PurchaseHeader.VALIDATE("Vendor Invoice No.",LibraryUtility.GenerateGUID);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

      // Sell 1
      LibraryPatterns.POSTSalesOrder(SalesHeader,Item,'','',1,PostingDate,0,TRUE,TRUE);
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');

      // Revalue
      LibraryPatterns.CalculateInventoryValueRun(ItemJnlBatch,Item,PostingDate,1,FALSE,FALSE,FALSE,0,FALSE,'','');
      LibraryPatterns.ModifyPostRevaluation(ItemJnlBatch,2);
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');

      PostingDate += 1;

      // Sell 1
      LibraryPatterns.POSTSalesOrder(SalesHeader,Item,'','',1,PostingDate,0,TRUE,TRUE);

      PostingDate += 1;
      // Purchase Invoice Remaining 2
      PurchaseHeader.FIND;
      PurchaseHeader.VALIDATE("Posting Date",PostingDate);
      PurchaseHeader.MODIFY;
      PurchaseLine.FIND;
      PurchaseLine.VALIDATE("Direct Unit Cost",12);
      PurchaseLine.MODIFY;
      PurchaseHeader.VALIDATE("Vendor Invoice No.",LibraryUtility.GenerateGUID);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

      PostingDate += 1;
      // Sell 1
      LibraryPatterns.POSTSalesOrder(SalesHeader,Item,'','',1,PostingDate,0,TRUE,TRUE);

      LibraryCosting.AdjustCostItemEntries(Item."No.",'');
      LibraryCosting.CheckAdjustment(Item);
Member of Lib.Library - Patterns


POSTConsumption@5 Method

The procedure POSTConsumption is available in codeunit 132212.

Syntax

POSTConsumption@5(
    ProdOrderLine@1008 : Record 5406 ProdOrderLine, //Input parameter of type Record
    Item@1005 : Record 27 Item, //Input parameter of type Record
    LocationCode@1004 : Code[10] LocationCode, //Input parameter of type Code
    VariantCode@1003 : Code[10] VariantCode, //Input parameter of type Code
    Qty@1002 : Decimal Qty, //Input parameter of type Decimal
    PostingDate@1001 : Date PostingDate, //Input parameter of type Date
    UnitCost@1000 : Decimal UnitCost //Input parameter of type Decimal
);

Parameters

ProdOrderLine
Input parameter of type Record
Item
Input parameter of type Record
LocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code
Qty
Input parameter of type Decimal
PostingDate
Input parameter of type Date
UnitCost
Input parameter of type Decimal

Remarks

The relevant search keywords are: POST, Consumption.

For a clarification about how this function works, refer to the code listed below.

      MAKEConsumptionJournalLine(ItemJournalBatch,ProdOrderLine,Item,PostingDate,LocationCode,VariantCode,Qty,UnitCost);
      LibraryInventory.PostItemJournalBatch(ItemJournalBatch);

Example

The below example is extracted from the test automation codeunit 137302 to show one way of using this function.

      IF ConsumptionQty <> 0 THEN
        LibraryPatterns.POSTConsumption(ProdOrderLine,ComponentItem,'','',ConsumptionQty,PostingDate,ComponentItem."Unit Cost");
      LibraryPatterns.POSTOutput(ProdOrderLine,OutputQty,PostingDate,ProdItemUnitCost);
Member of Lib.Library - Patterns


POSTItemJournalLine@7 Method

The procedure POSTItemJournalLine is available in codeunit 132212.

Syntax

POSTItemJournalLine@7(
    TemplateType@1000 : Option TemplateType, //Input parameter of type Option
    EntryType@1003 : Option EntryType, //Input parameter of type Option
    Item@1004 : Record 27 Item, //Input parameter of type Record
    LocationCode@1008 : Code[10] LocationCode, //Input parameter of type Code
    VariantCode@1009 : Code[10] VariantCode, //Input parameter of type Code
    BinCode@1010 : Code[20] BinCode, //Input parameter of type Code
    Qty@1005 : Decimal Qty, //Input parameter of type Decimal
    PostingDate@1006 : Date PostingDate, //Input parameter of type Date
    UnitAmount@1007 : Decimal UnitAmount //Input parameter of type Decimal
);

Parameters

TemplateType
Input parameter of type Option
EntryType
Input parameter of type Option
Item
Input parameter of type Record
LocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code
BinCode
Input parameter of type Code
Qty
Input parameter of type Decimal
PostingDate
Input parameter of type Date
UnitAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: POST, Item, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      LibraryInventory.CreateItemJournalBatchByType(ItemJournalBatch,TemplateType);
      MAKEItemJournalLine(ItemJournalLine,ItemJournalBatch,Item,LocationCode,VariantCode,PostingDate,EntryType,Qty,UnitAmount);
      ItemJournalLine."Bin Code" := BinCode;
      ItemJournalLine.MODIFY;
      LibraryInventory.PostItemJournalBatch(ItemJournalBatch);

Example

The below example is extracted from the test automation codeunit 137053 to show one way of using this function.

      // [SCENARIO] Verify ILE "Cost Amount (Actual)" after posting: purchase - sale - sale - adjust cost - revaluation - sale - sale with fix application to the purchase - adjust cost - revaluation - sale - adjust cost.

      CreateItemWithAvg(Item);

      PostingDate := WORKDATE;

      // Purchase 5 @ 1 each
      LibraryPatterns.POSTItemJournalLine(
        ItemJournalBatch."Template Type"::Item,ItemJournalLine."Entry Type"::Purchase,Item,'','','',5,PostingDate,1);
      ItemLedgerEntry[1].FINDLAST;

      // Sell 1
      LibraryPatterns.POSTItemJournalLine(
        ItemJournalBatch."Template Type"::Item,ItemJournalLine."Entry Type"::Sale,Item,'','','',1,PostingDate,1);
      ItemLedgerEntry[2].FINDLAST;

      // Sell 1, Fixed Application
      LibraryPatterns.POSTItemJournalLineWithApplication(
        ItemJournalBatch."Template Type"::Item,ItemJournalLine."Entry Type"::Sale,Item,'','',1,PostingDate,1,
        ItemLedgerEntry[1]."Entry No.");
      ItemLedgerEntry[3].FINDLAST;

      // Revalue Inventory Qty 3 to Value 10 to create rounding scenario
      LibraryCosting.AdjustCostItemEntries('','');
      RevalueToFixedInvValue(Item,PostingDate,10);

      // Sell 1
      LibraryPatterns.POSTItemJournalLine(
        ItemJournalBatch."Template Type"::Item,ItemJournalLine."Entry Type"::Sale,Item,'','','',1,PostingDate,1);
      ItemLedgerEntry[4].FINDLAST;

      // Sell 1, Fixed Application
      LibraryPatterns.POSTItemJournalLineWithApplication(
        ItemJournalBatch."Template Type"::Item,ItemJournalLine."Entry Type"::Sale,Item,'','',1,PostingDate,1,
        ItemLedgerEntry[1]."Entry No.");
      ItemLedgerEntry[5].FINDLAST;

      // Revalue remaining qty to 1
      LibraryCosting.AdjustCostItemEntries('','');
      RevalueToFixedInvValue(Item,PostingDate,1);

      // Sell 1
      LibraryPatterns.POSTItemJournalLine(
        ItemJournalBatch."Template Type"::Item,ItemJournalLine."Entry Type"::Sale,Item,'','','',1,PostingDate,1);
      LibraryCosting.AdjustCostItemEntries('','');
      ItemLedgerEntry[6].FINDLAST;

      VerifyItemLedgerEntry(ItemLedgerEntry[1],9.67); // purchase 5 + reval 7 + reval -2.33
      VerifyItemLedgerEntry(ItemLedgerEntry[2],-1);
      VerifyItemLedgerEntry(ItemLedgerEntry[3],-1);
      VerifyItemLedgerEntry(ItemLedgerEntry[4],-3.34); // 10 / 3 + rounding 0.01
      VerifyItemLedgerEntry(ItemLedgerEntry[5],-3.33); // 10 / 3
      VerifyItemLedgerEntry(ItemLedgerEntry[6],-1); // remaining value after final revaluation
Member of Lib.Library - Patterns


POSTItemJournalLineWithApplication@89 Method

The procedure POSTItemJournalLineWithApplication is available in codeunit 132212.

Syntax

POSTItemJournalLineWithApplication@89(
    TemplateType@1000 : Option TemplateType, //Input parameter of type Option
    EntryType@1003 : Option EntryType, //Input parameter of type Option
    Item@1004 : Record 27 Item, //Input parameter of type Record
    LocationCode@1008 : Code[10] LocationCode, //Input parameter of type Code
    VariantCode@1009 : Code[10] VariantCode, //Input parameter of type Code
    Qty@1005 : Decimal Qty, //Input parameter of type Decimal
    PostingDate@1006 : Date PostingDate, //Input parameter of type Date
    UnitAmount@1007 : Decimal UnitAmount, //Input parameter of type Decimal
    AppltoEntryNo@1010 : Integer AppltoEntryNo //Input parameter of type Integer
);

Parameters

TemplateType
Input parameter of type Option
EntryType
Input parameter of type Option
Item
Input parameter of type Record
LocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code
Qty
Input parameter of type Decimal
PostingDate
Input parameter of type Date
UnitAmount
Input parameter of type Decimal
AppltoEntryNo
Input parameter of type Integer

Remarks

The relevant search keywords are: POST, Item, Journal, Line, Application.

For a clarification about how this function works, refer to the code listed below.

      LibraryInventory.CreateItemJournalBatchByType(ItemJournalBatch,TemplateType);
      MAKEItemJournalLineWithApplication(
        ItemJournalLine,ItemJournalBatch,Item,LocationCode,VariantCode,PostingDate,EntryType,Qty,UnitAmount,AppltoEntryNo);
      LibraryInventory.PostItemJournalBatch(ItemJournalBatch);

Example

The below example is extracted from the test automation codeunit 137053 to show one way of using this function.

      // [SCENARIO] Verify ILE "Cost Amount (Actual)" after posting: purchase - sale - sale - adjust cost - revaluation - sale - sale with fix application to the purchase - adjust cost - revaluation - sale - adjust cost.

      CreateItemWithAvg(Item);

      PostingDate := WORKDATE;

      // Purchase 5 @ 1 each
      LibraryPatterns.POSTItemJournalLine(
        ItemJournalBatch."Template Type"::Item,ItemJournalLine."Entry Type"::Purchase,Item,'','','',5,PostingDate,1);
      ItemLedgerEntry[1].FINDLAST;

      // Sell 1
      LibraryPatterns.POSTItemJournalLine(
        ItemJournalBatch."Template Type"::Item,ItemJournalLine."Entry Type"::Sale,Item,'','','',1,PostingDate,1);
      ItemLedgerEntry[2].FINDLAST;

      // Sell 1, Fixed Application
      LibraryPatterns.POSTItemJournalLineWithApplication(
        ItemJournalBatch."Template Type"::Item,ItemJournalLine."Entry Type"::Sale,Item,'','',1,PostingDate,1,
        ItemLedgerEntry[1]."Entry No.");
      ItemLedgerEntry[3].FINDLAST;

      // Revalue Inventory Qty 3 to Value 10 to create rounding scenario
      LibraryCosting.AdjustCostItemEntries('','');
      RevalueToFixedInvValue(Item,PostingDate,10);

      // Sell 1
      LibraryPatterns.POSTItemJournalLine(
        ItemJournalBatch."Template Type"::Item,ItemJournalLine."Entry Type"::Sale,Item,'','','',1,PostingDate,1);
      ItemLedgerEntry[4].FINDLAST;

      // Sell 1, Fixed Application
      LibraryPatterns.POSTItemJournalLineWithApplication(
        ItemJournalBatch."Template Type"::Item,ItemJournalLine."Entry Type"::Sale,Item,'','',1,PostingDate,1,
        ItemLedgerEntry[1]."Entry No.");
      ItemLedgerEntry[5].FINDLAST;

      // Revalue remaining qty to 1
      LibraryCosting.AdjustCostItemEntries('','');
      RevalueToFixedInvValue(Item,PostingDate,1);

      // Sell 1
      LibraryPatterns.POSTItemJournalLine(
        ItemJournalBatch."Template Type"::Item,ItemJournalLine."Entry Type"::Sale,Item,'','','',1,PostingDate,1);
      LibraryCosting.AdjustCostItemEntries('','');
      ItemLedgerEntry[6].FINDLAST;

      VerifyItemLedgerEntry(ItemLedgerEntry[1],9.67); // purchase 5 + reval 7 + reval -2.33
      VerifyItemLedgerEntry(ItemLedgerEntry[2],-1);
      VerifyItemLedgerEntry(ItemLedgerEntry[3],-1);
      VerifyItemLedgerEntry(ItemLedgerEntry[4],-3.34); // 10 / 3 + rounding 0.01
      VerifyItemLedgerEntry(ItemLedgerEntry[5],-3.33); // 10 / 3
      VerifyItemLedgerEntry(ItemLedgerEntry[6],-1); // remaining value after final revaluation
Member of Lib.Library - Patterns


POSTNegativeAdjustment@3 Method

The procedure POSTNegativeAdjustment is available in codeunit 132212.

Syntax

POSTNegativeAdjustment@3(
    Item@1005 : Record 27 Item, //Input parameter of type Record
    LocationCode@1004 : Code[10] LocationCode, //Input parameter of type Code
    VariantCode@1003 : Code[10] VariantCode, //Input parameter of type Code
    BinCode@1008 : Code[20] BinCode, //Input parameter of type Code
    Qty@1002 : Decimal Qty, //Input parameter of type Decimal
    PostingDate@1001 : Date PostingDate, //Input parameter of type Date
    UnitAmount@1000 : Decimal UnitAmount //Input parameter of type Decimal
);

Parameters

Item
Input parameter of type Record
LocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code
BinCode
Input parameter of type Code
Qty
Input parameter of type Decimal
PostingDate
Input parameter of type Date
UnitAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: POST, Negative, Adjustment.

For a clarification about how this function works, refer to the code listed below.

      POSTItemJournalLine(ItemJournalTemplate.Type::Item,
        ItemJournalLine."Entry Type"::"Negative Adjmt.",
        Item,
        LocationCode,
        VariantCode,
        BinCode,
        Qty,
        PostingDate,
        UnitAmount);

Example

The below example is extracted from the test automation codeunit 137153 to show one way of using this function.

      // [FEATURE] [Physical Inventory Journal]
      // [SCENARIO] When running physical inventory calculation, item ledger entries on deleted location should be skipped

      // [GIVEN] 2 locations "L1" and "L2"
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location[1]);
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location[2]);

      // [GIVEN] Post positive adjustment and negative adjustment on location "L1", and positive adjustment on "L2". So there is inventory left only on "L2".
      LibraryInventory.CreateItem(Item);
      Qty := LibraryRandom.RandDec(100,2);
      LibraryPatterns.POSTPositiveAdjustment(Item,Location[1].Code,'','',Qty,WORKDATE,Item."Unit Cost");
      LibraryPatterns.POSTPositiveAdjustment(Item,Location[2].Code,'','',Qty,WORKDATE,Item."Unit Cost");
      LibraryPatterns.POSTNegativeAdjustment(Item,Location[1].Code,'','',Qty,WORKDATE,Item."Unit Cost");

      // [GIVEN] Delete location "L1"
      Location[1].DELETE(TRUE);

      // [WHEN] Run "Calculate Physical Inventory" for both locations
      RunReportCalculateInventory(ItemJournalLine,Item."No.",'','',TRUE);

      // [THEN] No item journal lines created for location "L1"
      ItemJournalLine.SETRANGE("Item No.",Item."No.");
      ItemJournalLine.SETRANGE("Location Code",Location[1].Code);
      Assert.RecordIsEmpty(ItemJournalLine);

      // [THEN] 1 item journal line created for location "L2"
      ItemJournalLine.SETRANGE("Location Code",Location[2].Code);
      Assert.AreEqual(1,ItemJournalLine.COUNT,ItemJnlLineMustExistErr);
Member of Lib.Library - Patterns


POSTNegativeAdjustmentAmount@1020 Method

The procedure POSTNegativeAdjustmentAmount is available in codeunit 132212.

Syntax

POSTNegativeAdjustmentAmount@1020(
    Item@1005 : Record 27 Item, //Input parameter of type Record
    LocationCode@1004 : Code[10] LocationCode, //Input parameter of type Code
    VariantCode@1003 : Code[10] VariantCode, //Input parameter of type Code
    Qty@1002 : Decimal Qty, //Input parameter of type Decimal
    PostingDate@1001 : Date PostingDate, //Input parameter of type Date
    Amount@1008 : Decimal Amount //Input parameter of type Decimal
);

Parameters

Item
Input parameter of type Record
LocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code
Qty
Input parameter of type Decimal
PostingDate
Input parameter of type Date
Amount
Input parameter of type Decimal

Remarks

The relevant search keywords are: POST, Negative, Adjustment, Amount.

For a clarification about how this function works, refer to the code listed below.

      LibraryInventory.CreateItemJournalBatchByType(ItemJournalBatch,ItemJournalTemplate.Type::Item);
      MAKEItemJournalLine(ItemJournalLine,ItemJournalBatch,Item,LocationCode,VariantCode,PostingDate,
        ItemJournalLine."Entry Type"::"Negative Adjmt.",Qty,0);
      ItemJournalLine.VALIDATE(Amount,Amount);
      ItemJournalLine.MODIFY;
      LibraryInventory.PostItemJournalBatch(ItemJournalBatch);

Example

There are no examples available.
Member of Lib.Library - Patterns


POSTNegativeAdjustmentWithItemTracking@97 Method

The procedure POSTNegativeAdjustmentWithItemTracking is available in codeunit 132212.

Syntax

POSTNegativeAdjustmentWithItemTracking@97(
    Item@1005 : Record 27 Item, //Input parameter of type Record
    LocationCode@1004 : Code[10] LocationCode, //Input parameter of type Code
    VariantCode@1003 : Code[10] VariantCode, //Input parameter of type Code
    Qty@1002 : Decimal Qty, //Input parameter of type Decimal
    PostingDate@1001 : Date PostingDate, //Input parameter of type Date
    SerialNo@1008 : Code[20] SerialNo, //Input parameter of type Code
    LotNo@1010 : Code[20] LotNo //Input parameter of type Code
);

Parameters

Item
Input parameter of type Record
LocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code
Qty
Input parameter of type Decimal
PostingDate
Input parameter of type Date
SerialNo
Input parameter of type Code
LotNo
Input parameter of type Code

Remarks

The relevant search keywords are: POST, Negative, Adjustment, Item, Tracking.

For a clarification about how this function works, refer to the code listed below.

      LibraryInventory.CreateItemJournalBatchByType(ItemJournalBatch,ItemJournalTemplate.Type::Item);
      MAKEItemJournalLine(ItemJournalLine,ItemJournalBatch,Item,LocationCode,VariantCode,PostingDate,
        ItemJournalLine."Entry Type"::"Negative Adjmt.",Qty,0);
      LibraryItemTracking.CreateItemJournalLineItemTracking(ReservEntry,ItemJournalLine,SerialNo,LotNo,Qty);
      LibraryInventory.PostItemJournalBatch(ItemJournalBatch);

Example

The below example is extracted from the test automation codeunit 137616 to show one way of using this function.

      Initialize;

      // Setup. Create lot tracked item. Purchase and adjust inventory.
      LibraryPatterns.MAKEItemSimple(Item,Item."Costing Method"::FIFO,LibraryRandom.RandDec(10,2));
      LibraryItemTracking.CreateItemTrackingCode(ItemTrackingCode,FALSE,TRUE);
      Item.VALIDATE("Item Tracking Code",ItemTrackingCode.Code);
      Item.MODIFY;

      LotNo := LibraryUtility.GenerateRandomCode(ReservationEntry.FIELDNO("Lot No."),DATABASE::"Reservation Entry");
      Qty := LibraryRandom.RandDecInRange(100,200,2);
      LibraryPatterns.POSTPurchaseOrderWithItemTracking(PurchaseHeader,Item,'','',Qty,WORKDATE,0,TRUE,FALSE,'',LotNo);
      LibraryPatterns.POSTNegativeAdjustmentWithItemTracking(Item,'','',Qty - 50,WORKDATE,'',LotNo);
      LibraryPatterns.InsertTempILEFromLast(TempItemLedgerEntry);

      LibraryInventory.CreateItemJournalBatchByType(ItemJournalBatch,ItemJournalTemplate.Type::Item);
      LibraryPatterns.MAKEItemJournalLine(ItemJournalLine,ItemJournalBatch,Item,'','',WORKDATE,
        ItemJournalLine."Entry Type"::"Positive Adjmt.",Qty - 75,0);

      // Exercise. Try to apply from the journal.
      ASSERTERROR ItemJournalLine.VALIDATE("Applies-from Entry",TempItemLedgerEntry."Entry No.");

      // Verify. Journal line cannot be posted.
      Assert.ExpectedError(ApplErr);
Member of Lib.Library - Patterns


POSTOutput@4 Method

The procedure POSTOutput is available in codeunit 132212.

Syntax

POSTOutput@4(
    ProdOrderLine@1008 : Record 5406 ProdOrderLine, //Input parameter of type Record
    Qty@1002 : Decimal Qty, //Input parameter of type Decimal
    PostingDate@1001 : Date PostingDate, //Input parameter of type Date
    UnitCost@1000 : Decimal UnitCost //Input parameter of type Decimal
);

Parameters

ProdOrderLine
Input parameter of type Record
Qty
Input parameter of type Decimal
PostingDate
Input parameter of type Date
UnitCost
Input parameter of type Decimal

Remarks

The relevant search keywords are: POST, Output.

For a clarification about how this function works, refer to the code listed below.

      Item.GET(ProdOrderLine."Item No.");
      MAKEOutputJournalLine(ItemJournalBatch,ProdOrderLine,PostingDate,Qty,UnitCost);
      LibraryInventory.PostItemJournalBatch(ItemJournalBatch);

Example

The below example is extracted from the test automation codeunit 137302 to show one way of using this function.

      IF ConsumptionQty <> 0 THEN
        LibraryPatterns.POSTConsumption(ProdOrderLine,ComponentItem,'','',ConsumptionQty,PostingDate,ComponentItem."Unit Cost");
      LibraryPatterns.POSTOutput(ProdOrderLine,OutputQty,PostingDate,ProdItemUnitCost);
Member of Lib.Library - Patterns


POSTOutputWithItemTracking@90 Method

The procedure POSTOutputWithItemTracking is available in codeunit 132212.

Syntax

POSTOutputWithItemTracking@90(
    ProdOrderLine@1008 : Record 5406 ProdOrderLine, //Input parameter of type Record
    Qty@1002 : Decimal Qty, //Input parameter of type Decimal
    RunTime@1010 : Decimal RunTime, //Input parameter of type Decimal
    PostingDate@1001 : Date PostingDate, //Input parameter of type Date
    UnitCost@1000 : Decimal UnitCost, //Input parameter of type Decimal
    SerialNo@1004 : Code[20] SerialNo, //Input parameter of type Code
    LotNo@1005 : Code[20] LotNo //Input parameter of type Code
);

Parameters

ProdOrderLine
Input parameter of type Record
Qty
Input parameter of type Decimal
RunTime
Input parameter of type Decimal
PostingDate
Input parameter of type Date
UnitCost
Input parameter of type Decimal
SerialNo
Input parameter of type Code
LotNo
Input parameter of type Code

Remarks

The relevant search keywords are: POST, Output, Item, Tracking.

For a clarification about how this function works, refer to the code listed below.

      Item.GET(ProdOrderLine."Item No.");
      MAKEOutputJournalLine(ItemJournalBatch,ProdOrderLine,PostingDate,Qty,UnitCost);
      ItemJournalLine.SETRANGE("Journal Template Name",ItemJournalBatch."Journal Template Name");
      ItemJournalLine.SETRANGE("Journal Batch Name",ItemJournalBatch.Name);
      ItemJournalLine.FINDFIRST;
      ItemJournalLine.VALIDATE("Run Time",RunTime);
      ItemJournalLine.MODIFY;
      LibraryItemTracking.CreateItemJournalLineItemTracking(ReservEntry,ItemJournalLine,SerialNo,LotNo,Qty);
      LibraryInventory.PostItemJournalBatch(ItemJournalBatch);

Example

The below example is extracted from the test automation codeunit 137612 to show one way of using this function.

      // This test automates the exact bug repro
      // Numbers have not been randomized because they introduce instability in the test

      // Create component
      CreateItemWithAdditionalUOM_FixedVal(CompItem,CompSecItemUnitOfMeasure,CompItem."Costing Method"::FIFO,0.01188,8.77193);

      // Create parent
      CreateItemWithAdditionalUOM_FixedVal(ParentItem,ParSecItemUnitOfMeasure,CompItem."Costing Method"::Standard,0,200);
      LibraryItemTracking.CreateItemTrackingCode(ItemTrackingCode,FALSE,TRUE);
      ParentItem."Replenishment System" := ParentItem."Replenishment System"::"Prod. Order";
      ParentItem.MODIFY;

      // Create Production BOM with Scrap
      CreateProductionBOM(ProductionBOMHeader,ParentItem,CompItem,ParentItem."Base Unit of Measure",'',1,10);

      // Create Work Center
      CreateWorkCenter_FixedCost(WorkCenter,0.07174,0.00381);

      // Create Routing
      LibraryPatterns.MAKERoutingforWorkCenter(RoutingHeader,ParentItem,WorkCenter."No.");

      // Standard Cost calculate
      CalculateStdCost.CalcItem(ParentItem."No.",FALSE);

      // Receive Purchase Order
      LibraryPatterns.MAKEPurchaseOrder(PurchaseHeader,PurchaseLine,CompItem,'','',2600,WORKDATE,0.47754);
      PurchaseLine.VALIDATE("Unit of Measure Code",CompSecItemUnitOfMeasure.Code);
      PurchaseLine.VALIDATE("Direct Unit Cost",0.47754);
      PurchaseLine.MODIFY(TRUE);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,FALSE);

      // Create Released Production Order
      LibraryPatterns.MAKEProductionOrder(
        ProductionOrder,ProductionOrder.Status::Released,ParentItem,'','',10000,WORKDATE);
      ProdOrderLine.SETRANGE(Status,ProductionOrder.Status);
      ProdOrderLine.SETRANGE("Prod. Order No.",ProductionOrder."No.");
      ProdOrderLine.FINDFIRST;

      // Post Output
      LibraryPatterns.POSTOutputWithItemTracking(ProdOrderLine,2400,2400,WORKDATE,ParentItem."Standard Cost",'','A');
      LibraryPatterns.POSTOutputWithItemTracking(ProdOrderLine,1200,1200,WORKDATE,ParentItem."Standard Cost",'','A');
      LibraryPatterns.POSTOutputWithItemTracking(ProdOrderLine,3600,3600,WORKDATE,ParentItem."Standard Cost",'','B');
      LibraryPatterns.POSTOutputWithItemTracking(ProdOrderLine,2600,2600,WORKDATE,ParentItem."Standard Cost",'','C');
      LibraryPatterns.POSTOutputWithItemTracking(ProdOrderLine,33,33,WORKDATE,ParentItem."Standard Cost",'','D');
      LibraryPatterns.POSTOutputWithItemTracking(ProdOrderLine,69,69,WORKDATE,ParentItem."Standard Cost",'','E');

      // Post Consumption
      LibraryPatterns.POSTConsumption(ProdOrderLine,CompItem,'','',ProductionOrder.Quantity,WORKDATE,CompItem."Unit Cost");

      // Change Prod. Order status
      LibraryManufacturing.ChangeStatusReleasedToFinished(ProductionOrder."No.");

      // Create and post sales order
      CreateAndPostSalesOrderWithItemTracking(ParentItem,ParSecItemUnitOfMeasure.Code);
      IF NOT AutoCostAdjustAlways THEN
        LibraryCosting.AdjustCostItemEntries(STRSUBSTNO('%1|%2',ParentItem."No.",CompItem."No."),'');

      // Change Cost and invoice purch. order
      PurchaseHeader.FIND('=');
      LibraryPurchase.ReopenPurchaseDocument(PurchaseHeader);
      PurchaseLine.FIND('=');
      PurchaseLine.VALIDATE("Direct Unit Cost",PurchaseLine."Direct Unit Cost" - 0.00001);
      PurchaseLine.MODIFY(TRUE);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);
      IF NOT AutoCostAdjustAlways THEN
        LibraryCosting.AdjustCostItemEntries(STRSUBSTNO('%1|%2',ParentItem."No.",CompItem."No."),'');

      LibraryCosting.CheckAdjustment(ParentItem);
      LibraryCosting.CheckAdjustment(CompItem);
Member of Lib.Library - Patterns


POSTPositiveAdjustment@2 Method

The procedure POSTPositiveAdjustment is available in codeunit 132212.

Syntax

POSTPositiveAdjustment@2(
    Item@1005 : Record 27 Item, //Input parameter of type Record
    LocationCode@1004 : Code[10] LocationCode, //Input parameter of type Code
    VariantCode@1003 : Code[10] VariantCode, //Input parameter of type Code
    BinCode@1008 : Code[20] BinCode, //Input parameter of type Code
    Qty@1002 : Decimal Qty, //Input parameter of type Decimal
    PostingDate@1001 : Date PostingDate, //Input parameter of type Date
    UnitAmount@1000 : Decimal UnitAmount //Input parameter of type Decimal
);

Parameters

Item
Input parameter of type Record
LocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code
BinCode
Input parameter of type Code
Qty
Input parameter of type Decimal
PostingDate
Input parameter of type Date
UnitAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: POST, Positive, Adjustment.

For a clarification about how this function works, refer to the code listed below.

      POSTItemJournalLine(ItemJournalTemplate.Type::Item,
        ItemJournalLine."Entry Type"::"Positive Adjmt.",
        Item,
        LocationCode,
        VariantCode,
        BinCode,
        Qty,
        PostingDate,
        UnitAmount);

Example

The below example is extracted from the test automation codeunit 136121 to show one way of using this function.

      // [FEATURE] [Automatic Reservation] [Sales Order]
      // [SCENARIO 363178] Reserved Quantity on Sales Order Subform is set automatically for Automatic Reservation
      Initialize;
      Quantity := LibraryRandom.RandDec(10,2);

      // [GIVEN] Item on Inventory with Reserve = Optional
      CreateItemWithReserve(Item,Item.Reserve::Optional);
      LibraryPatterns.POSTPositiveAdjustment(Item,'','','',Quantity,WORKDATE,LibraryRandom.RandDec(10,2));

      // [GIVEN] Sales Order for Customer with Reserve = Always
      CreateSalesOrderLineByPage(SalesOrder,CreateCustomerWithReserveAlways,Item."No.");

      // [WHEN] Set Quantity on Sales Order Subform to "Q"
      SalesOrder.SalesLines.Quantity.SETVALUE(Quantity);

      // [THEN] Reserved Quantity on Sales Order Subform is "Q"
      SalesOrder.SalesLines."Reserved Quantity".ASSERTEQUALS(Quantity);
Member of Lib.Library - Patterns


POSTPositiveAdjustmentAmount@1021 Method

The procedure POSTPositiveAdjustmentAmount is available in codeunit 132212.

Syntax

POSTPositiveAdjustmentAmount@1021(
    Item@1005 : Record 27 Item, //Input parameter of type Record
    LocationCode@1004 : Code[10] LocationCode, //Input parameter of type Code
    VariantCode@1003 : Code[10] VariantCode, //Input parameter of type Code
    Qty@1002 : Decimal Qty, //Input parameter of type Decimal
    PostingDate@1001 : Date PostingDate, //Input parameter of type Date
    Amount@1008 : Decimal Amount //Input parameter of type Decimal
);

Parameters

Item
Input parameter of type Record
LocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code
Qty
Input parameter of type Decimal
PostingDate
Input parameter of type Date
Amount
Input parameter of type Decimal

Remarks

The relevant search keywords are: POST, Positive, Adjustment, Amount.

For a clarification about how this function works, refer to the code listed below.

      LibraryInventory.CreateItemJournalBatchByType(ItemJournalBatch,ItemJournalTemplate.Type::Item);
      MAKEItemJournalLine(ItemJournalLine,ItemJournalBatch,Item,LocationCode,VariantCode,PostingDate,
        ItemJournalLine."Entry Type"::"Positive Adjmt.",Qty,0);
      ItemJournalLine.VALIDATE(Amount,Amount);
      ItemJournalLine.MODIFY;
      LibraryInventory.PostItemJournalBatch(ItemJournalBatch);

Example

The below example is extracted from the test automation codeunit 137616 to show one way of using this function.

      Initialize;

      // Setup: Create item, add to inventory then remove, generating a rounding entry.
      LibraryPatterns.MAKEItemSimple(Item,Item."Costing Method"::FIFO,0);
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location);
      LibraryPatterns.POSTPositiveAdjustmentAmount(Item,Location.Code,'',3,WORKDATE,10);
      LibraryPatterns.POSTNegativeAdjustment(Item,Location.Code,'','',1,WORKDATE,0);
      LibraryPatterns.POSTNegativeAdjustment(Item,Location.Code,'','',1,WORKDATE,0);
      LibraryPatterns.POSTNegativeAdjustment(Item,Location.Code,'','',1,WORKDATE,0);

      // Setup dimension with code mandatory for Inventory account.
      InventoryPostingSetup.GET(Location.Code,Item."Inventory Posting Group");
      LibraryDimension.CreateDimension(Dimension);
      LibraryDimension.CreateDimensionValue(DimensionValue,Dimension.Code);
      LibraryDimension.CreateDefaultDimensionGLAcc(DefaultDimension,InventoryPostingSetup."Inventory Account",
        Dimension.Code,DimensionValue.Code);
      DefaultDimension.VALIDATE("Value Posting",DefaultDimension."Value Posting"::"Code Mandatory");
      DefaultDimension.MODIFY(TRUE);

      // Exercise: Adjust.
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');

      // Verify: No error expected in adjustment.
      LibraryCosting.CheckAdjustment(Item);

      // Tear down
      DefaultDimension.DELETE(TRUE);
Member of Lib.Library - Patterns


POSTPositiveAdjustmentWithItemTracking@99 Method

The procedure POSTPositiveAdjustmentWithItemTracking is available in codeunit 132212.

Syntax

POSTPositiveAdjustmentWithItemTracking@99(
    Item@1005 : Record 27 Item, //Input parameter of type Record
    LocationCode@1004 : Code[10] LocationCode, //Input parameter of type Code
    VariantCode@1003 : Code[10] VariantCode, //Input parameter of type Code
    Qty@1002 : Decimal Qty, //Input parameter of type Decimal
    PostingDate@1001 : Date PostingDate, //Input parameter of type Date
    SerialNo@1008 : Code[20] SerialNo, //Input parameter of type Code
    LotNo@1010 : Code[20] LotNo //Input parameter of type Code
);

Parameters

Item
Input parameter of type Record
LocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code
Qty
Input parameter of type Decimal
PostingDate
Input parameter of type Date
SerialNo
Input parameter of type Code
LotNo
Input parameter of type Code

Remarks

The relevant search keywords are: POST, Positive, Adjustment, Item, Tracking.

For a clarification about how this function works, refer to the code listed below.

      LibraryInventory.CreateItemJournalBatchByType(ItemJournalBatch,ItemJournalTemplate.Type::Item);
      MAKEItemJournalLine(ItemJournalLine,ItemJournalBatch,Item,LocationCode,VariantCode,PostingDate,
        ItemJournalLine."Entry Type"::"Positive Adjmt.",Qty,0);
      LibraryItemTracking.CreateItemJournalLineItemTracking(ReservEntry,ItemJournalLine,SerialNo,LotNo,Qty);
      LibraryInventory.PostItemJournalBatch(ItemJournalBatch);

Example

The below example is extracted from the test automation codeunit 137150 to show one way of using this function.

      ILEQuantity := 10;

      // Setup : Create lot tracked item, with additional UOM used for put-away.
      Initialize;
      CreateItem(Item,ItemTrackingCode.Code);
      CreateItemUnitOfMeasure(ItemUnitOfMeasure,Item."No.",QtyPerUOM);
      UpdateItemUOM(Item,Item."Base Unit of Measure",Item."Base Unit of Measure",ItemUnitOfMeasure.Code);

      // Post positive adjustment in non-warehouse location.
      LotNo1 := LibraryUtility.GenerateRandomCode(WarehouseActivityLine.FIELDNO("Lot No."),DATABASE::"Warehouse Activity Line");
      LibraryPatterns.POSTPositiveAdjustmentWithItemTracking(Item,LocationBlue.Code,'',ILEQuantity,WORKDATE,'',LotNo1);
      LibraryPatterns.POSTPositiveAdjustmentWithItemTracking(Item,LocationBlue.Code,'',ILEQuantity,WORKDATE,'',LotNo1);

      LotNo2 := LibraryUtility.GenerateRandomCode(WarehouseActivityLine.FIELDNO("Lot No."),DATABASE::"Warehouse Activity Line");
      LibraryPatterns.POSTPositiveAdjustmentWithItemTracking(Item,LocationBlue.Code,'',ILEQuantity,WORKDATE,'',LotNo2);
      LibraryPatterns.POSTPositiveAdjustmentWithItemTracking(Item,LocationBlue.Code,'',ILEQuantity,WORKDATE,'',LotNo2);

      // Create transfer order to WHITE, post shipment, create whse. receipt.
      CreateAndReleaseTransferOrder(TransferHeader,LocationBlue.Code,LocationWhite.Code,Item."No.",TransferQty,ItemUnitOfMeasure.Code);
      TransferLine.SETRANGE("Document No.",TransferHeader."No.");
      TransferLine.FINDFIRST;

      // Split the transfer quantity across lots or not.
      IF TransferQty * QtyPerUOM <= 2 * ILEQuantity THEN
        LibraryItemTracking.CreateTransferOrderItemTracking(ReservEntry,TransferLine,'',LotNo1,TransferQty * QtyPerUOM)
      ELSE BEGIN
        LibraryItemTracking.CreateTransferOrderItemTracking(ReservEntry,TransferLine,'',LotNo1,2 * ILEQuantity);
        LibraryItemTracking.CreateTransferOrderItemTracking(
          ReservEntry,TransferLine,'',LotNo2,TransferQty * QtyPerUOM - 2 * ILEQuantity);
      END;
      LibraryWarehouse.PostTransferOrder(TransferHeader,TRUE,FALSE);

      LibraryWarehouse.CreateWhseReceiptFromTO(TransferHeader);

      // Force cross-dock.
      IF CrossDockQty > 0 THEN
        CreateAndReleaseSalesOrder(SalesHeader,SalesLine,Item."No.",Item."Base Unit of Measure",LocationWhite.Code,CrossDockQty,FALSE);
      FindWarehouseReceiptLine(WarehouseReceiptLine,WarehouseReceiptLine."Source Document"::"Inbound Transfer",TransferHeader."No.");
      LibraryWarehouse.CalculateCrossDockLines(
        WhseCrossDockOpportunity,'',WarehouseReceiptLine."No.",WarehouseReceiptLine."Location Code");

      // Exercise: Post receipt.
      LibraryVariableStorage.Enqueue(STRSUBSTNO(TransferOrderDeleted,TransferHeader."No."));  // Enqueue for MessageHandler.
      PostWarehouseReceipt(WarehouseReceiptLine."No.");

      // Verify: Put-away lines.
      // Put-away is not split across lots.
      IF TransferQty * QtyPerUOM <= 2 * ILEQuantity THEN BEGIN
        VerifyWhseActivityLine(
          WarehouseActivityLine,TransferHeader."No.",LotNo1,WarehouseActivityLine."Action Type"::Take,TransferQty * QtyPerUOM);

        IF CrossDockQty > 0 THEN BEGIN
          WarehouseActivityLine.SETRANGE("Bin Code",LocationWhite."Cross-Dock Bin Code");
          VerifyWhseActivityLine(
            WarehouseActivityLine,TransferHeader."No.",LotNo1,WarehouseActivityLine."Action Type"::Place,CrossDockQty);

          WarehouseActivityLine.SETFILTER("Bin Code",'<>%1',LocationWhite."Cross-Dock Bin Code");
          VerifyWhseActivityLine(
            WarehouseActivityLine,TransferHeader."No.",LotNo1,WarehouseActivityLine."Action Type"::Place,
            TransferQty * QtyPerUOM - CrossDockQty);
        END ELSE BEGIN
          WarehouseActivityLine.SETFILTER("Bin Code",'<>%1',LocationWhite."Cross-Dock Bin Code");
          VerifyWhseActivityLine(
            WarehouseActivityLine,TransferHeader."No.",LotNo1,WarehouseActivityLine."Action Type"::Place,TransferQty * QtyPerUOM);
        END;

        // Put-away is split across lots.
      END ELSE BEGIN
        VerifyWhseActivityLine(
          WarehouseActivityLine,TransferHeader."No.",LotNo1,WarehouseActivityLine."Action Type"::Take,2 * ILEQuantity);
        VerifyWhseActivityLine(
          WarehouseActivityLine,TransferHeader."No.",LotNo2,WarehouseActivityLine."Action Type"::Take,
          TransferQty * QtyPerUOM - 2 * ILEQuantity);

        // How is the cross dock qty distributed across lots?
        CASE TRUE OF
          (CrossDockQty > 0) AND (CrossDockQty <= 2 * ILEQuantity):
            // Cross dock qty consumes only from Lot 1.
            BEGIN
              WarehouseActivityLine.SETRANGE("Bin Code",LocationWhite."Cross-Dock Bin Code");
              VerifyWhseActivityLine(
                WarehouseActivityLine,TransferHeader."No.",LotNo1,WarehouseActivityLine."Action Type"::Place,CrossDockQty);

              WarehouseActivityLine.SETFILTER("Bin Code",'<>%1',LocationWhite."Cross-Dock Bin Code");
              VerifyWhseActivityLine(
                WarehouseActivityLine,TransferHeader."No.",LotNo1,WarehouseActivityLine."Action Type"::Place,
                2 * ILEQuantity - CrossDockQty);
              VerifyWhseActivityLine(
                WarehouseActivityLine,TransferHeader."No.",LotNo2,WarehouseActivityLine."Action Type"::Place,
                TransferQty * QtyPerUOM - 2 * ILEQuantity);
            END;
          (CrossDockQty > 0) AND (CrossDockQty > 2 * ILEQuantity) AND (CrossDockQty <= TransferQty * QtyPerUOM):
            // Cross dock qty consumes Lot 1 entirely and Lot 2 partially.
            BEGIN
              WarehouseActivityLine.SETRANGE("Bin Code",LocationWhite."Cross-Dock Bin Code");
              VerifyWhseActivityLine(
                WarehouseActivityLine,TransferHeader."No.",LotNo1,WarehouseActivityLine."Action Type"::Place,2 * ILEQuantity);
              VerifyWhseActivityLine(
                WarehouseActivityLine,TransferHeader."No.",LotNo2,WarehouseActivityLine."Action Type"::Place,
                CrossDockQty - 2 * ILEQuantity);

              WarehouseActivityLine.SETFILTER("Bin Code",'<>%1',LocationWhite."Cross-Dock Bin Code");
              VerifyWhseActivityLine(
                WarehouseActivityLine,TransferHeader."No.",LotNo2,WarehouseActivityLine."Action Type"::Place,
                TransferQty * QtyPerUOM - CrossDockQty);
              ASSERTERROR VerifyWhseActivityLine(
                  WarehouseActivityLine,TransferHeader."No.",LotNo1,WarehouseActivityLine."Action Type"::Place,0);
              Assert.AssertNothingInsideFilter;
            END;
          (CrossDockQty > 0) AND (CrossDockQty > 2 * ILEQuantity) AND (CrossDockQty > TransferQty * QtyPerUOM):
            // Cross dock qty consumes both Lot 1 and Lot 2.
            BEGIN
              WarehouseActivityLine.SETRANGE("Bin Code",LocationWhite."Cross-Dock Bin Code");
              VerifyWhseActivityLine(
                WarehouseActivityLine,TransferHeader."No.",LotNo1,WarehouseActivityLine."Action Type"::Place,2 * ILEQuantity);
              VerifyWhseActivityLine(
                WarehouseActivityLine,TransferHeader."No.",LotNo2,WarehouseActivityLine."Action Type"::Place,
                TransferQty * QtyPerUOM - 2 * ILEQuantity);

              WarehouseActivityLine.SETFILTER("Bin Code",'<>%1',LocationWhite."Cross-Dock Bin Code");
              ASSERTERROR VerifyWhseActivityLine(
                  WarehouseActivityLine,TransferHeader."No.",LotNo1,WarehouseActivityLine."Action Type"::Place,0);
              Assert.AssertNothingInsideFilter;
              ASSERTERROR VerifyWhseActivityLine(
                  WarehouseActivityLine,TransferHeader."No.",LotNo2,WarehouseActivityLine."Action Type"::Place,0);
              Assert.AssertNothingInsideFilter;
            END;
          CrossDockQty = 0:
            BEGIN
              VerifyWhseActivityLine(
                WarehouseActivityLine,TransferHeader."No.",LotNo1,WarehouseActivityLine."Action Type"::Place,2 * ILEQuantity);
              VerifyWhseActivityLine(
                WarehouseActivityLine,TransferHeader."No.",LotNo2,WarehouseActivityLine."Action Type"::Place,
                TransferQty * QtyPerUOM - 2 * ILEQuantity);
            END;
        END;
      END;
Member of Lib.Library - Patterns


POSTPurchaseJournal@6 Method

The procedure POSTPurchaseJournal is available in codeunit 132212.

Syntax

POSTPurchaseJournal@6(
    Item@1005 : Record 27 Item, //Input parameter of type Record
    LocationCode@1004 : Code[10] LocationCode, //Input parameter of type Code
    VariantCode@1003 : Code[10] VariantCode, //Input parameter of type Code
    BinCode@1008 : Code[20] BinCode, //Input parameter of type Code
    Qty@1002 : Decimal Qty, //Input parameter of type Decimal
    PostingDate@1001 : Date PostingDate, //Input parameter of type Date
    UnitAmount@1000 : Decimal UnitAmount //Input parameter of type Decimal
);

Parameters

Item
Input parameter of type Record
LocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code
BinCode
Input parameter of type Code
Qty
Input parameter of type Decimal
PostingDate
Input parameter of type Date
UnitAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: POST, Purchase, Journal.

For a clarification about how this function works, refer to the code listed below.

      POSTItemJournalLine(ItemJournalTemplate.Type::Item,
        ItemJournalLine."Entry Type"::Purchase,
        Item,
        LocationCode,
        VariantCode,
        BinCode,
        Qty,
        PostingDate,
        UnitAmount);

Example

The below example is extracted from the test automation codeunit 137612 to show one way of using this function.

      // Automation of 343200 repro:
      // verify that valuation date is not changed after ACIE for production order posted in 2 iterations on different dates

      // Update Inventory Setup: set Average Cost Period = Month
      SetAvgCostingPeriodInInvSetup(InventorySetup,InventorySetup."Average Cost Period"::Month);

      // Create component item. Costing Method = Average, Replenishment System = Purchase
      CreateItemWithAvgCosting(ComponentItem,ComponentItem."Replenishment System"::Purchase);

      // Create production item. Costing Method = Average, Replenishment System = Production order
      CreateItemWithAvgCosting(ProdItem,ProdItem."Replenishment System"::"Prod. Order");
      // Create BOM and assign to the production item
      CreateProductionBOM(ProductionBOMHeader,ProdItem,ComponentItem,ProdItem."Base Unit of Measure",'',1,0);
      ProdItem.VALIDATE("Production BOM No.",ProductionBOMHeader."No.");
      ProdItem.MODIFY(TRUE);

      // We need at least 2 components available for the production order
      LibraryPatterns.POSTPurchaseJournal(ComponentItem,'','','',2,WORKDATE,ProdItem."Unit Cost");

      CreateReleaseProdOrderWithLine(ProdOrder,ProdOrderLine,ProdItem,2);
      ProductionJnlMgt.CreateJnlLines(ProdOrder,ProdOrderLine."Line No.");

      // Posting consumption and output in 2 iterations with a one day delay
      LibraryPatterns.POSTConsumption(ProdOrderLine,ComponentItem,'','',1,WORKDATE,ComponentItem."Unit Cost");
      LibraryPatterns.POSTOutput(ProdOrderLine,1,WORKDATE,ProdItem."Unit Cost");
      LibraryPatterns.POSTConsumption(ProdOrderLine,ComponentItem,'','',1,CALCDATE('<+1D>',WORKDATE),ComponentItem."Unit Cost");
      LibraryPatterns.POSTOutput(ProdOrderLine,1,CALCDATE('<+1D>',WORKDATE),ProdItem."Unit Cost");

      ProdOrder.GET(ProdOrder.Status,ProdOrder."No.");
      LibraryManufacturing.ChangeStatusReleasedToFinished(ProdOrder."No.");

      LibraryCosting.AdjustCostItemEntries(ProdItem."No.",'');

      // Verify valuation dates in value entries
      VerifyValuationDatesInVE(ProdItem."No.");

      // Teardown:
      SetAvgCostingPeriodInInvSetup(InventorySetup,InventorySetup."Average Cost Period");
Member of Lib.Library - Patterns


POSTPurchaseOrder@9 Method

The procedure POSTPurchaseOrder is available in codeunit 132212.

Syntax

POSTPurchaseOrder@9(
    VAR PurchaseHeader@1011 : Record 38 PurchaseHeader, //Reference parameter of type Record
    Item@1008 : Record 27 Item, //Input parameter of type Record
    LocationCode@1007 : Code[10] LocationCode, //Input parameter of type Code
    VariantCode@1006 : Code[10] VariantCode, //Input parameter of type Code
    Qty@1005 : Decimal Qty, //Input parameter of type Decimal
    PostingDate@1004 : Date PostingDate, //Input parameter of type Date
    DirectUnitCost@1003 : Decimal DirectUnitCost, //Input parameter of type Decimal
    Receive@1009 : Boolean Receive, //Input parameter of type Boolean
    Invoice@1010 : Boolean Invoice //Input parameter of type Boolean
);

Parameters

PurchaseHeader
Reference parameter of type Record
Item
Input parameter of type Record
LocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code
Qty
Input parameter of type Decimal
PostingDate
Input parameter of type Date
DirectUnitCost
Input parameter of type Decimal
Receive
Input parameter of type Boolean
Invoice
Input parameter of type Boolean

Remarks

The relevant search keywords are: POST, Purchase, Order.

For a clarification about how this function works, refer to the code listed below.

      POSTPurchaseOrderPartially(PurchaseHeader,Item,LocationCode,VariantCode,Qty,PostingDate,DirectUnitCost,Receive,Qty,Invoice,Qty);

Example

The below example is extracted from the test automation codeunit 137011 to show one way of using this function.

      // [FEATURE] [Calculate Inventory Value] [Average Costing Method] [Unit Cost]
      // [SCENARIO 209978] Expected cost should not be included in average cost calculation for item with Costing Method = Average.
      Initialize;
      ExecuteUIHandlers;
      LibraryInventory.UpdateInventorySetup(
        InventorySetup,FALSE,FALSE,InventorySetup."Automatic Cost Adjustment"::Never,
        InventorySetup."Average Cost Calc. Type"::"Item & Location & Variant",InventorySetup."Average Cost Period"::Day);

      // [GIVEN] Item with Costing Method = Average.
      LibraryPatterns.MAKEItemSimple(Item,Item."Costing Method"::Average,0);

      // [GIVEN] Two purchase orders "P1" and "P2" for the item.
      // [GIVEN] "P1" is received and invoiced, "P2" is received but not invoiced.
      Qty := LibraryRandom.RandInt(10);
      FOR i := 1 TO 2 DO
        UnitCost[i] := LibraryRandom.RandDec(100,2);
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location);

      PostingDate := LibraryFiscalYear.GetFirstPostingDate(FALSE);
      LibraryPatterns.POSTPurchaseOrder(PurchaseHeader,Item,Location.Code,'',Qty,PostingDate,UnitCost[1],TRUE,TRUE);
      LibraryPatterns.POSTPurchaseOrder(PurchaseHeader,Item,Location.Code,'',Qty,PostingDate,UnitCost[2],TRUE,FALSE);

      // [WHEN] Calculate inventory value in revaluation journal for the item.
      CreateRevaluationJournalAndCalcInventoryValueByLocAndVar(Item);

      // [THEN] Unit Cost on the revaluation journal line is equal to the direct unit cost in "P1".
      FilterRevaluationJournalLine(ItemJournalLine,Item."No.",Location.Code);
      VerifyRevaluationJournalLine(ItemJournalLine,Qty,UnitCost[1]);
Member of Lib.Library - Patterns


POSTPurchaseOrderPartially@46 Method

The procedure POSTPurchaseOrderPartially is available in codeunit 132212.

Syntax

POSTPurchaseOrderPartially@46(
    VAR PurchaseHeader@1011 : Record 38 PurchaseHeader, //Reference parameter of type Record
    Item@1008 : Record 27 Item, //Input parameter of type Record
    LocationCode@1007 : Code[10] LocationCode, //Input parameter of type Code
    VariantCode@1006 : Code[10] VariantCode, //Input parameter of type Code
    Qty@1005 : Decimal Qty, //Input parameter of type Decimal
    PostingDate@1004 : Date PostingDate, //Input parameter of type Date
    DirectUnitCost@1003 : Decimal DirectUnitCost, //Input parameter of type Decimal
    Receive@1009 : Boolean Receive, //Input parameter of type Boolean
    ReceiveQty@1002 : Decimal ReceiveQty, //Input parameter of type Decimal
    Invoice@1010 : Boolean Invoice, //Input parameter of type Boolean
    InvoiceQty@1001 : Decimal InvoiceQty //Input parameter of type Decimal
);

Parameters

PurchaseHeader
Reference parameter of type Record
Item
Input parameter of type Record
LocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code
Qty
Input parameter of type Decimal
PostingDate
Input parameter of type Date
DirectUnitCost
Input parameter of type Decimal
Receive
Input parameter of type Boolean
ReceiveQty
Input parameter of type Decimal
Invoice
Input parameter of type Boolean
InvoiceQty
Input parameter of type Decimal

Remarks

The relevant search keywords are: POST, Purchase, Order, Partially.

For a clarification about how this function works, refer to the code listed below.

      MAKEPurchaseOrder(PurchaseHeader,PurchaseLine,Item,LocationCode,VariantCode,Qty,PostingDate,DirectUnitCost);
      PurchaseLine.VALIDATE("Qty. to Receive",ReceiveQty);
      PurchaseLine.VALIDATE("Qty. to Invoice",InvoiceQty);
      PurchaseLine.MODIFY;
      IF Invoice THEN
        SetVendorDocNo(PurchaseHeader);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,Receive,Invoice);

Example

The below example is extracted from the test automation codeunit 137011 to show one way of using this function.

      // [FEATURE] [Calculate Inventory Value] [Average Costing Method] [Unit Cost]
      // [SCENARIO 209978] Average cost calculation should include only actual cost posted no later than the revaluation date.
      Initialize;
      ExecuteUIHandlers;
      LibraryInventory.UpdateInventorySetup(
        InventorySetup,FALSE,FALSE,InventorySetup."Automatic Cost Adjustment"::Never,
        InventorySetup."Average Cost Calc. Type"::"Item & Location & Variant",InventorySetup."Average Cost Period"::Day);

      // [GIVEN] Item with Costing Method = Average.
      LibraryPatterns.MAKEItemSimple(Item,Item."Costing Method"::Average,0);

      // [GIVEN] Partially posted purchase order on WORKDATE.
      // [GIVEN] Received quantity = invoiced quantity = "q". Full quantity of the purchase line = "Q".
      // [GIVEN] Direct Unit Cost on the purchase line = "X".
      FOR i := 1 TO ARRAYLEN(Qty) DO BEGIN
        Qty[i] := LibraryRandom.RandInt(10);
        UnitCost[i] := LibraryRandom.RandDec(100,2);
      END;
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location);
      LibraryPatterns.POSTPurchaseOrderPartially(
        PurchaseHeader,Item,Location.Code,'',Qty[1] + Qty[2],LibraryFiscalYear.GetFirstPostingDate(FALSE),
        UnitCost[1],TRUE,Qty[1],TRUE,Qty[1]);

      // [GIVEN] Direct Unit Cost on the purchase line is updated to "Y".
      // [GIVEN] Remaining quantity ("Q" - "q") in the purchase is received and invoiced.
      UpdatePostingDateAndVendorInvoiceNoOnPurchaseHeader(PurchaseHeader);
      UpdateDirectUnitCostOnPurchaseLine(PurchaseHeader,UnitCost[2]);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

      // [WHEN] Calculate inventory value in revaluation journal for the item.
      CreateRevaluationJournalAndCalcInventoryValueByLocAndVar(Item);

      // [THEN] Unit Cost on the revaluation journal line is equal to "X".
      FilterRevaluationJournalLine(ItemJournalLine,Item."No.",Location.Code);
      VerifyRevaluationJournalLine(ItemJournalLine,Qty[1],UnitCost[1]);
Member of Lib.Library - Patterns


POSTPurchaseOrderWithItemTracking@96 Method

The procedure POSTPurchaseOrderWithItemTracking is available in codeunit 132212.

Syntax

POSTPurchaseOrderWithItemTracking@96(
    VAR PurchaseHeader@1011 : Record 38 PurchaseHeader, //Reference parameter of type Record
    Item@1008 : Record 27 Item, //Input parameter of type Record
    LocationCode@1007 : Code[10] LocationCode, //Input parameter of type Code
    VariantCode@1006 : Code[10] VariantCode, //Input parameter of type Code
    Qty@1005 : Decimal Qty, //Input parameter of type Decimal
    PostingDate@1004 : Date PostingDate, //Input parameter of type Date
    DirectUnitCost@1003 : Decimal DirectUnitCost, //Input parameter of type Decimal
    Receive@1009 : Boolean Receive, //Input parameter of type Boolean
    Invoice@1010 : Boolean Invoice, //Input parameter of type Boolean
    SerialNo@1002 : Code[20] SerialNo, //Input parameter of type Code
    LotNo@1012 : Code[20] LotNo //Input parameter of type Code
);

Parameters

PurchaseHeader
Reference parameter of type Record
Item
Input parameter of type Record
LocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code
Qty
Input parameter of type Decimal
PostingDate
Input parameter of type Date
DirectUnitCost
Input parameter of type Decimal
Receive
Input parameter of type Boolean
Invoice
Input parameter of type Boolean
SerialNo
Input parameter of type Code
LotNo
Input parameter of type Code

Remarks

The relevant search keywords are: POST, Purchase, Order, Item, Tracking.

For a clarification about how this function works, refer to the code listed below.

      MAKEPurchaseOrder(PurchaseHeader,PurchaseLine,Item,LocationCode,VariantCode,Qty,PostingDate,DirectUnitCost);
      PurchaseLine.VALIDATE("Qty. to Receive",Qty);
      PurchaseLine.VALIDATE("Qty. to Invoice",Qty);
      PurchaseLine.MODIFY;
      LibraryItemTracking.CreatePurchOrderItemTracking(ReservEntry,PurchaseLine,SerialNo,LotNo,Qty);
      IF Invoice THEN
        SetVendorDocNo(PurchaseHeader);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,Receive,Invoice);

Example

The below example is extracted from the test automation codeunit 137616 to show one way of using this function.

      Initialize;

      // Setup. Create lot tracked item. Purchase and adjust inventory.
      LibraryPatterns.MAKEItemSimple(Item,Item."Costing Method"::FIFO,LibraryRandom.RandDec(10,2));
      LibraryItemTracking.CreateItemTrackingCode(ItemTrackingCode,FALSE,TRUE);
      Item.VALIDATE("Item Tracking Code",ItemTrackingCode.Code);
      Item.MODIFY;

      LotNo := LibraryUtility.GenerateRandomCode(ReservationEntry.FIELDNO("Lot No."),DATABASE::"Reservation Entry");
      Qty := LibraryRandom.RandDecInRange(100,200,2);
      LibraryPatterns.POSTPurchaseOrderWithItemTracking(PurchaseHeader,Item,'','',Qty,WORKDATE,0,TRUE,FALSE,'',LotNo);
      LibraryPatterns.POSTNegativeAdjustmentWithItemTracking(Item,'','',Qty - 50,WORKDATE,'',LotNo);
      LibraryPatterns.InsertTempILEFromLast(TempItemLedgerEntry);

      LibraryInventory.CreateItemJournalBatchByType(ItemJournalBatch,ItemJournalTemplate.Type::Item);
      LibraryPatterns.MAKEItemJournalLine(ItemJournalLine,ItemJournalBatch,Item,'','',WORKDATE,
        ItemJournalLine."Entry Type"::"Positive Adjmt.",Qty - 75,0);

      // Exercise. Try to apply from the journal.
      ASSERTERROR ItemJournalLine.VALIDATE("Applies-from Entry",TempItemLedgerEntry."Entry No.");

      // Verify. Journal line cannot be posted.
      Assert.ExpectedError(ApplErr);
Member of Lib.Library - Patterns


POSTReclassificationJournalLine@82 Method

The procedure POSTReclassificationJournalLine is available in codeunit 132212.

Syntax

POSTReclassificationJournalLine@82(
    Item@1000 : Record 27 Item, //Input parameter of type Record
    StartDate@1001 : Date StartDate, //Input parameter of type Date
    FromLocationCode@1004 : Code[10] FromLocationCode, //Input parameter of type Code
    ToLocationCode@1007 : Code[10] ToLocationCode, //Input parameter of type Code
    VariantCode@1005 : Code[10] VariantCode, //Input parameter of type Code
    BinCode@1008 : Code[20] BinCode, //Input parameter of type Code
    NewBinCode@1009 : Code[20] NewBinCode, //Input parameter of type Code
    Quantity@1006 : Decimal Quantity //Input parameter of type Decimal
);

Parameters

Item
Input parameter of type Record
StartDate
Input parameter of type Date
FromLocationCode
Input parameter of type Code
ToLocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code
BinCode
Input parameter of type Code
NewBinCode
Input parameter of type Code
Quantity
Input parameter of type Decimal

Remarks

The relevant search keywords are: POST, Reclassification, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      LibraryInventory.CreateItemJournalBatchByType(ItemJnlBatch,ItemJnlBatch."Template Type"::Transfer);
      MAKEItemReclassificationJournalLine(ItemJnlLine,ItemJnlBatch,Item,VariantCode,FromLocationCode,ToLocationCode,
        BinCode,NewBinCode,StartDate,Quantity);
      LibraryInventory.PostItemJournalBatch(ItemJnlBatch);

Example

The below example is extracted from the test automation codeunit 137603 to show one way of using this function.

      LibraryPatterns.MAKEItem(Item,CostingMethod,StandardCost,3.33,11.33,'');
      LibraryInventory.CreateItemVariant(ItemVariant,Item."No.");
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location1);
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location2);
      LocationCode[1] := Location1.Code;
      LocationCode[2] := Location2.Code;
      LibraryInventory.CreateStockkeepingUnitForLocationAndVariant(StockkeepingUnit,LocationCode[1],Item."No.",'');
      LibraryInventory.CreateStockkeepingUnitForLocationAndVariant(StockkeepingUnit,LocationCode[1],Item."No.",ItemVariant.Code);
      LibraryInventory.CreateStockkeepingUnitForLocationAndVariant(StockkeepingUnit,LocationCode[2],Item."No.",'');
      LibraryInventory.CreateStockkeepingUnitForLocationAndVariant(StockkeepingUnit,LocationCode[2],Item."No.",ItemVariant.Code);

      CreateSetupEntrieswSKU2Loc2Var(Item,TempItemLedgerEntry,WORKDATE,LocationCode,ItemVariant.Code);

      ExecuteRevalueExistingInventory(
        Item,ItemJnlBatch,WORKDATE + 2,CalcPer,CostingMethod <> Item."Costing Method"::Average,
        CostingMethod <> Item."Costing Method"::Average,FALSE,CalculationBase::" ",'','');
      ModifyPostRevaluation(ItemJnlBatch,Item."No.",1.1);
      LibraryCosting.CheckAdjustment(Item);

      LibraryPatterns.POSTReclassificationJournalLine(Item,WORKDATE + 9,'',LocationCode[1],'','','',5);
      LibraryPatterns.POSTReclassificationJournalLine(Item,WORKDATE + 9,LocationCode[2],LocationCode[1],ItemVariant.Code,'','',5);
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');

      ExecuteRevalueExistingInventory(
        Item,ItemJnlBatch,WORKDATE + 9,CalcPer,CostingMethod <> Item."Costing Method"::Average,
        CostingMethod <> Item."Costing Method"::Average,FALSE,CalculationBase::" ",'','');
      ModifyPostRevaluation(ItemJnlBatch,Item."No.",1.1);
      LibraryCosting.CheckAdjustment(Item);
Member of Lib.Library - Patterns


POSTSaleJournal@8 Method

The procedure POSTSaleJournal is available in codeunit 132212.

Syntax

POSTSaleJournal@8(
    Item@1005 : Record 27 Item, //Input parameter of type Record
    LocationCode@1004 : Code[10] LocationCode, //Input parameter of type Code
    VariantCode@1003 : Code[10] VariantCode, //Input parameter of type Code
    BinCode@1008 : Code[10] BinCode, //Input parameter of type Code
    Qty@1002 : Decimal Qty, //Input parameter of type Decimal
    PostingDate@1001 : Date PostingDate, //Input parameter of type Date
    UnitAmount@1000 : Decimal UnitAmount //Input parameter of type Decimal
);

Parameters

Item
Input parameter of type Record
LocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code
BinCode
Input parameter of type Code
Qty
Input parameter of type Decimal
PostingDate
Input parameter of type Date
UnitAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: POST, Sale, Journal.

For a clarification about how this function works, refer to the code listed below.

      POSTItemJournalLine(ItemJournalTemplate.Type::Item,
        ItemJournalLine."Entry Type"::Sale,
        Item,
        LocationCode,
        VariantCode,
        BinCode,
        Qty,
        PostingDate,
        UnitAmount);

Example

The below example is extracted from the test automation codeunit 137606 to show one way of using this function.

      EmptyItem.INIT;
      EmptyProdOrder.INIT;
      VerifyVariance := ProducedItemCostingMethod = ProducedItem1."Costing Method"::Standard;
      InitializeQuantities(QtyCompInProdItem1,QtyCompInProdItem2,QtyProdItem1InProdItem2,ProdOrder1Qty,ProdOrder2Qty,SaleProdItem2Qty);
      SetupItems(
        ComponentItem,ProducedItem1,ProducedItem2,ComponentCostingMethod,ProducedItemCostingMethod,QtyCompInProdItem1,
        QtyCompInProdItem2,QtyProdItem1InProdItem2);
      SetupProdOrders(ProductionOrder1,ProductionOrder2,ProducedItem1,ProducedItem2,ProdOrder1Qty,ProdOrder2Qty,StartDate + 30);

      QtyCompInProdOrder1 := ROUND(QtyCompInProdItem1 * ProdOrder1Qty,ComponentItem."Rounding Precision",'>');
      QtyCompInProdOrder2 := ROUND(QtyCompInProdItem2 * ProdOrder2Qty,ComponentItem."Rounding Precision",'>');
      QtyProdItem1InProdOrder2 := ROUND(QtyProdItem1InProdItem2 * ProdOrder2Qty,ProducedItem1."Rounding Precision",'>');
      PurchaseItemSplitApplication(ComponentItem,QtyCompInProdOrder1,QtyCompInProdOrder2,ComponentItem."Unit Cost",StartDate);

      PostProdOrder1(ProductionOrder1,ComponentItem,ProducedItem1,StartDate + 4,QtyCompInProdOrder1,ProdOrder1Qty,0);
      // Finish Order 1
      LibraryManufacturing.ChangeProdOrderStatus(ProductionOrder1,ProductionOrder1.Status::Finished,StartDate + 10,FALSE);

      // AdjustCost
      LibraryCosting.AdjustCostItemEntries(STRSUBSTNO('%1|%2',ComponentItem."No.",ProducedItem1."No."),'');
      // Verify
      VerifyCost(ComponentItem,EmptyItem,EmptyItem,ProductionOrder1,EmptyProdOrder,VerifyVariance);

      PostProdOrder2(
        ProductionOrder2,ComponentItem,ProducedItem1,ProducedItem2,StartDate + 20,QtyCompInProdOrder2,QtyProdItem1InProdOrder2,
        ProdOrder2Qty);
      // Finish Order 2
      LibraryManufacturing.ChangeProdOrderStatus(ProductionOrder2,ProductionOrder2.Status::Finished,StartDate + 25,FALSE);
      // Sell ProducedItem2
      LibraryPatterns.POSTSaleJournal(ProducedItem2,'','','',SaleProdItem2Qty,StartDate + 30,0);
      // AdjustCost
      LibraryCosting.AdjustCostItemEntries(STRSUBSTNO('%1|%2|%3',ComponentItem."No.",ProducedItem1."No.",ProducedItem2."No."),'');

      // Verify
      VerifyCost(ComponentItem,ProducedItem1,ProducedItem2,EmptyProdOrder,ProductionOrder2,VerifyVariance);
      // Revalue
      IF RevalueBeforeProdOrder1 THEN BEGIN
        // Perform revaluation before consumption of order 1 was posted
        ExecuteRevalueExistingInventory(ComponentItem,ItemJnlBatch,StartDate + 1,CalcPer,FALSE,FALSE,FALSE,CalculationBase::" ",'','');
        LibraryPatterns.ModifyPostRevaluation(ItemJnlBatch,RevaluationFactor);
        LibraryCosting.AdjustCostItemEntries(STRSUBSTNO('%1|%2|%3',ComponentItem."No.",ProducedItem1."No.",ProducedItem2."No."),'');
        // Verify
        VerifyCost(ComponentItem,ProducedItem1,ProducedItem2,ProductionOrder1,ProductionOrder2,VerifyVariance);
      END;

      IF RevalueBeforeProdOrder2 THEN BEGIN
        // Perform revaluation after Order1 was finished, but before consumption of order 2 was posted
        ExecuteRevalueExistingInventory(
          ComponentItem,ItemJnlBatch,StartDate + 15,CalcPer,FALSE,FALSE,FALSE,CalculationBase::" ",'','');
        LibraryPatterns.ModifyPostRevaluation(ItemJnlBatch,RevaluationFactor);
        LibraryCosting.AdjustCostItemEntries(STRSUBSTNO('%1|%2|%3',ComponentItem."No.",ProducedItem1."No.",ProducedItem2."No."),'');
        // Verify
        VerifyCost(ComponentItem,ProducedItem1,ProducedItem2,ProductionOrder1,ProductionOrder2,VerifyVariance);
      END;

      IF RevalueAfterProdOrder2 THEN BEGIN
        // Perform revaluation after Order2 was finished
        ExecuteRevalueExistingInventory(
          ComponentItem,ItemJnlBatch,StartDate + 27,CalcPer,FALSE,FALSE,FALSE,CalculationBase::" ",'','');
        LibraryPatterns.ModifyPostRevaluation(ItemJnlBatch,RevaluationFactor);
        LibraryCosting.AdjustCostItemEntries(STRSUBSTNO('%1|%2|%3',ComponentItem."No.",ProducedItem1."No.",ProducedItem2."No."),'');
        // Verify
        VerifyCost(ComponentItem,ProducedItem1,ProducedItem2,ProductionOrder1,ProductionOrder2,VerifyVariance);
      END;
Member of Lib.Library - Patterns


POSTSalesLine@64 Method

The procedure POSTSalesLine is available in codeunit 132212.

Syntax

POSTSalesLine@64(
    SalesLine@1000 : Record 37 SalesLine, //Input parameter of type Record
    Ship@1002 : Boolean Ship, //Input parameter of type Boolean
    Invoice@1003 : Boolean Invoice //Input parameter of type Boolean
);

Parameters

SalesLine
Input parameter of type Record
Ship
Input parameter of type Boolean
Invoice
Input parameter of type Boolean

Remarks

The relevant search keywords are: POST, Sales, Line.

For a clarification about how this function works, refer to the code listed below.

      SalesHeader.GET(SalesLine."Document Type",SalesLine."Document No.");
      LibrarySales.PostSalesDocument(SalesHeader,Ship,Invoice);

Example

There are no examples available.
Member of Lib.Library - Patterns


POSTSalesOrder@10 Method

The procedure POSTSalesOrder is available in codeunit 132212.

Syntax

POSTSalesOrder@10(
    VAR SalesHeader@1010 : Record 36 SalesHeader, //Reference parameter of type Record
    Item@1009 : Record 27 Item, //Input parameter of type Record
    LocationCode@1008 : Code[10] LocationCode, //Input parameter of type Code
    VariantCode@1007 : Code[10] VariantCode, //Input parameter of type Code
    Qty@1006 : Decimal Qty, //Input parameter of type Decimal
    PostingDate@1005 : Date PostingDate, //Input parameter of type Date
    UnitCost@1004 : Decimal UnitCost, //Input parameter of type Decimal
    Ship@1003 : Boolean Ship, //Input parameter of type Boolean
    Invoice@1001 : Boolean Invoice //Input parameter of type Boolean
);

Parameters

SalesHeader
Reference parameter of type Record
Item
Input parameter of type Record
LocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code
Qty
Input parameter of type Decimal
PostingDate
Input parameter of type Date
UnitCost
Input parameter of type Decimal
Ship
Input parameter of type Boolean
Invoice
Input parameter of type Boolean

Remarks

The relevant search keywords are: POST, Sales, Order.

For a clarification about how this function works, refer to the code listed below.

      POSTSalesOrderPartially(SalesHeader,Item,LocationCode,VariantCode,Qty,PostingDate,UnitCost,Ship,Qty,Invoice,Qty);

Example

The below example is extracted from the test automation codeunit 137018 to show one way of using this function.

      Initialize;
      Qty := 100;
      // Inventory setup for test
      OldInventorySetup.GET;
      SetInventorySetup(
        OldInventorySetup,TRUE,TRUE,TRUE,
        OldInventorySetup."Automatic Cost Adjustment"::Always);

      // make item
      LibraryPatterns.MAKEItemSimple(Item,Item."Costing Method"::FIFO,0);

      // purchase
      LibraryPatterns.POSTPurchaseOrder(PurchaseHeader,Item,'','',Qty,WORKDATE,10,TRUE,FALSE);

      // Sales order - shipment only
      LibraryPatterns.POSTSalesOrder(SalesHeader,Item,'','',Qty,WORKDATE,0,TRUE,FALSE);

      // Now invoice of sales order
      PartialInvoiceOfSales(SalesHeader,Qty / 4);

      PurchaseOrderWithItemCharge(PurchaseHeader,100);
      PurchaseOrderWithItemCharge(PurchaseHeader,200);

      // Now invoice of sales order
      PartialInvoiceOfSales(SalesHeader,Qty / 4);

      // verify correct ValueEntries
      VerifyValueEntries(ValueEntry,75);
      VerifyValueEntries(ValueEntry,250);

      // restore Inventory Setup
      SetInventorySetup(
        OldInventorySetup,FALSE,
        OldInventorySetup."Automatic Cost Posting",
        OldInventorySetup."Expected Cost Posting to G/L",OldInventorySetup."Automatic Cost Adjustment");
Member of Lib.Library - Patterns


POSTSalesOrderPartially@61 Method

The procedure POSTSalesOrderPartially is available in codeunit 132212.

Syntax

POSTSalesOrderPartially@61(
    VAR SalesHeader@1011 : Record 36 SalesHeader, //Reference parameter of type Record
    Item@1010 : Record 27 Item, //Input parameter of type Record
    LocationCode@1009 : Code[10] LocationCode, //Input parameter of type Code
    VariantCode@1008 : Code[10] VariantCode, //Input parameter of type Code
    Qty@1007 : Decimal Qty, //Input parameter of type Decimal
    PostingDate@1006 : Date PostingDate, //Input parameter of type Date
    UnitCost@1005 : Decimal UnitCost, //Input parameter of type Decimal
    Ship@1004 : Boolean Ship, //Input parameter of type Boolean
    ShipQty@1003 : Decimal ShipQty, //Input parameter of type Decimal
    Invoice@1002 : Boolean Invoice, //Input parameter of type Boolean
    InvoiceQty@1001 : Decimal InvoiceQty //Input parameter of type Decimal
);

Parameters

SalesHeader
Reference parameter of type Record
Item
Input parameter of type Record
LocationCode
Input parameter of type Code
VariantCode
Input parameter of type Code
Qty
Input parameter of type Decimal
PostingDate
Input parameter of type Date
UnitCost
Input parameter of type Decimal
Ship
Input parameter of type Boolean
ShipQty
Input parameter of type Decimal
Invoice
Input parameter of type Boolean
InvoiceQty
Input parameter of type Decimal

Remarks

The relevant search keywords are: POST, Sales, Order, Partially.

For a clarification about how this function works, refer to the code listed below.

      MAKESalesOrder(SalesHeader,SalesLine,Item,LocationCode,VariantCode,Qty,PostingDate,UnitCost);
      SalesLine.VALIDATE("Qty. to Ship",ShipQty);
      SalesLine.VALIDATE("Qty. to Invoice",InvoiceQty);
      SalesLine.MODIFY;
      LibrarySales.PostSalesDocument(SalesHeader,Ship,Invoice);

Example

The below example is extracted from the test automation codeunit 137602 to show one way of using this function.

      Initialize;

      InventorySetup.GET;
      InventorySetup."Automatic Cost Adjustment" := InventorySetup."Automatic Cost Adjustment"::Always;
      InventorySetup.MODIFY;

      IsInitialized := FALSE;

      LibraryPatterns.MAKEItem(Item,Item."Costing Method"::FIFO,0,0,0,'');
      Day1 := WORKDATE;
      Loc := '';
      Variant := '';

      LibraryPatterns.POSTPurchaseOrder(PurchaseHeader,Item,Loc,Variant,2,Day1,10,TRUE,TRUE);
      LibraryPatterns.POSTPurchaseOrder(PurchaseHeader,Item,Loc,Variant,2,Day1,20,TRUE,TRUE);

      LibraryPatterns.POSTSalesOrderPartially(SalesHeader,Item,Loc,Variant,2,Day1,100,TRUE,1,TRUE,0.5);

      SalesHeader.GET(SalesHeader."Document Type",SalesHeader."No.");
      LibrarySales.PostSalesDocument(SalesHeader,FALSE,TRUE);

      // Adjustment is done automatic

      // verify
      LibraryCosting.CheckAdjustment(Item);
Member of Lib.Library - Patterns


POSTTransferOrder@85 Method

The procedure POSTTransferOrder is available in codeunit 132212.

Syntax

POSTTransferOrder@85(
    VAR TransferHeader@1010 : Record 5740 TransferHeader, //Reference parameter of type Record
    Item@1009 : Record 27 Item, //Input parameter of type Record
    FromLocation@1008 : Record 14 FromLocation, //Input parameter of type Record
    ToLocation@1000 : Record 14 ToLocation, //Input parameter of type Record
    InTransitLocation@1002 : Record 14 InTransitLocation, //Input parameter of type Record
    VariantCode@1007 : Code[10] VariantCode, //Input parameter of type Code
    Qty@1006 : Decimal Qty, //Input parameter of type Decimal
    PostingDate@1005 : Date PostingDate, //Input parameter of type Date
    ShipmentDate@1011 : Date ShipmentDate, //Input parameter of type Date
    Ship@1003 : Boolean Ship, //Input parameter of type Boolean
    Receive@1001 : Boolean Receive //Input parameter of type Boolean
);

Parameters

TransferHeader
Reference parameter of type Record
Item
Input parameter of type Record
FromLocation
Input parameter of type Record
ToLocation
Input parameter of type Record
InTransitLocation
Input parameter of type Record
VariantCode
Input parameter of type Code
Qty
Input parameter of type Decimal
PostingDate
Input parameter of type Date
ShipmentDate
Input parameter of type Date
Ship
Input parameter of type Boolean
Receive
Input parameter of type Boolean

Remarks

The relevant search keywords are: POST, Transfer, Order.

For a clarification about how this function works, refer to the code listed below.

      MAKETransferOrder(
        TransferHeader,TransferLine,Item,FromLocation,ToLocation,InTransitLocation,VariantCode,Qty,PostingDate,ShipmentDate);
      LibraryWarehouse.PostTransferOrder(TransferHeader,Ship,Receive);

Example

The below example is extracted from the test automation codeunit 137011 to show one way of using this function.

      LibraryPatterns.MAKEItemSimple(Item,Item."Costing Method"::Average,0);
      CreateLocationsForTransfer(FromLocation,ToLocation,InTransitLocation);

      Qty := LibraryRandom.RandInt(10);
      FOR i := 1 TO ARRAYLEN(UnitCost) DO
        UnitCost[i] := LibraryRandom.RandDec(100,2);

      PostingDate := LibraryFiscalYear.GetFirstPostingDate(FALSE);

      LibraryPatterns.POSTPurchaseOrder(PurchaseHeader,Item,FromLocation.Code,'',Qty,PostingDate,UnitCost[1],TRUE,FALSE);
      LibraryPatterns.POSTTransferOrder(
        TransferHeader,Item,FromLocation,ToLocation,InTransitLocation,'',Qty,PostingDate,PostingDate,TRUE,TRUE);

      LibraryPatterns.POSTPurchaseOrder(PurchaseHeader,Item,FromLocation.Code,'',Qty,PostingDate,UnitCost[2],TRUE,TRUE);
      LibraryPatterns.POSTPurchaseOrder(PurchaseHeader,Item,ToLocation.Code,'',Qty,PostingDate,UnitCost[3],TRUE,TRUE);
Member of Lib.Library - Patterns


RandCost@77 Method

The procedure RandCost is available in codeunit 132212.

Syntax

RandCost@77(
    Item@1000 : Record 27 Item //Input parameter of type Record
);

Parameters

Item
Input parameter of type Record

Return Value

Decimal

Remarks

The relevant search keywords are: Random, Cost.

For a clarification about how this function works, refer to the code listed below.

      Precision := LibraryERM.GetAmountRoundingPrecision;
      IF Item."Unit Cost" <> 0 THEN
        EXIT(ROUND(Item."Unit Cost" * RandDec(0,2,5),Precision));
      EXIT(ROUND(RandDec(0,100,5),Precision));

Example

The below example is extracted from the test automation codeunit 137009 to show one way of using this function.

      // [SCENARIO 361672] "Reserved Receipt" in Item Availability by Event is equal to Purchase Line qty. when sales order is reserved against purch. order
      Initialize;
      LibraryWarehouse.CreateLocation(Location);
      LibraryPatterns.MAKEItemSimple(Item,Item."Costing Method"::Standard,LibraryPatterns.RandCost(Item));

      // [GIVEN] Purchase order for item "X", quantity = "Q"
      LibraryPatterns.MAKEPurchaseOrder(
        PurchaseHeader,PurchaseLine,Item,Location.Code,'',LibraryRandom.RandInt(100),WORKDATE,Item."Unit Cost");
      LibraryPurchase.ReleasePurchaseDocument(PurchaseHeader);

      // [GIVEN] Sales order with reservation against purchase order, reserved quantity = "Q"
      LibraryPatterns.MAKESalesOrder(SalesHeader,SalesLine,Item,Location.Code,'',PurchaseLine.Quantity,WORKDATE,Item."Unit Price");

      SalesLine.VALIDATE("Shipment Date",PurchaseLine."Expected Receipt Date");
      SalesLine.MODIFY(TRUE);
      AutoReserveSalesLine(SalesLine);

      // [WHEN] Item availability by event is calculated
      CalculateAvailabilityByEvent(TempInvtPageData,Item);

      // [THEN] "Reserved Receipt" = "Q"
      FindInvtPageData(TempInvtPageData,TempInvtPageData.Type::Purchase);
      Assert.AreEqual(PurchaseLine.Quantity,TempInvtPageData."Reserved Receipt",WrongReservedQtyErr);
Member of Lib.Library - Patterns


RandDec@56 Method

The procedure RandDec is available in codeunit 132212.

Syntax

RandDec@56(
    Min@1000 : Decimal Min, //Input parameter of type Decimal
    Max@1001 : Decimal Max, //Input parameter of type Decimal
    Precision@1002 : Integer Precision //Input parameter of type Integer
);

Parameters

Min
Input parameter of type Decimal
Max
Input parameter of type Decimal
Precision
Input parameter of type Integer

Return Value

Decimal

Remarks

The relevant search keywords are: Random, Decimal.

For a clarification about how this function works, refer to the code listed below.

      Pow := POWER(10,Precision);
      Min2 := ROUND(Min * Pow,1);
      Max2 := ROUND(Max * Pow,1);
      EXIT(ROUND(LibraryRandom.RandDecInRange(Min2,Max2,1) / Pow,1 / Pow));

Example

The below example is extracted from the test automation codeunit 134150 to show one way of using this function.

      // Take Random Values for Purchase Line.
      LibraryPurchase.CreatePurchaseLine(PurchaseLine,PurchaseHeader,Type,No,LibraryRandom.RandDec(10,2));
      PurchaseLine.VALIDATE("Direct Unit Cost",LibraryRandom.RandDec(100,2));
      PurchaseLine.MODIFY(TRUE);
Member of Lib.Library - Patterns


RevaluationJournalCalcInventory@107 Method

The procedure RevaluationJournalCalcInventory is available in codeunit 132212.

Syntax

RevaluationJournalCalcInventory@107(
    VAR ItemJournalBatch@1000 : Record 233 ItemJournalBatch, //Reference parameter of type Record
    VAR Item@1001 : Record 27 Item, //Reference parameter of type Record
    NewPostingDate@1002 : Date NewPostingDate, //Input parameter of type Date
    NewDocNo@1003 : Code[20] NewDocNo, //Input parameter of type Code
    NewCalculatePer@1004 : Option NewCalculatePer, //Input parameter of type Option
    NewByLocation@1005 : Boolean NewByLocation, //Input parameter of type Boolean
    NewByVariant@1006 : Boolean NewByVariant, //Input parameter of type Boolean
    NewUpdStdCost@1007 : Boolean NewUpdStdCost, //Input parameter of type Boolean
    NewCalcBase@1008 : Option NewCalcBase //Input parameter of type Option
);

Parameters

ItemJournalBatch
Reference parameter of type Record
Item
Reference parameter of type Record
NewPostingDate
Input parameter of type Date
NewDocNo
Input parameter of type Code
NewCalculatePer
Input parameter of type Option
NewByLocation
Input parameter of type Boolean
NewByVariant
Input parameter of type Boolean
NewUpdStdCost
Input parameter of type Boolean
NewCalcBase
Input parameter of type Option

Remarks

The relevant search keywords are: Revaluation, Journal, Calc, Inventory.

For a clarification about how this function works, refer to the code listed below.

      COMMIT;
      CalculateInventoryValue.InitializeRequest(NewPostingDate,NewDocNo,TRUE,NewCalculatePer,NewByLocation,NewByVariant,
        NewUpdStdCost,NewCalcBase,TRUE);

      LibraryInventory.CreateItemJournalBatchByType(ItemJournalBatch,ItemJournalBatch."Template Type"::Revaluation);

      ItemJournalLine.INIT;
      ItemJnlMgt.TemplateSelection(PAGE::"Revaluation Journal",3,FALSE,ItemJournalLine,JnlSelected); // 3 = FormTemplate::Revaluation
      ItemJnlMgt.OpenJnl(ItemJournalBatch.Name,ItemJournalLine);

      ItemJournalLine.VALIDATE("Journal Template Name",ItemJournalBatch."Journal Template Name");
      ItemJournalLine.VALIDATE("Journal Batch Name",ItemJournalBatch.Name);
      ItemJournalLine.SetUpNewLine(ItemJournalLine);
      CalculateInventoryValue.SetItemJnlLine(ItemJournalLine);

      IF Item.HASFILTER THEN
        TmpItem.COPYFILTERS(Item)
      ELSE BEGIN
        Item.GET(Item."No.");
        TmpItem.SETRANGE("No.",Item."No.");
      END;
      CalculateInventoryValue.SETTABLEVIEW(TmpItem);
      CalculateInventoryValue.USEREQUESTPAGE(FALSE);
      CalculateInventoryValue.RUNMODAL;

Example

There are no examples available.
Member of Lib.Library - Patterns


SETInventorySetup@16 Method

The procedure SETInventorySetup is available in codeunit 132212.

Syntax

SETInventorySetup@16(
    AutomaticCostAdjustment@1000 : Option AutomaticCostAdjustment, //Input parameter of type Option
    AvgCostCalcType@1001 : Option AvgCostCalcType, //Input parameter of type Option
    AvgCostPeriod@1002 : Option AvgCostPeriod //Input parameter of type Option
);

Parameters

AutomaticCostAdjustment
Input parameter of type Option
AvgCostCalcType
Input parameter of type Option
AvgCostPeriod
Input parameter of type Option

Remarks

The relevant search keywords are: SET, Inventory, Setup.

For a clarification about how this function works, refer to the code listed below.

      InventorySetup.GET;
      InventorySetup."Automatic Cost Posting" := FALSE;
      InventorySetup."Expected Cost Posting to G/L" := FALSE;
      InventorySetup.VALIDATE("Automatic Cost Adjustment",AutomaticCostAdjustment);
      InventorySetup.VALIDATE("Average Cost Calc. Type",AvgCostCalcType);
      InventorySetup.VALIDATE("Average Cost Period",AvgCostPeriod);
      InventorySetup.MODIFY;

Example

The below example is extracted from the test automation codeunit 137616 to show one way of using this function.

      // Refer to PS 33459 (VedbaekSE) & PS 29207 (Navision Corsica) for issue details.
      Initialize;

      // Setup: make item, setup inventory setup, post item journals
      LibraryPatterns.MAKEItemSimple(Item,Item."Costing Method"::Average,0);

      LibraryPatterns.SETInventorySetup(
        InventorySetup."Automatic Cost Adjustment"::Never,InventorySetup."Average Cost Calc. Type"::Item,
        InventorySetup."Average Cost Period"::Month);

      UnitCost := LibraryRandom.RandDecInRange(1,100,2);
      LibraryPatterns.POSTPositiveAdjustment(Item,'','','',800,CALCDATE('<1M>',WORKDATE),UnitCost);
      LibraryPatterns.POSTNegativeAdjustment(Item,'','','',200,CALCDATE('<2M>',WORKDATE),0);
      LibraryPatterns.POSTNegativeAdjustment(Item,'','','',200,CALCDATE('<3M>',WORKDATE),0);
      LibraryPatterns.POSTNegativeAdjustment(Item,'','','',100,CALCDATE('<1Y>',WORKDATE),0);

      // Exercise: Run adjust cost, and verify that no error occurs
      AdjustCostAndVerify(Item."No.",UnitCost);
Member of Lib.Library - Patterns


SETNoSeries@19 Method

The procedure SETNoSeries is available in codeunit 132212.

Syntax

SETNoSeries@19(
      //param element not supplied
);

Remarks

The relevant search keywords are: SET, No, Series.

For a clarification about how this function works, refer to the code listed below.

      NoSeries := LibraryUtility.GetGlobalNoSeriesCode;

      InventorySetup.GET;
      IF InventorySetup."Item Nos." <> NoSeries THEN BEGIN
        InventorySetup.VALIDATE("Item Nos.",NoSeries);
        InventorySetup.MODIFY;
      END;
      IF InventorySetup."Transfer Order Nos." <> NoSeries THEN BEGIN
        InventorySetup.VALIDATE("Transfer Order Nos.",NoSeries);
        InventorySetup.MODIFY;
      END;

      ManufacturingSetup.GET;
      IF ManufacturingSetup."Simulated Order Nos." <> NoSeries THEN BEGIN
        ManufacturingSetup."Simulated Order Nos." := NoSeries;
        ManufacturingSetup.MODIFY;
      END;
      IF ManufacturingSetup."Planned Order Nos." <> NoSeries THEN BEGIN
        ManufacturingSetup."Planned Order Nos." := NoSeries;
        ManufacturingSetup.MODIFY;
      END;
      IF ManufacturingSetup."Firm Planned Order Nos." <> NoSeries THEN BEGIN
        ManufacturingSetup."Firm Planned Order Nos." := NoSeries;
        ManufacturingSetup.MODIFY;
      END;
      IF ManufacturingSetup."Released Order Nos." <> NoSeries THEN BEGIN
        ManufacturingSetup."Released Order Nos." := NoSeries;
        ManufacturingSetup.MODIFY;
      END;

      SalesReceivablesSetup.GET;
      IF SalesReceivablesSetup."Quote Nos." <> NoSeries THEN BEGIN
        SalesReceivablesSetup."Quote Nos." := NoSeries;
        SalesReceivablesSetup.MODIFY;
      END;
      IF SalesReceivablesSetup."Order Nos." <> NoSeries THEN BEGIN
        SalesReceivablesSetup."Order Nos." := NoSeries;
        SalesReceivablesSetup.MODIFY;
      END;
      IF SalesReceivablesSetup."Invoice Nos." <> NoSeries THEN BEGIN
        SalesReceivablesSetup."Invoice Nos." := NoSeries;
        SalesReceivablesSetup.MODIFY;
      END;
      IF SalesReceivablesSetup."Credit Memo Nos." <> NoSeries THEN BEGIN
        SalesReceivablesSetup."Credit Memo Nos." := NoSeries;
        SalesReceivablesSetup.MODIFY;
      END;
      IF SalesReceivablesSetup."Return Order Nos." <> NoSeries THEN BEGIN
        SalesReceivablesSetup."Return Order Nos." := NoSeries;
        SalesReceivablesSetup.MODIFY;
      END;
      IF SalesReceivablesSetup."Customer Nos." <> NoSeries THEN BEGIN
        SalesReceivablesSetup."Customer Nos." := NoSeries;
        SalesReceivablesSetup.MODIFY;
      END;

      MarketingSetup.GET;
      IF MarketingSetup."Contact Nos." <> NoSeries THEN BEGIN
        MarketingSetup."Contact Nos." := NoSeries;
        MarketingSetup.MODIFY;
      END;

Example

The below example is extracted from the test automation codeunit 137353 to show one way of using this function.

      LibrarySetupStorage.Restore;
      LibraryVariableStorage.Clear;

      // Lazy Setup.
      IF isInitialized THEN BEGIN
        WORKDATE := OriginalWorkDate;
        EXIT;
      END;

      OriginalWorkDate := WORKDATE;
      LibraryERM.SetUseLegacyGLEntryLocking(FALSE);
      LibraryERMCountryData.UpdatePurchasesPayablesSetup;
      LibraryERMCountryData.CreateVATData;
      LibraryERMCountryData.UpdateGeneralLedgerSetup;
      LibraryERMCountryData.UpdateGeneralPostingSetup;
      LibraryPatterns.SETNoSeries;
      isInitialized := TRUE;
      COMMIT;
      LibrarySetupStorage.Save(DATABASE::"General Ledger Setup");
Member of Lib.Library - Patterns


Library - Payment Export Class

Lib.Library - Payment Export

COD130100 applies to ERM,W1,AT,AU,BE,CA,DE,ES,FI,FR,GB,IN,IS,IT,NL,NO,SE,NZ,MX,US,RU,CZ.

Methods

Name | Description
CreateBankAccount@6 | The procedure CreateBankAccount is available in codeunit 130100.
CreateBankExportImportSetup@10 | The procedure CreateBankExportImportSetup is available in codeunit 130100.
CreateGenJournalBatch@7 | The procedure CreateGenJournalBatch is available in codeunit 130100.
CreatePaymentExportBatch@5 | The procedure CreatePaymentExportBatch is available in codeunit 130100.
CreatePaymentMethod@1 | The procedure CreatePaymentMethod is available in codeunit 130100.
CreateSimpleDataExchDefWithMapping@28 | The procedure CreateSimpleDataExchDefWithMapping is available in codeunit 130100.
CreateSimpleDataExchDefWithMapping2@16 | The procedure CreateSimpleDataExchDefWithMapping2 is available in codeunit 130100.
CreateVendorPmtJnlLine@9 | The procedure CreateVendorPmtJnlLine is available in codeunit 130100.
CreateVendorWithBankAccount@4 | The procedure CreateVendorWithBankAccount is available in codeunit 130100.
GetRandomCreditorNo@2 | The procedure GetRandomCreditorNo is available in codeunit 130100.
GetRandomPaymentReference@3 | The procedure GetRandomPaymentReference is available in codeunit 130100.
SelectPaymentJournalTemplate@8 | The procedure SelectPaymentJournalTemplate is available in codeunit 130100.
SetPmtToDomestic@51 | The procedure SetPmtToDomestic is available in codeunit 130100.
SetPmtToInternational@54 | The procedure SetPmtToInternational is available in codeunit 130100.
SetRefundToDomestic@79 | The procedure SetRefundToDomestic is available in codeunit 130100.
SetRefundToInternational@78 | The procedure SetRefundToInternational is available in codeunit 130100.
VerifyGenJnlLineErr@39 | The procedure VerifyGenJnlLineErr is available in codeunit 130100.

See Also

Lib


CreateBankAccount@6 Method

The procedure CreateBankAccount is available in codeunit 130100.

Syntax

CreateBankAccount@6(
    VAR BankAccount@1000 : Record 270 BankAccount //Reference parameter of type Record
);

Parameters

BankAccount
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Bank, Account.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.CreateBankAccount(BankAccount);
      BankAccount."Bank Branch No." := FORMAT(LibraryRandom.RandIntInRange(111111,999999));
      BankAccount."Bank Account No." := FORMAT(LibraryRandom.RandIntInRange(111111111,999999999));
      BankAccount.MODIFY;

Example

The below example is extracted from the test automation codeunit 134407 to show one way of using this function.

      LibraryERM.CreateBankAccount(BankAcc);
      BankAcc.IBAN := LibraryUtility.GenerateGUID;
      BankAcc."SWIFT Code" := LibraryUtility.GenerateGUID;
      BankAcc.MODIFY;
Member of Lib.Library - Payment Export


CreateBankExportImportSetup@10 Method

The procedure CreateBankExportImportSetup is available in codeunit 130100.

Syntax

CreateBankExportImportSetup@10(
    VAR BankExportImportSetup@1000 : Record 1200 BankExportImportSetup, //Reference parameter of type Record
    DataExchDefCode@1001 : Code[20] DataExchDefCode //Input parameter of type Code
);

Parameters

BankExportImportSetup
Reference parameter of type Record
DataExchDefCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Bank, Export, Import, Setup.

For a clarification about how this function works, refer to the code listed below.

      WITH BankExportImportSetup DO BEGIN
        IF GET(DataExchDefCode) THEN
          DELETE;
        RESET;
        Code := DataExchDefCode;
        Direction := Direction::Export;
        "Data Exch. Def. Code" := DataExchDefCode;
        INSERT;
      END;

Example

The below example is extracted from the test automation codeunit 134660 to show one way of using this function.

      LibraryPaymentFormat.CreateDataExchDef(
        DataExchDef,CODEUNIT::"Exp. Data Handling Gen. Jnl.",
        CODEUNIT::"Exp. Validation Gen. Jnl.",CODEUNIT::"Exp. Writing Gen. Jnl.",XMLPORT::"Export Generic CSV",
        CODEUNIT::"Save Data Exch. Blob Sample",CODEUNIT::"Exp. User Feedback Gen. Jnl.");

      DataExchLineDef.InsertRec(DataExchDef.Code,PaymentType,LibraryUtility.GenerateGUID,3);

      LibraryPaymentFormat.CreateDataExchColumnDef(DataExchColumnDef,DataExchDef.Code,DataExchLineDef.Code);

      LibraryPaymentFormat.CreateDataExchMapping(DataExchMapping,DataExchDef.Code,DataExchLineDef.Code,
        CODEUNIT::"Exp. Pre-Mapping Gen. Jnl.",CODEUNIT::"Exp. Mapping Gen. Jnl.",CODEUNIT::"Exp. Post-Mapping Gen. Jnl.");

      LibraryPaymentFormat.CreateDataExchFieldMapping(DataExchFieldMapping,DataExchDef.Code,DataExchLineDef.Code);

      LibraryPaymentFormat.CreateBankExportImportSetup(BankExportImportSetup,DataExchDef);

      EXIT(DataExchDef.Code);
Member of Lib.Library - Payment Export


CreateGenJournalBatch@7 Method

The procedure CreateGenJournalBatch is available in codeunit 130100.

Syntax

CreateGenJournalBatch@7(
    VAR GenJournalBatch@1000 : Record 232 GenJournalBatch, //Reference parameter of type Record
    BalAccountType@1001 : Option BalAccountType, //Input parameter of type Option
    BalAccountNo@1002 : Code[20] BalAccountNo, //Input parameter of type Code
    AllowPaymentExport@1003 : Boolean AllowPaymentExport //Input parameter of type Boolean
);

Parameters

GenJournalBatch
Reference parameter of type Record
BalAccountType
Input parameter of type Option
BalAccountNo
Input parameter of type Code
AllowPaymentExport
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, General, Journal, Batch.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.CreateGenJournalBatch(GenJournalBatch,LibraryPurchase.SelectPmtJnlTemplate);
      GenJournalBatch.VALIDATE("Bal. Account Type",BalAccountType);
      GenJournalBatch.VALIDATE("Bal. Account No.",BalAccountNo);
      GenJournalBatch.VALIDATE("Allow Payment Export",AllowPaymentExport);
      GenJournalBatch.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134407 to show one way of using this function.

      CreateBankAccount(BankAcc);
      LibraryERM.CreateGenJournalBatch(GenJnlBatch,LibraryERM.SelectGenJnlTemplate);
      GenJnlBatch.VALIDATE("Bal. Account Type",GenJnlBatch."Bal. Account Type"::"Bank Account");
      GenJnlBatch.VALIDATE("Bal. Account No.",BankAcc."No.");
      GenJnlBatch.VALIDATE("Allow Payment Export",TRUE);
      GenJnlBatch.MODIFY(TRUE);
Member of Lib.Library - Payment Export


CreatePaymentExportBatch@5 Method

The procedure CreatePaymentExportBatch is available in codeunit 130100.

Syntax

CreatePaymentExportBatch@5(
    VAR GenJournalBatch@1001 : Record 232 GenJournalBatch, //Reference parameter of type Record
    DataExchDefCode@1002 : Code[20] DataExchDefCode //Input parameter of type Code
);

Parameters

GenJournalBatch
Reference parameter of type Record
DataExchDefCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Payment, Export, Batch.

For a clarification about how this function works, refer to the code listed below.

      CreateBankAccount(BankAccount);
      CreateBankExportImportSetup(BankExportImportSetup,DataExchDefCode);
      BankAccount.VALIDATE("Payment Export Format",BankExportImportSetup.Code);
      BankAccount.MODIFY;
      CreateGenJournalBatch(GenJournalBatch,GenJournalBatch."Bal. Account Type"::"Bank Account",BankAccount."No.",TRUE);

Example

The below example is extracted from the test automation codeunit 134161 to show one way of using this function.

      // [SCENARIO 1] Re-Export Payment Journal Line to a File
      // [GIVEN] Gen. Journal Line of type Payment
      // [GIVEN] Gen. Journal Line is auto-applied to a Posted Purchase Invoice
      // [GIVEN] The Exported to Payment File flag is set to true on the Gen. Journal Line
      // [WHEN] User clicks the Export Payment to File action on the Payment Journal
      // [THEN] Confirmation message pops up
      // [THEN] File is created

      // Pre-Setup
      LibraryPaymentExport.CreateVendorWithBankAccount(Vendor);
      PostPurchaseInvoice(InvGenJournalLine,Vendor."No.");

      DefinePaymentExportFormat(DataExchMapping);
      UpdatePaymentMethodLineDef(Vendor."Payment Method Code",DataExchMapping."Data Exch. Line Def Code");

      // Setup
      LibraryPaymentExport.CreatePaymentExportBatch(GenJournalBatch,DataExchMapping."Data Exch. Def Code");
      UpdateBankExportImportSetup(GenJournalBatch."Bal. Account No.");

      LibraryPaymentExport.CreateVendorPmtJnlLine(PmtGenJournalLine,GenJournalBatch,Vendor."No.");
      MessageToRecipient := LibraryUtility.GenerateRandomText(MAXSTRLEN(PmtGenJournalLine."Message to Recipient"));
      PmtGenJournalLine."Message to Recipient" := COPYSTR(MessageToRecipient,1,MAXSTRLEN(PmtGenJournalLine."Message to Recipient"));
      PmtGenJournalLine.MODIFY;

      ApplyPaymentToPurchaseInvoice(PmtGenJournalLine,InvGenJournalLine);

      // Exercise
      PmtGenJournalLine.SETRANGE("Journal Template Name",GenJournalBatch."Journal Template Name");
      PmtGenJournalLine.SETRANGE("Journal Batch Name",GenJournalBatch.Name);

      PmtExportMgtGenJnlLine.EnableExportToServerTempFile(TRUE,'txt');
      PmtExportMgtGenJnlLine.ExportJournalPaymentFileYN(PmtGenJournalLine); // Will set exported flag
      PmtExportMgtGenJnlLine.ExportJournalPaymentFileYN(PmtGenJournalLine); // Will ask for export again

      // Verify
      ValidatePaymentFile(PmtExportMgtGenJnlLine.GetServerTempFileName,MessageToRecipient);
      ValidateExportedPmtJnlLine(GenJournalBatch);
      ValidateCreditTransferRegister(DataExchMapping."Data Exch. Def Code",GenJournalBatch."Bal. Account No.");
Member of Lib.Library - Payment Export


CreatePaymentMethod@1 Method

The procedure CreatePaymentMethod is available in codeunit 130100.

Syntax

CreatePaymentMethod@1(
    VAR PaymentMethod@1000 : Record 289 PaymentMethod //Reference parameter of type Record
);

Parameters

PaymentMethod
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Payment, Method.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.CreatePaymentMethod(PaymentMethod);

Example

The below example is extracted from the test automation codeunit 134411 to show one way of using this function.

      LibraryPurchase.CreateVendor(Vendor);
      CreateVendorBankAccountWithDetails(VendorBankAccount,Vendor."No.");
      LibraryERM.CreatePaymentMethod(PaymentMethod);

      Vendor.VALIDATE("Payment Method Code",PaymentMethod.Code);
      Vendor.VALIDATE("Preferred Bank Account",VendorBankAccount.Code);
      Vendor.VALIDATE(Name,
        LibraryUtility.GenerateRandomCode(Vendor.FIELDNO(Name),DATABASE::Vendor));
      Vendor.VALIDATE(Address,
        LibraryUtility.GenerateRandomCode(Vendor.FIELDNO(Address),DATABASE::Vendor));
      Vendor.VALIDATE("Address 2",
        LibraryUtility.GenerateRandomCode(Vendor.FIELDNO("Address 2"),DATABASE::Vendor));
      Vendor.VALIDATE(City,
        LibraryUtility.GenerateRandomCode(Vendor.FIELDNO(City),DATABASE::Vendor));
      Vendor.VALIDATE("Post Code",
        LibraryUtility.GenerateRandomCode(Vendor.FIELDNO("Post Code"),DATABASE::Vendor));
      Vendor.MODIFY(TRUE);
      Vendor.SETRANGE("No.",Vendor."No.");
Member of Lib.Library - Payment Export


CreateSimpleDataExchDefWithMapping@28 Method

The procedure CreateSimpleDataExchDefWithMapping is available in codeunit 130100.

Syntax

CreateSimpleDataExchDefWithMapping@28(
    VAR DataExchMapping@1007 : Record 1224 DataExchMapping, //Reference parameter of type Record
    TableID@1000 : Integer TableID, //Input parameter of type Integer
    FieldID@1002 : Integer FieldID //Input parameter of type Integer
);

Parameters

DataExchMapping
Reference parameter of type Record
TableID
Input parameter of type Integer
FieldID
Input parameter of type Integer

Remarks

The relevant search keywords are: Create, Simple, Data, Exchange, Def, Mapping.

For a clarification about how this function works, refer to the code listed below.

      CreateSimpleDataExchDefWithMapping2(DataExchDef,DataExchMapping,DataExchFieldMapping,TableID,FieldID);

Example

The below example is extracted from the test automation codeunit 134161 to show one way of using this function.

      LibraryPaymentExport.CreateSimpleDataExchDefWithMapping(DataExchMapping,
        DATABASE::"Payment Export Data",PaymentExportData.FIELDNO("Message to Recipient 1"));

      DataExchDef.GET(DataExchMapping."Data Exch. Def Code");
      DataExchDef.VALIDATE("File Type",DataExchDef."File Type"::"Variable Text");
      DataExchDef.VALIDATE("Reading/Writing XMLport",XMLPORT::"Export Generic CSV");
      DataExchDef.MODIFY(TRUE);

      DataExchLineDef.GET(DataExchMapping."Data Exch. Def Code",DataExchMapping."Data Exch. Line Def Code");
      DataExchLineDef.VALIDATE("Column Count",1);
      DataExchLineDef.MODIFY(TRUE);
Member of Lib.Library - Payment Export


CreateSimpleDataExchDefWithMapping2@16 Method

The procedure CreateSimpleDataExchDefWithMapping2 is available in codeunit 130100.

Syntax

CreateSimpleDataExchDefWithMapping2@16(
    VAR DataExchDef@1003 : Record 1222 DataExchDef, //Reference parameter of type Record
    VAR DataExchMapping@1007 : Record 1224 DataExchMapping, //Reference parameter of type Record
    VAR DataExchFieldMapping@1001 : Record 1225 DataExchFieldMapping, //Reference parameter of type Record
    TableID@1005 : Integer TableID, //Input parameter of type Integer
    FieldID@1008 : Integer FieldID //Input parameter of type Integer
);

Parameters

DataExchDef
Reference parameter of type Record
DataExchMapping
Reference parameter of type Record
DataExchFieldMapping
Reference parameter of type Record
TableID
Input parameter of type Integer
FieldID
Input parameter of type Integer

Remarks

The relevant search keywords are: Create, Simple, Data, Exchange, Def, Mapping2.

For a clarification about how this function works, refer to the code listed below.

      DataExchDefCode := LibraryUtility.GenerateRandomCode(DataExchDef.FIELDNO(Code),DATABASE::"Data Exch. Def");
      DataExchDef.INIT;
      DataExchDef.Code := DataExchDefCode;
      DataExchDef.Name := DataExchDef.Code;
      DataExchDef.Type := DataExchDef.Type::"Payment Export";
      DataExchDef.INSERT;

      DataExchLineDefCode := LibraryUtility.GenerateRandomCode(DataExchLineDef.FIELDNO(Code),DATABASE::"Data Exch. Line Def");
      DataExchLineDef.INIT;
      DataExchLineDef.Code := DataExchLineDefCode;
      DataExchLineDef."Data Exch. Def Code" := DataExchDefCode;
      DataExchLineDef.INSERT;

      DataExchColDef.INIT;
      DataExchColDef."Data Exch. Def Code" := DataExchDefCode;
      DataExchColDef."Data Exch. Line Def Code" := DataExchLineDefCode;
      DataExchColDef."Column No." := 1;
      DataExchColDef.INSERT;

      DataExchMapping.INIT;
      DataExchMapping."Data Exch. Def Code" := DataExchDefCode;
      DataExchMapping."Data Exch. Line Def Code" := DataExchLineDefCode;
      DataExchMapping."Table ID" := TableID;
      DataExchMapping.INSERT;

      DataExchFieldMapping.INIT;
      DataExchFieldMapping."Data Exch. Def Code" := DataExchDefCode;
      DataExchFieldMapping."Data Exch. Line Def Code" := DataExchLineDefCode;
      DataExchFieldMapping."Table ID" := DataExchMapping."Table ID";
      DataExchFieldMapping."Column No." := 1;
      DataExchFieldMapping."Field ID" := FieldID;
      DataExchFieldMapping.INSERT;

Example

The below example is extracted from the test automation codeunit 134662 to show one way of using this function.

      LibraryPaymentExport.CreateSimpleDataExchDefWithMapping2(
        DataExchDef,DataExchMapping,DataExchFieldMapping,TableID,FieldID);

      DataExchDef."Reading/Writing Codeunit" := CODEUNIT::"Exp. Writing Gen. Jnl.";
      DataExchDef."Reading/Writing XMLport" := XMLPORT::"Export Generic CSV";
      DataExchDef."Ext. Data Handling Codeunit" := CODEUNIT::"Save Data Exch. Blob Sample";
      DataExchDef.MODIFY;

      DataExchMapping."Mapping Codeunit" := CODEUNIT::"Export Mapping";
      DataExchMapping.MODIFY;
Member of Lib.Library - Payment Export


CreateVendorPmtJnlLine@9 Method

The procedure CreateVendorPmtJnlLine is available in codeunit 130100.

Syntax

CreateVendorPmtJnlLine@9(
    VAR GenJournalLine@1000 : Record 81 GenJournalLine, //Reference parameter of type Record
    GenJournalBatch@1001 : Record 232 GenJournalBatch, //Input parameter of type Record
    VendorNo@1002 : Code[20] VendorNo //Input parameter of type Code
);

Parameters

GenJournalLine
Reference parameter of type Record
GenJournalBatch
Input parameter of type Record
VendorNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Vendor, Payment, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.CreateGeneralJnlLine(GenJournalLine,
        GenJournalBatch."Journal Template Name",GenJournalBatch.Name,GenJournalLine."Document Type"::Payment,
        GenJournalLine."Account Type"::Vendor,VendorNo,LibraryRandom.RandDec(1000,2));

Example

The below example is extracted from the test automation codeunit 134161 to show one way of using this function.

      // [SCENARIO 1] Re-Export Payment Journal Line to a File
      // [GIVEN] Gen. Journal Line of type Payment
      // [GIVEN] Gen. Journal Line is auto-applied to a Posted Purchase Invoice
      // [GIVEN] The Exported to Payment File flag is set to true on the Gen. Journal Line
      // [WHEN] User clicks the Export Payment to File action on the Payment Journal
      // [THEN] Confirmation message pops up
      // [THEN] File is created

      // Pre-Setup
      LibraryPaymentExport.CreateVendorWithBankAccount(Vendor);
      PostPurchaseInvoice(InvGenJournalLine,Vendor."No.");

      DefinePaymentExportFormat(DataExchMapping);
      UpdatePaymentMethodLineDef(Vendor."Payment Method Code",DataExchMapping."Data Exch. Line Def Code");

      // Setup
      LibraryPaymentExport.CreatePaymentExportBatch(GenJournalBatch,DataExchMapping."Data Exch. Def Code");
      UpdateBankExportImportSetup(GenJournalBatch."Bal. Account No.");

      LibraryPaymentExport.CreateVendorPmtJnlLine(PmtGenJournalLine,GenJournalBatch,Vendor."No.");
      MessageToRecipient := LibraryUtility.GenerateRandomText(MAXSTRLEN(PmtGenJournalLine."Message to Recipient"));
      PmtGenJournalLine."Message to Recipient" := COPYSTR(MessageToRecipient,1,MAXSTRLEN(PmtGenJournalLine."Message to Recipient"));
      PmtGenJournalLine.MODIFY;

      ApplyPaymentToPurchaseInvoice(PmtGenJournalLine,InvGenJournalLine);

      // Exercise
      PmtGenJournalLine.SETRANGE("Journal Template Name",GenJournalBatch."Journal Template Name");
      PmtGenJournalLine.SETRANGE("Journal Batch Name",GenJournalBatch.Name);

      PmtExportMgtGenJnlLine.EnableExportToServerTempFile(TRUE,'txt');
      PmtExportMgtGenJnlLine.ExportJournalPaymentFileYN(PmtGenJournalLine); // Will set exported flag
      PmtExportMgtGenJnlLine.ExportJournalPaymentFileYN(PmtGenJournalLine); // Will ask for export again

      // Verify
      ValidatePaymentFile(PmtExportMgtGenJnlLine.GetServerTempFileName,MessageToRecipient);
      ValidateExportedPmtJnlLine(GenJournalBatch);
      ValidateCreditTransferRegister(DataExchMapping."Data Exch. Def Code",GenJournalBatch."Bal. Account No.");
Member of Lib.Library - Payment Export


CreateVendorWithBankAccount@4 Method

The procedure CreateVendorWithBankAccount is available in codeunit 130100.

Syntax

CreateVendorWithBankAccount@4(
    VAR Vendor@1000 : Record 23 Vendor //Reference parameter of type Record
);

Parameters

Vendor
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Vendor, Bank, Account.

For a clarification about how this function works, refer to the code listed below.

      LibraryPurchase.CreateVendor(Vendor);
      LibraryPurchase.CreateVendorBankAccount(VendorBankAccount,Vendor."No.");
      LibraryERM.CreatePaymentMethod(PaymentMethod);

      Vendor.VALIDATE("Payment Method Code",PaymentMethod.Code);
      Vendor.VALIDATE("Preferred Bank Account",VendorBankAccount.Code);
      Vendor.MODIFY(TRUE);

      VendorBankAccount."Bank Branch No." := FORMAT(LibraryRandom.RandIntInRange(111111,999999));
      VendorBankAccount."Bank Account No." := FORMAT(LibraryRandom.RandIntInRange(111111111,999999999));
      VendorBankAccount.MODIFY;

Example

The below example is extracted from the test automation codeunit 134161 to show one way of using this function.

      // [SCENARIO 1] Re-Export Payment Journal Line to a File
      // [GIVEN] Gen. Journal Line of type Payment
      // [GIVEN] Gen. Journal Line is auto-applied to a Posted Purchase Invoice
      // [GIVEN] The Exported to Payment File flag is set to true on the Gen. Journal Line
      // [WHEN] User clicks the Export Payment to File action on the Payment Journal
      // [THEN] Confirmation message pops up
      // [THEN] File is created

      // Pre-Setup
      LibraryPaymentExport.CreateVendorWithBankAccount(Vendor);
      PostPurchaseInvoice(InvGenJournalLine,Vendor."No.");

      DefinePaymentExportFormat(DataExchMapping);
      UpdatePaymentMethodLineDef(Vendor."Payment Method Code",DataExchMapping."Data Exch. Line Def Code");

      // Setup
      LibraryPaymentExport.CreatePaymentExportBatch(GenJournalBatch,DataExchMapping."Data Exch. Def Code");
      UpdateBankExportImportSetup(GenJournalBatch."Bal. Account No.");

      LibraryPaymentExport.CreateVendorPmtJnlLine(PmtGenJournalLine,GenJournalBatch,Vendor."No.");
      MessageToRecipient := LibraryUtility.GenerateRandomText(MAXSTRLEN(PmtGenJournalLine."Message to Recipient"));
      PmtGenJournalLine."Message to Recipient" := COPYSTR(MessageToRecipient,1,MAXSTRLEN(PmtGenJournalLine."Message to Recipient"));
      PmtGenJournalLine.MODIFY;

      ApplyPaymentToPurchaseInvoice(PmtGenJournalLine,InvGenJournalLine);

      // Exercise
      PmtGenJournalLine.SETRANGE("Journal Template Name",GenJournalBatch."Journal Template Name");
      PmtGenJournalLine.SETRANGE("Journal Batch Name",GenJournalBatch.Name);

      PmtExportMgtGenJnlLine.EnableExportToServerTempFile(TRUE,'txt');
      PmtExportMgtGenJnlLine.ExportJournalPaymentFileYN(PmtGenJournalLine); // Will set exported flag
      PmtExportMgtGenJnlLine.ExportJournalPaymentFileYN(PmtGenJournalLine); // Will ask for export again

      // Verify
      ValidatePaymentFile(PmtExportMgtGenJnlLine.GetServerTempFileName,MessageToRecipient);
      ValidateExportedPmtJnlLine(GenJournalBatch);
      ValidateCreditTransferRegister(DataExchMapping."Data Exch. Def Code",GenJournalBatch."Bal. Account No.");
Member of Lib.Library - Payment Export


GetRandomCreditorNo@2 Method

The procedure GetRandomCreditorNo is available in codeunit 130100.

Syntax

GetRandomCreditorNo@2(
      //param element not supplied
);

Return Value

Code[20]

Remarks

The relevant search keywords are: Get, Random, Creditor, No.

For a clarification about how this function works, refer to the code listed below.

      EXIT(LibraryUtility.GenerateGUID + FORMAT(LibraryRandom.RandIntInRange(111111111,999999999)));

Example

There are no examples available.
Member of Lib.Library - Payment Export


GetRandomPaymentReference@3 Method

The procedure GetRandomPaymentReference is available in codeunit 130100.

Syntax

GetRandomPaymentReference@3(
      //param element not supplied
);

Return Value

Code[50]

Remarks

The relevant search keywords are: Get, Random, Payment, Reference.

For a clarification about how this function works, refer to the code listed below.

      RandomValue := FORMAT(LibraryRandom.RandIntInRange(111111111,999999999));
      EXIT(LibraryUtility.GenerateGUID + RandomValue + RandomValue);

Example

There are no examples available.
Member of Lib.Library - Payment Export


SelectPaymentJournalTemplate@8 Method

The procedure SelectPaymentJournalTemplate is available in codeunit 130100.

Syntax

SelectPaymentJournalTemplate@8(
      //param element not supplied
);

Return Value

Code[10]

Remarks

The relevant search keywords are: Select, Payment, Journal, Template.

For a clarification about how this function works, refer to the code listed below.

      WITH GenJnlTemplate DO BEGIN
        SETRANGE(Type,Type::Payments);
        SETRANGE(Recurring,FALSE);

        IF NOT FINDFIRST THEN BEGIN
          INIT;
          Name := LibraryUtility.GenerateRandomCode(FIELDNO(Name),DATABASE::"Gen. Journal Template");
          Type := Type::Payments;
          Recurring := FALSE;
          INSERT;
        END;

        EXIT(Name);
      END;

Example

There are no examples available.
Member of Lib.Library - Payment Export


SetPmtToDomestic@51 Method

The procedure SetPmtToDomestic is available in codeunit 130100.

Syntax

SetPmtToDomestic@51(
    VAR BankAccount@1001 : Record 270 BankAccount, //Reference parameter of type Record
    VAR VendorBankAccount@1000 : Record 288 VendorBankAccount //Reference parameter of type Record
);

Parameters

BankAccount
Reference parameter of type Record
VendorBankAccount
Reference parameter of type Record

Remarks

The relevant search keywords are: Set, Payment, To, Domestic.

For a clarification about how this function works, refer to the code listed below.

      CompanyInformation.GET;
      BankAccount.VALIDATE("Country/Region Code",CompanyInformation."Country/Region Code");
      BankAccount.MODIFY(TRUE);
      VendorBankAccount.VALIDATE("Country/Region Code",BankAccount."Country/Region Code");
      VendorBankAccount.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134411 to show one way of using this function.

      // [SCENARIO 1] Export a number of payments applied to an existing vendor invoices.
      // [GIVEN] A number of domestic vendor invoices.
      // [GIVEN] A number of suggested payments applied to those invoices (fully or partially).
      // [GIVEN] A bank account set up to export to AMC format, used by the payments.
      // [WHEN] Invoking the Export to Payment file from the Payment Journal.
      // [THEN] The Payment Export Data buffer table is populated with information regarding
      // - sender identification (creditor no., company name, template and batch name, unique message id, VAT no.,
      // own reference, own address info, sender bank account info, etc.
      // - transaction information (amount details, transaction specification, costs, payment type)
      // - receiver identification: receiver's address, receiver's bank account (including address)
      // More details in the linked document in the deliverable.
      Initialize;

      // Setup.
      SetupVendorDetails(Vendor,VendorBankAccount);
      CreateBankAccountWithDetails(BankAccount);
      LibraryPaymentExport.SetPmtToDomestic(BankAccount,VendorBankAccount);
      PostVendorInvoice(Vendor."No.");

      LibraryERM.CreateGenJournalBatch(PmtGenJnlBatch,LibraryERM.SelectGenJnlTemplate);
      PmtGenJnlBatch.VALIDATE("Bal. Account Type",PmtGenJnlBatch."Bal. Account Type"::"Bank Account");
      PmtGenJnlBatch.VALIDATE("Bal. Account No.",BankAccount."No.");
      PmtGenJnlBatch.MODIFY(TRUE);
      SuggestVendorPayments(Vendor,PmtGenJnlBatch);
      SetupPmtDetails(PmtGenJnlBatch);

      // Exercise. Run the pre-mapping.
      ExtractAMCData(PmtGenJnlBatch);

      // Verify. Payment Export Data.
      VerifyVendorPaymentExportData(PmtGenJnlBatch,Vendor,VendorBankAccount,BankAccount);
Member of Lib.Library - Payment Export


SetPmtToInternational@54 Method

The procedure SetPmtToInternational is available in codeunit 130100.

Syntax

SetPmtToInternational@54(
    VAR BankAccount@1001 : Record 270 BankAccount, //Reference parameter of type Record
    VAR VendorBankAccount@1000 : Record 288 VendorBankAccount //Reference parameter of type Record
);

Parameters

BankAccount
Reference parameter of type Record
VendorBankAccount
Reference parameter of type Record

Remarks

The relevant search keywords are: Set, Payment, To, International.

For a clarification about how this function works, refer to the code listed below.

      CompanyInformation.GET;
      BankAccount.VALIDATE("Country/Region Code",CompanyInformation."Country/Region Code");
      BankAccount.MODIFY(TRUE);
      CountryRegion.SETFILTER(Code,'<>%1',BankAccount."Country/Region Code");
      CountryRegion.FINDFIRST;
      VendorBankAccount.VALIDATE("Country/Region Code",CountryRegion.Code);
      VendorBankAccount.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134411 to show one way of using this function.

      // [SCENARIO 4] Export a number of payments applied to non-domestic vendor invoices.
      // [GIVEN] A number of non-domestic vendor invoices.
      // [GIVEN] A number of suggested payments applied to those invoices (fully or partially).
      // [GIVEN] A bank account set up to export to AMC format, used by the payments.
      // [WHEN] Invoking the Export to Payment file from the Payment Journal.
      // [THEN] The Payment Export Data buffer table is populated with information regarding
      // - sender identification (creditor no., company name, template and batch name, unique message id, VAT no.,
      // own reference, own address info, sender bank account info, etc.
      // - transaction information (amount details, transaction specification, costs, payment type)
      // - receiver identification: receiver's address, receiver's bank account (including address)
      // More details in the linked document in the deliverable.
      Initialize;

      // Setup.
      SetupVendorDetails(Vendor,VendorBankAccount);
      CreateBankAccountWithDetails(BankAccount);
      LibraryPaymentExport.SetPmtToInternational(BankAccount,VendorBankAccount);
      PostVendorInvoice(Vendor."No.");
      LibraryERM.CreateGenJournalBatch(PmtGenJnlBatch,LibraryERM.SelectGenJnlTemplate);
      PmtGenJnlBatch.VALIDATE("Bal. Account Type",PmtGenJnlBatch."Bal. Account Type"::"Bank Account");
      PmtGenJnlBatch.VALIDATE("Bal. Account No.",BankAccount."No.");
      PmtGenJnlBatch.MODIFY(TRUE);
      SuggestVendorPayments(Vendor,PmtGenJnlBatch);
      SetupPmtDetails(PmtGenJnlBatch);

      // Exercise. Run the pre-mapping.
      ExtractAMCData(PmtGenJnlBatch);

      // Verify. Payment Export Data.
      VerifyVendorPaymentExportData(PmtGenJnlBatch,Vendor,VendorBankAccount,BankAccount);
Member of Lib.Library - Payment Export


SetRefundToDomestic@79 Method

The procedure SetRefundToDomestic is available in codeunit 130100.

Syntax

SetRefundToDomestic@79(
    VAR BankAccount@1001 : Record 270 BankAccount, //Reference parameter of type Record
    VAR CustomerBankAccount@1000 : Record 287 CustomerBankAccount //Reference parameter of type Record
);

Parameters

BankAccount
Reference parameter of type Record
CustomerBankAccount
Reference parameter of type Record

Remarks

The relevant search keywords are: Set, Refund, To, Domestic.

For a clarification about how this function works, refer to the code listed below.

      CompanyInformation.GET;
      BankAccount.VALIDATE("Country/Region Code",CompanyInformation."Country/Region Code");
      BankAccount.MODIFY(TRUE);
      CustomerBankAccount.VALIDATE("Country/Region Code",BankAccount."Country/Region Code");
      CustomerBankAccount.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134411 to show one way of using this function.

      // [SCENARIO 3] Export a number of payments, both customer and vendor, applied to invoices/credit memos.
      // [GIVEN] A number of domestic vendor invoices and domestic customer credit memos.
      // [GIVEN] A number of payment/refund lines applied to them.
      // [GIVEN] A bank account set up to export to AMC format, used by the payments.
      // [WHEN] Invoking the Export to Payment file from the Payment Journal.
      // [THEN] The Payment Export Data buffer table is populated with information regarding
      // - sender identification (creditor no., company name, template and batch name, unique message id, VAT no.,
      // own reference, own address info, sender bank account info, etc.
      // - transaction information (amount details, transaction specification, costs, payment type)
      // - receiver identification: receiver's address, receiver's bank account (including address)
      // More details in the linked document in the deliverable.
      Initialize;

      // Setup.
      SetupVendorDetails(Vendor,VendorBankAccount);
      SetupCustomerDetails(Customer,CustomerBankAccount);
      CreateBankAccountWithDetails(BankAccount);
      LibraryPaymentExport.SetPmtToDomestic(BankAccount,VendorBankAccount);
      LibraryPaymentExport.SetRefundToDomestic(BankAccount,CustomerBankAccount);

      LibraryERM.CreateGenJournalBatch(GenJnlBatch,LibraryERM.SelectGenJnlTemplate);
      LibraryERM.CreateGLAccount(GLAccount);
      LibraryERM.CreateGeneralJnlLineWithBalAcc(CrMemoGenJnlLine,
        GenJnlBatch."Journal Template Name",GenJnlBatch.Name,GenJnlLine."Document Type"::"Credit Memo",
        CrMemoGenJnlLine."Account Type"::Customer,Customer."No.",GenJnlLine."Bal. Account Type"::"G/L Account",GLAccount."No.",
        -LibraryRandom.RandDec(1000,2));
      LibraryERM.PostGeneralJnlLine(CrMemoGenJnlLine);

      LibraryERM.CreateGenJournalBatch(PmtGenJnlBatch,LibraryERM.SelectGenJnlTemplate);
      PmtGenJnlBatch.VALIDATE("Bal. Account Type",PmtGenJnlBatch."Bal. Account Type"::"Bank Account");
      PmtGenJnlBatch.VALIDATE("Bal. Account No.",BankAccount."No.");
      PmtGenJnlBatch.MODIFY(TRUE);
      LibraryERM.CreateGeneralJnlLine(GenJnlLine,
        PmtGenJnlBatch."Journal Template Name",PmtGenJnlBatch.Name,GenJnlLine."Document Type"::Payment,
        GenJnlLine."Account Type"::Vendor,Vendor."No.",LibraryRandom.RandDec(1000,2));
      LibraryERM.CreateGeneralJnlLine(GenJnlLine,
        PmtGenJnlBatch."Journal Template Name",PmtGenJnlBatch.Name,GenJnlLine."Document Type"::Refund,
        GenJnlLine."Account Type"::Customer,Customer."No.",-LibraryRandom.RandDec(1000,2));
      GenJnlLine.VALIDATE("Applies-to Doc. Type",GenJnlLine."Applies-to Doc. Type"::"Credit Memo");
      GenJnlLine.VALIDATE("Applies-to Doc. No.",CrMemoGenJnlLine."Document No.");
      GenJnlLine.MODIFY(TRUE);
      SetupPmtDetails(PmtGenJnlBatch);

      // Exercise. Run the pre-mapping.
      ExtractAMCData(PmtGenJnlBatch);

      // Verify. Payment Export Data.
      VerifyVendorPaymentExportData(PmtGenJnlBatch,Vendor,VendorBankAccount,BankAccount);
      VerifyCustomerPaymentExportData(PmtGenJnlBatch,Customer,CustomerBankAccount,BankAccount);
Member of Lib.Library - Payment Export


SetRefundToInternational@78 Method

The procedure SetRefundToInternational is available in codeunit 130100.

Syntax

SetRefundToInternational@78(
    VAR BankAccount@1001 : Record 270 BankAccount, //Reference parameter of type Record
    VAR CustomerBankAccount@1000 : Record 287 CustomerBankAccount //Reference parameter of type Record
);

Parameters

BankAccount
Reference parameter of type Record
CustomerBankAccount
Reference parameter of type Record

Remarks

The relevant search keywords are: Set, Refund, To, International.

For a clarification about how this function works, refer to the code listed below.

      CompanyInformation.GET;
      BankAccount.VALIDATE("Country/Region Code",CompanyInformation."Country/Region Code");
      BankAccount.MODIFY(TRUE);
      CountryRegion.SETFILTER(Code,'<>%1',BankAccount."Country/Region Code");
      CountryRegion.FINDFIRST;
      CustomerBankAccount.VALIDATE("Country/Region Code",CountryRegion.Code);
      CustomerBankAccount.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134411 to show one way of using this function.

      // [SCENARIO 6] Export a number of payments applied to both non-domestic customer and vendor.
      // [GIVEN] A number of non-domestic vendor invoices and non-domestic customer credit memos.
      // [GIVEN] A number of payment/refund lines applied to them.
      // [GIVEN] A bank account set up to export to AMC format, used by the payments.
      // [WHEN] Invoking the Export to Payment file from the Payment Journal.
      // [THEN] The Payment Export Data buffer table is populated with information regarding
      // - sender identification (creditor no., company name, template and batch name, unique message id, VAT no.,
      // own reference, own address info, sender bank account info, etc.
      // - transaction information (amount details, transaction specification, costs, payment type)
      // - receiver identification: receiver's address, receiver's bank account (including address)
      // More details in the linked document in the deliverable.
      Initialize;

      // Setup.
      SetupVendorDetails(Vendor,VendorBankAccount);
      SetupCustomerDetails(Customer,CustomerBankAccount);
      CreateBankAccountWithDetails(BankAccount);
      LibraryPaymentExport.SetPmtToInternational(BankAccount,VendorBankAccount);
      LibraryPaymentExport.SetRefundToInternational(BankAccount,CustomerBankAccount);
      LibraryERM.CreateGenJournalBatch(PmtGenJnlBatch,LibraryERM.SelectGenJnlTemplate);
      PmtGenJnlBatch.VALIDATE("Bal. Account Type",PmtGenJnlBatch."Bal. Account Type"::"Bank Account");
      PmtGenJnlBatch.VALIDATE("Bal. Account No.",BankAccount."No.");
      PmtGenJnlBatch.MODIFY(TRUE);
      LibraryERM.CreateGeneralJnlLine(GenJnlLine,
        PmtGenJnlBatch."Journal Template Name",PmtGenJnlBatch.Name,GenJnlLine."Document Type"::Payment,
        GenJnlLine."Account Type"::Vendor,Vendor."No.",LibraryRandom.RandDec(1000,2));
      LibraryERM.CreateGeneralJnlLine(GenJnlLine,
        PmtGenJnlBatch."Journal Template Name",PmtGenJnlBatch.Name,GenJnlLine."Document Type"::Refund,
        GenJnlLine."Account Type"::Customer,Customer."No.",-LibraryRandom.RandDec(1000,2));
      SetupPmtDetails(PmtGenJnlBatch);

      // Exercise. Run the pre-mapping.
      ExtractAMCData(PmtGenJnlBatch);

      // Verify. Payment Export Data.
      VerifyVendorPaymentExportData(PmtGenJnlBatch,Vendor,VendorBankAccount,BankAccount);
      VerifyCustomerPaymentExportData(PmtGenJnlBatch,Customer,CustomerBankAccount,BankAccount);
Member of Lib.Library - Payment Export


VerifyGenJnlLineErr@39 Method

The procedure VerifyGenJnlLineErr is available in codeunit 130100.

Syntax

VerifyGenJnlLineErr@39(
    GenJnlLine@1000 : Record 81 GenJnlLine, //Input parameter of type Record
    ExpectedError@1001 : Text[250] ExpectedError //Input parameter of type Text
);

Parameters

GenJnlLine
Input parameter of type Record
ExpectedError
Input parameter of type Text

Remarks

The relevant search keywords are: Verify, General, Journal, Line, Err.

For a clarification about how this function works, refer to the code listed below.

      PaymentJnlExportErrorText.SETRANGE("Journal Template Name",GenJnlLine."Journal Template Name");
      PaymentJnlExportErrorText.SETRANGE("Journal Batch Name",GenJnlLine."Journal Batch Name");
      PaymentJnlExportErrorText.SETRANGE("Document No.",GenJnlLine."Document No.");
      PaymentJnlExportErrorText.SETRANGE("Journal Line No.",GenJnlLine."Line No.");
      PaymentJnlExportErrorText.SETRANGE("Error Text",ExpectedError);
      Assert.IsFalse(PaymentJnlExportErrorText.ISEMPTY,'Expected Error message cannot be found.');

Example

The below example is extracted from the test automation codeunit 134407 to show one way of using this function.

      Initialize;

      // Setup
      CreateVendorGenJnlLineWithRecipientBankAcc(GenJnlLine);
      GenJnlLine."Bal. Account Type" := GenJnlLine."Bal. Account Type"::"G/L Account";
      GenJnlLine.MODIFY;

      // Exercise
      CODEUNIT.RUN(CODEUNIT::"SEPA CT-Check Line",GenJnlLine);

      // Verify
      LibraryPaymentExport.VerifyGenJnlLineErr(GenJnlLine,MustBeBankAccErr);
Member of Lib.Library - Payment Export


Library - Payment Format Class

Lib.Library - Payment Format

COD130101 applies to ERM,W1,All.

Methods

Name | Description
CreateBankExportImportSetup@22 | The procedure CreateBankExportImportSetup is available in codeunit 130101.
CreateDataExchColumnDef@10 | The procedure CreateDataExchColumnDef is available in codeunit 130101.
CreateDataExchDef@1 | The procedure CreateDataExchDef is available in codeunit 130101.
CreateDataExchFieldMapping@18 | The procedure CreateDataExchFieldMapping is available in codeunit 130101.
CreateDataExchMapping@14 | The procedure CreateDataExchMapping is available in codeunit 130101.

See Also

Lib


CreateBankExportImportSetup@22 Method

The procedure CreateBankExportImportSetup is available in codeunit 130101.

Syntax

CreateBankExportImportSetup@22(
    VAR BankExportImportSetup@1000 : Record 1200 BankExportImportSetup, //Reference parameter of type Record
    DataExchDef@1001 : Record 1222 DataExchDef //Input parameter of type Record
);

Parameters

BankExportImportSetup
Reference parameter of type Record
DataExchDef
Input parameter of type Record

Remarks

The relevant search keywords are: Create, Bank, Export, Import, Setup.

For a clarification about how this function works, refer to the code listed below.

      BankExportImportSetup.VALIDATE(Code,DataExchDef.Code);
      BankExportImportSetup.VALIDATE(Name,DataExchDef.Name);
      BankExportImportSetup.VALIDATE(Direction,BankExportImportSetup.Direction::Export);
      BankExportImportSetup.VALIDATE("Data Exch. Def. Code",DataExchDef.Code);
      BankExportImportSetup.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134660 to show one way of using this function.

      LibraryPaymentFormat.CreateDataExchDef(
        DataExchDef,CODEUNIT::"Exp. Data Handling Gen. Jnl.",
        CODEUNIT::"Exp. Validation Gen. Jnl.",CODEUNIT::"Exp. Writing Gen. Jnl.",XMLPORT::"Export Generic CSV",
        CODEUNIT::"Save Data Exch. Blob Sample",CODEUNIT::"Exp. User Feedback Gen. Jnl.");

      DataExchLineDef.InsertRec(DataExchDef.Code,PaymentType,LibraryUtility.GenerateGUID,3);

      LibraryPaymentFormat.CreateDataExchColumnDef(DataExchColumnDef,DataExchDef.Code,DataExchLineDef.Code);

      LibraryPaymentFormat.CreateDataExchMapping(DataExchMapping,DataExchDef.Code,DataExchLineDef.Code,
        CODEUNIT::"Exp. Pre-Mapping Gen. Jnl.",CODEUNIT::"Exp. Mapping Gen. Jnl.",CODEUNIT::"Exp. Post-Mapping Gen. Jnl.");

      LibraryPaymentFormat.CreateDataExchFieldMapping(DataExchFieldMapping,DataExchDef.Code,DataExchLineDef.Code);

      LibraryPaymentFormat.CreateBankExportImportSetup(BankExportImportSetup,DataExchDef);

      EXIT(DataExchDef.Code);
Member of Lib.Library - Payment Format


CreateDataExchColumnDef@10 Method

The procedure CreateDataExchColumnDef is available in codeunit 130101.

Syntax

CreateDataExchColumnDef@10(
    VAR DataExchColumnDef@1000 : Record 1223 DataExchColumnDef, //Reference parameter of type Record
    DataExchDefCode@1001 : Code[20] DataExchDefCode, //Input parameter of type Code
    DataExchLineDefCode@1002 : Code[20] DataExchLineDefCode //Input parameter of type Code
);

Parameters

DataExchColumnDef
Reference parameter of type Record
DataExchDefCode
Input parameter of type Code
DataExchLineDefCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Data, Exchange, Column, Def.

For a clarification about how this function works, refer to the code listed below.

      DataExchColumnDef.InsertRec(DataExchDefCode,DataExchLineDefCode,1,GenJnlLine.FIELDCAPTION(Description),
        TRUE,DataExchColumnDef."Data Type"::Text,'','',GenJnlLine.FIELDNAME(Description));
      DataExchColumnDef.InsertRec(DataExchDefCode,DataExchLineDefCode,2,GenJnlLine.FIELDCAPTION("Posting Date"),
        TRUE,DataExchColumnDef."Data Type"::Date,'<Day,2><Month,2><Year4>','',GenJnlLine.FIELDNAME("Posting Date"));
      DataExchColumnDef.InsertRec(DataExchDefCode,DataExchLineDefCode,3,GenJnlLine.FIELDCAPTION(Amount),
        TRUE,DataExchColumnDef."Data Type"::Decimal,'<Precision,2><sign><Integer><Decimals><Comma,.>','',
        GenJnlLine.FIELDNAME(Amount));
      DataExchColumnDef.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134660 to show one way of using this function.

      LibraryPaymentFormat.CreateDataExchDef(
        DataExchDef,CODEUNIT::"Exp. Data Handling Gen. Jnl.",
        CODEUNIT::"Exp. Validation Gen. Jnl.",CODEUNIT::"Exp. Writing Gen. Jnl.",XMLPORT::"Export Generic CSV",
        CODEUNIT::"Save Data Exch. Blob Sample",CODEUNIT::"Exp. User Feedback Gen. Jnl.");

      DataExchLineDef.InsertRec(DataExchDef.Code,PaymentType,LibraryUtility.GenerateGUID,3);

      LibraryPaymentFormat.CreateDataExchColumnDef(DataExchColumnDef,DataExchDef.Code,DataExchLineDef.Code);

      LibraryPaymentFormat.CreateDataExchMapping(DataExchMapping,DataExchDef.Code,DataExchLineDef.Code,
        CODEUNIT::"Exp. Pre-Mapping Gen. Jnl.",CODEUNIT::"Exp. Mapping Gen. Jnl.",CODEUNIT::"Exp. Post-Mapping Gen. Jnl.");

      LibraryPaymentFormat.CreateDataExchFieldMapping(DataExchFieldMapping,DataExchDef.Code,DataExchLineDef.Code);

      LibraryPaymentFormat.CreateBankExportImportSetup(BankExportImportSetup,DataExchDef);

      EXIT(DataExchDef.Code);
Member of Lib.Library - Payment Format


CreateDataExchDef@1 Method

The procedure CreateDataExchDef is available in codeunit 130101.

Syntax

CreateDataExchDef@1(
    VAR DataExchDef@1000 : Record 1222 DataExchDef, //Reference parameter of type Record
    DataHandlingCodeunit@1005 : Integer DataHandlingCodeunit, //Input parameter of type Integer
    ValidationCodeunit@1004 : Integer ValidationCodeunit, //Input parameter of type Integer
    ReadingWritingCodeunit@1003 : Integer ReadingWritingCodeunit, //Input parameter of type Integer
    ReadingWritingXMLport@1001 : Integer ReadingWritingXMLport, //Input parameter of type Integer
    ExternalDataHandlingCodeunit@1002 : Integer ExternalDataHandlingCodeunit, //Input parameter of type Integer
    UserFeedbackCodeunit@1006 : Integer UserFeedbackCodeunit //Input parameter of type Integer
);

Parameters

DataExchDef
Reference parameter of type Record
DataHandlingCodeunit
Input parameter of type Integer
ValidationCodeunit
Input parameter of type Integer
ReadingWritingCodeunit
Input parameter of type Integer
ReadingWritingXMLport
Input parameter of type Integer
ExternalDataHandlingCodeunit
Input parameter of type Integer
UserFeedbackCodeunit
Input parameter of type Integer

Remarks

The relevant search keywords are: Create, Data, Exchange, Def.

For a clarification about how this function works, refer to the code listed below.

      DataExchDef.InsertRecForExport(
        LibraryUtility.GenerateGUID,LibraryUtility.GenerateGUID,DataExchDef.Type::"Payment Export",
        ReadingWritingXMLport,DataExchDef."File Type"::"Variable Text");
      DataExchDef.VALIDATE("Ext. Data Handling Codeunit",ExternalDataHandlingCodeunit);
      DataExchDef.VALIDATE("Reading/Writing Codeunit",ReadingWritingCodeunit);
      DataExchDef.VALIDATE("Validation Codeunit",ValidationCodeunit);
      DataExchDef.VALIDATE("Data Handling Codeunit",DataHandlingCodeunit);
      DataExchDef.VALIDATE("User Feedback Codeunit",UserFeedbackCodeunit);
      DataExchDef.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134162 to show one way of using this function.

      LibraryPaymentFormat.CreateDataExchDef(DataExchDef,0,0,
        0,XMLPORT::"Data Exch. Import - CSV",CODEUNIT::"Read Data Exch. from File",0);
      DataExchDef.VALIDATE(Type,DataExchDef.Type::"Payroll Import");
      DataExchDef.VALIDATE("File Encoding",DataExchDef."File Encoding"::WINDOWS);
      DataExchDef.VALIDATE("Column Separator",DataExchDef."Column Separator"::Comma);
      DataExchDef.MODIFY(TRUE);

      DataExchLineDef.InsertRec(DataExchDef.Code,DataExchDef.Code,DataExchDef.Code,2);

      DataExchColumnDef.InsertRec(DataExchDef.Code,DataExchLineDef.Code,1,GenJournalLine.FIELDCAPTION("Document No."),
        TRUE,DataExchColumnDef."Data Type"::Text,'','',GenJournalLine.FIELDNAME("Document No."));
      DataExchColumnDef.InsertRec(DataExchDef.Code,DataExchLineDef.Code,2,GenJournalLine.FIELDCAPTION(Amount),
        TRUE,DataExchColumnDef."Data Type"::Decimal,'<Precision,2><sign><Integer><Decimals><Comma,.>','en-US',
        GenJournalLine.FIELDNAME(Amount));

      DataExchMapping.InsertRecForExport(DataExchDef.Code,DataExchLineDef.Code,
        DATABASE::"Gen. Journal Line",DataExchDef.Code,CODEUNIT::"Process Gen. Journal  Lines");
      DataExchFieldMapping.InsertRec(DataExchDef.Code,DataExchLineDef.Code,
        DATABASE::"Gen. Journal Line",1,GenJournalLine.FIELDNO("Document No."),FALSE,0);
      DataExchFieldMapping.InsertRec(DataExchDef.Code,DataExchLineDef.Code,
        DATABASE::"Gen. Journal Line",2,GenJournalLine.FIELDNO(Amount),FALSE,1);
Member of Lib.Library - Payment Format


CreateDataExchFieldMapping@18 Method

The procedure CreateDataExchFieldMapping is available in codeunit 130101.

Syntax

CreateDataExchFieldMapping@18(
    VAR DataExchFieldMapping@1000 : Record 1225 DataExchFieldMapping, //Reference parameter of type Record
    DataExchDefCode@1002 : Code[20] DataExchDefCode, //Input parameter of type Code
    DataExchLineDefCode@1001 : Code[20] DataExchLineDefCode //Input parameter of type Code
);

Parameters

DataExchFieldMapping
Reference parameter of type Record
DataExchDefCode
Input parameter of type Code
DataExchLineDefCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Data, Exchange, Field, Mapping.

For a clarification about how this function works, refer to the code listed below.

      DataExchFieldMapping.InsertRec(DataExchDefCode,DataExchLineDefCode,
        DATABASE::"Payment Export Data",1,PaymentExportData.FIELDNO("Document No."),FALSE,0);
      DataExchFieldMapping.InsertRec(DataExchDefCode,DataExchLineDefCode,
        DATABASE::"Payment Export Data",2,PaymentExportData.FIELDNO("Transfer Date"),FALSE,0);
      DataExchFieldMapping.InsertRec(DataExchDefCode,DataExchLineDefCode,
        DATABASE::"Payment Export Data",3,PaymentExportData.FIELDNO(Amount),FALSE,1);

Example

The below example is extracted from the test automation codeunit 134660 to show one way of using this function.

      LibraryPaymentFormat.CreateDataExchDef(
        DataExchDef,CODEUNIT::"Exp. Data Handling Gen. Jnl.",
        CODEUNIT::"Exp. Validation Gen. Jnl.",CODEUNIT::"Exp. Writing Gen. Jnl.",XMLPORT::"Export Generic CSV",
        CODEUNIT::"Save Data Exch. Blob Sample",CODEUNIT::"Exp. User Feedback Gen. Jnl.");

      DataExchLineDef.InsertRec(DataExchDef.Code,PaymentType,LibraryUtility.GenerateGUID,3);

      LibraryPaymentFormat.CreateDataExchColumnDef(DataExchColumnDef,DataExchDef.Code,DataExchLineDef.Code);

      LibraryPaymentFormat.CreateDataExchMapping(DataExchMapping,DataExchDef.Code,DataExchLineDef.Code,
        CODEUNIT::"Exp. Pre-Mapping Gen. Jnl.",CODEUNIT::"Exp. Mapping Gen. Jnl.",CODEUNIT::"Exp. Post-Mapping Gen. Jnl.");

      LibraryPaymentFormat.CreateDataExchFieldMapping(DataExchFieldMapping,DataExchDef.Code,DataExchLineDef.Code);

      LibraryPaymentFormat.CreateBankExportImportSetup(BankExportImportSetup,DataExchDef);

      EXIT(DataExchDef.Code);
Member of Lib.Library - Payment Format


CreateDataExchMapping@14 Method

The procedure CreateDataExchMapping is available in codeunit 130101.

Syntax

CreateDataExchMapping@14(
    VAR DataExchMapping@1000 : Record 1224 DataExchMapping, //Reference parameter of type Record
    DataExchDefCode@1002 : Code[20] DataExchDefCode, //Input parameter of type Code
    DataExchLineDefCode@1001 : Code[20] DataExchLineDefCode, //Input parameter of type Code
    PreMappingCodeunit@1003 : Integer PreMappingCodeunit, //Input parameter of type Integer
    MappingCodeunit@1005 : Integer MappingCodeunit, //Input parameter of type Integer
    PostMappingCodeunit@1004 : Integer PostMappingCodeunit //Input parameter of type Integer
);

Parameters

DataExchMapping
Reference parameter of type Record
DataExchDefCode
Input parameter of type Code
DataExchLineDefCode
Input parameter of type Code
PreMappingCodeunit
Input parameter of type Integer
MappingCodeunit
Input parameter of type Integer
PostMappingCodeunit
Input parameter of type Integer

Remarks

The relevant search keywords are: Create, Data, Exchange, Mapping.

For a clarification about how this function works, refer to the code listed below.

      DataExchMapping.InsertRecForExport(DataExchDefCode,DataExchLineDefCode,
        DATABASE::"Payment Export Data",LibraryUtility.GenerateGUID,MappingCodeunit);
      DataExchMapping.VALIDATE("Pre-Mapping Codeunit",PreMappingCodeunit);
      DataExchMapping.VALIDATE("Post-Mapping Codeunit",PostMappingCodeunit);
      DataExchMapping.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134660 to show one way of using this function.

      LibraryPaymentFormat.CreateDataExchDef(
        DataExchDef,CODEUNIT::"Exp. Data Handling Gen. Jnl.",
        CODEUNIT::"Exp. Validation Gen. Jnl.",CODEUNIT::"Exp. Writing Gen. Jnl.",XMLPORT::"Export Generic CSV",
        CODEUNIT::"Save Data Exch. Blob Sample",CODEUNIT::"Exp. User Feedback Gen. Jnl.");

      DataExchLineDef.InsertRec(DataExchDef.Code,PaymentType,LibraryUtility.GenerateGUID,3);

      LibraryPaymentFormat.CreateDataExchColumnDef(DataExchColumnDef,DataExchDef.Code,DataExchLineDef.Code);

      LibraryPaymentFormat.CreateDataExchMapping(DataExchMapping,DataExchDef.Code,DataExchLineDef.Code,
        CODEUNIT::"Exp. Pre-Mapping Gen. Jnl.",CODEUNIT::"Exp. Mapping Gen. Jnl.",CODEUNIT::"Exp. Post-Mapping Gen. Jnl.");

      LibraryPaymentFormat.CreateDataExchFieldMapping(DataExchFieldMapping,DataExchDef.Code,DataExchLineDef.Code);

      LibraryPaymentFormat.CreateBankExportImportSetup(BankExportImportSetup,DataExchDef);

      EXIT(DataExchDef.Code);
Member of Lib.Library - Payment Format


Library - Permissions Class

Lib.Library - Permissions

COD132214 applies to W1,All.

Methods

Name | Description
AddPermission@12 | The procedure AddPermission is available in codeunit 132214.
AddPermissionSetToUser@3 | The procedure AddPermissionSetToUser is available in codeunit 132214.
AddPermissionSetToUserGroup@35 | The procedure AddPermissionSetToUserGroup is available in codeunit 132214.
AddUserToUserGroup@10 | The procedure AddUserToUserGroup is available in codeunit 132214.
CreatePermissionSet@11 | The procedure CreatePermissionSet is available in codeunit 132214.
CreateTenantPermissionSet@16 | The procedure CreateTenantPermissionSet is available in codeunit 132214.
CreateUser@7 | The procedure CreateUser is available in codeunit 132214.
CreateUserGroup@6 | The procedure CreateUserGroup is available in codeunit 132214.
CreateUserGroupMember@1 | The procedure CreateUserGroupMember is available in codeunit 132214.
CreateUsersUserGroupsPermissionSets@29 | The procedure CreateUsersUserGroupsPermissionSets is available in codeunit 132214.
GetMyUser@8 | The procedure GetMyUser is available in codeunit 132214.

See Also

Lib


AddPermission@12 Method

The procedure AddPermission is available in codeunit 132214.

Syntax

AddPermission@12(
    RoleID@1000 : Code[20] RoleID, //Input parameter of type Code
    ObjectType@1001 : Option ObjectType, //Input parameter of type Option
    ObjectID@1002 : Integer ObjectID //Input parameter of type Integer
);

Parameters

RoleID
Input parameter of type Code
ObjectType
Input parameter of type Option
ObjectID
Input parameter of type Integer

Remarks

The relevant search keywords are: Add, Permission.

For a clarification about how this function works, refer to the code listed below.

      Permission.INIT;
      Permission."Role ID" := RoleID;
      Permission."Object Type" := ObjectType;
      Permission."Object ID" := ObjectID;
      IF ObjectType = Permission."Object Type"::"Table Data" THEN BEGIN
        Permission."Read Permission" := Permission."Read Permission"::Yes;
        Permission."Insert Permission" := Permission."Insert Permission"::" ";
        Permission."Modify Permission" := Permission."Modify Permission"::" ";
        Permission."Delete Permission" := Permission."Delete Permission"::" ";
      END ELSE
        Permission."Execute Permission" := Permission."Execute Permission"::" ";
      Permission.INSERT;

Example

The below example is extracted from the test automation codeunit 134610 to show one way of using this function.

      // Verifies that report 9000 adds another permission set to the current
      // Init
      LibraryPermissions.CreatePermissionSet(SourcePermissionSet,'');
      LibraryPermissions.AddPermission(SourcePermissionSet."Role ID",Permission."Object Type"::"Table Data",DATABASE::"Sales Header");
      LibraryPermissions.AddPermission(
        SourcePermissionSet."Role ID",Permission."Object Type"::"Table Data",DATABASE::"Purchase Header");
      LibraryPermissions.CreatePermissionSet(DestPermissionSet,'');
      LibraryPermissions.AddPermission(DestPermissionSet."Role ID",Permission."Object Type"::"Table Data",DATABASE::"Purchase Header");
      Permission.SETRANGE("Role ID",DestPermissionSet."Role ID");
      Assert.AreEqual(1,Permission.COUNT,'');

      // Execute
      GlobalSourcePermissionSetRoleID := SourcePermissionSet."Role ID";
      AddSubtractPermissionSet.SetDestination(DestPermissionSet."Role ID");
      AddSubtractPermissionSet.RUNMODAL; // triggers AddSubractPermissionSetHandler

      // Verify
      Assert.AreEqual(2,Permission.COUNT,'');
      TestCleanup;
Member of Lib.Library - Permissions


AddPermissionSetToUser@3 Method

The procedure AddPermissionSetToUser is available in codeunit 132214.

Syntax

AddPermissionSetToUser@3(
    VAR User@1000 : Record 2000000120 User, //Reference parameter of type Record
    VAR PermissionSet@1001 : Record 2000000004 PermissionSet //Reference parameter of type Record
);

Parameters

User
Reference parameter of type Record
PermissionSet
Reference parameter of type Record

Remarks

The relevant search keywords are: Add, Permission, Set, To, User.

For a clarification about how this function works, refer to the code listed below.

      AccessControl.INIT;
      AccessControl."Role ID" := PermissionSet."Role ID";
      AccessControl.Scope := AccessControl.Scope::System;
      AccessControl."User Security ID" := User."User Security ID";

      AccessControl.INSERT

Example

There are no examples available.
Member of Lib.Library - Permissions


AddPermissionSetToUserGroup@35 Method

The procedure AddPermissionSetToUserGroup is available in codeunit 132214.

Syntax

AddPermissionSetToUserGroup@35(
    VAR UserGroup@1000 : Record 9000 UserGroup, //Reference parameter of type Record
    VAR PermissionSet@1001 : Record 2000000004 PermissionSet //Reference parameter of type Record
);

Parameters

UserGroup
Reference parameter of type Record
PermissionSet
Reference parameter of type Record

Remarks

The relevant search keywords are: Add, Permission, Set, To, User, Group.

For a clarification about how this function works, refer to the code listed below.

      UserGroupPermissionSet.INIT;
      UserGroupPermissionSet."User Group Code" := UserGroup.Code;
      UserGroupPermissionSet."Role ID" := PermissionSet."Role ID";
      UserGroupPermissionSet.INSERT

Example

The below example is extracted from the test automation codeunit 134610 to show one way of using this function.

      // Tests that invoking action Copy Permission Set starts report 9802.
      // Init
      CopyToUserGroup := COPYSTR(GetGuidString,1,20);
      LibraryPermissions.CreatePermissionSet(PermissionSet,'');
      LibraryPermissions.CreateUserGroup(UserGroup,'');
      LibraryPermissions.AddPermissionSetToUserGroup(UserGroup,PermissionSet);

      // Execute
      UserGroups.OPENEDIT;
      UserGroups.FIRST;
      UserGroups.CopyUserGroup.INVOKE;
      UserGroups.CLOSE;

      // Verification: PageHandler is executed.
      UserGroup.GET(CopyToUserGroup);
      UserGroupPermissionSet.SETRANGE("User Group Code",UserGroup.Code);
      UserGroupPermissionSet.FINDFIRST;
      Assert.AreEqual(PermissionSet."Role ID",UserGroupPermissionSet."Role ID",'');
      TestCleanup;
Member of Lib.Library - Permissions


AddUserToUserGroup@10 Method

The procedure AddUserToUserGroup is available in codeunit 132214.

Syntax

AddUserToUserGroup@10(
    VAR UserGroup@1000 : Record 9000 UserGroup, //Reference parameter of type Record
    VAR User@1001 : Record 2000000120 User, //Reference parameter of type Record
    NewCompanyName@1003 : Text[30] NewCompanyName //Input parameter of type Text
);

Parameters

UserGroup
Reference parameter of type Record
User
Reference parameter of type Record
NewCompanyName
Input parameter of type Text

Remarks

The relevant search keywords are: Add, User, To, User, Group.

For a clarification about how this function works, refer to the code listed below.

      UserGroupMember.INIT;
      UserGroupMember."User Group Code" := UserGroup.Code;
      UserGroupMember."User Security ID" := User."User Security ID";
      UserGroupMember."Company Name" := NewCompanyName;
      UserGroupMember.INSERT

Example

The below example is extracted from the test automation codeunit 134610 to show one way of using this function.

      // Test function IsUserMember in table 9000
      // Init
      LibraryPermissions.GetMyUser(User);
      LibraryPermissions.CreateUserGroup(UserGroup,'');
      Assert.IsFalse(UserGroup.IsUserMember(User,''),'');
      LibraryPermissions.AddUserToUserGroup(UserGroup,User,'');

      // Execute / validate
      Assert.IsTrue(UserGroup.IsUserMember(User,''),'');
      TestCleanup;
Member of Lib.Library - Permissions


CreatePermissionSet@11 Method

The procedure CreatePermissionSet is available in codeunit 132214.

Syntax

CreatePermissionSet@11(
    VAR PermissionSet@1000 : Record 2000000004 PermissionSet, //Reference parameter of type Record
    NewCode@1001 : Code[20] NewCode //Input parameter of type Code
);

Parameters

PermissionSet
Reference parameter of type Record
NewCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Permission, Set.

For a clarification about how this function works, refer to the code listed below.

      IF NewCode <> '' THEN
        PermissionSet."Role ID" := NewCode
      ELSE
        PermissionSet."Role ID" := COPYSTR(GetGuidString,1,MAXSTRLEN(PermissionSet."Role ID"));
      PermissionSet.Name := PermissionSet."Role ID" + ' Name';
      PermissionSet.INSERT;

Example

The below example is extracted from the test automation codeunit 134610 to show one way of using this function.

      // Tests that invoking action Copy Permission Set starts report 9802.
      // Init
      CopyToUserGroup := COPYSTR(GetGuidString,1,20);
      LibraryPermissions.CreatePermissionSet(PermissionSet,'');
      LibraryPermissions.CreateUserGroup(UserGroup,'');
      LibraryPermissions.AddPermissionSetToUserGroup(UserGroup,PermissionSet);

      // Execute
      UserGroups.OPENEDIT;
      UserGroups.FIRST;
      UserGroups.CopyUserGroup.INVOKE;
      UserGroups.CLOSE;

      // Verification: PageHandler is executed.
      UserGroup.GET(CopyToUserGroup);
      UserGroupPermissionSet.SETRANGE("User Group Code",UserGroup.Code);
      UserGroupPermissionSet.FINDFIRST;
      Assert.AreEqual(PermissionSet."Role ID",UserGroupPermissionSet."Role ID",'');
      TestCleanup;
Member of Lib.Library - Permissions


CreateTenantPermissionSet@16 Method

The procedure CreateTenantPermissionSet is available in codeunit 132214.

Syntax

CreateTenantPermissionSet@16(
    VAR TenantPermissionSet@1000 : Record 2000000165 TenantPermissionSet, //Reference parameter of type Record
    NewCode@1001 : Code[20] NewCode, //Input parameter of type Code
    AppID@1002 : GUID AppID //Input parameter of type GUID
);

Parameters

TenantPermissionSet
Reference parameter of type Record
NewCode
Input parameter of type Code
AppID
Input parameter of type GUID

Remarks

The relevant search keywords are: Create, Tenant, Permission, Set.

For a clarification about how this function works, refer to the code listed below.

      IF NewCode <> '' THEN
        TenantPermissionSet."Role ID" := NewCode
      ELSE
        TenantPermissionSet."Role ID" := COPYSTR(GetGuidString,1,MAXSTRLEN(TenantPermissionSet."Role ID"));
      TenantPermissionSet.Name := TenantPermissionSet."Role ID" + ' Name';
      TenantPermissionSet."App ID" := AppID;
      TenantPermissionSet.INSERT;

Example

The below example is extracted from the test automation codeunit 134611 to show one way of using this function.

      CLEAR(NullGuid); // Ensure the null GUID is cleared

      User.DELETEALL;

      // Need to add at least one super user.
      CODEUNIT.RUN(CODEUNIT::"Users - Create Super User");

      // Set up 3 users
      FOR i := 1 TO 3 DO
        LibraryPermissions.CreateUser(User,LibraryUtility.GenerateRandomAlphabeticText(10,0),FALSE);

      // Set up 3 groups
      FOR i := 1 TO 3 DO
        LibraryPermissions.CreateUserGroup(
          UserGroup,LibraryUtility.GenerateRandomCode(UserGroup.FIELDNO(Code),DATABASE::"User Group"));

      // Set up 2 system permission sets
      FOR i := 1 TO 2 DO BEGIN
        PermissionRoles[i] := LibraryUtility.GenerateRandomCode(PermissionSet.FIELDNO("Role ID"),DATABASE::"Permission Set");
        LibraryPermissions.CreatePermissionSet(PermissionSet,PermissionRoles[i]);
      END;

      // Add permissions to the new permission sets
      PermissionSet.FIND('-');
      LibraryPermissions.AddPermission(PermissionRoles[1],Permission."Object Type"::Report,REPORT::Statement);
      LibraryPermissions.AddPermission(PermissionRoles[1],Permission."Object Type"::Report,REPORT::"Mini Statement");

      PermissionSet.NEXT;
      LibraryPermissions.AddPermission(PermissionRoles[2],Permission."Object Type"::Report,REPORT::"Sales - Quote");
      LibraryPermissions.AddPermission(PermissionRoles[2],Permission."Object Type"::Report,REPORT::"Mini Sales - Quote");

      // Set up 2 tenant permission sets (non-app)
      FOR i := 1 TO 2 DO BEGIN
        TenantPermissionRoles[i] :=
          LibraryUtility.GenerateRandomCode(TenantPermissionSet.FIELDNO("Role ID"),DATABASE::"Permission Set");
        LibraryPermissions.CreateTenantPermissionSet(TenantPermissionSet,TenantPermissionRoles[i],NullGuid);
      END;

      // Add permissions to the new permission sets
      TenantPermissionSet.FIND('-');
      LibraryPermissions.AddPermission(TenantPermissionRoles[1],Permission."Object Type"::Table,DATABASE::Customer);
      LibraryPermissions.AddPermission(TenantPermissionRoles[1],Permission."Object Type"::Table,DATABASE::Vendor);
      TenantPermissionSet.NEXT;
      LibraryPermissions.AddPermission(TenantPermissionRoles[2],Permission."Object Type"::Table,DATABASE::"Sales Header");
      LibraryPermissions.AddPermission(TenantPermissionRoles[2],Permission."Object Type"::Table,DATABASE::"Sales Invoice Header");

      // Set up 2 Nav App permission sets
      FOR i := 1 TO 2 DO BEGIN
        AppPermissionRoles[i] := LibraryUtility.GenerateRandomCode(AppPermissionSet.FIELDNO("Role ID"),DATABASE::"Permission Set");
        AppGUIDs[i] := CREATEGUID;
        LibraryPermissions.CreateTenantPermissionSet(AppPermissionSet,AppPermissionRoles[i],AppGUIDs[i]);
      END;
      NavApp.INIT;
      NavApp."Package ID" := AppGUIDs[1];
      NavApp.ID := AppGUIDs[1];
      NavApp.Name := LibraryUtility.GenerateRandomAlphabeticText(10,0);
      NavApp.INSERT;
      NavApp.INIT;
      NavApp."Package ID" := AppGUIDs[2];
      NavApp.Name := LibraryUtility.GenerateRandomAlphabeticText(10,0);
      NavApp.ID := AppGUIDs[2];
      NavApp.INSERT;

      // Add permissions to the new permission sets
      AppPermissionSet.GET(AppGUIDs[1],AppPermissionRoles[1]);
      LibraryPermissions.AddPermission(AppPermissionRoles[1],Permission."Object Type"::Table,PAGE::"Customer Card");
      LibraryPermissions.AddPermission(AppPermissionRoles[1],Permission."Object Type"::Table,PAGE::"Vendor Card");
      AppPermissionSet.NEXT;
      LibraryPermissions.AddPermission(AppPermissionRoles[2],Permission."Object Type"::Table,PAGE::"Customer Statistics");
      LibraryPermissions.AddPermission(AppPermissionRoles[2],Permission."Object Type"::Table,PAGE::"Vendor Statistics");
Member of Lib.Library - Permissions


CreateUser@7 Method

The procedure CreateUser is available in codeunit 132214.

Syntax

CreateUser@7(
    VAR User@1002 : Record 2000000120 User, //Reference parameter of type Record
    NewUserName@1000 : Text[50] NewUserName, //Input parameter of type Text
    IsWindowsUser@1001 : Boolean IsWindowsUser //Input parameter of type Boolean
);

Parameters

User
Reference parameter of type Record
NewUserName
Input parameter of type Text
IsWindowsUser
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, User.

For a clarification about how this function works, refer to the code listed below.

      User.INIT;
      User."User Security ID" := CREATEGUID;
      IF NewUserName = '' THEN
        User."User Name" := COPYSTR(GetGuidString,1,MAXSTRLEN(User."User Name"))
      ELSE
        User."User Name" := NewUserName;
      User."Full Name" := User."User Name";
      IF IsWindowsUser THEN
        User."Windows Security ID" := SID(User."User Name");
      User.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134610 to show one way of using this function.

      // Tests the lookup and addition of a user as a new member.
      // Init
      Initialize;
      LibraryPermissions.CreateUserGroup(UserGroup,'');
      LibraryPermissions.CreateUser(User,'',FALSE);
      UserGroupMember.SETRANGE("User Group Code",UserGroup.Code);
      Assert.AreEqual(0,UserGroupMember.COUNT,'');

      // Execution
      UserGroupMember.AddUsers('');

      // Verification
      Assert.AreEqual(1,UserGroupMember.COUNT,'');
      TestCleanup;
Member of Lib.Library - Permissions


CreateUserGroup@6 Method

The procedure CreateUserGroup is available in codeunit 132214.

Syntax

CreateUserGroup@6(
    VAR UserGroup@1000 : Record 9000 UserGroup, //Reference parameter of type Record
    NewCode@1001 : Code[20] NewCode //Input parameter of type Code
);

Parameters

UserGroup
Reference parameter of type Record
NewCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, User, Group.

For a clarification about how this function works, refer to the code listed below.

      UserGroup.INIT;
      IF NewCode = '' THEN
        UserGroup.Code := COPYSTR(GetGuidString,1,MAXSTRLEN(UserGroup.Code))
      ELSE
        UserGroup.Code := NewCode;
      UserGroup.Name := UserGroup.Code;
      UserGroup.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134610 to show one way of using this function.

      // Verify that the OnDelete trigger of table 9000 also deletes from table 9003.
      // Init
      LibraryPermissions.CreateUserGroup(UserGroup,'');
      CreateUserGroupPermissionSet(UserGroupPermissionSet,UserGroup.Code,'X');
      UserGroupPermissionSet.SETRANGE("User Group Code",UserGroup.Code);
      Assert.AreEqual(1,UserGroupPermissionSet.COUNT,'');

      // Execute
      UserGroup.DELETE(TRUE);

      // Verfiy
      Assert.AreEqual(0,UserGroupPermissionSet.COUNT,'');
      TestCleanup;
Member of Lib.Library - Permissions


CreateUserGroupMember@1 Method

The procedure CreateUserGroupMember is available in codeunit 132214.

Syntax

CreateUserGroupMember@1(
    VAR UserGroup@1000 : Record 9000 UserGroup, //Reference parameter of type Record
    VAR UserGroupMember@1001 : Record 9001 UserGroupMember //Reference parameter of type Record
);

Parameters

UserGroup
Reference parameter of type Record
UserGroupMember
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, User, Group, Member.

For a clarification about how this function works, refer to the code listed below.

      GetMyUser(User);
      UserGroupMember.INIT;
      UserGroupMember."User Group Code" := UserGroup.Code;
      UserGroupMember."User Security ID" := User."User Security ID";
      IF UserGroupMember.INSERT THEN;

Example

The below example is extracted from the test automation codeunit 134610 to show one way of using this function.

      // Verify that the OnDelete trigger of table 9000 prevents deletion if there are members.
      // Init
      LibraryPermissions.CreateUserGroup(UserGroup,'');
      LibraryPermissions.CreateUserGroupMember(UserGroup,UserGroupMember);

      // Execute + Verfiy
      ASSERTERROR UserGroup.DELETE(TRUE);
      TestCleanup;
Member of Lib.Library - Permissions


CreateUsersUserGroupsPermissionSets@29 Method

The procedure CreateUsersUserGroupsPermissionSets is available in codeunit 132214.

Syntax

CreateUsersUserGroupsPermissionSets@29(
      //param element not supplied
);

Remarks

The relevant search keywords are: Create, Users, User, Groups, Permission, Sets.

For a clarification about how this function works, refer to the code listed below.

      // Creates a batch of test data, using other functions in this library
      UserGroup.SETFILTER(Code,'TEST*');
      UserGroup.DELETEALL(TRUE);
      UserGroup.SETRANGE(Code);
      PermissionSet.SETFILTER("Role ID",'TEST*');
      PermissionSet.DELETEALL(TRUE);
      Initialize;
      FOR i := 1 TO 15 DO BEGIN
        NewCode := STRSUBSTNO('TEST%1',i);
        User.SETRANGE("User Name",NewCode);
        IF User.ISEMPTY THEN
          CreateUser(User,NewCode,FALSE);
        IF NOT UserGroup.GET(NewCode) THEN
          CreateUserGroup(UserGroup,NewCode);
        IF NOT PermissionSet.GET(NewCode) THEN
          CreatePermissionSet(PermissionSet,NewCode);
      END;

Example

The below example is extracted from the test automation codeunit 134610 to show one way of using this function.

      // Test page 9816 which is a 'matrix'-like presentation of permission sets by users.
      // Init
      LibraryPermissions.CreateUsersUserGroupsPermissionSets;
      LibraryPermissions.GetMyUser(User);

      // Execute
      PermissionSetbyUser.OPENEDIT;
      PermissionSetbyUser.ShowDomainName.SETVALUE(FALSE);
      PermissionSetbyUser.SelectedCompany.SETVALUE(COMPANYNAME);
      MoreRecords := PermissionSetbyUser.FIRST;
      WHILE MoreRecords AND (COPYSTR(PermissionSetbyUser."Role ID".VALUE,1,4) <> 'TEST') DO
        MoreRecords := PermissionSetbyUser.NEXT;
      SelectedPermissionSet := PermissionSetbyUser."Role ID".VALUE;
      PermissionSet.GET(SelectedPermissionSet);

      AccessControl.SETRANGE("Company Name",COMPANYNAME);
      AccessControl.SETRANGE("Role ID",PermissionSet."Role ID");
      Assert.AreEqual(0,AccessControl.COUNT,'');

      PermissionSetbyUser.AllUsersHavePermission.SETVALUE(TRUE);
      PermissionSetbyUser.AllUsersHavePermission.SETVALUE(FALSE);
      PermissionSetbyUser.Column1.SETVALUE(TRUE);
      PermissionSetbyUser.Column2.SETVALUE(TRUE);
      PermissionSetbyUser.Column3.SETVALUE(TRUE);
      PermissionSetbyUser.Column4.SETVALUE(TRUE);
      PermissionSetbyUser.Column5.SETVALUE(TRUE);
      PermissionSetbyUser.Column6.SETVALUE(TRUE);
      PermissionSetbyUser.Column7.SETVALUE(TRUE);
      PermissionSetbyUser.Column8.SETVALUE(TRUE);
      PermissionSetbyUser.Column9.SETVALUE(TRUE);
      PermissionSetbyUser.Column10.SETVALUE(TRUE);
      FirstUserID := PermissionSetbyUser.Column1.CAPTION;
      PermissionSetbyUser.ColumnRight.INVOKE;
      WHILE FirstUserID <> PermissionSetbyUser.Column1.CAPTION DO BEGIN
        PermissionSetbyUser.Column10.SETVALUE(TRUE);
        FirstUserID := PermissionSetbyUser.Column1.CAPTION;
        PermissionSetbyUser.ColumnRight.INVOKE;
      END;
      PermissionSetbyUser.AllColumnsLeft.INVOKE;
      PermissionSetbyUser.ColumnLeft.INVOKE;
      PermissionSetbyUser.AllColumnsRight.INVOKE;

      // Validate
      Assert.AreEqual(User.COUNT,AccessControl.COUNT,'');
      PermissionSetbyUser.AllUsersHavePermission.SETVALUE(FALSE);
      Assert.AreEqual(0,AccessControl.COUNT,'');
      PermissionSetbyUser.CLOSE;
      TestCleanup;
Member of Lib.Library - Permissions


GetMyUser@8 Method

The procedure GetMyUser is available in codeunit 132214.

Syntax

GetMyUser@8(
    VAR User@1000 : Record 2000000120 User //Reference parameter of type Record
);

Parameters

User
Reference parameter of type Record

Remarks

The relevant search keywords are: Get, My, User.

For a clarification about how this function works, refer to the code listed below.

      Initialize;
      User.SETRANGE("User Name",USERID);
      User.FINDFIRST;
      User.SETRANGE("User Name");

Example

The below example is extracted from the test automation codeunit 134610 to show one way of using this function.

      // Tests codeunit 9000 - creation of an admin/SUPER user for currently logged in user.
      // Init: Not possible to delete existing users, so this will only give full coverage in a clean DB

      // Execute
      Users.OPENEDIT;
      Users.AddMeAsSuper.INVOKE;
      Users.CLOSE;

      // Verify
      LibraryPermissions.GetMyUser(User);
      AccessControl.GET(User."User Security ID",'SUPER');
      Permission.SETRANGE("Role ID",'SUPER');
      Assert.IsTrue(Permission.COUNT >= 9,'');
      TestCleanup;
Member of Lib.Library - Permissions


Library - Planning Class

Lib.Library - Planning

COD132203 applies to SCM,COSTING,W1,All.
Unsupported version tags:
Contains all utility functions related to Planning.

Methods

Name | Description
CalcNetChangePlanForPlanWksh@114 | The procedure CalcNetChangePlanForPlanWksh is available in codeunit 132203.
CalcRegenPlanForPlanWksh@74 | The procedure CalcRegenPlanForPlanWksh is available in codeunit 132203.
CalcRegenPlanForPlanWkshPlanningParams@5 | The procedure CalcRegenPlanForPlanWkshPlanningParams is available in codeunit 132203.
CalculateLowLevelCode@3 | The procedure CalculateLowLevelCode is available in codeunit 132203.
CalculateOrderPlanJob@6 | The procedure CalculateOrderPlanJob is available in codeunit 132203.
CalculateOrderPlanProduction@161 | The procedure CalculateOrderPlanProduction is available in codeunit 132203.
CalculateOrderPlanSales@152 | The procedure CalculateOrderPlanSales is available in codeunit 132203.
CalculateOrderPlanService@4 | The procedure CalculateOrderPlanService is available in codeunit 132203.
CalculatePlanForReqWksh@1 | The procedure CalculatePlanForReqWksh is available in codeunit 132203.
CarryOutActionMsgPlanWksh@73 | The procedure CarryOutActionMsgPlanWksh is available in codeunit 132203.
CarryOutAMSubcontractWksh@35 | The procedure CarryOutAMSubcontractWksh is available in codeunit 132203.
CarryOutPlanWksh@126 | The procedure CarryOutPlanWksh is available in codeunit 132203.
CarryOutReqWksh@128 | The procedure CarryOutReqWksh is available in codeunit 132203.
CreateManufUserTemplate@170 | The procedure CreateManufUserTemplate is available in codeunit 132203.
CreatePlanningComponent@155 | The procedure CreatePlanningComponent is available in codeunit 132203.
CreatePlanningRoutingLine@156 | The procedure CreatePlanningRoutingLine is available in codeunit 132203.
CreateProdOrderUsingPlanning@125 | The procedure CreateProdOrderUsingPlanning is available in codeunit 132203.
CreateRequisitionLine@2 | The procedure CreateRequisitionLine is available in codeunit 132203.
CreateRequisitionWkshName@93 | The procedure CreateRequisitionWkshName is available in codeunit 132203.
GetActionMessages@7 | The procedure GetActionMessages is available in codeunit 132203.
GetSalesOrders@45 | The procedure GetSalesOrders is available in codeunit 132203.
GetSpecialOrder@63 | The procedure GetSpecialOrder is available in codeunit 132203.
MakeSupplyOrders@162 | The procedure MakeSupplyOrders is available in codeunit 132203.
RefreshPlanningLine@44 | The procedure RefreshPlanningLine is available in codeunit 132203.
SelectRequisitionTemplateName@1033 | The procedure SelectRequisitionTemplateName is available in codeunit 132203.
SelectRequisitionWkshName@1019 | The procedure SelectRequisitionWkshName is available in codeunit 132203.

See Also

Lib


CalcNetChangePlanForPlanWksh@114 Method

The procedure CalcNetChangePlanForPlanWksh is available in codeunit 132203.

Syntax

CalcNetChangePlanForPlanWksh@114(
    VAR ItemRec@1002 : Record 27 ItemRec, //Reference parameter of type Record
    OrderDate@1001 : Date OrderDate, //Input parameter of type Date
    ToDate@1000 : Date ToDate, //Input parameter of type Date
    RespectPlanningParameters@1005 : Boolean RespectPlanningParameters //Input parameter of type Boolean
);

Parameters

ItemRec
Reference parameter of type Record
OrderDate
Input parameter of type Date
ToDate
Input parameter of type Date
RespectPlanningParameters
Input parameter of type Boolean

Remarks

The relevant search keywords are: Calc, Net, Change, Plan, For, Plan, Wksh.

For a clarification about how this function works, refer to the code listed below.

      CalculatePlanOnPlanningWorksheet(ItemRec,OrderDate,ToDate,RespectPlanningParameters,FALSE);  // Passing False for Regenerative Boolean.

Example

The below example is extracted from the test automation codeunit 137008 to show one way of using this function.

      Item.SETRANGE("No.",ItemNo);
      LibraryPlanning.CalcNetChangePlanForPlanWksh(Item,WORKDATE,WORKDATE,TRUE);
Member of Lib.Library - Planning


CalcRegenPlanForPlanWksh@74 Method

The procedure CalcRegenPlanForPlanWksh is available in codeunit 132203.

Syntax

CalcRegenPlanForPlanWksh@74(
    VAR ItemRec@1002 : Record 27 ItemRec, //Reference parameter of type Record
    OrderDate@1001 : Date OrderDate, //Input parameter of type Date
    ToDate@1000 : Date ToDate //Input parameter of type Date
);

Parameters

ItemRec
Reference parameter of type Record
OrderDate
Input parameter of type Date
ToDate
Input parameter of type Date

Remarks

The relevant search keywords are: Calc, Regen, Plan, For, Plan, Wksh.

For a clarification about how this function works, refer to the code listed below.

      CalcRegenPlanForPlanWkshPlanningParams(ItemRec,OrderDate,ToDate,FALSE);

Example

The below example is extracted from the test automation codeunit 136131 to show one way of using this function.

      // Check Planning Lines for Sevice and Job Demand using Reordering Policy as Order after running Calculate Regenerative Plan.

      // 1. Setup: Create Item with Reordering Policy as Order, Create demand for Service and Job.
      Initialize;
      Quantity := RANDOM(10);  // Assigning Random integer value.
      CreateItem(Item,Item."Reordering Policy"::Order);
      CreateJobDemand(Item."No.",Quantity);
      CreateServiceDemand(Item."No.",Quantity);

      // 2. Exercise: Calculate Regenerative Plan. Using Random Date for Order Date.
      LibraryPlanning.CalcRegenPlanForPlanWksh(Item,WORKDATE,CALCDATE('<' + FORMAT(RANDOM(10)) + 'D>',WORKDATE));

      // 3. Verify: Verify Planning Worksheet Lines.
      VerifyRequisitionLine(Item."No.",Quantity);
Member of Lib.Library - Planning


CalcRegenPlanForPlanWkshPlanningParams@5 Method

The procedure CalcRegenPlanForPlanWkshPlanningParams is available in codeunit 132203.

Syntax

CalcRegenPlanForPlanWkshPlanningParams@5(
    VAR ItemRec@1002 : Record 27 ItemRec, //Reference parameter of type Record
    OrderDate@1001 : Date OrderDate, //Input parameter of type Date
    ToDate@1000 : Date ToDate, //Input parameter of type Date
    RespectPlanningParameters@1005 : Boolean RespectPlanningParameters //Input parameter of type Boolean
);

Parameters

ItemRec
Reference parameter of type Record
OrderDate
Input parameter of type Date
ToDate
Input parameter of type Date
RespectPlanningParameters
Input parameter of type Boolean

Remarks

The relevant search keywords are: Calc, Regen, Plan, For, Plan, Wksh, Planning, Params.

For a clarification about how this function works, refer to the code listed below.

      CalculatePlanOnPlanningWorksheet(ItemRec,OrderDate,ToDate,RespectPlanningParameters,TRUE);  // Passing True for Regenerative Boolean.

Example

The below example is extracted from the test automation codeunit 137045 to show one way of using this function.

      // Check Sales Return Order page will open from Order Tracking.

      // Setup : create item,Sales order and calculated Regenrative plan
      Initialize;
      CreateItemWithReorderValues(Item);
      CreateSalesOrder(SalesHeader,Item."No.",'',-LibraryRandom.RandDec(15,2),SalesHeader."Document Type"::"Return Order");
      LibraryVariableStorage.Enqueue(SalesHeader."No.");
      LibraryPlanning.CalcRegenPlanForPlanWkshPlanningParams(
        Item,WORKDATE,CALCDATE(STRSUBSTNO('<%1m>',LibraryRandom.RandInt(3)),WORKDATE),FALSE);

      // Exercise : Open Planning work sheet and invoke Order Tracking page.
      OpenOrderTrackingFromPlanWorkSheet(Item."No.");

      // Verify : Verification of opening SalesReturnOrder Page done in SalesReturnOrderHandler.
Member of Lib.Library - Planning


CalculateLowLevelCode@3 Method

The procedure CalculateLowLevelCode is available in codeunit 132203.

Syntax

CalculateLowLevelCode@3(
      //param element not supplied
);

Remarks

The relevant search keywords are: Calculate, Low, Level, Code.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(CalcLowLevelCode);
      CalcLowLevelCode.RUN;

Example

The below example is extracted from the test automation codeunit 137063 to show one way of using this function.

      // Verify Low level Code after changing status of Production BOM Version.
      // Setup: Create two level of Item Hierarchy.
      Initialize;
      CreateItemHierarchy(ProductionBOMHeader,ParentItem,ChildItem,LibraryRandom.RandInt(5));
      CreateItemHierarchy(GrandProductionBOMHeader,GrandParentItem,ParentItem,LibraryRandom.RandInt(5));
      LibraryVariableStorage.Enqueue(LowLevelCodeQst);  // Enqueue value for Confirm Handler.
      LibraryPlanning.CalculateLowLevelCode;

      // Exercise: Create Production BOM Version and change Status.
      CreateBOMVersionAndCertify(ProductionBOMHeader."No.",ParentItem."Base Unit of Measure");

      // Verify: Verify Low Level Code.
      VerifyBOMHeaderLLC(ProductionBOMHeader."No.",2);  // Value is important for Test.

      // Exercise.
      LibraryVariableStorage.Enqueue(LowLevelCodeQst);  // Enqueue value for Confirm Handler.
      LibraryPlanning.CalculateLowLevelCode;

      // Verify: Verify Low Level Code.
      VerifyBOMHeaderLLC(ProductionBOMHeader."No.",2);  // Value is important for Test.
Member of Lib.Library - Planning


CalculateOrderPlanJob@6 Method

The procedure CalculateOrderPlanJob is available in codeunit 132203.

Syntax

CalculateOrderPlanJob@6(
    VAR RequisitionLine@1000 : Record 246 RequisitionLine //Reference parameter of type Record
);

Parameters

RequisitionLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Calculate, Order, Plan, Job.

For a clarification about how this function works, refer to the code listed below.

      OrderPlanningMgt.SetJobOrder;
      OrderPlanningMgt.GetOrdersToPlan(RequisitionLine);

Example

The below example is extracted from the test automation codeunit 137087 to show one way of using this function.

      // Setup : Create Item with inventory on location, Sale order and Calculate Plan.
      Initialize;
      Quantities[1] := 10 * LibraryRandom.RandDec(10,2);
      Quantities[2] := 10 * LibraryRandom.RandDec(10,2);
      CreateItem(Item,Item."Replenishment System"::Purchase,'','');
      JobNo := CreateJobPlanningLines(Item."No.",Quantities);

      // Exercise : Calculate Order Planning.
      LibraryPlanning.CalculateOrderPlanJob(RequisitionLine);

      // Verify : Check values of Needed Quantity.
      VerifyNeededQuantities(JobNo,Item."No.",Quantities);
Member of Lib.Library - Planning


CalculateOrderPlanProduction@161 Method

The procedure CalculateOrderPlanProduction is available in codeunit 132203.

Syntax

CalculateOrderPlanProduction@161(
    VAR RequisitionLine@1000 : Record 246 RequisitionLine //Reference parameter of type Record
);

Parameters

RequisitionLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Calculate, Order, Plan, Production.

For a clarification about how this function works, refer to the code listed below.

      OrderPlanningMgt.SetProdOrder;
      OrderPlanningMgt.GetOrdersToPlan(RequisitionLine);

Example

The below example is extracted from the test automation codeunit 137046 to show one way of using this function.

      // Setup : Create Manufacturing Item Setup, Create Production Order and consume less than required quantity
      Initialize;
      UpdateSalesReceivablesSetup(TempSalesReceivablesSetup);
      BOMQuantity := LibraryRandom.RandDec(10,2);
      CreateManufacturingSetup(ParentItem,ChildItem,BOMQuantity,FALSE);  // Child Item With Replenishment System Purchase.
      UpdateItemInventory(BOMQuantity,ChildItem."No.");
      CreateAndRefreshProdOrder(
        ProductionOrder,ProductionOrder.Status::Released,ParentItem."No.",'',LibraryRandom.RandDec(5,2) + 1,
        CALCDATE('<' + FORMAT(LibraryRandom.RandInt(2) + 2) + 'D>',WORKDATE));
      CreateAndPostConsumWithQty(ProductionOrder."No.",BOMQuantity);

      // Exercise : Run Order Planning.
      LibraryPlanning.CalculateOrderPlanProduction(RequisitionLine);

      // Verify : Verify That Quantity on Requisition Line same as Remaining Quantity on ProdOrderComponent.
      VerifyDemandQtyAndLocation(ProductionOrder."No.",DemandTypeGlobal::Production,ProductionOrder.Status::Released);

      // Tear Down.
      RestoreSalesReceivableSetup(TempSalesReceivablesSetup);
Member of Lib.Library - Planning


CalculateOrderPlanSales@152 Method

The procedure CalculateOrderPlanSales is available in codeunit 132203.

Syntax

CalculateOrderPlanSales@152(
    VAR RequisitionLine@1000 : Record 246 RequisitionLine //Reference parameter of type Record
);

Parameters

RequisitionLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Calculate, Order, Plan, Sales.

For a clarification about how this function works, refer to the code listed below.

      OrderPlanningMgt.SetSalesOrder;
      OrderPlanningMgt.GetOrdersToPlan(RequisitionLine);

Example

The below example is extracted from the test automation codeunit 137003 to show one way of using this function.

      // [FEATURE] [Manufacturing] [Planning] [Adjust Cost - Item Entries]
      // [SCENARIO 376035] "Last Direct Cost" is updated for Top Item in complex Production Order after running "Adjust Cost - Item Entries".

      // [GIVEN] Production Item "T", with Production BOM which includes production Items "C1" (Production BOM with component "CC1") and "C2" (Production BOM with component "CC2").
      Initialize;
      PrepareItemsOfComplexProdBOM(ItemNo);

      // [GIVEN] Purchase "CC1" and "CC2".
      CreatePurchaseOrder(PurchaseHeader,PurchaseLine,ItemNo[1],ItemNo[2],1,1,FALSE); // specific values needed for test
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

      // [GIVEN] Create Sales Order for Item "T", run planning calculation, make supply Production Order and release it.
      CreateSalesOrder(SalesHeader,ItemNo[5],1); // specific value needed for test
      LibraryPlanning.CalculateOrderPlanSales(ReqLine);
      MakeSupplyOrdersActiveOrder(SalesHeader."No.");
      FindProdOrder(ProdOrder,ProdOrder.Status::"Firm Planned",ItemNo[5]);
      ReleasedProdOrderNo :=
        LibraryManufacturing.ChangeStatusFirmPlanToReleased(
          ProdOrder."No.",ProdOrder.Status,ProdOrder.Status::Released);

      // [GIVEN] Post Production Journal for Production Order Lines: "C2", "C1" and "T" in that sequence, then finish Production Order.
      FindProdOrder(ProdOrder,ProdOrder.Status::Released,ItemNo[5]);
      PostProdJournal(ProdOrder,ItemNo[3]);
      PostProdJournal(ProdOrder,ItemNo[4]);
      PostProdJournal(ProdOrder,ItemNo[5]);
      LibraryManufacturing.ChangeStatusReleasedToFinished(ReleasedProdOrderNo);

      // [GIVEN] Add Item Charge to received components "CC1" and "CC2".
      AddItemCharge(ItemNo[1],LibraryRandom.RandDecInRange(5,10,2));
      AddItemCharge(ItemNo[2],LibraryRandom.RandDecInRange(5,10,2));

      // [GIVEN] Cost of components "CC1", "CC2" and production Items "C1", "C2" is adjusted.
      LibraryCosting.AdjustCostItemEntries(STRSUBSTNO('%1|%2|%3|%4',ItemNo[1],ItemNo[2],ItemNo[3],ItemNo[4]),'');

      // [WHEN] Run "Adjust Cost - Item Entries" for the production Item "T".
      LibraryCosting.AdjustCostItemEntries(ItemNo[5],'');

      // [THEN] For Item "T": "Last Direct Cost" is updated and equals to "Unit Cost".
      Item.GET(ItemNo[5]);
      Item.TESTFIELD("Last Direct Cost",Item."Unit Cost");
Member of Lib.Library - Planning


CalculateOrderPlanService@4 Method

The procedure CalculateOrderPlanService is available in codeunit 132203.

Syntax

CalculateOrderPlanService@4(
    VAR RequisitionLine@1000 : Record 246 RequisitionLine //Reference parameter of type Record
);

Parameters

RequisitionLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Calculate, Order, Plan, Service.

For a clarification about how this function works, refer to the code listed below.

      OrderPlanningMgt.SetServOrder;
      OrderPlanningMgt.GetOrdersToPlan(RequisitionLine);

Example

The below example is extracted from the test automation codeunit 136111 to show one way of using this function.

      // Check Quantity on Order Planning Worksheet for Service Order after running Calculate Plan.

      // Setup: Create Service Order for Item having Zero inventory.
      Initialize;
      LibraryService.CreateServiceHeader(ServiceHeader,ServiceHeader."Document Type"::Order,'');
      CreateServiceLineWithItem(ServiceHeader);

      // Exercise: Run Calculate Plan from Order Planning Worksheet.
      LibraryPlanning.CalculateOrderPlanService(RequisitionLine);

      // Verify: Verify that Requisition Line has same quantity as on Service Order.
      VerifyRequisitionLine(ServiceHeader."No.");
Member of Lib.Library - Planning


CalculatePlanForReqWksh@1 Method

The procedure CalculatePlanForReqWksh is available in codeunit 132203.

Syntax

CalculatePlanForReqWksh@1(
    VAR Item@1002 : Record 27 Item, //Reference parameter of type Record
    TemplateName@1004 : Code[10] TemplateName, //Input parameter of type Code
    WorksheetName@1005 : Code[10] WorksheetName, //Input parameter of type Code
    StartDate@1001 : Date StartDate, //Input parameter of type Date
    EndDate@1000 : Date EndDate //Input parameter of type Date
);

Parameters

Item
Reference parameter of type Record
TemplateName
Input parameter of type Code
WorksheetName
Input parameter of type Code
StartDate
Input parameter of type Date
EndDate
Input parameter of type Date

Remarks

The relevant search keywords are: Calculate, Plan, For, Req, Wksh.

For a clarification about how this function works, refer to the code listed below.

      CalculatePlanReqWksh.SetTemplAndWorksheet(TemplateName,WorksheetName);
      CalculatePlanReqWksh.InitializeRequest(StartDate,EndDate);
      IF Item.HASFILTER THEN
        TmpItem.COPYFILTERS(Item)
      ELSE BEGIN
        Item.GET(Item."No.");
        TmpItem.SETRANGE("No.",Item."No.");
      END;
      CalculatePlanReqWksh.SETTABLEVIEW(TmpItem);
      CalculatePlanReqWksh.USEREQUESTPAGE(FALSE);
      CalculatePlanReqWksh.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 134381 to show one way of using this function.

      ReqWkshTemplate.SETRANGE(Type,ReqWkshTemplate.Type::"Req.");
      ReqWkshTemplate.SETRANGE(Recurring,FALSE);
      ReqWkshTemplate.FINDFIRST;
      LibraryPlanning.CreateRequisitionWkshName(RequisitionWkshName,ReqWkshTemplate.Name);
      Item.GET(ItemNo);
      LibraryPlanning.CalculatePlanForReqWksh(Item,ReqWkshTemplate.Name,RequisitionWkshName.Name,WORKDATE,WORKDATE);
      FindReqLine(ReqLine,Item."No.");
Member of Lib.Library - Planning


CarryOutActionMsgPlanWksh@73 Method

The procedure CarryOutActionMsgPlanWksh is available in codeunit 132203.

Syntax

CarryOutActionMsgPlanWksh@73(
    VAR ReqLineRec@1002 : Record 246 ReqLineRec //Reference parameter of type Record
);

Parameters

ReqLineRec
Reference parameter of type Record

Remarks

The relevant search keywords are: Carry, Out, Action, Msg, Plan, Wksh.

For a clarification about how this function works, refer to the code listed below.

      COMMIT;
      CarryOutActionMsgPlan.InitializeRequest(2,1,1,1);
      IF ReqLineRec.HASFILTER THEN
        TmpReqLineRec.COPYFILTERS(ReqLineRec)
      ELSE BEGIN
        ReqLineRec.GET(ReqLineRec."Worksheet Template Name",
          ReqLineRec."Journal Batch Name",ReqLineRec."Line No.");
        TmpReqLineRec.SETRANGE("Worksheet Template Name",ReqLineRec."Worksheet Template Name");
        TmpReqLineRec.SETRANGE("Journal Batch Name",ReqLineRec."Journal Batch Name");
        TmpReqLineRec.SETRANGE("Line No.",ReqLineRec."Line No.");
      END;
      CarryOutActionMsgPlan.SetReqWkshLine(ReqLineRec);
      CarryOutActionMsgPlan.SETTABLEVIEW(TmpReqLineRec);
      CarryOutActionMsgPlan.USEREQUESTPAGE(FALSE);
      CarryOutActionMsgPlan.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 134476 to show one way of using this function.

      // Test Dimension on Purchase Receipt created from Drop Shipment functionality.

      // 1. Setup: Create Customer, Sales Order having Purchasing Code with Drop Shipment True, Create Dimension Set Entry for Sales Line
      // and Run Get Sales Order from Requisition Worksheet.
      Initialize;
      DimensionCode := CreateRequisitionLine(RequisitionWkshName,DimensionSetID);
      UpdateVendorOnRequisitionLine(
        RequisitionLine,RequisitionWkshName,
        CreateVendorWithDimension(DefaultDimension,DefaultDimension."Value Posting"::" ",FindDifferentDimension(DimensionCode)));

      // 2. Exercise: Create Purcahse Order from Requisition Worksheet, Post Sales Order and Purchase Order.
      LibraryPlanning.CarryOutActionMsgPlanWksh(RequisitionLine);
      SalesHeader.GET(SalesHeader."Document Type"::Order,RequisitionLine."Sales Order No.");
      LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      OrderNo := PostPurchaseOrder(RequisitionLine."Vendor No.");

      // 3. Verify: Verify Dimension on Purchase Receipt.
      PurchRcptHeader.SETRANGE("Order No.",OrderNo);
      PurchRcptHeader.FINDFIRST;
      PurchRcptHeader.TESTFIELD("Dimension Set ID",RequisitionLine."Dimension Set ID");
      VerifyDimensionOnReceiptLine(PurchRcptHeader."No.",RequisitionLine."Dimension Set ID");
Member of Lib.Library - Planning


CarryOutAMSubcontractWksh@35 Method

The procedure CarryOutAMSubcontractWksh is available in codeunit 132203.

Syntax

CarryOutAMSubcontractWksh@35(
    VAR RequisitionLine@1000 : Record 246 RequisitionLine //Reference parameter of type Record
);

Parameters

RequisitionLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Carry, Out, AM, Subcontract, Wksh.

For a clarification about how this function works, refer to the code listed below.

      CarryOutActionMsgReq.SetReqWkshLine(RequisitionLine);
      CarryOutActionMsgReq.USEREQUESTPAGE(FALSE);
      CarryOutActionMsgReq.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 137004 to show one way of using this function.

      // Update Direct unit Cost and Make Order,random is used values not important for test.
      RequisitionLine.SETRANGE("Prod. Order No.",ProductionOrderNo);
      RequisitionLine.SETRANGE("Work Center No.",WorkCenterNo);
      RequisitionLine.FINDFIRST;
      RequisitionLine.VALIDATE("Direct Unit Cost",LibraryRandom.RandInt(10));
      RequisitionLine.MODIFY(TRUE);
      Vendor.GET(RequisitionLine."Vendor No.");
      LibraryPurchase.CreateSetupForSubContracting(Vendor);
      LibraryPlanning.CarryOutAMSubcontractWksh(RequisitionLine);
Member of Lib.Library - Planning


CarryOutPlanWksh@126 Method

The procedure CarryOutPlanWksh is available in codeunit 132203.

Syntax

CarryOutPlanWksh@126(
    VAR RequisitionLine@1000 : Record 246 RequisitionLine, //Reference parameter of type Record
    NewProdOrderChoice@1012 : Option NewProdOrderChoice, //Input parameter of type Option
    NewPurchOrderChoice@1011 : Option NewPurchOrderChoice, //Input parameter of type Option
    NewTransOrderChoice@1010 : Option NewTransOrderChoice, //Input parameter of type Option
    NewAsmOrderChoice@1002 : Option NewAsmOrderChoice, //Input parameter of type Option
    NewReqWkshTemp@1009 : Code[10] NewReqWkshTemp, //Input parameter of type Code
    NewReqWksh@1008 : Code[10] NewReqWksh, //Input parameter of type Code
    NewTransWkshTemp@1007 : Code[10] NewTransWkshTemp, //Input parameter of type Code
    NewTransWkshName@1006 : Code[10] NewTransWkshName //Input parameter of type Code
);

Parameters

RequisitionLine
Reference parameter of type Record
NewProdOrderChoice
Input parameter of type Option
NewPurchOrderChoice
Input parameter of type Option
NewTransOrderChoice
Input parameter of type Option
NewAsmOrderChoice
Input parameter of type Option
NewReqWkshTemp
Input parameter of type Code
NewReqWksh
Input parameter of type Code
NewTransWkshTemp
Input parameter of type Code
NewTransWkshName
Input parameter of type Code

Remarks

The relevant search keywords are: Carry, Out, Plan, Wksh.

For a clarification about how this function works, refer to the code listed below.

      CarryOutActionMsgPlan.SetReqWkshLine(RequisitionLine);
      CarryOutActionMsgPlan.InitializeRequest2(
        NewProdOrderChoice,NewPurchOrderChoice,NewTransOrderChoice,NewAsmOrderChoice,
        NewReqWkshTemp,NewReqWksh,NewTransWkshTemp,NewTransWkshName);
      CarryOutActionMsgPlan.SETTABLEVIEW(RequisitionLine);
      CarryOutActionMsgPlan.USEREQUESTPAGE(FALSE);
      CarryOutActionMsgPlan.RUN;

Example

The below example is extracted from the test automation codeunit 137035 to show one way of using this function.

      RequisitionLine.SETRANGE("No.",No);
      RequisitionLine.FINDFIRST;
      RequisitionLine.VALIDATE("Accept Action Message",TRUE);
      RequisitionLine.MODIFY(TRUE);
      LibraryPlanning.CarryOutPlanWksh(
        RequisitionLine,NewProdOrderChoice::Planned,NewPurchOrderChoice::" ",NewTransOrderChoice::" ",NewAsmOrderChoice::" ",'','',
        '','');
Member of Lib.Library - Planning


CarryOutReqWksh@128 Method

The procedure CarryOutReqWksh is available in codeunit 132203.

Syntax

CarryOutReqWksh@128(
    VAR RequisitionLine@1000 : Record 246 RequisitionLine, //Reference parameter of type Record
    ExpirationDate@1006 : Date ExpirationDate, //Input parameter of type Date
    OrderDate@1005 : Date OrderDate, //Input parameter of type Date
    PostingDate@1004 : Date PostingDate, //Input parameter of type Date
    ExpectedReceiptDate@1003 : Date ExpectedReceiptDate, //Input parameter of type Date
    YourRef@1002 : Text[50] YourRef //Input parameter of type Text
);

Parameters

RequisitionLine
Reference parameter of type Record
ExpirationDate
Input parameter of type Date
OrderDate
Input parameter of type Date
PostingDate
Input parameter of type Date
ExpectedReceiptDate
Input parameter of type Date
YourRef
Input parameter of type Text

Remarks

The relevant search keywords are: Carry, Out, Req, Wksh.

For a clarification about how this function works, refer to the code listed below.

      CarryOutActionMsgReq.SetReqWkshLine(RequisitionLine);
      CarryOutActionMsgReq.InitializeRequest(ExpirationDate,OrderDate,PostingDate,ExpectedReceiptDate,YourRef);
      CarryOutActionMsgReq.USEREQUESTPAGE(FALSE);
      CarryOutActionMsgReq.RUN;
      CarryOutActionMsgReq.GetReqWkshLine(RequisitionLine);

Example

The below example is extracted from the test automation codeunit 134381 to show one way of using this function.

      // Test that purchase order line created by carry out action from requisition worskeet with changed dimension has dimension value from requisition worksheet

      // Setup.
      Initialize;
      SetupDimensionPriorityForPurchSrcCode;
      DimensionCode := CreateDimensionValues(DimValueArray);
      PrevGlobalDimCode := SetupGlobalDimension(1,DimensionCode);
      VendNo := CreateVendorWithPurchaserAndDefDim(DimensionCode,DimValueArray);
      ItemNo := CreateItemWithReplenishmentPociliyAndDefDim(DimensionCode,DimValueArray[3],VendNo);
      ExpectedDimValue := CreateReqLineWithCustomDimVal(RequisitionLine,ItemNo,DimensionCode);

      // Exercise.
      LibraryPlanning.CarryOutReqWksh(RequisitionLine,WORKDATE,WORKDATE,WORKDATE,WORKDATE,'');

      // Verify.
      VerifyDimValueInPurchLine(VendNo,DimensionCode,ExpectedDimValue);

      // Teardown.
      SetupGlobalDimension(1,PrevGlobalDimCode);
Member of Lib.Library - Planning


CreateManufUserTemplate@170 Method

The procedure CreateManufUserTemplate is available in codeunit 132203.

Syntax

CreateManufUserTemplate@170(
    VAR ManufacturingUserTemplate@1001 : Record 5525 ManufacturingUserTemplate, //Reference parameter of type Record
    UserID@1000 : Code[50] UserID, //Input parameter of type Code
    MakeOrders@1002 : Option MakeOrders, //Input parameter of type Option
    CreatePurchaseOrder@1003 : Option CreatePurchaseOrder, //Input parameter of type Option
    CreateProductionOrder@1004 : Option CreateProductionOrder, //Input parameter of type Option
    CreateTransferOrder@1005 : Option CreateTransferOrder //Input parameter of type Option
);

Parameters

ManufacturingUserTemplate
Reference parameter of type Record
UserID
Input parameter of type Code
MakeOrders
Input parameter of type Option
CreatePurchaseOrder
Input parameter of type Option
CreateProductionOrder
Input parameter of type Option
CreateTransferOrder
Input parameter of type Option

Remarks

The relevant search keywords are: Create, Manuf, User, Template.

For a clarification about how this function works, refer to the code listed below.

      ManufacturingUserTemplate.INIT;
      ManufacturingUserTemplate."User ID" := UserID;
      ManufacturingUserTemplate.INSERT(TRUE);
      ManufacturingUserTemplate.VALIDATE("Make Orders",MakeOrders);
      ManufacturingUserTemplate.VALIDATE("Create Purchase Order",CreatePurchaseOrder);
      ManufacturingUserTemplate.VALIDATE("Create Production Order",CreateProductionOrder);
      ManufacturingUserTemplate.VALIDATE("Create Transfer Order",CreateTransferOrder);
      ManufacturingUserTemplate.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 136111 to show one way of using this function.

      LibraryPlanning.CreateManufUserTemplate(
        ManufacturingUserTemplate,USERID,MakeOrder,ManufacturingUserTemplate."Create Purchase Order"::"Make Purch. Orders",
        ManufacturingUserTemplate."Create Production Order"::"Firm Planned",
        ManufacturingUserTemplate."Create Transfer Order"::"Make Trans. Orders");
Member of Lib.Library - Planning


CreatePlanningComponent@155 Method

The procedure CreatePlanningComponent is available in codeunit 132203.

Syntax

CreatePlanningComponent@155(
    VAR PlanningComponent@1001 : Record 99000829 PlanningComponent, //Reference parameter of type Record
    VAR RequisitionLine@1000 : Record 246 RequisitionLine //Reference parameter of type Record
);

Parameters

PlanningComponent
Reference parameter of type Record
RequisitionLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Planning, Component.

For a clarification about how this function works, refer to the code listed below.

      PlanningComponent.INIT;
      PlanningComponent.VALIDATE("Worksheet Template Name",RequisitionLine."Worksheet Template Name");
      PlanningComponent.VALIDATE("Worksheet Batch Name",RequisitionLine."Journal Batch Name");
      PlanningComponent.VALIDATE("Worksheet Line No.",RequisitionLine."Line No.");
      RecRef.GETTABLE(PlanningComponent);
      PlanningComponent.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,PlanningComponent.FIELDNO("Line No.")));
      PlanningComponent.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137071 to show one way of using this function.

      LibraryPlanning.CreatePlanningComponent(PlanningComponent,RequisitionLine);
      PlanningComponent.VALIDATE("Item No.",ItemNo);
      PlanningComponent.VALIDATE("Quantity per",QuantityPer);
      PlanningComponent.MODIFY(TRUE);
Member of Lib.Library - Planning


CreatePlanningRoutingLine@156 Method

The procedure CreatePlanningRoutingLine is available in codeunit 132203.

Syntax

CreatePlanningRoutingLine@156(
    VAR PlanningRoutingLine@1000 : Record 99000830 PlanningRoutingLine, //Reference parameter of type Record
    VAR RequisitionLine@1001 : Record 246 RequisitionLine, //Reference parameter of type Record
    OperationNo@1002 : Code[10] OperationNo //Input parameter of type Code
);

Parameters

PlanningRoutingLine
Reference parameter of type Record
RequisitionLine
Reference parameter of type Record
OperationNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Planning, Routing, Line.

For a clarification about how this function works, refer to the code listed below.

      PlanningRoutingLine.INIT;
      PlanningRoutingLine.VALIDATE("Worksheet Template Name",RequisitionLine."Worksheet Template Name");
      PlanningRoutingLine.VALIDATE("Worksheet Batch Name",RequisitionLine."Journal Batch Name");
      PlanningRoutingLine.VALIDATE("Worksheet Line No.",RequisitionLine."Line No.");
      PlanningRoutingLine.VALIDATE("Operation No.",OperationNo);
      PlanningRoutingLine.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137088 to show one way of using this function.

      // Setup: Create Work Center, Routing, Item, Create Firm Planned Production Order and calculate Plan from Order Planning and Add Planning Routing.
      Initialize;
      CreateManufacturingSetup(ParentItem,ChildItem,TRUE,ChildItem."Order Tracking Policy"::None);
      CreateAndRefreshProdOrder(
        ProductionOrder,ProductionOrder.Status::"Firm Planned",ParentItem."No.",LocationRed.Code,LibraryRandom.RandDec(10,2));
      LibraryPlanning.CalculateOrderPlanProduction(RequisitionLine);
      FindRequisitionLine(RequisitionLine,ProductionOrder."No.",ChildItem."No.",LocationRed.Code);
      CreateWorkCenter(WorkCenter);
      OperationNo := FindLastOperationNo(ChildItem."Routing No.") + FORMAT(LibraryRandom.RandInt(5));
      LibraryPlanning.CreatePlanningRoutingLine(PlanningRoutingLine,RequisitionLine,OperationNo);
      UpdatePlanningRoutingLine(
        PlanningRoutingLine,WorkCenter."No.",FindLastOperationNo(ChildItem."Routing No."),LibraryRandom.RandDec(10,2),
        LibraryRandom.RandDec(10,2));  // Random Value Required.

      // Exercise.
      MakeSupplyOrdersActiveOrder(ProductionOrder."No.");

      // Verify : Check That Production Order Routing Line is Created with the added Routing Line in Order Planning Page.
      VerifyProdOrderRoutingLine(PlanningRoutingLine,ChildItem."Routing No.",OperationNo);
Member of Lib.Library - Planning


CreateProdOrderUsingPlanning@125 Method

The procedure CreateProdOrderUsingPlanning is available in codeunit 132203.

Syntax

CreateProdOrderUsingPlanning@125(
    VAR ProductionOrder@1004 : Record 5405 ProductionOrder, //Reference parameter of type Record
    Status@1002 : Option Status, //Input parameter of type Option
    DocumentNo@1001 : Code[20] DocumentNo, //Input parameter of type Code
    SourceNo@1003 : Code[20] SourceNo //Input parameter of type Code
);

Parameters

ProductionOrder
Reference parameter of type Record
Status
Input parameter of type Option
DocumentNo
Input parameter of type Code
SourceNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Product, Order, Using, Planning.

For a clarification about how this function works, refer to the code listed below.

      SalesOrderPlanning.SetSalesOrder(DocumentNo);
      SalesOrderPlanning.BuildForm;
      SalesOrderPlanning.CreateProdOrder;
      CLEAR(ProductionOrder);
      ProductionOrder.SETRANGE(Status,Status);
      ProductionOrder.SETRANGE("Source No.",SourceNo);
      ProductionOrder.FINDLAST;

Example

The below example is extracted from the test automation codeunit 137035 to show one way of using this function.

      // 1. Setup : Update Sales Setup.Create and Update Item Inventory.
      Initialize;

      CreateItem(
        Item,Item."Costing Method",'','',Item."Manufacturing Policy"::"Make-to-Order",Item."Reordering Policy",
        Item."Replenishment System"::Purchase);
      UpdateItem(Item,Item."Flushing Method"::Backward,Item."Reordering Policy",0);
      CreateAndPostItemJrnl(ItemJournalLine."Entry Type"::"Positive Adjmt.",Item."No.",LibraryRandom.RandInt(100));

      // Create Routing with Flushing Method Backward.Create Production BOM.
      CreateRoutingSetup(RoutingHeader,Item."Flushing Method"::Backward);
      CreateProdBOM(ProductionBOMHeader,Item,Item."Base Unit of Measure");

      // Create Finished Item.
      CreateItem(
        Item,Item."Costing Method"::FIFO,RoutingHeader."No.",ProductionBOMHeader."No.",Item."Manufacturing Policy"::"Make-to-Order",
        Item."Reordering Policy",Item."Replenishment System"::"Prod. Order");
      UpdateItem(Item,Item."Flushing Method"::Manual,Item."Reordering Policy",0);

      // Create Sales Order and Create Firm Planned Prod order using order Planning.Change Status to Released.
      CreateSalesOrder(SalesHeader,Item."No.",LibraryRandom.RandInt(10));
      LibraryPlanning.CreateProdOrderUsingPlanning(
        ProductionOrder,ProductionOrder.Status::"Firm Planned",SalesHeader."No.",Item."No.");
      ProdOrderNo :=
        LibraryManufacturing.ChangeStatusFirmPlanToReleased(
          ProductionOrder."No.",ProductionOrder.Status,ProductionOrder.Status::Released);

      // 2. Execute : Change Status from Released to Finished.
      ASSERTERROR LibraryManufacturing.ChangeStatusReleasedToFinished(ProdOrderNo);

      // 3. Verify: Verify Output entry missing.
      ProdOrderLine.SETRANGE(Status,ProdOrderLine.Status::Released);
      ProdOrderLine.SETRANGE("Prod. Order No.",ProdOrderNo);
      ProdOrderLine.FINDFIRST;
      Assert.AreEqual(
        STRSUBSTNO(ExpectedOutputMissing,ProdOrderLine."Line No.",ProdOrderLine."Prod. Order No."),GETLASTERRORTEXT,
        ErrorGeneratedMustBeSame);
Member of Lib.Library - Planning


CreateRequisitionLine@2 Method

The procedure CreateRequisitionLine is available in codeunit 132203.

Syntax

CreateRequisitionLine@2(
    VAR RequisitionLine@1000 : Record 246 RequisitionLine, //Reference parameter of type Record
    WorksheetTemplateName@1001 : Code[10] WorksheetTemplateName, //Input parameter of type Code
    JournalBatchName@1002 : Code[10] JournalBatchName //Input parameter of type Code
);

Parameters

RequisitionLine
Reference parameter of type Record
WorksheetTemplateName
Input parameter of type Code
JournalBatchName
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Requisition, Line.

For a clarification about how this function works, refer to the code listed below.

      RequisitionLine.INIT;
      RequisitionLine.VALIDATE("Worksheet Template Name",WorksheetTemplateName);
      RequisitionLine.VALIDATE("Journal Batch Name",JournalBatchName);
      RecRef.GETTABLE(RequisitionLine);
      RequisitionLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,RequisitionLine.FIELDNO("Line No.")));
      RequisitionLine.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134900 to show one way of using this function.

      LibraryPlanning.CreateRequisitionLine(RequisitionLine,ReqWkshTemplate,RequisitionWkshName);
      LibraryPlanning.GetSpecialOrder(RequisitionLine,SalesLine."No.");
Member of Lib.Library - Planning


CreateRequisitionWkshName@93 Method

The procedure CreateRequisitionWkshName is available in codeunit 132203.

Syntax

CreateRequisitionWkshName@93(
    VAR RequisitionWkshName@1000 : Record 245 RequisitionWkshName, //Reference parameter of type Record
    WorksheetTemplateName@1001 : Code[10] WorksheetTemplateName //Input parameter of type Code
);

Parameters

RequisitionWkshName
Reference parameter of type Record
WorksheetTemplateName
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Requisition, Wksh, Name.

For a clarification about how this function works, refer to the code listed below.

      // Create Requisition Wksh. Name with a random Name of String length less than 10.
      RequisitionWkshName.INIT;
      RequisitionWkshName.VALIDATE("Worksheet Template Name",WorksheetTemplateName);
      RequisitionWkshName.VALIDATE(
        Name,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(RequisitionWkshName.FIELDNO(Name),DATABASE::"Requisition Wksh. Name"),
          1,LibraryUtility.GetFieldLength(DATABASE::"Requisition Wksh. Name",RequisitionWkshName.FIELDNO(Name))));
      RequisitionWkshName.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134381 to show one way of using this function.

      ReqWkshTemplate.SETRANGE(Type,ReqWkshTemplate.Type::"Req.");
      ReqWkshTemplate.SETRANGE(Recurring,FALSE);
      ReqWkshTemplate.FINDFIRST;
      LibraryPlanning.CreateRequisitionWkshName(RequisitionWkshName,ReqWkshTemplate.Name);
      Item.GET(ItemNo);
      LibraryPlanning.CalculatePlanForReqWksh(Item,ReqWkshTemplate.Name,RequisitionWkshName.Name,WORKDATE,WORKDATE);
      FindReqLine(ReqLine,Item."No.");
Member of Lib.Library - Planning


GetActionMessages@7 Method

The procedure GetActionMessages is available in codeunit 132203.

Syntax

GetActionMessages@7(
    VAR Item@1002 : Record 27 Item //Reference parameter of type Record
);

Parameters

Item
Reference parameter of type Record

Remarks

The relevant search keywords are: Get, Action, Messages.

For a clarification about how this function works, refer to the code listed below.

      SelectRequisitionWkshName(RequisitionWkshName);
      GetActionMessages.SetTemplAndWorksheet(RequisitionWkshName."Worksheet Template Name",RequisitionWkshName.Name);
      GetActionMessages.USEREQUESTPAGE(FALSE);
      IF Item.HASFILTER THEN
        TmpItem.COPYFILTERS(Item)
      ELSE BEGIN
        Item.GET(Item."No.");
        TmpItem.SETRANGE("No.",Item."No.");
      END;
      GetActionMessages.SETTABLEVIEW(TmpItem);
      GetActionMessages.RUN;

Example

The below example is extracted from the test automation codeunit 137080 to show one way of using this function.

      // Setup: Create Item.
      Initialize;
      LibraryInventory.CreateItem(Item);

      // Exercise.
      ASSERTERROR LibraryPlanning.GetActionMessages(Item);

      // Verify.
      Assert.ExpectedError(NoActionMessagesExistError);
Member of Lib.Library - Planning


GetSalesOrders@45 Method

The procedure GetSalesOrders is available in codeunit 132203.

Syntax

GetSalesOrders@45(
    SalesLine@1000 : Record 37 SalesLine, //Input parameter of type Record
    RequisitionLine@1001 : Record 246 RequisitionLine, //Input parameter of type Record
    RetrieveDimensionsFrom@1004 : Option RetrieveDimensionsFrom //Input parameter of type Option
);

Parameters

SalesLine
Input parameter of type Record
RequisitionLine
Input parameter of type Record
RetrieveDimensionsFrom
Input parameter of type Option

Remarks

The relevant search keywords are: Get, Sales, Orders.

For a clarification about how this function works, refer to the code listed below.

      SalesLine.SETRANGE("Document Type",SalesLine."Document Type");
      SalesLine.SETRANGE("Document No.",SalesLine."Document No.");
      CLEAR(GetSalesOrders);
      GetSalesOrders.SETTABLEVIEW(SalesLine);
      GetSalesOrders.InitializeRequest(RetrieveDimensionsFrom);
      GetSalesOrders.SetReqWkshLine(RequisitionLine,0);
      GetSalesOrders.USEREQUESTPAGE(FALSE);
      GetSalesOrders.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 134900 to show one way of using this function.

      LibraryPlanning.CreateRequisitionLine(RequisitionLine,ReqWkshTemplate,RequisitionWkshName);
      LibraryPlanning.GetSalesOrders(SalesLine,RequisitionLine,RetrieveDimensionsFrom::"Sales Line");
Member of Lib.Library - Planning


GetSpecialOrder@63 Method

The procedure GetSpecialOrder is available in codeunit 132203.

Syntax

GetSpecialOrder@63(
    VAR RequisitionLine@1004 : Record 246 RequisitionLine, //Reference parameter of type Record
    No@1000 : Code[20] No //Input parameter of type Code
);

Parameters

RequisitionLine
Reference parameter of type Record
No
Input parameter of type Code

Remarks

The relevant search keywords are: Get, Special, Order.

For a clarification about how this function works, refer to the code listed below.

      SalesLine.SETRANGE("No.",No);
      GetSalesOrders.SetReqWkshLine(RequisitionLine,1);  // Value required.
      GetSalesOrders.SETTABLEVIEW(SalesLine);
      GetSalesOrders.InitializeRequest(NewRetrieveDimensionsFrom::Item);
      GetSalesOrders.USEREQUESTPAGE(FALSE);
      GetSalesOrders.RUN;

Example

The below example is extracted from the test automation codeunit 134900 to show one way of using this function.

      LibraryPlanning.CreateRequisitionLine(RequisitionLine,ReqWkshTemplate,RequisitionWkshName);
      LibraryPlanning.GetSpecialOrder(RequisitionLine,SalesLine."No.");
Member of Lib.Library - Planning


MakeSupplyOrders@162 Method

The procedure MakeSupplyOrders is available in codeunit 132203.

Syntax

MakeSupplyOrders@162(
    VAR ManufacturingUserTemplate@1002 : Record 5525 ManufacturingUserTemplate, //Reference parameter of type Record
    VAR RequisitionLine@1001 : Record 246 RequisitionLine //Reference parameter of type Record
);

Parameters

ManufacturingUserTemplate
Reference parameter of type Record
RequisitionLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Make, Supply, Orders.

For a clarification about how this function works, refer to the code listed below.

      MakeSupplyOrdersYesNo.SetManufUserTemplate(ManufacturingUserTemplate);
      MakeSupplyOrdersYesNo.RUN(RequisitionLine);

Example

The below example is extracted from the test automation codeunit 136111 to show one way of using this function.

      RequisitionLine.SETRANGE("Demand Order No.",DocumentNo);
      RequisitionLine.FINDFIRST;
      GetManufacturingUserTemplate(ManufacturingUserTemplate,ManufacturingUserTemplate."Make Orders"::"The Active Order");
      LibraryPlanning.MakeSupplyOrders(ManufacturingUserTemplate,RequisitionLine);
Member of Lib.Library - Planning


RefreshPlanningLine@44 Method

The procedure RefreshPlanningLine is available in codeunit 132203.

Syntax

RefreshPlanningLine@44(
    VAR RequisitionLine@1001 : Record 246 RequisitionLine, //Reference parameter of type Record
    SchDirection@1002 : Option SchDirection, //Input parameter of type Option
    CalcRouting@1003 : Boolean CalcRouting, //Input parameter of type Boolean
    CalcCompNeed@1004 : Boolean CalcCompNeed //Input parameter of type Boolean
);

Parameters

RequisitionLine
Reference parameter of type Record
SchDirection
Input parameter of type Option
CalcRouting
Input parameter of type Boolean
CalcCompNeed
Input parameter of type Boolean

Remarks

The relevant search keywords are: Refresh, Planning, Line.

For a clarification about how this function works, refer to the code listed below.

      RefreshPlanningDemand.InitializeRequest(SchDirection,CalcRouting,CalcCompNeed);
      IF RequisitionLine.HASFILTER THEN
        TmpRequisitionLine.COPYFILTERS(RequisitionLine)
      ELSE BEGIN
        RequisitionLine.GET(RequisitionLine."Worksheet Template Name",
          RequisitionLine."Journal Batch Name",RequisitionLine."Line No.");
        TmpRequisitionLine.SETRANGE("Worksheet Template Name",RequisitionLine."Worksheet Template Name");
        TmpRequisitionLine.SETRANGE("Journal Batch Name",RequisitionLine."Journal Batch Name");
        TmpRequisitionLine.SETRANGE("Line No.",RequisitionLine."Line No.");
      END;
      RefreshPlanningDemand.SETTABLEVIEW(TmpRequisitionLine);
      RefreshPlanningDemand.USEREQUESTPAGE(FALSE);
      RefreshPlanningDemand.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 137054 to show one way of using this function.

      // Create Item with Planning parameters.
      CreateLFLItem(Item,Item."Replenishment System"::"Prod. Order",'<1W>','<1W>',TRUE,0,0);  // Rescheduling Period, Lot Accumulation Period, Include Inventory, Safety Stock, Dampener Qty.
      CreateChildItemSetup(Item2,Item."Base Unit of Measure",ProductionBOMHeader,'<1W>');  // Rescheduling Period

      // Create Demand - Supply Scenario with random values taking Global Variable for Sales and Production.
      CreateDemandDate(DemandDateValue,GetRandomDateUsingWorkDate(25),GetRandomDateUsingWorkDate(55),0D);  // Dates based on WORKDATE.
      CreateDemandQuantity(DemandQuantityValue,LibraryRandom.RandInt(100) + 800,LibraryRandom.RandInt(100) + 1000,0);
      CreateDemand(DemandDateValue,DemandQuantityValue,Item."No.",2);  // Number of Sales Order.

      CreateSupplyType(SupplyType,SupplyType::Released,SupplyType::Released,SupplyType::Released,SupplyType::None,SupplyType::None);
      CreateSupplyDate(
        SupplyDateValue,GetRandomDateUsingWorkDate(15),GetRandomDateUsingWorkDate(25),GetRandomDateUsingWorkDate(50),0D,0D);  // Dates based on WORKDATE.
      CreateSupplyQuantity(SupplyQuantityValue,DemandQuantityValue[2],DemandQuantityValue[2],DemandQuantityValue[2],0,0);
      CreateSupply(SupplyDateValue,SupplyQuantityValue,SupplyType,Item."No.",'','');

      LibraryPlanning.CalcRegenPlanForPlanWksh(Item,WORKDATE,GetRandomDateUsingWorkDate(60));  // Dates based on WORKDATE
      UpdateItem(Item,Item.FIELDNO("Production BOM No."),ProductionBOMHeader."No.");

      IF ProductionComponent THEN
        CreateProdOrderComponent(GlobalProductionOrder[2],Item2."No.");

      // Exercise: Calculate Regenerative Plan.
      FilterRequisitionLine(RequisitionLine2,Item."No.");
      LibraryPlanning.RefreshPlanningLine(RequisitionLine2,Direction::Backward,TRUE,TRUE);

      // Verify: Verify planning worksheet.
      PlanningComponent.SETRANGE("Item No.",Item2."No.");
      Assert.AreEqual(0,PlanningComponent.COUNT,NumberOfLineEqualError);  // Zero for empty line.
Member of Lib.Library - Planning


SelectRequisitionTemplateName@1033 Method

The procedure SelectRequisitionTemplateName is available in codeunit 132203.

Syntax

SelectRequisitionTemplateName@1033(
      //param element not supplied
);

Return Value

Code[10]

Remarks

The relevant search keywords are: Select, Requisition, Template, Name.

For a clarification about how this function works, refer to the code listed below.

      ReqWkshTemplate.SETRANGE(Type,ReqWkshTemplate.Type::Planning);
      ReqWkshTemplate.SETRANGE(Recurring,FALSE);
      IF NOT ReqWkshTemplate.FINDFIRST THEN BEGIN
        ReqWkshTemplate.INIT;
        ReqWkshTemplate.VALIDATE(
          Name,LibraryUtility.GenerateRandomCode(ReqWkshTemplate.FIELDNO(Name),DATABASE::"Req. Wksh. Template"));
        ReqWkshTemplate.INSERT(TRUE);
        ReqWkshTemplate.VALIDATE(Type,ReqWkshTemplate.Type::Planning);
        ReqWkshTemplate.MODIFY(TRUE);
      END;
      EXIT(ReqWkshTemplate.Name);

Example

The below example is extracted from the test automation codeunit 137296 to show one way of using this function.

      // [FEATURE] [Requisition Worksheet] [Item Cross Reference]
      // [SCENARIO 202830] Description should be copied into a requisition worksheet line from the item cross reference when calculating requisition plan

      Initialize;

      // [GIVEN] Item "I". Vendor "V" is setup as the default vendor for the item.
      CreateItemWithVendor(Item);

      // [GIVEN] Item cross reference "CR" for item "I" with vendor "V". Description in the cross reference is "D".
      CreateItemCrossReference(ItemCrossReference,Item."No.",Item."Vendor No.");
      // [GIVEN] Create a sales order for item "I"
      CreateSalesDocument(SalesLine,SalesLine."Document Type"::Order,Item."No.",'',LibraryRandom.RandInt(100));

      // [WHEN] Calculate requisition plan for item "I"
      ReqWkshTemplateName := LibraryPlanning.SelectRequisitionTemplateName;
      LibraryPlanning.CreateRequisitionWkshName(RequisitionWkshName,ReqWkshTemplateName);
      LibraryPlanning.CreateRequisitionLine(RequisitionLine,ReqWkshTemplateName,RequisitionWkshName.Name);
      LibraryPlanning.CalcRegenPlanForPlanWksh(Item,WORKDATE,WORKDATE);

      // [THEN] New requisition line is created with "Description" = "D"
      VerifyDescriptionsOnRequisitionLine(Item."No.",ItemCrossReference.Description,'');
Member of Lib.Library - Planning


SelectRequisitionWkshName@1019 Method

The procedure SelectRequisitionWkshName is available in codeunit 132203.

Syntax

SelectRequisitionWkshName@1019(
    VAR RequisitionWkshName@1000 : Record 245 RequisitionWkshName //Reference parameter of type Record
);

Parameters

RequisitionWkshName
Reference parameter of type Record

Remarks

The relevant search keywords are: Select, Requisition, Wksh, Name.

For a clarification about how this function works, refer to the code listed below.

      RequisitionWkshName.SETRANGE("Template Type",RequisitionWkshName."Template Type"::Planning);
      RequisitionWkshName.SETRANGE(Recurring,FALSE);
      IF NOT RequisitionWkshName.FINDFIRST THEN
        CreateRequisitionWkshName(RequisitionWkshName,SelectRequisitionTemplateName);

Example

The below example is extracted from the test automation codeunit 137008 to show one way of using this function.

      // [FEATURE] [UT] [Planning Worksheet]
      // [SCENARIO 257194] Function CalculatePlanningLineDates in codeunit 99000809 "Planning Line Management" updates fields "Starting Date-Time" and "Ending Date-Time" of the requisition line

      LibraryPlanning.SelectRequisitionWkshName(RequisitionWkshName);
      LibraryPlanning.CreateRequisitionLine(RequisitionLine,RequisitionWkshName."Worksheet Template Name",RequisitionWkshName.Name);

      MockPlanningRoutingLine(PlanningRoutingLine,RequisitionLine);

      PlanningLineManagement.CalculatePlanningLineDates(RequisitionLine);

      RequisitionLine.TESTFIELD(
        "Starting Date-Time",CREATEDATETIME(PlanningRoutingLine."Starting Date",PlanningRoutingLine."Starting Time"));
      RequisitionLine.TESTFIELD(
        "Ending Date-Time",CREATEDATETIME(PlanningRoutingLine."Ending Date",PlanningRoutingLine."Ending Time"));
Member of Lib.Library - Planning


Library - Pmt Disc Setup Class

Lib.Library - Pmt Disc Setup

COD131303 applies to ERM,W1,All.
Library for Payment Discount Test Cases.

Methods

Name | Description
ClearAdjustPmtDiscInVATSetup@92 | The procedure ClearAdjustPmtDiscInVATSetup is available in codeunit 131303.
GetPaymentTermsDiscountDate@29 | The procedure GetPaymentTermsDiscountDate is available in codeunit 131303.
GetPaymentTermsDiscountPct@21 | The procedure GetPaymentTermsDiscountPct is available in codeunit 131303.
GetPmtDiscGracePeriod@4 | The procedure GetPmtDiscGracePeriod is available in codeunit 131303.
GetPmtTolerancePct@10 | The procedure GetPmtTolerancePct is available in codeunit 131303.
SetAdjustForPaymentDisc@1 | The procedure SetAdjustForPaymentDisc is available in codeunit 131303.
SetPmtDiscExclVAT@2 | The procedure SetPmtDiscExclVAT is available in codeunit 131303.
SetPmtDiscGracePeriod@14 | The procedure SetPmtDiscGracePeriod is available in codeunit 131303.
SetPmtDiscGracePeriodByText@3 | The procedure SetPmtDiscGracePeriodByText is available in codeunit 131303.
SetPmtDiscToleranceWarning@9 | The procedure SetPmtDiscToleranceWarning is available in codeunit 131303.
SetPmtTolerance@5 | The procedure SetPmtTolerance is available in codeunit 131303.
SetPmtToleranceWarning@8 | The procedure SetPmtToleranceWarning is available in codeunit 131303.

See Also

Lib


ClearAdjustPmtDiscInVATSetup@92 Method

The procedure ClearAdjustPmtDiscInVATSetup is available in codeunit 131303.

Syntax

ClearAdjustPmtDiscInVATSetup@92(
      //param element not supplied
);

Remarks

The relevant search keywords are: Clear, Adjust, Payment, Discount, In, VAT, Setup.

For a clarification about how this function works, refer to the code listed below.

      VATPostingSetup.SETRANGE("Adjust for Payment Discount",TRUE);
      VATPostingSetup.MODIFYALL("Adjust for Payment Discount",FALSE,TRUE);

Example

The below example is extracted from the test automation codeunit 134006 to show one way of using this function.

      // Verify that no VAT are entries creates when unapplies the entry without discount but with "Adjust For Payment Discount"

      // Setup: Set "Adjust For Payment Discount" option.
      Initialize;
      EmptyDocumentType := 0;
      LibraryPmtDiscSetup.SetAdjustForPaymentDisc(TRUE);

      // Exercise: Find and modify Reverse Charge VAT posting setup with "Adjust For Payment Disc." and post invoice.
      PostedDocumentNo :=
        CreatePostSalesInvWithReverseChargeVATAdjForPmtDisc(SalesLine);
      LibraryERM.FindCustomerLedgerEntry(CustLedgEntry,CustLedgEntry."Document Type"::Invoice,PostedDocumentNo);
      CustLedgEntry.CALCFIELDS("Amount (LCY)");

      // Exercise: Post and apply document with empty type.
      CreateGenJnlLineWithPostingGroups(GenJnlLine,SalesLine."Sell-to Customer No.",
        EmptyDocumentType,-CustLedgEntry."Amount (LCY)",SalesLine);
      GenJnlLine.VALIDATE("Applies-to Doc. Type",GenJnlLine."Applies-to Doc. Type"::Invoice);
      GenJnlLine.VALIDATE("Applies-to Doc. No.",PostedDocumentNo);
      GenJnlLine.MODIFY(TRUE);
      LibraryERM.PostGeneralJnlLine(GenJnlLine);

      // Exericse: Unapply the empty document application.
      LibraryERM.FindCustomerLedgerEntry(CustLedgEntry,EmptyDocumentType,GenJnlLine."Document No.");
      LibraryERM.UnapplyCustomerLedgerEntry(CustLedgEntry);

      // Verify: Make sure that no entries have been created on unapplication.
      VerifyNoVATEntriesOnUnapplication(EmptyDocumentType,GenJnlLine."Document No.");

      // Cleanup: Return back the old value of "Adjust For Payment Discount".
      LibraryPmtDiscSetup.ClearAdjustPmtDiscInVATSetup;
Member of Lib.Library - Pmt Disc Setup


GetPaymentTermsDiscountDate@29 Method

The procedure GetPaymentTermsDiscountDate is available in codeunit 131303.

Syntax

GetPaymentTermsDiscountDate@29(
    PaymentTermsCode@1001 : Code[10] PaymentTermsCode //Input parameter of type Code
);

Parameters

PaymentTermsCode
Input parameter of type Code

Return Value

Date

Remarks

The relevant search keywords are: Get, Payment, Terms, Discount, Date.

For a clarification about how this function works, refer to the code listed below.

      PaymentTerms.GET(PaymentTermsCode);
      EXIT(CALCDATE(PaymentTerms."Discount Date Calculation",WORKDATE));

Example

The below example is extracted from the test automation codeunit 134914 to show one way of using this function.

      // [FEATURE] [Purchase] [Payment Tolerance]
      // [SCENARIO 222804] Several VAT Entries have been created for Apply\Unapply vendor payment to credit memo and invoice with several lines
      // [SCENARIO 222804] in case of the same General\VAT Posting setup, payment discount and tolerance
      Initialize;

      // [GIVEN] "Adjust for Payment Disc." = TRUE, "Payment Discount Grace Period" = "5D"
      LibraryPmtDiscSetup.SetAdjustForPaymentDisc(TRUE);
      LibraryPmtDiscSetup.SetPmtDiscGracePeriodByText('<5D>');

      // [GIVEN] Vendor with payment terms "1M(8D)"
      LibraryERM.CreatePaymentTermsDiscount(PaymentTerms,TRUE);
      CreateVATPostingSetupWithAdjForPmtDisc(VATPostingSetup,VATPostingSetup."VAT Calculation Type"::"Normal VAT");
      VendorNo := LibraryPurchase.CreateVendorWithVATBusPostingGroup(VATPostingSetup."VAT Bus. Posting Group");
      GLAccountNo := LibraryERM.CreateGLAccountWithVATPostingSetup(VATPostingSetup,GLAccount."Gen. Posting Type"::Purchase);
      UpdateGenPostingSetupForVendorAndGLAccount(VendorNo,GLAccountNo);

      // [GIVEN] Posted purchase credit memo on 04-01-2017 with Amount = 1250 (2 lines, each has Amount = 625)
      CrMemoLinesCount := LibraryRandom.RandIntInRange(2,5);
      CrMemoLineAmount := LibraryRandom.RandDecInRange(1000,2000,2);
      DocumentNo[1] :=
        CreatePostDocWithSevLines(
          WORKDATE + 1,GenJournalLine."Document Type"::"Credit Memo",GenJournalLine."Account Type"::Vendor,
          VendorNo,GLAccountNo,PaymentTerms.Code,CrMemoLinesCount,-CrMemoLineAmount);
      // [GIVEN] Posted purchase invoice on 01-01-2017 with Amount = 2500 (4 lines, each has Amount = 625)
      InvLinesCount := LibraryRandom.RandIntInRange(2,5);
      InvLineAmount := ROUND(CrMemoLineAmount * CrMemoLinesCount / InvLinesCount) + LibraryRandom.RandDecInRange(1000,2000,2);
      DocumentNo[2] :=
        CreatePostDocWithSevLines(
          WORKDATE,GenJournalLine."Document Type"::Invoice,GenJournalLine."Account Type"::Vendor,
          VendorNo,GLAccountNo,PaymentTerms.Code,InvLinesCount,InvLineAmount);
      // [GIVEN] Posted payment on 10-01-2017 with Amount = 1250
      PmtAmount := InvLineAmount * InvLinesCount - CrMemoLineAmount * CrMemoLinesCount;
      PaymentNo :=
        CreatePostPmtJournalLine(
          LibraryPmtDiscSetup.GetPaymentTermsDiscountDate(PaymentTerms.Code) + 1,
          GenJournalLine."Account Type"::Vendor,VendorNo,PmtAmount);

      // [GIVEN] Apply payment to both documents
      ApplyVendorPmtToSevDocs(VendorNo,PaymentNo,DocumentNo);

      // [THEN] There are 6 VAT Entries have been created for application (2 Discount, 4 Tolerance)
      ApplTransactionNo := GetVendApplTransactionNo(VendorNo,PaymentNo);
      VerifyVATEntriesCountByTransactionNo(ApplTransactionNo,CrMemoLinesCount + InvLinesCount);

      // [WHEN] Unapply
      UnapplyVendorLedgerEntry(VendorNo,PaymentNo);

      // [THEN] There are 6 VAT Entries have been created for application (2 Discount, 4 Tolerance)
      VerifyVATEntriesCountByTransactionNo(ApplTransactionNo + 1,CrMemoLinesCount + InvLinesCount);
Member of Lib.Library - Pmt Disc Setup


GetPaymentTermsDiscountPct@21 Method

The procedure GetPaymentTermsDiscountPct is available in codeunit 131303.

Syntax

GetPaymentTermsDiscountPct@21(
    PaymentTermsCode@1001 : Code[10] PaymentTermsCode //Input parameter of type Code
);

Parameters

PaymentTermsCode
Input parameter of type Code

Return Value

Decimal

Remarks

The relevant search keywords are: Get, Payment, Terms, Discount, Percent.

For a clarification about how this function works, refer to the code listed below.

      PaymentTerms.GET(PaymentTermsCode);
      EXIT(PaymentTerms."Discount %");

Example

The below example is extracted from the test automation codeunit 134914 to show one way of using this function.

      FOR i := 1 TO ARRAYLEN(VATPostingSetup) DO BEGIN
        LibraryERM.CreatePaymentTermsDiscount(PaymentTerms,FALSE);
        CreatePostPurchaseInvoice(GenJournalLine,VATPostingSetup[i],VendorNo,PaymentTerms.Code);
        InvoiceNo[i] := GenJournalLine."Document No.";
        InvoiceAmount[i] := GenJournalLine.Amount;
        DiscountAmount[i] := ROUND(InvoiceAmount[i] * LibraryPmtDiscSetup.GetPaymentTermsDiscountPct(PaymentTerms.Code) / 100);
      END;
Member of Lib.Library - Pmt Disc Setup


GetPmtDiscGracePeriod@4 Method

The procedure GetPmtDiscGracePeriod is available in codeunit 131303.

Syntax

GetPmtDiscGracePeriod@4(
      //param element not supplied
);

Return Value

Text

Remarks

The relevant search keywords are: Get, Payment, Discount, Grace, Period.

For a clarification about how this function works, refer to the code listed below.

      GeneralLedgerSetup.GET;
      EXIT(FORMAT(GeneralLedgerSetup."Payment Discount Grace Period"));

Example

There are no examples available.
Member of Lib.Library - Pmt Disc Setup


GetPmtTolerancePct@10 Method

The procedure GetPmtTolerancePct is available in codeunit 131303.

Syntax

GetPmtTolerancePct@10(
      //param element not supplied
);

Return Value

Decimal

Remarks

The relevant search keywords are: Get, Payment, Tolerance, Percent.

For a clarification about how this function works, refer to the code listed below.

      GeneralLedgerSetup.GET;
      EXIT(GeneralLedgerSetup."Payment Tolerance %");

Example

There are no examples available.
Member of Lib.Library - Pmt Disc Setup


SetAdjustForPaymentDisc@1 Method

The procedure SetAdjustForPaymentDisc is available in codeunit 131303.

Syntax

SetAdjustForPaymentDisc@1(
    AdjustForPaymentDisc@1001 : Boolean AdjustForPaymentDisc //Input parameter of type Boolean
);

Parameters

AdjustForPaymentDisc
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, Adjust, For, Payment, Discount.

For a clarification about how this function works, refer to the code listed below.

      GeneralLedgerSetup.GET;
      GeneralLedgerSetup.VALIDATE("Adjust for Payment Disc.",AdjustForPaymentDisc);
      GeneralLedgerSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134006 to show one way of using this function.

      // To verify that program calculate correct payment discount value in customer ledger entry when Pmt. Disc. Excl. VAT is true while Bal VAT. Amount is not equal to zero.

      // Setup: Create customer and Create Gen Journal Line with Bal Account No.
      Initialize;
      LibraryPmtDiscSetup.SetAdjustForPaymentDisc(FALSE);
      LibraryPmtDiscSetup.SetPmtDiscExclVAT(TRUE);
      CreateCustomerWithPaymentTerm(Customer);

      // Exercise:Create - Post Gen. Journal Line.
      CreatePostGenJnlLineWithBalAccount(GenJournalLine,Customer."No.");

      // Verify: Verify Customer Ledger Entry.
      PaymentTerms.GET(Customer."Payment Terms Code");
      PmtDiscAmount :=
        ROUND((GenJournalLine.Amount + ABS(GenJournalLine."Bal. VAT Amount (LCY)")) * PaymentTerms."Discount %" / 100);
      VerifyDiscountValueInCustomerLedger(GenJournalLine,PmtDiscAmount);
Member of Lib.Library - Pmt Disc Setup


SetPmtDiscExclVAT@2 Method

The procedure SetPmtDiscExclVAT is available in codeunit 131303.

Syntax

SetPmtDiscExclVAT@2(
    PmtDiscExclVAT@1001 : Boolean PmtDiscExclVAT //Input parameter of type Boolean
);

Parameters

PmtDiscExclVAT
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, Payment, Discount, Excluding, VAT.

For a clarification about how this function works, refer to the code listed below.

      GeneralLedgerSetup.GET;
      GeneralLedgerSetup.VALIDATE("Pmt. Disc. Excl. VAT",PmtDiscExclVAT);
      GeneralLedgerSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134006 to show one way of using this function.

      // To verify that program calculate correct payment discount value in customer ledger entry when Pmt. Disc. Excl. VAT is true while Bal VAT. Amount is not equal to zero.

      // Setup: Create customer and Create Gen Journal Line with Bal Account No.
      Initialize;
      LibraryPmtDiscSetup.SetAdjustForPaymentDisc(FALSE);
      LibraryPmtDiscSetup.SetPmtDiscExclVAT(TRUE);
      CreateCustomerWithPaymentTerm(Customer);

      // Exercise:Create - Post Gen. Journal Line.
      CreatePostGenJnlLineWithBalAccount(GenJournalLine,Customer."No.");

      // Verify: Verify Customer Ledger Entry.
      PaymentTerms.GET(Customer."Payment Terms Code");
      PmtDiscAmount :=
        ROUND((GenJournalLine.Amount + ABS(GenJournalLine."Bal. VAT Amount (LCY)")) * PaymentTerms."Discount %" / 100);
      VerifyDiscountValueInCustomerLedger(GenJournalLine,PmtDiscAmount);
Member of Lib.Library - Pmt Disc Setup


SetPmtDiscGracePeriod@14 Method

The procedure SetPmtDiscGracePeriod is available in codeunit 131303.

Syntax

SetPmtDiscGracePeriod@14(
    GracePeriod@1002 : DateFormula GracePeriod //Input parameter of type DateFormula
);

Parameters

GracePeriod
Input parameter of type DateFormula

Remarks

The relevant search keywords are: Set, Payment, Discount, Grace, Period.

For a clarification about how this function works, refer to the code listed below.

      GeneralLedgerSetup.GET;
      GeneralLedgerSetup.VALIDATE("Payment Discount Grace Period",GracePeriod);
      GeneralLedgerSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134262 to show one way of using this function.

      LibraryPmtDiscSetup.SetPmtToleranceWarning(PaymentToleranceWarning);
      LibraryPmtDiscSetup.SetPmtDiscToleranceWarning(PmtDiscToleranceWarning);
      EVALUATE(PmtDiscGracePeriod,'<' + FORMAT(LibraryRandom.RandInt(10)) + 'D>');
      LibraryPmtDiscSetup.SetPmtDiscGracePeriod(PmtDiscGracePeriod);
      RunChangePaymentTolerance(TRUE,TolerancePct,0);

      IF IsInitialized THEN
        EXIT;

      LibraryERMCountryData.CreateVATData;
      LibraryERMCountryData.UpdateGeneralPostingSetup;
      LibraryERMCountryData.UpdatePurchasesPayablesSetup;

      IsInitialized := TRUE;
      COMMIT;
Member of Lib.Library - Pmt Disc Setup


SetPmtDiscGracePeriodByText@3 Method

The procedure SetPmtDiscGracePeriodByText is available in codeunit 131303.

Syntax

SetPmtDiscGracePeriodByText@3(
    DateFormulaText@1000 : Text DateFormulaText //Input parameter of type Text
);

Parameters

DateFormulaText
Input parameter of type Text

Remarks

The relevant search keywords are: Set, Payment, Discount, Grace, Period, By, Text.

For a clarification about how this function works, refer to the code listed below.

      EVALUATE(GracePeriod,DateFormulaText);
      SetPmtDiscGracePeriod(GracePeriod);

Example

The below example is extracted from the test automation codeunit 134022 to show one way of using this function.

      // Test the Do not accept late payment discount option within payment discount warning.

      // Setup: Create setup for payment tolerance. Create and post General Journal Lines.
      Initialize;
      LibraryVariableStorage.Enqueue(PostingAction::"Remaining Amount");
      LibraryPmtDiscSetup.SetPmtDiscGracePeriodByText('<' + FORMAT(LibraryRandom.RandInt(5)) + 'D>');
      CreateAndPostGenJournalLinesWithPaymentDiscountToleranceSetup(GenJournalLine);

      // Exercise: Apply and post Customer Entry.
      ApplyAndPostCustomerEntry(GenJournalLine."Document No.",GenJournalLine.Amount);

      // Verify: Detailed Customer Ledger Entry must not exist with Payment Discount Tolerance.
      Assert.IsFalse(
        FindDetailedCustLedgEntry(GenJournalLine."Account No.",DetailedCustLedgEntry."Entry Type"::"Payment Discount Tolerance"),
        STRSUBSTNO(DetailedCustomerLedgerEntryMustNotExist,FORMAT(DetailedCustLedgEntry."Entry Type"::"Payment Discount Tolerance")));
Member of Lib.Library - Pmt Disc Setup


SetPmtDiscToleranceWarning@9 Method

The procedure SetPmtDiscToleranceWarning is available in codeunit 131303.

Syntax

SetPmtDiscToleranceWarning@9(
    PmtDiscToleranceWarning@1000 : Boolean PmtDiscToleranceWarning //Input parameter of type Boolean
);

Parameters

PmtDiscToleranceWarning
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, Payment, Discount, Tolerance, Warning.

For a clarification about how this function works, refer to the code listed below.

      GeneralLedgerSetup.GET;
      GeneralLedgerSetup.VALIDATE("Pmt. Disc. Tolerance Warning",PmtDiscToleranceWarning);
      GeneralLedgerSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134022 to show one way of using this function.

      // Check GL Entry for Payment Tolerance Received after applying Payment with Payment Tolerance Warning.

      // Setup: Create Customer, Update General Ledger, Post Invoice and create Customer Payment.
      Initialize;
      LibraryVariableStorage.Enqueue(PostingAction::"Payment Tolerance Accounts");
      LibrarySales.CreateCustomer(Customer);
      TolerancePct := LibraryRandom.RandDec(100,2);
      SetPmtTolerance(TRUE,FALSE,TolerancePct);
      LibraryPmtDiscSetup.SetPmtDiscToleranceWarning(FALSE);
      ToleranceAmount :=
        CustomerInvoiceAndPayment(GenJournalLine,Customer."No.",LibraryERM.CreateGLAccountWithSalesSetup,TolerancePct);

      // Exercise: Apply Payment with Invoice.
      ApplyFromGeneralJournal(GenJournalLine."Document Type",GenJournalLine."Account No.");
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // Verify: Verify Payment Tolerance received in GL Entry.
      CustomerPostingGroup.GET(Customer."Customer Posting Group");
      VerifyGLEntry(GenJournalLine."Document Type",GenJournalLine."Document No.",
        CustomerPostingGroup."Payment Tolerance Debit Acc.",-ToleranceAmount);
Member of Lib.Library - Pmt Disc Setup


SetPmtTolerance@5 Method

The procedure SetPmtTolerance is available in codeunit 131303.

Syntax

SetPmtTolerance@5(
    PaymentTolerancePct@1000 : Decimal PaymentTolerancePct //Input parameter of type Decimal
);

Parameters

PaymentTolerancePct
Input parameter of type Decimal

Remarks

The relevant search keywords are: Set, Payment, Tolerance.

For a clarification about how this function works, refer to the code listed below.

      SetPmtDiscGracePeriodByText('<5D>');
      GeneralLedgerSetup.VALIDATE("Payment Tolerance %",PaymentTolerancePct);
      GeneralLedgerSetup.VALIDATE("Max. Payment Tolerance Amount",5);
      SetPmtTolerancePostings;
      SetPmtToleranceWarnings;
      GeneralLedgerSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134007 to show one way of using this function.

      // Verify VAT Amount on G/L Entry after Unappling Payment from Vendor Ledger Entry.

      // Setup: Modify General Ledger Setup,VAT Posting Setup and Create Vendor With Payment Terms.Post Purchase Invoice and Payment Line.
      Initialize;
      LibraryPmtDiscSetup.SetAdjustForPaymentDisc(TRUE);
      LibraryPmtDiscSetup.SetPmtTolerance(LibraryRandom.RandDec(100,2));
      LibraryERM.FindVATPostingSetup(VATPostingSetup,VATPostingSetup."VAT Calculation Type"::"Reverse Charge VAT");
      OldAdjustforPaymentDiscount := SetAdjustForPaymentDiscInVATPostingSetup(VATPostingSetup,TRUE);
      CreateAndPostPurchaseOrder(PurchaseHeader,VATPostingSetup);
      CreateGeneralJournalLine(GenJournalLine,1,PurchaseHeader."Buy-from Vendor No.",GenJournalLine."Document Type"::Payment,0);  // Taken 1 and 0 to create only one General Journal line with zero amount.
      OpenGeneralJournalPage(GenJournalLine."Document No.",GenJournalLine."Document Type");  // Open General Journal Page and apply to above Posted Purchase Invoice.
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // Exercise: Unapply Vendor Entries.
      UnapplyVendorLedgerEntry(GenJournalLine."Document Type",GenJournalLine."Document No.");

      // Verify: Verify VAT Amount on G/L Entry.
      VerifyVATAmountOnGLEntry(GenJournalLine);

      // TearDown: Cleanup of setup done.
      SetAdjustForPaymentDiscInVATPostingSetup(VATPostingSetup,OldAdjustforPaymentDiscount);
Member of Lib.Library - Pmt Disc Setup


SetPmtToleranceWarning@8 Method

The procedure SetPmtToleranceWarning is available in codeunit 131303.

Syntax

SetPmtToleranceWarning@8(
    PmtToleranceWarning@1000 : Boolean PmtToleranceWarning //Input parameter of type Boolean
);

Parameters

PmtToleranceWarning
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, Payment, Tolerance, Warning.

For a clarification about how this function works, refer to the code listed below.

      GeneralLedgerSetup.GET;
      GeneralLedgerSetup.VALIDATE("Payment Tolerance Warning",PmtToleranceWarning);
      GeneralLedgerSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134022 to show one way of using this function.

      LibraryPmtDiscSetup.SetPmtToleranceWarning(PaymentToleranceWarning);
      LibraryPmtDiscSetup.SetPmtDiscToleranceWarning(PmtDiscToleranceWarning);
      RunChangePaymentTolerance(TRUE,'',TolerancePct,0);
Member of Lib.Library - Pmt Disc Setup


Library - Purchase Class

Lib.Library - Purchase

COD130512 applies to ERM,SCM,RES,W1,All.
Contains all utility functions related to Purchase.

Methods

Name | Description
BlanketPurchaseOrderMakeOrder@27 | The procedure BlanketPurchaseOrderMakeOrder is available in codeunit 130512.
CalcPurchaseDiscount@71 | The procedure CalcPurchaseDiscount is available in codeunit 130512.
CopyPurchaseDocument@10 | The procedure CopyPurchaseDocument is available in codeunit 130512.
CreateFCYPurchaseDocumentWithItem@40 | The procedure CreateFCYPurchaseDocumentWithItem is available in codeunit 130512.
CreateIntrastatContact@53 | The procedure CreateIntrastatContact is available in codeunit 130512.
CreateItemChargeAssignment@32 | The procedure CreateItemChargeAssignment is available in codeunit 130512.
CreateOrderAddress@13 | The procedure CreateOrderAddress is available in codeunit 130512.
CreatePrepaymentVATSetup@34 | The procedure CreatePrepaymentVATSetup is available in codeunit 130512.
CreatePurchaseDocumentWithItem@24 | The procedure CreatePurchaseDocumentWithItem is available in codeunit 130512.
CreatePurchaseHeaderPostingJobQueueEntry@18 | The procedure CreatePurchaseHeaderPostingJobQueueEntry is available in codeunit 130512.
CreatePurchaseInvoice@41 | The procedure CreatePurchaseInvoice is available in codeunit 130512.
CreatePurchaseLine@4 | The procedure CreatePurchaseLine is available in codeunit 130512.
CreatePurchasePrepaymentPct@38 | The procedure CreatePurchasePrepaymentPct is available in codeunit 130512.
CreatePurchasingCode@7 | The procedure CreatePurchasingCode is available in codeunit 130512.
CreatePurchCommentLine@22 | The procedure CreatePurchCommentLine is available in codeunit 130512.
CreatePurchHeader@3 | The procedure CreatePurchHeader is available in codeunit 130512.
CreatePurchHeaderWithDocNo@16 | The procedure CreatePurchHeaderWithDocNo is available in codeunit 130512.
CreateSetupForSubContracting@1500000 | The procedure CreateSetupForSubContracting is available in codeunit 130512.
CreateStandardPurchaseCode@17 | The procedure CreateStandardPurchaseCode is available in codeunit 130512.
CreateStandardPurchaseLine@15 | The procedure CreateStandardPurchaseLine is available in codeunit 130512.
CreateSubcontractor@21 | The procedure CreateSubcontractor is available in codeunit 130512.
CreateVendor@2 | The procedure CreateVendor is available in codeunit 130512.
CreateVendorBankAccount@6 | The procedure CreateVendorBankAccount is available in codeunit 130512.
CreateVendorNo@14 | The procedure CreateVendorNo is available in codeunit 130512.
CreateVendorPostingGroup@93 | The procedure CreateVendorPostingGroup is available in codeunit 130512.
CreateVendorPurchaseCode@25 | The procedure CreateVendorPurchaseCode is available in codeunit 130512.
CreateVendorWithAddress@44 | The procedure CreateVendorWithAddress is available in codeunit 130512.
CreateVendorWithBusPostingGroups@31 | The procedure CreateVendorWithBusPostingGroups is available in codeunit 130512.
CreateVendorWithLocationCode@114 | The procedure CreateVendorWithLocationCode is available in codeunit 130512.
CreateVendorWithVATBusPostingGroup@181 | The procedure CreateVendorWithVATBusPostingGroup is available in codeunit 130512.
CreateVendorWithVATRegNo@28 | The procedure CreateVendorWithVATRegNo is available in codeunit 130512.
DeleteInvoicedPurchOrders@26 | The procedure DeleteInvoicedPurchOrders is available in codeunit 130512.
ExplodeBOM@70 | The procedure ExplodeBOM is available in codeunit 130512.
FindVendorPostingGroup@19 | The procedure FindVendorPostingGroup is available in codeunit 130512.
GetDropShipment@96 | The procedure GetDropShipment is available in codeunit 130512.
GetPurchaseReceiptLine@30 | The procedure GetPurchaseReceiptLine is available in codeunit 130512.
GetSpecialOrder@29 | The procedure GetSpecialOrder is available in codeunit 130512.
PostPurchaseDocument@23 | The procedure PostPurchaseDocument is available in codeunit 130512.
PostPurchasePrepaymentCrMemo@12 | The procedure PostPurchasePrepaymentCrMemo is available in codeunit 130512.
PostPurchasePrepaymentInvoice@11 | The procedure PostPurchasePrepaymentInvoice is available in codeunit 130512.
QuoteMakeOrder@65 | The procedure QuoteMakeOrder is available in codeunit 130512.
ReleasePurchaseDocument@1 | The procedure ReleasePurchaseDocument is available in codeunit 130512.
ReopenPurchaseDocument@110 | The procedure ReopenPurchaseDocument is available in codeunit 130512.
RunBatchPostPurchaseReturnOrdersReport@127 | The procedure RunBatchPostPurchaseReturnOrdersReport is available in codeunit 130512.
RunDeleteInvoicedPurchaseReturnOrdersReport@107 | The procedure RunDeleteInvoicedPurchaseReturnOrdersReport is available in codeunit 130512.
RunMoveNegativePurchaseLinesReport@102 | The procedure RunMoveNegativePurchaseLinesReport is available in codeunit 130512.
SelectPmtJnlBatch@35 | The procedure SelectPmtJnlBatch is available in codeunit 130512.
SelectPmtJnlTemplate@37 | The procedure SelectPmtJnlTemplate is available in codeunit 130512.
SetAllowDocumentDeletionBeforeDate@59 | The procedure SetAllowDocumentDeletionBeforeDate is available in codeunit 130512.
SetAllowVATDifference@39 | The procedure SetAllowVATDifference is available in codeunit 130512.
SetArchiveQuotesAndOrders@5 | The procedure SetArchiveQuotesAndOrders is available in codeunit 130512.
SetCalcInvDiscount@33 | The procedure SetCalcInvDiscount is available in codeunit 130512.
SetCorrDocNoPurchase@20 | The procedure SetCorrDocNoPurchase is available in codeunit 130512.
SetExactCostReversingMandatory@54 | The procedure SetExactCostReversingMandatory is available in codeunit 130512.
SetExtDocNo@100 | The procedure SetExtDocNo is available in codeunit 130512.
SetInvoiceRounding@36 | The procedure SetInvoiceRounding is available in codeunit 130512.
SetReturnOrderNoSeriesInSetup@73 | The procedure SetReturnOrderNoSeriesInSetup is available in codeunit 130512.
SetSubConReceiptPostingDate@1500005 | The procedure SetSubConReceiptPostingDate is available in codeunit 130512.
UndoPurchaseReceiptLine@9 | The procedure UndoPurchaseReceiptLine is available in codeunit 130512.
UndoReturnShipmentLine@8 | The procedure UndoReturnShipmentLine is available in codeunit 130512.

See Also

Lib


BlanketPurchaseOrderMakeOrder@27 Method

The procedure BlanketPurchaseOrderMakeOrder is available in codeunit 130512.

Syntax

BlanketPurchaseOrderMakeOrder@27(
    VAR PurchaseHeader@1000 : Record 38 PurchaseHeader //Reference parameter of type Record
);

Parameters

PurchaseHeader
Reference parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Blanket, Purchase, Order, Make, Order.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(BlanketPurchOrderToOrder);
      BlanketPurchOrderToOrder.RUN(PurchaseHeader);
      BlanketPurchOrderToOrder.GetPurchOrderHeader(PurchOrderHeader);
      EXIT(PurchOrderHeader."No.");

Example

The below example is extracted from the test automation codeunit 134326 to show one way of using this function.

      // [SCENARIO] Test that Quantity Received field updated after posting Purchase Order. Create Purchase Order from Purchase Blanket Order.

      // Setup: Create Purchase Blanket Order with Quantity greater than 1. Change the Quantity to Receive and store it in a variable
      // with Multiple Purchase Line.
      Initialize;
      LibraryPurchase.CreatePurchHeader(PurchaseHeader,PurchaseHeader."Document Type"::"Blanket Order",'');
      LibraryPurchase.CreatePurchaseLine(PurchaseLine,PurchaseHeader,PurchaseLine.Type::Item,'',2 * LibraryRandom.RandInt(10));
      PurchaseLine.VALIDATE("Qty. to Receive",PurchaseLine.Quantity - 1);
      PurchaseLine.MODIFY(TRUE);
      QtyToReceive := PurchaseLine."Qty. to Receive";

      // Exercise: Create Purchase Order from Purchase Blanket Order and post it.
      LibraryPurchase.BlanketPurchaseOrderMakeOrder(PurchaseHeader);
      PurchaseLine2.SETRANGE("Blanket Order No.",PurchaseLine."Document No.");
      PurchaseLine2.SETRANGE("Document Type",PurchaseLine2."Document Type"::Order);
      PurchaseLine2.FINDFIRST;
      PurchaseHeader2.GET(PurchaseLine2."Document Type",PurchaseLine2."Document No.");
      PurchaseHeader2.VALIDATE("Vendor Invoice No.",PurchaseHeader2."No.");
      PurchaseHeader2.MODIFY(TRUE);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader2,TRUE,TRUE);

      // Verify: Verify that the correct Quantity has been updated on Purchase Blanket Order Line.
      PurchaseLine.GET(PurchaseLine."Document Type",PurchaseLine."Document No.",PurchaseLine."Line No.");
      Assert.AreEqual(
        QtyToReceive,PurchaseLine."Quantity Received",STRSUBSTNO(FieldError,PurchaseLine.FIELDCAPTION("Quantity Received")));
Member of Lib.Library - Purchase


CalcPurchaseDiscount@71 Method

The procedure CalcPurchaseDiscount is available in codeunit 130512.

Syntax

CalcPurchaseDiscount@71(
    PurchaseHeader@1000 : Record 38 PurchaseHeader //Input parameter of type Record
);

Parameters

PurchaseHeader
Input parameter of type Record

Remarks

The relevant search keywords are: Calc, Purchase, Discount.

For a clarification about how this function works, refer to the code listed below.

      PurchaseLine."Document Type" := PurchaseHeader."Document Type";
      PurchaseLine."Document No." := PurchaseHeader."No.";
      CODEUNIT.RUN(CODEUNIT::"Purch.-Calc.Discount",PurchaseLine);

Example

The below example is extracted from the test automation codeunit 134104 to show one way of using this function.

      PrepareUnitPrices_TFS229419_ExclVAT(UnitPrices);
      CreatePurchaseOrder_TFS229419(PurchaseHeader,ItemNo,FALSE,DiscountPct,PrepaymentPct);
      CreatePurchaseOrderLines_TFS229419(PurchaseHeader,ItemNo,UnitPrices);
      LibraryPurchase.CalcPurchaseDiscount(PurchaseHeader);
Member of Lib.Library - Purchase


CopyPurchaseDocument@10 Method

The procedure CopyPurchaseDocument is available in codeunit 130512.

Syntax

CopyPurchaseDocument@10(
    PurchaseHeader@1001 : Record 38 PurchaseHeader, //Input parameter of type Record
    NewDocType@1005 : Option NewDocType, //Input parameter of type Option
    NewDocNo@1004 : Code[20] NewDocNo, //Input parameter of type Code
    NewIncludeHeader@1003 : Boolean NewIncludeHeader, //Input parameter of type Boolean
    NewRecalcLines@1002 : Boolean NewRecalcLines //Input parameter of type Boolean
);

Parameters

PurchaseHeader
Input parameter of type Record
NewDocType
Input parameter of type Option
NewDocNo
Input parameter of type Code
NewIncludeHeader
Input parameter of type Boolean
NewRecalcLines
Input parameter of type Boolean

Remarks

The relevant search keywords are: Copy, Purchase, Document.

For a clarification about how this function works, refer to the code listed below.

      CopyPurchaseDocument.SetPurchHeader(PurchaseHeader);
      CopyPurchaseDocument.InitializeRequest(NewDocType,NewDocNo,NewIncludeHeader,NewRecalcLines);
      CopyPurchaseDocument.USEREQUESTPAGE(FALSE);
      CopyPurchaseDocument.RUN;

Example

The below example is extracted from the test automation codeunit 134018 to show one way of using this function.

      // Covers Test Case 124089.
      // Check Vendor Ledger Entry for Payment Tolerance after posting Purchase Credit Memo and Copy Document.

      // Setup: Update General ledger Setup and Create and Post Purchase Invoice.
      Initialize;
      LibraryPmtDiscSetup.SetPmtTolerance(5);

      CreatePurchaseDocument(PurchaseHeader,'',PurchaseHeader."Document Type"::Invoice);
      PurchaseHeader.VALIDATE("Vendor Invoice No.",PurchaseHeader."No.");
      PurchaseHeader.MODIFY(TRUE);
      DocumentNo := LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);
      PurchaseHeader.INIT;
      PurchaseHeader.VALIDATE("Document Type",PurchaseHeader."Document Type"::"Credit Memo");
      PurchaseHeader.INSERT(TRUE);

      // Exercise: Create and Post Purchase Credit Memo after Copy Document with Document Type Posted Invoice.
      LibraryPurchase.CopyPurchaseDocument(PurchaseHeader,DocumentType::"Posted Invoice",DocumentNo,TRUE,TRUE);
      PurchaseHeader.SETRANGE("Applies-to Doc. No.",DocumentNo);
      PurchaseHeader.FINDFIRST;
      PurchaseHeader.VALIDATE("Vendor Cr. Memo No.",DocumentNo);
      PurchaseHeader.MODIFY(TRUE);
      DocumentNo := LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);
      ExecuteUIHandler;  // Need to invoke confirmation message everytime to prevent test failures in ES build.

      // Verify: Max Payment Tolerance is zero for Credit Memo applied to Invoice.
      VerifyMaxPaymentTolCreditMemo(DocumentNo,0);
Member of Lib.Library - Purchase


CreateFCYPurchaseDocumentWithItem@40 Method

The procedure CreateFCYPurchaseDocumentWithItem is available in codeunit 130512.

Syntax

CreateFCYPurchaseDocumentWithItem@40(
    VAR PurchaseHeader@1000 : Record 38 PurchaseHeader, //Reference parameter of type Record
    VAR PurchaseLine@1008 : Record 39 PurchaseLine, //Reference parameter of type Record
    DocumentType@1007 : Option DocumentType, //Input parameter of type Option
    VendorNo@1005 : Code[20] VendorNo, //Input parameter of type Code
    ItemNo@1001 : Code[20] ItemNo, //Input parameter of type Code
    Quantity@1002 : Decimal Quantity, //Input parameter of type Decimal
    LocationCode@1003 : Code[10] LocationCode, //Input parameter of type Code
    ExpectedReceiptDate@1006 : Date ExpectedReceiptDate, //Input parameter of type Date
    CurrencyCode@1004 : Code[10] CurrencyCode //Input parameter of type Code
);

Parameters

PurchaseHeader
Reference parameter of type Record
PurchaseLine
Reference parameter of type Record
DocumentType
Input parameter of type Option
VendorNo
Input parameter of type Code
ItemNo
Input parameter of type Code
Quantity
Input parameter of type Decimal
LocationCode
Input parameter of type Code
ExpectedReceiptDate
Input parameter of type Date
CurrencyCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, FCY, Purchase, Document, Item.

For a clarification about how this function works, refer to the code listed below.

      CreatePurchHeader(PurchaseHeader,DocumentType,VendorNo);
      IF LocationCode <> '' THEN
        PurchaseHeader.VALIDATE("Location Code",LocationCode);
      IF CurrencyCode <> '' THEN
        PurchaseHeader.VALIDATE("Currency Code",CurrencyCode);
      PurchaseHeader.MODIFY(TRUE);
      IF ItemNo = '' THEN
        ItemNo := LibraryInventory.CreateItemNo;
      CreatePurchaseLine(PurchaseLine,PurchaseHeader,PurchaseLine.Type::Item,ItemNo,Quantity);
      IF LocationCode <> '' THEN
        PurchaseLine.VALIDATE("Location Code",LocationCode);
      IF ExpectedReceiptDate <> 0D THEN
        PurchaseLine.VALIDATE("Expected Receipt Date",ExpectedReceiptDate);
      PurchaseLine.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - Purchase


CreateIntrastatContact@53 Method

The procedure CreateIntrastatContact is available in codeunit 130512.

Syntax

CreateIntrastatContact@53(
    CountryRegionCode@1000 : Code[10] CountryRegionCode //Input parameter of type Code
);

Parameters

CountryRegionCode
Input parameter of type Code

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Intrastat, Contact.

For a clarification about how this function works, refer to the code listed below.

      CreateVendor(Vendor);
      Vendor.VALIDATE(Name,LibraryUtility.GenerateGUID);
      Vendor.VALIDATE(Address,LibraryUtility.GenerateGUID);
      Vendor.VALIDATE("Post Code",LibraryUtility.GenerateGUID);
      Vendor.VALIDATE(City,LibraryUtility.GenerateGUID);
      Vendor.VALIDATE("Country/Region Code",CountryRegionCode);
      Vendor.VALIDATE("Phone No.",LibraryUtility.GenerateGUID);
      Vendor.VALIDATE("Fax No.",LibraryUtility.GenerateGUID);
      Vendor.VALIDATE("E-Mail",LibraryUtility.GenerateGUID + '@' + LibraryUtility.GenerateGUID);
      Vendor.MODIFY(TRUE);
      EXIT(Vendor."No.");

Example

The below example is extracted from the test automation codeunit 134150 to show one way of using this function.

      // [FEATURE] [Intrastat Setup] [UT] [UI]
      // [SCENARIO 255730] Set "Intrastat Contact Type" and "Intrastat Contact No." fields via "Intrastat Setup" page
      Initialize;

      // Set "Intrastat Contact Type" = "Contact"
      IntrastatContactNo := LibraryERM.CreateIntrastatContact(CompanyInformation."Intrastat Contact Type"::Contact);
      SetIntrastatContactViaPage(CompanyInformation."Intrastat Contact Type"::Contact,IntrastatContactNo);
      VerifyIntrastatContact(CompanyInformation."Intrastat Contact Type"::Contact,IntrastatContactNo);

      // Set "Intrastat Contact Type" = "Vendor"
      IntrastatContactNo := LibraryERM.CreateIntrastatContact(CompanyInformation."Intrastat Contact Type"::Vendor);
      SetIntrastatContactViaPage(CompanyInformation."Intrastat Contact Type"::Vendor,IntrastatContactNo);
      VerifyIntrastatContact(CompanyInformation."Intrastat Contact Type"::Vendor,IntrastatContactNo);

      // Trying to set "Intrastat Contact Type" = "Contact" with vendor
      Vendor.GET(LibraryPurchase.CreateIntrastatContact(''));
      ASSERTERROR SetIntrastatContactViaPage(CompanyInformation."Intrastat Contact Type"::Contact,Vendor."No.");
      Assert.ExpectedErrorCode('TestValidation');
      Assert.ExpectedError(Contact.TABLECAPTION);

      // Trying to set "Intrastat Contact Type" = "Vendor" with contact
      Contact.GET(LibraryMarketing.CreateIntrastatContact(''));
      ASSERTERROR SetIntrastatContactViaPage(CompanyInformation."Intrastat Contact Type"::Vendor,Contact."No.");
      Assert.ExpectedErrorCode('TestValidation');
      Assert.ExpectedError(Vendor.TABLECAPTION);
Member of Lib.Library - Purchase


CreateItemChargeAssignment@32 Method

The procedure CreateItemChargeAssignment is available in codeunit 130512.

Syntax

CreateItemChargeAssignment@32(
    VAR ItemChargeAssignmentPurch@1000 : Record 5805 ItemChargeAssignmentPurch, //Reference parameter of type Record
    PurchaseLine@1001 : Record 39 PurchaseLine, //Input parameter of type Record
    ItemCharge@1011 : Record 5800 ItemCharge, //Input parameter of type Record
    DocType@1008 : Option DocType, //Input parameter of type Option
    DocNo@1007 : Code[20] DocNo, //Input parameter of type Code
    DocLineNo@1006 : Integer DocLineNo, //Input parameter of type Integer
    ItemNo@1003 : Code[20] ItemNo, //Input parameter of type Code
    Qty@1009 : Decimal Qty, //Input parameter of type Decimal
    UnitCost@1010 : Decimal UnitCost //Input parameter of type Decimal
);

Parameters

ItemChargeAssignmentPurch
Reference parameter of type Record
PurchaseLine
Input parameter of type Record
ItemCharge
Input parameter of type Record
DocType
Input parameter of type Option
DocNo
Input parameter of type Code
DocLineNo
Input parameter of type Integer
ItemNo
Input parameter of type Code
Qty
Input parameter of type Decimal
UnitCost
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Item, Charge, Assignment.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(ItemChargeAssignmentPurch);

      WITH ItemChargeAssignmentPurch DO BEGIN
        "Document Type" := PurchaseLine."Document Type";
        "Document No." := PurchaseLine."Document No.";
        "Document Line No." := PurchaseLine."Line No.";
        "Item Charge No." := PurchaseLine."No.";
        "Unit Cost" := PurchaseLine."Unit Cost";
        RecRef.GETTABLE(ItemChargeAssignmentPurch);
        "Line No." := LibraryUtility.GetNewLineNo(RecRef,FIELDNO("Line No."));
        "Item Charge No." := ItemCharge."No.";
        "Applies-to Doc. Type" := DocType;
        "Applies-to Doc. No." := DocNo;
        "Applies-to Doc. Line No." := DocLineNo;
        "Item No." := ItemNo;
        "Unit Cost" := UnitCost;
        VALIDATE("Qty. to Assign",Qty);
      END;

Example

The below example is extracted from the test automation codeunit 137048 to show one way of using this function.

      LibrarySales.CreateSalesLine(
        SalesLine,SalesHeader,SalesLine.Type::"Charge (Item)",
        LibraryInventory.CreateItemChargeNo,LibraryRandom.RandDec(100,2));
      SalesLine.VALIDATE("Unit Price",LibraryRandom.RandDec(100,2));
      SalesLine.MODIFY(TRUE);
      LibraryInventory.CreateItemChargeAssignment(
        ItemChargeAssignmentSales,SalesLine,ItemChargeAssignmentSales."Applies-to Doc. Type"::Shipment,
        SalesShipmentLine."Document No.",SalesShipmentLine."Line No.",SalesShipmentLine."No.");
Member of Lib.Library - Purchase


CreateOrderAddress@13 Method

The procedure CreateOrderAddress is available in codeunit 130512.

Syntax

CreateOrderAddress@13(
    VAR OrderAddress@1000 : Record 224 OrderAddress, //Reference parameter of type Record
    VendorNo@1001 : Code[20] VendorNo //Input parameter of type Code
);

Parameters

OrderAddress
Reference parameter of type Record
VendorNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Order, Address.

For a clarification about how this function works, refer to the code listed below.

      OrderAddress.INIT;
      OrderAddress.VALIDATE("Vendor No.",VendorNo);
      OrderAddress.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(OrderAddress.FIELDNO(Code),DATABASE::"Order Address"),
          1,
          LibraryUtility.GetFieldLength(DATABASE::"Order Address",OrderAddress.FIELDNO(Code))));
      OrderAddress.INSERT(TRUE);

Example

There are no examples available.
Member of Lib.Library - Purchase


CreatePrepaymentVATSetup@34 Method

The procedure CreatePrepaymentVATSetup is available in codeunit 130512.

Syntax

CreatePrepaymentVATSetup@34(
    VAR LineGLAccount@1001 : Record 15 LineGLAccount, //Reference parameter of type Record
    VATCalculationType@1000 : Option VATCalculationType //Input parameter of type Option
);

Parameters

LineGLAccount
Reference parameter of type Record
VATCalculationType
Input parameter of type Option

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Prepayment, VAT, Setup.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.CreatePrepaymentVATSetup(
        LineGLAccount,PrepmtGLAccount,LineGLAccount."Gen. Posting Type"::Purchase,VATCalculationType,VATCalculationType);
      EXIT(PrepmtGLAccount."No.");

Example

The below example is extracted from the test automation codeunit 134100 to show one way of using this function.

      // [FEATURE] [Sales] [VAT]
      // [SCENARIO 128406] Changed VAT Prod Posting Group on Sales Line.

      // 1. Setup: Create a Sales Order, create an Item, create a Customer with new posting setup, change the Prepayement Percent in Sales
      // Line, change the VAT Prod. Posting Group in Sales Line.
      Initialize;
      LibrarySales.CreatePrepaymentVATSetup(LineGLAccount,VATCalculationType::"Normal VAT");
      CreateSalesDocumentPrepayment(
        SalesHeader,SalesLine,CreateCustomerWithVAT(LineGLAccount."VAT Bus. Posting Group"),
        CreateItemVATProdPostingGroup(LineGLAccount."VAT Prod. Posting Group"));
      UpdateGeneralPostingSetupInGL(SalesLine);
      FindSalesLine(SalesLine,SalesHeader);
      PrepaymentPercentInSalesLine(SalesLine,LibraryRandom.RandDec(99,5));
      NewVATProdPostingGr := LibraryERM.CreateRelatedVATPostingSetup(LineGLAccount);
      SalesLine.VALIDATE("VAT Prod. Posting Group",NewVATProdPostingGr);
      SalesLine.MODIFY(TRUE);

      // 2. Exercise: Post the Prepayment Invoice and post the Sales Order as Ship and Invoice.
      LibrarySales.PostSalesPrepaymentInvoice(SalesHeader);
      InvoiceNo := LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      // 3. Verify: Verify GL Account.
      VerifyGLAccountForVAT(SalesLine);
      VerifyGLAccountForNewVAT(SalesLine,InvoiceNo);
Member of Lib.Library - Purchase


CreatePurchaseDocumentWithItem@24 Method

The procedure CreatePurchaseDocumentWithItem is available in codeunit 130512.

Syntax

CreatePurchaseDocumentWithItem@24(
    VAR PurchaseHeader@1000 : Record 38 PurchaseHeader, //Reference parameter of type Record
    VAR PurchaseLine@1008 : Record 39 PurchaseLine, //Reference parameter of type Record
    DocumentType@1007 : Option DocumentType, //Input parameter of type Option
    VendorNo@1005 : Code[20] VendorNo, //Input parameter of type Code
    ItemNo@1001 : Code[20] ItemNo, //Input parameter of type Code
    Quantity@1002 : Decimal Quantity, //Input parameter of type Decimal
    LocationCode@1003 : Code[10] LocationCode, //Input parameter of type Code
    ExpectedReceiptDate@1006 : Date ExpectedReceiptDate //Input parameter of type Date
);

Parameters

PurchaseHeader
Reference parameter of type Record
PurchaseLine
Reference parameter of type Record
DocumentType
Input parameter of type Option
VendorNo
Input parameter of type Code
ItemNo
Input parameter of type Code
Quantity
Input parameter of type Decimal
LocationCode
Input parameter of type Code
ExpectedReceiptDate
Input parameter of type Date

Remarks

The relevant search keywords are: Create, Purchase, Document, Item.

For a clarification about how this function works, refer to the code listed below.

      CreateFCYPurchaseDocumentWithItem(
        PurchaseHeader,PurchaseLine,DocumentType,VendorNo,ItemNo,Quantity,LocationCode,ExpectedReceiptDate,'');

Example

The below example is extracted from the test automation codeunit 134152 to show one way of using this function.

      // [FEATURE] [Purchase] [Receipt]
      // [SCENARIO 271063] "IC Partner Ref. Type" and "IC Partner Reference" are transferred from Purchase Line to Purchase Receipt Line when posting Purchase Order
      Initialize;

      // [GIVEN] Purchase Order for IC Vendor and Item "I"
      LibraryPurchase.CreatePurchaseDocumentWithItem(
        PurchaseHeader,PurchaseLine,PurchaseHeader."Document Type"::Order,CreateICVendor(CreateICPartner),
        LibraryInventory.CreateItemNo,LibraryRandom.RandDecInRange(10,20,2),'',WORKDATE);

      // [WHEN] Post Purchase Order
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

      // [THEN] Purchase Receipt Line has "IC Partner Ref. Type" = Item and "IC Partner Reference" = "I"
      PurchRcptLine.SETRANGE("Buy-from Vendor No.",PurchaseHeader."Buy-from Vendor No.");
      PurchRcptLine.FINDFIRST;
      PurchRcptLine.TESTFIELD("IC Partner Ref. Type",PurchRcptLine."IC Partner Ref. Type"::Item);
      PurchRcptLine.TESTFIELD("IC Partner Reference",PurchaseLine."No.");
Member of Lib.Library - Purchase


CreatePurchaseHeaderPostingJobQueueEntry@18 Method

The procedure CreatePurchaseHeaderPostingJobQueueEntry is available in codeunit 130512.

Syntax

CreatePurchaseHeaderPostingJobQueueEntry@18(
    VAR JobQueueEntry@1000 : Record 472 JobQueueEntry, //Reference parameter of type Record
    PurchaseHeader@1001 : Record 38 PurchaseHeader //Input parameter of type Record
);

Parameters

JobQueueEntry
Reference parameter of type Record
PurchaseHeader
Input parameter of type Record

Remarks

The relevant search keywords are: Create, Purchase, Header, Posting, Job, Queue, Entry.

For a clarification about how this function works, refer to the code listed below.

      JobQueueEntry.INIT;
      JobQueueEntry.ID := CREATEGUID;
      JobQueueEntry."Earliest Start Date/Time" := CREATEDATETIME(TODAY,0T);
      JobQueueEntry."Object Type to Run" := JobQueueEntry."Object Type to Run"::Codeunit;
      JobQueueEntry."Object ID to Run" := CODEUNIT::"Purchase Post via Job Queue";
      JobQueueEntry."Record ID to Process" := PurchaseHeader.RECORDID;
      JobQueueEntry."Run in User Session" := TRUE;
      JobQueueEntry.Priority := 1000;
      JobQueueEntry.INSERT(TRUE);

Example

There are no examples available.
Member of Lib.Library - Purchase


CreatePurchaseInvoice@41 Method

The procedure CreatePurchaseInvoice is available in codeunit 130512.

Syntax

CreatePurchaseInvoice@41(
    VAR PurchaseHeader@1000 : Record 38 PurchaseHeader //Reference parameter of type Record
);

Parameters

PurchaseHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Purchase, Invoice.

For a clarification about how this function works, refer to the code listed below.

      CreatePurchHeader(PurchaseHeader,PurchaseHeader."Document Type"::Invoice,CreateVendorNo);
      CreatePurchaseLine(PurchaseLine,PurchaseHeader,PurchaseLine.Type::Item,LibraryInventory.CreateItemNo,LibraryRandom.RandInt(100));
      PurchaseLine.VALIDATE("Direct Unit Cost",LibraryRandom.RandDecInRange(1,100,2));
      PurchaseLine.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - Purchase


CreatePurchaseLine@4 Method

The procedure CreatePurchaseLine is available in codeunit 130512.

Syntax

CreatePurchaseLine@4(
    VAR PurchaseLine@1000 : Record 39 PurchaseLine, //Reference parameter of type Record
    PurchaseHeader@1001 : Record 38 PurchaseHeader, //Input parameter of type Record
    Type@1006 : Option Type, //Input parameter of type Option
    No@1005 : Code[20] No, //Input parameter of type Code
    Quantity@1004 : Decimal Quantity //Input parameter of type Decimal
);

Parameters

PurchaseLine
Reference parameter of type Record
PurchaseHeader
Input parameter of type Record
Type
Input parameter of type Option
No
Input parameter of type Code
Quantity
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Purchase, Line.

For a clarification about how this function works, refer to the code listed below.

      PurchaseLine.INIT;
      PurchaseLine.VALIDATE("Document Type",PurchaseHeader."Document Type");
      PurchaseLine.VALIDATE("Document No.",PurchaseHeader."No.");
      RecRef.GETTABLE(PurchaseLine);
      PurchaseLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,PurchaseLine.FIELDNO("Line No.")));
      PurchaseLine.INSERT(TRUE);

      PurchaseLine.VALIDATE(Type,Type);
      CASE Type OF
        PurchaseLine.Type::Item:
          IF No = '' THEN
            No := LibraryInventory.CreateItemNo;
        PurchaseLine.Type::"Charge (Item)":
          IF No = '' THEN
            No := LibraryInventory.CreateItemChargeNo;
        PurchaseLine.Type::"Fixed Asset":
          IF No = '' THEN BEGIN
            LibraryFixedAsset.CreateFixedAsset(FixedAsset);
            No := FixedAsset."No.";
          END;
        PurchaseLine.Type::"G/L Account":
          IF No = '' THEN
            No := LibraryERM.CreateGLAccountNo;
      END;

      IF No <> '' THEN
          LibrarySales.FindType(PurchaseLine.Type,No,PurchaseHeader."Gen. Bus. Posting Group",PurchaseHeader."VAT Bus. Posting Group");

      PurchaseLine.VALIDATE("No.",No);
      PurchaseLine.VALIDATE(Quantity,Quantity);
      PurchaseLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134001 to show one way of using this function.

      LibraryPurchase.CreatePurchaseLine(PurchaseLine,PurchaseHeader,PurchaseLine.Type::Item,ItemNo,Quantity);
      PurchaseLine.VALIDATE("Direct Unit Cost",DirectUnitCost);
      PurchaseLine.MODIFY(TRUE);
Member of Lib.Library - Purchase


CreatePurchasePrepaymentPct@38 Method

The procedure CreatePurchasePrepaymentPct is available in codeunit 130512.

Syntax

CreatePurchasePrepaymentPct@38(
    VAR PurchasePrepaymentPct@1000 : Record 460 PurchasePrepaymentPct, //Reference parameter of type Record
    ItemNo@1003 : Code[20] ItemNo, //Input parameter of type Code
    VendorNo@1001 : Code[20] VendorNo, //Input parameter of type Code
    StartingDate@1004 : Date StartingDate //Input parameter of type Date
);

Parameters

PurchasePrepaymentPct
Reference parameter of type Record
ItemNo
Input parameter of type Code
VendorNo
Input parameter of type Code
StartingDate
Input parameter of type Date

Remarks

The relevant search keywords are: Create, Purchase, Prepayment, Percent.

For a clarification about how this function works, refer to the code listed below.

      PurchasePrepaymentPct.INIT;
      PurchasePrepaymentPct.VALIDATE("Item No.",ItemNo);
      PurchasePrepaymentPct.VALIDATE("Vendor No.",VendorNo);
      PurchasePrepaymentPct.VALIDATE("Starting Date",StartingDate);
      PurchasePrepaymentPct.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134102 to show one way of using this function.

      // Take Random Prepayment %.
      LibraryERM.FindVATPostingSetup(VATPostingSetup,VATPostingSetup."VAT Calculation Type"::"Normal VAT");
      LibraryPurchase.CreatePurchasePrepaymentPct(
        PurchasePrepaymentPct,LibraryInventory.CreateItemNo,VendorNo,WORKDATE);
      PurchasePrepaymentPct.VALIDATE("Prepayment %",LibraryRandom.RandDec(10,2));
      PurchasePrepaymentPct.MODIFY(TRUE);
Member of Lib.Library - Purchase


CreatePurchasingCode@7 Method

The procedure CreatePurchasingCode is available in codeunit 130512.

Syntax

CreatePurchasingCode@7(
    VAR Purchasing@1000 : Record 5721 Purchasing //Reference parameter of type Record
);

Parameters

Purchasing
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Purchasing, Code.

For a clarification about how this function works, refer to the code listed below.

      Purchasing.INIT;
      Purchasing.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(Purchasing.FIELDNO(Code),DATABASE::Purchasing),
          1,
          LibraryUtility.GetFieldLength(DATABASE::Purchasing,Purchasing.FIELDNO(Code))));
      Purchasing.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134417 to show one way of using this function.

      LibraryPurchase.CreatePurchasingCode(Purchasing);
      Purchasing.VALIDATE("Special Order",TRUE);
      Purchasing.MODIFY(TRUE);

      CreateSalesDocument(SalesHeader,SalesLine,SalesHeader."Document Type"::Order);
      SalesLine.VALIDATE("Purchasing Code",Purchasing.Code);
      SalesLine.MODIFY(TRUE);
Member of Lib.Library - Purchase


CreatePurchCommentLine@22 Method

The procedure CreatePurchCommentLine is available in codeunit 130512.

Syntax

CreatePurchCommentLine@22(
    VAR PurchCommentLine@1000 : Record 43 PurchCommentLine, //Reference parameter of type Record
    DocumentType@1001 : Option DocumentType, //Input parameter of type Option
    No@1003 : Code[20] No, //Input parameter of type Code
    DocumentLineNo@1004 : Integer DocumentLineNo //Input parameter of type Integer
);

Parameters

PurchCommentLine
Reference parameter of type Record
DocumentType
Input parameter of type Option
No
Input parameter of type Code
DocumentLineNo
Input parameter of type Integer

Remarks

The relevant search keywords are: Create, Purchase, Comment, Line.

For a clarification about how this function works, refer to the code listed below.

      PurchCommentLine.INIT;
      PurchCommentLine.VALIDATE("Document Type",DocumentType);
      PurchCommentLine.VALIDATE("No.",No);
      PurchCommentLine.VALIDATE("Document Line No.",DocumentLineNo);
      RecRef.GETTABLE(PurchCommentLine);
      PurchCommentLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,PurchCommentLine.FIELDNO("Line No.")));
      PurchCommentLine.INSERT(TRUE);
      // Validate Comment as primary key to enable user to distinguish between comments because value is not important.
      PurchCommentLine.VALIDATE(
        Comment,FORMAT(PurchCommentLine."Document Type") + PurchCommentLine."No." +
        FORMAT(PurchCommentLine."Document Line No.") + FORMAT(PurchCommentLine."Line No."));
      PurchCommentLine.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - Purchase


CreatePurchHeader@3 Method

The procedure CreatePurchHeader is available in codeunit 130512.

Syntax

CreatePurchHeader@3(
    VAR PurchaseHeader@1000 : Record 38 PurchaseHeader, //Reference parameter of type Record
    DocumentType@1001 : Option DocumentType, //Input parameter of type Option
    BuyfromVendorNo@1002 : Code[20] BuyfromVendorNo //Input parameter of type Code
);

Parameters

PurchaseHeader
Reference parameter of type Record
DocumentType
Input parameter of type Option
BuyfromVendorNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Purchase, Header.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(PurchaseHeader);
      PurchaseHeader.VALIDATE("Document Type",DocumentType);
      PurchaseHeader.INSERT(TRUE);
      IF BuyfromVendorNo = '' THEN
        BuyfromVendorNo := CreateVendorNo;
      PurchaseHeader.VALIDATE("Buy-from Vendor No.",BuyfromVendorNo);
      IF PurchaseHeader."Document Type" IN [PurchaseHeader."Document Type"::"Credit Memo",
                                            PurchaseHeader."Document Type"::"Return Order"]
      THEN
        PurchaseHeader.VALIDATE("Vendor Cr. Memo No.",LibraryUtility.GenerateGUID)
      ELSE
        PurchaseHeader.VALIDATE("Vendor Invoice No.",LibraryUtility.GenerateGUID);
      SetCorrDocNoPurchase(PurchaseHeader);
      PurchaseHeader.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134001 to show one way of using this function.

      LibraryPurchase.CreatePurchHeader(PurchaseHeader,DocumentType,VendorNo);
      PurchaseHeader.VALIDATE("Vendor Cr. Memo No.",PurchaseHeader."No.");
      PurchaseHeader.MODIFY(TRUE);
      CreatePurchaseLine(PurchaseHeader,PurchaseLine,ItemNo,DirectUnitCost,Quantity);
      EXIT(LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE));
Member of Lib.Library - Purchase


CreatePurchHeaderWithDocNo@16 Method

The procedure CreatePurchHeaderWithDocNo is available in codeunit 130512.

Syntax

CreatePurchHeaderWithDocNo@16(
    VAR PurchaseHeader@1000 : Record 38 PurchaseHeader, //Reference parameter of type Record
    DocumentType@1001 : Option DocumentType, //Input parameter of type Option
    BuyfromVendorNo@1002 : Code[20] BuyfromVendorNo, //Input parameter of type Code
    DocNo@1003 : Code[20] DocNo //Input parameter of type Code
);

Parameters

PurchaseHeader
Reference parameter of type Record
DocumentType
Input parameter of type Option
BuyfromVendorNo
Input parameter of type Code
DocNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Purchase, Header, Document, No.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(PurchaseHeader);
      PurchaseHeader.VALIDATE("Document Type",DocumentType);
      PurchaseHeader."No." := DocNo;
      PurchaseHeader.INSERT(TRUE);
      IF BuyfromVendorNo = '' THEN
        BuyfromVendorNo := CreateVendorNo;
      PurchaseHeader.VALIDATE("Buy-from Vendor No.",BuyfromVendorNo);
      PurchaseHeader.VALIDATE("Vendor Invoice No.",LibraryUtility.GenerateGUID);
      SetCorrDocNoPurchase(PurchaseHeader);
      PurchaseHeader.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137068 to show one way of using this function.

      // [FEATURE] [Purchase] [Item Tracking] [Item Charge] [Costing]
      // [SCENARIO 349405] Item Charge should be distributed equally to all Item Ledger Entries of Purchase Line with Serial No. tracking when the document is partially invoiced.
      Initialize;

      // [GIVEN] Item with Serial No. tracking.
      CreateSerialNoTrackedItem(ItemSNTracked);

      // [GIVEN] Tracked Purchase Line for the Item. "Qty. to Invoice" is set less than Quantity.
      LibraryPurchase.CreatePurchHeaderWithDocNo(
        PurchaseHeader,PurchaseHeader."Document Type"::Order,LibraryPurchase.CreateVendorNo,LibraryUtility.GenerateGUID);
      CreateAndTrackPurchaseLine(PurchaseHeader,PurchaseLine,ItemSNTracked."No.",TrackingMethod::"Serial No.");

      // [GIVEN] Purchase Line with Item Charge. The Charge is assigned to the line with Item.
      CreatePurchaseLineForItemCharge(PurchaseLineCharge,PurchaseHeader);
      InsertItemChargeAssignmentPurch(PurchaseHeader,PurchaseLine,PurchaseLineCharge,PurchaseLineCharge.Quantity);

      // [WHEN] Post Purchase with "Receive and Invoice" option.
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

      // [THEN] Item Charge is equally distributed to all Item Ledger Entries of posted Purchase.
      VerifyValueEntriesWithItemCharge(PurchaseLineCharge,ItemSNTracked."No.",1); // 1 means 100% of charge is assigned to this line
Member of Lib.Library - Purchase


CreateSetupForSubContracting@1500000 Method

The procedure CreateSetupForSubContracting is available in codeunit 130512.

Syntax

CreateSetupForSubContracting@1500000(
    Vendor@1500000 : Record 23 Vendor //Input parameter of type Record
);

Parameters

Vendor
Input parameter of type Record

Remarks

The relevant search keywords are: Create, Setup, For, Sub, Contracting.

For a clarification about how this function works, refer to the code listed below.

      VendorLocation.SETRANGE("Subcontracting Location",TRUE);
      IF NOT VendorLocation.FINDFIRST THEN BEGIN
        LibraryWarehouse.CreateLocationWithInventoryPostingSetup(VendorLocation);
        VendorLocation.VALIDATE("Subcontracting Location",TRUE);
        VendorLocation.MODIFY(TRUE);
      END;
      InventorySetup.GET;
      InventorySetup.VALIDATE("Job Work Return Period",1);
      InventorySetup.MODIFY(TRUE);
      IF Vendor."Vendor Location" = '' THEN BEGIN
        Vendor."Vendor Location" := VendorLocation.Code;
        Vendor.MODIFY(TRUE);
      END;

Example

The below example is extracted from the test automation codeunit 137004 to show one way of using this function.

      // Update Direct unit Cost and Make Order,random is used values not important for test.
      RequisitionLine.SETRANGE("Prod. Order No.",ProductionOrderNo);
      RequisitionLine.SETRANGE("Work Center No.",WorkCenterNo);
      RequisitionLine.FINDFIRST;
      RequisitionLine.VALIDATE("Direct Unit Cost",LibraryRandom.RandInt(10));
      RequisitionLine.MODIFY(TRUE);
      Vendor.GET(RequisitionLine."Vendor No.");
      LibraryPurchase.CreateSetupForSubContracting(Vendor);
      LibraryPlanning.CarryOutAMSubcontractWksh(RequisitionLine);
Member of Lib.Library - Purchase


CreateStandardPurchaseCode@17 Method

The procedure CreateStandardPurchaseCode is available in codeunit 130512.

Syntax

CreateStandardPurchaseCode@17(
    VAR StandardPurchaseCode@1000 : Record 173 StandardPurchaseCode //Reference parameter of type Record
);

Parameters

StandardPurchaseCode
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Standard, Purchase, Code.

For a clarification about how this function works, refer to the code listed below.

      StandardPurchaseCode.INIT;
      StandardPurchaseCode.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(StandardPurchaseCode.FIELDNO(Code),DATABASE::"Standard Purchase Code"),
          1,
          LibraryUtility.GetFieldLength(DATABASE::"Standard Purchase Code",StandardPurchaseCode.FIELDNO(Code))));
      // Validating Description as Code because value is not important.
      StandardPurchaseCode.VALIDATE(Description,StandardPurchaseCode.Code);
      StandardPurchaseCode.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134327 to show one way of using this function.

      // Test Dimensions are "merged" between the ones coming from Standard Sales Code and Sales Header (customer)

      // 1. Setup : Create Item and customer with dimensions
      Initialize;
      LibraryDimension.FindDimension(Dimension);
      CreateItemWithDimension(Item,Dimension.Code,DefaultDimension."Value Posting"::" ");
      DifferentDimensionCode := FindDifferentDimension(Dimension.Code);
      CreateVendorWithDimension(Vendor,DefaultDimension,DefaultDimension."Value Posting",DifferentDimensionCode);

      // Create Standard Codes and sales header
      LibraryPurchase.CreateStandardPurchaseCode(StandardPurchaseCode);
      CreateStandardPurchaseLine(StandardPurchaseLine,StandardPurchaseCode.Code,StandardPurchaseLine.Type::Item,Item."No.");
      UpdateDimensionSetID(StandardPurchaseLine,Dimension.Code);
      LibraryPurchase.CreateVendorPurchaseCode(StandardVendorPurchaseCode,Vendor."No.",StandardPurchaseLine."Standard Purchase Code");

      LibraryPurchase.CreatePurchHeader(PurchaseHeader,PurchaseHeader."Document Type"::Order,Vendor."No.");

      // 2. Exercise
      LibraryVariableStorage.Enqueue(Vendor."No."); // for the page handler
      StandardVendorPurchaseCode.InsertPurchLines(PurchaseHeader);

      // 3. Verify : Verify that sales Line Dimensions are copied from Standard Sales Line and header
      FindPurchaseLine(PurchaseLine,PurchaseHeader."No.",PurchaseHeader."Document Type");
      VerifyDimensionCode(PurchaseLine."Dimension Set ID",Dimension.Code);
      VerifyDimensionCode(PurchaseLine."Dimension Set ID",DefaultDimension."Dimension Code");
Member of Lib.Library - Purchase


CreateStandardPurchaseLine@15 Method

The procedure CreateStandardPurchaseLine is available in codeunit 130512.

Syntax

CreateStandardPurchaseLine@15(
    VAR StandardPurchaseLine@1000 : Record 174 StandardPurchaseLine, //Reference parameter of type Record
    StandardPurchaseCode@1001 : Code[10] StandardPurchaseCode //Input parameter of type Code
);

Parameters

StandardPurchaseLine
Reference parameter of type Record
StandardPurchaseCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Standard, Purchase, Line.

For a clarification about how this function works, refer to the code listed below.

      StandardPurchaseLine.INIT;
      StandardPurchaseLine.VALIDATE("Standard Purchase Code",StandardPurchaseCode);
      RecRef.GETTABLE(StandardPurchaseLine);
      StandardPurchaseLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,StandardPurchaseLine.FIELDNO("Line No.")));
      StandardPurchaseLine.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134327 to show one way of using this function.

      LibraryPurchase.CreateStandardPurchaseCode(StandardPurchaseCode);
      LibraryPurchase.CreateStandardPurchaseLine(StandardPurchaseLine,StandardPurchaseCode.Code);
      ModifyStandardPurchaseLine(StandardPurchaseLine,ShortCutDimension1,ShortCutDimension2);
      StandardPurchaseLine.GET(StandardPurchaseLine."Standard Purchase Code",StandardPurchaseLine."Line No.");
      CreateStandardPurchLineForPurchaseOrder(PurchaseHeader,StandardPurchaseCode.Code);
Member of Lib.Library - Purchase


CreateSubcontractor@21 Method

The procedure CreateSubcontractor is available in codeunit 130512.

Syntax

CreateSubcontractor@21(
    VAR Vendor@1000 : Record 23 Vendor //Reference parameter of type Record
);

Parameters

Vendor
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Subcontractor.

For a clarification about how this function works, refer to the code listed below.

      CreateVendor(Vendor);
      CreateSetupForSubContracting(Vendor);

Example

The below example is extracted from the test automation codeunit 137004 to show one way of using this function.

      // Create a Subcontractor Vendor.
      LibraryPurchase.CreateSubcontractor(Vendor);
      Vendor.VALIDATE("Currency Code",CurrencyCode);
      Vendor.MODIFY(TRUE);
      EXIT(Vendor."No.");
Member of Lib.Library - Purchase


CreateVendor@2 Method

The procedure CreateVendor is available in codeunit 130512.

Syntax

CreateVendor@2(
    VAR Vendor@1000 : Record 23 Vendor //Reference parameter of type Record
);

Parameters

Vendor
Reference parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Vendor.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.FindPaymentMethod(PaymentMethod);
      LibraryERM.FindGeneralPostingSetupInvtFull(GeneralPostingSetup);
      LibraryERM.FindVATPostingSetupInvt(VATPostingSetup);
      LibraryERM.CreatePaymentTerms(PaymentTerms);
      LibraryUtility.UpdateSetupNoSeriesCode(
        DATABASE::"Purchases & Payables Setup",PurchasesPayablesSetup.FIELDNO("Vendor Nos."));

      CLEAR(Vendor);
      Vendor.INSERT(TRUE);
      Vendor.VALIDATE(Name,Vendor."No."); // Validating Name as No. because value is not important.
      Vendor.VALIDATE("Gen. Bus. Posting Group",GeneralPostingSetup."Gen. Bus. Posting Group");
      Vendor.VALIDATE("VAT Bus. Posting Group",VATPostingSetup."VAT Bus. Posting Group");
      Vendor.VALIDATE("Vendor Posting Group",FindVendorPostingGroup);
      Vendor.VALIDATE("Payment Terms Code",PaymentTerms.Code);
      Vendor.VALIDATE("Payment Method Code",PaymentMethod.Code);
      Vendor.MODIFY(TRUE);
      EXIT(Vendor."No.");

Example

The below example is extracted from the test automation codeunit 134001 to show one way of using this function.

      LibraryPurchase.CreateVendor(Vendor);
      Vendor.VALIDATE("Payment Terms Code",PmtTerms.Code);
      Vendor.VALIDATE("Application Method",Vendor."Application Method"::Manual);
      Vendor.MODIFY(TRUE);
Member of Lib.Library - Purchase


CreateVendorBankAccount@6 Method

The procedure CreateVendorBankAccount is available in codeunit 130512.

Syntax

CreateVendorBankAccount@6(
    VAR VendorBankAccount@1001 : Record 288 VendorBankAccount, //Reference parameter of type Record
    VendorNo@1000 : Code[20] VendorNo //Input parameter of type Code
);

Parameters

VendorBankAccount
Reference parameter of type Record
VendorNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Vendor, Bank, Account.

For a clarification about how this function works, refer to the code listed below.

      VendorBankAccount.INIT;
      VendorBankAccount.VALIDATE("Vendor No.",VendorNo);
      VendorBankAccount.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(VendorBankAccount.FIELDNO(Code),DATABASE::"Vendor Bank Account"),
          1,
          LibraryUtility.GetFieldLength(DATABASE::"Vendor Bank Account",VendorBankAccount.FIELDNO(Code))));
      VendorBankAccount.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134231 to show one way of using this function.

      // [FEATURE] [UT] [Purchase]
      // [SCENARIO 378203] Vendor Bank Account cannot be deleted when it has associated open entries
      Initialize;

      // [GIVEN] Vendor with Vendor Bank Account "X"
      LibraryPurchase.CreateVendor(Vendor);
      LibraryPurchase.CreateVendorBankAccount(VendorBankAccount,Vendor."No.");

      // [GIVEN] Opened Vendor Ledger Entry with "Recipient Bank Account" = "X"
      CreateVendLedgEntry(VendorBankAccount,TRUE);

      // [WHEN] Delete Vendor Bank Account "X"
      ASSERTERROR VendorBankAccount.DELETE(TRUE);

      // [THEN] Error Message: You cannot delete this bank account because there are one or more open entries associated with it.
      Assert.ExpectedError(BankAccDeleteErr);
Member of Lib.Library - Purchase


CreateVendorNo@14 Method

The procedure CreateVendorNo is available in codeunit 130512.

Syntax

CreateVendorNo@14(
      //param element not supplied
);

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Vendor, No.

For a clarification about how this function works, refer to the code listed below.

      CreateVendor(Vendor);
      EXIT(Vendor."No.");

Example

The below example is extracted from the test automation codeunit 134007 to show one way of using this function.

      // [SCENARIO 380040] During application, if there is no "Applies-to ID", then "The application could not be posted, because no entry
      // [SCENARIO] has been selected to be applied / for none of the open entries the "Applies-to ID" has been specfied." error message should appear

      Initialize;

      // [GIVEN] Vendor VVV
      VendorNo := LibraryPurchase.CreateVendorNo;

      // [GIVEN] Gen. Journal Batch GJB with two lines
      // [GIVEN] Gen. Journal Line JL1: an invoice for Vendor VVV with "Document No" = 123 and "Amount" = -1000
      LibraryERM.CreateGenJournalTemplate(GenJournalTemplate);
      LibraryERM.CreateGenJournalBatch(GenJournalBatch,GenJournalTemplate.Name);
      Amount := LibraryRandom.RandDec(1000,2);
      LibraryERM.CreateGeneralJnlLineWithBalAcc(
        GenJournalLine,GenJournalTemplate.Name,GenJournalBatch.Name,GenJournalLine."Document Type"::Invoice,
        GenJournalLine."Account Type"::"G/L Account",LibraryERM.CreateGLAccountNo,
        GenJournalLine."Bal. Account Type"::Vendor,VendorNo,Amount);
      DocNo := GenJournalLine."Document No.";

      // [GIVEN] Gen. Journal Line JL2: a payment for Vendor VVV with "Document No" = 123 (same as JL1) and "Amount" = 1000
      LibraryERM.CreateGeneralJnlLineWithBalAcc(
        GenJournalLine,GenJournalTemplate.Name,GenJournalBatch.Name,GenJournalLine."Document Type"::Payment,
        GenJournalLine."Account Type"::"G/L Account",LibraryERM.CreateGLAccountNo,
        GenJournalLine."Bal. Account Type"::Vendor,VendorNo,-Amount);
      GenJournalLine.VALIDATE("Document No.",DocNo);
      GenJournalLine.MODIFY(TRUE);

      // [GIVEN] Batch GJB posted
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // [WHEN] Apply Payment to Invoice
      LibraryERM.FindVendorLedgerEntry(VendLedgerEntry,VendLedgerEntry."Document Type"::Payment,DocNo);
      ASSERTERROR VendEntryApplyPostedEntries.Apply(VendLedgerEntry,DocNo,WORKDATE);

      // [THEN] The following message appears: Cannot post because you did not specify which entry to apply. You must specify an entry in the Applies-to ID field for one or more open entries.
      Assert.ExpectedError(NoEntriesAppliedErr);
Member of Lib.Library - Purchase


CreateVendorPostingGroup@93 Method

The procedure CreateVendorPostingGroup is available in codeunit 130512.

Syntax

CreateVendorPostingGroup@93(
    VAR VendorPostingGroup@1001 : Record 93 VendorPostingGroup //Reference parameter of type Record
);

Parameters

VendorPostingGroup
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Vendor, Posting, Group.

For a clarification about how this function works, refer to the code listed below.

      VendorPostingGroup.INIT;
      VendorPostingGroup.VALIDATE(Code,
        LibraryUtility.GenerateRandomCode(VendorPostingGroup.FIELDNO(Code),DATABASE::"Vendor Posting Group"));
      VendorPostingGroup.VALIDATE("Payables Account",LibraryERM.CreateGLAccountNo);
      VendorPostingGroup.VALIDATE("Service Charge Acc.",LibraryERM.CreateGLAccountWithPurchSetup);
      VendorPostingGroup.VALIDATE("Invoice Rounding Account",LibraryERM.CreateGLAccountWithPurchSetup);
      VendorPostingGroup.VALIDATE("Debit Rounding Account",LibraryERM.CreateGLAccountNo);
      VendorPostingGroup.VALIDATE("Credit Rounding Account",LibraryERM.CreateGLAccountNo);
      VendorPostingGroup.VALIDATE("Payment Disc. Debit Acc.",LibraryERM.CreateGLAccountNo);
      VendorPostingGroup.VALIDATE("Payment Disc. Credit Acc.",LibraryERM.CreateGLAccountNo);
      VendorPostingGroup.VALIDATE("Payment Tolerance Debit Acc.",LibraryERM.CreateGLAccountNo);
      VendorPostingGroup.VALIDATE("Payment Tolerance Credit Acc.",LibraryERM.CreateGLAccountNo);
      VendorPostingGroup.VALIDATE("Debit Curr. Appln. Rndg. Acc.",LibraryERM.CreateGLAccountNo);
      VendorPostingGroup.VALIDATE("Credit Curr. Appln. Rndg. Acc.",LibraryERM.CreateGLAccountNo);
      VendorPostingGroup.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134093 to show one way of using this function.

      Initialize;

      LibraryPurchase.CreateVendorPostingGroup(VendorPostingGroup);
      VendorPostingGroup.VALIDATE("Invoice Rounding Account",LibraryERM.CreateGLAccountWithPurchSetup);
      VendorPostingGroup.MODIFY;
      LibraryVariableStorage.Enqueue(VendorPostingGroup.FIELDNAME("Invoice Rounding Account"));

      // Execute
      CalcGLAccWhereUsed.CheckGLAcc(VendorPostingGroup."Invoice Rounding Account");

      // Validate in page handler
Member of Lib.Library - Purchase


CreateVendorPurchaseCode@25 Method

The procedure CreateVendorPurchaseCode is available in codeunit 130512.

Syntax

CreateVendorPurchaseCode@25(
    VAR StandardVendorPurchaseCode@1000 : Record 175 StandardVendorPurchaseCode, //Reference parameter of type Record
    VendorNo@1001 : Code[20] VendorNo, //Input parameter of type Code
    Code@1002 : Code[10] Code //Input parameter of type Code
);

Parameters

StandardVendorPurchaseCode
Reference parameter of type Record
VendorNo
Input parameter of type Code
Code
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Vendor, Purchase, Code.

For a clarification about how this function works, refer to the code listed below.

      StandardVendorPurchaseCode.INIT;
      StandardVendorPurchaseCode.VALIDATE("Vendor No.",VendorNo);
      StandardVendorPurchaseCode.VALIDATE(Code,Code);
      StandardVendorPurchaseCode.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134327 to show one way of using this function.

      // Test Dimensions are "merged" between the ones coming from Standard Sales Code and Sales Header (customer)

      // 1. Setup : Create Item and customer with dimensions
      Initialize;
      LibraryDimension.FindDimension(Dimension);
      CreateItemWithDimension(Item,Dimension.Code,DefaultDimension."Value Posting"::" ");
      DifferentDimensionCode := FindDifferentDimension(Dimension.Code);
      CreateVendorWithDimension(Vendor,DefaultDimension,DefaultDimension."Value Posting",DifferentDimensionCode);

      // Create Standard Codes and sales header
      LibraryPurchase.CreateStandardPurchaseCode(StandardPurchaseCode);
      CreateStandardPurchaseLine(StandardPurchaseLine,StandardPurchaseCode.Code,StandardPurchaseLine.Type::Item,Item."No.");
      UpdateDimensionSetID(StandardPurchaseLine,Dimension.Code);
      LibraryPurchase.CreateVendorPurchaseCode(StandardVendorPurchaseCode,Vendor."No.",StandardPurchaseLine."Standard Purchase Code");

      LibraryPurchase.CreatePurchHeader(PurchaseHeader,PurchaseHeader."Document Type"::Order,Vendor."No.");

      // 2. Exercise
      LibraryVariableStorage.Enqueue(Vendor."No."); // for the page handler
      StandardVendorPurchaseCode.InsertPurchLines(PurchaseHeader);

      // 3. Verify : Verify that sales Line Dimensions are copied from Standard Sales Line and header
      FindPurchaseLine(PurchaseLine,PurchaseHeader."No.",PurchaseHeader."Document Type");
      VerifyDimensionCode(PurchaseLine."Dimension Set ID",Dimension.Code);
      VerifyDimensionCode(PurchaseLine."Dimension Set ID",DefaultDimension."Dimension Code");
Member of Lib.Library - Purchase


CreateVendorWithAddress@44 Method

The procedure CreateVendorWithAddress is available in codeunit 130512.

Syntax

CreateVendorWithAddress@44(
    VAR Vendor@1000 : Record 23 Vendor //Reference parameter of type Record
);

Parameters

Vendor
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Vendor, Address.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.CreatePostCode(PostCode);
      CreateVendor(Vendor);
      Vendor.VALIDATE(Name,LibraryUtility.GenerateRandomText(MAXSTRLEN(Vendor.Name)));
      Vendor.VALIDATE(Address,LibraryUtility.GenerateRandomText(MAXSTRLEN(Vendor.Address)));
      Vendor.VALIDATE("Post Code",PostCode.Code);
      Vendor.Contact := COPYSTR(LibraryUtility.GenerateRandomText(MAXSTRLEN(Vendor.Contact)),1,MAXSTRLEN(Vendor.Contact));
      Vendor.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - Purchase


CreateVendorWithBusPostingGroups@31 Method

The procedure CreateVendorWithBusPostingGroups is available in codeunit 130512.

Syntax

CreateVendorWithBusPostingGroups@31(
    GenBusPostGroupCode@1000 : Code[10] GenBusPostGroupCode, //Input parameter of type Code
    VATBusPostGroupCode@1002 : Code[10] VATBusPostGroupCode //Input parameter of type Code
);

Parameters

GenBusPostGroupCode
Input parameter of type Code
VATBusPostGroupCode
Input parameter of type Code

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Vendor, Business, Posting, Groups.

For a clarification about how this function works, refer to the code listed below.

      WITH Vendor DO BEGIN
        CreateVendor(Vendor);
        VALIDATE("Gen. Bus. Posting Group",GenBusPostGroupCode);
        VALIDATE("VAT Bus. Posting Group",VATBusPostGroupCode);
        MODIFY(TRUE);
        EXIT("No.");
      END;

Example

The below example is extracted from the test automation codeunit 134090 to show one way of using this function.

      CreateNormalVATPostingSetupWithAdjPmtDisc(VATPostingSetup,VATPct);
      CreateGeneralPostingSetup(GeneralPostingSetup);

      VendorNo :=
        LibraryPurchase.CreateVendorWithBusPostingGroups(
          GeneralPostingSetup."Gen. Bus. Posting Group",VATPostingSetup."VAT Bus. Posting Group");
      LibraryERM.CreateGLAccount(GLAccount);
      LibraryERM.UpdateGLAccountWithPostingSetup(
        GLAccount,GLAccount."Gen. Posting Type"::Purchase,GeneralPostingSetup,VATPostingSetup);
      GLAccountNo := GLAccount."No.";
Member of Lib.Library - Purchase


CreateVendorWithLocationCode@114 Method

The procedure CreateVendorWithLocationCode is available in codeunit 130512.

Syntax

CreateVendorWithLocationCode@114(
    VAR Vendor@1000 : Record 23 Vendor, //Reference parameter of type Record
    LocationCode@1001 : Code[10] LocationCode //Input parameter of type Code
);

Parameters

Vendor
Reference parameter of type Record
LocationCode
Input parameter of type Code

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Vendor, Location, Code.

For a clarification about how this function works, refer to the code listed below.

      WITH Vendor DO BEGIN
        CreateVendor(Vendor);
        VALIDATE("Location Code",LocationCode);
        MODIFY(TRUE);
        EXIT("No.");
      END;

Example

The below example is extracted from the test automation codeunit 134383 to show one way of using this function.

      // [SCENARIO 360231] Verify that location code can be updated in purchase order with blank line.

      // [GIVEN] Purchase Order with blank line
      Initialize;
      CreatePurchOrderWithBlankLine(PurchHeader);
      LibraryWarehouse.CreateLocation(Location);
      // [GIVEN] Vendor A with location code X
      LibraryPurchase.CreateVendorWithLocationCode(Vendor,Location.Code);
      PurchHeader.SetHideValidationDialog(TRUE);

      // [WHEN] Set Vendor A as "Buy-from Vendor No."
      PurchHeader.VALIDATE("Buy-from Vendor No.",Vendor."No.");

      // [THEN] Location code on the header is X
      Assert.AreEqual(Vendor."Location Code",PurchHeader."Location Code",UnexpectedLocationCodeErr);
Member of Lib.Library - Purchase


CreateVendorWithVATBusPostingGroup@181 Method

The procedure CreateVendorWithVATBusPostingGroup is available in codeunit 130512.

Syntax

CreateVendorWithVATBusPostingGroup@181(
    VATBusPostGroupCode@1000 : Code[10] VATBusPostGroupCode //Input parameter of type Code
);

Parameters

VATBusPostGroupCode
Input parameter of type Code

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Vendor, VAT, Business, Posting, Group.

For a clarification about how this function works, refer to the code listed below.

      WITH Vendor DO BEGIN
        CreateVendor(Vendor);
        VALIDATE("VAT Bus. Posting Group",VATBusPostGroupCode);
        MODIFY(TRUE);
        EXIT("No.");
      END;

Example

The below example is extracted from the test automation codeunit 134022 to show one way of using this function.

      CreatePaymentTerms(PaymentTerms);
      LibraryPurchase.CreatePurchHeader(
        PurchHeader,PurchHeader."Document Type"::Invoice,
        LibraryPurchase.CreateVendorWithVATBusPostingGroup(VATPostingSetup."VAT Bus. Posting Group"));
      PurchHeader.VALIDATE("Payment Terms Code",PaymentTerms.Code);
      PurchHeader.MODIFY(TRUE);
      LibraryPurchase.CreatePurchaseLine(
        PurchLine,PurchHeader,PurchLine.Type::"G/L Account",GLAccNo,LibraryRandom.RandDec(10,2));
      PurchLine.VALIDATE("Direct Unit Cost",LibraryRandom.RandDec(100,2));
      PurchLine.MODIFY(TRUE);
      UpdateGenPostingSetupWithPmtDiscAcc(PurchLine."Gen. Bus. Posting Group",PurchLine."Gen. Prod. Posting Group");
      EXIT(LibraryPurchase.PostPurchaseDocument(PurchHeader,TRUE,TRUE));
Member of Lib.Library - Purchase


CreateVendorWithVATRegNo@28 Method

The procedure CreateVendorWithVATRegNo is available in codeunit 130512.

Syntax

CreateVendorWithVATRegNo@28(
    VAR Vendor@1000 : Record 23 Vendor //Reference parameter of type Record
);

Parameters

Vendor
Reference parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Vendor, VAT, Reg, No.

For a clarification about how this function works, refer to the code listed below.

      CreateVendor(Vendor);
      LibraryERM.CreateCountryRegion(CountryRegion);
      Vendor.VALIDATE("Country/Region Code",CountryRegion.Code);
      Vendor.VALIDATE("VAT Registration No.",LibraryERM.GenerateVATRegistrationNo(CountryRegion.Code));
      Vendor.MODIFY(TRUE);
      EXIT(Vendor."No.");

Example

The below example is extracted from the test automation codeunit 134045 to show one way of using this function.

      LibraryPurchase.CreateVendorWithVATRegNo(Vendor);
      Vendor.VALIDATE("VAT Bus. Posting Group",VATBusPostingGroup);
      Vendor.MODIFY;
Member of Lib.Library - Purchase


DeleteInvoicedPurchOrders@26 Method

The procedure DeleteInvoicedPurchOrders is available in codeunit 130512.

Syntax

DeleteInvoicedPurchOrders@26(
    VAR PurchaseHeader@1000 : Record 38 PurchaseHeader //Reference parameter of type Record
);

Parameters

PurchaseHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Delete, Invoiced, Purchase, Orders.

For a clarification about how this function works, refer to the code listed below.

      IF PurchaseHeader.HASFILTER THEN
        PurchaseHeader2.COPYFILTERS(PurchaseHeader)
      ELSE BEGIN
        PurchaseHeader.GET(PurchaseHeader."Document Type",PurchaseHeader."No.");
        PurchaseHeader2.SETRANGE("Document Type",PurchaseHeader."Document Type");
        PurchaseHeader2.SETRANGE("No.",PurchaseHeader."No.");
      END;
      CLEAR(DeleteInvoicedPurchOrders);
      DeleteInvoicedPurchOrders.SETTABLEVIEW(PurchaseHeader2);
      DeleteInvoicedPurchOrders.USEREQUESTPAGE(FALSE);
      DeleteInvoicedPurchOrders.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 137061 to show one way of using this function.

      // Post Invoice and delete Invoiced Purchase Orders.
      // 1. Setup.
      Initialize;
      CreateItem(Item);

      // Create and Post Purchase orders and combine Purchase Receipts and post Invoice.
      CombinePurchaseReceiptsSetup(Vendor,Item,PurchaseReceiptNo,PurchaseReceiptNo2);

      // 2. Exercise: Delete the Invoiced Purchase Orders.
      PurchaseHeader2.SETRANGE("Document Type",PurchaseHeader."Document Type"::Order);
      PurchaseHeader2.SETRANGE("Buy-from Vendor No.",Vendor."No.");
      LibraryPurchase.DeleteInvoicedPurchOrders(PurchaseHeader2);

      // 3. Verify: verify Old Purchase Orders have been deleted.
      PurchaseHeader.SETRANGE("Document Type",PurchaseHeader."Document Type"::Order);
      PurchaseHeader.SETRANGE("No.",Vendor."No.");
      Assert.AreEqual(0,PurchaseHeader.COUNT,OrdersDeletedError);
Member of Lib.Library - Purchase


ExplodeBOM@70 Method

The procedure ExplodeBOM is available in codeunit 130512.

Syntax

ExplodeBOM@70(
    VAR PurchaseLine@1001 : Record 39 PurchaseLine //Reference parameter of type Record
);

Parameters

PurchaseLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Explode, BOM.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(PurchExplodeBOM);
      PurchExplodeBOM.RUN(PurchaseLine);

Example

The below example is extracted from the test automation codeunit 134330 to show one way of using this function.

      // Verify error while applying Explode BOM on Purchase Credit Memo created from Purchase Return Order.

      // Setup: Create and Ship Purchase Return Order. Create Purchase Credit Memo using Get Return Shipment Lines.
      Initialize;
      CreateAndShipPurchRetOrder(PurchaseHeader);
      CreatePurchCrMemoUsingGetRetShptLines(PurchaseHeader2,PurchaseHeader."Buy-from Vendor No.");
      FilterOnPurchaseLine(PurchaseLine,PurchaseHeader2."Document Type",PurchaseHeader2."No.");
      PurchaseLine.FINDFIRST;

      // Excercise: Apply Explode BOM on Purchase Credit Memo Line.
      ASSERTERROR LibraryPurchase.ExplodeBOM(PurchaseLine);

      // Verify: Verify error while applying Explode BOM on Purchase Credit Memo.
      Assert.ExpectedError(STRSUBSTNO(ExplodBOMErr,PurchaseLine."Document No.",PurchaseLine."Line No."));
Member of Lib.Library - Purchase


FindVendorPostingGroup@19 Method

The procedure FindVendorPostingGroup is available in codeunit 130512.

Syntax

FindVendorPostingGroup@19(
      //param element not supplied
);

Return Value

Code[10]

Remarks

The relevant search keywords are: Find, Vendor, Posting, Group.

For a clarification about how this function works, refer to the code listed below.

      IF NOT VendorPostingGroup.FINDFIRST THEN
        CreateVendorPostingGroup(VendorPostingGroup);
      EXIT(VendorPostingGroup.Code);

Example

There are no examples available.
Member of Lib.Library - Purchase


GetDropShipment@96 Method

The procedure GetDropShipment is available in codeunit 130512.

Syntax

GetDropShipment@96(
    VAR PurchaseHeader@1001 : Record 38 PurchaseHeader //Reference parameter of type Record
);

Parameters

PurchaseHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Get, Drop, Shipment.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(PurchGetDropShpt);
      PurchGetDropShpt.RUN(PurchaseHeader);

Example

The below example is extracted from the test automation codeunit 134900 to show one way of using this function.

      // [FEATURE] [Special Order] [Drop Shipment] [Sales]
      // Setup: Create Sales Order with Special Order Line And Drop Shipment Line.
      Initialize;
      CreateSalesOrderWithSpecialOrderAndDropShipment(SalesHeader);

      // Exercise: Create Purchase Order. Get Special Order then Get Drop Shipment.
      CreatePurchHeader(PurchHeader,SalesHeader."Sell-to Customer No.",'');
      DistIntegration.GetSpecialOrders(PurchHeader);
      COMMIT;
      ASSERTERROR LibraryPurchase.GetDropShipment(PurchHeader);

      // Verify: Verify Error message.
      Assert.ExpectedError(STRSUBSTNO(ShipToNameErr,PurchHeader.FIELDCAPTION("Ship-to Name"),PurchHeader."No.",SalesHeader."No."));

      // Verify: Verify Purchasing Code, Ship-to Name, Ship-to Address on Purchase Order with Special Order.
      SelectSalesLineWithSpecialOrder(SalesLine,SalesHeader);
      VerifyPurchasingCodeAndSpecialOrderOnPurchaseLine(SalesLine,PurchHeader."No.");
      Location.GET(SalesHeader."Location Code");
      VerifyPurchShippingDetails(PurchHeader,Location.Name,Location.Address);
Member of Lib.Library - Purchase


GetPurchaseReceiptLine@30 Method

The procedure GetPurchaseReceiptLine is available in codeunit 130512.

Syntax

GetPurchaseReceiptLine@30(
    VAR PurchaseLine@1001 : Record 39 PurchaseLine //Reference parameter of type Record
);

Parameters

PurchaseLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Get, Purchase, Receipt, Line.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(PurchGetReceipt);
      PurchGetReceipt.RUN(PurchaseLine);

Example

The below example is extracted from the test automation codeunit 134481 to show one way of using this function.

      // [FEATURE] [Purchase] [Order] [Get Receipt Lines]
      // [SCENARIO 200401] System creates archive after delete invoiced purchase order

      // [GIVEN] Purchase Order "PO" fully receipt and not invoiced (1 archive exists)
      Initialize;
      LibraryPurchase.SetArchiveQuotesAndOrders(TRUE);
      CreatePurchaseOrder(PurchaseHeaderOrder,PurchaseLineOrder);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeaderOrder,TRUE,FALSE);

      VerifyPurchaseOrderArchive(PurchaseHeaderOrder,PurchaseLineOrder,1);

      // [GIVEN] Purchase Invoice created from "PO" with "Get Receipt Lines" and fully invoiced
      LibraryPurchase.CreatePurchHeader(
        PurchaseHeaderInvoice,PurchaseHeaderInvoice."Document Type"::Invoice,PurchaseHeaderOrder."Buy-from Vendor No.");
      PurchaseLineInvoice.VALIDATE("Document Type",PurchaseHeaderInvoice."Document Type");
      PurchaseLineInvoice.VALIDATE("Document No.",PurchaseHeaderInvoice."No.");
      LibraryPurchase.GetPurchaseReceiptLine(PurchaseLineInvoice);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeaderInvoice,TRUE,TRUE);

      // [WHEN] Delete "PO"
      PurchaseHeaderOrder.FIND;
      PurchaseHeaderOrder.DELETE(TRUE);

      // [THEN] 2nd archive created
      VerifyPurchaseOrderArchive(PurchaseHeaderOrder,PurchaseLineOrder,2);
Member of Lib.Library - Purchase


GetSpecialOrder@29 Method

The procedure GetSpecialOrder is available in codeunit 130512.

Syntax

GetSpecialOrder@29(
    VAR PurchaseHeader@1000 : Record 38 PurchaseHeader //Reference parameter of type Record
);

Parameters

PurchaseHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Get, Special, Order.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(DistIntegration);
      DistIntegration.GetSpecialOrders(PurchaseHeader);

Example

The below example is extracted from the test automation codeunit 134417 to show one way of using this function.

      LibraryPurchase.CreatePurchHeader(PurchaseHeader,PurchaseHeader."Document Type"::Order,LibraryPurchase.CreateVendorNo);
      PurchaseHeader.VALIDATE("Sell-to Customer No.",CustomerNo);
      PurchaseHeader.MODIFY(TRUE);
      LibraryPurchase.GetSpecialOrder(PurchaseHeader);
Member of Lib.Library - Purchase


PostPurchaseDocument@23 Method

The procedure PostPurchaseDocument is available in codeunit 130512.

Syntax

PostPurchaseDocument@23(
    VAR PurchaseHeader@1002 : Record 38 PurchaseHeader, //Reference parameter of type Record
    ToShipReceive@1001 : Boolean ToShipReceive, //Input parameter of type Boolean
    ToInvoice@1000 : Boolean ToInvoice //Input parameter of type Boolean
);

Parameters

PurchaseHeader
Reference parameter of type Record
ToShipReceive
Input parameter of type Boolean
ToInvoice
Input parameter of type Boolean

Return Value

Code[20]

Remarks

The relevant search keywords are: Post, Purchase, Document.

For a clarification about how this function works, refer to the code listed below.

      // Post the purchase document.
      // Depending on the document type and posting type return the number of the:
      // - purchase receipt,
      // - posted purchase invoice,
      // - purchase return shipment, or
      // - posted credit memo
      SetCorrDocNoPurchase(PurchaseHeader);
      WITH PurchaseHeader DO BEGIN
        VALIDATE(Receive,ToShipReceive);
        VALIDATE(Ship,ToShipReceive);
        VALIDATE(Invoice,ToInvoice);

        CASE "Document Type" OF
          "Document Type"::Invoice:
            NoSeriesCode := "Posting No. Series"; // posted purchase invoice
          "Document Type"::Order:
            IF ToShipReceive AND NOT ToInvoice THEN
              NoSeriesCode := "Receiving No. Series" // posted purchase receipt
            ELSE
              NoSeriesCode := "Posting No. Series"; // posted purchase invoice
          "Document Type"::"Credit Memo":
            NoSeriesCode := "Posting No. Series"; // posted purchase credit memo
          "Document Type"::"Return Order":
            IF ToShipReceive AND NOT ToInvoice THEN
              NoSeriesCode := "Return Shipment No. Series" // posted purchase return shipment
            ELSE
              NoSeriesCode := "Posting No. Series"; // posted purchase credit memo
          ELSE
            Assert.Fail(STRSUBSTNO('Document type not supported: %1',"Document Type"))
        END
      END;

      DocumentNo := NoSeriesManagement.GetNextNo(NoSeriesCode,LibraryUtility.GetNextNoSeriesPurchaseDate(NoSeriesCode),FALSE);

      IF (ToShipReceive) AND (PurchaseHeader.Subcontracting) THEN
        UpdateSubConOrder(PurchaseHeader);

      CODEUNIT.RUN(CODEUNIT::"Purch.-Post",PurchaseHeader);

      IF (ToShipReceive) AND (PurchaseHeader.Subcontracting) THEN
        UpdateSubConOrderZero(PurchaseHeader);

Example

The below example is extracted from the test automation codeunit 134001 to show one way of using this function.

      LibraryPurchase.CreatePurchHeader(PurchaseHeader,DocumentType,VendorNo);
      PurchaseHeader.VALIDATE("Vendor Cr. Memo No.",PurchaseHeader."No.");
      PurchaseHeader.MODIFY(TRUE);
      CreatePurchaseLine(PurchaseHeader,PurchaseLine,ItemNo,DirectUnitCost,Quantity);
      EXIT(LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE));
Member of Lib.Library - Purchase


PostPurchasePrepaymentCrMemo@12 Method

The procedure PostPurchasePrepaymentCrMemo is available in codeunit 130512.

Syntax

PostPurchasePrepaymentCrMemo@12(
    VAR PurchaseHeader@1000 : Record 38 PurchaseHeader //Reference parameter of type Record
);

Parameters

PurchaseHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Post, Purchase, Prepayment, Credit, Memo.

For a clarification about how this function works, refer to the code listed below.

      PurchPostPrepayments.CreditMemo(PurchaseHeader);

Example

The below example is extracted from the test automation codeunit 134100 to show one way of using this function.

      // [FEATURE] [Purchase] [Credit Memo]
      // [SCENARIO 360198] Purchase Prepayment Cr. Memo after full Prepayment Invoice and Partial Invoice with Amounts Excl. VAT
      // [GIVEN] Posted 100% Prepayment Invoice in LCY and Price Including VAT is FALSE
      InitPurchasePrepaymentScenario(PurchaseHeader,PurchaseLine,FALSE,100,'');
      // [GIVEN] Posted Prepayment Invoice
      LibraryPurchase.PostPurchasePrepaymentInvoice(PurchaseHeader);
      // [GIVEN] Posted Partial Invoice
      PostPartialPurchaseInvoice(PurchaseHeader,PurchaseLine);
      // [WHEN] Prepayment Credit Memo posted
      LibraryPurchase.PostPurchasePrepaymentCrMemo(PurchaseHeader);
      // [THEN] Prepaymen Amt Incl. VAT in Purchase Line must be decreased by amount of Prepayment Credit Memo
      VerifyPurchPrepmtAmtInclVAT(PurchaseLine,PurchaseHeader."Prices Including VAT");
Member of Lib.Library - Purchase


PostPurchasePrepaymentInvoice@11 Method

The procedure PostPurchasePrepaymentInvoice is available in codeunit 130512.

Syntax

PostPurchasePrepaymentInvoice@11(
    VAR PurchaseHeader@1000 : Record 38 PurchaseHeader //Reference parameter of type Record
);

Parameters

PurchaseHeader
Reference parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Post, Purchase, Prepayment, Invoice.

For a clarification about how this function works, refer to the code listed below.

      NoSeriesCode := PurchaseHeader."Prepayment No. Series";
      IF PurchaseHeader."Prepayment No." = '' THEN
        DocumentNo := NoSeriesMgt.GetNextNo(NoSeriesCode,LibraryUtility.GetNextNoSeriesPurchaseDate(NoSeriesCode),FALSE)
      ELSE
        DocumentNo := PurchaseHeader."Prepayment No.";
      PurchasePostPrepayments.Invoice(PurchaseHeader);

Example

The below example is extracted from the test automation codeunit 134100 to show one way of using this function.

      // Setup: Create a new Customer with Prepayment %.
      Initialize;
      PurchaseAndPayablesSetup.GET;
      PurchaseAndPayablesSetup."Ext. Doc. No. Mandatory" := FALSE;
      PurchaseAndPayablesSetup.MODIFY;
      CreatePrepmtVATSetup(LineGLAccount,LineGLAccount."Gen. Posting Type"::Purchase);
      CreateVendorWithPrepmtPct(Vendor,LineGLAccount);

      // Exercise: Create Purch Order with one G/L Account line and post Prepayment Invoice,
      // Create Prepayment and apply it to Prepayment Invoice,
      // Post partitial Invoice
      CreatePurchOrderWithOneLine(Vendor."No.",PurchHeader,PurchLine,LineGLAccount);
      LibraryPurchase.PostPurchasePrepaymentInvoice(PurchHeader);
      FindPurchPrepmtInvoice(PrepmtPurchInvHeader,PurchHeader."No.");
      CreateVendorPrepmtPaymentAndApply(PrepmtPurchInvHeader);
      PurchInvHeader.GET(PostPurchaseDocument(PurchHeader));
      PurchLine.GET(PurchLine."Document Type",PurchLine."Document No.",PurchLine."Line No.");

      // Verify: Verify Total Amount (LCY) at Customer Statistics page
      VerifyVendorStatisticsTotalAmount(
        Vendor,PurchHeader,PurchLine,PrepmtPurchInvHeader,PurchInvHeader);
Member of Lib.Library - Purchase


QuoteMakeOrder@65 Method

The procedure QuoteMakeOrder is available in codeunit 130512.

Syntax

QuoteMakeOrder@65(
    VAR PurchaseHeader@1000 : Record 38 PurchaseHeader //Reference parameter of type Record
);

Parameters

PurchaseHeader
Reference parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Quote, Make, Order.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(PurchQuoteToOrder);
      PurchQuoteToOrder.RUN(PurchaseHeader);
      PurchQuoteToOrder.GetPurchOrderHeader(PurchaseOrderHeader);
      EXIT(PurchaseOrderHeader."No.");

Example

The below example is extracted from the test automation codeunit 137068 to show one way of using this function.

      // Setup: Create Item and create and post a Sales Order. Copy Sales Order to a Sales blank Quote
      Initialize;
      ItemNo := CreateItem;
      StockoutWarning := UpdateStockoutWarning(FALSE);
      Quantity := LibraryRandom.RandDec(100,2);
      CreateAndReleaseSalesOrder(SalesHeader,ItemNo,Quantity);
      LibrarySales.PostSalesDocument(SalesHeader,TRUE,FALSE);  // Post as Ship only.
      CopySalesDocument(SalesHeader2,SalesHeader2."Document Type"::Quote,GlobalDocumentType::Order,SalesHeader."No.");

      // Exercise: Make Sales Order from Sales Quote.
      LibrarySales.QuoteMakeOrder(SalesHeader2);

      // Verify: Verify the Last Shipping No as blank on Sales Order created from Sales Quote. Verify the values on Sales Order made from the Sales Quote.
      SelectSalesHeader(SalesHeader2,SalesHeader2."Sell-to Customer No.");
      SalesHeader2.TESTFIELD("Last Shipping No.",'');
      VerifySalesLine(SalesHeader2,ItemNo,Quantity);

      // Tear Down: Set Stockout Warning to original state.
      UpdateStockoutWarning(StockoutWarning);
Member of Lib.Library - Purchase


ReleasePurchaseDocument@1 Method

The procedure ReleasePurchaseDocument is available in codeunit 130512.

Syntax

ReleasePurchaseDocument@1(
    VAR PurchaseHeader@1000 : Record 38 PurchaseHeader //Reference parameter of type Record
);

Parameters

PurchaseHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Release, Purchase, Document.

For a clarification about how this function works, refer to the code listed below.

      ReleasePurchDoc.PerformManualRelease(PurchaseHeader);

Example

The below example is extracted from the test automation codeunit 134031 to show one way of using this function.

      LibraryPmtDiscSetup.SetPmtDiscExclVAT(PmtDiscExclVAT);
      CreatePurchaseDocument(PurchaseHeader,CreateVendor,CurrencyCode,DocumentType);
      LibraryPurchase.ReleasePurchaseDocument(PurchaseHeader);
      PurchaseHeader.CALCFIELDS("Amount Including VAT",Amount);
      EXIT(LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE));
Member of Lib.Library - Purchase


ReopenPurchaseDocument@110 Method

The procedure ReopenPurchaseDocument is available in codeunit 130512.

Syntax

ReopenPurchaseDocument@110(
    VAR PurchaseHeader@1000 : Record 38 PurchaseHeader //Reference parameter of type Record
);

Parameters

PurchaseHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Reopen, Purchase, Document.

For a clarification about how this function works, refer to the code listed below.

      ReleasePurchDoc.PerformManualReopen(PurchaseHeader);

Example

The below example is extracted from the test automation codeunit 134101 to show one way of using this function.

      // [FEATURE] [Purchases] [Prepayment %]
      // [SCENARIO 301615] Prepayment Line Amount Error while updating the Prepayment% on the Partial Posted Purchase Invoice.

      // [GIVEN] Update Quantity to Receive after Posting Prepayment Invoice and Post Purchase Order.
      Initialize;

      CreatePurchaseOrderWithPrepaymentVAT(PurchaseHeader,PurchaseLine,LibraryRandom.RandDec(50,2));
      PurchasePostPrepayments.Invoice(PurchaseHeader);
      ModifyPurchaseQtyToReceive(PurchaseLine,PurchaseHeader."Document Type",PurchaseHeader."No.",PurchaseLine."Line No.");
      UpdateVendorInvoiceNo(PurchaseHeader);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

      // [WHEN] Reopen partially posted Purchase Order and Modify Prepayment %.
      LibraryPurchase.ReopenPurchaseDocument(PurchaseHeader);
      ASSERTERROR PurchaseHeader.VALIDATE("Prepayment %",100 - PurchaseHeader."Prepayment %" + LibraryRandom.RandInt(5));

      // [THEN] Error will popup after modifing Prepayment%.
      Assert.ExpectedError(PrepmtLineAmtErr);
Member of Lib.Library - Purchase


RunBatchPostPurchaseReturnOrdersReport@127 Method

The procedure RunBatchPostPurchaseReturnOrdersReport is available in codeunit 130512.

Syntax

RunBatchPostPurchaseReturnOrdersReport@127(
    VAR PurchaseHeader@1001 : Record 38 PurchaseHeader //Reference parameter of type Record
);

Parameters

PurchaseHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Run, Batch, Post, Purchase, Return, Orders, Report.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(BatchPostPurchRetOrders);
      BatchPostPurchRetOrders.SETTABLEVIEW(PurchaseHeader);
      COMMIT;  // COMMIT is required to run this report.
      BatchPostPurchRetOrders.USEREQUESTPAGE(TRUE);
      BatchPostPurchRetOrders.RUN;

Example

The below example is extracted from the test automation codeunit 137156 to show one way of using this function.

      // Setup: Create two Purchase Return Orders.
      Initialize;
      LibraryInventory.CreateItem(Item);
      LibraryInventory.CreateItem(Item2);
      Quantity := LibraryRandom.RandDec(10,2);
      CreatePurchaseReturnOrder(PurchaseHeader,Item."No.",Quantity);
      CreatePurchaseReturnOrder(PurchaseHeader2,Item2."No.",Quantity);

      // Exercise.
      LibraryVariableStorage.Enqueue(ReturnOrderPostedMsg);  // Enqueue for MessageHandler.
      PurchaseHeader.SETFILTER("No.",'%1|%2',PurchaseHeader."No.",PurchaseHeader2."No.");
      LibraryPurchase.RunBatchPostPurchaseReturnOrdersReport(PurchaseHeader);

      // Verify.
      VerifyPurchaseCreditMemoLine(Item."No.",Quantity);
      VerifyPurchaseCreditMemoLine(Item2."No.",Quantity);
Member of Lib.Library - Purchase


RunDeleteInvoicedPurchaseReturnOrdersReport@107 Method

The procedure RunDeleteInvoicedPurchaseReturnOrdersReport is available in codeunit 130512.

Syntax

RunDeleteInvoicedPurchaseReturnOrdersReport@107(
    VAR PurchaseHeader@1001 : Record 38 PurchaseHeader //Reference parameter of type Record
);

Parameters

PurchaseHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Run, Delete, Invoiced, Purchase, Return, Orders, Report.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(DeleteInvdPurchRetOrders);
      DeleteInvdPurchRetOrders.SETTABLEVIEW(PurchaseHeader);
      DeleteInvdPurchRetOrders.USEREQUESTPAGE(FALSE);
      DeleteInvdPurchRetOrders.RUN;

Example

The below example is extracted from the test automation codeunit 137156 to show one way of using this function.

      // Setup: Create and post Purchase Order. Create and Post Purchase Credit Memo with Get Return Shipment Line.
      Initialize;
      LibraryInventory.CreateItem(Item);
      LibraryPurchase.CreateVendor(Vendor);
      PostedDocumentNo :=
        CreateAndPostPurchaseDocument(
          PurchaseHeader,PurchaseHeader."Document Type"::"Return Order",PurchaseLine.Type::Item,Vendor."No.",Item."No.",
          LibraryRandom.RandDec(50,2),FALSE);
      CreateAndPostPurchaseCreditMemoAfterGetReturnShipmentLine(PurchaseHeader2,PostedDocumentNo,Vendor."No.",0);

      // Exercise.
      PurchaseHeader.SETRANGE("No.",PurchaseHeader."No.");
      LibraryPurchase.RunDeleteInvoicedPurchaseReturnOrdersReport(PurchaseHeader);

      // Verify.
      FilterPurchaseHeader(PurchaseHeader,PurchaseHeader."No.");
      Assert.IsTrue(PurchaseHeader.ISEMPTY,RecordMustBeDeletedTxt);
Member of Lib.Library - Purchase


RunMoveNegativePurchaseLinesReport@102 Method

The procedure RunMoveNegativePurchaseLinesReport is available in codeunit 130512.

Syntax

RunMoveNegativePurchaseLinesReport@102(
    VAR PurchaseHeader@1004 : Record 38 PurchaseHeader, //Reference parameter of type Record
    FromDocType@1007 : Option FromDocType, //Input parameter of type Option
    ToDocType@1006 : Option ToDocType, //Input parameter of type Option
    ToDocType2@1008 : Option ToDocType2 //Input parameter of type Option
);

Parameters

PurchaseHeader
Reference parameter of type Record
FromDocType
Input parameter of type Option
ToDocType
Input parameter of type Option
ToDocType2
Input parameter of type Option

Remarks

The relevant search keywords are: Run, Move, Negative, Purchase, Lines, Report.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(MoveNegativePurchaseLines);
      MoveNegativePurchaseLines.SetPurchHeader(PurchaseHeader);
      MoveNegativePurchaseLines.InitializeRequest(FromDocType,ToDocType,ToDocType2);
      MoveNegativePurchaseLines.USEREQUESTPAGE(FALSE);
      MoveNegativePurchaseLines.RUN;

Example

The below example is extracted from the test automation codeunit 137156 to show one way of using this function.

      // Setup: Copy Document after create and post Purchase Order. Create negative Purchase Line in the Purchase Order.
      Initialize;
      Quantity := LibraryRandom.RandDec(50,2);
      LibraryPurchase.CreateVendor(Vendor);
      LibraryInventory.CreateItem(Item);
      CopyDocumentAfterCreateAndPostPurchaseOrder(PurchaseHeader,Vendor."No.",Item."No.",Quantity);
      CreateNegativePurchaseLine(PurchaseHeader,Item."No.",-Quantity);

      // Exercise.
      PurchaseHeader.SETRANGE("No.",PurchaseHeader."No.");
      LibraryPurchase.RunMoveNegativePurchaseLinesReport(
        PurchaseHeader,FromDocumentType::Order,ToDocumentType::"Return Order",ToDocumentType2::Order);

      // Verify.
      VerifyPurchaseReturnOrder(PurchaseHeader."Buy-from Vendor No.",Vendor.Name,Item."No.",Quantity);
Member of Lib.Library - Purchase


SelectPmtJnlBatch@35 Method

The procedure SelectPmtJnlBatch is available in codeunit 130512.

Syntax

SelectPmtJnlBatch@35(
    VAR GenJournalBatch@1000 : Record 232 GenJournalBatch //Reference parameter of type Record
);

Parameters

GenJournalBatch
Reference parameter of type Record

Remarks

The relevant search keywords are: Select, Payment, Journal, Batch.

For a clarification about how this function works, refer to the code listed below.

      LibraryJournals.SelectGenJournalBatch(GenJournalBatch,SelectPmtJnlTemplate);

Example

The below example is extracted from the test automation codeunit 134160 to show one way of using this function.

      Initialize;

      // Pre-Setup
      LibraryPurchase.CreateVendor(Vendor);
      LibraryERM.SelectGenJnlBatch(GenJnlBatch);
      LibraryERM.CreateGeneralJnlLine(GenJnlLine,
        GenJnlBatch."Journal Template Name",GenJnlBatch.Name,GenJnlLine."Document Type"::Invoice,
        GenJnlLine."Account Type"::Vendor,Vendor."No.",-1 * LibraryRandom.RandDec(1000,2));

      // Setup
      CreditorNo := AddCreditorNoOnGenJnlLine(GenJnlLine);
      PaymentReference := AddPaymentReferenceOnGenJnlLine(GenJnlLine);
      LibraryERM.PostGeneralJnlLine(GenJnlLine);

      // Exercise
      LibraryPurchase.SelectPmtJnlBatch(PmtGenJnlBatch);
      LibraryERM.CreatePaymentMethod(PaymentMethod);
      Vendor."Payment Method Code" := PaymentMethod.Code;
      Vendor.MODIFY(TRUE);
      Vendor.SETRANGE("No.",Vendor."No.");
      SuggestVendorPayments(Vendor,PmtGenJnlBatch);

      // Verify
      FindGenJnlLine(PmtGenJnlLine,PmtGenJnlBatch,PmtGenJnlLine."Account Type"::Vendor,Vendor."No.");
      PmtGenJnlLine.TESTFIELD("Payment Method Code",GetPmtMethodCodeFromVendorLedgerEntry(Vendor."No."));
      PmtGenJnlLine.TESTFIELD("Creditor No.",CreditorNo);
      PmtGenJnlLine.TESTFIELD("Payment Reference",PaymentReference);
Member of Lib.Library - Purchase


SelectPmtJnlTemplate@37 Method

The procedure SelectPmtJnlTemplate is available in codeunit 130512.

Syntax

SelectPmtJnlTemplate@37(
      //param element not supplied
);

Return Value

Code[10]

Remarks

The relevant search keywords are: Select, Payment, Journal, Template.

For a clarification about how this function works, refer to the code listed below.

      EXIT(LibraryJournals.SelectGenJournalTemplate(GenJournalTemplate.Type::Payments,PAGE::"Payment Journal"));

Example

There are no examples available.
Member of Lib.Library - Purchase


SetAllowDocumentDeletionBeforeDate@59 Method

The procedure SetAllowDocumentDeletionBeforeDate is available in codeunit 130512.

Syntax

SetAllowDocumentDeletionBeforeDate@59(
    Date@1000 : Date Date //Input parameter of type Date
);

Parameters

Date
Input parameter of type Date

Remarks

The relevant search keywords are: Set, Allow, Document, Deletion, Before, Date.

For a clarification about how this function works, refer to the code listed below.

      PurchasesPayablesSetup.GET;
      PurchasesPayablesSetup.VALIDATE("Allow Document Deletion Before",Date);
      PurchasesPayablesSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134417 to show one way of using this function.

      // [FEATURE] [Allow Document Deletion] [Sales]
      // [SCENARIO 169264] Delete posted Sales Invoice. "Allow Document Deletion Before" is not set up.
      Initialize;
      // [GIVEN] "Sales Setup"."Allow Document Deletion Before" = 0D.
      LibrarySales.SetAllowDocumentDeletionBeforeDate(0D);
      // [GIVEN] Posted Sales Invoice.
      MockPostedSalesInvoice(SalesInvoiceHeader,WORKDATE);
      COMMIT;
      // [WHEN] Delete posted Sales Invoice.
      ASSERTERROR SalesInvoiceHeader.DELETE(TRUE);
      // [THEN] Error "Allow Document Deletion Before must have a value in Sales & Receivables Setup"
      Assert.ExpectedError(
        STRSUBSTNO(TestFieldErr,SalesReceivablesSetup.FIELDCAPTION("Allow Document Deletion Before"),
          SalesReceivablesSetup.TABLECAPTION));
      Assert.ExpectedErrorCode(TestFieldCodeErr);
Member of Lib.Library - Purchase


SetAllowVATDifference@39 Method

The procedure SetAllowVATDifference is available in codeunit 130512.

Syntax

SetAllowVATDifference@39(
    AllowVATDifference@1000 : Boolean AllowVATDifference //Input parameter of type Boolean
);

Parameters

AllowVATDifference
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, Allow, VAT, Difference.

For a clarification about how this function works, refer to the code listed below.

      PurchasesPayablesSetup.GET;
      PurchasesPayablesSetup.VALIDATE("Allow VAT Difference",AllowVATDifference);
      PurchasesPayablesSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134028 to show one way of using this function.

      Result := LibraryRandom.RandDec(2,2);  // Use any Random decimal value between 0.01 and 1.99, value is not important.
      LibraryERM.SetMaxVATDifferenceAllowed(Result);
      IF SalesAndReceivables THEN
        LibrarySales.SetAllowVATDifference(TRUE)
      ELSE
        LibraryPurchase.SetAllowVATDifference(TRUE);
Member of Lib.Library - Purchase


SetArchiveQuotesAndOrders@5 Method

The procedure SetArchiveQuotesAndOrders is available in codeunit 130512.

Syntax

SetArchiveQuotesAndOrders@5(
    ArchiveQuotesandOrders@1001 : Boolean ArchiveQuotesandOrders //Input parameter of type Boolean
);

Parameters

ArchiveQuotesandOrders
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, Archive, Quotes, Orders.

For a clarification about how this function works, refer to the code listed below.

      PurchasesPayablesSetup.GET;
      PurchasesPayablesSetup.VALIDATE("Archive Quotes and Orders",ArchiveQuotesandOrders);
      PurchasesPayablesSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134327 to show one way of using this function.

      // Check Purchase Line Archive for Archive Version after Posting Partial Purchase Order.

      // Setup: Create and Post Purchase Order with Archive Quotes and Orders TRUE on Purchase and payable Setup.
      Initialize;
      LibraryPurchase.SetArchiveQuotesAndOrders(TRUE);
      CreatePurchaseDocument(PurchaseHeader,PurchaseLine,CreateVendor,PurchaseHeader."Document Type"::Order);
      ModifyPurchaseLineQtyToReceive(PurchaseLine,PurchaseLine."Qty. to Receive" / 2);

      // Exercise: Post Purchase Order with Receive.
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,FALSE);

      // Verify: Verify No. of Archived Versions fields on Purchase Header and Purchase Line Archive.
      // Take 1 as static becuase it will generate 1 Posting of Purchase Order on first time.
      PurchaseHeader.GET(PurchaseHeader."Document Type",PurchaseHeader."No.");
      PurchaseHeader.CALCFIELDS("No. of Archived Versions");
      PurchaseHeader.TESTFIELD("No. of Archived Versions",1);

      PurchaseLineArchive.SETRANGE("Document Type",PurchaseHeader."Document Type");
      PurchaseLineArchive.SETRANGE("Document No.",PurchaseHeader."No.");
      PurchaseLineArchive.FINDFIRST;
      PurchaseLineArchive.TESTFIELD("Version No.",PurchaseHeader."No. of Archived Versions");
      PurchaseLineArchive.TESTFIELD("Qty. to Receive",PurchaseLine."Qty. to Receive");
      PurchaseLineArchive.TESTFIELD(Quantity,PurchaseLine.Quantity);
      PurchaseLineArchive.TESTFIELD("Qty. to Invoice",PurchaseLine."Qty. to Invoice");
Member of Lib.Library - Purchase


SetCalcInvDiscount@33 Method

The procedure SetCalcInvDiscount is available in codeunit 130512.

Syntax

SetCalcInvDiscount@33(
    CalcInvDiscount@1000 : Boolean CalcInvDiscount //Input parameter of type Boolean
);

Parameters

CalcInvDiscount
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, Calc, Invoice, Discount.

For a clarification about how this function works, refer to the code listed below.

      PurchasesPayablesSetup.GET;
      PurchasesPayablesSetup.VALIDATE("Calc. Inv. Discount",CalcInvDiscount);
      PurchasesPayablesSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134039 to show one way of using this function.

      // Check Inv. Discount Amount on Purchase CreditMemo Statistics after Posting Purchase Return Order.

      // Setup: Create Purchase Return Order and Credit Memo.
      Initialize;
      LibraryPurchase.SetCalcInvDiscount(TRUE);
      VendorNo := CreateVendAndInvoiceDiscount;
      InvoiceDiscountAmount := CreateAndPostPurchaseReturnOrder(PurchaseHeader."Document Type"::"Return Order",VendorNo);
      LibraryVariableStorage.Enqueue(InvoiceDiscountAmount);

      // Exercise: Create and Get Shiment Lines for Purchase Credit Memo.
      CreatePurchaseCreditMemoAndGetShipmentLines(PurchaseHeader,VendorNo);

      // Verify: Verify Inv. Discount Amount on Purchase Creditmemo Statistics using Purchase Statistics Page handler.
      PurchaseHeader.CalcInvDiscForHeader;
      PAGE.RUNMODAL(PAGE::"Purchase Statistics",PurchaseHeader);
Member of Lib.Library - Purchase


SetCorrDocNoPurchase@20 Method

The procedure SetCorrDocNoPurchase is available in codeunit 130512.

Syntax

SetCorrDocNoPurchase@20(
    VAR PurchHeader@1000 : Record 38 PurchHeader //Reference parameter of type Record
);

Parameters

PurchHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Set, Corr, Document, No, Purchase.

For a clarification about how this function works, refer to the code listed below.

      WITH PurchHeader DO
        IF "Document Type" IN ["Document Type"::"Credit Memo","Document Type"::"Return Order"] THEN;

Example

There are no examples available.
Member of Lib.Library - Purchase


SetExactCostReversingMandatory@54 Method

The procedure SetExactCostReversingMandatory is available in codeunit 130512.

Syntax

SetExactCostReversingMandatory@54(
    ExactCostReversingMandatory@1000 : Boolean ExactCostReversingMandatory //Input parameter of type Boolean
);

Parameters

ExactCostReversingMandatory
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, Exact, Cost, Reversing, Mandatory.

For a clarification about how this function works, refer to the code listed below.

      PurchasesPayablesSetup.GET;
      PurchasesPayablesSetup.VALIDATE("Exact Cost Reversing Mandatory",ExactCostReversingMandatory);
      PurchasesPayablesSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137019 to show one way of using this function.

      // [FEATURE] [Item Tracking] [Exact Cost Reversing Mandatory]
      // [SCENARIO 210894] Negative Line of Posted Sales Invoice with Lot Tracking copies to Credit Memo when "Exact Cost Reversing Mandatory" is set

      Initialize;

      // [GIVEN] Item with Lot Tracking
      ItemNo := CreateTrackedItem;

      // [GIVEN] Posted Sales Invoice with Quantity = - 1 and "Lot No."
      PostSalesInvWithNegativeLineAndLotNo(InvNo,SalesLine,ItemNo);

      // [GIVEN] "Exact Cost Reversing Mandatory" is set
      LibrarySales.SetExactCostReversingMandatory(TRUE);

      // [GIVEN] Sales Credit Memo
      LibrarySales.CreateSalesHeader(
        SalesHeaderCorrection,SalesHeaderCorrection."Document Type"::"Credit Memo",SalesLine."Sell-to Customer No.");

      // [WHEN]  Copy Posted Sales Invoice to Sales Credit Memo
      LibrarySales.CopySalesDocument(SalesHeaderCorrection,DocType::"Posted Invoice",InvNo,TRUE,FALSE);

      // [THEN] Credit Memo created with Quantity = -1 and "Lot No."
      VerifySalesLineWithTrackedQty(SalesHeaderCorrection,SalesLine.Quantity);
Member of Lib.Library - Purchase


SetExtDocNo@100 Method

The procedure SetExtDocNo is available in codeunit 130512.

Syntax

SetExtDocNo@100(
    ExtDocNoMandatory@1001 : Boolean ExtDocNoMandatory //Input parameter of type Boolean
);

Parameters

ExtDocNoMandatory
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, External, Document, No.

For a clarification about how this function works, refer to the code listed below.

      PurchasesPayablesSetup.GET;
      PurchasesPayablesSetup.VALIDATE("Ext. Doc. No. Mandatory",ExtDocNoMandatory);
      PurchasesPayablesSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134103 to show one way of using this function.

      // [FEATURE] [Sales] [Release Document]
      // [SCENARIO 371945] Status of Sales Order should remain "Pending Prepayment" after document posting error when prepayment is posted and "External Document No." is empty.
      Initialize;

      // [GIVEN] Sales & Receivable Setup has option "Ext. Doc. No. Mandatory" set to TRUE.
      LibrarySales.SetExtDocNo(TRUE);

      LibrarySales.CreatePrepaymentVATSetup(GLAccount,VATPostingSetup."VAT Calculation Type"::"Normal VAT");
      CreateSalesOrderWithAccount(SalesHeader,SalesLine,GLAccount,LibraryRandom.RandIntInRange(10,90));

      // [GIVEN] Posted Prepayment Invoice. Sales Header has Status "Pending Prepayment".
      LibrarySales.PostSalesPrepaymentInvoice(SalesHeader);

      // [GIVEN] Cleared "External Document No." in Sales Header.
      SalesHeader.VALIDATE("External Document No.",'');
      SalesHeader.MODIFY(TRUE);

      // [WHEN] Post Sales Order (Ship and Invoice). Posting error raises.
      ASSERTERROR LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      // [THEN] Sales Header has Status "Pending Prepayment".
      SalesHeader.TESTFIELD(Status,SalesHeader.Status::"Pending Prepayment");
Member of Lib.Library - Purchase


SetInvoiceRounding@36 Method

The procedure SetInvoiceRounding is available in codeunit 130512.

Syntax

SetInvoiceRounding@36(
    InvoiceRounding@1000 : Boolean InvoiceRounding //Input parameter of type Boolean
);

Parameters

InvoiceRounding
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, Invoice, Rounding.

For a clarification about how this function works, refer to the code listed below.

      PurchasesPayablesSetup.GET;
      PurchasesPayablesSetup.VALIDATE("Invoice Rounding",InvoiceRounding);
      PurchasesPayablesSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134007 to show one way of using this function.

      LibrarySetupStorage.Restore;
      LibraryVariableStorage.Clear;
      IF IsInitialized THEN
        EXIT;

      LibraryPurchase.SetInvoiceRounding(FALSE);
      LibraryERMCountryData.CreateVATData;
      LibraryERMCountryData.CreateGeneralPostingSetupData;
      LibraryERMCountryData.UpdateGeneralPostingSetup;
      LibraryERMCountryData.UpdateAccountInVendorPostingGroups;
      LibraryERMCountryData.UpdatePurchasesPayablesSetup;
      LibraryERMCountryData.UpdateGeneralLedgerSetup;
      LibraryERMCountryData.RemoveBlankGenJournalTemplate;
      LibraryERMCountryData.UpdateLocalData;
      IsInitialized := TRUE;
      COMMIT;

      LibrarySetupStorage.Save(DATABASE::"General Ledger Setup");
      LibrarySetupStorage.Save(DATABASE::"Purchases & Payables Setup");
      LibrarySetupStorage.Save(DATABASE::"Source Code Setup");
Member of Lib.Library - Purchase


SetReturnOrderNoSeriesInSetup@73 Method

The procedure SetReturnOrderNoSeriesInSetup is available in codeunit 130512.

Syntax

SetReturnOrderNoSeriesInSetup@73(
      //param element not supplied
);

Remarks

The relevant search keywords are: Set, Return, Order, No, Series, In, Setup.

For a clarification about how this function works, refer to the code listed below.

      WITH PurchasesPayablesSetup DO BEGIN
        GET;
        VALIDATE("Return Order Nos.",LibraryERM.CreateNoSeriesCode);
        VALIDATE("Posted Return Shpt. Nos.",LibraryERM.CreateNoSeriesCode);
        MODIFY(TRUE);
      END;

Example

There are no examples available.
Member of Lib.Library - Purchase


SetSubConReceiptPostingDate@1500005 Method

The procedure SetSubConReceiptPostingDate is available in codeunit 130512.

Syntax

SetSubConReceiptPostingDate@1500005(
    PostingDate@1500000 : Date PostingDate //Input parameter of type Date
);

Parameters

PostingDate
Input parameter of type Date

Remarks

The relevant search keywords are: Set, Sub, Con, Receipt, Posting, Date.

For a clarification about how this function works, refer to the code listed below.

      SubConReceiptDate := PostingDate;

Example

The below example is extracted from the test automation codeunit 137077 to show one way of using this function.

      PurchaseLine.VALIDATE(SubConReceive,TRUE);
      PurchaseLine.MODIFY(TRUE);
      COMMIT;
      PurchaseHeader.GET(PurchaseLine."Document Type",PurchaseLine."Document No.");
      LibraryPurchase.SetSubConReceiptPostingDate(CALCDATE('<2D>',WORKDATE));
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);
Member of Lib.Library - Purchase


UndoPurchaseReceiptLine@9 Method

The procedure UndoPurchaseReceiptLine is available in codeunit 130512.

Syntax

UndoPurchaseReceiptLine@9(
    VAR PurchRcptLine@1000 : Record 121 PurchRcptLine //Reference parameter of type Record
);

Parameters

PurchRcptLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Undo, Purchase, Receipt, Line.

For a clarification about how this function works, refer to the code listed below.

      CODEUNIT.RUN(CODEUNIT::"Undo Purchase Receipt Line",PurchRcptLine);

Example

The below example is extracted from the test automation codeunit 134150 to show one way of using this function.

      PurchRcptLine.SETRANGE("Document No.",DocumentNo);
      PurchRcptLine.SETRANGE("No.",No);
      PurchRcptLine.FINDFIRST;
      LibraryPurchase.UndoPurchaseReceiptLine(PurchRcptLine);
Member of Lib.Library - Purchase


UndoReturnShipmentLine@8 Method

The procedure UndoReturnShipmentLine is available in codeunit 130512.

Syntax

UndoReturnShipmentLine@8(
    VAR ReturnShipmentLine@1000 : Record 6651 ReturnShipmentLine //Reference parameter of type Record
);

Parameters

ReturnShipmentLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Undo, Return, Shipment, Line.

For a clarification about how this function works, refer to the code listed below.

      CODEUNIT.RUN(CODEUNIT::"Undo Return Shipment Line",ReturnShipmentLine);

Example

The below example is extracted from the test automation codeunit 134150 to show one way of using this function.

      WITH ReturnShipmentLine DO BEGIN
        SETRANGE("Document No.",DocumentNo);
        FINDSET;
        NEXT(LineNo - 1);
        SETRECFILTER;
      END;
      LibraryPurchase.UndoReturnShipmentLine(ReturnShipmentLine);
Member of Lib.Library - Purchase


Library - Rapid Start Class

Lib.Library - Rapid Start

COD131903 applies to RES,RIM,W1,All.
Contains all utility functions related to Rapid Implementation Methodology.

Methods

Name | Description
ApplyPackage@55 | The procedure ApplyPackage is available in codeunit 131903.
CreateConfigLine@11 | The procedure CreateConfigLine is available in codeunit 131903.
CreateConfigTemplateHeader@2 | The procedure CreateConfigTemplateHeader is available in codeunit 131903.
CreateConfigTemplateLine@7 | The procedure CreateConfigTemplateLine is available in codeunit 131903.
CreatePackage@10 | The procedure CreatePackage is available in codeunit 131903.
CreatePackageData@6 | The procedure CreatePackageData is available in codeunit 131903.
CreatePackageDataForField@16 | The procedure CreatePackageDataForField is available in codeunit 131903.
CreatePackageTable@4 | The procedure CreatePackageTable is available in codeunit 131903.
CreateQuestion@5 | The procedure CreateQuestion is available in codeunit 131903.
CreateQuestionArea@1 | The procedure CreateQuestionArea is available in codeunit 131903.
CreateQuestionnaire@3 | The procedure CreateQuestionnaire is available in codeunit 131903.
SetCreateMissingCodesForField@13 | The procedure SetCreateMissingCodesForField is available in codeunit 131903.
SetIncludeFields@8 | The procedure SetIncludeFields is available in codeunit 131903.
SetIncludeOneField@28 | The procedure SetIncludeOneField is available in codeunit 131903.
SetProcessingOrderForField@12 | The procedure SetProcessingOrderForField is available in codeunit 131903.
SetProcessingOrderForRecord@34 | The procedure SetProcessingOrderForRecord is available in codeunit 131903.
SetValidateOneField@9 | The procedure SetValidateOneField is available in codeunit 131903.
ValidatePackage@57 | The procedure ValidatePackage is available in codeunit 131903.

See Also

Lib


ApplyPackage@55 Method

The procedure ApplyPackage is available in codeunit 131903.

Syntax

ApplyPackage@55(
    ConfigPackage@1001 : Record 8623 ConfigPackage, //Input parameter of type Record
    SetupProcessingOrderForTables@1003 : Boolean SetupProcessingOrderForTables //Input parameter of type Boolean
);

Parameters

ConfigPackage
Input parameter of type Record
SetupProcessingOrderForTables
Input parameter of type Boolean

Remarks

The relevant search keywords are: Apply, Package.

For a clarification about how this function works, refer to the code listed below.

      ConfigPackageMgt.SetHideDialog(TRUE);
      ConfigPackageTable.SETRANGE("Package Code",ConfigPackage.Code);
      ConfigPackageMgt.ApplyPackage(ConfigPackage,ConfigPackageTable,SetupProcessingOrderForTables);

Example

The below example is extracted from the test automation codeunit 136601 to show one way of using this function.

      Initialize;
      GenerateTemplateAndPackageForTableWithSeriesNo(ConfigPackage,ConfigTemplateCode);

      InitialCustCount := Customer.COUNT;
      LibraryRapidStart.ApplyPackage(ConfigPackage,TRUE);
      Assert.IsTrue(Customer.COUNT - InitialCustCount = 1,InvalidQtyOfCustomersAppliedErr);

      Cleanup(ConfigPackage.Code,ConfigTemplateCode);
Member of Lib.Library - Rapid Start


CreateConfigLine@11 Method

The procedure CreateConfigLine is available in codeunit 131903.

Syntax

CreateConfigLine@11(
    VAR ConfigLine@1000 : Record 8622 ConfigLine, //Reference parameter of type Record
    LineType@1001 : Option LineType, //Input parameter of type Option
    TableID@1002 : Integer TableID, //Input parameter of type Integer
    LineName@1003 : Text[50] LineName, //Input parameter of type Text
    PackageCode@1008 : Code[20] PackageCode, //Input parameter of type Code
    Dimensions@1007 : Boolean Dimensions //Input parameter of type Boolean
);

Parameters

ConfigLine
Reference parameter of type Record
LineType
Input parameter of type Option
TableID
Input parameter of type Integer
LineName
Input parameter of type Text
PackageCode
Input parameter of type Code
Dimensions
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, Config, Line.

For a clarification about how this function works, refer to the code listed below.

      NextLineNo := 0;
      ConfigLine.RESET;
      IF ConfigLine.FINDLAST THEN
        NextLineNo := ConfigLine."Line No." + 10000;

      ConfigLine.INIT;
      ConfigLine.VALIDATE("Line No.",NextLineNo);
      ConfigLine.VALIDATE("Line Type",LineType);
      IF LineType = LineType::Table THEN
        ConfigLine.VALIDATE("Table ID",TableID)
      ELSE
        ConfigLine.VALIDATE(Name,LineName);
      ConfigLine.INSERT(TRUE);

      ConfigMgt.AssignParentLineNos;

      IF PackageCode <> '' THEN BEGIN
        ConfigLine.SETRANGE("Line No.",ConfigLine."Line No.");
        ConfigPackageManagement.AssignPackage(ConfigLine,PackageCode);
        ConfigLine.SETRANGE("Line No.");
      END;

      IF Dimensions THEN BEGIN
        ConfigLine.GET(NextLineNo);
        ConfigLine.VALIDATE("Dimensions as Columns",TRUE);
        ConfigLine.MODIFY(TRUE);
      END;

Example

The below example is extracted from the test automation codeunit 136603 to show one way of using this function.

      TableID := FindTableID;
      LibraryRapidStart.CreateConfigLine(ConfigLine,ConfigLine."Line Type"::Area,0,'main area',PackageCode,FALSE);
      LibraryRapidStart.CreateConfigLine(ConfigLine,ConfigLine."Line Type"::Group,0,'',PackageCode,FALSE);
      LibraryRapidStart.CreateConfigLine(ConfigLine,ConfigLine."Line Type"::Table,TableID,'',PackageCode,FALSE);
      TableID := FindNextTableID(TableID);
      LibraryRapidStart.CreateConfigLine(ConfigLine,ConfigLine."Line Type"::Group,0,'',PackageCode,FALSE);
      LibraryRapidStart.CreateConfigLine(ConfigLine,ConfigLine."Line Type"::Table,TableID,'',PackageCode,FALSE);
      TableID := FindNextTableID(TableID);
      LibraryRapidStart.CreateConfigLine(ConfigLine,ConfigLine."Line Type"::Group,0,'',PackageCode,FALSE);
      LibraryRapidStart.CreateConfigLine(ConfigLine,ConfigLine."Line Type"::Table,TableID,'',PackageCode,FALSE);

      LibraryRapidStart.CreateConfigLine(ConfigLine,ConfigLine."Line Type"::Area,0,'additional area',PackageCode,FALSE);
      LibraryRapidStart.CreateConfigLine(ConfigLine,ConfigLine."Line Type"::Table,DATABASE::Customer,'',PackageCode,TRUE);
Member of Lib.Library - Rapid Start


CreateConfigTemplateHeader@2 Method

The procedure CreateConfigTemplateHeader is available in codeunit 131903.

Syntax

CreateConfigTemplateHeader@2(
    VAR ConfigTemplateHeader@1000 : Record 8618 ConfigTemplateHeader //Reference parameter of type Record
);

Parameters

ConfigTemplateHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Config, Template, Header.

For a clarification about how this function works, refer to the code listed below.

      ConfigTemplateHeader.INIT;
      ConfigTemplateHeader.VALIDATE(
        Code,
        LibraryUtility.GenerateRandomCode(ConfigTemplateHeader.FIELDNO(Code),DATABASE::"Config. Template Header"));
      // Validating Code as Description because value is not important.
      ConfigTemplateHeader.VALIDATE(Description,ConfigTemplateHeader.Code);
      ConfigTemplateHeader.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136601 to show one way of using this function.

      // Test if a Master Record - Vendor can be created using Standard Master Data Templates.

      // 1. Setup: Create new Data Template Header, Data Template Line for Vendor Posting Group, Currency Code,
      // Gen. Bus. Posting Group. Create new Instance.
      Initialize;
      LibraryRapidStart.CreateConfigTemplateHeader(ConfigTemplateHeader);
      InputTableInConfigTemplateHeader(ConfigTemplateHeader,DATABASE::Vendor);

      VendorPostingGroup.GET(LibraryPurchase.FindVendorPostingGroup);
      CreateConfigTemplateLineForField(
        ConfigTemplateHeader.Code,Vendor.FIELDNO("Vendor Posting Group"),
        Vendor.FIELDNAME("Vendor Posting Group"),VendorPostingGroup.Code);

      LibraryERM.FindCurrency(Currency);
      CreateConfigTemplateLineForField(
        ConfigTemplateHeader.Code,Vendor.FIELDNO("Currency Code"),Vendor.FIELDNAME("Currency Code"),Currency.Code);

      LibraryERM.FindGenBusinessPostingGroup(GenBusinessPostingGroup);
      CreateConfigTemplateLineForField(
        ConfigTemplateHeader.Code,Vendor.FIELDNO("Gen. Bus. Posting Group"),
        Vendor.FIELDNAME("Gen. Bus. Posting Group"),GenBusinessPostingGroup.Code);

      CreateNewInstance(ConfigTemplateHeader);

      // 2. Exercise: Apply Template to a new Vendor.
      LibraryPurchase.CreateVendor(Vendor);
      ApplyTemplateToVendor(Vendor,ConfigTemplateHeader);

      // 3. Verify: Check that the Master Data Template has been applied to the Vendor.
      Vendor.GET(Vendor."No.");
      Vendor.TESTFIELD("Vendor Posting Group",VendorPostingGroup.Code);
      Vendor.TESTFIELD("Currency Code",Currency.Code);
      Vendor.TESTFIELD("Gen. Bus. Posting Group",GenBusinessPostingGroup.Code);
Member of Lib.Library - Rapid Start


CreateConfigTemplateLine@7 Method

The procedure CreateConfigTemplateLine is available in codeunit 131903.

Syntax

CreateConfigTemplateLine@7(
    VAR ConfigTemplateLine@1000 : Record 8619 ConfigTemplateLine, //Reference parameter of type Record
    ConfigTemplateCode@1001 : Code[10] ConfigTemplateCode //Input parameter of type Code
);

Parameters

ConfigTemplateLine
Reference parameter of type Record
ConfigTemplateCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Config, Template, Line.

For a clarification about how this function works, refer to the code listed below.

      ConfigTemplateLine.INIT;
      ConfigTemplateLine.VALIDATE("Data Template Code",ConfigTemplateCode);
      RecRef.GETTABLE(ConfigTemplateLine);
      ConfigTemplateLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,ConfigTemplateLine.FIELDNO("Line No.")));
      ConfigTemplateLine.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136601 to show one way of using this function.

      // Test Creation and Maintenance of templates - insert same Template on Template Line.

      // 1. Setup: Create new Data Template Header, Data Template Line.
      Initialize;
      LibraryRapidStart.CreateConfigTemplateHeader(ConfigTemplateHeader);
      InputTableInConfigTemplateHeader(ConfigTemplateHeader,DATABASE::Item);
      LibraryRapidStart.CreateConfigTemplateLine(ConfigTemplateLine,ConfigTemplateHeader.Code);

      // 2. Exercise: Change Type on Data Template Line to Template and try to Apply Template on Line.
      ASSERTERROR InputTemplateConfigTemplateLine(ConfigTemplateLine,ConfigTemplateHeader.Code);

      // 3. Verify: Check that the application generates an error as "A template cannot relate to itself.".
      Assert.AreEqual(STRSUBSTNO(TemplateRelateToItselfError),GETLASTERRORTEXT,UnknownError);
Member of Lib.Library - Rapid Start


CreatePackage@10 Method

The procedure CreatePackage is available in codeunit 131903.

Syntax

CreatePackage@10(
    VAR ConfigPackage@1000 : Record 8623 ConfigPackage //Reference parameter of type Record
);

Parameters

ConfigPackage
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Package.

For a clarification about how this function works, refer to the code listed below.

      RecRef.OPEN(DATABASE::"Config. Package");
      ConfigPackage.INIT;
      ConfigPackage.VALIDATE(
        Code,
        LibraryUtility.GenerateRandomCode(ConfigPackage.FIELDNO(Code),DATABASE::"Config. Package"));
      ConfigPackage.VALIDATE("Package Name",'Package ' + FORMAT(ConfigPackage.Code));
      ConfigPackage.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136600 to show one way of using this function.

      // Creating question
      SetupQuestionnaireTestScenario(ConfigQuestionnaire,ConfigQuestionArea,DATABASE::Currency);

      // Initializing answers list
      LibraryRapidStart.CreatePackage(ConfigPackage);
      LibraryRapidStart.CreatePackageTable(ConfigPackageTable,ConfigPackage.Code,DATABASE::"G/L Account");

      LibraryERM.FindGLAccount(GLAccount);
      LibraryRapidStart.CreatePackageDataForField(
        ConfigPackage,
        ConfigPackageTable,
        DATABASE::"G/L Account",
        GLAccount.FIELDNO("No."),
        GLAccount."No.",
        1);

      // Positioning on a new question line
      ConfigQuestion.SETRANGE("Questionnaire Code",ConfigQuestionnaire.Code);
      ConfigQuestion.SETRANGE("Question Area Code",ConfigQuestionArea.Code);
      ConfigQuestion.SETRANGE("Table ID",DATABASE::Currency);
      ConfigQuestion.SETRANGE("Field ID",Currency.FIELDNO("Unrealized Gains Acc."));
      ConfigQuestion.FINDFIRST;
Member of Lib.Library - Rapid Start


CreatePackageData@6 Method

The procedure CreatePackageData is available in codeunit 131903.

Syntax

CreatePackageData@6(
    PackageCode@1006 : Code[20] PackageCode, //Input parameter of type Code
    TableID@1001 : Integer TableID, //Input parameter of type Integer
    RecNo@1005 : Integer RecNo, //Input parameter of type Integer
    FieldID@1002 : Integer FieldID, //Input parameter of type Integer
    Value@1003 : Text[250] Value //Input parameter of type Text
);

Parameters

PackageCode
Input parameter of type Code
TableID
Input parameter of type Integer
RecNo
Input parameter of type Integer
FieldID
Input parameter of type Integer
Value
Input parameter of type Text

Remarks

The relevant search keywords are: Create, Package, Data.

For a clarification about how this function works, refer to the code listed below.

      ConfigPackageRecord.INIT;
      ConfigPackageRecord.VALIDATE("Package Code",PackageCode);
      ConfigPackageRecord.VALIDATE("Table ID",TableID);
      ConfigPackageRecord.VALIDATE("No.",RecNo);
      IF ConfigPackageRecord.INSERT THEN;

      ConfigPackageData.INIT;
      ConfigPackageData.VALIDATE("Package Code",PackageCode);
      ConfigPackageData.VALIDATE("Table ID",TableID);
      ConfigPackageData.VALIDATE("No.",RecNo);
      ConfigPackageData.VALIDATE("Field ID",FieldID);
      ConfigPackageData.VALIDATE(Value,Value);
      ConfigPackageData.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136604 to show one way of using this function.

      LibraryERM.FindGLAccount(GLAccount);
      PrepareGenJnlLinePackageData(
        PackageCode,RecordNo,GenJnlTemplate,GenJnlBatch,LineNo,PostingDate,DocumentNo,GLAccount."No.",Amount);
      LibraryRapidStart.CreatePackageData(
        PackageCode,DATABASE::"Gen. Journal Line",RecordNo,GenJnlLine.FIELDNO("Dimension Set ID"),FORMAT(DimSetID));
Member of Lib.Library - Rapid Start


CreatePackageDataForField@16 Method

The procedure CreatePackageDataForField is available in codeunit 131903.

Syntax

CreatePackageDataForField@16(
    VAR ConfigPackage@1001 : Record 8623 ConfigPackage, //Reference parameter of type Record
    VAR ConfigPackageTable@1000 : Record 8613 ConfigPackageTable, //Reference parameter of type Record
    TableID@1005 : Integer TableID, //Input parameter of type Integer
    FieldID@1009 : Integer FieldID, //Input parameter of type Integer
    Value@1008 : Code[250] Value, //Input parameter of type Code
    RecNo@1002 : Integer RecNo //Input parameter of type Integer
);

Parameters

ConfigPackage
Reference parameter of type Record
ConfigPackageTable
Reference parameter of type Record
TableID
Input parameter of type Integer
FieldID
Input parameter of type Integer
Value
Input parameter of type Code
RecNo
Input parameter of type Integer

Remarks

The relevant search keywords are: Create, Package, Data, For, Field.

For a clarification about how this function works, refer to the code listed below.

      IF ConfigPackage.Code = '' THEN
        CreatePackage(ConfigPackage);

      IF ConfigPackageTable."Table ID" = 0 THEN
        CreatePackageTable(ConfigPackageTable,ConfigPackage.Code,TableID);

      CreatePackageData(ConfigPackage.Code,TableID,RecNo,FieldID,Value);

Example

The below example is extracted from the test automation codeunit 136600 to show one way of using this function.

      // Creating question
      SetupQuestionnaireTestScenario(ConfigQuestionnaire,ConfigQuestionArea,DATABASE::Currency);

      // Initializing answers list
      LibraryRapidStart.CreatePackage(ConfigPackage);
      LibraryRapidStart.CreatePackageTable(ConfigPackageTable,ConfigPackage.Code,DATABASE::"G/L Account");

      LibraryERM.FindGLAccount(GLAccount);
      LibraryRapidStart.CreatePackageDataForField(
        ConfigPackage,
        ConfigPackageTable,
        DATABASE::"G/L Account",
        GLAccount.FIELDNO("No."),
        GLAccount."No.",
        1);

      // Positioning on a new question line
      ConfigQuestion.SETRANGE("Questionnaire Code",ConfigQuestionnaire.Code);
      ConfigQuestion.SETRANGE("Question Area Code",ConfigQuestionArea.Code);
      ConfigQuestion.SETRANGE("Table ID",DATABASE::Currency);
      ConfigQuestion.SETRANGE("Field ID",Currency.FIELDNO("Unrealized Gains Acc."));
      ConfigQuestion.FINDFIRST;
Member of Lib.Library - Rapid Start


CreatePackageTable@4 Method

The procedure CreatePackageTable is available in codeunit 131903.

Syntax

CreatePackageTable@4(
    VAR ConfigPackageTable@1000 : Record 8613 ConfigPackageTable, //Reference parameter of type Record
    PackageCode@1002 : Code[20] PackageCode, //Input parameter of type Code
    TableID@1001 : Integer TableID //Input parameter of type Integer
);

Parameters

ConfigPackageTable
Reference parameter of type Record
PackageCode
Input parameter of type Code
TableID
Input parameter of type Integer

Remarks

The relevant search keywords are: Create, Package, Table.

For a clarification about how this function works, refer to the code listed below.

      ConfigPackageTable.INIT;
      ConfigPackageTable.VALIDATE("Package Code",PackageCode);
      ConfigPackageTable.VALIDATE("Table ID",TableID);
      ConfigPackageTable.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136600 to show one way of using this function.

      // Creating question
      SetupQuestionnaireTestScenario(ConfigQuestionnaire,ConfigQuestionArea,DATABASE::Currency);

      // Initializing answers list
      LibraryRapidStart.CreatePackage(ConfigPackage);
      LibraryRapidStart.CreatePackageTable(ConfigPackageTable,ConfigPackage.Code,DATABASE::"G/L Account");

      LibraryERM.FindGLAccount(GLAccount);
      LibraryRapidStart.CreatePackageDataForField(
        ConfigPackage,
        ConfigPackageTable,
        DATABASE::"G/L Account",
        GLAccount.FIELDNO("No."),
        GLAccount."No.",
        1);

      // Positioning on a new question line
      ConfigQuestion.SETRANGE("Questionnaire Code",ConfigQuestionnaire.Code);
      ConfigQuestion.SETRANGE("Question Area Code",ConfigQuestionArea.Code);
      ConfigQuestion.SETRANGE("Table ID",DATABASE::Currency);
      ConfigQuestion.SETRANGE("Field ID",Currency.FIELDNO("Unrealized Gains Acc."));
      ConfigQuestion.FINDFIRST;
Member of Lib.Library - Rapid Start


CreateQuestion@5 Method

The procedure CreateQuestion is available in codeunit 131903.

Syntax

CreateQuestion@5(
    VAR ConfigQuestion@1000 : Record 8612 ConfigQuestion, //Reference parameter of type Record
    ConfigQuestionArea@1001 : Record 8611 ConfigQuestionArea //Input parameter of type Record
);

Parameters

ConfigQuestion
Reference parameter of type Record
ConfigQuestionArea
Input parameter of type Record

Remarks

The relevant search keywords are: Create, Question.

For a clarification about how this function works, refer to the code listed below.

      ConfigQuestion2.SETRANGE("Questionnaire Code",ConfigQuestionArea."Questionnaire Code");
      ConfigQuestion2.SETRANGE("Question Area Code",ConfigQuestionArea.Code);
      IF ConfigQuestion2.FINDLAST THEN;  // IF condition is required because Question may not be found.

      ConfigQuestion.INIT;
      ConfigQuestion.VALIDATE("Questionnaire Code",ConfigQuestionArea."Questionnaire Code");
      ConfigQuestion.VALIDATE("Question Area Code",ConfigQuestionArea.Code);
      ConfigQuestion.VALIDATE("No.",ConfigQuestion2."No." + 1);
      ConfigQuestion.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136600 to show one way of using this function.

      // Test if answer can be applied for a field that does not exist.

      // 1. Setup: Create new Config. Questionnaire, Question Area, Question.
      Initialize;
      LibraryRapidStart.CreateQuestionnaire(ConfigQuestionnaire);
      CreateQuestionAreaWithTableID(ConfigQuestionArea,ConfigQuestionnaire.Code,FindTable);
      LibraryRapidStart.CreateQuestion(ConfigQuestion,ConfigQuestionArea);

      // 2. Exercise: Input and apply answer.
      InputAnswer(ConfigQuestion);
      ASSERTERROR QuestionnaireManagement.ApplyAnswers(ConfigQuestionnaire);

      // 3. Verify: Check that the application generates an error on applying answers for a field that does not exist.
      Assert.AreEqual(
        STRSUBSTNO(FieldDoesNotExistError,ConfigQuestionArea."Table ID"),GETLASTERRORTEXT,ErrorMessagesMustMatch);
Member of Lib.Library - Rapid Start


CreateQuestionArea@1 Method

The procedure CreateQuestionArea is available in codeunit 131903.

Syntax

CreateQuestionArea@1(
    VAR ConfigQuestionArea@1000 : Record 8611 ConfigQuestionArea, //Reference parameter of type Record
    QuestionnaireCode@1001 : Code[10] QuestionnaireCode //Input parameter of type Code
);

Parameters

ConfigQuestionArea
Reference parameter of type Record
QuestionnaireCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Question, Area.

For a clarification about how this function works, refer to the code listed below.

      ConfigQuestionArea.INIT;
      ConfigQuestionArea.VALIDATE("Questionnaire Code",QuestionnaireCode);
      ConfigQuestionArea.VALIDATE(
        Code,
        LibraryUtility.GenerateRandomCode(ConfigQuestionArea.FIELDNO(Code),DATABASE::"Config. Question Area"));
      // Validating Primary Key as Description because value is not important.
      ConfigQuestionArea.VALIDATE(Description,ConfigQuestionArea."Questionnaire Code" + ConfigQuestionArea.Code);
      ConfigQuestionArea.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136600 to show one way of using this function.

      LibraryRapidStart.CreateQuestionArea(ConfigQuestionArea,QuestionnaireCode);
      ConfigQuestionArea.VALIDATE("Table ID",TableID);
      ConfigQuestionArea.MODIFY(TRUE);
Member of Lib.Library - Rapid Start


CreateQuestionnaire@3 Method

The procedure CreateQuestionnaire is available in codeunit 131903.

Syntax

CreateQuestionnaire@3(
    VAR ConfigQuestionnaire@1000 : Record 8610 ConfigQuestionnaire //Reference parameter of type Record
);

Parameters

ConfigQuestionnaire
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Questionnaire.

For a clarification about how this function works, refer to the code listed below.

      ConfigQuestionnaire.INIT;
      ConfigQuestionnaire.VALIDATE(
        Code,
        LibraryUtility.GenerateRandomCode(ConfigQuestionnaire.FIELDNO(Code),DATABASE::"Config. Questionnaire"));
      // Validating Code as Description because value is not important.
      ConfigQuestionnaire.VALIDATE(Description,ConfigQuestionnaire.Code);
      ConfigQuestionnaire.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136600 to show one way of using this function.

      // Test that a new Config. Questionnaire can be created.

      // 1. Setup.
      Initialize;

      // 2. Exercise: Create new Config. Questionnaire.
      LibraryRapidStart.CreateQuestionnaire(ConfigQuestionnaire);

      // 3. Verify: Check the Config. Questionnaire has been created.
      ConfigQuestionnaire.GET(ConfigQuestionnaire.Code);
Member of Lib.Library - Rapid Start


SetCreateMissingCodesForField@13 Method

The procedure SetCreateMissingCodesForField is available in codeunit 131903.

Syntax

SetCreateMissingCodesForField@13(
    PackageCode@1003 : Code[20] PackageCode, //Input parameter of type Code
    TableID@1002 : Integer TableID, //Input parameter of type Integer
    FieldID@1001 : Integer FieldID, //Input parameter of type Integer
    SetCreateMissingCodes@1000 : Boolean SetCreateMissingCodes //Input parameter of type Boolean
);

Parameters

PackageCode
Input parameter of type Code
TableID
Input parameter of type Integer
FieldID
Input parameter of type Integer
SetCreateMissingCodes
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, Create, Missing, Codes, For, Field.

For a clarification about how this function works, refer to the code listed below.

      ConfigPackageField.GET(PackageCode,TableID,FieldID);
      ConfigPackageField.VALIDATE("Create Missing Codes",SetCreateMissingCodes);
      ConfigPackageField.MODIFY;

Example

The below example is extracted from the test automation codeunit 136603 to show one way of using this function.

      // [FEATURE] [UT]
      // [SCENARIO 382272] Import Config Package should save the "Create Missing Codes" package field value
      Initialize;

      // [GIVEN] Config Package for Customer
      CreatePackageWithTable(ConfigPackage,ConfigPackageTable,DATABASE::Customer);

      // [GIVEN] Config Package Field setup for Customer.City and Customer."Territory Code"
      FieldNo1 := Customer.FIELDNO(City);
      FieldNo2 := Customer.FIELDNO("Territory Code");
      LibraryRapidStart.SetIncludeOneField(ConfigPackage.Code,DATABASE::Customer,FieldNo1,TRUE);
      LibraryRapidStart.SetIncludeOneField(ConfigPackage.Code,DATABASE::Customer,FieldNo2,TRUE);

      // [GIVEN] Customer.City field setup "Create Missing Codes" set to TRUE
      LibraryRapidStart.SetCreateMissingCodesForField(ConfigPackage.Code,DATABASE::Customer,FieldNo1,TRUE);
      // [GIVEN] Customer."Territory Code" field setup "Create Missing Codes" set to FALSE
      LibraryRapidStart.SetCreateMissingCodesForField(ConfigPackage.Code,DATABASE::Customer,FieldNo2,FALSE);

      // [WHEN] Import Config Package
      ExportImportXML(ConfigPackage.Code);

      // [THEN] Customer.City field setup "Create Missing Codes" is TRUE
      ConfigPackageField.GET(ConfigPackage.Code,DATABASE::Customer,FieldNo1);
      ConfigPackageField.TESTFIELD("Create Missing Codes",TRUE);

      // [THEN] Customer."Territory Code" field setup "Create Missing Codes" is FALSE
      ConfigPackageField.GET(ConfigPackage.Code,DATABASE::Customer,FieldNo2);
      ConfigPackageField.TESTFIELD("Create Missing Codes",FALSE);

      Cleanup(ConfigPackage.Code);
Member of Lib.Library - Rapid Start


SetIncludeFields@8 Method

The procedure SetIncludeFields is available in codeunit 131903.

Syntax

SetIncludeFields@8(
    PackageCode@1005 : Code[20] PackageCode, //Input parameter of type Code
    TableID@1002 : Integer TableID, //Input parameter of type Integer
    FromFieldID@1001 : Integer FromFieldID, //Input parameter of type Integer
    ToFieldID@1003 : Integer ToFieldID, //Input parameter of type Integer
    SetInclude@1000 : Boolean SetInclude //Input parameter of type Boolean
);

Parameters

PackageCode
Input parameter of type Code
TableID
Input parameter of type Integer
FromFieldID
Input parameter of type Integer
ToFieldID
Input parameter of type Integer
SetInclude
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, Include, Fields.

For a clarification about how this function works, refer to the code listed below.

      ConfigPackageField.RESET;
      ConfigPackageField.SETRANGE("Package Code",PackageCode);
      ConfigPackageField.SETRANGE("Table ID",TableID);
      ConfigPackageField.SETRANGE("Field ID",FromFieldID,ToFieldID);
      ConfigPackageField.MODIFYALL("Include Field",SetInclude,TRUE);

Example

The below example is extracted from the test automation codeunit 136603 to show one way of using this function.

      // Check that in Package Table the field "No of Fields Included" represents the actual data
      Initialize;

      // Add table Vendor to Package
      CreatePackageWithTable(ConfigPackage,ConfigPackageTable,DATABASE::Vendor);

      // Select some package fields
      LibraryRapidStart.SetIncludeFields(ConfigPackage.Code,DATABASE::Vendor,2,22,TRUE);
      LibraryRapidStart.SetIncludeFields(ConfigPackage.Code,DATABASE::Vendor,54,85,TRUE);
      LibraryRapidStart.SetIncludeFields(ConfigPackage.Code,DATABASE::Vendor,92,103,TRUE);

      ConfigPackageField.RESET;
      ConfigPackageField.SETRANGE("Package Code",ConfigPackage.Code);
      ConfigPackageField.SETRANGE("Table ID",DATABASE::Vendor);
      ConfigPackageField.SETRANGE("Include Field",TRUE);
      NoOfFields := ConfigPackageField.COUNT;

      ConfigPackageTable.GET(ConfigPackage.Code,DATABASE::Vendor);
      ConfigPackageTable.CALCFIELDS("No. of Fields Included");

      // Validate field show correct data
      Assert.AreEqual(NoOfFields,ConfigPackageTable."No. of Fields Included",Text101);

      Cleanup(ConfigPackage.Code);
Member of Lib.Library - Rapid Start


SetIncludeOneField@28 Method

The procedure SetIncludeOneField is available in codeunit 131903.

Syntax

SetIncludeOneField@28(
    PackageCode@1004 : Code[20] PackageCode, //Input parameter of type Code
    TableID@1000 : Integer TableID, //Input parameter of type Integer
    FieldID@1001 : Integer FieldID, //Input parameter of type Integer
    SetInclude@1002 : Boolean SetInclude //Input parameter of type Boolean
);

Parameters

PackageCode
Input parameter of type Code
TableID
Input parameter of type Integer
FieldID
Input parameter of type Integer
SetInclude
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, Include, One, Field.

For a clarification about how this function works, refer to the code listed below.

      ConfigPackageField.GET(PackageCode,TableID,FieldID);
      ConfigPackageField.VALIDATE("Include Field",SetInclude);
      ConfigPackageField.MODIFY;

Example

The below example is extracted from the test automation codeunit 136603 to show one way of using this function.

      Initialize;

      // Create new location
      LibraryWarehouse.CreateLocation(Location);
      LibraryERM.CreatePostCode(PostCode);
      Location.City := PostCode.City;
      Location."Post Code" := PostCode.Code;
      Location.MODIFY;
      LocationCode := Location.Code;
      PostCode2 := Location."Post Code";
      City2 := Location.City;

      CreatePackageWithTable(ConfigPackage,ConfigPackageTable,DATABASE::Location);
      LibraryRapidStart.SetIncludeOneField(ConfigPackage.Code,DATABASE::Location,Location.FIELDNO(Name),TRUE);
      LibraryRapidStart.SetIncludeOneField(ConfigPackage.Code,DATABASE::Location,Location.FIELDNO("Name 2"),TRUE);
      LibraryRapidStart.SetIncludeOneField(ConfigPackage.Code,DATABASE::Location,Location.FIELDNO(City),TRUE);
      LibraryRapidStart.SetIncludeOneField(ConfigPackage.Code,DATABASE::Location,Location.FIELDNO("Post Code"),TRUE);

      ExportToXML(ConfigPackage.Code,ConfigPackageTable,FilePath);

      Cleanup(ConfigPackage.Code);
      PostCode.DELETE;
      Location.DELETE;

      ConfigXMLExchange.ImportPackageXML(FilePath);
      LibraryRapidStart.SetValidateOneField(ConfigPackage.Code,DATABASE::Location,Location.FIELDNO(City),FALSE);
      LibraryRapidStart.SetValidateOneField(ConfigPackage.Code,DATABASE::Location,Location.FIELDNO("Post Code"),FALSE);
      LibraryRapidStart.ApplyPackage(ConfigPackage,TRUE);

      Location.GET(LocationCode);
      Assert.IsTrue(
        (City2 = Location.City) AND
        (PostCode2 = Location."Post Code"),
        ErrorInApplyingWithoutValidationFlag);

      ERASE(FilePath);
      Cleanup(ConfigPackage.Code);
Member of Lib.Library - Rapid Start


SetProcessingOrderForField@12 Method

The procedure SetProcessingOrderForField is available in codeunit 131903.

Syntax

SetProcessingOrderForField@12(
    PackageCode@1000 : Code[20] PackageCode, //Input parameter of type Code
    TableID@1001 : Integer TableID, //Input parameter of type Integer
    FieldID@1004 : Integer FieldID, //Input parameter of type Integer
    ProcessingNo@1002 : Integer ProcessingNo //Input parameter of type Integer
);

Parameters

PackageCode
Input parameter of type Code
TableID
Input parameter of type Integer
FieldID
Input parameter of type Integer
ProcessingNo
Input parameter of type Integer

Remarks

The relevant search keywords are: Set, Processing, Order, For, Field.

For a clarification about how this function works, refer to the code listed below.

      ConfigPackageField.GET(PackageCode,TableID,FieldID);
      ConfigPackageField."Processing Order" := ProcessingNo;
      ConfigPackageField.MODIFY;

Example

The below example is extracted from the test automation codeunit 136609 to show one way of using this function.

      CreateResource(Resource,ResourcePrice);

      ResourcePriceCode := ResourcePrice.Code;

      LibraryRapidStart.CreatePackageDataForField(
        ConfigPackage,
        ConfigPackageTable,
        DATABASE::"Resource Price",
        ResourcePrice.FIELDNO(Type),
        FORMAT(ResourcePrice.Type::All),
        SingleEntryRecNo);

      LibraryRapidStart.CreatePackageDataForField(
        ConfigPackage,
        ConfigPackageTable,
        DATABASE::"Resource Price",
        ResourcePrice.FIELDNO(Code),
        ResourcePrice.Code,
        SingleEntryRecNo);

      LibraryRapidStart.CreatePackageDataForField(
        ConfigPackage,
        ConfigPackageTable,
        DATABASE::"Resource Price",
        ResourcePrice.FIELDNO("Work Type Code"),
        ResourcePrice."Work Type Code",
        SingleEntryRecNo);

      LibraryRapidStart.CreatePackageDataForField(
        ConfigPackage,
        ConfigPackageTable,
        DATABASE::"Resource Price",
        ResourcePrice.FIELDNO("Currency Code"),
        ResourcePrice."Currency Code",
        SingleEntryRecNo);

      LibraryRapidStart.SetProcessingOrderForField(
        ConfigPackage.Code,ConfigPackageTable."Table ID",ResourcePrice.FIELDNO(Type),FieldPriorityWithoutDependency);
      LibraryRapidStart.SetProcessingOrderForField(
        ConfigPackage.Code,ConfigPackageTable."Table ID",ResourcePrice.FIELDNO(Code),FieldPriorityWithDependency);

      IF NOT SavePackageRecord THEN
        ResourcePrice.DELETE;
Member of Lib.Library - Rapid Start


SetProcessingOrderForRecord@34 Method

The procedure SetProcessingOrderForRecord is available in codeunit 131903.

Syntax

SetProcessingOrderForRecord@34(
    PackageCode@1000 : Code[20] PackageCode, //Input parameter of type Code
    TableID@1001 : Integer TableID, //Input parameter of type Integer
    ProcessingNo@1002 : Integer ProcessingNo //Input parameter of type Integer
);

Parameters

PackageCode
Input parameter of type Code
TableID
Input parameter of type Integer
ProcessingNo
Input parameter of type Integer

Remarks

The relevant search keywords are: Set, Processing, Order, For, Record.

For a clarification about how this function works, refer to the code listed below.

      ConfigPackageTable.GET(PackageCode,TableID);
      ConfigPackageTable."Processing Order" := ProcessingNo;
      ConfigPackageTable.MODIFY;

Example

The below example is extracted from the test automation codeunit 136608 to show one way of using this function.

      LibraryERM.CreateGenJournalTemplate(GenJournalTemplate); // Master
      LibraryERM.CreateGenJournalBatch(GenJournalBatch,GenJournalTemplate.Name); // Related

      KeyValueWithRelation := GenJournalTemplate.Name;
      KeyValueWithoutRelation := GenJournalBatch.Name;

      IF DeletePrimaryRecord THEN
        GenJournalTemplate.DELETE;
      IF DeleteRelatedRecord THEN
        GenJournalBatch.DELETE;

      // Master data
      IF CreatePrimaryPackageData THEN BEGIN
        LibraryRapidStart.CreatePackageDataForField(
          ConfigPackage,
          PrimaryConfigPackageTable,
          DATABASE::"Gen. Journal Template",
          GenJournalTemplate.FIELDNO(Name),
          KeyValueWithRelation,
          1);
        LibraryRapidStart.SetProcessingOrderForRecord(ConfigPackage.Code,PrimaryConfigPackageTable."Table ID",PrimaryDataPriority);
      END;

      // Related Table field with relation
      IF CreateRelatedPackageData THEN BEGIN
        // PK Field with relation
        LibraryRapidStart.CreatePackageDataForField(
          ConfigPackage,
          RelatedConfigPackageTable,
          DATABASE::"Gen. Journal Batch",
          GenJournalBatch.FIELDNO("Journal Template Name"),
          KeyValueWithRelation,
          1);

        // Field without relation
        LibraryRapidStart.CreatePackageDataForField(
          ConfigPackage,
          RelatedConfigPackageTable,
          DATABASE::"Gen. Journal Batch",
          GenJournalBatch.FIELDNO(Name),
          KeyValueWithoutRelation,
          1);
        LibraryRapidStart.SetProcessingOrderForRecord(ConfigPackage.Code,RelatedConfigPackageTable."Table ID",RelatedDataPriority);
      END;
Member of Lib.Library - Rapid Start


SetValidateOneField@9 Method

The procedure SetValidateOneField is available in codeunit 131903.

Syntax

SetValidateOneField@9(
    PackageCode@1004 : Code[20] PackageCode, //Input parameter of type Code
    TableID@1000 : Integer TableID, //Input parameter of type Integer
    FieldID@1001 : Integer FieldID, //Input parameter of type Integer
    SetValidate@1002 : Boolean SetValidate //Input parameter of type Boolean
);

Parameters

PackageCode
Input parameter of type Code
TableID
Input parameter of type Integer
FieldID
Input parameter of type Integer
SetValidate
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, Validate, One, Field.

For a clarification about how this function works, refer to the code listed below.

      ConfigPackageField.GET(PackageCode,TableID,FieldID);
      ConfigPackageField.VALIDATE("Validate Field",SetValidate);
      ConfigPackageField.MODIFY;

Example

The below example is extracted from the test automation codeunit 136603 to show one way of using this function.

      Initialize;

      // Create new location
      LibraryWarehouse.CreateLocation(Location);
      LibraryERM.CreatePostCode(PostCode);
      Location.City := PostCode.City;
      Location."Post Code" := PostCode.Code;
      Location.MODIFY;
      LocationCode := Location.Code;
      PostCode2 := Location."Post Code";
      City2 := Location.City;

      CreatePackageWithTable(ConfigPackage,ConfigPackageTable,DATABASE::Location);
      LibraryRapidStart.SetIncludeOneField(ConfigPackage.Code,DATABASE::Location,Location.FIELDNO(Name),TRUE);
      LibraryRapidStart.SetIncludeOneField(ConfigPackage.Code,DATABASE::Location,Location.FIELDNO("Name 2"),TRUE);
      LibraryRapidStart.SetIncludeOneField(ConfigPackage.Code,DATABASE::Location,Location.FIELDNO(City),TRUE);
      LibraryRapidStart.SetIncludeOneField(ConfigPackage.Code,DATABASE::Location,Location.FIELDNO("Post Code"),TRUE);

      ExportToXML(ConfigPackage.Code,ConfigPackageTable,FilePath);

      Cleanup(ConfigPackage.Code);
      PostCode.DELETE;
      Location.DELETE;

      ConfigXMLExchange.ImportPackageXML(FilePath);
      LibraryRapidStart.SetValidateOneField(ConfigPackage.Code,DATABASE::Location,Location.FIELDNO(City),FALSE);
      LibraryRapidStart.SetValidateOneField(ConfigPackage.Code,DATABASE::Location,Location.FIELDNO("Post Code"),FALSE);
      LibraryRapidStart.ApplyPackage(ConfigPackage,TRUE);

      Location.GET(LocationCode);
      Assert.IsTrue(
        (City2 = Location.City) AND
        (PostCode2 = Location."Post Code"),
        ErrorInApplyingWithoutValidationFlag);

      ERASE(FilePath);
      Cleanup(ConfigPackage.Code);
Member of Lib.Library - Rapid Start


ValidatePackage@57 Method

The procedure ValidatePackage is available in codeunit 131903.

Syntax

ValidatePackage@57(
    ConfigPackage@1000 : Record 8623 ConfigPackage, //Input parameter of type Record
    SetupProcessingOrderForTables@1004 : Boolean SetupProcessingOrderForTables //Input parameter of type Boolean
);

Parameters

ConfigPackage
Input parameter of type Record
SetupProcessingOrderForTables
Input parameter of type Boolean

Remarks

The relevant search keywords are: Validate, Package.

For a clarification about how this function works, refer to the code listed below.

      ConfigPackageMgt.SetHideDialog(TRUE);
      ConfigPackageTable.SETRANGE("Package Code",ConfigPackage.Code);
      ConfigPackageMgt.ValidatePackageRelations(ConfigPackageTable,TempConfigPackageTable,SetupProcessingOrderForTables);

Example

The below example is extracted from the test automation codeunit 136601 to show one way of using this function.

      Initialize;
      GenerateTemplateAndPackageForTableWithSeriesNo(ConfigPackage,ConfigTemplateCode);

      InitialCustCount := Customer.COUNT;
      LibraryRapidStart.ValidatePackage(ConfigPackage,TRUE);
      Assert.IsTrue(Customer.COUNT = InitialCustCount,InvalidQtyOfCustomersAfterValidateErr);

      Cleanup(ConfigPackage.Code,ConfigTemplateCode);
Member of Lib.Library - Rapid Start


Library - Report Dataset Class

Lib.Library - Report Dataset

COD131007 applies to RES,ERM,SCM,All.

Methods

Name | Description
AssertCurrentRowValue@10 | The procedure AssertCurrentRowValue is available in codeunit 131007.
AssertCurrentRowValueNotEquals@32 | The procedure AssertCurrentRowValueNotEquals is available in codeunit 131007.
AssertElementTagExists@29 | The procedure AssertElementTagExists is available in codeunit 131007.
AssertElementTagWithValueExists@23 | The procedure AssertElementTagWithValueExists is available in codeunit 131007.
AssertElementTagWithValueNotExist@28 | The procedure AssertElementTagWithValueNotExist is available in codeunit 131007.
AssertElementWithValueExists@3 | The procedure AssertElementWithValueExists is available in codeunit 131007.
AssertElementWithValueNotExist@19 | The procedure AssertElementWithValueNotExist is available in codeunit 131007.
AssertParameterValueExists@33 | The procedure AssertParameterValueExists is available in codeunit 131007.
CurrentRowHasElement@17 | The procedure CurrentRowHasElement is available in codeunit 131007.
CurrentRowHasElementTag@26 | The procedure CurrentRowHasElementTag is available in codeunit 131007.
FindCurrentRowTagValue@27 | The procedure FindCurrentRowTagValue is available in codeunit 131007.
FindCurrentRowValue@7 | The procedure FindCurrentRowValue is available in codeunit 131007.
FindRow@14 | The procedure FindRow is available in codeunit 131007.
FindRowWithTag@25 | The procedure FindRowWithTag is available in codeunit 131007.
FindRowWithTagNoValue@30 | The procedure FindRowWithTagNoValue is available in codeunit 131007.
GetElementValueInCurrentRow@15 | The procedure GetElementValueInCurrentRow is available in codeunit 131007.
GetFileName@11 | The procedure GetFileName is available in codeunit 131007.
GetLastRow@13 | The procedure GetLastRow is available in codeunit 131007.
GetNextRow@2 | The procedure GetNextRow is available in codeunit 131007.
GetParametersFileName@4 | The procedure GetParametersFileName is available in codeunit 131007.
LoadDataSetFile@1 | The procedure LoadDataSetFile is available in codeunit 131007.
LoadDataSetFileWithNoSchema@21 | The procedure LoadDataSetFileWithNoSchema is available in codeunit 131007.
LoadParametersFile@31 | The procedure LoadParametersFile is available in codeunit 131007.
MoveToRow@20 | The procedure MoveToRow is available in codeunit 131007.
Reset@6 | The procedure Reset is available in codeunit 131007.
RowCount@18 | The procedure RowCount is available in codeunit 131007.
SearchForElementByValue@8 | The procedure SearchForElementByValue is available in codeunit 131007.
SetRange@9 | The procedure SetRange is available in codeunit 131007.
SetRangeWithTrimmedValues@5 | The procedure SetRangeWithTrimmedValues is available in codeunit 131007.
SetXmlNodeList@22 | The procedure SetXmlNodeList is available in codeunit 131007.
Sum@16 | The procedure Sum is available in codeunit 131007.

See Also

Lib


AssertCurrentRowValue@10 Method

The procedure AssertCurrentRowValue is available in codeunit 131007.

Syntax

AssertCurrentRowValue@10(
    ElementName@1001 : Text ElementName, //Input parameter of type Text
    ExpectedValue@1000 : Variant ExpectedValue //Input parameter of type Variant
);

Parameters

ElementName
Input parameter of type Text
ExpectedValue
Input parameter of type Variant

Remarks

The relevant search keywords are: Assert, Current, Row, Value.

For a clarification about how this function works, refer to the code listed below.

      FindCurrentRowValue(ElementName,Value);
      Assert.AreEqual(ExpectedValue,Value,
        STRSUBSTNO(CurrentRowErr,ElementName,ExpectedValue))

Example

The below example is extracted from the test automation codeunit 134335 to show one way of using this function.

      // Check Vendor Order Detail Report with default option.

      // Setup.
      Initialize;
      CreatePurchaseDocument(PurchaseHeader,PurchaseHeader."Document Type"::Order,'',CreateItem,'');
      PurchaseLine.SETRANGE("Document Type",PurchaseLine."Document Type"::Order);
      PurchaseLine.SETRANGE("Document No.",PurchaseHeader."No.");
      PurchaseLine.FINDFIRST;

      // Exercise: Save Vendor Order Details Report with option Amount LCY FALSE.
      SaveOrderDetailReport(PurchaseHeader."Buy-from Vendor No.",FALSE);

      // Verify: Verify Report values.
      LibraryReportDataset.LoadDataSetFile;
      LibraryReportDataset.SetRange('PurchOrderHeaderNo',PurchaseHeader."No.");
      IF NOT LibraryReportDataset.GetNextRow THEN
        ERROR(STRSUBSTNO(NoDatasetRowErr,'PurchOrderHeaderNo',PurchaseHeader."No."));
      WITH PurchaseLine DO BEGIN
        LibraryReportDataset.AssertCurrentRowValue('Quantity_PurchaseLine',Quantity);
        LibraryReportDataset.AssertCurrentRowValue('OutstandingQty_PurchLine',"Outstanding Quantity");
        LibraryReportDataset.AssertCurrentRowValue('DirectUnitCost_PurchLine',"Direct Unit Cost");
        LibraryReportDataset.FindCurrentRowValue('PurchOrderAmount',ActualOutstandingOrders);
        Assert.AreNearlyEqual("Outstanding Amt. Ex. VAT (LCY)",ActualOutstandingOrders,LibraryERM.GetAmountRoundingPrecision,
          STRSUBSTNO(MustBeEqualErr,"Outstanding Amt. Ex. VAT (LCY)",'Outstanding Orders'));
      END;
Member of Lib.Library - Report Dataset


AssertCurrentRowValueNotEquals@32 Method

The procedure AssertCurrentRowValueNotEquals is available in codeunit 131007.

Syntax

AssertCurrentRowValueNotEquals@32(
    ElementName@1001 : Text ElementName, //Input parameter of type Text
    ExpectedValue@1000 : Variant ExpectedValue //Input parameter of type Variant
);

Parameters

ElementName
Input parameter of type Text
ExpectedValue
Input parameter of type Variant

Remarks

The relevant search keywords are: Assert, Current, Row, Value, Not, Equals.

For a clarification about how this function works, refer to the code listed below.

      FindCurrentRowValue(ElementName,Value);
      Assert.AreNotEqual(ExpectedValue,Value,
        STRSUBSTNO(CurrentRowErr,ElementName,ExpectedValue))

Example

The below example is extracted from the test automation codeunit 134986 to show one way of using this function.

      // [SCENARIO 271843] The Reminder report contains Company Logo only in the first row of dataset
      Initialize;

      // [GIVEN] "Sales & Receivables Setup"."Logo Position on Document" = Left (the position is not matter)
      SalesReceivablesSetup.GET;
      SalesReceivablesSetup."Logo Position on Documents" := SalesReceivablesSetup."Logo Position on Documents"::Left;
      SalesReceivablesSetup.MODIFY;

      // [GIVEN] Issued Reminder
      CreateIssuedReminderWithInterestAmount(IssuedReminderHeader,1); // VAT Calculation type is not matter
      COMMIT;

      // [WHEN] Run report Reminder
      REPORT.RUN(REPORT::Reminder,TRUE,FALSE,IssuedReminderHeader);

      // [THEN] The first row of dataset contains logo
      LibraryReportDataset.LoadDataSetFile;
      LibraryReportDataset.GetNextRow;
      LibraryReportDataset.AssertCurrentRowValueNotEquals('CompanyInfo1Picture','');
      LibraryReportDataset.GetNextRow;
      LibraryReportDataset.AssertCurrentRowValue('CompanyInfo1Picture','');
Member of Lib.Library - Report Dataset


AssertElementTagExists@29 Method

The procedure AssertElementTagExists is available in codeunit 131007.

Syntax

AssertElementTagExists@29(
    ElementTag@1000 : Text ElementTag //Input parameter of type Text
);

Parameters

ElementTag
Input parameter of type Text

Remarks

The relevant search keywords are: Assert, Element, Tag, Exists.

For a clarification about how this function works, refer to the code listed below.

      SetXmlNodeList(ElementTag);
      Assert.IsTrue(
        FindRowWithTagNoValue(ElementTag) <> -1,
        STRSUBSTNO(RowNotFoundErr,ElementTag,''))

Example

There are no examples available.
Member of Lib.Library - Report Dataset


AssertElementTagWithValueExists@23 Method

The procedure AssertElementTagWithValueExists is available in codeunit 131007.

Syntax

AssertElementTagWithValueExists@23(
    ElementTag@1000 : Text ElementTag, //Input parameter of type Text
    ExpectedValue@1002 : Variant ExpectedValue //Input parameter of type Variant
);

Parameters

ElementTag
Input parameter of type Text
ExpectedValue
Input parameter of type Variant

Remarks

The relevant search keywords are: Assert, Element, Tag, Value, Exists.

For a clarification about how this function works, refer to the code listed below.

      SetXmlNodeList(ElementTag);
      Assert.IsTrue(
        SearchForElementTagByValue(ElementTag,ExpectedValue),
        STRSUBSTNO(RowNotFoundErr,ElementTag,ExpectedValue))

Example

The below example is extracted from the test automation codeunit 134092 to show one way of using this function.

      // [FEATURE] [Reports]
      Initialize;

      // [GIVEN] G/L Account = "X" with Consolidation Setup
      CreateGLAccountWithConsolidationSetup(GLAccount);

      // [GIVEN] Business Unit "BU" with current company
      CreateBusinessUnit(BusinessUnit,BusinessUnit."Data Source"::"Local Curr. (LCY)");

      // [GIVEN] Default Dimension with Dimension Code = "D1", Dimension value = "V1"
      // [GIVEN] "D1"."Value Posting" = "Value Posting"::"Same Code"
      // [GIVEN] Dimension Set entry "DS": "DS".Dimension Code = "D1", "DS".Dimension Value = "V2"
      // [GIVEN] Selected Dimension code for checking in report is "D1"
      CreateSelectedDim(DefaultDimension,DimSetID,GLAccount."No.");

      // [GIVEN] G/L Entry "GLE": "GLE"."G/L Account" = "X", "GLE".BusinessUnit = "BU", "GLE".Dimension Set = "DS"
      GLEntryNo := InsertGLEntryWithBusinessUnit(GLAccount."No.",BusinessUnit.Code,DimSetID);

      // [WHEN] Run "Consolidation - Test Database" report filtered on Business Unit "BU"
      LibraryVariableStorage.Enqueue(DefaultDimension."Dimension Code");
      COMMIT;
      REPORT.RUN(REPORT::"Consolidation - Test Database",TRUE,FALSE,BusinessUnit);

      // [THEN] Error "G/L Entry "GLE": Select Dimension Value Code "V1" for the Dimension Code "D1 for G/L Account "X"." has been logged.
      LibraryReportDataset.LoadDataSetFile;
      LibraryReportDataset.AssertElementTagWithValueExists(
        GLEntryErrTagTok,
        STRSUBSTNO(
          GLEntryDimensionErr,GLEntryNo,DefaultDimension."Dimension Value Code",DefaultDimension."Dimension Code",GLAccount."No."));
Member of Lib.Library - Report Dataset


AssertElementTagWithValueNotExist@28 Method

The procedure AssertElementTagWithValueNotExist is available in codeunit 131007.

Syntax

AssertElementTagWithValueNotExist@28(
    ElementTag@1000 : Text ElementTag, //Input parameter of type Text
    ExpectedValue@1002 : Variant ExpectedValue //Input parameter of type Variant
);

Parameters

ElementTag
Input parameter of type Text
ExpectedValue
Input parameter of type Variant

Remarks

The relevant search keywords are: Assert, Element, Tag, Value, Not, Exist.

For a clarification about how this function works, refer to the code listed below.

      SetXmlNodeList(ElementTag);
      Assert.IsFalse(
        SearchForElementTagByValue(ElementTag,ExpectedValue),
        STRSUBSTNO(RowNotFoundErr,ElementTag,ExpectedValue))

Example

The below example is extracted from the test automation codeunit 134982 to show one way of using this function.

      // [SCENARIO 201781] Validate Detail Trial Balance Report when setting a date range.
      Initialize;

      // [GIVEN] Document "D1": Posted General Journal Line with amount 1000 and date 31.12.17
      // [GIVEN] Document "D2": Posted General Journal Line with amount 2000 and date 01.01.18
      CreatePostTwoGenJnlLines(Amount,AccountNo,DocumentNo);

      // [WHEN] Run Save Detail Trial Balance Report with date range '01.01.18..'
      DateFilter := STRSUBSTNO('%1..',WORKDATE);
      RunDetailTrialBalanceReport(AccountNo,FALSE,FALSE,FALSE,FALSE,DateFilter);
      LibraryReportDataset.LoadDataSetFile;

      // [THEN] No lines for "D1" created
      // [THEN] Document "D2": 'StartBalance' = 1000; 'DebitAmount_GLEntry' = 2000; 'GLBalance' = 3000
      LibraryReportDataset.AssertElementTagWithValueNotExist('DocumentNo_GLEntry',DocumentNo[1]);
      VerifyDetailTrialBalanceDate(DocumentNo[2],Amount[1],Amount[2]);
Member of Lib.Library - Report Dataset


AssertElementWithValueExists@3 Method

The procedure AssertElementWithValueExists is available in codeunit 131007.

Syntax

AssertElementWithValueExists@3(
    ElementName@1000 : Text ElementName, //Input parameter of type Text
    ExpectedValue@1002 : Variant ExpectedValue //Input parameter of type Variant
);

Parameters

ElementName
Input parameter of type Text
ExpectedValue
Input parameter of type Variant

Remarks

The relevant search keywords are: Assert, Element, Value, Exists.

For a clarification about how this function works, refer to the code listed below.

      Assert.IsTrue(
        SearchForElementByValue(ElementName,ExpectedValue),
        STRSUBSTNO(RowNotFoundErr,ElementName,ExpectedValue))

Example

The below example is extracted from the test automation codeunit 134063 to show one way of using this function.

      LibraryReportDataset.LoadDataSetFile;
      LibraryReportDataset.AssertElementWithValueExists('IntrastatJnlLineQty',Quantity);
      LibraryReportDataset.AssertElementWithValueExists('IntrastatJnlLineTariffNo',TariffNo);
Member of Lib.Library - Report Dataset


AssertElementWithValueNotExist@19 Method

The procedure AssertElementWithValueNotExist is available in codeunit 131007.

Syntax

AssertElementWithValueNotExist@19(
    ElementName@1000 : Text ElementName, //Input parameter of type Text
    ExpectedValue@1002 : Variant ExpectedValue //Input parameter of type Variant
);

Parameters

ElementName
Input parameter of type Text
ExpectedValue
Input parameter of type Variant

Remarks

The relevant search keywords are: Assert, Element, Value, Not, Exist.

For a clarification about how this function works, refer to the code listed below.

      Assert.IsFalse(
        SearchForElementByValue(ElementName,ExpectedValue),
        STRSUBSTNO(RowFoundErr,ElementName,ExpectedValue))

Example

The below example is extracted from the test automation codeunit 134335 to show one way of using this function.

      // [SCENARIO 378237] Vendor Balance To Date for closed Entry with zero balance inside period and application after Ending Date
      Initialize;

      // [GIVEN] Vendor with payment of Amount = 150
      MockVendorLedgerEntry(VendorLedgerEntry,LibraryPurchase.CreateVendorNo,LibraryRandom.RandDec(100,2),WORKDATE);

      // [GIVEN] Closed Vendor Ledger Entry on 31.12.15 with Amount = -100
      // [GIVEN] Application dtld. vend. ledger entries of Amount = 100 applied on 31.12.15 and unapplied on 01.01.16
      // [GIVEN] Application dtld. vend. ledger entry with Amount = 100 on 01.01.16
      Amount := -LibraryRandom.RandDec(100,2);
      MockApplyUnapplyScenario(VendorLedgerEntry."Vendor No.",WORKDATE,WORKDATE + 1,WORKDATE + 1,Amount);

      // [WHEN] Save Vendor Balance To Data report on 31.12.15 with Include Unapplied Entries = Yes
      RunVendorBalanceToDateWithVendor(VendorLedgerEntry."Vendor No.",TRUE,WORKDATE);

      // [THEN] Payment Entry of 150 is printed, -100 is printed with 0 balance, Total Amount = 150
      // [THEN] Applied Entry (01.01.16) is not printed
      VerifyVendorBalanceToDateTwoEntriesExist(
        VendorLedgerEntry."Vendor No.",VendorLedgerEntry.Amount,Amount,VendorLedgerEntry.Amount);
      // [THEN] Applied Entry (31.12.15) is printed. Initial TFSID 232772
      LibraryReportDataset.AssertElementWithValueNotExist('PostDate_DtldVendLedEnt',FORMAT(WORKDATE + 1));
Member of Lib.Library - Report Dataset


AssertParameterValueExists@33 Method

The procedure AssertParameterValueExists is available in codeunit 131007.

Syntax

AssertParameterValueExists@33(
    ParameterName@1000 : Text ParameterName, //Input parameter of type Text
    ExpectedValue@1001 : Text ExpectedValue //Input parameter of type Text
);

Parameters

ParameterName
Input parameter of type Text
ExpectedValue
Input parameter of type Text

Remarks

The relevant search keywords are: Assert, Parameter, Value, Exists.

For a clarification about how this function works, refer to the code listed below.

      SetXmlNodeList(NameTagTxt);
      ParameterNameRow := FindRowWithTag(NameTagTxt,ParameterName);
      Assert.IsTrue(
        ParameterNameRow <> -1,
        STRSUBSTNO(RowNotFoundErr,NameTagTxt,ParameterName));

      SetXmlNodeList(StringTagTxt);
      ValueNameRow := FindRowWithTag(StringTagTxt,ExpectedValue);
      Assert.IsTrue(
        ValueNameRow <> -1,
        STRSUBSTNO(RowNotFoundErr,StringTagTxt,ExpectedValue));

      WHILE (ValueNameRow <> -1) AND (ValueNameRow < ParameterNameRow) DO BEGIN
        MoveToRow(ValueNameRow + 1);
        ValueNameRow := FindRowWithTag(StringTagTxt,ExpectedValue);
      END;

      Assert.IsTrue(
        ParameterNameRow = ValueNameRow,
        STRSUBSTNO(RowNotFoundErr,ParameterName,ExpectedValue))

Example

The below example is extracted from the test automation codeunit 134335 to show one way of using this function.

      // [FEATURE] [Vendor] [Detail Trial Balance]
      // [SCENARIO 379230] REP 304 "Vendor - Detail Trial Balance" prints "Entry No." column caption
      Initialize;

      // [WHEN] Run REP 304 "Vendor - Detail Trial Balance"
      SaveVendorDetailTrialBalReport(LibraryPurchase.CreateVendorNo,FALSE,FALSE,WORKDATE);

      // [THEN] "Entry No." column caption is shown
      LibraryReportDataset.LoadParametersFile;
      LibraryReportDataset.AssertParameterValueExists('EntryNo_VendorLedgerEntryCaption','Entry No.');
Member of Lib.Library - Report Dataset


CurrentRowHasElement@17 Method

The procedure CurrentRowHasElement is available in codeunit 131007.

Syntax

CurrentRowHasElement@17(
    ElementName@1000 : Text ElementName //Input parameter of type Text
);

Parameters

ElementName
Input parameter of type Text

Return Value

Boolean

Remarks

The relevant search keywords are: Current, Row, Has, Element.

For a clarification about how this function works, refer to the code listed below.

      XmlNode := XmlNodeList.Item(CurrentRowIndex);
      EXIT(NOT ISNULL(XmlNode.Item(ElementName)));

Example

The below example is extracted from the test automation codeunit 134067 to show one way of using this function.

      LibraryReportDataset.LoadDataSetFile;
      LibraryReportDataset.SetRange('No_SalesInvHdr',SalesInvHdrNo);

      WHILE LibraryReportDataset.GetNextRow DO
        Assert.IsFalse(LibraryReportDataset.CurrentRowHasElement('VATClauseCode') OR
          LibraryReportDataset.CurrentRowHasElement('VATClauseDescription') OR
          LibraryReportDataset.CurrentRowHasElement('VATClauseDescription2'),VATClauseDoesNotExistErr);
Member of Lib.Library - Report Dataset


CurrentRowHasElementTag@26 Method

The procedure CurrentRowHasElementTag is available in codeunit 131007.

Syntax

CurrentRowHasElementTag@26(
    ElementName@1000 : Text ElementName //Input parameter of type Text
);

Parameters

ElementName
Input parameter of type Text

Return Value

Boolean

Remarks

The relevant search keywords are: Current, Row, Has, Element, Tag.

For a clarification about how this function works, refer to the code listed below.

      XmlNode := XmlNodeList.Item(CurrentRowIndex);
      EXIT(XmlNode.Name = ElementName);

Example

There are no examples available.
Member of Lib.Library - Report Dataset


FindCurrentRowTagValue@27 Method

The procedure FindCurrentRowTagValue is available in codeunit 131007.

Syntax

FindCurrentRowTagValue@27(
    ElementTag@1000 : Text ElementTag, //Input parameter of type Text
    VAR Value@1002 : Variant Value //Reference parameter of type Variant
);

Parameters

ElementTag
Input parameter of type Text
Value
Reference parameter of type Variant

Remarks

The relevant search keywords are: Find, Current, Row, Tag, Value.

For a clarification about how this function works, refer to the code listed below.

      IF CurrentRowIndex = -1 THEN
        ERROR(InvalidRowErr);

      XmlNode := XmlNodeList.Item(CurrentRowIndex);

      // verify
      IF NOT CurrentRowHasElementTag(ElementTag) THEN
        ERROR(InvalidFieldErr,ElementTag);

      ElementText := XmlNode.InnerText;
      Value := ElementText;

Example

There are no examples available.
Member of Lib.Library - Report Dataset


FindCurrentRowValue@7 Method

The procedure FindCurrentRowValue is available in codeunit 131007.

Syntax

FindCurrentRowValue@7(
    ElementName@1000 : Text ElementName, //Input parameter of type Text
    VAR Value@1002 : Variant Value //Reference parameter of type Variant
);

Parameters

ElementName
Input parameter of type Text
Value
Reference parameter of type Variant

Remarks

The relevant search keywords are: Find, Current, Row, Value.

For a clarification about how this function works, refer to the code listed below.

      IF CurrentRowIndex = -1 THEN
        ERROR(InvalidRowErr);

      XmlNode := XmlNodeList.Item(CurrentRowIndex);
      IF NOT CurrentRowHasElement(ElementName) THEN
        ERROR(InvalidFieldErr,ElementName);

      ElementText := XmlNode.Item(ElementName).InnerText;

      CASE GetElementSchemaType(ElementName) OF
        'xs:boolean':
          BEGIN
            EVALUATE(Boolean,ElementText,9);
            Value := Boolean;
          END;
        'xs:int':
          BEGIN
            EVALUATE(Integer,ElementText,9);
            Value := Integer;
          END;
        'xs:decimal':
          BEGIN
            EVALUATE(Decimal,ElementText,9);
            Value := Decimal;
          END;
        ELSE
          Value := ElementText;
      END;

Example

The below example is extracted from the test automation codeunit 134063 to show one way of using this function.

      CompanyInformation.GET;
      LibraryReportDataset.LoadDataSetFile;
      LibraryReportDataset.GetLastRow;
      CompanyInformationName := CompanyInformation.Name;
      LibraryReportDataset.FindCurrentRowValue('CompanyName',CompanyInformationName);
Member of Lib.Library - Report Dataset


FindRow@14 Method

The procedure FindRow is available in codeunit 131007.

Syntax

FindRow@14(
    ElementName@1001 : Text ElementName, //Input parameter of type Text
    ElementValue@1000 : Variant ElementValue //Input parameter of type Variant
);

Parameters

ElementName
Input parameter of type Text
ElementValue
Input parameter of type Variant

Return Value

Integer

Remarks

The relevant search keywords are: Find, Row.

For a clarification about how this function works, refer to the code listed below.

      WHILE GetNextRow DO
        IF CurrentRowHasElement(ElementName) THEN BEGIN
          FindCurrentRowValue(ElementName,CurrentValue);
          IF Assert.Compare(CurrentValue,ElementValue) THEN BEGIN
            Result := CurrentRowIndex;
            CurrentRowIndex := -1;
            EXIT(Result);
          END;
        END;

      CurrentRowIndex := -1;
      Result := -1;
      EXIT(Result);

Example

The below example is extracted from the test automation codeunit 134092 to show one way of using this function.

      // [FEATURE] [Reports]
      // [SCENARIO 372262] "G/L Account No." should be printed in "Consolidation - Test Database" report if related G/L Entry exists

      Initialize;
      // [GIVEN] G/L Account = "X" with Consolidation Setup and posted G/L Entry
      CreateGLAccountWithConsolidationSetup(GLAccount);
      InsertGLEntry(GLAccount."No.");

      // [WHEN] Run "Consolidation - Test Database" report
      LibraryVariableStorage.Enqueue('');
      RunConsolidationTestDatabase;

      // [THEN] G/L Account = "X" is printed
      LibraryReportDataset.LoadDataSetFile;
      LibraryReportDataset.MoveToRow(LibraryReportDataset.FindRow('G_L_Account__No__',GLAccount."No."));
Member of Lib.Library - Report Dataset


FindRowWithTag@25 Method

The procedure FindRowWithTag is available in codeunit 131007.

Syntax

FindRowWithTag@25(
    ElementTag@1001 : Text ElementTag, //Input parameter of type Text
    ElementValue@1000 : Variant ElementValue //Input parameter of type Variant
);

Parameters

ElementTag
Input parameter of type Text
ElementValue
Input parameter of type Variant

Return Value

Integer

Remarks

The relevant search keywords are: Find, Row, Tag.

For a clarification about how this function works, refer to the code listed below.

      WHILE GetNextRow DO
        IF CurrentRowHasElementTag(ElementTag) THEN BEGIN
          FindCurrentRowTagValue(ElementTag,CurrentValue);
          IF Assert.Compare(CurrentValue,ElementValue) THEN BEGIN
            Result := CurrentRowIndex;
            CurrentRowIndex := -1;
            EXIT(Result);
          END;
        END;

      CurrentRowIndex := -1;
      Result := -1;
      EXIT(Result);

Example

There are no examples available.
Member of Lib.Library - Report Dataset


FindRowWithTagNoValue@30 Method

The procedure FindRowWithTagNoValue is available in codeunit 131007.

Syntax

FindRowWithTagNoValue@30(
    ElementTag@1001 : Text ElementTag //Input parameter of type Text
);

Parameters

ElementTag
Input parameter of type Text

Return Value

Integer

Remarks

The relevant search keywords are: Find, Row, Tag, No, Value.

For a clarification about how this function works, refer to the code listed below.

      WHILE GetNextRow DO
        IF CurrentRowHasElementTag(ElementTag) THEN BEGIN
          Result := CurrentRowIndex;
          CurrentRowIndex := -1;
          EXIT(Result);
        END;

      CurrentRowIndex := -1;
      Result := -1;
      EXIT(Result);

Example

There are no examples available.
Member of Lib.Library - Report Dataset


GetElementValueInCurrentRow@15 Method

The procedure GetElementValueInCurrentRow is available in codeunit 131007.

Syntax

GetElementValueInCurrentRow@15(
    ElementName@1000 : Text ElementName, //Input parameter of type Text
    VAR Result@1001 : Variant Result //Reference parameter of type Variant
);

Parameters

ElementName
Input parameter of type Text
Result
Reference parameter of type Variant

Remarks

The relevant search keywords are: Get, Element, Value, In, Current, Row.

For a clarification about how this function works, refer to the code listed below.

      Assert.IsTrue(CurrentRowIndex > -1,STRSUBSTNO(RowIndexErr,CurrentRowIndex));
      Assert.IsTrue(CurrentRowHasElement(ElementName),STRSUBSTNO(ElementNameErr,ElementName));
      FindCurrentRowValue(ElementName,Result);

Example

The below example is extracted from the test automation codeunit 134984 to show one way of using this function.

      // [FEATURE] [Sales Document - Test]
      // [SCENARIO 378473] Sales Document - Test report should show Exchange Rate from Sales header in section "VAT Amount Specification ..."
      Initialize;

      // [GIVEN] "General Ledger Setup"."Print VAT specification in LCY" = TRUE
      GeneralLedgerSetup.GET;
      GeneralLedgerSetup."Print VAT specification in LCY" := TRUE;
      GeneralLedgerSetup.MODIFY;

      // [GIVEN] Currency "C" with Exchange Rate = "X"
      CreateCurrencyWithExchRate(CurrencyExchangeRate);

      // [GIVEN] Sales Invoice with "Currency Code" = "C" and Exchange Rate = "Y"
      CreateSalesInvoiceWithCurrFactor(SalesHeaderNo,ExpectedResult,VATIdentifier,CurrencyExchangeRate);

      // [WHEN] Run "Sales Document - Test"
      SaveSalesDocumentTest(SalesHeaderNo,TRUE,TRUE,FALSE,FALSE);

      // [THEN] Exchange Rate = "Y"
      LibraryReportDataset.LoadDataSetFile;
      LibraryReportDataset.SetRange(VATIdentifierTok,VATIdentifier);
      LibraryReportDataset.GetNextRow;
      LibraryReportDataset.GetElementValueInCurrentRow(VALExchRateTok,ActualResult);
      Assert.AreNotEqual(0,STRPOS(ActualResult,FORMAT(ExpectedResult)),WrongExchRateErr);
Member of Lib.Library - Report Dataset


GetFileName@11 Method

The procedure GetFileName is available in codeunit 131007.

Syntax

GetFileName@11(
      //param element not supplied
);

Return Value

Text[1024]

Remarks

The relevant search keywords are: Get, File, Name.

For a clarification about how this function works, refer to the code listed below.

      DataSetFileName := FileManagement.ServerTempFileName('.xml');
      EXIT(DataSetFileName)

Example

The below example is extracted from the test automation codeunit 134982 to show one way of using this function.

      CLEAR(VATVIESDeclarationDisk);
      VATVIESDeclarationDisk.InitializeRequest(TRUE);
      VATVIESDeclarationDisk.SETTABLEVIEW(VATEntry);
      VATVIESDeclarationDisk.RUNMODAL;
      FileName := VATVIESDeclarationDisk.GetFileName;
Member of Lib.Library - Report Dataset


GetLastRow@13 Method

The procedure GetLastRow is available in codeunit 131007.

Syntax

GetLastRow@13(
      //param element not supplied
);

Remarks

The relevant search keywords are: Get, Last, Row.

For a clarification about how this function works, refer to the code listed below.

      CurrentRowIndex := RowCount - 1;

Example

The below example is extracted from the test automation codeunit 134063 to show one way of using this function.

      CompanyInformation.GET;
      LibraryReportDataset.LoadDataSetFile;
      LibraryReportDataset.GetLastRow;
      CompanyInformationName := CompanyInformation.Name;
      LibraryReportDataset.FindCurrentRowValue('CompanyName',CompanyInformationName);
Member of Lib.Library - Report Dataset


GetNextRow@2 Method

The procedure GetNextRow is available in codeunit 131007.

Syntax

GetNextRow@2(
      //param element not supplied
);

Return Value

Boolean

Remarks

The relevant search keywords are: Get, Next, Row.

For a clarification about how this function works, refer to the code listed below.

      IF CurrentRowIndex < RowCount - 1 THEN BEGIN
        CurrentRowIndex += 1;
        EXIT(TRUE);
      END;
      EXIT(FALSE)

Example

The below example is extracted from the test automation codeunit 134335 to show one way of using this function.

      // Check Vendor Order Summary Report with Posting Date

      // Setup.
      Initialize;
      CreatePurchaseDocument(PurchaseHeader,PurchaseHeader."Document Type"::Order,'','','');
      FindPurchaseLine(PurchaseLine,PurchaseHeader."Document Type",PurchaseHeader."No.");

      // Exercise: Save Vendor Order Summary without Currency.
      SaveVendorOrderSummary(PurchaseHeader."Buy-from Vendor No.",PurchaseHeader."Posting Date",FALSE);

      // Verify: Verify Saved Report Data with Customized Formula.
      LibraryReportDataset.LoadDataSetFile;
      LibraryReportDataset.AssertElementWithValueExists('PurchAmtOnOrder3',0);
      LibraryReportDataset.GetNextRow;
      LibraryReportDataset.FindCurrentRowValue('PurchAmtOnOrder2',AmountOnOrder2);
      Assert.AreNearlyEqual(AmountOnOrder2,PurchaseLine."Line Amount",LibraryERM.GetAmountRoundingPrecision,
        STRSUBSTNO(ValidationErr,'Total',PurchaseLine."Line Amount"));
      LibraryReportDataset.FindCurrentRowValue('PurchOrderAmount',OrderAmount);
      Assert.AreNearlyEqual(OrderAmount,PurchaseLine."Line Amount",LibraryERM.GetAmountRoundingPrecision,
        STRSUBSTNO(ValidationErr,'Total (LCY)',PurchaseLine."Line Amount"));
Member of Lib.Library - Report Dataset


GetParametersFileName@4 Method

The procedure GetParametersFileName is available in codeunit 131007.

Syntax

GetParametersFileName@4(
      //param element not supplied
);

Return Value

Text

Remarks

The relevant search keywords are: Get, Parameters, File, Name.

For a clarification about how this function works, refer to the code listed below.

      ParametersFileName := FileManagement.ServerTempFileName('.xml');
      EXIT(ParametersFileName)

Example

There are no examples available.
Member of Lib.Library - Report Dataset


LoadDataSetFile@1 Method

The procedure LoadDataSetFile is available in codeunit 131007.

Syntax

LoadDataSetFile@1(
      //param element not supplied
);

Remarks

The relevant search keywords are: Load, Data, Set, File.

For a clarification about how this function works, refer to the code listed below.

      LoadXMLFile(DataSetFileName,TRUE);

Example

The below example is extracted from the test automation codeunit 134063 to show one way of using this function.

      LibraryReportDataset.LoadDataSetFile;
      LibraryReportDataset.AssertElementWithValueExists('IntrastatJnlLineQty',Quantity);
      LibraryReportDataset.AssertElementWithValueExists('IntrastatJnlLineTariffNo',TariffNo);
Member of Lib.Library - Report Dataset


LoadDataSetFileWithNoSchema@21 Method

The procedure LoadDataSetFileWithNoSchema is available in codeunit 131007.

Syntax

LoadDataSetFileWithNoSchema@21(
      //param element not supplied
);

Remarks

The relevant search keywords are: Load, Data, Set, File, No, Schema.

For a clarification about how this function works, refer to the code listed below.

      LoadXMLFile(DataSetFileName,FALSE);

Example

There are no examples available.
Member of Lib.Library - Report Dataset


LoadParametersFile@31 Method

The procedure LoadParametersFile is available in codeunit 131007.

Syntax

LoadParametersFile@31(
      //param element not supplied
);

Remarks

The relevant search keywords are: Load, Parameters, File.

For a clarification about how this function works, refer to the code listed below.

      LoadXMLFile(ParametersFileName,FALSE);

Example

The below example is extracted from the test automation codeunit 134335 to show one way of using this function.

      // [FEATURE] [Vendor] [Detail Trial Balance]
      // [SCENARIO 379230] REP 304 "Vendor - Detail Trial Balance" prints "Entry No." column caption
      Initialize;

      // [WHEN] Run REP 304 "Vendor - Detail Trial Balance"
      SaveVendorDetailTrialBalReport(LibraryPurchase.CreateVendorNo,FALSE,FALSE,WORKDATE);

      // [THEN] "Entry No." column caption is shown
      LibraryReportDataset.LoadParametersFile;
      LibraryReportDataset.AssertParameterValueExists('EntryNo_VendorLedgerEntryCaption','Entry No.');
Member of Lib.Library - Report Dataset


MoveToRow@20 Method

The procedure MoveToRow is available in codeunit 131007.

Syntax

MoveToRow@20(
    RowIndex@1000 : Integer RowIndex //Input parameter of type Integer
);

Parameters

RowIndex
Input parameter of type Integer

Remarks

The relevant search keywords are: Move, To, Row.

For a clarification about how this function works, refer to the code listed below.

      // Assume incoming index is in range  1..Count (like arrays in C/AL)
      // Dataset indices start from 0.. thus we need compare CurrentRowIndex with passed decremented (by 1) RowIndex
      CurrentRowIndex := -1;
      WHILE GetNextRow AND (CurrentRowIndex <> (RowIndex - 1)) DO;
      IF NOT ((CurrentRowIndex = (RowIndex - 1)) AND (CurrentRowIndex > -1)) THEN
        ERROR(STRSUBSTNO(RowIndexNotFoundErr,RowIndex));

Example

The below example is extracted from the test automation codeunit 134092 to show one way of using this function.

      // [FEATURE] [Reports]
      // [SCENARIO 372262] "G/L Account No." should be printed in "Consolidation - Test Database" report if related G/L Entry exists

      Initialize;
      // [GIVEN] G/L Account = "X" with Consolidation Setup and posted G/L Entry
      CreateGLAccountWithConsolidationSetup(GLAccount);
      InsertGLEntry(GLAccount."No.");

      // [WHEN] Run "Consolidation - Test Database" report
      LibraryVariableStorage.Enqueue('');
      RunConsolidationTestDatabase;

      // [THEN] G/L Account = "X" is printed
      LibraryReportDataset.LoadDataSetFile;
      LibraryReportDataset.MoveToRow(LibraryReportDataset.FindRow('G_L_Account__No__',GLAccount."No."));
Member of Lib.Library - Report Dataset


Reset@6 Method

The procedure Reset is available in codeunit 131007.

Syntax

Reset@6(
      //param element not supplied
);

Remarks

The relevant search keywords are: Reset.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(XmlNodeList);
      CurrentRowIndex := -1

Example

The below example is extracted from the test automation codeunit 134976 to show one way of using this function.

      // Check the Value of Total(LCY) in Customer Order Report when Show Amount LCY is FALSE and Currency Filter is not blank.

      // Setup: Create Customer with currency and then create a sales order.
      Initialize;
      CreateCustomerWithCurrencyCode(Customer);
      CreateSalesOrder(SalesHeader,SalesLine,Customer."Currency Code",Customer."No.");

      // Exercise: Run Customer Order Summary Report with currency filter not blank and Show Amount LCY is FALSE.
      LibraryVariableStorage.Enqueue(WORKDATE);
      LibraryVariableStorage.Enqueue(FALSE);
      Customer.SETRANGE("Currency Filter",SalesHeader."Currency Code");
      RunCustomerOrderSummaryReport(Customer);

      // Verify: Verify that Totoal (LCY) shows the correct value in local currency and check that Currency Code is showing in the report.
      LibraryReportDataset.LoadDataSetFile;
      VerifyTotalLCYOnCustomerOrderSummary(SalesLine."Line Amount" / SalesHeader."Currency Factor");
      LibraryReportDataset.Reset;
      LibraryReportDataset.AssertElementWithValueExists('SalesLineCurrencyFilter',SalesHeader."Currency Code");
Member of Lib.Library - Report Dataset


RowCount@18 Method

The procedure RowCount is available in codeunit 131007.

Syntax

RowCount@18(
      //param element not supplied
);

Return Value

Integer

Remarks

The relevant search keywords are: Row, Count.

For a clarification about how this function works, refer to the code listed below.

      IF ISNULL(XmlNodeList) THEN
        XmlNodeList := XmlDoc.GetElementsByTagName('Result');

      EXIT(XmlNodeList.Count);

Example

The below example is extracted from the test automation codeunit 136901 to show one way of using this function.

      LibraryReportDataset.LoadDataSetFile;
      RowCount := LibraryReportDataset.RowCount;
Member of Lib.Library - Report Dataset


SearchForElementByValue@8 Method

The procedure SearchForElementByValue is available in codeunit 131007.

Syntax

SearchForElementByValue@8(
    ElementName@1000 : Text ElementName, //Input parameter of type Text
    ElementValue@1001 : Variant ElementValue //Input parameter of type Variant
);

Parameters

ElementName
Input parameter of type Text
ElementValue
Input parameter of type Variant

Return Value

Boolean

Remarks

The relevant search keywords are: Search, For, Element, By, Value.

For a clarification about how this function works, refer to the code listed below.

      EXIT(FindRow(ElementName,ElementValue) <> -1);

Example

There are no examples available.
Member of Lib.Library - Report Dataset


SetRange@9 Method

The procedure SetRange is available in codeunit 131007.

Syntax

SetRange@9(
    ElementName@1000 : Text ElementName, //Input parameter of type Text
    Value@1001 : Variant Value //Input parameter of type Variant
);

Parameters

ElementName
Input parameter of type Text
Value
Input parameter of type Variant

Remarks

The relevant search keywords are: Set, Range.

For a clarification about how this function works, refer to the code listed below.

      SetRangeWithTrimmedValues(ElementName,Value,FALSE)

Example

The below example is extracted from the test automation codeunit 134067 to show one way of using this function.

      LibraryReportDataset.LoadDataSetFile;
      LibraryReportDataset.SetRange('No_SalesInvHdr',SalesInvHdrNo);

      WHILE LibraryReportDataset.GetNextRow DO
        Assert.IsFalse(LibraryReportDataset.CurrentRowHasElement('VATClauseCode') OR
          LibraryReportDataset.CurrentRowHasElement('VATClauseDescription') OR
          LibraryReportDataset.CurrentRowHasElement('VATClauseDescription2'),VATClauseDoesNotExistErr);
Member of Lib.Library - Report Dataset


SetRangeWithTrimmedValues@5 Method

The procedure SetRangeWithTrimmedValues is available in codeunit 131007.

Syntax

SetRangeWithTrimmedValues@5(
    ElementName@1000 : Text ElementName, //Input parameter of type Text
    Value@1001 : Variant Value, //Input parameter of type Variant
    TrimSpacesInValue@1003 : Boolean TrimSpacesInValue //Input parameter of type Boolean
);

Parameters

ElementName
Input parameter of type Text
Value
Input parameter of type Variant
TrimSpacesInValue
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, Range, Trimmed, Values.

For a clarification about how this function works, refer to the code listed below.

      // Validate that the element exists in the dataset
      GetElementSchemaType(ElementName);
      XmlNode := XmlDoc.GetElementsByTagName('DataSet').Item(0);
      IF TrimSpacesInValue = FALSE THEN
        XmlNodeList := XmlNode.SelectNodes(STRSUBSTNO('//*/*[%1="%2"]',ElementName,FORMAT(Value,0,9)))
      ELSE
        XmlNodeList := XmlNode.SelectNodes(STRSUBSTNO('//*/*[normalize-space(%1)="%2"]',ElementName,FORMAT(Value,0,9)));
      CurrentRowIndex := -1

Example

The below example is extracted from the test automation codeunit 136904 to show one way of using this function.

      Column := 0;
      Row := 1;
      Found := FALSE;
      WHILE (FALSE = Found) AND (Column <= 3) DO BEGIN
        Column += 1;
        XmlElementName := STRSUBSTNO(EmployeeAddrCap,Column,Row);
        LibraryReportDataset.SetRangeWithTrimmedValues(XmlElementName,AlternativeAddress."Employee No.",TRUE);
        Found := LibraryReportDataset.GetNextRow;
      END;

      Assert.IsTrue(Found,AlternativeAddress."Employee No.");

      IF Found THEN BEGIN
        Row += 1;
        LibraryReportDataset.AssertCurrentRowValue(STRSUBSTNO(EmployeeAddrCap,Column,Row),
          AlternativeAddress.Address);
        Row += 1;
        LibraryReportDataset.AssertCurrentRowValue(STRSUBSTNO(EmployeeAddrCap,Column,Row),
          AlternativeAddress."Address 2");
        CountryRegion.GET(AlternativeAddress."Country/Region Code");
        FormatAddress.FormatPostCodeCity(PostCodeCity,County,AlternativeAddress.City,
          AlternativeAddress."Post Code",AlternativeAddress.County,CountryRegion.Code);
        Row += 1;
        LibraryReportDataset.AssertCurrentRowValue(STRSUBSTNO(EmployeeAddrCap,Column,Row),PostCodeCity);
        IF County <> '' THEN BEGIN
          Row += 1;
          LibraryReportDataset.AssertCurrentRowValue(STRSUBSTNO(EmployeeAddrCap,Column,Row),County);
        END;
        Row += 1;
        LibraryReportDataset.AssertCurrentRowValue(STRSUBSTNO(EmployeeAddrCap,Column,Row),CountryRegion.Name);
      END;
Member of Lib.Library - Report Dataset


SetXmlNodeList@22 Method

The procedure SetXmlNodeList is available in codeunit 131007.

Syntax

SetXmlNodeList@22(
    value@1000 : Text value //Input parameter of type Text
);

Parameters

value
Input parameter of type Text

Remarks

The relevant search keywords are: Set, Xml, Node, List.

For a clarification about how this function works, refer to the code listed below.

      XmlNodeList := XmlDoc.GetElementsByTagName(value);

Example

There are no examples available.
Member of Lib.Library - Report Dataset


Sum@16 Method

The procedure Sum is available in codeunit 131007.

Syntax

Sum@16(
    ElementName@1000 : Text ElementName //Input parameter of type Text
);

Parameters

ElementName
Input parameter of type Text

Return Value

Decimal

Remarks

The relevant search keywords are: Sum.

For a clarification about how this function works, refer to the code listed below.

      WHILE GetNextRow DO
        IF CurrentRowHasElement(ElementName) THEN BEGIN
          FindCurrentRowValue(ElementName,ValueVar);
          Value := ValueVar;
          TotalValue += Value;
        END;

      CurrentRowIndex := -1

Example

The below example is extracted from the test automation codeunit 134335 to show one way of using this function.

      LibraryReportDataset.LoadDataSetFile;
      LibraryReportDataset.SetRange('No_Vendor',VendorNo);
      ActualAmount := LibraryReportDataset.Sum('PurchAmtOnOrder2');
      Assert.AreEqual(ExpectedAmount,ROUND(ActualAmount),STRSUBSTNO(MustBeEqualErr,ExpectedAmount,ROUND(ActualAmount)));
Member of Lib.Library - Report Dataset


Library - Report Validation Class

Lib.Library - Report Validation

COD131002 applies to RES,W1,All.
// Contains all functions related to report Validation.

Methods

Name | Description
CheckIfDecimalValueExists@39 | The procedure CheckIfDecimalValueExists is available in codeunit 131002.
CheckIfValueExists@18 | The procedure CheckIfValueExists is available in codeunit 131002.
CheckIfValueExistsInSpecifiedColumn@25 | The procedure CheckIfValueExistsInSpecifiedColumn is available in codeunit 131002.
CheckIfValueExistsOnSpecifiedWorksheet@29 | The procedure CheckIfValueExistsOnSpecifiedWorksheet is available in codeunit 131002.
CountColumns@19 | The procedure CountColumns is available in codeunit 131002.
CountDistinctRows@8 | The procedure CountDistinctRows is available in codeunit 131002.
CountRows@7 | The procedure CountRows is available in codeunit 131002.
CountRowsBetweenColumnCaptions@5 | The procedure CountRowsBetweenColumnCaptions is available in codeunit 131002.
CountWorksheets@26 | The procedure CountWorksheets is available in codeunit 131002.
DownloadFile@40 | The procedure DownloadFile is available in codeunit 131002.
FindColumnNoFromColumnCaption@4 | The procedure FindColumnNoFromColumnCaption is available in codeunit 131002.
FindColumnNoFromColumnCaptionInsideArea@27 | The procedure FindColumnNoFromColumnCaptionInsideArea is available in codeunit 131002.
FindFirstColumnNoByValue@104 | The procedure FindFirstColumnNoByValue is available in codeunit 131002.
FindFirstRow@20 | The procedure FindFirstRow is available in codeunit 131002.
FindNextRow@22 | The procedure FindNextRow is available in codeunit 131002.
FindRowNoFromColumnCaption@6 | The procedure FindRowNoFromColumnCaption is available in codeunit 131002.
FindRowNoFromColumnNoAndValue@3 | The procedure FindRowNoFromColumnNoAndValue is available in codeunit 131002.
FindRowNoFromColumnNoAndValueInsideArea@31 | The procedure FindRowNoFromColumnNoAndValueInsideArea is available in codeunit 131002.
FindSet@15 | The procedure FindSet is available in codeunit 131002.
FindSetByColumnNo@125 | The procedure FindSetByColumnNo is available in codeunit 131002.
FormatDecimalValue@37 | The procedure FormatDecimalValue is available in codeunit 131002.
GetFileName@11 | The procedure GetFileName is available in codeunit 131002.
GetValue@2 | The procedure GetValue is available in codeunit 131002.
GetValue2@30 | The procedure GetValue2 is available in codeunit 131002.
GetValueAt@28 | The procedure GetValueAt is available in codeunit 131002.
GetValueAtFromWorksheet@34 | The procedure GetValueAtFromWorksheet is available in codeunit 131002.
GetValueByRef@59 | The procedure GetValueByRef is available in codeunit 131002.
GetValueFromSpecifiedCellOnWorksheet@38 | The procedure GetValueFromSpecifiedCellOnWorksheet is available in codeunit 131002.
IsEmptyCell@21 | The procedure IsEmptyCell is available in codeunit 131002.
OpenBookAsExcel@33 | The procedure OpenBookAsExcel is available in codeunit 131002.
OpenExcelFile@41 | The procedure OpenExcelFile is available in codeunit 131002.
OpenFile@9 | The procedure OpenFile is available in codeunit 131002.
SetColumn@13 | The procedure SetColumn is available in codeunit 131002.
SetFileName@10 | The procedure SetFileName is available in codeunit 131002.
SetFixedColumn@24 | The procedure SetFixedColumn is available in codeunit 131002.
SetFullFileName@32 | The procedure SetFullFileName is available in codeunit 131002.
SetRange@12 | The procedure SetRange is available in codeunit 131002.
VerifyCellValue@36 | The procedure VerifyCellValue is available in codeunit 131002.
VerifyCellValueByRef@132 | The procedure VerifyCellValueByRef is available in codeunit 131002.
VerifyCellValueOnWorksheet@35 | The procedure VerifyCellValueOnWorksheet is available in codeunit 131002.
VerifyEmptyCellByRef@14 | The procedure VerifyEmptyCellByRef is available in codeunit 131002.

See Also

Lib


CheckIfDecimalValueExists@39 Method

The procedure CheckIfDecimalValueExists is available in codeunit 131002.

Syntax

CheckIfDecimalValueExists@39(
    Value@1000 : Decimal Value //Input parameter of type Decimal
);

Parameters

Value
Input parameter of type Decimal

Return Value

Boolean

Remarks

The relevant search keywords are: Check, If, Decimal, Value, Exists.

For a clarification about how this function works, refer to the code listed below.

      EXIT(CheckIfValueExists(FormatDecimalValue(Value)));

Example

The below example is extracted from the test automation codeunit 134978 to show one way of using this function.

      Assert.IsTrue(
        LibraryReportValidation.CheckIfDecimalValueExists(Amount),STRSUBSTNO(ExistErr,Amount));
      Assert.IsTrue(
        LibraryReportValidation.CheckIfDecimalValueExists(Amount2),
        STRSUBSTNO(ExistErr,Amount2));
      Assert.IsTrue(
        LibraryReportValidation.CheckIfDecimalValueExists(Amount + Amount2),
        STRSUBSTNO(ExistErr,Amount + Amount2));
      Assert.IsTrue(
        LibraryReportValidation.CheckIfDecimalValueExists(DepreciationAmount),
        STRSUBSTNO(ExistErr,DepreciationAmount));
      Assert.IsTrue(
        LibraryReportValidation.CheckIfDecimalValueExists(DepreciationAmount2),
        STRSUBSTNO(ExistErr,DepreciationAmount2));
      Assert.IsTrue(
        LibraryReportValidation.CheckIfDecimalValueExists(DepreciationAmount + DepreciationAmount2),
        STRSUBSTNO(ExistErr,DepreciationAmount + DepreciationAmount2));
Member of Lib.Library - Report Validation


CheckIfValueExists@18 Method

The procedure CheckIfValueExists is available in codeunit 131002.

Syntax

CheckIfValueExists@18(
    ColumnValue@1000 : Text ColumnValue //Input parameter of type Text
);

Parameters

ColumnValue
Input parameter of type Text

Return Value

Boolean

Remarks

The relevant search keywords are: Check, If, Value, Exists.

For a clarification about how this function works, refer to the code listed below.

      IF NOT FileOpened THEN
        OpenFile;

      FilterExcelBuffer(ExcelBuffer,ColumnValue);
      EXIT(ExcelBuffer.FINDFIRST);

Example

The below example is extracted from the test automation codeunit 134904 to show one way of using this function.

      // [SCENARIO 252587] Interest Amount is printed with Issued Reminder when begin text exist
      Initialize;

      // [GIVEN] Reminder with Interest amount "RM" and Beginning Text = "AAA"
      // [GIVEN] "RM" is issued
      CreateIssuedReminderWithInterestAmount(IssuedReminderHeader);

      // [WHEN] Print issued "RM"
      COMMIT;
      LibraryReportValidation.SetFileName(LibraryUtility.GenerateGUID);
      IssuedReminderHeader.SETRECFILTER;
      Reminder.SETTABLEVIEW(IssuedReminderHeader);
      Reminder.SAVEASEXCEL(LibraryReportValidation.GetFileName);

      // [THEN] Interest amount is printed
      LibraryReportValidation.OpenExcelFile;
      Assert.IsTrue(LibraryReportValidation.CheckIfValueExists('Interest Amount'),'Interest Amount must be printed');
Member of Lib.Library - Report Validation


CheckIfValueExistsInSpecifiedColumn@25 Method

The procedure CheckIfValueExistsInSpecifiedColumn is available in codeunit 131002.

Syntax

CheckIfValueExistsInSpecifiedColumn@25(
    Column@1000 : Text[250] Column, //Input parameter of type Text
    ColumnValue@1001 : Text[250] ColumnValue //Input parameter of type Text
);

Parameters

Column
Input parameter of type Text
ColumnValue
Input parameter of type Text

Return Value

Boolean

Remarks

The relevant search keywords are: Check, If, Value, Exists, In, Specified, Column.

For a clarification about how this function works, refer to the code listed below.

      IF NOT FileOpened THEN
        OpenFile;

      ExcelBuffer.SETRANGE(xlColID,Column);
      ExcelBuffer.SETRANGE("Cell Value as Text",ColumnValue);

      EXIT(ExcelBuffer.FINDFIRST);

Example

There are no examples available.
Member of Lib.Library - Report Validation


CheckIfValueExistsOnSpecifiedWorksheet@29 Method

The procedure CheckIfValueExistsOnSpecifiedWorksheet is available in codeunit 131002.

Syntax

CheckIfValueExistsOnSpecifiedWorksheet@29(
    WorksheetNo@1001 : Integer WorksheetNo, //Input parameter of type Integer
    ColumnValue@1000 : Text[250] ColumnValue //Input parameter of type Text
);

Parameters

WorksheetNo
Input parameter of type Integer
ColumnValue
Input parameter of type Text

Return Value

Boolean

Remarks

The relevant search keywords are: Check, If, Value, Exists, On, Specified, Worksheet.

For a clarification about how this function works, refer to the code listed below.

      IF NOT FileOpened THEN
        OpenFile;

      ExcelBuffer.SETRANGE(Comment,FORMAT(WorksheetNo));
      ExcelBuffer.SETRANGE("Cell Value as Text",ColumnValue);

      EXIT(ExcelBuffer.FINDFIRST);

Example

There are no examples available.
Member of Lib.Library - Report Validation


CountColumns@19 Method

The procedure CountColumns is available in codeunit 131002.

Syntax

CountColumns@19(
      //param element not supplied
);

Return Value

Integer

Remarks

The relevant search keywords are: Count, Columns.

For a clarification about how this function works, refer to the code listed below.

      // Count the number of Columns.
      IF NOT FileOpened THEN
        OpenFile;

      IF ExcelBuffer.FINDSET THEN
        REPEAT
          TempExcelBuffer.INIT;
          TempExcelBuffer."Column No." := ExcelBuffer."Column No.";
          IF TempExcelBuffer.INSERT THEN;
        UNTIL ExcelBuffer.NEXT = 0;
      EXIT(TempExcelBuffer.COUNT);

Example

There are no examples available.
Member of Lib.Library - Report Validation


CountDistinctRows@8 Method

The procedure CountDistinctRows is available in codeunit 131002.

Syntax

CountDistinctRows@8(
    VAR ExcelBuffer@1000 : Record 370 ExcelBuffer //Reference parameter of type Record
);

Parameters

ExcelBuffer
Reference parameter of type Record

Return Value

Integer

Remarks

The relevant search keywords are: Count, Distinct, Rows.

For a clarification about how this function works, refer to the code listed below.

      IF NOT FileOpened THEN
        OpenFile;

      IF ExcelBuffer.FINDSET THEN
        REPEAT
          TempExcelBuffer.INIT;
          TempExcelBuffer."Row No." := ExcelBuffer."Row No.";
          IF TempExcelBuffer.INSERT THEN;
        UNTIL ExcelBuffer.NEXT = 0;
      EXIT(TempExcelBuffer.COUNT);

Example

There are no examples available.
Member of Lib.Library - Report Validation


CountRows@7 Method

The procedure CountRows is available in codeunit 131002.

Syntax

CountRows@7(
      //param element not supplied
);

Return Value

Integer

Remarks

The relevant search keywords are: Count, Rows.

For a clarification about how this function works, refer to the code listed below.

      // Count the number of rows for where a given Column has the value specified.
      IF NOT FileOpened THEN
        OpenFile;

      ExcelBuffer.SETRANGE("Column No.",FindColumnNoFromColumnCaption(FilterColumnCaption));
      ExcelBuffer.SETRANGE("Cell Value as Text",FilterColumnValue);
      EXIT(CountDistinctRows(ExcelBuffer));

Example

There are no examples available.
Member of Lib.Library - Report Validation


CountRowsBetweenColumnCaptions@5 Method

The procedure CountRowsBetweenColumnCaptions is available in codeunit 131002.

Syntax

CountRowsBetweenColumnCaptions@5(
    ColumnCaptionFrom@1000 : Text[250] ColumnCaptionFrom, //Input parameter of type Text
    ColumnCaptionTo@1001 : Text[250] ColumnCaptionTo //Input parameter of type Text
);

Parameters

ColumnCaptionFrom
Input parameter of type Text
ColumnCaptionTo
Input parameter of type Text

Return Value

Integer

Remarks

The relevant search keywords are: Count, Rows, Between, Column, Captions.

For a clarification about how this function works, refer to the code listed below.

      IF NOT FileOpened THEN
        OpenFile;

      ExcelBuffer.SETFILTER(
        "Row No.",'>%1 & <%2',FindRowNoFromColumnCaption(ColumnCaptionFrom),FindRowNoFromColumnCaption(ColumnCaptionTo));
      EXIT(CountDistinctRows(ExcelBuffer));

Example

There are no examples available.
Member of Lib.Library - Report Validation


CountWorksheets@26 Method

The procedure CountWorksheets is available in codeunit 131002.

Syntax

CountWorksheets@26(
      //param element not supplied
);

Return Value

Integer

Remarks

The relevant search keywords are: Count, Worksheets.

For a clarification about how this function works, refer to the code listed below.

      // Count the number of Worksheets.
      IF NOT FileOpened THEN
        OpenFile;

      EXIT(WorksheetCount);

Example

There are no examples available.
Member of Lib.Library - Report Validation


DownloadFile@40 Method

The procedure DownloadFile is available in codeunit 131002.

Syntax

DownloadFile@40(
      //param element not supplied
);

Remarks

The relevant search keywords are: Download, File.

For a clarification about how this function works, refer to the code listed below.

      SetFullFileName(GetFileName);

Example

The below example is extracted from the test automation codeunit 134335 to show one way of using this function.

      // Verify that purchase quote report shows line where type is blank.

      // Setup: Create purchase quote with type blank.
      Initialize;
      CreatePurchaseQuoteWithMultipleLine(PurchaseHeader);
      LibraryVariableStorage.Enqueue(PurchaseHeader."No.");

      // Exercise: Run Purchase-Quote report.
      PurchaseHeader.SETRANGE("No.",PurchaseHeader."No.");
      COMMIT;
      REPORT.RUN(REPORT::"Purchase - Quote",TRUE,FALSE,PurchaseHeader);

      // Verify: Verifying that both line exists on report.
      LibraryReportValidation.DownloadFile;
      LibraryReportValidation.OpenFile;
      LibraryReportValidation.SetRange(PurchaseLine.FIELDCAPTION(Description),PurchaseHeader."No.");
      Assert.AreEqual(2,LibraryReportValidation.CountRows,NumberOfRowsErr);
Member of Lib.Library - Report Validation


FindColumnNoFromColumnCaption@4 Method

The procedure FindColumnNoFromColumnCaption is available in codeunit 131002.

Syntax

FindColumnNoFromColumnCaption@4(
    ColumnCaption@1000 : Text[250] ColumnCaption //Input parameter of type Text
);

Parameters

ColumnCaption
Input parameter of type Text

Return Value

Integer

Remarks

The relevant search keywords are: Find, Column, No, From, Column, Caption.

For a clarification about how this function works, refer to the code listed below.

      IF NOT FileOpened THEN
        OpenFile;

      IF FixedColumnNo <> 0 THEN
        EXIT(FixedColumnNo);

      FilterExcelBuffer(ExcelBuffer,ColumnCaption);
      IF ExcelBuffer.FINDFIRST THEN
        EXIT(ExcelBuffer."Column No.");
      ERROR(STRSUBSTNO(ColumnNotFoundError,ColumnCaption));

Example

The below example is extracted from the test automation codeunit 137301 to show one way of using this function.

      // [FEATURE] [Inventory Valuation]
      // [SCENARIO 378286] Expected cost line should not be shown in the report "Inventory Valuation" when expected amount is 0.
      // [GIVEN] Create item
      LibraryInventory.CreateItem(Item);

      // [GIVEN] Post purchase order as received and invoiced
      CreatePurchaseOrder(PurchaseHeader,Item."No.",LibraryRandom.RandDec(100,2),LibraryRandom.RandDec(100,2),1);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

      // [WHEN] Run report "Inventory Valuation" with parameter "Include expected cost" = TRUE
      SaveAsExcelInventoryValuationReport(Item."No.");

      // [THEN] The string with description "Expected Cost Included" shouldn't be in this report for created item
      RowNo := LibraryReportValidation.FindRowNoFromColumnNoAndValue(
          LibraryReportValidation.FindColumnNoFromColumnCaption('Item No.'),Item."No.");
      Assert.AreNotEqual(
        'Expected Cost Included',LibraryReportValidation.GetValueAt(ValueFound,RowNo + 1,
          LibraryReportValidation.FindColumnNoFromColumnCaption('Description')),IncorrectValueInCellErr);
Member of Lib.Library - Report Validation


FindColumnNoFromColumnCaptionInsideArea@27 Method

The procedure FindColumnNoFromColumnCaptionInsideArea is available in codeunit 131002.

Syntax

FindColumnNoFromColumnCaptionInsideArea@27(
    ColumnCaption@1000 : Text[250] ColumnCaption, //Input parameter of type Text
    FilterRowNo@1003 : Text[250] FilterRowNo, //Input parameter of type Text
    FilterColumnNo@1002 : Text[250] FilterColumnNo //Input parameter of type Text
);

Parameters

ColumnCaption
Input parameter of type Text
FilterRowNo
Input parameter of type Text
FilterColumnNo
Input parameter of type Text

Return Value

Integer

Remarks

The relevant search keywords are: Find, Column, No, From, Column, Caption, Inside, Area.

For a clarification about how this function works, refer to the code listed below.

      IF NOT FileOpened THEN
        OpenFile;

      IF FixedColumnNo <> 0 THEN
        EXIT(FixedColumnNo);

      ExcelBuffer.SETFILTER("Row No.",FilterRowNo);
      ExcelBuffer.SETFILTER("Column No.",FilterColumnNo);
      FilterExcelBuffer(ExcelBuffer,ColumnCaption);
      IF ExcelBuffer.FINDFIRST THEN
        EXIT(ExcelBuffer."Column No.");
      ERROR(STRSUBSTNO(ColumnNotFoundError,ColumnCaption));

Example

There are no examples available.
Member of Lib.Library - Report Validation


FindFirstColumnNoByValue@104 Method

The procedure FindFirstColumnNoByValue is available in codeunit 131002.

Syntax

FindFirstColumnNoByValue@104(
    Value@1000 : Text[250] Value //Input parameter of type Text
);

Parameters

Value
Input parameter of type Text

Return Value

Integer

Remarks

The relevant search keywords are: Find, First, Column, No, By, Value.

For a clarification about how this function works, refer to the code listed below.

      IF NOT FileOpened THEN
        OpenFile;

      IF FixedColumnNo <> 0 THEN
        EXIT(FixedColumnNo);

      ExcelBuffer.SETRANGE("Cell Value as Text",Value);
      IF ExcelBuffer.FINDFIRST THEN
        EXIT(ExcelBuffer."Column No.");
      ERROR(STRSUBSTNO(ColumnNotFoundError,Value));

Example

There are no examples available.
Member of Lib.Library - Report Validation


FindFirstRow@20 Method

The procedure FindFirstRow is available in codeunit 131002.

Syntax

FindFirstRow@20(
    VAR RowValueSet@1000 : ARRAY [50] OF Text[250] RowValueSet //Reference Array parameter of type Text
);

Parameters

RowValueSet
Reference Array parameter of type Text

Remarks

The relevant search keywords are: Find, First, Row.

For a clarification about how this function works, refer to the code listed below.

      // Retrieve the first row.
      IF NOT FileOpened THEN
        OpenFile;

      Counter := 1;
      IF FilterColumnCaption <> '' THEN BEGIN
        ExcelBuffer.SETRANGE("Column No.",FindColumnNoFromColumnCaption(FilterColumnCaption));
        ExcelBuffer.SETRANGE("Cell Value as Text",FilterColumnValue);
      END;
      IF ExcelBuffer.FINDFIRST THEN BEGIN
        ExcelBuffer2.SETRANGE("Row No.",ExcelBuffer."Row No.");
        IF ExcelBuffer2.FINDSET THEN
          REPEAT
            RowValueSet[Counter] := ExcelBuffer2."Cell Value as Text";
            Counter += 1;
          UNTIL ExcelBuffer2.NEXT = 0;
        RowNumber := ExcelBuffer."Row No.";
      END;
      IF Counter = 1 THEN
        ERROR(RowNotFoundError);

Example

There are no examples available.
Member of Lib.Library - Report Validation


FindNextRow@22 Method

The procedure FindNextRow is available in codeunit 131002.

Syntax

FindNextRow@22(
    VAR RowValueSet@1000 : ARRAY [50] OF Text[250] RowValueSet //Reference Array parameter of type Text
);

Parameters

RowValueSet
Reference Array parameter of type Text

Remarks

The relevant search keywords are: Find, Next, Row.

For a clarification about how this function works, refer to the code listed below.

      // Retrieve the next row.
      IF NOT FileOpened THEN
        OpenFile;

      Counter := 1;
      IF FilterColumnCaption <> '' THEN BEGIN
        ExcelBuffer.SETRANGE("Column No.",FindColumnNoFromColumnCaption(FilterColumnCaption));
        ExcelBuffer.SETRANGE("Cell Value as Text",FilterColumnValue);
      END;

      ExcelBuffer.SETFILTER("Row No.",'>%1',RowNumber);
      IF ExcelBuffer.FINDFIRST THEN BEGIN
        ExcelBuffer2.SETRANGE("Row No.",ExcelBuffer."Row No.");
        IF ExcelBuffer2.FINDSET THEN
          REPEAT
            RowValueSet[Counter] := ExcelBuffer2."Cell Value as Text";
            Counter += 1;
          UNTIL ExcelBuffer2.NEXT = 0;
        RowNumber := ExcelBuffer."Row No.";
      END;
      IF Counter = 1 THEN
        ERROR(RowNotFoundError);

Example

There are no examples available.
Member of Lib.Library - Report Validation


FindRowNoFromColumnCaption@6 Method

The procedure FindRowNoFromColumnCaption is available in codeunit 131002.

Syntax

FindRowNoFromColumnCaption@6(
    ColumnCaption@1000 : Text[250] ColumnCaption //Input parameter of type Text
);

Parameters

ColumnCaption
Input parameter of type Text

Return Value

Integer

Remarks

The relevant search keywords are: Find, Row, No, From, Column, Caption.

For a clarification about how this function works, refer to the code listed below.

      IF NOT FileOpened THEN
        OpenFile;

      FilterExcelBuffer(ExcelBuffer,ColumnCaption);
      IF ExcelBuffer.FINDFIRST THEN
        EXIT(ExcelBuffer."Row No.");
      ERROR(STRSUBSTNO(ColumnNotFoundError,ColumnCaption));

Example

There are no examples available.
Member of Lib.Library - Report Validation


FindRowNoFromColumnNoAndValue@3 Method

The procedure FindRowNoFromColumnNoAndValue is available in codeunit 131002.

Syntax

FindRowNoFromColumnNoAndValue@3(
    ColumnNo@1000 : Integer ColumnNo, //Input parameter of type Integer
    ColumnValue@1001 : Text[250] ColumnValue //Input parameter of type Text
);

Parameters

ColumnNo
Input parameter of type Integer
ColumnValue
Input parameter of type Text

Return Value

Integer

Remarks

The relevant search keywords are: Find, Row, No, From, Column, No, Value.

For a clarification about how this function works, refer to the code listed below.

      IF NOT FileOpened THEN
        OpenFile;

      ExcelBuffer.SETRANGE("Column No.",ColumnNo);
      ExcelBuffer.SETRANGE("Cell Value as Text",ColumnValue);
      IF ExcelBuffer.FINDFIRST THEN
        EXIT(ExcelBuffer."Row No.");
      ERROR(STRSUBSTNO(RowNotFoundForColumnValueError,ColumnNo,ColumnValue));

Example

The below example is extracted from the test automation codeunit 137301 to show one way of using this function.

      // [FEATURE] [Inventory Valuation]
      // [SCENARIO 378286] Expected cost line should not be shown in the report "Inventory Valuation" when expected amount is 0.
      // [GIVEN] Create item
      LibraryInventory.CreateItem(Item);

      // [GIVEN] Post purchase order as received and invoiced
      CreatePurchaseOrder(PurchaseHeader,Item."No.",LibraryRandom.RandDec(100,2),LibraryRandom.RandDec(100,2),1);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

      // [WHEN] Run report "Inventory Valuation" with parameter "Include expected cost" = TRUE
      SaveAsExcelInventoryValuationReport(Item."No.");

      // [THEN] The string with description "Expected Cost Included" shouldn't be in this report for created item
      RowNo := LibraryReportValidation.FindRowNoFromColumnNoAndValue(
          LibraryReportValidation.FindColumnNoFromColumnCaption('Item No.'),Item."No.");
      Assert.AreNotEqual(
        'Expected Cost Included',LibraryReportValidation.GetValueAt(ValueFound,RowNo + 1,
          LibraryReportValidation.FindColumnNoFromColumnCaption('Description')),IncorrectValueInCellErr);
Member of Lib.Library - Report Validation


FindRowNoFromColumnNoAndValueInsideArea@31 Method

The procedure FindRowNoFromColumnNoAndValueInsideArea is available in codeunit 131002.

Syntax

FindRowNoFromColumnNoAndValueInsideArea@31(
    ColumnNo@1000 : Integer ColumnNo, //Input parameter of type Integer
    ColumnValue@1001 : Text[250] ColumnValue, //Input parameter of type Text
    FilterRowNo@1004 : Text[250] FilterRowNo //Input parameter of type Text
);

Parameters

ColumnNo
Input parameter of type Integer
ColumnValue
Input parameter of type Text
FilterRowNo
Input parameter of type Text

Return Value

Integer

Remarks

The relevant search keywords are: Find, Row, No, From, Column, No, Value, Inside, Area.

For a clarification about how this function works, refer to the code listed below.

      IF NOT FileOpened THEN
        OpenFile;

      ExcelBuffer.SETFILTER("Row No.",FilterRowNo);
      ExcelBuffer.SETRANGE("Column No.",ColumnNo);
      ExcelBuffer.SETRANGE("Cell Value as Text",ColumnValue);
      IF ExcelBuffer.FINDFIRST THEN
        EXIT(ExcelBuffer."Row No.");
      ERROR(STRSUBSTNO(RowNotFoundForColumnValueError,ColumnNo,ColumnValue));

Example

There are no examples available.
Member of Lib.Library - Report Validation


FindSet@15 Method

The procedure FindSet is available in codeunit 131002.

Syntax

FindSet@15(
    VAR ColumnValueSet@1000 : ARRAY [250] OF Text[250] ColumnValueSet //Reference Array parameter of type Text
);

Parameters

ColumnValueSet
Reference Array parameter of type Text

Remarks

The relevant search keywords are: Find, Set.

For a clarification about how this function works, refer to the code listed below.

      // Retrieve all the values in a Column where another given Column has the value specified.
      IF NOT FileOpened THEN
        OpenFile;

      IF FilterColumnCaption <> '' THEN BEGIN
        ExcelBuffer.SETRANGE("Column No.",FindColumnNoFromColumnCaption(FilterColumnCaption));
        ExcelBuffer.SETRANGE("Cell Value as Text",FilterColumnValue);
      END;

      FindSetByFilters(ExcelBuffer,FindColumnNoFromColumnCaption(ColumnCaption),ColumnValueSet);

Example

The below example is extracted from the test automation codeunit 134978 to show one way of using this function.

      LibraryReportValidation.OpenFile;
      LibraryReportValidation.SetColumn(ColumnValue);
      LibraryReportValidation.FindSet(Amount);
      Assert.IsTrue(FindValueInArray(Amount,FORMAT(FAJournalLineAmount)),ErrorMessage);
Member of Lib.Library - Report Validation


FindSetByColumnNo@125 Method

The procedure FindSetByColumnNo is available in codeunit 131002.

Syntax

FindSetByColumnNo@125(
    ColumnNo@1001 : Integer ColumnNo, //Input parameter of type Integer
    VAR ColumnValueSet@1000 : ARRAY [250] OF Text[250] ColumnValueSet //Reference Array parameter of type Text
);

Parameters

ColumnNo
Input parameter of type Integer
ColumnValueSet
Reference Array parameter of type Text

Remarks

The relevant search keywords are: Find, Set, By, Column, No.

For a clarification about how this function works, refer to the code listed below.

      IF NOT FileOpened THEN
        OpenFile;

      ExcelBuffer.SETRANGE("Column No.",ColumnNo);
      FindSetByFilters(ExcelBuffer,ColumnNo,ColumnValueSet);

Example

There are no examples available.
Member of Lib.Library - Report Validation


FormatDecimalValue@37 Method

The procedure FormatDecimalValue is available in codeunit 131002.

Syntax

FormatDecimalValue@37(
    Value@1000 : Decimal Value //Input parameter of type Decimal
);

Parameters

Value
Input parameter of type Decimal

Return Value

Text

Remarks

The relevant search keywords are: Format, Decimal, Value.

For a clarification about how this function works, refer to the code listed below.

      EXIT(FORMAT(Value,0,GetDefaultDecimalFormat));

Example

The below example is extracted from the test automation codeunit 134335 to show one way of using this function.

      LibraryReportValidation.OpenExcelFile;
      LibraryReportValidation.VerifyCellValueByRef(ColumnName,RowNo,1,LibraryReportValidation.FormatDecimalValue(TotalVATAmount));
      LibraryReportValidation.VerifyCellValueByRef(ColumnName,RowNo + 1,1,LibraryReportValidation.FormatDecimalValue(TotalBaseAmount));
Member of Lib.Library - Report Validation


GetFileName@11 Method

The procedure GetFileName is available in codeunit 131002.

Syntax

GetFileName@11(
      //param element not supplied
);

Return Value

Text[1024]

Remarks

The relevant search keywords are: Get, File, Name.

For a clarification about how this function works, refer to the code listed below.

      IF FullFileName = '' THEN
        EXIT(TEMPORARYPATH + FileNameTo + '.xlsx');
      EXIT(FullFileName);

Example

The below example is extracted from the test automation codeunit 134922 to show one way of using this function.

      // Verify that G/L Budget can export to Excel Buffer correctly.

      Initialize;
      GLBudgetName.FINDFIRST;
      LibraryReportValidation.SetFileName(GLBudgetName.Name);
      FileName := LibraryReportValidation.GetFileName;

      // Execute
      EVALUATE(PeriodLength,'<1Y>');
      GLBudgetEntry.SETRANGE("Budget Name",GLBudgetName.Name);
      ExportBudgetToExcel.SetFileNameSilent(FileName);
      ExportBudgetToExcel.SetParameters(DMY2DATE(1,1,2016),1,PeriodLength,0);
      ExportBudgetToExcel.SetTestMode(TRUE);
      ExportBudgetToExcel.SETTABLEVIEW(GLBudgetEntry);
      ExportBudgetToExcel.USEREQUESTPAGE(FALSE);
      ExportBudgetToExcel.RUN;
      CLEAR(ExportBudgetToExcel);

      // Verify
      LibraryERM.CreateGLBudgetName(GLBudgetName2);
      ImportBudgetFromExcel.SetParameters(GLBudgetName2.Name,1); // Add entries
      ImportBudgetFromExcel.SetFileName(FileName);
      ImportBudgetFromExcel.USEREQUESTPAGE(FALSE);
      ImportBudgetFromExcel.RUN;
Member of Lib.Library - Report Validation


GetValue@2 Method

The procedure GetValue is available in codeunit 131002.

Syntax

GetValue@2(
      //param element not supplied
);

Return Value

Text[250]

Remarks

The relevant search keywords are: Get, Value.

For a clarification about how this function works, refer to the code listed below.

      // Retrieve the value of a Column where another given Column has the value specified.
      // Throws an error if the cell doesnt contain a value
      // To check whether a cell contains a value or not, use function IsEmptyCell()

      IF NOT FileOpened THEN
        OpenFile;

      IF ExcelBuffer.GET(
           FindRowNoFromColumnNoAndValue(FindColumnNoFromColumnCaption(FilterColumnCaption),FilterColumnValue),
           FindColumnNoFromColumnCaption(ColumnCaption))
      THEN
        EXIT(ExcelBuffer."Cell Value as Text");

      ERROR(ValueNotFoundError);

Example

There are no examples available.
Member of Lib.Library - Report Validation


GetValue2@30 Method

The procedure GetValue2 is available in codeunit 131002.

Syntax

GetValue2@30(
    VAR FoundValue@1005 : Boolean FoundValue, //Reference parameter of type Boolean
    FilterRowNo@1004 : Text[250] FilterRowNo, //Input parameter of type Text
    FilterColumnNo@1002 : Text[250] FilterColumnNo //Input parameter of type Text
);

Parameters

FoundValue
Reference parameter of type Boolean
FilterRowNo
Input parameter of type Text
FilterColumnNo
Input parameter of type Text

Return Value

Text[250]

Remarks

The relevant search keywords are: Get, Value2.

For a clarification about how this function works, refer to the code listed below.

      // Retrieve the value of a Column where another given Column has the value specified.

      IF NOT FileOpened THEN
        OpenFile;

      ColumnNo := FindColumnNoFromColumnCaptionInsideArea(ColumnCaption,FilterRowNo,FilterColumnNo);
      RowNo := FindRowNoFromColumnNoAndValueInsideArea(FindColumnNoFromColumnCaptionInsideArea(
            FilterColumnCaption,FilterRowNo,FilterColumnNo),FilterColumnValue,FilterRowNo);

      FoundValue := TRUE;
      IF ExcelBuffer.GET(RowNo,ColumnNo)
      THEN
        EXIT(ExcelBuffer."Cell Value as Text");

      FoundValue := FALSE;
      EXIT('');

Example

There are no examples available.
Member of Lib.Library - Report Validation


GetValueAt@28 Method

The procedure GetValueAt is available in codeunit 131002.

Syntax

GetValueAt@28(
    VAR FoundValue@1005 : Boolean FoundValue, //Reference parameter of type Boolean
    RowNo@1004 : Integer RowNo, //Input parameter of type Integer
    ColumnNo@1002 : Integer ColumnNo //Input parameter of type Integer
);

Parameters

FoundValue
Reference parameter of type Boolean
RowNo
Input parameter of type Integer
ColumnNo
Input parameter of type Integer

Return Value

Text[250]

Remarks

The relevant search keywords are: Get, Value, At.

For a clarification about how this function works, refer to the code listed below.

      // Retrieve the value of a Column where another given Column has the value specified.
      // Throws an error if the cell doesnt contain a value
      // To check whether a cell contains a value or not, use function IsEmptyCell()

      IF NOT FileOpened THEN
        OpenFile;

      FoundValue := TRUE;
      IF ExcelBuffer.GET(RowNo,ColumnNo)
      THEN
        EXIT(ExcelBuffer."Cell Value as Text");

      FoundValue := FALSE;
      EXIT('');

Example

The below example is extracted from the test automation codeunit 137301 to show one way of using this function.

      // [FEATURE] [Inventory Valuation]
      // [SCENARIO 378286] Expected cost line should not be shown in the report "Inventory Valuation" when expected amount is 0.
      // [GIVEN] Create item
      LibraryInventory.CreateItem(Item);

      // [GIVEN] Post purchase order as received and invoiced
      CreatePurchaseOrder(PurchaseHeader,Item."No.",LibraryRandom.RandDec(100,2),LibraryRandom.RandDec(100,2),1);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

      // [WHEN] Run report "Inventory Valuation" with parameter "Include expected cost" = TRUE
      SaveAsExcelInventoryValuationReport(Item."No.");

      // [THEN] The string with description "Expected Cost Included" shouldn't be in this report for created item
      RowNo := LibraryReportValidation.FindRowNoFromColumnNoAndValue(
          LibraryReportValidation.FindColumnNoFromColumnCaption('Item No.'),Item."No.");
      Assert.AreNotEqual(
        'Expected Cost Included',LibraryReportValidation.GetValueAt(ValueFound,RowNo + 1,
          LibraryReportValidation.FindColumnNoFromColumnCaption('Description')),IncorrectValueInCellErr);
Member of Lib.Library - Report Validation


GetValueAtFromWorksheet@34 Method

The procedure GetValueAtFromWorksheet is available in codeunit 131002.

Syntax

GetValueAtFromWorksheet@34(
    RowNo@1004 : Integer RowNo, //Input parameter of type Integer
    ColumnNo@1002 : Integer ColumnNo, //Input parameter of type Integer
    Worksheet@1006 : Text Worksheet //Input parameter of type Text
);

Parameters

RowNo
Input parameter of type Integer
ColumnNo
Input parameter of type Integer
Worksheet
Input parameter of type Text

Return Value

Text[250]

Remarks

The relevant search keywords are: Get, Value, At, From, Worksheet.

For a clarification about how this function works, refer to the code listed below.

      // Retrieve the value of a Column from a specific worksheet where another given Column has the value specified.
      // Throws an error if the cell doesnt contain a value
      // To check whether a cell contains a value or not, use function IsEmptyCell()

      IF NOT FileOpened THEN
        OpenFile;

      IF ExcelBuffer.GET(RowNo,ColumnNo) AND (ExcelBuffer.Comment = Worksheet)
      THEN
        EXIT(ExcelBuffer."Cell Value as Text");

      EXIT('');

Example

There are no examples available.
Member of Lib.Library - Report Validation


GetValueByRef@59 Method

The procedure GetValueByRef is available in codeunit 131002.

Syntax

GetValueByRef@59(
    ColumnName@1000 : Text ColumnName, //Input parameter of type Text
    RowNo@1004 : Integer RowNo, //Input parameter of type Integer
    WorksheetNo@1001 : Integer WorksheetNo //Input parameter of type Integer
);

Parameters

ColumnName
Input parameter of type Text
RowNo
Input parameter of type Integer
WorksheetNo
Input parameter of type Integer

Return Value

Text

Remarks

The relevant search keywords are: Get, Value, By, Ref.

For a clarification about how this function works, refer to the code listed below.

      IF NOT FileOpened THEN
        OpenFile;

      ExcelBuffer.SETRANGE(xlColID,ColumnName);
      ExcelBuffer.SETRANGE(xlRowID,FORMAT(RowNo));
      ExcelBuffer.SETRANGE(Comment,FORMAT(WorksheetNo));
      IF ExcelBuffer.FINDFIRST THEN;

      EXIT(ExcelBuffer."Cell Value as Text");

Example

There are no examples available.
Member of Lib.Library - Report Validation


GetValueFromSpecifiedCellOnWorksheet@38 Method

The procedure GetValueFromSpecifiedCellOnWorksheet is available in codeunit 131002.

Syntax

GetValueFromSpecifiedCellOnWorksheet@38(
    WorksheetNo@1000 : Integer WorksheetNo, //Input parameter of type Integer
    RowId@1001 : Integer RowId, //Input parameter of type Integer
    ColumnId@1002 : Integer ColumnId //Input parameter of type Integer
);

Parameters

WorksheetNo
Input parameter of type Integer
RowId
Input parameter of type Integer
ColumnId
Input parameter of type Integer

Return Value

Text

Remarks

The relevant search keywords are: Get, Value, From, Specified, Cell, On, Worksheet.

For a clarification about how this function works, refer to the code listed below.

      // Checks the value in specified cell within specified worksheet (note the function requires row number within worksheet not report).
      IF NOT FileOpened THEN
        OpenFile;

      IF WorksheetNo > 1 THEN BEGIN
        ExcelBuffer.SETRANGE(Comment,FORMAT(WorksheetNo - 1));
        ExcelBuffer.FINDLAST;
        IF ExcelBuffer."Row No." > 0 THEN
          RowId += ExcelBuffer."Row No." - 1;
      END;

      ExcelBuffer.GET(RowId,ColumnId);
      EXIT(ExcelBuffer."Cell Value as Text");

Example

There are no examples available.
Member of Lib.Library - Report Validation


IsEmptyCell@21 Method

The procedure IsEmptyCell is available in codeunit 131002.

Syntax

IsEmptyCell@21(
      //param element not supplied
);

Return Value

Boolean

Remarks

The relevant search keywords are: Is, Empty, Cell.

For a clarification about how this function works, refer to the code listed below.

      // Returns true if a cell, specified by SetRange and SetColumn, is empty,
      // otherwise false.

      IF NOT FileOpened THEN
        OpenFile;

      EXIT(
        NOT ExcelBuffer.GET(FindRowNoFromColumnNoAndValue(FindColumnNoFromColumnCaption(FilterColumnCaption),FilterColumnValue),
          FindColumnNoFromColumnCaption(ColumnCaption)));

Example

There are no examples available.
Member of Lib.Library - Report Validation


OpenBookAsExcel@33 Method

The procedure OpenBookAsExcel is available in codeunit 131002.

Syntax

OpenBookAsExcel@33(
    ClientFileName@1000 : Text ClientFileName //Input parameter of type Text
);

Parameters

ClientFileName
Input parameter of type Text

Remarks

The relevant search keywords are: Open, Book, As, Excel.

For a clarification about how this function works, refer to the code listed below.

      FileMgt.ServerFileExists(ClientFileName);

      ExcelBuffer.DELETEALL;

      WorkbookReader := WorkbookReader.Open(ClientFileName,FALSE);

      ValueMaxLength := MAXSTRLEN(Value);
      SheetNames := WorkbookReader.SheetNames;
      WorksheetCount := SheetNames.Length;
      SheetIndex := 0;
      RowOffset := 0;
      WHILE SheetIndex < WorksheetCount DO BEGIN
        WorksheetReader := WorkbookReader.GetWorksheetByName(SheetNames.GetValue(SheetIndex));
        FOREACH CellData IN WorksheetReader DO BEGIN
          RowIndex := CellData.RowNumber;
          ColumnIndex := CellData.ColumnNumber;
          Value := COPYSTR(CellData.Value,1,ValueMaxLength);
          InsertIntoExcelBuffer(RowIndex + RowOffset,ColumnIndex,Value,SheetIndex + 1);
        END;
        RowOffset += RowIndex; // WorksheetReader.RowCount; Excel may have skipped rows in a sheet, so RowCount would be less than RowIndex
        SheetIndex += 1;
      END;

Example

There are no examples available.
Member of Lib.Library - Report Validation


OpenExcelFile@41 Method

The procedure OpenExcelFile is available in codeunit 131002.

Syntax

OpenExcelFile@41(
      //param element not supplied
);

Remarks

The relevant search keywords are: Open, Excel, File.

For a clarification about how this function works, refer to the code listed below.

      FilePath := GetFileName;
      OpenFileAsExcel(FilePath);
      FileOpened := TRUE;

Example

The below example is extracted from the test automation codeunit 134335 to show one way of using this function.

      LibraryReportValidation.OpenExcelFile;
      LibraryReportValidation.VerifyCellValueByRef(ColumnName,RowNo,1,LibraryReportValidation.FormatDecimalValue(TotalVATAmount));
      LibraryReportValidation.VerifyCellValueByRef(ColumnName,RowNo + 1,1,LibraryReportValidation.FormatDecimalValue(TotalBaseAmount));
Member of Lib.Library - Report Validation


OpenFile@9 Method

The procedure OpenFile is available in codeunit 131002.

Syntax

OpenFile@9(
      //param element not supplied
);

Remarks

The relevant search keywords are: Open, File.

For a clarification about how this function works, refer to the code listed below.

      FilePath := GetFileName;
      OpenFileAsExcel(FilePath);
      FileOpened := TRUE;

Example

The below example is extracted from the test automation codeunit 134335 to show one way of using this function.

      // Verify that purchase quote report shows line where type is blank.

      // Setup: Create purchase quote with type blank.
      Initialize;
      CreatePurchaseQuoteWithMultipleLine(PurchaseHeader);
      LibraryVariableStorage.Enqueue(PurchaseHeader."No.");

      // Exercise: Run Purchase-Quote report.
      PurchaseHeader.SETRANGE("No.",PurchaseHeader."No.");
      COMMIT;
      REPORT.RUN(REPORT::"Purchase - Quote",TRUE,FALSE,PurchaseHeader);

      // Verify: Verifying that both line exists on report.
      LibraryReportValidation.DownloadFile;
      LibraryReportValidation.OpenFile;
      LibraryReportValidation.SetRange(PurchaseLine.FIELDCAPTION(Description),PurchaseHeader."No.");
      Assert.AreEqual(2,LibraryReportValidation.CountRows,NumberOfRowsErr);
Member of Lib.Library - Report Validation


SetColumn@13 Method

The procedure SetColumn is available in codeunit 131002.

Syntax

SetColumn@13(
    ColumnCaptionFrom@1000 : Text[250] ColumnCaptionFrom //Input parameter of type Text
);

Parameters

ColumnCaptionFrom
Input parameter of type Text

Remarks

The relevant search keywords are: Set, Column.

For a clarification about how this function works, refer to the code listed below.

      FixedColumnNo := 0;
      ColumnCaption := ColumnCaptionFrom;

Example

The below example is extracted from the test automation codeunit 134978 to show one way of using this function.

      LibraryReportValidation.OpenFile;
      LibraryReportValidation.SetColumn(ColumnValue);
      LibraryReportValidation.FindSet(Amount);
      Assert.IsTrue(FindValueInArray(Amount,FORMAT(FAJournalLineAmount)),ErrorMessage);
Member of Lib.Library - Report Validation


SetFileName@10 Method

The procedure SetFileName is available in codeunit 131002.

Syntax

SetFileName@10(
    FileNameFrom@1000 : Text FileNameFrom //Input parameter of type Text
);

Parameters

FileNameFrom
Input parameter of type Text

Remarks

The relevant search keywords are: Set, File, Name.

For a clarification about how this function works, refer to the code listed below.

      FileNameTo := FileNameFrom;
      FullFileName := '';
      FileOpened := FALSE; // Force reopen of Excel file

Example

The below example is extracted from the test automation codeunit 134335 to show one way of using this function.

      LibraryVariableStorage.Dequeue(PurchaseHeaderNo);
      LibraryReportValidation.SetFileName(PurchaseHeaderNo);
      PurchaseQuote.SAVEASEXCEL(LibraryReportValidation.GetFileName);
Member of Lib.Library - Report Validation


SetFixedColumn@24 Method

The procedure SetFixedColumn is available in codeunit 131002.

Syntax

SetFixedColumn@24(
    Index@1000 : Integer Index //Input parameter of type Integer
);

Parameters

Index
Input parameter of type Integer

Remarks

The relevant search keywords are: Set, Fixed, Column.

For a clarification about how this function works, refer to the code listed below.

      FixedColumnNo := Index;

Example

There are no examples available.
Member of Lib.Library - Report Validation


SetFullFileName@32 Method

The procedure SetFullFileName is available in codeunit 131002.

Syntax

SetFullFileName@32(
    NewFullFileName@1000 : Text NewFullFileName //Input parameter of type Text
);

Parameters

NewFullFileName
Input parameter of type Text

Remarks

The relevant search keywords are: Set, Full, File, Name.

For a clarification about how this function works, refer to the code listed below.

      FullFileName := NewFullFileName;
      FileNameTo := '';
      FileOpened := FALSE; // Force reopen of Excel file

Example

The below example is extracted from the test automation codeunit 136600 to show one way of using this function.

      ServerFileName := FileManagement.UploadFileSilent(ClientFileName);
      LibraryReportValidation.SetFullFileName(ServerFileName);
      LibraryReportValidation.OpenFile;
Member of Lib.Library - Report Validation


SetRange@12 Method

The procedure SetRange is available in codeunit 131002.

Syntax

SetRange@12(
    FilterColumnCaptionFrom@1001 : Text[250] FilterColumnCaptionFrom, //Input parameter of type Text
    FilterColumnValueFrom@1000 : Text[250] FilterColumnValueFrom //Input parameter of type Text
);

Parameters

FilterColumnCaptionFrom
Input parameter of type Text
FilterColumnValueFrom
Input parameter of type Text

Remarks

The relevant search keywords are: Set, Range.

For a clarification about how this function works, refer to the code listed below.

      FilterColumnCaption := FilterColumnCaptionFrom;
      FilterColumnValue := FilterColumnValueFrom;

Example

The below example is extracted from the test automation codeunit 134335 to show one way of using this function.

      // Check Vendor Order Detail Report with default option.

      // Setup.
      Initialize;
      CreatePurchaseDocument(PurchaseHeader,PurchaseHeader."Document Type"::Order,'',CreateItem,'');
      PurchaseLine.SETRANGE("Document Type",PurchaseLine."Document Type"::Order);
      PurchaseLine.SETRANGE("Document No.",PurchaseHeader."No.");
      PurchaseLine.FINDFIRST;

      // Exercise: Save Vendor Order Details Report with option Amount LCY FALSE.
      SaveOrderDetailReport(PurchaseHeader."Buy-from Vendor No.",FALSE);

      // Verify: Verify Report values.
      LibraryReportDataset.LoadDataSetFile;
      LibraryReportDataset.SetRange('PurchOrderHeaderNo',PurchaseHeader."No.");
      IF NOT LibraryReportDataset.GetNextRow THEN
        ERROR(STRSUBSTNO(NoDatasetRowErr,'PurchOrderHeaderNo',PurchaseHeader."No."));
      WITH PurchaseLine DO BEGIN
        LibraryReportDataset.AssertCurrentRowValue('Quantity_PurchaseLine',Quantity);
        LibraryReportDataset.AssertCurrentRowValue('OutstandingQty_PurchLine',"Outstanding Quantity");
        LibraryReportDataset.AssertCurrentRowValue('DirectUnitCost_PurchLine',"Direct Unit Cost");
        LibraryReportDataset.FindCurrentRowValue('PurchOrderAmount',ActualOutstandingOrders);
        Assert.AreNearlyEqual("Outstanding Amt. Ex. VAT (LCY)",ActualOutstandingOrders,LibraryERM.GetAmountRoundingPrecision,
          STRSUBSTNO(MustBeEqualErr,"Outstanding Amt. Ex. VAT (LCY)",'Outstanding Orders'));
      END;
Member of Lib.Library - Report Validation


VerifyCellValue@36 Method

The procedure VerifyCellValue is available in codeunit 131002.

Syntax

VerifyCellValue@36(
    RowId@1000 : Integer RowId, //Input parameter of type Integer
    ColumnId@1001 : Integer ColumnId, //Input parameter of type Integer
    ExpectedValue@1002 : Text ExpectedValue //Input parameter of type Text
);

Parameters

RowId
Input parameter of type Integer
ColumnId
Input parameter of type Integer
ExpectedValue
Input parameter of type Text

Remarks

The relevant search keywords are: Verify, Cell, Value.

For a clarification about how this function works, refer to the code listed below.

      Assert.AreEqual(
        DELCHR(ExpectedValue,'<>'),GetValueAt(ValueFound,RowId,ColumnId),
        STRSUBSTNO(IncorrectValueInCellErr,RowId,ColumnId));

Example

The below example is extracted from the test automation codeunit 134976 to show one way of using this function.

      LibraryReportValidation.OpenExcelFile;
      LibraryReportValidation.VerifyCellValue(15,4,YourReference);
Member of Lib.Library - Report Validation


VerifyCellValueByRef@132 Method

The procedure VerifyCellValueByRef is available in codeunit 131002.

Syntax

VerifyCellValueByRef@132(
    ColumnName@1000 : Text ColumnName, //Input parameter of type Text
    RowNo@1001 : Integer RowNo, //Input parameter of type Integer
    WorksheetNo@1002 : Integer WorksheetNo, //Input parameter of type Integer
    ExpectedValue@1003 : Text ExpectedValue //Input parameter of type Text
);

Parameters

ColumnName
Input parameter of type Text
RowNo
Input parameter of type Integer
WorksheetNo
Input parameter of type Integer
ExpectedValue
Input parameter of type Text

Remarks

The relevant search keywords are: Verify, Cell, Value, By, Ref.

For a clarification about how this function works, refer to the code listed below.

      Value := GetValueByRef(ColumnName,RowNo,WorksheetNo);
      IF Value <> '' THEN
        Assert.AreEqual(
          DELCHR(ExpectedValue,'<>'),
          Value,
          STRSUBSTNO(IncorrectValueInCellErr,ColumnName,RowNo));

Example

The below example is extracted from the test automation codeunit 134335 to show one way of using this function.

      LibraryReportValidation.OpenExcelFile;
      LibraryReportValidation.VerifyCellValueByRef(ColumnName,RowNo,1,LibraryReportValidation.FormatDecimalValue(TotalVATAmount));
      LibraryReportValidation.VerifyCellValueByRef(ColumnName,RowNo + 1,1,LibraryReportValidation.FormatDecimalValue(TotalBaseAmount));
Member of Lib.Library - Report Validation


VerifyCellValueOnWorksheet@35 Method

The procedure VerifyCellValueOnWorksheet is available in codeunit 131002.

Syntax

VerifyCellValueOnWorksheet@35(
    RowId@1000 : Integer RowId, //Input parameter of type Integer
    ColumnId@1001 : Integer ColumnId, //Input parameter of type Integer
    ExpectedValue@1002 : Text ExpectedValue, //Input parameter of type Text
    Worksheet@1004 : Text Worksheet //Input parameter of type Text
);

Parameters

RowId
Input parameter of type Integer
ColumnId
Input parameter of type Integer
ExpectedValue
Input parameter of type Text
Worksheet
Input parameter of type Text

Remarks

The relevant search keywords are: Verify, Cell, Value, On, Worksheet.

For a clarification about how this function works, refer to the code listed below.

      Assert.AreEqual(
        DELCHR(ExpectedValue,'<>'),GetValueAtFromWorksheet(RowId,ColumnId,Worksheet),
        STRSUBSTNO(IncorrectValueInCellErr,RowId,ColumnId));

Example

The below example is extracted from the test automation codeunit 134984 to show one way of using this function.

      // [FEATURE] [EC Sales List]
      Initialize;
      CompanyInformation.GET;

      // [GIVEN] Report 130 "EC Sales List" request page
      // [GIVEN] Type filter for VAT Entry "Posting Date"  = "01-01-2120" (on a date with no data)
      // [WHEN] Run the report
      DummyVATEntry.SETRANGE("Posting Date",DMY2DATE(1,1,DATE2DMY(WORKDATE,3) + 10),DMY2DATE(31,1,DATE2DMY(WORKDATE,3) + 10));
      REPORT.SAVEASEXCEL(REPORT::"EC Sales List",LibraryReportValidation.GetFileName,DummyVATEntry);

      // [THEN] The report has been printed
      LibraryReportValidation.OpenExcelFile;
      LibraryReportValidation.VerifyCellValueOnWorksheet(5,5,CompanyInformation.Name,'1');
Member of Lib.Library - Report Validation


VerifyEmptyCellByRef@14 Method

The procedure VerifyEmptyCellByRef is available in codeunit 131002.

Syntax

VerifyEmptyCellByRef@14(
    ColumnName@1003 : Text ColumnName, //Input parameter of type Text
    RowNo@1002 : Integer RowNo, //Input parameter of type Integer
    WorksheetNo@1001 : Integer WorksheetNo //Input parameter of type Integer
);

Parameters

ColumnName
Input parameter of type Text
RowNo
Input parameter of type Integer
WorksheetNo
Input parameter of type Integer

Remarks

The relevant search keywords are: Verify, Empty, Cell, By, Ref.

For a clarification about how this function works, refer to the code listed below.

      IF NOT FileOpened THEN
        OpenFile;

      DummyExcelBuffer.SETRANGE(xlColID,ColumnName);
      DummyExcelBuffer.SETRANGE(xlRowID,FORMAT(RowNo));
      DummyExcelBuffer.SETRANGE(Comment,FORMAT(WorksheetNo));
      Assert.RecordIsEmpty(DummyExcelBuffer);

Example

There are no examples available.
Member of Lib.Library - Report Validation


Library - Resource Class

Lib.Library - Resource

COD130511 applies to ERM,SCM,RES,W1,All.
Contains all utility functions related to Resource.

Methods

Name | Description
CreateResJournalLine@7 | The procedure CreateResJournalLine is available in codeunit 130511.
CreateResource@3 | The procedure CreateResource is available in codeunit 130511.
CreateResourceGroup@5 | The procedure CreateResourceGroup is available in codeunit 130511.
CreateResourceJournalBatch@12 | The procedure CreateResourceJournalBatch is available in codeunit 130511.
CreateResourceJournalTemplate@11 | The procedure CreateResourceJournalTemplate is available in codeunit 130511.
CreateResourceNew@16 | The procedure CreateResourceNew is available in codeunit 130511.
CreateResourceNo@13 | The procedure CreateResourceNo is available in codeunit 130511.
CreateResourcePrice@6 | The procedure CreateResourcePrice is available in codeunit 130511.
CreateResourceSkill@2 | The procedure CreateResourceSkill is available in codeunit 130511.
CreateResourceUnitOfMeasure@4 | The procedure CreateResourceUnitOfMeasure is available in codeunit 130511.
CreateResourceWithUsers@84 | The procedure CreateResourceWithUsers is available in codeunit 130511.
CreateSkillCode@1 | The procedure CreateSkillCode is available in codeunit 130511.
CreateWorkHourTemplate@10 | The procedure CreateWorkHourTemplate is available in codeunit 130511.
CreateWorkType@45 | The procedure CreateWorkType is available in codeunit 130511.
FindResJournalBatch@78 | The procedure FindResJournalBatch is available in codeunit 130511.
FindResJournalTemplate@66 | The procedure FindResJournalTemplate is available in codeunit 130511.
FindResource@53 | The procedure FindResource is available in codeunit 130511.
FindWorkType@9 | The procedure FindWorkType is available in codeunit 130511.
PostResourceJournalLine@8 | The procedure PostResourceJournalLine is available in codeunit 130511.
SetResourceBlocked@75 | The procedure SetResourceBlocked is available in codeunit 130511.

See Also

Lib


CreateResJournalLine@7 Method

The procedure CreateResJournalLine is available in codeunit 130511.

Syntax

CreateResJournalLine@7(
    VAR ResJournalLine@1000 : Record 207 ResJournalLine, //Reference parameter of type Record
    JournalTemplateName@1002 : Code[10] JournalTemplateName, //Input parameter of type Code
    JournalBatchName@1003 : Code[10] JournalBatchName //Input parameter of type Code
);

Parameters

ResJournalLine
Reference parameter of type Record
JournalTemplateName
Input parameter of type Code
JournalBatchName
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Resource, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      ResJournalLine.INIT;
      ResJournalLine.VALIDATE("Journal Template Name",JournalTemplateName);
      ResJournalLine.VALIDATE("Journal Batch Name",JournalBatchName);
      RecRef.GETTABLE(ResJournalLine);
      ResJournalLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,ResJournalLine.FIELDNO("Line No.")));
      ResJournalLine.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136402 to show one way of using this function.

      LibraryFiscalYear.CreateFiscalYear;
      StartDate := LibraryFiscalYear.GetLastPostingDate(TRUE);
      EndDate := LibraryFiscalYear.GetLastPostingDate(TRUE);

      LibraryResource.CreateResourceJournalTemplate(ResJournalTemplate);
      LibraryResource.CreateResourceJournalBatch(ResJournalBatch,ResJournalTemplate.Name);
      LibraryResource.CreateResJournalLine(ResJournalLine,ResJournalTemplate.Name,ResJournalBatch.Name);
      ResJournalLine.VALIDATE("Posting Date",LibraryFiscalYear.GetLastPostingDate(TRUE));
      ResJournalLine.VALIDATE("Resource No.",ResourceNo);
      ResJournalLine.VALIDATE(Quantity,RANDOM(10) + LibraryUtility.GenerateRandomFraction);  // Value is not important here.
      ResJournalLine.MODIFY(TRUE);
      LibraryResource.PostResourceJournalLine(ResJournalLine);
      LibraryFiscalYear.CloseFiscalYear;
      EXIT(ResJournalBatch.Name);
Member of Lib.Library - Resource


CreateResource@3 Method

The procedure CreateResource is available in codeunit 130511.

Syntax

CreateResource@3(
    VAR Resource@1000 : Record 156 Resource, //Reference parameter of type Record
    VATBusPostingGroup@1005 : Code[10] VATBusPostingGroup //Input parameter of type Code
);

Parameters

Resource
Reference parameter of type Record
VATBusPostingGroup
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Resource.

For a clarification about how this function works, refer to the code listed below.

      Resource.INIT;
      Resource.VALIDATE("No.",LibraryUtility.GenerateRandomCode(Resource.FIELDNO("No."),DATABASE::Resource));
      Resource.INSERT(TRUE);

      LibraryInventory.FindUnitOfMeasure(UnitOfMeasure);

      GeneralPostingSetup.SETFILTER("Gen. Bus. Posting Group",'<>%1','');
      GeneralPostingSetup.SETFILTER("Gen. Prod. Posting Group",'<>%1','');
      GeneralPostingSetup.SETFILTER("Sales Account",'<>%1','');
      GeneralPostingSetup.FINDFIRST;

      VATPostingSetup.SETRANGE("VAT Bus. Posting Group",VATBusPostingGroup);
      VATPostingSetup.SETRANGE("VAT Calculation Type",VATPostingSetup."VAT Calculation Type"::"Normal VAT");
      VATPostingSetup.FINDFIRST;

      Resource.VALIDATE(Name,Resource."No.");  // Validate Name as No. because value is not important.
      Resource.VALIDATE("Base Unit of Measure",UnitOfMeasure.Code);
      Resource.VALIDATE("Direct Unit Cost",RANDOM(100));  // Required field - value is not important.
      Resource.VALIDATE("Unit Price",RANDOM(100));  // Required field - value is not important.
      Resource.VALIDATE("Gen. Prod. Posting Group",GeneralPostingSetup."Gen. Prod. Posting Group");
      Resource.VALIDATE("VAT Prod. Posting Group",VATPostingSetup."VAT Prod. Posting Group");
      Resource.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134100 to show one way of using this function.

      LibraryResource.CreateResource(Resource,LineGLAccount."VAT Bus. Posting Group");
      Resource.VALIDATE("Gen. Prod. Posting Group",LineGLAccount."Gen. Prod. Posting Group");
      Resource.VALIDATE("VAT Prod. Posting Group",LineGLAccount."VAT Prod. Posting Group");
      Resource.MODIFY(TRUE);
      EXIT(Resource."No.");
Member of Lib.Library - Resource


CreateResourceGroup@5 Method

The procedure CreateResourceGroup is available in codeunit 130511.

Syntax

CreateResourceGroup@5(
    VAR ResourceGroup@1000 : Record 152 ResourceGroup //Reference parameter of type Record
);

Parameters

ResourceGroup
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Resource, Group.

For a clarification about how this function works, refer to the code listed below.

      ResourceGroup.INIT;
      ResourceGroup.VALIDATE("No.",LibraryUtility.GenerateRandomCode(ResourceGroup.FIELDNO("No."),DATABASE::"Resource Group"));
      ResourceGroup.VALIDATE(Name,ResourceGroup."No.");  // Validate Name as No. because value is not important.
      ResourceGroup.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136111 to show one way of using this function.

      // Covers document number TC0085 - refer to TFS ID 21724.
      // Test Resource allocation using Resource Availability without Allocation Date.

      // 1. Setup: Create Resource Group, Service Order - Service Header, Service Item and Service Item Line.
      CreateServiceOrder(ServiceItemLine);
      LibraryResource.CreateResourceGroup(ResourceGroup);

      // 2. Exercise: Allocate Resource Group to the Service Line with Resource Availability Form Without specifying the Allocation Date.
      ResourceNo2 := '';  // Global variable should be set to blank.
      ResourceGroupNo2 := ResourceGroup."No.";
      AllocatedHours2 := RANDOM(10);  // Required field - value is not important to test case.
      AllocationDate2 := 0D;
      RunResourceAllocationForm(ServiceItemLine);

      // 3. Verify: Check Status as Non Active and Updated Values, Resource Not to be allocated to the Service Order.
      VerifyValuesServiceAllocation(
        ServiceItemLine,ServiceOrderAllocation.Status::Nonactive,'',ResourceGroupNo2,AllocationDate2,AllocatedHours2);
      VerifyNoOfAllocations(ServiceItemLine."Document No.",0);  // Zero Resource should be allocated.
Member of Lib.Library - Resource


CreateResourceJournalBatch@12 Method

The procedure CreateResourceJournalBatch is available in codeunit 130511.

Syntax

CreateResourceJournalBatch@12(
    VAR ResJournalBatch@1000 : Record 236 ResJournalBatch, //Reference parameter of type Record
    JournalTemplateName@1002 : Code[10] JournalTemplateName //Input parameter of type Code
);

Parameters

ResJournalBatch
Reference parameter of type Record
JournalTemplateName
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Resource, Journal, Batch.

For a clarification about how this function works, refer to the code listed below.

      ResJournalBatch.INIT;
      ResJournalBatch.VALIDATE("Journal Template Name",JournalTemplateName);
      ResJournalBatch.VALIDATE(
        Name,
        COPYSTR(LibraryUtility.GenerateRandomCode(ResJournalBatch.FIELDNO(Name),DATABASE::"Res. Journal Batch"),
          1,
          LibraryUtility.GetFieldLength(DATABASE::"Res. Journal Batch",ResJournalBatch.FIELDNO(Name))));
      // Validate Description as Primary Key because value is not important.
      ResJournalBatch.VALIDATE(Description,ResJournalBatch."Journal Template Name" + ResJournalBatch.Name);
      ResJournalBatch.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136402 to show one way of using this function.

      LibraryFiscalYear.CreateFiscalYear;
      StartDate := LibraryFiscalYear.GetLastPostingDate(TRUE);
      EndDate := LibraryFiscalYear.GetLastPostingDate(TRUE);

      LibraryResource.CreateResourceJournalTemplate(ResJournalTemplate);
      LibraryResource.CreateResourceJournalBatch(ResJournalBatch,ResJournalTemplate.Name);
      LibraryResource.CreateResJournalLine(ResJournalLine,ResJournalTemplate.Name,ResJournalBatch.Name);
      ResJournalLine.VALIDATE("Posting Date",LibraryFiscalYear.GetLastPostingDate(TRUE));
      ResJournalLine.VALIDATE("Resource No.",ResourceNo);
      ResJournalLine.VALIDATE(Quantity,RANDOM(10) + LibraryUtility.GenerateRandomFraction);  // Value is not important here.
      ResJournalLine.MODIFY(TRUE);
      LibraryResource.PostResourceJournalLine(ResJournalLine);
      LibraryFiscalYear.CloseFiscalYear;
      EXIT(ResJournalBatch.Name);
Member of Lib.Library - Resource


CreateResourceJournalTemplate@11 Method

The procedure CreateResourceJournalTemplate is available in codeunit 130511.

Syntax

CreateResourceJournalTemplate@11(
    VAR ResJournalTemplate@1000 : Record 206 ResJournalTemplate //Reference parameter of type Record
);

Parameters

ResJournalTemplate
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Resource, Journal, Template.

For a clarification about how this function works, refer to the code listed below.

      ResJournalTemplate.INIT;
      ResJournalTemplate.VALIDATE(
        Name,
        COPYSTR(LibraryUtility.GenerateRandomCode(ResJournalTemplate.FIELDNO(Name),DATABASE::"Res. Journal Template"),
          1,
          LibraryUtility.GetFieldLength(DATABASE::"Res. Journal Template",ResJournalTemplate.FIELDNO(Name))));
      ResJournalTemplate.VALIDATE(Description,ResJournalTemplate.Name);  // Validate Description as Name because value is not important.
      ResJournalTemplate.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136402 to show one way of using this function.

      LibraryFiscalYear.CreateFiscalYear;
      StartDate := LibraryFiscalYear.GetLastPostingDate(TRUE);
      EndDate := LibraryFiscalYear.GetLastPostingDate(TRUE);

      LibraryResource.CreateResourceJournalTemplate(ResJournalTemplate);
      LibraryResource.CreateResourceJournalBatch(ResJournalBatch,ResJournalTemplate.Name);
      LibraryResource.CreateResJournalLine(ResJournalLine,ResJournalTemplate.Name,ResJournalBatch.Name);
      ResJournalLine.VALIDATE("Posting Date",LibraryFiscalYear.GetLastPostingDate(TRUE));
      ResJournalLine.VALIDATE("Resource No.",ResourceNo);
      ResJournalLine.VALIDATE(Quantity,RANDOM(10) + LibraryUtility.GenerateRandomFraction);  // Value is not important here.
      ResJournalLine.MODIFY(TRUE);
      LibraryResource.PostResourceJournalLine(ResJournalLine);
      LibraryFiscalYear.CloseFiscalYear;
      EXIT(ResJournalBatch.Name);
Member of Lib.Library - Resource


CreateResourceNew@16 Method

The procedure CreateResourceNew is available in codeunit 130511.

Syntax

CreateResourceNew@16(
    VAR Resource@1000 : Record 156 Resource //Reference parameter of type Record
);

Parameters

Resource
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Resource, New.

For a clarification about how this function works, refer to the code listed below.

      ResNoSeriesSetup;
      LibraryInventory.FindUnitOfMeasure(UnitOfMeasure);
      LibraryERM.FindGeneralPostingSetupInvtFull(GeneralPostingSetup);
      LibraryERM.FindVATPostingSetupInvt(VATPostingSetup);

      CLEAR(Resource);
      Resource.INSERT(TRUE);
      Resource.VALIDATE(Name,Resource."No.");  // Validate Name as No. because value is not important.
      Resource.VALIDATE("Base Unit of Measure",UnitOfMeasure.Code);
      Resource.VALIDATE("Direct Unit Cost",RANDOM(100));  // Required field - value is not important.
      Resource.VALIDATE("Unit Price",RANDOM(100));  // Required field - value is not important.
      Resource.VALIDATE("Gen. Prod. Posting Group",GeneralPostingSetup."Gen. Prod. Posting Group");
      Resource.VALIDATE("VAT Prod. Posting Group",VATPostingSetup."VAT Prod. Posting Group");
      Resource.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134805 to show one way of using this function.

      LibraryResource.CreateResourceNew(Resource);
Member of Lib.Library - Resource


CreateResourceNo@13 Method

The procedure CreateResourceNo is available in codeunit 130511.

Syntax

CreateResourceNo@13(
      //param element not supplied
);

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Resource, No.

For a clarification about how this function works, refer to the code listed below.

      CreateResourceNew(Resource);
      EXIT(Resource."No.");

Example

The below example is extracted from the test automation codeunit 136104 to show one way of using this function.

      // [SCENARIO 143443] Create Service Credit Memo for Type Resource, post it and verify the Service Ledger Entries.

      // [GIVEN] Create Resource, create Customer with Price Including VAT.
      Initialize;
      ResourceNo := LibraryResource.CreateResourceNo;
      CustomerNo := CustomerWithPriceIncludingVAT(TRUE);

      // [WHEN] Create Service Credit Memo and post it.
      No := LibraryService.CreateServiceCreditMemoHeaderUsingPage;
      CreateCreditMemoLine(No,CustomerNo,ServiceLine.Type::Resource,ResourceNo);
      ServiceCreditMemoOpenEdit(ServiceCreditMemo,No);
      Quantity := ServiceCreditMemo.ServLines.Quantity.ASDECIMAL;
      ServiceCreditMemo.Post.INVOKE;

      // [THEN] Verify the Service Ledger Entries for the posted Service Credit Memo.
      VerifyCreditMemoServiceLedgerEntry(No,CustomerNo,ResourceNo,Quantity);
Member of Lib.Library - Resource


CreateResourcePrice@6 Method

The procedure CreateResourcePrice is available in codeunit 130511.

Syntax

CreateResourcePrice@6(
    VAR ResourcePrice@1000 : Record 201 ResourcePrice, //Reference parameter of type Record
    Type@1002 : Option Type, //Input parameter of type Option
    Code@1003 : Code[20] Code, //Input parameter of type Code
    WorkTypeCode@1004 : Code[10] WorkTypeCode, //Input parameter of type Code
    CurrencyCode@1005 : Code[10] CurrencyCode //Input parameter of type Code
);

Parameters

ResourcePrice
Reference parameter of type Record
Type
Input parameter of type Option
Code
Input parameter of type Code
WorkTypeCode
Input parameter of type Code
CurrencyCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Resource, Price.

For a clarification about how this function works, refer to the code listed below.

      ResourcePrice.INIT;
      ResourcePrice.VALIDATE(Type,Type);
      ResourcePrice.VALIDATE(Code,Code);
      ResourcePrice.VALIDATE("Work Type Code",WorkTypeCode);
      ResourcePrice.VALIDATE("Currency Code",CurrencyCode);
      ResourcePrice.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136402 to show one way of using this function.

      LibraryResource.CreateResourcePrice(ResourcePrice,ResourcePrice.Type::Resource,ResourceNo,'','');
      ResourcePrice.VALIDATE("Unit Price",RANDOM(100) + LibraryUtility.GenerateRandomFraction);  // Use Random because value is not important.
      ResourcePrice.MODIFY(TRUE);
      EXIT(ResourcePrice."Unit Price");
Member of Lib.Library - Resource


CreateResourceSkill@2 Method

The procedure CreateResourceSkill is available in codeunit 130511.

Syntax

CreateResourceSkill@2(
    VAR ResourceSkill@1000 : Record 5956 ResourceSkill, //Reference parameter of type Record
    Type@1001 : Option Type, //Input parameter of type Option
    No@1002 : Code[20] No, //Input parameter of type Code
    SkillCode@1003 : Code[10] SkillCode //Input parameter of type Code
);

Parameters

ResourceSkill
Reference parameter of type Record
Type
Input parameter of type Option
No
Input parameter of type Code
SkillCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Resource, Skill.

For a clarification about how this function works, refer to the code listed below.

      ResourceSkill.INIT;
      ResourceSkill.VALIDATE(Type,Type);
      ResourceSkill.VALIDATE("No.",No);
      ResourceSkill.VALIDATE("Skill Code",SkillCode);
      ResourceSkill.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136103 to show one way of using this function.

      LibraryService.CreateServiceItemGroup(ServiceItemGroup);
      LibraryResource.CreateResourceSkill(
        ResourceSkill,ResourceSkill.Type::"Service Item Group",ServiceItemGroup.Code,CreateSkillCode);
      EXIT(ServiceItemGroup.Code);
Member of Lib.Library - Resource


CreateResourceUnitOfMeasure@4 Method

The procedure CreateResourceUnitOfMeasure is available in codeunit 130511.

Syntax

CreateResourceUnitOfMeasure@4(
    VAR ResourceUnitOfMeasure@1000 : Record 205 ResourceUnitOfMeasure, //Reference parameter of type Record
    ResourceNo@1001 : Code[20] ResourceNo, //Input parameter of type Code
    UnitOfMeasureCode@1003 : Code[10] UnitOfMeasureCode, //Input parameter of type Code
    QtyPerUoM@1002 : Decimal QtyPerUoM //Input parameter of type Decimal
);

Parameters

ResourceUnitOfMeasure
Reference parameter of type Record
ResourceNo
Input parameter of type Code
UnitOfMeasureCode
Input parameter of type Code
QtyPerUoM
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Resource, Unit, Of, Measure.

For a clarification about how this function works, refer to the code listed below.

      ResourceUnitOfMeasure.INIT;
      ResourceUnitOfMeasure.VALIDATE("Resource No.",ResourceNo);
      ResourceUnitOfMeasure.VALIDATE(Code,UnitOfMeasureCode);
      IF QtyPerUoM = 0 THEN
        QtyPerUoM := 1;
      ResourceUnitOfMeasure.VALIDATE("Qty. per Unit of Measure",QtyPerUoM);
      ResourceUnitOfMeasure.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136305 to show one way of using this function.

      LibraryResource.CreateResourceUnitOfMeasure(
        ResourceUnitOfMeasure,Resource."No.",FindUnitOfMeasure,1);

      // Use 1 to insure that Qty per Unit of Measure greater than Qty per Unit of Measure for Base Unit of Measure.
      ResourceUnitOfMeasure.VALIDATE("Qty. per Unit of Measure",1 + LibraryRandom.RandInt(10));
      ResourceUnitOfMeasure.MODIFY(TRUE);
Member of Lib.Library - Resource


CreateResourceWithUsers@84 Method

The procedure CreateResourceWithUsers is available in codeunit 130511.

Syntax

CreateResourceWithUsers@84(
    VAR Resource@1000 : Record 156 Resource //Reference parameter of type Record
);

Parameters

Resource
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Resource, Users.

For a clarification about how this function works, refer to the code listed below.

      Resource.INIT;
      Resource.VALIDATE("No.",LibraryUtility.GenerateRandomCode(Resource.FIELDNO("No."),DATABASE::Resource));
      Resource.INSERT(TRUE);

      Resource."Time Sheet Owner User ID" := USERID;
      Resource."Time Sheet Approver User ID" := USERID;
      Resource.MODIFY;

Example

The below example is extracted from the test automation codeunit 136504 to show one way of using this function.

      // [FEATURE] [UT]
      // [SCENARIO 223058] Cassie cannot create time sheet header refered to blocked resource
      LibraryResource.CreateResourceWithUsers(Resource);

      LibraryResource.SetResourceBlocked(Resource);

      TimeSheetHeader.INIT;
      TimeSheetHeader."Resource No." := Resource."No.";
      ASSERTERROR TimeSheetHeader.INSERT(TRUE);

      Assert.ExpectedError(ResourceBlockedErr);
Member of Lib.Library - Resource


CreateSkillCode@1 Method

The procedure CreateSkillCode is available in codeunit 130511.

Syntax

CreateSkillCode@1(
    VAR SkillCode@1000 : Record 5955 SkillCode //Reference parameter of type Record
);

Parameters

SkillCode
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Skill, Code.

For a clarification about how this function works, refer to the code listed below.

      SkillCode.INIT;
      SkillCode.VALIDATE(Code,LibraryUtility.GenerateRandomCode(SkillCode.FIELDNO(Code),DATABASE::"Skill Code"));
      SkillCode.INSERT(TRUE);
      SkillCode.VALIDATE(Description,SkillCode.Code);  // Validate Description as Code because value is not important.
      SkillCode.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 136103 to show one way of using this function.

      LibraryResource.CreateSkillCode(SkillCode);
      EXIT(SkillCode.Code);
Member of Lib.Library - Resource


CreateWorkHourTemplate@10 Method

The procedure CreateWorkHourTemplate is available in codeunit 130511.

Syntax

CreateWorkHourTemplate@10(
    VAR WorkHourTemplate@1000 : Record 5954 WorkHourTemplate //Reference parameter of type Record
);

Parameters

WorkHourTemplate
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Work, Hour, Template.

For a clarification about how this function works, refer to the code listed below.

      WorkHourTemplate.INIT;
      WorkHourTemplate.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(WorkHourTemplate.FIELDNO(Code),DATABASE::"Work-Hour Template"),1,
          LibraryUtility.GetFieldLength(DATABASE::"Work-Hour Template",WorkHourTemplate.FIELDNO(Code))));
      WorkHourTemplate.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136404 to show one way of using this function.

      // [FEATURE] [UT]
      // [SCENARIO 377427] Check Work-Hour Template capacity day ranges: [0..24]
      LibraryResource.CreateWorkHourTemplate(WorkHourTemplate);
      WorkHourTemplates.OPENEDIT;
      WorkHourTemplates.GOTORECORD(WorkHourTemplate);

      ASSERTERROR WorkHourTemplates.Monday.SETVALUE(-0.00001);
      Assert.ExpectedErrorCode(TestValidationTxt);

      ASSERTERROR WorkHourTemplates.Monday.SETVALUE(24.00001);
      Assert.ExpectedErrorCode(TestValidationTxt);

      ASSERTERROR WorkHourTemplates.Tuesday.SETVALUE(-0.00001);
      Assert.ExpectedErrorCode(TestValidationTxt);

      ASSERTERROR WorkHourTemplates.Tuesday.SETVALUE(24.00001);
      Assert.ExpectedErrorCode(TestValidationTxt);

      ASSERTERROR WorkHourTemplates.Wednesday.SETVALUE(-0.00001);
      Assert.ExpectedErrorCode(TestValidationTxt);

      ASSERTERROR WorkHourTemplates.Wednesday.SETVALUE(24.00001);
      Assert.ExpectedErrorCode(TestValidationTxt);

      ASSERTERROR WorkHourTemplates.Thursday.SETVALUE(-0.00001);
      Assert.ExpectedErrorCode(TestValidationTxt);

      ASSERTERROR WorkHourTemplates.Thursday.SETVALUE(24.00001);
      Assert.ExpectedErrorCode(TestValidationTxt);

      ASSERTERROR WorkHourTemplates.Friday.SETVALUE(-0.00001);
      Assert.ExpectedErrorCode(TestValidationTxt);

      ASSERTERROR WorkHourTemplates.Friday.SETVALUE(24.00001);
      Assert.ExpectedErrorCode(TestValidationTxt);

      ASSERTERROR WorkHourTemplates.Saturday.SETVALUE(-0.00001);
      Assert.ExpectedErrorCode(TestValidationTxt);

      ASSERTERROR WorkHourTemplates.Saturday.SETVALUE(24.00001);
      Assert.ExpectedErrorCode(TestValidationTxt);

      ASSERTERROR WorkHourTemplates.Sunday.SETVALUE(-0.00001);
      Assert.ExpectedErrorCode(TestValidationTxt);

      ASSERTERROR WorkHourTemplates.Sunday.SETVALUE(24.00001);
      Assert.ExpectedErrorCode(TestValidationTxt);
Member of Lib.Library - Resource


CreateWorkType@45 Method

The procedure CreateWorkType is available in codeunit 130511.

Syntax

CreateWorkType@45(
    VAR WorkType@1000 : Record 200 WorkType //Reference parameter of type Record
);

Parameters

WorkType
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Work, Type.

For a clarification about how this function works, refer to the code listed below.

      LibraryInventory.FindUnitOfMeasure(UnitOfMeasure);

      WorkType.INIT;
      WorkType.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(WorkType.FIELDNO(Code),DATABASE::"Work Type"),
          1,
          LibraryUtility.GetFieldLength(DATABASE::"Work Type",WorkType.FIELDNO(Code))));

      // Validating Description as Code because value is not important.
      WorkType.VALIDATE(Description,WorkType.Code);
      WorkType.VALIDATE("Unit of Measure Code",UnitOfMeasure.Code);
      WorkType.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136403 to show one way of using this function.

      // Check Resource Price on Resource Journal Line with and without Work Type by Page.

      // 1. Setup: Create Resource and Resource Price.
      Initialize;
      Resource.GET(CreateResource);
      LibraryResource.CreateWorkType(WorkType);
      CreateResourcePrice(ResourcePrice,ResourcePrice.Type::Resource,Resource."No.",'','');
      CreateResourcePrice(ResourcePrice2,ResourcePrice.Type::Resource,Resource."No.",WorkType.Code,'');
      FindResourceJournalBatch(ResJournalBatch);
      TemplateName := ResJournalBatch."Journal Template Name";  // Assign global variable.

      // 2. Exercise: Create Resource Journal Lines without and with Work Type with same Document No.
      ResourceJournal.OPENEDIT;
      CreateResourceJournalLineByPage(ResourceJournal,ResJournalBatch.Name,Resource."No.",'');
      ResourceJournal.NEW;
      CreateResourceJournalLineByPage(ResourceJournal,ResJournalBatch.Name,Resource."No.",WorkType.Code);
      ResourceJournal.OK.INVOKE;

      // 3. Verify: Check Unit Price of Resource Journal Lines.
      VerifyResourceJournalLineUnitPrice(Resource."No.",'',ResourcePrice."Unit Price",ResJournalBatch.Name);
      VerifyResourceJournalLineUnitPrice(Resource."No.",WorkType.Code,ResourcePrice2."Unit Price",ResJournalBatch.Name);
Member of Lib.Library - Resource


FindResJournalBatch@78 Method

The procedure FindResJournalBatch is available in codeunit 130511.

Syntax

FindResJournalBatch@78(
    VAR ResJournalBatch@1000 : Record 236 ResJournalBatch, //Reference parameter of type Record
    JournalTemplateName@1001 : Code[10] JournalTemplateName //Input parameter of type Code
);

Parameters

ResJournalBatch
Reference parameter of type Record
JournalTemplateName
Input parameter of type Code

Remarks

The relevant search keywords are: Find, Resource, Journal, Batch.

For a clarification about how this function works, refer to the code listed below.

      ResJournalBatch.SETRANGE("Journal Template Name",JournalTemplateName);
      ResJournalBatch.FINDFIRST;

Example

The below example is extracted from the test automation codeunit 136403 to show one way of using this function.

      ResJournalTemplate.SETRANGE(Recurring,FALSE);
      LibraryResource.FindResJournalTemplate(ResJournalTemplate);
      LibraryResource.FindResJournalBatch(ResJournalBatch,ResJournalTemplate.Name);
Member of Lib.Library - Resource


FindResJournalTemplate@66 Method

The procedure FindResJournalTemplate is available in codeunit 130511.

Syntax

FindResJournalTemplate@66(
    VAR ResJournalTemplate@1000 : Record 206 ResJournalTemplate //Reference parameter of type Record
);

Parameters

ResJournalTemplate
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Resource, Journal, Template.

For a clarification about how this function works, refer to the code listed below.

      ResJournalTemplate.FINDFIRST;

Example

The below example is extracted from the test automation codeunit 136403 to show one way of using this function.

      ResJournalTemplate.SETRANGE(Recurring,FALSE);
      LibraryResource.FindResJournalTemplate(ResJournalTemplate);
      LibraryResource.FindResJournalBatch(ResJournalBatch,ResJournalTemplate.Name);
Member of Lib.Library - Resource


FindResource@53 Method

The procedure FindResource is available in codeunit 130511.

Syntax

FindResource@53(
    VAR Resource@1000 : Record 156 Resource //Reference parameter of type Record
);

Parameters

Resource
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Resource.

For a clarification about how this function works, refer to the code listed below.

      // Filter Resource so that errors are not generated due to mandatory fields.
      Resource.SETFILTER("Gen. Prod. Posting Group",'<>''''');
      Resource.SETFILTER("VAT Prod. Posting Group",'<>''''');
      Resource.SETRANGE(Blocked,FALSE);

      Resource.FINDSET;

Example

The below example is extracted from the test automation codeunit 134087 to show one way of using this function.

      LibrarySales.CreateCustomer(Customer);
      LibraryResource.FindResource(Resource);
      LibraryERM.FindCurrency(Currency);
      SalesQuotePage.OPENEDIT;
      SalesQuotePage.NEW;
      SalesQuotePage."Sell-to Customer No.".VALUE(Customer."No.");
      SalesQuotePage.SalesLines.Type.VALUE(FORMAT(SalesLine.Type::Resource));
      SalesQuotePage.SalesLines."No.".VALUE(Resource."No.");
      SalesQuotePage.SalesLines.Quantity.VALUE(FORMAT(LibraryRandom.RandInt(5)));
      SalesQuotePage."Currency Code".VALUE(Currency.Code);
      DocumentNo := SalesQuotePage."No.".VALUE;
      SalesQuotePage.CLOSE;

      VerifyCurrencyInSalesLine(SalesLine."Document Type"::Quote,DocumentNo,Resource."No.",Currency.Code);
Member of Lib.Library - Resource


FindWorkType@9 Method

The procedure FindWorkType is available in codeunit 130511.

Syntax

FindWorkType@9(
    VAR WorkType@1000 : Record 200 WorkType //Reference parameter of type Record
);

Parameters

WorkType
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Work, Type.

For a clarification about how this function works, refer to the code listed below.

      WorkType.FINDSET;

Example

There are no examples available.
Member of Lib.Library - Resource


PostResourceJournalLine@8 Method

The procedure PostResourceJournalLine is available in codeunit 130511.

Syntax

PostResourceJournalLine@8(
    VAR ResJournalLine@1000 : Record 207 ResJournalLine //Reference parameter of type Record
);

Parameters

ResJournalLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Post, Resource, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      ResJournalLine.SETRANGE("Journal Template Name",ResJournalLine."Journal Template Name");
      ResJournalLine.SETRANGE("Journal Batch Name",ResJournalLine."Journal Batch Name");
      CODEUNIT.RUN(CODEUNIT::"Res. Jnl.-Post",ResJournalLine);

Example

The below example is extracted from the test automation codeunit 136402 to show one way of using this function.

      LibraryFiscalYear.CreateFiscalYear;
      StartDate := LibraryFiscalYear.GetLastPostingDate(TRUE);
      EndDate := LibraryFiscalYear.GetLastPostingDate(TRUE);

      LibraryResource.CreateResourceJournalTemplate(ResJournalTemplate);
      LibraryResource.CreateResourceJournalBatch(ResJournalBatch,ResJournalTemplate.Name);
      LibraryResource.CreateResJournalLine(ResJournalLine,ResJournalTemplate.Name,ResJournalBatch.Name);
      ResJournalLine.VALIDATE("Posting Date",LibraryFiscalYear.GetLastPostingDate(TRUE));
      ResJournalLine.VALIDATE("Resource No.",ResourceNo);
      ResJournalLine.VALIDATE(Quantity,RANDOM(10) + LibraryUtility.GenerateRandomFraction);  // Value is not important here.
      ResJournalLine.MODIFY(TRUE);
      LibraryResource.PostResourceJournalLine(ResJournalLine);
      LibraryFiscalYear.CloseFiscalYear;
      EXIT(ResJournalBatch.Name);
Member of Lib.Library - Resource


SetResourceBlocked@75 Method

The procedure SetResourceBlocked is available in codeunit 130511.

Syntax

SetResourceBlocked@75(
    VAR Resource@1000 : Record 156 Resource //Reference parameter of type Record
);

Parameters

Resource
Reference parameter of type Record

Remarks

The relevant search keywords are: Set, Resource, Blocked.

For a clarification about how this function works, refer to the code listed below.

      Resource.VALIDATE(Blocked,TRUE);
      Resource.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 136504 to show one way of using this function.

      // [FEATURE] [UT]
      // [SCENARIO 223058] Cassie cannot create time sheet header refered to blocked resource
      LibraryResource.CreateResourceWithUsers(Resource);

      LibraryResource.SetResourceBlocked(Resource);

      TimeSheetHeader.INIT;
      TimeSheetHeader."Resource No." := Resource."No.";
      ASSERTERROR TimeSheetHeader.INSERT(TRUE);

      Assert.ExpectedError(ResourceBlockedErr);
Member of Lib.Library - Resource


Library - Sales Class

Lib.Library - Sales

COD130509 applies to ERM,SCM,RES,W1,IN.
Contains all utility functions related to Sales.

Methods

Name | Description
AutoReserveSalesLine@9 | The procedure AutoReserveSalesLine is available in codeunit 130509.
BatchPostSalesHeaders@40 | The procedure BatchPostSalesHeaders is available in codeunit 130509.
BlanketSalesOrderMakeOrder@36 | The procedure BlanketSalesOrderMakeOrder is available in codeunit 130509.
CalcSalesDiscount@77 | The procedure CalcSalesDiscount is available in codeunit 130509.
CombineReturnReceipts@39 | The procedure CombineReturnReceipts is available in codeunit 130509.
CombineShipments@37 | The procedure CombineShipments is available in codeunit 130509.
CopySalesDocument@60 | The procedure CopySalesDocument is available in codeunit 130509.
CreateCustomer@3 | The procedure CreateCustomer is available in codeunit 130509.
CreateCustomerBankAccount@24 | The procedure CreateCustomerBankAccount is available in codeunit 130509.
CreateCustomerMandate@27 | The procedure CreateCustomerMandate is available in codeunit 130509.
CreateCustomerNo@30 | The procedure CreateCustomerNo is available in codeunit 130509.
CreateCustomerPostingGroup@50 | The procedure CreateCustomerPostingGroup is available in codeunit 130509.
CreateCustomerPriceGroup@6 | The procedure CreateCustomerPriceGroup is available in codeunit 130509.
CreateCustomerSalesCode@25 | The procedure CreateCustomerSalesCode is available in codeunit 130509.
CreateCustomerTemplate@1 | The procedure CreateCustomerTemplate is available in codeunit 130509.
CreateCustomerWithAddress@65 | The procedure CreateCustomerWithAddress is available in codeunit 130509.
CreateCustomerWithBusPostingGroups@53 | The procedure CreateCustomerWithBusPostingGroups is available in codeunit 130509.
CreateCustomerWithLocationCode@102 | The procedure CreateCustomerWithLocationCode is available in codeunit 130509.
CreateCustomerWithStateCode@1500000 | The procedure CreateCustomerWithStateCode is available in codeunit 130509.
CreateCustomerWithVATBusPostingGroup@63 | The procedure CreateCustomerWithVATBusPostingGroup is available in codeunit 130509.
CreateCustomerWithVATRegNo@35 | The procedure CreateCustomerWithVATRegNo is available in codeunit 130509.
CreateFCYSalesDocumentWithItem@56 | The procedure CreateFCYSalesDocumentWithItem is available in codeunit 130509.
CreateForeignCustomer@1500012 | The procedure CreateForeignCustomer is available in codeunit 130509.
CreateItemChargeAssignment@43 | The procedure CreateItemChargeAssignment is available in codeunit 130509.
CreatePaymentAndApplytoInvoice@69 | The procedure CreatePaymentAndApplytoInvoice is available in codeunit 130509.
CreatePrepaymentVATSetup@34 | The procedure CreatePrepaymentVATSetup is available in codeunit 130509.
CreateSalesCommentLine@22 | The procedure CreateSalesCommentLine is available in codeunit 130509.
CreateSalesDocumentWithItem@33 | The procedure CreateSalesDocumentWithItem is available in codeunit 130509.
CreateSalesHeader@14 | The procedure CreateSalesHeader is available in codeunit 130509.
CreateSalesInvoice@55 | The procedure CreateSalesInvoice is available in codeunit 130509.
CreateSalesInvoiceForCustomerNo@79 | The procedure CreateSalesInvoiceForCustomerNo is available in codeunit 130509.
CreateSalesLine@17 | The procedure CreateSalesLine is available in codeunit 130509.
CreateSalesLineWithShipmentDate@16 | The procedure CreateSalesLineWithShipmentDate is available in codeunit 130509.
CreateSalesperson@5 | The procedure CreateSalesperson is available in codeunit 130509.
CreateSalesPrepaymentPct@38 | The procedure CreateSalesPrepaymentPct is available in codeunit 130509.
CreateSalesPrice@10 | The procedure CreateSalesPrice is available in codeunit 130509.
CreateShipToAddress@13 | The procedure CreateShipToAddress is available in codeunit 130509.
CreateStandardSalesCode@8 | The procedure CreateStandardSalesCode is available in codeunit 130509.
CreateStandardSalesLine@15 | The procedure CreateStandardSalesLine is available in codeunit 130509.
CreateStandardTextWithExtendedText@130 | The procedure CreateStandardTextWithExtendedText is available in codeunit 130509.
DeleteInvoicedSalesOrders@41 | The procedure DeleteInvoicedSalesOrders is available in codeunit 130509.
DeleteInvoicedSalesReturnOrders@42 | The procedure DeleteInvoicedSalesReturnOrders is available in codeunit 130509.
ExplodeBOM@72 | The procedure ExplodeBOM is available in codeunit 130509.
FindCustomerPostingGroup@31 | The procedure FindCustomerPostingGroup is available in codeunit 130509.
FindItem@93 | The procedure FindItem is available in codeunit 130509.
FindType@1500001 | The procedure FindType is available in codeunit 130509.
GetCustomerAccount@1500013 | The procedure GetCustomerAccount is available in codeunit 130509.
GetShipmentLines@7 | The procedure GetShipmentLines is available in codeunit 130509.
PostSalesDocument@19 | The procedure PostSalesDocument is available in codeunit 130509.
PostSalesDocumentAndEmail@29 | The procedure PostSalesDocumentAndEmail is available in codeunit 130509.
PostSalesPrepaymentCrMemo@12 | The procedure PostSalesPrepaymentCrMemo is available in codeunit 130509.
PostSalesPrepaymentInvoice@23 | The procedure PostSalesPrepaymentInvoice is available in codeunit 130509.
QuoteMakeOrder@44 | The procedure QuoteMakeOrder is available in codeunit 130509.
ReleaseSalesDocument@78 | The procedure ReleaseSalesDocument is available in codeunit 130509.
ReopenSalesDocument@32 | The procedure ReopenSalesDocument is available in codeunit 130509.
SelectCashReceiptJnlBatch@52 | The procedure SelectCashReceiptJnlBatch is available in codeunit 130509.
SelectCashReceiptJnlTemplate@51 | The procedure SelectCashReceiptJnlTemplate is available in codeunit 130509.
SetAllowDocumentDeletionBeforeDate@88 | The procedure SetAllowDocumentDeletionBeforeDate is available in codeunit 130509.
SetAllowVATDifference@48 | The procedure SetAllowVATDifference is available in codeunit 130509.
SetApplnBetweenCurrencies@45 | The procedure SetApplnBetweenCurrencies is available in codeunit 130509.
SetArchiveQuotesandOrders@26 | The procedure SetArchiveQuotesandOrders is available in codeunit 130509.
SetCalcInvDiscount@46 | The procedure SetCalcInvDiscount is available in codeunit 130509.
SetCorrDocNoSales@11 | The procedure SetCorrDocNoSales is available in codeunit 130509.
SetCreditWarnings@49 | The procedure SetCreditWarnings is available in codeunit 130509.
SetCreditWarningsToNoWarnings@2 | The procedure SetCreditWarningsToNoWarnings is available in codeunit 130509.
SetExactCostReversingMandatory@54 | The procedure SetExactCostReversingMandatory is available in codeunit 130509.
SetExtDocNo@100 | The procedure SetExtDocNo is available in codeunit 130509.
SetInvoiceRounding@47 | The procedure SetInvoiceRounding is available in codeunit 130509.
SetPreventNegativeInventory@21 | The procedure SetPreventNegativeInventory is available in codeunit 130509.
SetReturnOrderNoSeriesInSetup@73 | The procedure SetReturnOrderNoSeriesInSetup is available in codeunit 130509.
SetStockoutWarning@4 | The procedure SetStockoutWarning is available in codeunit 130509.
UndoReturnReceiptLine@20 | The procedure UndoReturnReceiptLine is available in codeunit 130509.
UndoSalesShipmentLine@18 | The procedure UndoSalesShipmentLine is available in codeunit 130509.

See Also

Lib


AutoReserveSalesLine@9 Method

The procedure AutoReserveSalesLine is available in codeunit 130509.

Syntax

AutoReserveSalesLine@9(
    SalesLine@1000 : Record 37 SalesLine //Input parameter of type Record
);

Parameters

SalesLine
Input parameter of type Record

Remarks

The relevant search keywords are: Auto, Reserve, Sales, Line.

For a clarification about how this function works, refer to the code listed below.

      SalesLine.AutoReserve;

Example

The below example is extracted from the test automation codeunit 136137 to show one way of using this function.

      LibrarySales.CreateSalesLine(SalesLine,SalesHeader,SalesLine.Type::Item,ItemNo,Qty);
      SalesLine.VALIDATE("Location Code",LocationCode);
      SalesLine.MODIFY;
      LibrarySales.AutoReserveSalesLine(SalesLine);
Member of Lib.Library - Sales


BatchPostSalesHeaders@40 Method

The procedure BatchPostSalesHeaders is available in codeunit 130509.

Syntax

BatchPostSalesHeaders@40(
    VAR SalesHeader@1000 : Record 36 SalesHeader, //Reference parameter of type Record
    Ship@1005 : Boolean Ship, //Input parameter of type Boolean
    Invoice@1006 : Boolean Invoice, //Input parameter of type Boolean
    PostingDate@1003 : Date PostingDate, //Input parameter of type Date
    ReplacePostingDate@1004 : Boolean ReplacePostingDate, //Input parameter of type Boolean
    ReplaceDocumentDate@1007 : Boolean ReplaceDocumentDate, //Input parameter of type Boolean
    CalcInvDiscount@1001 : Boolean CalcInvDiscount //Input parameter of type Boolean
);

Parameters

SalesHeader
Reference parameter of type Record
Ship
Input parameter of type Boolean
Invoice
Input parameter of type Boolean
PostingDate
Input parameter of type Date
ReplacePostingDate
Input parameter of type Boolean
ReplaceDocumentDate
Input parameter of type Boolean
CalcInvDiscount
Input parameter of type Boolean

Remarks

The relevant search keywords are: Batch, Post, Sales, Headers.

For a clarification about how this function works, refer to the code listed below.

      BatchPostSalesOrders.USEREQUESTPAGE(FALSE);
      BatchPostSalesOrders.InitializeRequest(Ship,Invoice,PostingDate,ReplacePostingDate,ReplaceDocumentDate,CalcInvDiscount);
      BatchPostSalesOrders.SETTABLEVIEW(SalesHeader);
      BatchPostSalesOrders.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 137096 to show one way of using this function.

      CreateAssembledItem(ItemATO,ItemATO."Assembly Policy"::"Assemble-to-Order",LibraryRandom.RandInt(10),
        LibraryRandom.RandInt(10),LibraryRandom.RandInt(10),LibraryRandom.RandInt(1000),
        ItemATO."Costing Method"::FIFO);
      CreateAssembledItem(ItemATS,ItemATS."Assembly Policy"::"Assemble-to-Stock",LibraryRandom.RandInt(10),
        LibraryRandom.RandInt(10),LibraryRandom.RandInt(10),LibraryRandom.RandInt(1000),
        ItemATS."Costing Method"::FIFO);
      LibraryInventory.CreateItem(RegularItem);

      // create SOs with ATO/ATS/Regular item
      OrderQty := LibraryRandom.RandInt(1000);
      DueDate := CALCDATE('<+' + FORMAT(LibraryRandom.RandInt(30)) + 'D>',WorkDate2);
      CreateSalesOrder(SalesHeader1,ItemATS."No.",'',OrderQty,DueDate,LocationCode);
      AddSalesOrderLine(SalesHeader1,SalesLine,ItemATO."No.",LocationCode,'',OrderQty,DueDate);
      AddSalesOrderLine(SalesHeader1,SalesLine,RegularItem."No.",LocationCode,'',OrderQty,DueDate);
      CreateSalesOrder(SalesHeader2,ItemATS."No.",'',OrderQty,DueDate,LocationCode);
      AddSalesOrderLine(SalesHeader2,SalesLine,ItemATO."No.",LocationCode,'',OrderQty + 1,DueDate);
      AddSalesOrderLine(SalesHeader2,SalesLine,RegularItem."No.",LocationCode,'',OrderQty,DueDate);

      // Find created AOs
      FindAssemblyHeader(AssemblyHeader1,AssemblyHeader1."Document Type"::Order,ItemATO,'',LocationCode,DueDate,
        ItemATO."Base Unit of Measure",OrderQty);
      CopyAsmLinesToTemp(AssemblyHeader1,TempAssemblyLine1);
      FindAssemblyHeader(AssemblyHeader2,AssemblyHeader2."Document Type"::Order,ItemATO,'',LocationCode,DueDate,
        ItemATO."Base Unit of Measure",OrderQty + 1);
      CopyAsmLinesToTemp(AssemblyHeader2,TempAssemblyLine2);

      // Add enough inventory for components and regular item
      AddInvNonDirectLocAllComponent(AssemblyHeader1,100);
      AddInvNonDirectLocAllComponent(AssemblyHeader2,100);
      AddInventoryNonDirectLocation(RegularItem."No.",LocationCode,'',3 * OrderQty);
      AddInventoryNonDirectLocation(ItemATS."No.",LocationCode,'',3 * OrderQty);

      // Exercise - batch post SOs
      CLEAR(SalesHeader);
      SalesHeader.SETRANGE("Document Type",SalesHeader."Document Type"::Order);
      SalesHeader.SETFILTER("No.",SalesHeader1."No." + '|' + SalesHeader2."No.");
      LibrarySales.BatchPostSalesHeaders(SalesHeader,TRUE,TRUE,0D,FALSE,FALSE,FALSE);

      // Verify - SOs posted and invoiced - no SOs
      // No ATO headers - posted
      COMMIT;
      ASSERTERROR SalesHeader.GET(SalesHeader1."Document Type",SalesHeader1."No.");
      ASSERTERROR SalesHeader.GET(SalesHeader2."Document Type",SalesHeader2."No.");
      AssertNoAssemblyHeader(AssemblyHeader1."Document Type",AssemblyHeader1."No.");
      AssertNoAssemblyHeader(AssemblyHeader2."Document Type",AssemblyHeader2."No.");
      LibraryAssembly.VerifyPostedAssemblyHeader(TempAssemblyLine1,AssemblyHeader1,OrderQty);
      LibraryAssembly.VerifyPostedAssemblyHeader(TempAssemblyLine2,AssemblyHeader2,OrderQty + 1);
Member of Lib.Library - Sales


BlanketSalesOrderMakeOrder@36 Method

The procedure BlanketSalesOrderMakeOrder is available in codeunit 130509.

Syntax

BlanketSalesOrderMakeOrder@36(
    VAR SalesHeader@1000 : Record 36 SalesHeader //Reference parameter of type Record
);

Parameters

SalesHeader
Reference parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Blanket, Sales, Order, Make, Order.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(BlanketSalesOrderToOrder);
      BlanketSalesOrderToOrder.RUN(SalesHeader);
      BlanketSalesOrderToOrder.GetSalesOrderHeader(SalesOrderHeader);
      EXIT(SalesOrderHeader."No.");

Example

The below example is extracted from the test automation codeunit 134377 to show one way of using this function.

      Customer.GET(LibrarySales.CreateCustomerNo);
      LibraryERM.CreatePaymentTermsDiscount(PaymentTerms,FALSE);
      Customer.VALIDATE("Payment Terms Code",PaymentTerms.Code);
      Customer.MODIFY(TRUE);

      CreateSalesBlanketOrder(BlanketSalesHeader,BlanketSalesLine,1,Customer."No.",LibraryInventory.CreateItemNo);
      BlanketSalesHeader.VALIDATE("Document Date",BlanketSalesHeader."Document Date" - 1);
      BlanketSalesHeader.MODIFY;

      SalesHeaderNo := LibrarySales.BlanketSalesOrderMakeOrder(BlanketSalesHeader);
      SalesHeader.GET(SalesHeader."Document Type"::Order,SalesHeaderNo);

      WITH SalesHeader DO BEGIN
        PaymentTerms.GET("Prepmt. Payment Terms Code");
        TESTFIELD("Document Date",WORKDATE);
        TESTFIELD("Prepayment Due Date",CALCDATE(PaymentTerms."Due Date Calculation","Document Date"));
        TESTFIELD("Prepmt. Pmt. Discount Date",CALCDATE(PaymentTerms."Discount Date Calculation","Document Date"));
        TESTFIELD("Due Date",CALCDATE(PaymentTerms."Due Date Calculation","Document Date"));
        TESTFIELD("Pmt. Discount Date",CALCDATE(PaymentTerms."Discount Date Calculation","Document Date"));
      END;
Member of Lib.Library - Sales


CalcSalesDiscount@77 Method

The procedure CalcSalesDiscount is available in codeunit 130509.

Syntax

CalcSalesDiscount@77(
    SalesHeader@1000 : Record 36 SalesHeader //Input parameter of type Record
);

Parameters

SalesHeader
Input parameter of type Record

Remarks

The relevant search keywords are: Calc, Sales, Discount.

For a clarification about how this function works, refer to the code listed below.

      SalesLine."Document Type" := SalesHeader."Document Type";
      SalesLine."Document No." := SalesHeader."No.";
      CODEUNIT.RUN(CODEUNIT::"Sales-Calc. Discount",SalesLine);

Example

The below example is extracted from the test automation codeunit 134104 to show one way of using this function.

      PrepareUnitPrices_TFS229419_ExclVAT(UnitPrices);
      CreateSalesOrder_TFS229419(SalesHeader,ItemNo,FALSE,DiscountPct,PrepaymentPct);
      CreateSalesOrderLines_TFS229419(SalesHeader,ItemNo,UnitPrices);
      LibrarySales.CalcSalesDiscount(SalesHeader);
Member of Lib.Library - Sales


CombineReturnReceipts@39 Method

The procedure CombineReturnReceipts is available in codeunit 130509.

Syntax

CombineReturnReceipts@39(
    VAR SalesHeader@1000 : Record 36 SalesHeader, //Reference parameter of type Record
    VAR ReturnReceiptHeader@1001 : Record 6660 ReturnReceiptHeader, //Reference parameter of type Record
    PostingDate@1002 : Date PostingDate, //Input parameter of type Date
    DocDate@1003 : Date DocDate, //Input parameter of type Date
    CalcInvDiscount@1004 : Boolean CalcInvDiscount, //Input parameter of type Boolean
    PostCreditMemos@1005 : Boolean PostCreditMemos //Input parameter of type Boolean
);

Parameters

SalesHeader
Reference parameter of type Record
ReturnReceiptHeader
Reference parameter of type Record
PostingDate
Input parameter of type Date
DocDate
Input parameter of type Date
CalcInvDiscount
Input parameter of type Boolean
PostCreditMemos
Input parameter of type Boolean

Remarks

The relevant search keywords are: Combine, Return, Receipts.

For a clarification about how this function works, refer to the code listed below.

      CombineReturnReceipts.InitializeRequest(PostingDate,DocDate,CalcInvDiscount,PostCreditMemos);
      IF SalesHeader.HASFILTER THEN
        TmpSalesHeader.COPYFILTERS(SalesHeader)
      ELSE BEGIN
        SalesHeader.GET(SalesHeader."No.",SalesHeader."Document Type");
        TmpSalesHeader.SETRANGE("Document Type",SalesHeader."Document Type");
        TmpSalesHeader.SETRANGE("No.",SalesHeader."No.");
      END;
      CombineReturnReceipts.SETTABLEVIEW(TmpSalesHeader);
      IF ReturnReceiptHeader.HASFILTER THEN
        TmpReturnReceiptHeader.COPYFILTERS(ReturnReceiptHeader)
      ELSE BEGIN
        ReturnReceiptHeader.GET(ReturnReceiptHeader."No.");
        TmpReturnReceiptHeader.SETRANGE("No.",ReturnReceiptHeader."No.");
      END;
      CombineReturnReceipts.SETTABLEVIEW(TmpReturnReceiptHeader);
      CombineReturnReceipts.USEREQUESTPAGE(FALSE);
      CombineReturnReceipts.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 137052 to show one way of using this function.

      // Setup: Create Item With Tracking Code Serial Specific, Create Customer, Create two Sales Return Order and assign Tracking and Post with Receive option.
      Initialize;
      CreateItem(Item,ItemTrackingCodeSerialSpecific.Code,Item."Costing Method"::FIFO);
      CreateItem(Item2,ItemTrackingCodeSerialSpecific.Code,Item2."Costing Method"::FIFO);
      CreateCustomerWithCombineShipments(Customer);  // Create Customer require for Combine Return Receipt.

      SetGlobalValue(Item."No.",FALSE,FALSE,FALSE,AssignTracking::SerialNo,0,FALSE);
      CreateAndPostSalesReturnOrderWithTracking(
        SalesHeader,SalesLine,Customer."No.",Item."No.",LocationBlue.Code,LibraryRandom.RandInt(10));
      CreateAndPostSalesReturnOrderWithTracking(
        SalesHeader2,SalesLine2,Customer."No.",Item2."No.",LocationBlue.Code,LibraryRandom.RandInt(10));

      // Exercise: Combine Sales Return Receipt and Post Invoice.
      SalesHeader2.SETRANGE("Sell-to Customer No.",Customer."No.");
      ReturnReceiptHeader.SETRANGE("Sell-to Customer No.",Customer."No.");
      LibrarySales.CombineReturnReceipts(SalesHeader2,ReturnReceiptHeader,WORKDATE,WORKDATE,FALSE,TRUE);

      // Verify: Verify Tracking line on Posted Sales Credit Memo Line.
      SetGlobalValue(Item."No.",FALSE,FALSE,FALSE,AssignTracking::None,SalesLine.Quantity,FALSE);  // Tracking Quantity required.
      SalesCrMemoHeader.SETRANGE("Sell-to Customer No.",Customer."No.");
      SalesCrMemoHeader.FINDFIRST;

      VerifyTrackingOnSalesCrMemoLine(SalesCrMemoHeader."No.",Item."No.");
      SetGlobalValue(Item."No.",FALSE,FALSE,FALSE,AssignTracking::None,SalesLine2.Quantity,FALSE);  // Tracking Quantity required.
      VerifyTrackingOnSalesCrMemoLine(SalesCrMemoHeader."No.",Item2."No.");
Member of Lib.Library - Sales


CombineShipments@37 Method

The procedure CombineShipments is available in codeunit 130509.

Syntax

CombineShipments@37(
    VAR SalesHeader@1003 : Record 36 SalesHeader, //Reference parameter of type Record
    VAR SalesShipmentHeader@1004 : Record 110 SalesShipmentHeader, //Reference parameter of type Record
    PostingDate@1005 : Date PostingDate, //Input parameter of type Date
    DocumentDate@1006 : Date DocumentDate, //Input parameter of type Date
    CalcInvDisc@1007 : Boolean CalcInvDisc, //Input parameter of type Boolean
    PostInvoices@1008 : Boolean PostInvoices, //Input parameter of type Boolean
    OnlyStdPmtTerms@1009 : Boolean OnlyStdPmtTerms, //Input parameter of type Boolean
    CopyTextLines@1010 : Boolean CopyTextLines //Input parameter of type Boolean
);

Parameters

SalesHeader
Reference parameter of type Record
SalesShipmentHeader
Reference parameter of type Record
PostingDate
Input parameter of type Date
DocumentDate
Input parameter of type Date
CalcInvDisc
Input parameter of type Boolean
PostInvoices
Input parameter of type Boolean
OnlyStdPmtTerms
Input parameter of type Boolean
CopyTextLines
Input parameter of type Boolean

Remarks

The relevant search keywords are: Combine, Shipments.

For a clarification about how this function works, refer to the code listed below.

      CombineShipments.InitializeRequest(PostingDate,DocumentDate,CalcInvDisc,PostInvoices,OnlyStdPmtTerms,CopyTextLines);
      IF SalesHeader.HASFILTER THEN
        TmpSalesHeader.COPYFILTERS(SalesHeader)
      ELSE BEGIN
        SalesHeader.GET(SalesHeader."No.",SalesHeader."Document Type");
        TmpSalesHeader.SETRANGE("Document Type",SalesHeader."Document Type");
        TmpSalesHeader.SETRANGE("No.",SalesHeader."No.");
        END;
      CombineShipments.SETTABLEVIEW(TmpSalesHeader);
      IF SalesShipmentHeader.HASFILTER THEN
        TmpSalesShipmentHeader.COPYFILTERS(SalesShipmentHeader)
      ELSE BEGIN
        SalesShipmentHeader.GET(SalesShipmentHeader."No.");
        TmpSalesShipmentHeader.SETRANGE("No.",SalesShipmentHeader."No.");
      END;
      CombineShipments.SETTABLEVIEW(TmpSalesShipmentHeader);
      CombineShipments.USEREQUESTPAGE(FALSE);
      CombineShipments.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 137052 to show one way of using this function.

      // Setup: Create Item With Tracking Code Serial Specific, Create Customer, Create two Sales Order and assign Tracking and Post with Ship option.
      Initialize;
      CreateItem(Item,ItemTrackingCodeSerialSpecific.Code,Item."Costing Method"::FIFO);
      CreateItem(Item2,ItemTrackingCodeSerialSpecific.Code,Item2."Costing Method"::FIFO);
      CreateCustomerWithCombineShipments(Customer);  // Create Customer require for Combine Shipments.
      CreateAndPostItemJournalLine(
        ItemJournalLine."Entry Type"::"Positive Adjmt.",Item."No.",LocationBlue.Code,LibraryRandom.RandInt(10) + 10,0,FALSE,
        AssignTracking::SerialNo);  // Using Large random value for Quantity.
      CreateAndPostItemJournalLine(
        ItemJournalLine."Entry Type"::"Positive Adjmt.",Item2."No.",LocationBlue.Code,LibraryRandom.RandInt(10) + 10,0,FALSE,
        AssignTracking::SerialNo);  // Using Large random value for Quantity.

      SetGlobalValue(Item."No.",FALSE,FALSE,FALSE,AssignTracking::None,0,FALSE);
      CreateAndPostSalesOrderWithTracking(
        SalesHeader,SalesLine,Customer."No.",Item."No.",LocationBlue.Code,LibraryRandom.RandInt(10));
      CreateAndPostSalesOrderWithTracking(
        SalesHeader2,SalesLine2,Customer."No.",Item2."No.",LocationBlue.Code,LibraryRandom.RandInt(10));

      // Exercise: Combine Sales Shipments and Post Invoice.
      SalesHeader2.SETRANGE("Sell-to Customer No.",Customer."No.");
      SalesShipmentHeader.SETRANGE("Sell-to Customer No.",Customer."No.");
      LibrarySales.CombineShipments(SalesHeader2,SalesShipmentHeader,WORKDATE,WORKDATE,FALSE,TRUE,FALSE,FALSE);

      // Verify: Verify Tracking line on Posted Sales Invoive Line.
      SetGlobalValue(Item."No.",FALSE,FALSE,FALSE,AssignTracking::None,SalesLine.Quantity,FALSE);  // Tracking Quantity required.
      SalesInvoiceHeader.SETRANGE("Sell-to Customer No.",Customer."No.");
      SalesInvoiceHeader.FINDFIRST;

      VerifyTrackingOnSalesInvoiceLine(SalesInvoiceHeader."No.",Item."No.");
      SetGlobalValue(Item."No.",FALSE,FALSE,FALSE,AssignTracking::None,SalesLine2.Quantity,FALSE);  // Tracking Quantity required.
      VerifyTrackingOnSalesInvoiceLine(SalesInvoiceHeader."No.",Item2."No.");
Member of Lib.Library - Sales


CopySalesDocument@60 Method

The procedure CopySalesDocument is available in codeunit 130509.

Syntax

CopySalesDocument@60(
    SalesHeader@1000 : Record 36 SalesHeader, //Input parameter of type Record
    DocType@1005 : Option DocType, //Input parameter of type Option
    DocNo@1004 : Code[20] DocNo, //Input parameter of type Code
    IncludeHeader@1003 : Boolean IncludeHeader, //Input parameter of type Boolean
    RecalcLines@1002 : Boolean RecalcLines //Input parameter of type Boolean
);

Parameters

SalesHeader
Input parameter of type Record
DocType
Input parameter of type Option
DocNo
Input parameter of type Code
IncludeHeader
Input parameter of type Boolean
RecalcLines
Input parameter of type Boolean

Remarks

The relevant search keywords are: Copy, Sales, Document.

For a clarification about how this function works, refer to the code listed below.

      CopySalesDocument.SetSalesHeader(SalesHeader);
      CopySalesDocument.InitializeRequest(DocType,DocNo,IncludeHeader,RecalcLines);
      CopySalesDocument.USEREQUESTPAGE(FALSE);
      CopySalesDocument.RUN;

Example

The below example is extracted from the test automation codeunit 134017 to show one way of using this function.

      // Covers Test Case 124089.
      // Check Customer Ledger Entry for Payment Tolerance after posting Sales Credit Memo and Copy Document.

      // Setup: Update General ledger Setup and Create and Post Sales Invoice.
      Initialize;
      LibraryPmtDiscSetup.SetPmtTolerance(5);
      CreateSalesDocument(SalesHeader,'',SalesHeader."Document Type"::Invoice);
      SalesInvoiceNo := LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);
      SalesHeader.INIT;
      SalesHeader.VALIDATE("Document Type",SalesHeader."Document Type"::"Credit Memo");
      SalesHeader.INSERT(TRUE);

      // Exercise: Create and Post Sales Credit Memo after Copy Document with Document Type Posted Invoice.
      LibrarySales.CopySalesDocument(SalesHeader,DocumentType::"Posted Invoice",SalesInvoiceNo,TRUE,TRUE);
      SalesHeader.SETRANGE("Applies-to Doc. No.",SalesInvoiceNo);
      SalesHeader.FINDFIRST;
      DocumentNo := LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      // Verify: Max Payment Tolerance is zero for Credit Memo applied to Invoice.
      VerifyMaxPaymentTolCreditMemo(DocumentNo,0);
Member of Lib.Library - Sales


CreateCustomer@3 Method

The procedure CreateCustomer is available in codeunit 130509.

Syntax

CreateCustomer@3(
    VAR Customer@1000 : Record 18 Customer //Reference parameter of type Record
);

Parameters

Customer
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Customer.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.FindPaymentMethod(PaymentMethod);
      LibraryERM.FindGeneralPostingSetupInvtFull(GeneralPostingSetup);
      LibraryERM.FindVATPostingSetupInvt(VATPostingSetup);
      LibraryUtility.UpdateSetupNoSeriesCode(
        DATABASE::"Sales & Receivables Setup",SalesReceivablesSetup.FIELDNO("Customer Nos."));

      CLEAR(Customer);
      Customer.INSERT(TRUE);
      Customer.VALIDATE(Name,Customer."No.");  // Validating Name as No. because value is not important.
      Customer.VALIDATE("Payment Method Code",PaymentMethod.Code);  // Mandatory for posting in ES build
      Customer.VALIDATE("Payment Terms Code",LibraryERM.FindPaymentTermsCode);  // Mandatory for posting in ES build
      Customer.VALIDATE("Gen. Bus. Posting Group",GeneralPostingSetup."Gen. Bus. Posting Group");
      Customer.VALIDATE("VAT Bus. Posting Group",VATPostingSetup."VAT Bus. Posting Group");
      Customer.VALIDATE("Customer Posting Group",FindCustomerPostingGroup);
      Customer.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134000 to show one way of using this function.

      LibraryERM.GetDiscountPaymentTerm(PaymentTerms);
      LibrarySales.CreateCustomer(Customer);
      Customer.VALIDATE("Payment Terms Code",PaymentTerms.Code);
      Customer.MODIFY(TRUE);
      EXIT(Customer."No.");
Member of Lib.Library - Sales


CreateCustomerBankAccount@24 Method

The procedure CreateCustomerBankAccount is available in codeunit 130509.

Syntax

CreateCustomerBankAccount@24(
    VAR CustomerBankAccount@1001 : Record 287 CustomerBankAccount, //Reference parameter of type Record
    CustomerNo@1000 : Code[20] CustomerNo //Input parameter of type Code
);

Parameters

CustomerBankAccount
Reference parameter of type Record
CustomerNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Customer, Bank, Account.

For a clarification about how this function works, refer to the code listed below.

      CustomerBankAccount.INIT;
      CustomerBankAccount.VALIDATE("Customer No.",CustomerNo);
      CustomerBankAccount.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(CustomerBankAccount.FIELDNO(Code),DATABASE::"Customer Bank Account"),
          1,
          LibraryUtility.GetFieldLength(DATABASE::"Customer Bank Account",CustomerBankAccount.FIELDNO(Code))));
      CustomerBankAccount.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134231 to show one way of using this function.

      // [FEATURE] [UT] [Sales]
      // [SCENARIO 378203] Customer Bank Account cannot be deleted when it has associated open entries
      Initialize;

      // [GIVEN] Customer with Customer Bank Account "X"
      LibrarySales.CreateCustomer(Customer);
      LibrarySales.CreateCustomerBankAccount(CustomerBankAccount,Customer."No.");

      // [GIVEN] Opened Customer Ledger Entry with "Recipient Bank Account" = "X"
      CreateCustLedgEntry(CustomerBankAccount,TRUE);

      // [WHEN] Delete Customer Bank Account "X"
      ASSERTERROR CustomerBankAccount.DELETE(TRUE);

      // [THEN] Error Message: You cannot delete this bank account because there are one or more open entries associated with it.
      Assert.ExpectedError(BankAccDeleteErr);
Member of Lib.Library - Sales


CreateCustomerMandate@27 Method

The procedure CreateCustomerMandate is available in codeunit 130509.

Syntax

CreateCustomerMandate@27(
    VAR SEPADirectDebitMandate@1000 : Record 1230 SEPADirectDebitMandate, //Reference parameter of type Record
    CustomerNo@1001 : Code[20] CustomerNo, //Input parameter of type Code
    CustomerBankCode@1002 : Code[10] CustomerBankCode, //Input parameter of type Code
    FromDate@1003 : Date FromDate, //Input parameter of type Date
    ToDate@1004 : Date ToDate //Input parameter of type Date
);

Parameters

SEPADirectDebitMandate
Reference parameter of type Record
CustomerNo
Input parameter of type Code
CustomerBankCode
Input parameter of type Code
FromDate
Input parameter of type Date
ToDate
Input parameter of type Date

Remarks

The relevant search keywords are: Create, Customer, Mandate.

For a clarification about how this function works, refer to the code listed below.

      SEPADirectDebitMandate.INIT;
      SEPADirectDebitMandate.VALIDATE("Customer No.",CustomerNo);
      SEPADirectDebitMandate.VALIDATE("Customer Bank Account Code",CustomerBankCode);
      SEPADirectDebitMandate.VALIDATE("Valid From",FromDate);
      SEPADirectDebitMandate.VALIDATE("Valid To",ToDate);
      SEPADirectDebitMandate.VALIDATE("Date of Signature",FromDate);
      SEPADirectDebitMandate.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134404 to show one way of using this function.

      FOR i := 1 TO ARRAYLEN(CustomerBankAccount) DO
        LibrarySales.CreateCustomerMandate(
          SEPADirectDebitMandate[i],CustomerBankAccount[i]."Customer No.",CustomerBankAccount[i].Code,
          CALCDATE('<-CY>',WORKDATE),CALCDATE('<CY>',WORKDATE));
Member of Lib.Library - Sales


CreateCustomerNo@30 Method

The procedure CreateCustomerNo is available in codeunit 130509.

Syntax

CreateCustomerNo@30(
      //param element not supplied
);

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Customer, No.

For a clarification about how this function works, refer to the code listed below.

      CreateCustomer(Customer);
      EXIT(Customer."No.");

Example

The below example is extracted from the test automation codeunit 134006 to show one way of using this function.

      // [SCENARIO 380040] During application, if there is no "Applies-to ID", then "The application could not be posted, because no entry
      // [SCENARIO] has been selected to be applied / for none of the open entries the "Applies-to ID" has been specfied." error message should appear

      Initialize;

      // [GIVEN] Customer CCC
      CustomerNo := LibrarySales.CreateCustomerNo;

      // [GIVEN] Gen. Journal Batch GJB with two lines
      // [GIVEN] Gen. Journal Line JL1: an invoice for Custmer CCC with "Document No" = 123 and "Amount" = -1000
      LibraryERM.CreateGenJournalTemplate(GenJournalTemplate);
      LibraryERM.CreateGenJournalBatch(GenJournalBatch,GenJournalTemplate.Name);
      Amount := LibraryRandom.RandDec(1000,2);
      LibraryERM.CreateGeneralJnlLineWithBalAcc(
        GenJournalLine,GenJournalTemplate.Name,GenJournalBatch.Name,GenJournalLine."Document Type"::Invoice,
        GenJournalLine."Account Type"::"G/L Account",LibraryERM.CreateGLAccountNo,
        GenJournalLine."Bal. Account Type"::Customer,CustomerNo,-Amount);
      DocNo := GenJournalLine."Document No.";

      // [GIVEN] Gen. Journal Line JL2: a payment for Custmer CCC with "Document No" = 123 (same as JL1) and "Amount" = 1000
      LibraryERM.CreateGeneralJnlLineWithBalAcc(
        GenJournalLine,GenJournalTemplate.Name,GenJournalBatch.Name,GenJournalLine."Document Type"::Payment,
        GenJournalLine."Account Type"::"G/L Account",LibraryERM.CreateGLAccountNo,
        GenJournalLine."Bal. Account Type"::Customer,CustomerNo,Amount);
      GenJournalLine.VALIDATE("Document No.",DocNo);
      GenJournalLine.MODIFY(TRUE);

      // [GIVEN] Batch GJB posted
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // [GIVEN] Openned Customer Ledger Entries for Customer CCC, selected Payment JL2 and called action "Apply Entries"
      LibraryERM.FindCustomerLedgerEntry(CustLedgerEntry,CustLedgerEntry."Document Type"::Payment,DocNo);

      // [WHEN] Apply Payment to Invoice
      ASSERTERROR CustEntryApplyPostedEntries.Apply(CustLedgerEntry,DocNo,WORKDATE);

      // [THEN] The following message appears: Cannot post because you did not specify which entry to apply. You must specify an entry in the Applies-to ID field for one or more open entries.
      Assert.ExpectedError(NoEntriesAppliedErr);
Member of Lib.Library - Sales


CreateCustomerPostingGroup@50 Method

The procedure CreateCustomerPostingGroup is available in codeunit 130509.

Syntax

CreateCustomerPostingGroup@50(
    VAR CustomerPostingGroup@1000 : Record 92 CustomerPostingGroup //Reference parameter of type Record
);

Parameters

CustomerPostingGroup
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Customer, Posting, Group.

For a clarification about how this function works, refer to the code listed below.

      CustomerPostingGroup.INIT;
      CustomerPostingGroup.VALIDATE(Code,
        LibraryUtility.GenerateRandomCode(CustomerPostingGroup.FIELDNO(Code),DATABASE::"Customer Posting Group"));
      CustomerPostingGroup.VALIDATE("Receivables Account",LibraryERM.CreateGLAccountNo);
      CustomerPostingGroup.VALIDATE("Invoice Rounding Account",LibraryERM.CreateGLAccountWithSalesSetup);
      CustomerPostingGroup.VALIDATE("Debit Rounding Account",LibraryERM.CreateGLAccountNo);
      CustomerPostingGroup.VALIDATE("Credit Rounding Account",LibraryERM.CreateGLAccountNo);
      CustomerPostingGroup.VALIDATE("Payment Disc. Debit Acc.",LibraryERM.CreateGLAccountNo);
      CustomerPostingGroup.VALIDATE("Payment Disc. Credit Acc.",LibraryERM.CreateGLAccountNo);
      CustomerPostingGroup.VALIDATE("Payment Tolerance Debit Acc.",LibraryERM.CreateGLAccountNo);
      CustomerPostingGroup.VALIDATE("Payment Tolerance Credit Acc.",LibraryERM.CreateGLAccountNo);
      CustomerPostingGroup.VALIDATE("Debit Curr. Appln. Rndg. Acc.",LibraryERM.CreateGLAccountNo);
      CustomerPostingGroup.VALIDATE("Credit Curr. Appln. Rndg. Acc.",LibraryERM.CreateGLAccountNo);
      CustomerPostingGroup.VALIDATE("Interest Account",LibraryERM.CreateGLAccountWithSalesSetup);
      CustomerPostingGroup.VALIDATE("Additional Fee Account",LibraryERM.CreateGLAccountWithSalesSetup);
      CustomerPostingGroup.VALIDATE("Add. Fee per Line Account",LibraryERM.CreateGLAccountWithSalesSetup);
      CustomerPostingGroup.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134093 to show one way of using this function.

      Initialize;

      LibrarySales.CreateCustomerPostingGroup(CustomerPostingGroup);
      CustomerPostingGroup.VALIDATE("Invoice Rounding Account",LibraryERM.CreateGLAccountWithSalesSetup);
      CustomerPostingGroup.MODIFY;
      LibraryVariableStorage.Enqueue(CustomerPostingGroup.FIELDNAME("Invoice Rounding Account"));

      // Execute
      CalcGLAccWhereUsed.CheckGLAcc(CustomerPostingGroup."Invoice Rounding Account");

      // Validate in page handler
Member of Lib.Library - Sales


CreateCustomerPriceGroup@6 Method

The procedure CreateCustomerPriceGroup is available in codeunit 130509.

Syntax

CreateCustomerPriceGroup@6(
    VAR CustomerPriceGroup@1000 : Record 6 CustomerPriceGroup //Reference parameter of type Record
);

Parameters

CustomerPriceGroup
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Customer, Price, Group.

For a clarification about how this function works, refer to the code listed below.

      CustomerPriceGroup.INIT;
      CustomerPriceGroup.VALIDATE(
        Code,LibraryUtility.GenerateRandomCode(CustomerPriceGroup.FIELDNO(Code),DATABASE::"Customer Price Group"));
      CustomerPriceGroup.VALIDATE(Description,CustomerPriceGroup.Code);
      // Validating Description as Code because value is not important.
      CustomerPriceGroup.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134100 to show one way of using this function.

      // [FEATURE] [Sales] [Sales Prepayment %]
      // [SCENARIO] Setting up a Prepayment % between 0 to 100 with 5 decimal places for Sales Type Customer Price Group.

      // 1. Setup: Create a new Customer and Item. Create Sales Prepayment and Validate Prepayment %
      // between 0 to 100 with 5 decimal places for Sales Type Customer Price Group.
      Initialize;
      CreateItem(Item);
      LibrarySales.CreateCustomerPriceGroup(CustomerPriceGroup);
      CustomerNo := CreateCustomerWithPriceGroup(CustomerPriceGroup.Code);
      CreatePrepayment(
        SalesPrepaymentPct,SalesPrepaymentPct."Sales Type"::"Customer Price Group",CustomerPriceGroup.Code,Item."No.",
        LibraryRandom.RandDec(99,5));  // Random Number Generator for Prepayment Percent.

      // 2. Exercise: Create Sales Header, Sales Line for Item.
      CreateSalesDocumentPrepayment(SalesHeader,SalesLine,CustomerNo,Item."No.");

      // 3. Verify: Check that the Prepayment % on Sales Line is same as defined on Sales Prepayment, the calculation for Prepmt.
      // Line Amount on Sales Line are as per Prepayment % inputted and Prepayment Percent on Sales Header.
      VerifyPrepaymentLineAmount(SalesLine,SalesPrepaymentPct."Prepayment %");
      VerifyPrepaymentPercent(SalesHeader,SalesLine,0,SalesPrepaymentPct."Prepayment %");  // Prepayment percent in Customer is zero.
Member of Lib.Library - Sales


CreateCustomerSalesCode@25 Method

The procedure CreateCustomerSalesCode is available in codeunit 130509.

Syntax

CreateCustomerSalesCode@25(
    VAR StandardCustomerSalesCode@1000 : Record 172 StandardCustomerSalesCode, //Reference parameter of type Record
    CustomerNo@1001 : Code[20] CustomerNo, //Input parameter of type Code
    Code@1002 : Code[10] Code //Input parameter of type Code
);

Parameters

StandardCustomerSalesCode
Reference parameter of type Record
CustomerNo
Input parameter of type Code
Code
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Customer, Sales, Code.

For a clarification about how this function works, refer to the code listed below.

      StandardCustomerSalesCode.INIT;
      StandardCustomerSalesCode.VALIDATE("Customer No.",CustomerNo);
      StandardCustomerSalesCode.VALIDATE(Code,Code);
      StandardCustomerSalesCode.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134386 to show one way of using this function.

      LibrarySales.CreateStandardSalesCode(StandardSalesCode);
      LibrarySales.CreateStandardSalesLine(StandardSalesLine,StandardSalesCode.Code);
      ModifyStandardSalesLine(StandardSalesLine,ItemNo,ShortcutDimension1Code,ShortcutDimension2Code);
      StandardSalesLine.GET(StandardSalesLine."Standard Sales Code",StandardSalesLine."Line No.");
      LibrarySales.CreateCustomer(Customer);
      LibrarySales.CreateCustomerSalesCode(StandardCustomerSalesCode,Customer."No.",StandardSalesCode.Code);
      LibrarySales.CreateSalesHeader(SalesHeader,SalesHeader."Document Type"::Order,Customer."No.");
      StandardCustomerSalesCode.InsertSalesLines(SalesHeader);
Member of Lib.Library - Sales


CreateCustomerTemplate@1 Method

The procedure CreateCustomerTemplate is available in codeunit 130509.

Syntax

CreateCustomerTemplate@1(
    VAR CustomerTemplate@1000 : Record 5105 CustomerTemplate //Reference parameter of type Record
);

Parameters

CustomerTemplate
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Customer, Template.

For a clarification about how this function works, refer to the code listed below.

      CustomerTemplate.INIT;
      CustomerTemplate.VALIDATE(Code,LibraryUtility.GenerateRandomCode(CustomerTemplate.FIELDNO(Code),DATABASE::"Customer Template"));
      CustomerTemplate.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136101 to show one way of using this function.

      LibrarySales.CreateCustomer(Customer);
      LibrarySales.CreateCustomerTemplate(CustomerTemplate);
      CustomerTemplate.VALIDATE("Gen. Bus. Posting Group",Customer."Gen. Bus. Posting Group");
      CustomerTemplate.VALIDATE("Customer Posting Group",Customer."Customer Posting Group");
      CustomerTemplate.MODIFY(TRUE);
Member of Lib.Library - Sales


CreateCustomerWithAddress@65 Method

The procedure CreateCustomerWithAddress is available in codeunit 130509.

Syntax

CreateCustomerWithAddress@65(
    VAR Customer@1001 : Record 18 Customer //Reference parameter of type Record
);

Parameters

Customer
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Customer, Address.

For a clarification about how this function works, refer to the code listed below.

      CreateCustomer(Customer);
      CreateCustomerAddress(Customer);

Example

There are no examples available.
Member of Lib.Library - Sales


CreateCustomerWithBusPostingGroups@53 Method

The procedure CreateCustomerWithBusPostingGroups is available in codeunit 130509.

Syntax

CreateCustomerWithBusPostingGroups@53(
    GenBusPostGroupCode@1001 : Code[10] GenBusPostGroupCode, //Input parameter of type Code
    VATBusPostGroupCode@1002 : Code[10] VATBusPostGroupCode //Input parameter of type Code
);

Parameters

GenBusPostGroupCode
Input parameter of type Code
VATBusPostGroupCode
Input parameter of type Code

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Customer, Business, Posting, Groups.

For a clarification about how this function works, refer to the code listed below.

      WITH Customer DO BEGIN
        CreateCustomer(Customer);
        VALIDATE("Gen. Bus. Posting Group",GenBusPostGroupCode);
        VALIDATE("VAT Bus. Posting Group",VATBusPostGroupCode);
        MODIFY(TRUE);
        EXIT("No.");
      END;

Example

The below example is extracted from the test automation codeunit 134090 to show one way of using this function.

      CreateNormalVATPostingSetupWithAdjPmtDisc(VATPostingSetup,VATPct);
      CreateGeneralPostingSetup(GeneralPostingSetup);

      CustomerNo :=
        LibrarySales.CreateCustomerWithBusPostingGroups(
          GeneralPostingSetup."Gen. Bus. Posting Group",VATPostingSetup."VAT Bus. Posting Group");
      LibraryERM.CreateGLAccount(GLAccount);
      LibraryERM.UpdateGLAccountWithPostingSetup(
        GLAccount,GLAccount."Gen. Posting Type"::Sale,GeneralPostingSetup,VATPostingSetup);
      GLAccountNo := GLAccount."No.";
Member of Lib.Library - Sales


CreateCustomerWithLocationCode@102 Method

The procedure CreateCustomerWithLocationCode is available in codeunit 130509.

Syntax

CreateCustomerWithLocationCode@102(
    VAR Customer@1000 : Record 18 Customer, //Reference parameter of type Record
    LocationCode@1001 : Code[10] LocationCode //Input parameter of type Code
);

Parameters

Customer
Reference parameter of type Record
LocationCode
Input parameter of type Code

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Customer, Location, Code.

For a clarification about how this function works, refer to the code listed below.

      WITH Customer DO BEGIN
        CreateCustomer(Customer);
        VALIDATE("Location Code",LocationCode);
        MODIFY(TRUE);
        EXIT("No.");
      END;

Example

The below example is extracted from the test automation codeunit 134383 to show one way of using this function.

      // [SCENARIO 360231] Verify that location code can be updated in sales order with blank line.

      // [GIVEN] Sales Order with blank line
      Initialize;
      CreateSalesOrderWithBlankLine(SalesHeader);
      LibraryWarehouse.CreateLocation(Location);
      // [GIVEN] Customer A with location code X
      LibrarySales.CreateCustomerWithLocationCode(Customer,Location.Code);
      SalesHeader.SetHideValidationDialog(TRUE);

      // [WHEN] Set Customer A as "Sell-To Customer No."
      SalesHeader.VALIDATE("Sell-to Customer No.",Customer."No.");

      // [THEN] Location code on the header is X
      Assert.AreEqual(Customer."Location Code",SalesHeader."Location Code",UnexpectedLocationCodeErr);
Member of Lib.Library - Sales


CreateCustomerWithStateCode@1500000 Method

The procedure CreateCustomerWithStateCode is available in codeunit 130509.

Syntax

CreateCustomerWithStateCode@1500000(
    VAR Customer@1500000 : Record 18 Customer, //Reference parameter of type Record
    StateCode@1500001 : Code[10] StateCode //Input parameter of type Code
);

Parameters

Customer
Reference parameter of type Record
StateCode
Input parameter of type Code

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Customer, State, Code.

For a clarification about how this function works, refer to the code listed below.

      WITH Customer DO BEGIN
        CreateCustomer(Customer);
        VALIDATE("State Code",StateCode);
        MODIFY(TRUE);
        EXIT("No.");
      END;

Example

The below example is extracted from the test automation codeunit 144014 to show one way of using this function.

      LibrarySales.CreateCustomerWithStateCode(Customer,State.Code);
      Customer.VALIDATE("Tax Liable",TRUE);
      Customer.MODIFY;
      LibraryERM.CreateInvDiscForCustomer(CustInvoiceDisc,Customer."No.",'',0);
      CustInvoiceDisc.VALIDATE("Discount %",LibraryRandom.RandIntInRange(5,10));
      CustInvoiceDisc.MODIFY(TRUE);
      EXIT(Customer."No.");
Member of Lib.Library - Sales


CreateCustomerWithVATBusPostingGroup@63 Method

The procedure CreateCustomerWithVATBusPostingGroup is available in codeunit 130509.

Syntax

CreateCustomerWithVATBusPostingGroup@63(
    VATBusPostGroupCode@1001 : Code[10] VATBusPostGroupCode //Input parameter of type Code
);

Parameters

VATBusPostGroupCode
Input parameter of type Code

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Customer, VAT, Business, Posting, Group.

For a clarification about how this function works, refer to the code listed below.

      WITH Customer DO BEGIN
        CreateCustomer(Customer);
        VALIDATE("VAT Bus. Posting Group",VATBusPostGroupCode);
        MODIFY(TRUE);
        EXIT("No.");
      END;

Example

The below example is extracted from the test automation codeunit 134022 to show one way of using this function.

      CreatePaymentTerms(PaymentTerms);
      LibrarySales.CreateSalesHeader(
        SalesHeader,SalesHeader."Document Type"::Invoice,
        LibrarySales.CreateCustomerWithVATBusPostingGroup(VATPostingSetup."VAT Bus. Posting Group"));
      SalesHeader.VALIDATE("Payment Terms Code",PaymentTerms.Code);
      SalesHeader.MODIFY(TRUE);
      LibrarySales.CreateSalesLine(
        SalesLine,SalesHeader,SalesLine.Type::"G/L Account",GLAccNo,LibraryRandom.RandDec(10,2));
      SalesLine.VALIDATE("Unit Price",LibraryRandom.RandDec(100,2));
      SalesLine.MODIFY(TRUE);
      UpdateGenPostingSetupWithPmtDiscAcc(SalesLine."Gen. Bus. Posting Group",SalesLine."Gen. Prod. Posting Group");
      EXIT(LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE));
Member of Lib.Library - Sales


CreateCustomerWithVATRegNo@35 Method

The procedure CreateCustomerWithVATRegNo is available in codeunit 130509.

Syntax

CreateCustomerWithVATRegNo@35(
    VAR Customer@1000 : Record 18 Customer //Reference parameter of type Record
);

Parameters

Customer
Reference parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Customer, VAT, Reg, No.

For a clarification about how this function works, refer to the code listed below.

      CreateCustomer(Customer);
      LibraryERM.CreateCountryRegion(CountryRegion);
      Customer.VALIDATE("Country/Region Code",CountryRegion.Code);
      Customer.VALIDATE("VAT Registration No.",LibraryERM.GenerateVATRegistrationNo(CountryRegion.Code));
      Customer.MODIFY(TRUE);
      EXIT(Customer."No.");

Example

The below example is extracted from the test automation codeunit 134029 to show one way of using this function.

      // [SCENARIO 121626] "Country Code","VAT Registration No.","Bill-to/Pay-to No." are copied to VAT Entry from Customer that is set as "Bal. Account" while "Account No." is empty in the Gen. Journal Line.
      Initialize;

      // [GIVEN] Two Posting Dates "D1", "D2". "D2" > "D1".
      FOR i := 1 TO 2 DO BEGIN
        PostingDate[i] := WORKDATE + i;
        Amount[i] := LibraryRandom.RandDec(100,2);
      END;

      // [GIVEN] G/L Account "S" with posting type "Sale"
      GLAccountNo := LibraryERM.CreateGLAccountWithSalesSetup;

      // [GIVEN] Customer "C1" with "Country Code" = "X1" and "VAT Registration No." = "Y1"
      LibrarySales.CreateCustomerWithVATRegNo(Customer[1]);

      // [GIVEN] Customer "C2" with "Country Code" = "X2" and "VAT Registration No." = "Y2"
      LibrarySales.CreateCustomerWithVATRegNo(Customer[2]);

      // [GIVEN] 1st Journal Line with "Posting Date" = "D2", empty "Account No.", "Bal. Account Type"="Customer", "Bal. Account No." = "C2"
      FindAndClearGenJnlBatch(GenJournalBatch);
      CreateCustGenJournalLine(GenJournalLine,GenJournalBatch,PostingDate[2],Customer[2]."No.",Amount[2]);

      // [GIVEN] 2nd Journal Line with "Posting Date" = "D1", empty "Account No.", "Bal. Account Type"="Customer", "Bal. Account No." = "C1"
      CreateCustGenJournalLine(GenJournalLine,GenJournalBatch,PostingDate[1],Customer[1]."No.",Amount[1]);

      // [GIVEN] 3rd Journal Line with "Posting Date" = "D2", "Account No." = "S" and empty "Bal. Account No."
      CreateGLGenJournalLine(GenJournalLine,GenJournalBatch,PostingDate[2],GLAccountNo,Amount[2]);

      // [GIVEN] 4th Journal Line with "Posting Date" = "D1", "Account No." = "S" and empty "Bal. Account No."
      CreateGLGenJournalLine(GenJournalLine,GenJournalBatch,PostingDate[1],GLAccountNo,Amount[1]);

      // [GIVEN] Change order Gen Journal Lines By "Posting Date". New line's numbers order: 2, 4, 1, 3
      GenJournalLine.SETCURRENTKEY("Journal Template Name","Journal Batch Name","Posting Date","Document No.");

      // [WHEN] Post Gen. Journal lines
      CODEUNIT.RUN(CODEUNIT::"Gen. Jnl.-Post Batch",GenJournalLine);

      // [THEN] Posted VAT Entry related to Customer "C1" has "Country Code" = "X1", "VAT Registration No." = "Y1", "Bill-to/Pay-to No." = "C1"
      FindCustLedgerEntry(CustLedgerEntry,Customer[1]."No.");
      VerifyVATEntryCVInfo(
        CustLedgerEntry."Transaction No.",
        Customer[1]."Country/Region Code",Customer[1]."VAT Registration No.",Customer[1]."No.");

      // [THEN] Posted VAT Entry related to Customer "C2" has "Country Code" = "X2", "VAT Registration No." = "Y2", "Bill-to/Pay-to No." = "C2"
      FindCustLedgerEntry(CustLedgerEntry,Customer[2]."No.");
      VerifyVATEntryCVInfo(
        CustLedgerEntry."Transaction No.",
        Customer[2]."Country/Region Code",Customer[2]."VAT Registration No.",Customer[2]."No.");
Member of Lib.Library - Sales


CreateFCYSalesDocumentWithItem@56 Method

The procedure CreateFCYSalesDocumentWithItem is available in codeunit 130509.

Syntax

CreateFCYSalesDocumentWithItem@56(
    VAR SalesHeader@1008 : Record 36 SalesHeader, //Reference parameter of type Record
    VAR SalesLine@1007 : Record 37 SalesLine, //Reference parameter of type Record
    DocumentType@1006 : Option DocumentType, //Input parameter of type Option
    CustomerNo@1005 : Code[20] CustomerNo, //Input parameter of type Code
    ItemNo@1004 : Code[20] ItemNo, //Input parameter of type Code
    Quantity@1002 : Decimal Quantity, //Input parameter of type Decimal
    LocationCode@1001 : Code[10] LocationCode, //Input parameter of type Code
    ShipmentDate@1000 : Date ShipmentDate, //Input parameter of type Date
    CurrencyCode@1003 : Code[10] CurrencyCode //Input parameter of type Code
);

Parameters

SalesHeader
Reference parameter of type Record
SalesLine
Reference parameter of type Record
DocumentType
Input parameter of type Option
CustomerNo
Input parameter of type Code
ItemNo
Input parameter of type Code
Quantity
Input parameter of type Decimal
LocationCode
Input parameter of type Code
ShipmentDate
Input parameter of type Date
CurrencyCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, FCY, Sales, Document, Item.

For a clarification about how this function works, refer to the code listed below.

      CreateSalesHeader(SalesHeader,DocumentType,CustomerNo);
      IF LocationCode <> '' THEN
        SalesHeader.VALIDATE("Location Code",LocationCode);
      IF CurrencyCode <> '' THEN
        SalesHeader.VALIDATE("Currency Code",CurrencyCode);
      SalesHeader.MODIFY(TRUE);
      IF ItemNo = '' THEN
        ItemNo := LibraryInventory.CreateItemNo;
      CreateSalesLine(SalesLine,SalesHeader,SalesLine.Type::Item,ItemNo,Quantity);
      IF LocationCode <> '' THEN
        SalesLine.VALIDATE("Location Code",LocationCode);
      IF ShipmentDate <> 0D THEN
        SalesLine.VALIDATE("Shipment Date",ShipmentDate);
      SalesLine.VALIDATE("Unit Price",LibraryRandom.RandDec(100,2));
      SalesLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134976 to show one way of using this function.

      // [FEATURE] [FCY] [Report]
      // [SENARIO 381014] Print "Customer - Order Summary" when sales order has a currency code different from the customer's currency code and different from the LCY.

      // [GIVEN] Customer with LCY
      // [GIVEN] Sales Order with Amount = "X", "Amount (LCY)" = "Y" invoiced in foreign currency
      LibrarySales.CreateFCYSalesDocumentWithItem(
        SalesHeader,SalesLine,SalesHeader."Document Type"::Order,
        LibrarySales.CreateCustomerNo,LibraryInventory.CreateItemNo,1,'',0D,
        LibraryERM.CreateCurrencyWithRandomExchRates);
      COMMIT;

      // [WHEN] Run "Customer - Order Summary" report with "Print in LCY" option
      RunCustOrderSummaryReport(SalesHeader."Sell-to Customer No.",TRUE);

      // [THEN] Printed Sales Amount is equal to "Y"
      VerifyCustomerOrderSummarySalesAmount(SalesHeader,SalesLine);
Member of Lib.Library - Sales


CreateForeignCustomer@1500012 Method

The procedure CreateForeignCustomer is available in codeunit 130509.

Syntax

CreateForeignCustomer@1500012(
    CurrencyCode@1500000 : Code[10] CurrencyCode //Input parameter of type Code
);

Parameters

CurrencyCode
Input parameter of type Code

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Foreign, Customer.

For a clarification about how this function works, refer to the code listed below.

      CreateCustomer(Customer);
      Customer.VALIDATE("Currency Code",CurrencyCode);
      Customer.MODIFY(TRUE);
      EXIT(Customer."No.");

Example

The below example is extracted from the test automation codeunit 144014 to show one way of using this function.

      CustomerNo := LibrarySales.CreateForeignCustomer(CurrencyCode);
      LibraryERM.CreateGeneralJnlLine(GenJournalLine,GenJournalBatch."Journal Template Name",GenJournalBatch.Name,
        GenJournalLine."Document Type"::Payment,GenJournalLine."Account Type"::Customer,
        CustomerNo,-LibraryRandom.RandDecInRange(10000,20000,2));
      WITH GenJournalLine DO BEGIN
        VALIDATE("Party Type","Party Type"::Customer);
        VALIDATE("Party Code",CustomerNo);
        VALIDATE("Serv. Tax on Advance Payment",TRUE);
        VALIDATE("Service Tax Group Code",ServiceTaxGroups.Code);
        VALIDATE("Service Tax Registration No.",ServiceTaxRegistrationNos.Code);
        VALIDATE("Bal. Account Type","Bal. Account Type"::"Bank Account");
        VALIDATE("Bal. Account No.",LibraryERM.CreateBankAccountNo);
        MODIFY(TRUE);
      END
Member of Lib.Library - Sales


CreateItemChargeAssignment@43 Method

The procedure CreateItemChargeAssignment is available in codeunit 130509.

Syntax

CreateItemChargeAssignment@43(
    VAR ItemChargeAssignmentSales@1000 : Record 5809 ItemChargeAssignmentSales, //Reference parameter of type Record
    SalesLine@1001 : Record 37 SalesLine, //Input parameter of type Record
    ItemCharge@1011 : Record 5800 ItemCharge, //Input parameter of type Record
    DocType@1010 : Option DocType, //Input parameter of type Option
    DocNo@1009 : Code[20] DocNo, //Input parameter of type Code
    DocLineNo@1008 : Integer DocLineNo, //Input parameter of type Integer
    ItemNo@1007 : Code[20] ItemNo, //Input parameter of type Code
    Qty@1006 : Decimal Qty, //Input parameter of type Decimal
    UnitCost@1005 : Decimal UnitCost //Input parameter of type Decimal
);

Parameters

ItemChargeAssignmentSales
Reference parameter of type Record
SalesLine
Input parameter of type Record
ItemCharge
Input parameter of type Record
DocType
Input parameter of type Option
DocNo
Input parameter of type Code
DocLineNo
Input parameter of type Integer
ItemNo
Input parameter of type Code
Qty
Input parameter of type Decimal
UnitCost
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Item, Charge, Assignment.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(ItemChargeAssignmentSales);

      WITH ItemChargeAssignmentSales DO BEGIN
        "Document Type" := SalesLine."Document Type";
        "Document No." := SalesLine."Document No.";
        "Document Line No." := SalesLine."Line No.";
        "Item Charge No." := SalesLine."No.";
        "Unit Cost" := SalesLine."Unit Cost";
        RecRef.GETTABLE(ItemChargeAssignmentSales);
        "Line No." := LibraryUtility.GetNewLineNo(RecRef,FIELDNO("Line No."));
        "Item Charge No." := ItemCharge."No.";
        "Applies-to Doc. Type" := DocType;
        "Applies-to Doc. No." := DocNo;
        "Applies-to Doc. Line No." := DocLineNo;
        "Item No." := ItemNo;
        "Unit Cost" := UnitCost;
        VALIDATE("Qty. to Assign",Qty);
      END;

Example

The below example is extracted from the test automation codeunit 134378 to show one way of using this function.

      FindShipmentLine(SalesShipmentLine,OrderNo);
      LibraryInventory.CreateItemChargeAssignment(
        ItemChargeAssignmentSales,SalesLine,ItemChargeAssignmentSales."Applies-to Doc. Type"::Shipment,
        SalesShipmentLine."Document No.",SalesShipmentLine."Line No.",SalesShipmentLine."No.");
Member of Lib.Library - Sales


CreatePaymentAndApplytoInvoice@69 Method

The procedure CreatePaymentAndApplytoInvoice is available in codeunit 130509.

Syntax

CreatePaymentAndApplytoInvoice@69(
    VAR GenJournalLine@1003 : Record 81 GenJournalLine, //Reference parameter of type Record
    CustomerNo@1004 : Code[20] CustomerNo, //Input parameter of type Code
    AppliesToDocNo@1007 : Code[20] AppliesToDocNo, //Input parameter of type Code
    Amount@1005 : Decimal Amount //Input parameter of type Decimal
);

Parameters

GenJournalLine
Reference parameter of type Record
CustomerNo
Input parameter of type Code
AppliesToDocNo
Input parameter of type Code
Amount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Payment, Applyto, Invoice.

For a clarification about how this function works, refer to the code listed below.

      CreateGeneralJournalBatch(GenJournalBatch);
      LibraryERM.CreateGLAccount(GLAccount);
      LibraryERM.CreateGeneralJnlLine(
        GenJournalLine,GenJournalBatch."Journal Template Name",GenJournalBatch.Name,GenJournalLine."Document Type"::Payment,
        GenJournalLine."Account Type"::Customer,CustomerNo,Amount);

      // Value of Document No. is not important.
      GenJournalLine.VALIDATE("Document No.",GenJournalLine."Journal Batch Name" + FORMAT(GenJournalLine."Line No."));
      GenJournalLine.VALIDATE("Applies-to Doc. Type",GenJournalLine."Applies-to Doc. Type"::Invoice);
      GenJournalLine.VALIDATE("Applies-to Doc. No.",AppliesToDocNo);
      GenJournalLine.VALIDATE("Bal. Account No.",GLAccount."No.");
      GenJournalLine.MODIFY(TRUE);
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

Example

The below example is extracted from the test automation codeunit 134000 to show one way of using this function.

      // [FEATURE] [Dimension] [Payment Discount]
      // [SCENARIO 376797] Error try posting sales payment journal without dimension applied to posted Invoice in case of Discount, "Payment Disc. Debit Acc." with default dimension with "Value Posting" = "Same Code"
      Initialize;

      // [GIVEN] Customer with "Payment Disc. Debit Acc." = "A"
      // [GIVEN] Default Dimension "D" with "Value Posting" = "Same Code" is set for G/L Account "A"
      CustomerNo := CreateCustomer;
      CreateDefaultDimensionGLAccSameValue(DimensionValue,CreateCustPostingGrPmtDiscDebitAccNo(CustomerNo));

      // [GIVEN] Posted Sales Invoice with Amount Including VAT = 10000 and possible Discount = 2%. No dimension is set.
      CreateAndPostGenJnlLine(
        GenJournalLine,WORKDATE,GenJournalLine."Document Type"::Invoice,LibraryRandom.RandIntInRange(1000,2000),CustomerNo,'');
      PaymentAmount := -GenJournalLine.Amount + GenJournalLine.Amount * GetPmtTermsDiscountPct / 100;

      // [GIVEN] Sales Journal with Payment Amount = 9800 and applied to posted Invoice. No dimension is set.
      // [WHEN] Post Sales Journal
      ASSERTERROR LibrarySales.CreatePaymentAndApplytoInvoice(
          GenJournalLine,CustomerNo,GenJournalLine."Document No.",PaymentAmount);

      // [THEN] Error occurs: "A dimension used in Gen. Journal Line GENERAL, CASH, 10000 has caused an error."
      Assert.ExpectedErrorCode(DialogTxt);
      Assert.ExpectedError(
        STRSUBSTNO(DimensionUsedErr,
          GenJournalLine.TABLECAPTION,GenJournalLine."Journal Template Name",
          GenJournalLine."Journal Batch Name",GenJournalLine."Line No."));
Member of Lib.Library - Sales


CreatePrepaymentVATSetup@34 Method

The procedure CreatePrepaymentVATSetup is available in codeunit 130509.

Syntax

CreatePrepaymentVATSetup@34(
    VAR LineGLAccount@1001 : Record 15 LineGLAccount, //Reference parameter of type Record
    VATCalculationType@1000 : Option VATCalculationType //Input parameter of type Option
);

Parameters

LineGLAccount
Reference parameter of type Record
VATCalculationType
Input parameter of type Option

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Prepayment, VAT, Setup.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.CreatePrepaymentVATSetup(
        LineGLAccount,PrepmtGLAccount,LineGLAccount."Gen. Posting Type"::Sale,VATCalculationType,VATCalculationType);
      EXIT(PrepmtGLAccount."No.");

Example

The below example is extracted from the test automation codeunit 134100 to show one way of using this function.

      // [FEATURE] [Sales] [VAT]
      // [SCENARIO 128406] Changed VAT Prod Posting Group on Sales Line.

      // 1. Setup: Create a Sales Order, create an Item, create a Customer with new posting setup, change the Prepayement Percent in Sales
      // Line, change the VAT Prod. Posting Group in Sales Line.
      Initialize;
      LibrarySales.CreatePrepaymentVATSetup(LineGLAccount,VATCalculationType::"Normal VAT");
      CreateSalesDocumentPrepayment(
        SalesHeader,SalesLine,CreateCustomerWithVAT(LineGLAccount."VAT Bus. Posting Group"),
        CreateItemVATProdPostingGroup(LineGLAccount."VAT Prod. Posting Group"));
      UpdateGeneralPostingSetupInGL(SalesLine);
      FindSalesLine(SalesLine,SalesHeader);
      PrepaymentPercentInSalesLine(SalesLine,LibraryRandom.RandDec(99,5));
      NewVATProdPostingGr := LibraryERM.CreateRelatedVATPostingSetup(LineGLAccount);
      SalesLine.VALIDATE("VAT Prod. Posting Group",NewVATProdPostingGr);
      SalesLine.MODIFY(TRUE);

      // 2. Exercise: Post the Prepayment Invoice and post the Sales Order as Ship and Invoice.
      LibrarySales.PostSalesPrepaymentInvoice(SalesHeader);
      InvoiceNo := LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      // 3. Verify: Verify GL Account.
      VerifyGLAccountForVAT(SalesLine);
      VerifyGLAccountForNewVAT(SalesLine,InvoiceNo);
Member of Lib.Library - Sales


CreateSalesCommentLine@22 Method

The procedure CreateSalesCommentLine is available in codeunit 130509.

Syntax

CreateSalesCommentLine@22(
    VAR SalesCommentLine@1000 : Record 44 SalesCommentLine, //Reference parameter of type Record
    DocumentType@1001 : Option DocumentType, //Input parameter of type Option
    No@1003 : Code[20] No, //Input parameter of type Code
    DocumentLineNo@1004 : Integer DocumentLineNo //Input parameter of type Integer
);

Parameters

SalesCommentLine
Reference parameter of type Record
DocumentType
Input parameter of type Option
No
Input parameter of type Code
DocumentLineNo
Input parameter of type Integer

Remarks

The relevant search keywords are: Create, Sales, Comment, Line.

For a clarification about how this function works, refer to the code listed below.

      SalesCommentLine.INIT;
      SalesCommentLine.VALIDATE("Document Type",DocumentType);
      SalesCommentLine.VALIDATE("No.",No);
      SalesCommentLine.VALIDATE("Document Line No.",DocumentLineNo);
      RecRef.GETTABLE(SalesCommentLine);
      SalesCommentLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,SalesCommentLine.FIELDNO("Line No.")));
      SalesCommentLine.INSERT(TRUE);
      // Validate Comment as primary key to enable user to distinguish between comments because value is not important.
      SalesCommentLine.VALIDATE(
        Comment,FORMAT(SalesCommentLine."Document Type") + SalesCommentLine."No." +
        FORMAT(SalesCommentLine."Document Line No.") + FORMAT(SalesCommentLine."Line No."));
      SalesCommentLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 136202 to show one way of using this function.

      // 1. Setup: Create Sales Header, Sales Line with Type Item, Create Comments for Sales Header and Sales Line, Archive the Sales
      // Document.
      CreateSalesDocumentWithItem(SalesHeader,SalesLine,DocumentType);
      LibrarySales.CreateSalesCommentLine(SalesCommentLine,DocumentType,SalesHeader."No.",0);
      Comment := SalesCommentLine.Comment;
      LibrarySales.CreateSalesCommentLine(SalesCommentLine,DocumentType,SalesHeader."No.",SalesLine."Line No.");
      Comment2 := SalesCommentLine.Comment;
      ArchiveManagement.ArchiveSalesDocument(SalesHeader);

      // 2. Exercise: Delete Comments for Sales Header and Sales Line, Restore the Archived Sales Document.
      SalesCommentLine.SETRANGE("Document Type",SalesHeader."Document Type");
      SalesCommentLine.SETRANGE("No.",SalesHeader."No.");
      SalesCommentLine.DELETEALL(TRUE);

      SalesHeaderArchive.SETRANGE("Document Type",SalesHeader."Document Type");
      SalesHeaderArchive.SETRANGE("No.",SalesHeader."No.");
      SalesHeaderArchive.FINDFIRST;
      ArchiveManagement.RestoreSalesDocument(SalesHeaderArchive);

      // 3. Verify: Verify Comments on Service Header and Service Line.
      VerifySalesCommentLine(SalesHeader,0,Comment);
      VerifySalesCommentLine(SalesHeader,SalesLine."Line No.",Comment2);
Member of Lib.Library - Sales


CreateSalesDocumentWithItem@33 Method

The procedure CreateSalesDocumentWithItem is available in codeunit 130509.

Syntax

CreateSalesDocumentWithItem@33(
    VAR SalesHeader@1000 : Record 36 SalesHeader, //Reference parameter of type Record
    VAR SalesLine@1008 : Record 37 SalesLine, //Reference parameter of type Record
    DocumentType@1001 : Option DocumentType, //Input parameter of type Option
    CustomerNo@1003 : Code[20] CustomerNo, //Input parameter of type Code
    ItemNo@1002 : Code[20] ItemNo, //Input parameter of type Code
    Quantity@1004 : Decimal Quantity, //Input parameter of type Decimal
    LocationCode@1005 : Code[10] LocationCode, //Input parameter of type Code
    ShipmentDate@1006 : Date ShipmentDate //Input parameter of type Date
);

Parameters

SalesHeader
Reference parameter of type Record
SalesLine
Reference parameter of type Record
DocumentType
Input parameter of type Option
CustomerNo
Input parameter of type Code
ItemNo
Input parameter of type Code
Quantity
Input parameter of type Decimal
LocationCode
Input parameter of type Code
ShipmentDate
Input parameter of type Date

Remarks

The relevant search keywords are: Create, Sales, Document, Item.

For a clarification about how this function works, refer to the code listed below.

      CreateFCYSalesDocumentWithItem(SalesHeader,SalesLine,DocumentType,CustomerNo,ItemNo,Quantity,LocationCode,ShipmentDate,'');

Example

The below example is extracted from the test automation codeunit 134152 to show one way of using this function.

      // [FEATURE] [Sales] [Shipment]
      // [SCENARIO 271063] "IC Partner Ref. Type" and "IC Partner Reference" are transferred from Sales Line to Sales Shipment Line when posting Sales Order
      Initialize;

      // [GIVEN] Sales Order for IC Customer and Item "I"
      LibrarySales.CreateSalesDocumentWithItem(
        SalesHeader,SalesLine,SalesHeader."Document Type"::Order,CreateICCustomer(CreateICPartner),
        LibraryInventory.CreateItemNo,LibraryRandom.RandDecInRange(10,20,2),'',WORKDATE);

      // [WHEN] Post Purchase Order
      LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      // [THEN] Purchase Receipt Line has "IC Partner Ref. Type" = Item and "IC Partner Reference" = "I"
      SalesShipmentLine.SETRANGE("Sell-to Customer No.",SalesHeader."Sell-to Customer No.");
      SalesShipmentLine.FINDFIRST;
      SalesShipmentLine.TESTFIELD("IC Partner Ref. Type",SalesShipmentLine."IC Partner Ref. Type"::Item);
      SalesShipmentLine.TESTFIELD("IC Partner Reference",SalesLine."No.");
Member of Lib.Library - Sales


CreateSalesHeader@14 Method

The procedure CreateSalesHeader is available in codeunit 130509.

Syntax

CreateSalesHeader@14(
    VAR SalesHeader@1000 : Record 36 SalesHeader, //Reference parameter of type Record
    DocumentType@1001 : Option DocumentType, //Input parameter of type Option
    SellToCustomerNo@1002 : Code[20] SellToCustomerNo //Input parameter of type Code
);

Parameters

SalesHeader
Reference parameter of type Record
DocumentType
Input parameter of type Option
SellToCustomerNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Sales, Header.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(SalesHeader);
      SalesHeader.VALIDATE("Document Type",DocumentType);
      SalesHeader.INSERT(TRUE);
      IF SellToCustomerNo = '' THEN
        SellToCustomerNo := CreateCustomerNo;
      SalesHeader.VALIDATE("Sell-to Customer No.",SellToCustomerNo);
      SalesHeader.VALIDATE(
        "External Document No.",
        COPYSTR(LibraryUtility.GenerateRandomCode(SalesHeader.FIELDNO("External Document No."),DATABASE::"Sales Header"),1,20));
      UpdatePaymentChannel(SalesHeader);
      SetCorrDocNoSales(SalesHeader);
      SalesHeader.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134006 to show one way of using this function.

      // Check Remaining Amount on Customer Ledger Entry after Creating and Posting Sales Invoice without Currency and Apply with Partial Payment.

      // Setup: Create and Post Sales Invoice, Create a Customer Payment and apply it to posted Invoice.
      Initialize;
      LibrarySales.CreateCustomer(Customer);
      LibrarySales.CreateSalesHeader(SalesHeader,SalesHeader."Document Type"::Invoice,Customer."No.");
      CreateAndModifySalesLine(SalesHeader,LibraryRandom.RandDec(10,2),LibraryRandom.RandDec(100,2));
      PostedDocumentNo := LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);
      SelectGenJournalBatch(GenJournalBatch,FALSE);
      CreateGeneralJournalLines(
        GenJournalLine,GenJournalBatch,1,SalesHeader."Sell-to Customer No.",GenJournalLine."Document Type"::Payment,0);  // Taken 1 and 0 to create only one General Journal line with zero amount.
      Amount := OpenGeneralJournalPage(GenJournalLine."Document No.",GenJournalLine."Document Type");
      GenJournalLine.FIND;
      GenJournalLine.VALIDATE(Amount,GenJournalLine.Amount + Amount);
      GenJournalLine.MODIFY(TRUE);

      // Exericse.
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // Verify: Verify Remaining Amount on Customer Ledger Entry.
      LibraryERM.FindCustomerLedgerEntry(CustLedgerEntry,SalesHeader."Document Type",PostedDocumentNo);
      CustLedgerEntry.CALCFIELDS("Remaining Amount");
      CustLedgerEntry.TESTFIELD("Remaining Amount",Amount);
Member of Lib.Library - Sales


CreateSalesInvoice@55 Method

The procedure CreateSalesInvoice is available in codeunit 130509.

Syntax

CreateSalesInvoice@55(
    VAR SalesHeader@1000 : Record 36 SalesHeader //Reference parameter of type Record
);

Parameters

SalesHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Sales, Invoice.

For a clarification about how this function works, refer to the code listed below.

      CreateSalesHeader(SalesHeader,SalesHeader."Document Type"::Invoice,CreateCustomerNo);
      LibraryInventory.CreateItemWithUnitPriceAndUnitCost(
        Item,LibraryRandom.RandDecInRange(1,100,2),LibraryRandom.RandDecInRange(1,100,2));
      CreateSalesLine(SalesLine,SalesHeader,SalesLine.Type::Item,Item."No.",LibraryRandom.RandInt(100));

Example

The below example is extracted from the test automation codeunit 134141 to show one way of using this function.

      LibrarySales.CreateSalesInvoice(SalesHeader);
      LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);
      CustLedgerEntry.SETRANGE("Customer No.",SalesHeader."Sell-to Customer No.");
      CustLedgerEntry.FINDFIRST;
      CustLedgerEntry.CALCFIELDS("Remaining Amount");
      CustomerNo := CustLedgerEntry."Customer No.";
      CustLedgerEntryNo := CustLedgerEntry."Entry No.";
      RemainingAmount := CustLedgerEntry."Remaining Amount";
Member of Lib.Library - Sales


CreateSalesInvoiceForCustomerNo@79 Method

The procedure CreateSalesInvoiceForCustomerNo is available in codeunit 130509.

Syntax

CreateSalesInvoiceForCustomerNo@79(
    VAR SalesHeader@1000 : Record 36 SalesHeader, //Reference parameter of type Record
    CustomerNo@1003 : Code[20] CustomerNo //Input parameter of type Code
);

Parameters

SalesHeader
Reference parameter of type Record
CustomerNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Sales, Invoice, For, Customer, No.

For a clarification about how this function works, refer to the code listed below.

      CreateSalesHeader(SalesHeader,SalesHeader."Document Type"::Invoice,CustomerNo);
      LibraryInventory.CreateItemWithUnitPriceAndUnitCost(
        Item,LibraryRandom.RandDecInRange(1,100,2),LibraryRandom.RandDecInRange(1,100,2));
      CreateSalesLine(SalesLine,SalesHeader,SalesLine.Type::Item,Item."No.",LibraryRandom.RandInt(100));

Example

The below example is extracted from the test automation codeunit 134170 to show one way of using this function.

      LibrarySales.CreateCustomer(Customer);
      Customer.VALIDATE("Credit Limit (LCY)",LibraryRandom.RandInt(3));
      Customer.MODIFY(TRUE);
      LibrarySales.CreateSalesInvoiceForCustomerNo(SalesHeader,Customer."No.");
Member of Lib.Library - Sales


CreateSalesLine@17 Method

The procedure CreateSalesLine is available in codeunit 130509.

Syntax

CreateSalesLine@17(
    VAR SalesLine@1000 : Record 37 SalesLine, //Reference parameter of type Record
    SalesHeader@1001 : Record 36 SalesHeader, //Input parameter of type Record
    Type@1003 : Option Type, //Input parameter of type Option
    No@1004 : Code[20] No, //Input parameter of type Code
    Quantity@1005 : Decimal Quantity //Input parameter of type Decimal
);

Parameters

SalesLine
Reference parameter of type Record
SalesHeader
Input parameter of type Record
Type
Input parameter of type Option
No
Input parameter of type Code
Quantity
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Sales, Line.

For a clarification about how this function works, refer to the code listed below.

      CreateSalesLineWithShipmentDate(SalesLine,SalesHeader,Type,No,SalesHeader."Shipment Date",Quantity);

Example

The below example is extracted from the test automation codeunit 134006 to show one way of using this function.

      LibrarySales.CreateSalesHeader(SalesHeader,DocumentType,CustomerNo);
      SalesHeader.VALIDATE("Posting Date",PostingDate);
      SalesHeader.MODIFY(TRUE);
      LibrarySales.CreateSalesLine(SalesLine,SalesHeader,SalesLine.Type::Item,ItemNo,Quantity);
      SalesLine.VALIDATE("Unit Price",UnitPrice);
      SalesLine.MODIFY(TRUE);
      EXIT(LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE));
Member of Lib.Library - Sales


CreateSalesLineWithShipmentDate@16 Method

The procedure CreateSalesLineWithShipmentDate is available in codeunit 130509.

Syntax

CreateSalesLineWithShipmentDate@16(
    VAR SalesLine@1000 : Record 37 SalesLine, //Reference parameter of type Record
    SalesHeader@1001 : Record 36 SalesHeader, //Input parameter of type Record
    Type@1003 : Option Type, //Input parameter of type Option
    No@1004 : Code[20] No, //Input parameter of type Code
    ShipmentDate@1006 : Date ShipmentDate, //Input parameter of type Date
    Quantity@1005 : Decimal Quantity //Input parameter of type Decimal
);

Parameters

SalesLine
Reference parameter of type Record
SalesHeader
Input parameter of type Record
Type
Input parameter of type Option
No
Input parameter of type Code
ShipmentDate
Input parameter of type Date
Quantity
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Sales, Line, Shipment, Date.

For a clarification about how this function works, refer to the code listed below.

      SalesLine.INIT;
      SalesLine.VALIDATE("Document Type",SalesHeader."Document Type");
      SalesLine.VALIDATE("Document No.",SalesHeader."No.");
      RecRef.GETTABLE(SalesLine);
      SalesLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,SalesLine.FIELDNO("Line No.")));
      SalesLine.INSERT(TRUE);

      SalesLine.VALIDATE(Type,Type);
      CASE Type OF
        SalesLine.Type::Item:
          IF No = '' THEN
            No := LibraryInventory.CreateItemNo;
        SalesLine.Type::Resource:
          IF No = '' THEN
            No := LibraryResource.CreateResourceNo;
        SalesLine.Type::"Charge (Item)":
          IF No = '' THEN
            No := LibraryInventory.CreateItemChargeNo;
      END;

      IF No <> '' THEN
          FindType(SalesLine.Type,No,SalesHeader."Gen. Bus. Posting Group",SalesHeader."VAT Bus. Posting Group");

      SalesLine.VALIDATE("No.",No);
      SalesLine.VALIDATE("Shipment Date",ShipmentDate);
      SalesLine.VALIDATE(Quantity,Quantity);
      SalesLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 136137 to show one way of using this function.

      LibrarySales.CreateSalesHeader(SalesHeader,SalesHeader."Document Type"::"Blanket Order",CustNo);
      TotalQty := LibraryRandom.RandIntInRange(100,1000);
      QtyToShip := LibraryRandom.RandInt(TotalQty - 1);
      LibrarySales.CreateSalesLineWithShipmentDate(SalesLine,SalesHeader,SalesLine.Type::Item,ItemNo,ShipmentDate[1],TotalQty);
      LibrarySales.CreateSalesLineWithShipmentDate(SalesLine,SalesHeader,SalesLine.Type::Item,ItemNo,ShipmentDate[2],TotalQty);
      SalesLine.SETRANGE("Document Type",SalesLine."Document Type"::"Blanket Order");
      SalesLine.SETRANGE("Document No.",SalesHeader."No.");
      SalesLine.MODIFYALL("Qty. to Ship",QtyToShip);
Member of Lib.Library - Sales


CreateSalesperson@5 Method

The procedure CreateSalesperson is available in codeunit 130509.

Syntax

CreateSalesperson@5(
    VAR SalespersonPurchaser@1000 : Record 13 SalespersonPurchaser //Reference parameter of type Record
);

Parameters

SalespersonPurchaser
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Salesperson.

For a clarification about how this function works, refer to the code listed below.

      SalespersonPurchaser.INIT;
      SalespersonPurchaser.VALIDATE(
        Code,LibraryUtility.GenerateRandomCode(SalespersonPurchaser.FIELDNO(Code),DATABASE::"Salesperson/Purchaser"));
      SalespersonPurchaser.VALIDATE(Name,SalespersonPurchaser.Code);  // Validating Name as Code because value is not important.
      SalespersonPurchaser.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134141 to show one way of using this function.

      // [FEATURE] [UT] [Customer]
      // [SCENARIO 175792] Salesperson code as default dimension should be in dimension set of Bank Account Reconcilation Line after validation of Customer
      Initialize;

      // [GIVEN] Customer with Salesperson Code as default dimension = "X"
      LibrarySales.CreateCustomer(Customer);
      LibrarySales.CreateSalesperson(SalespersonPurchaser);
      Customer."Salesperson Code" := SalespersonPurchaser.Code;
      Customer.MODIFY;
      CreateDefaultDimensionWithSpecCode(SalespersonPurchaser.Code,DATABASE::"Salesperson/Purchaser");

      // [GIVEN] Record of Bank Account Reconcilation Line
      MockBankAccReconLine(BankAccReconciliationLine,BankAccReconciliationLine."Account Type"::Customer);

      // [WHEN] Validate Customer to "Account No." of Bank Account Reconcilation Line
      BankAccReconciliationLine.VALIDATE("Account No.",Customer."No.");

      // [THEN] Dimension set of Bank Account Reconcilation Line contains Salesperson Code = "X"
      VerifyDimSetEntryValue(BankAccReconciliationLine."Dimension Set ID",Customer."Salesperson Code");
Member of Lib.Library - Sales


CreateSalesPrepaymentPct@38 Method

The procedure CreateSalesPrepaymentPct is available in codeunit 130509.

Syntax

CreateSalesPrepaymentPct@38(
    VAR SalesPrepaymentPct@1000 : Record 459 SalesPrepaymentPct, //Reference parameter of type Record
    SalesType@1001 : Option SalesType, //Input parameter of type Option
    SalesCode@1002 : Code[20] SalesCode, //Input parameter of type Code
    ItemNo@1003 : Code[20] ItemNo, //Input parameter of type Code
    StartingDate@1004 : Date StartingDate //Input parameter of type Date
);

Parameters

SalesPrepaymentPct
Reference parameter of type Record
SalesType
Input parameter of type Option
SalesCode
Input parameter of type Code
ItemNo
Input parameter of type Code
StartingDate
Input parameter of type Date

Remarks

The relevant search keywords are: Create, Sales, Prepayment, Percent.

For a clarification about how this function works, refer to the code listed below.

      SalesPrepaymentPct.INIT;
      SalesPrepaymentPct.VALIDATE("Item No.",ItemNo);
      SalesPrepaymentPct.VALIDATE("Sales Type",SalesType);
      SalesPrepaymentPct.VALIDATE("Sales Code",SalesCode);
      SalesPrepaymentPct.VALIDATE("Starting Date",StartingDate);
      SalesPrepaymentPct.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134100 to show one way of using this function.

      // [FEATURE] [Sales] [Sales Prepayment %]
      // [SCENARIO] Setting up a Prepayment % for Not complete setup.

      // 1. Setup: Create new Customer and Item.
      Initialize;
      CreateItem(Item);

      // 2. Exercise: Create Sales Prepayment without Sales Code for Sales Type Customer.
      ASSERTERROR LibrarySales.CreateSalesPrepaymentPct(
          SalesPrepaymentPct,SalesPrepaymentPct."Sales Type"::Customer,'',Item."No.",WORKDATE);

      // 3. Verify: Check that while defining Prepayment %, system must give an error.
      Assert.IsTrue(STRPOS(GETLASTERRORTEXT,Item."No.") > 0,UnknownErr);
Member of Lib.Library - Sales


CreateSalesPrice@10 Method

The procedure CreateSalesPrice is available in codeunit 130509.

Syntax

CreateSalesPrice@10(
    VAR SalesPrice@1000 : Record 7002 SalesPrice, //Reference parameter of type Record
    ItemNo@1001 : Code[20] ItemNo, //Input parameter of type Code
    SalesType@1002 : Option SalesType, //Input parameter of type Option
    SalesCode@1003 : Code[20] SalesCode, //Input parameter of type Code
    StartingDate@1004 : Date StartingDate, //Input parameter of type Date
    CurrencyCode@1005 : Code[10] CurrencyCode, //Input parameter of type Code
    VariantCode@1006 : Code[10] VariantCode, //Input parameter of type Code
    UOMCode@1007 : Code[10] UOMCode, //Input parameter of type Code
    MinQty@1008 : Decimal MinQty, //Input parameter of type Decimal
    UnitPrice@1009 : Decimal UnitPrice //Input parameter of type Decimal
);

Parameters

SalesPrice
Reference parameter of type Record
ItemNo
Input parameter of type Code
SalesType
Input parameter of type Option
SalesCode
Input parameter of type Code
StartingDate
Input parameter of type Date
CurrencyCode
Input parameter of type Code
VariantCode
Input parameter of type Code
UOMCode
Input parameter of type Code
MinQty
Input parameter of type Decimal
UnitPrice
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Sales, Price.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(SalesPrice);
      SalesPrice.VALIDATE("Item No.",ItemNo);
      SalesPrice.VALIDATE("Sales Type",SalesType);
      SalesPrice.VALIDATE("Sales Code",SalesCode);
      SalesPrice.VALIDATE("Starting Date",StartingDate);
      SalesPrice.VALIDATE("Currency Code",CurrencyCode);
      SalesPrice.VALIDATE("Variant Code",VariantCode);
      SalesPrice.VALIDATE("Unit of Measure Code",UOMCode);
      SalesPrice.VALIDATE("Minimum Quantity",MinQty);
      SalesPrice.INSERT(TRUE);
      SalesPrice.VALIDATE("Unit Price",UnitPrice);
      SalesPrice.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134386 to show one way of using this function.

      // [FEATURE] [UT] [Customer Price Group] [Sales Price]
      // [SCENARIO 364564] Delete related "Sales Price" when "Customer Price Group" is deleted

      // [GIVEN] Customer Price Group = "X"
      // [GIVEN] Sales Price with "Sales Type" = "Customer Price Group" and "Sales Code" = "X"
      Initialize;
      LibrarySales.CreateCustomerPriceGroup(CustomerPriceGroup);
      LibraryCosting.CreateSalesPrice(
        SalesPrice,SalesPrice."Sales Type"::"Customer Price Group",CustomerPriceGroup.Code,
        LibraryInventory.CreateItemNo,WORKDATE,'','','',LibraryRandom.RandInt(100));

      // [WHEN] Delete Customer Price Group
      CustomerPriceGroup.DELETE(TRUE);

      // [THEN] Sales Price is removed
      SalesPrice.SETRANGE("Sales Type",SalesPrice."Sales Type"::"Customer Price Group");
      SalesPrice.SETRANGE("Sales Code",CustomerPriceGroup.Code);
      Assert.RecordIsEmpty(SalesPrice);
Member of Lib.Library - Sales


CreateShipToAddress@13 Method

The procedure CreateShipToAddress is available in codeunit 130509.

Syntax

CreateShipToAddress@13(
    VAR ShipToAddress@1000 : Record 222 ShipToAddress, //Reference parameter of type Record
    CustomerNo@1001 : Code[20] CustomerNo //Input parameter of type Code
);

Parameters

ShipToAddress
Reference parameter of type Record
CustomerNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Ship, To, Address.

For a clarification about how this function works, refer to the code listed below.

      ShipToAddress.INIT;
      ShipToAddress.VALIDATE("Customer No.",CustomerNo);
      ShipToAddress.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(ShipToAddress.FIELDNO(Code),DATABASE::"Ship-to Address"),
          1,
          LibraryUtility.GetFieldLength(DATABASE::"Ship-to Address",ShipToAddress.FIELDNO(Code))));
      ShipToAddress.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134332 to show one way of using this function.

      LibrarySales.CreateShipToAddress(ShipToAddress,CustomerNo);
      LibraryUtility.FillMaxText(ShipToAddress,ShipToAddress.FIELDNO(Name));
      ShipToAddress.GET(CustomerNo,ShipToAddress.Code);
      LibraryUtility.FillMaxText(ShipToAddress,ShipToAddress.FIELDNO("Name 2"));
      ShipToAddress.GET(CustomerNo,ShipToAddress.Code);
      LibraryUtility.FillMaxText(ShipToAddress,ShipToAddress.FIELDNO(Address));
      ShipToAddress.GET(CustomerNo,ShipToAddress.Code);
      LibraryUtility.FillMaxText(ShipToAddress,ShipToAddress.FIELDNO("Address 2"));
      ShipToAddress.GET(CustomerNo,ShipToAddress.Code);
      LibraryUtility.FillMaxText(ShipToAddress,ShipToAddress.FIELDNO(County));
      ShipToAddress.GET(CustomerNo,ShipToAddress.Code);
      ShipToAddress.VALIDATE("Post Code",CreatePostCode);
      ShipToAddress.MODIFY;
      EXIT(ShipToAddress.Code);
Member of Lib.Library - Sales


CreateStandardSalesCode@8 Method

The procedure CreateStandardSalesCode is available in codeunit 130509.

Syntax

CreateStandardSalesCode@8(
    VAR StandardSalesCode@1000 : Record 170 StandardSalesCode //Reference parameter of type Record
);

Parameters

StandardSalesCode
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Standard, Sales, Code.

For a clarification about how this function works, refer to the code listed below.

      StandardSalesCode.INIT;
      StandardSalesCode.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(StandardSalesCode.FIELDNO(Code),DATABASE::"Standard Sales Code"),
          1,
          LibraryUtility.GetFieldLength(DATABASE::"Standard Sales Code",StandardSalesCode.FIELDNO(Code))));
      // Validating Description as Code because value is not important.
      StandardSalesCode.VALIDATE(Description,StandardSalesCode.Code);
      StandardSalesCode.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134386 to show one way of using this function.

      LibrarySales.CreateStandardSalesCode(StandardSalesCode);
      LibrarySales.CreateStandardSalesLine(StandardSalesLine,StandardSalesCode.Code);
      ModifyStandardSalesLine(StandardSalesLine,ItemNo,ShortcutDimension1Code,ShortcutDimension2Code);
      StandardSalesLine.GET(StandardSalesLine."Standard Sales Code",StandardSalesLine."Line No.");
      LibrarySales.CreateCustomer(Customer);
      LibrarySales.CreateCustomerSalesCode(StandardCustomerSalesCode,Customer."No.",StandardSalesCode.Code);
      LibrarySales.CreateSalesHeader(SalesHeader,SalesHeader."Document Type"::Order,Customer."No.");
      StandardCustomerSalesCode.InsertSalesLines(SalesHeader);
Member of Lib.Library - Sales


CreateStandardSalesLine@15 Method

The procedure CreateStandardSalesLine is available in codeunit 130509.

Syntax

CreateStandardSalesLine@15(
    VAR StandardSalesLine@1000 : Record 171 StandardSalesLine, //Reference parameter of type Record
    StandardSalesCode@1001 : Code[10] StandardSalesCode //Input parameter of type Code
);

Parameters

StandardSalesLine
Reference parameter of type Record
StandardSalesCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Standard, Sales, Line.

For a clarification about how this function works, refer to the code listed below.

      StandardSalesLine.INIT;
      StandardSalesLine.VALIDATE("Standard Sales Code",StandardSalesCode);
      RecRef.GETTABLE(StandardSalesLine);
      StandardSalesLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,StandardSalesLine.FIELDNO("Line No.")));
      StandardSalesLine.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134386 to show one way of using this function.

      LibrarySales.CreateStandardSalesCode(StandardSalesCode);
      LibrarySales.CreateStandardSalesLine(StandardSalesLine,StandardSalesCode.Code);
      ModifyStandardSalesLine(StandardSalesLine,ItemNo,ShortcutDimension1Code,ShortcutDimension2Code);
      StandardSalesLine.GET(StandardSalesLine."Standard Sales Code",StandardSalesLine."Line No.");
      LibrarySales.CreateCustomer(Customer);
      LibrarySales.CreateCustomerSalesCode(StandardCustomerSalesCode,Customer."No.",StandardSalesCode.Code);
      LibrarySales.CreateSalesHeader(SalesHeader,SalesHeader."Document Type"::Order,Customer."No.");
      StandardCustomerSalesCode.InsertSalesLines(SalesHeader);
Member of Lib.Library - Sales


CreateStandardTextWithExtendedText@130 Method

The procedure CreateStandardTextWithExtendedText is available in codeunit 130509.

Syntax

CreateStandardTextWithExtendedText@130(
    VAR StandardText@1004 : Record 7 StandardText, //Reference parameter of type Record
    VAR ExtendedText@1003 : Text ExtendedText //Reference parameter of type Text
);

Parameters

StandardText
Reference parameter of type Record
ExtendedText
Reference parameter of type Text

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Standard, Text, Extended, Text.

For a clarification about how this function works, refer to the code listed below.

      StandardText.INIT;
      StandardText.Code := LibraryUtility.GenerateRandomCode(StandardText.FIELDNO(Code),DATABASE::"Standard Text");
      StandardText.Description := LibraryUtility.GenerateGUID;
      StandardText.INSERT;
      LibrarySmallBusiness.CreateExtendedTextHeader(
        ExtendedTextHeader,ExtendedTextHeader."Table Name"::"Standard Text",StandardText.Code);
      LibrarySmallBusiness.CreateExtendedTextLine(ExtendedTextLine,ExtendedTextHeader);
      ExtendedText := ExtendedTextLine.Text;
      EXIT(StandardText.Code);

Example

The below example is extracted from the test automation codeunit 134327 to show one way of using this function.

      // [FEATURE] [Standard Text] [Extended Text]
      // [SCENARIO 380579] Replacing of Purchase Line's Standard Text Code updates attached Extended Text lines
      Initialize;

      // [GIVEN] Standard Text (Code = "ST1", Description = "SD1") with Extended Text "ET1".
      // [GIVEN] Standard Text (Code = "ST2", Description = "SD2") with Extended Text "ET2".
      // [GIVEN] Purchase Order with line: "Type" = "", "No." = "ST1"
      LibraryPurchase.CreatePurchHeader(PurchaseHeader,PurchaseHeader."Document Type"::Order,LibraryPurchase.CreateVendorNo);
      MockPurchaseLine(PurchaseLine,PurchaseHeader);
      ValidatePurchaseLineStandardCode(PurchaseLine,LibrarySales.CreateStandardTextWithExtendedText(StandardText,ExtendedText));

      // [WHEN] Validate Purchase Line "No." = "ST2"
      ValidatePurchaseLineStandardCode(PurchaseLine,LibrarySales.CreateStandardTextWithExtendedText(StandardText,ExtendedText));

      // [THEN] There are two Purchase lines:
      // [THEN] Line1: Type = "", "No." = "ST2", Description = "SD2"
      // [THEN] Line2: Type = "", "No." = "", Description = "ET2"
      VerifyPurchaseLineCount(PurchaseHeader,2);
      VerifyPurchaseLineDescription(PurchaseLine,PurchaseLine.Type::" ",StandardText.Code,StandardText.Description);
      PurchaseLine.NEXT;
      VerifyPurchaseLineDescription(PurchaseLine,PurchaseLine.Type::" ",'',ExtendedText);
Member of Lib.Library - Sales


DeleteInvoicedSalesOrders@41 Method

The procedure DeleteInvoicedSalesOrders is available in codeunit 130509.

Syntax

DeleteInvoicedSalesOrders@41(
    VAR SalesHeader@1000 : Record 36 SalesHeader //Reference parameter of type Record
);

Parameters

SalesHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Delete, Invoiced, Sales, Orders.

For a clarification about how this function works, refer to the code listed below.

      IF SalesHeader.HASFILTER THEN
        TmpSalesHeader.COPYFILTERS(SalesHeader)
      ELSE BEGIN
        SalesHeader.GET(SalesHeader."Document Type",SalesHeader."No.");
        TmpSalesHeader.SETRANGE("Document Type",SalesHeader."Document Type");
        TmpSalesHeader.SETRANGE("No.",SalesHeader."No.");
      END;
      DeleteInvoicedSalesOrders.SETTABLEVIEW(TmpSalesHeader);
      DeleteInvoicedSalesOrders.USEREQUESTPAGE(FALSE);
      DeleteInvoicedSalesOrders.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 137061 to show one way of using this function.

      // Post Invoice and delete Invoiced Sales Orders.
      // 1. Setup.
      Initialize;
      SalesReceivablesSetup.GET;
      LibrarySales.SetStockoutWarning(FALSE);
      CreateItem(Item);

      // Create and Post Sales Orders.Combine Sales Shipments and Post Invoice.
      CombineSalesShipmentsSetup(Customer,Item,SalesShipmentNo,SalesShipmentNo2);

      // 2. Exercise: Delete the Invoiced Sales Orders.
      SalesHeader2.SETRANGE("Document Type",SalesHeader2."Document Type"::Order);
      SalesHeader2.SETRANGE("Sell-to Customer No.",Customer."No.");
      LibrarySales.DeleteInvoicedSalesOrders(SalesHeader2);

      // 3. Verify: verify that old Sales Orders have been deleted.
      SalesHeader.SETRANGE("Document Type",SalesHeader."Document Type"::Order);
      SalesHeader.SETRANGE("No.",Customer."No.");
      Assert.AreEqual(0,SalesHeader.COUNT,OrdersDeletedError);

      // 4. Teardown: Rollback Stockout Warning to default value on Sales & Receivables Setup.
      LibrarySales.SetStockoutWarning(SalesReceivablesSetup."Stockout Warning");
Member of Lib.Library - Sales


DeleteInvoicedSalesReturnOrders@42 Method

The procedure DeleteInvoicedSalesReturnOrders is available in codeunit 130509.

Syntax

DeleteInvoicedSalesReturnOrders@42(
    VAR SalesHeader@1000 : Record 36 SalesHeader //Reference parameter of type Record
);

Parameters

SalesHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Delete, Invoiced, Sales, Return, Orders.

For a clarification about how this function works, refer to the code listed below.

      IF SalesHeader.HASFILTER THEN
        TmpSalesHeader.COPYFILTERS(SalesHeader)
      ELSE BEGIN
        SalesHeader.GET(SalesHeader."Document Type",SalesHeader."No.");
        TmpSalesHeader.SETRANGE("Document Type",SalesHeader."Document Type");
        TmpSalesHeader.SETRANGE("No.",SalesHeader."No.");
      END;
      DeleteInvdSalesRetOrders.SETTABLEVIEW(TmpSalesHeader);
      DeleteInvdSalesRetOrders.USEREQUESTPAGE(FALSE);
      DeleteInvdSalesRetOrders.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 137061 to show one way of using this function.

      // Post Credit Memo and delete Invoiced Sales Return Orders.
      // 1. Setup.
      Initialize;
      SalesReceivablesSetup.GET;
      LibrarySales.SetStockoutWarning(FALSE);
      CreateItem(Item);

      // Create and Post Sales Orders.Combine Sales Shipments and Post Invoice.
      CombineSalesShipmentsSetup(Customer,Item,SalesShipmentNo,SalesShipmentNo2);

      // Create and Post Receipt of the Return Orders for the sales.Combine the Receipts to a Credit Memo and Post it.
      CombineForSalesMemoSetup(Customer,SalesShipmentNo,SalesShipmentNo2);

      // 2. Exercise: Delete the Invoiced Sales Return Orders.
      SalesHeader2.SETRANGE("Document Type",SalesHeader2."Document Type"::"Return Order");
      SalesHeader2.SETRANGE("Sell-to Customer No.",Customer."No.");
      LibrarySales.DeleteInvoicedSalesReturnOrders(SalesHeader2);

      // 3. Verify: verify that old Sales Return Orders have been deleted.
      SalesHeader.SETRANGE("Document Type",SalesHeader."Document Type"::"Return Order");
      SalesHeader.SETRANGE("No.",Customer."No.");
      Assert.AreEqual(0,SalesHeader.COUNT,ReturnOrdersDeletedError);  // Value is important for Test.

      // 4. Teardown: Rollback Stockout Warning to default value on Sales & Receivables Setup.
      LibrarySales.SetStockoutWarning(SalesReceivablesSetup."Stockout Warning");
Member of Lib.Library - Sales


ExplodeBOM@72 Method

The procedure ExplodeBOM is available in codeunit 130509.

Syntax

ExplodeBOM@72(
    VAR SalesLine@1001 : Record 37 SalesLine //Reference parameter of type Record
);

Parameters

SalesLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Explode, BOM.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(SalesExplodeBOM);
      SalesExplodeBOM.RUN(SalesLine);

Example

The below example is extracted from the test automation codeunit 134387 to show one way of using this function.

      // Verify Error while applying Explode BOM on Credit Memo created by Get Return Receipt Line.

      // Setup: Create Sales Return Order,Create Credit Memo.
      Initialize;
      ItemNo := LibraryInventory.CreateItemNo;

      CreateSalesDocumentItem(SalesHeader,SalesHeader."Document Type"::"Return Order",ItemNo);
      ReturnReceiptHeader.GET(LibrarySales.PostSalesDocument(SalesHeader,TRUE,FALSE));
      SalesHeader.GET(SalesHeader."Document Type"::"Return Order",ReturnReceiptHeader."Return Order No.");

      CreateCreditMemo(SalesHeader,ItemNo);
      FindSalesLine(SalesLine,SalesHeader."Document Type",SalesHeader."No.",SalesLine.Type::" ");

      // Excercise: Apply Explode BOM on Sales Return Order Line.
      ASSERTERROR LibrarySales.ExplodeBOM(SalesLine);

      // Verify: Verify Error while applying Explode BOM on Sales Return Order Line.
      Assert.ExpectedError(STRSUBSTNO(SalesLnTypeErr,SalesHeader."No.",SalesLine."Line No."));
Member of Lib.Library - Sales


FindCustomerPostingGroup@31 Method

The procedure FindCustomerPostingGroup is available in codeunit 130509.

Syntax

FindCustomerPostingGroup@31(
      //param element not supplied
);

Return Value

Code[10]

Remarks

The relevant search keywords are: Find, Customer, Posting, Group.

For a clarification about how this function works, refer to the code listed below.

      IF NOT CustomerPostingGroup.FINDFIRST THEN
        CreateCustomerPostingGroup(CustomerPostingGroup);
      EXIT(CustomerPostingGroup.Code);

Example

There are no examples available.
Member of Lib.Library - Sales


FindItem@93 Method

The procedure FindItem is available in codeunit 130509.

Syntax

FindItem@93(
    VAR Item@1000 : Record 27 Item //Reference parameter of type Record
);

Parameters

Item
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Item.

For a clarification about how this function works, refer to the code listed below.

      // Filter Item so that errors are not generated due to mandatory fields or Item Tracking.
      Item.SETFILTER("Inventory Posting Group",'<>''''');
      Item.SETFILTER("Gen. Prod. Posting Group",'<>''''');
      Item.SETRANGE("Item Tracking Code",'');
      Item.SETRANGE(Blocked,FALSE);
      Item.SETFILTER("Unit Price",'<>0');
      Item.SETFILTER(Reserve,'<>%1',Item.Reserve::Always);

      Item.FINDSET;

Example

The below example is extracted from the test automation codeunit 134997 to show one way of using this function.

      LibrarySales.CreateSalesHeader(SalesHeader,SalesHeader."Document Type"::Invoice,CustomerNo);
      SalesHeader.VALIDATE("Posting Date",PostingDate);
      SalesHeader.MODIFY(TRUE);
      LibrarySales.FindItem(Item);
      LibrarySales.CreateSalesLine(
        SalesLine,
        SalesHeader,
        SalesLine.Type::Item,
        Item."No.",
        LibraryRandom.RandDecInRange(MinDocumentValue,MaxDocumentValue,2));
      EXIT(LibrarySales.PostSalesDocument(SalesHeader,FALSE,TRUE)); // Ship, Invoice
Member of Lib.Library - Sales


FindType@1500001 Method

The procedure FindType is available in codeunit 130509.

Syntax

FindType@1500001(
    Type@1500000 : Option Type, //Input parameter of type Option
    No@1500001 : Code[20] No, //Input parameter of type Code
    GenBusPostCode@1500009 : Code[10] GenBusPostCode, //Input parameter of type Code
    VATBusPostCode@1500010 : Code[10] VATBusPostCode //Input parameter of type Code
);

Parameters

Type
Input parameter of type Option
No
Input parameter of type Code
GenBusPostCode
Input parameter of type Code
VATBusPostCode
Input parameter of type Code

Remarks

The relevant search keywords are: Find, Type.

For a clarification about how this function works, refer to the code listed below.

      GenProdPostCode := '';
      VATPostCode := '';
      CASE Type OF
        Type::Item: BEGIN
          ItemRec.RESET;
          ItemRec.GET(No);
          GenProdPostCode := ItemRec."Gen. Prod. Posting Group";
          VATPostCode := ItemRec."VAT Prod. Posting Group";
        END;
        Type::Resource: BEGIN
          ResourceRec.RESET;
          ResourceRec.GET(No);
          GenProdPostCode := ResourceRec."Gen. Prod. Posting Group";
          VATPostCode := ResourceRec."VAT Prod. Posting Group";
        END;
        Type::"Charge (Item)": BEGIN
          ChargeItemRec.RESET;
          ChargeItemRec.GET(No);
          GenProdPostCode := ChargeItemRec."Gen. Prod. Posting Group";
          VATPostCode := ChargeItemRec."VAT Prod. Posting Group";
        END;
        Type::"G/L Account": BEGIN
          GLAccRec.RESET;
          GLAccRec.GET(No);
          GenProdPostCode := GLAccRec."Gen. Prod. Posting Group";
          VATPostCode := GLAccRec."VAT Prod. Posting Group";
        END;
        Type::"Fixed Asset": BEGIN
          FARec.RESET;
          FARec.GET(No);
          GenProdPostCode := FARec."Gen. Prod. Posting Group";
          VATPostCode := FARec."VAT Product Posting Group";
        END;
      END;
      LibraryERM.CreateGenPostSetup(GenBusPostCode,GenProdPostCode);
      LibraryERM.CreateVATPostingSetups(VATBusPostCode,VATPostCode);

Example

The below example is extracted from the test automation codeunit 137091 to show one way of using this function.

      // Setup.
      Initialize;
      SalesReceivablesSetup.GET;
      SalesReceivablesSetup.VALIDATE("Stockout Warning",FALSE);
      SalesReceivablesSetup.MODIFY(TRUE);
      LibraryAssembly.CreateMultipleLvlTree(Item,Item1,Item."Replenishment System"::Assembly,Item."Costing Method"::Standard,1,2);
      SaveInitialAssemblyList(TempBOMComponent,Item1."No.");
      LibrarySales.CreateSalesHeader(SalesHeader,SalesHeader."Document Type"::Order,'');
      LibrarySales.CreateSalesLine(SalesLine,SalesHeader,SalesLine.Type::Item,Item1."No.",LibraryRandom.RandDec(5,2));
      TempSalesLine.DELETEALL;
      TempSalesLine := SalesLine;
      TempSalesLine.INSERT;

      // DL
      AssBOMCompRec.RESET;
      AssBOMCompRec.SETCURRENTKEY("Parent Item No.","Line No.");
      AssBOMCompRec.SETRANGE("Parent Item No.",Item1."No.");
      IF AssBOMCompRec.FINDSET THEN REPEAT
        TypeBOM := 0;
        TypeBOM := AssBOMCompRec.Type + 1;
        IF TypeBOM > 0 THEN
        LibrarySales.FindType(TypeBOM,AssBOMCompRec."No.",SalesHeader."Gen. Bus. Posting Group",SalesHeader."VAT Bus. Posting Group");
      UNTIL AssBOMCompRec.NEXT = 0;

      // Exercise.
      SalesExplodeBOM.RUN(SalesLine);

      // Validate.
      VerifyExplodedSalesLines(TempBOMComponent,SalesHeader,TempSalesLine);
Member of Lib.Library - Sales


GetCustomerAccount@1500013 Method

The procedure GetCustomerAccount is available in codeunit 130509.

Syntax

GetCustomerAccount@1500013(
    CustomerNo@1500000 : Code[20] CustomerNo //Input parameter of type Code
);

Parameters

CustomerNo
Input parameter of type Code

Return Value

Code[20]

Remarks

The relevant search keywords are: Get, Customer, Account.

For a clarification about how this function works, refer to the code listed below.

      Customer.GET(CustomerNo);
      CustomerPostingGroup.GET(Customer."Customer Posting Group");
      EXIT(CustomerPostingGroup."Receivables Account");

Example

The below example is extracted from the test automation codeunit 144014 to show one way of using this function.

      DummyGLEntry.SETRANGE("Document No.",GenJournalLine."Document No.");
      Assert.RecordCount(DummyGLEntry,8);
      VerifyGLEntry(LibrarySales.GetCustomerAccount(GenJournalLine."Account No."),GenJournalLine."Document No.",
        GenJournalLine.Amount / GenJournalLine."Currency Factor");
      VerifyGLEntryAdditionalCurrencyAmount(LibrarySales.GetCustomerAccount(GenJournalLine."Account No."),
        GenJournalLine."Document No.",GenJournalLine.Amount);
      VerifyGLEntry(ReverseServiceTaxHelper.GetBankAccGLPostingAcc(GenJournalLine."Bal. Account No."),
        GenJournalLine."Document No.",-GenJournalLine.Amount / GenJournalLine."Currency Factor");
      VerifyGLEntryAdditionalCurrencyAmount(ReverseServiceTaxHelper.GetBankAccGLPostingAcc(GenJournalLine."Bal. Account No."),
        GenJournalLine."Document No.",-GenJournalLine.Amount);
      ServTaxBaseAmount := ReverseServiceTaxHelper.CalcServTaxBaseAmountBackwardWithKKC(GenJournalLine.Amount,ServiceTaxSetup,0);
      VerifyGLEntry(ServiceTaxSetup."Service Tax Payable Account",GenJournalLine."Document No.",
        ReverseServiceTaxHelper.CalculateServTax(ServTaxBaseAmount,ServiceTaxSetup) / GenJournalLine."Currency Factor");
      VerifyGLEntryAdditionalCurrencyAmount(ServiceTaxSetup."Service Tax Payable Account",GenJournalLine."Document No.",
        ReverseServiceTaxHelper.CalculateServTax(ServTaxBaseAmount,ServiceTaxSetup));
      VerifyGLEntry(ServiceTaxSetup."Payables Account (Interim)",GenJournalLine."Document No.",-
        ReverseServiceTaxHelper.CalculateServTax(ServTaxBaseAmount,ServiceTaxSetup) / GenJournalLine."Currency Factor");
      VerifyGLEntryAdditionalCurrencyAmount(ServiceTaxSetup."Payables Account (Interim)",GenJournalLine."Document No.",-
        ReverseServiceTaxHelper.CalculateServTax(ServTaxBaseAmount,ServiceTaxSetup));
Member of Lib.Library - Sales


GetShipmentLines@7 Method

The procedure GetShipmentLines is available in codeunit 130509.

Syntax

GetShipmentLines@7(
    VAR SalesLine@1000 : Record 37 SalesLine //Reference parameter of type Record
);

Parameters

SalesLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Get, Shipment, Lines.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(SalesGetShipment);
      SalesGetShipment.RUN(SalesLine);

Example

The below example is extracted from the test automation codeunit 134101 to show one way of using this function.

      // [FEATURE] [Sales] [Get Shipment Lines]
      // [SCENARIO 352832] Get Shipment Lines shows lines from Sales Order that has prepayment and fully shipped.

      // [GIVEN] Ship once Sales Order with non-zero Prepayment %
      Initialize;
      LibraryVariableStorage.Enqueue(1);
      PrepareShptLinesWithPrepmtPerc(SalesLine,LibraryRandom.RandIntInRange(1,50),FALSE);

      // [WHEN] "Get Shipment Lines" on the new Invoice
      LibrarySales.GetShipmentLines(SalesLine);
      // [THEN] Shipment Line is in the list
      // Verification in VerifyNoOfGetShipmentLinesPageHandler
Member of Lib.Library - Sales


PostSalesDocument@19 Method

The procedure PostSalesDocument is available in codeunit 130509.

Syntax

PostSalesDocument@19(
    VAR SalesHeader@1000 : Record 36 SalesHeader, //Reference parameter of type Record
    NewShipReceive@1001 : Boolean NewShipReceive, //Input parameter of type Boolean
    NewInvoice@1002 : Boolean NewInvoice //Input parameter of type Boolean
);

Parameters

SalesHeader
Reference parameter of type Record
NewShipReceive
Input parameter of type Boolean
NewInvoice
Input parameter of type Boolean

Return Value

Code[20]

Remarks

The relevant search keywords are: Post, Sales, Document.

For a clarification about how this function works, refer to the code listed below.

      EXIT(DoPostSalesDocument(SalesHeader,NewShipReceive,NewInvoice,FALSE));

Example

The below example is extracted from the test automation codeunit 134006 to show one way of using this function.

      // Check Remaining Amount on Customer Ledger Entry after Creating and Posting Sales Invoice without Currency and Apply with Partial Payment.

      // Setup: Create and Post Sales Invoice, Create a Customer Payment and apply it to posted Invoice.
      Initialize;
      LibrarySales.CreateCustomer(Customer);
      LibrarySales.CreateSalesHeader(SalesHeader,SalesHeader."Document Type"::Invoice,Customer."No.");
      CreateAndModifySalesLine(SalesHeader,LibraryRandom.RandDec(10,2),LibraryRandom.RandDec(100,2));
      PostedDocumentNo := LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);
      SelectGenJournalBatch(GenJournalBatch,FALSE);
      CreateGeneralJournalLines(
        GenJournalLine,GenJournalBatch,1,SalesHeader."Sell-to Customer No.",GenJournalLine."Document Type"::Payment,0);  // Taken 1 and 0 to create only one General Journal line with zero amount.
      Amount := OpenGeneralJournalPage(GenJournalLine."Document No.",GenJournalLine."Document Type");
      GenJournalLine.FIND;
      GenJournalLine.VALIDATE(Amount,GenJournalLine.Amount + Amount);
      GenJournalLine.MODIFY(TRUE);

      // Exericse.
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // Verify: Verify Remaining Amount on Customer Ledger Entry.
      LibraryERM.FindCustomerLedgerEntry(CustLedgerEntry,SalesHeader."Document Type",PostedDocumentNo);
      CustLedgerEntry.CALCFIELDS("Remaining Amount");
      CustLedgerEntry.TESTFIELD("Remaining Amount",Amount);
Member of Lib.Library - Sales


PostSalesDocumentAndEmail@29 Method

The procedure PostSalesDocumentAndEmail is available in codeunit 130509.

Syntax

PostSalesDocumentAndEmail@29(
    VAR SalesHeader@1000 : Record 36 SalesHeader, //Reference parameter of type Record
    NewShipReceive@1001 : Boolean NewShipReceive, //Input parameter of type Boolean
    NewInvoice@1002 : Boolean NewInvoice //Input parameter of type Boolean
);

Parameters

SalesHeader
Reference parameter of type Record
NewShipReceive
Input parameter of type Boolean
NewInvoice
Input parameter of type Boolean

Return Value

Code[20]

Remarks

The relevant search keywords are: Post, Sales, Document, Email.

For a clarification about how this function works, refer to the code listed below.

      EXIT(DoPostSalesDocument(SalesHeader,NewShipReceive,NewInvoice,TRUE));

Example

There are no examples available.
Member of Lib.Library - Sales


PostSalesPrepaymentCrMemo@12 Method

The procedure PostSalesPrepaymentCrMemo is available in codeunit 130509.

Syntax

PostSalesPrepaymentCrMemo@12(
    VAR SalesHeader@1000 : Record 36 SalesHeader //Reference parameter of type Record
);

Parameters

SalesHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Post, Sales, Prepayment, Credit, Memo.

For a clarification about how this function works, refer to the code listed below.

      SalesPostPrepayments.CreditMemo(SalesHeader);

Example

The below example is extracted from the test automation codeunit 134100 to show one way of using this function.

      // [FEATURE] [Sales] [Series No] [Credit Memo]
      // [SCENARIO] Setting up the Posted Prepmt Inv Nos and Posted Prepmt Cr Memo Nos in Sales Setup with Posted Invoice Nos and Posted Credit Memo Nos.

      // 1. Setup: Change the Posted Prepmt Inv Nos and Posted Prepmt Cr Memo Nos in Sales and Receivable Setup, create Payment Terms,
      // create Sales Order with created payment terms.
      Initialize;
      PrepmtInvNosInSetup(SalesReceivablesSetup);
      PrepmtCreditMemoInSetup(SalesReceivablesSetup);
      LibraryERM.CreatePaymentTerms(PaymentTerms);

      CreatePrepmtVATSetup(LineGLAccount,LineGLAccount."Gen. Posting Type"::Sale);
      SalesOrderPrepaymentDueDate(SalesHeader,PaymentTerms.Code,LineGLAccount);

      // 2. Exercise: Create Setup for Sales Prepayment Account and Post the Prepayment Sales Invoice and Prepayment Credit Memo.
      LibrarySales.PostSalesPrepaymentInvoice(SalesHeader);
      LibrarySales.PostSalesPrepaymentCrMemo(SalesHeader);

      // 3. Verify: Verify the Posted Prepmt Sales Invoice No and Posted Prepmt Cr Memo Nos with No Series.
      VerifyPrepaymentInvoice(SalesHeader."No.",SalesReceivablesSetup."Posted Prepmt. Inv. Nos.");
      VerifyPrepaymentCreditMemo(SalesHeader."No.",SalesReceivablesSetup."Posted Prepmt. Cr. Memo Nos.");
Member of Lib.Library - Sales


PostSalesPrepaymentInvoice@23 Method

The procedure PostSalesPrepaymentInvoice is available in codeunit 130509.

Syntax

PostSalesPrepaymentInvoice@23(
    VAR SalesHeader@1001 : Record 36 SalesHeader //Reference parameter of type Record
);

Parameters

SalesHeader
Reference parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Post, Sales, Prepayment, Invoice.

For a clarification about how this function works, refer to the code listed below.

      NoSeriesCode := SalesHeader."Prepayment No. Series";
      IF SalesHeader."Prepayment No." = '' THEN
        DocumentNo := NoSeriesMgt.GetNextNo(NoSeriesCode,LibraryUtility.GetNextNoSeriesSalesDate(NoSeriesCode),FALSE)
      ELSE
        DocumentNo := SalesHeader."Prepayment No.";
      SalesPostPrepayments.Invoice(SalesHeader);

Example

The below example is extracted from the test automation codeunit 134100 to show one way of using this function.

      // 1. Setup: Create a new Payment Term Due Date Calculation as per parameter passed. Create Sales Order - Create Customer, Sales
      // Header, Sales Line with Item, G/L Account, Resource, Fixed Asset, Charge (Item).
      Initialize;
      CreatePaymentTermWithDueDate(PaymentTerms,DueDate);

      CreatePrepmtVATSetup(LineGLAccount,LineGLAccount."Gen. Posting Type"::Sale);
      SalesOrderPrepaymentDueDate(SalesHeader,PaymentTerms.Code,LineGLAccount);

      // 2. Exercise: Setup Prepayments Accounts for Sales Lines and Post Prepayment Invoice.
      LibrarySales.PostSalesPrepaymentInvoice(SalesHeader);

      // 3. Verify: Check the Prepayment Amount on Prepayment Invoice is sum of Prepayment Amount on Sales Line and the Due Date is the
      // Prepayment Due Date on Sales Header.
      VerifyPrepaymentAmountDueDate(SalesHeader);
Member of Lib.Library - Sales


QuoteMakeOrder@44 Method

The procedure QuoteMakeOrder is available in codeunit 130509.

Syntax

QuoteMakeOrder@44(
    VAR SalesHeader@1000 : Record 36 SalesHeader //Reference parameter of type Record
);

Parameters

SalesHeader
Reference parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Quote, Make, Order.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(SalesQuoteToOrder);
      SalesQuoteToOrder.RUN(SalesHeader);
      SalesQuoteToOrder.GetSalesOrderHeader(SalesOrderHeader);
      EXIT(SalesOrderHeader."No.");

Example

The below example is extracted from the test automation codeunit 137068 to show one way of using this function.

      // Setup: Create Item and create and post a Sales Order. Copy Sales Order to a Sales blank Quote
      Initialize;
      ItemNo := CreateItem;
      StockoutWarning := UpdateStockoutWarning(FALSE);
      Quantity := LibraryRandom.RandDec(100,2);
      CreateAndReleaseSalesOrder(SalesHeader,ItemNo,Quantity);
      LibrarySales.PostSalesDocument(SalesHeader,TRUE,FALSE);  // Post as Ship only.
      CopySalesDocument(SalesHeader2,SalesHeader2."Document Type"::Quote,GlobalDocumentType::Order,SalesHeader."No.");

      // Exercise: Make Sales Order from Sales Quote.
      LibrarySales.QuoteMakeOrder(SalesHeader2);

      // Verify: Verify the Last Shipping No as blank on Sales Order created from Sales Quote. Verify the values on Sales Order made from the Sales Quote.
      SelectSalesHeader(SalesHeader2,SalesHeader2."Sell-to Customer No.");
      SalesHeader2.TESTFIELD("Last Shipping No.",'');
      VerifySalesLine(SalesHeader2,ItemNo,Quantity);

      // Tear Down: Set Stockout Warning to original state.
      UpdateStockoutWarning(StockoutWarning);
Member of Lib.Library - Sales


ReleaseSalesDocument@78 Method

The procedure ReleaseSalesDocument is available in codeunit 130509.

Syntax

ReleaseSalesDocument@78(
    VAR SalesHeader@1000 : Record 36 SalesHeader //Reference parameter of type Record
);

Parameters

SalesHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Release, Sales, Document.

For a clarification about how this function works, refer to the code listed below.

      ReleaseSalesDoc.PerformManualRelease(SalesHeader);

Example

The below example is extracted from the test automation codeunit 134031 to show one way of using this function.

      LibraryPmtDiscSetup.SetPmtDiscExclVAT(PmtDiscExclVAT);
      CreateSalesDocument(SalesHeader,CreateCustomer,CurrencyCode,DocumentType);
      LibrarySales.ReleaseSalesDocument(SalesHeader);
      SalesHeader.CALCFIELDS("Amount Including VAT",Amount);
      PostedInvoiceNo := LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);
Member of Lib.Library - Sales


ReopenSalesDocument@32 Method

The procedure ReopenSalesDocument is available in codeunit 130509.

Syntax

ReopenSalesDocument@32(
    VAR SalesHeader@1000 : Record 36 SalesHeader //Reference parameter of type Record
);

Parameters

SalesHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Reopen, Sales, Document.

For a clarification about how this function works, refer to the code listed below.

      ReleaseSalesDoc.PerformManualReopen(SalesHeader);

Example

The below example is extracted from the test automation codeunit 134074 to show one way of using this function.

      // [FEATURE] [Sales]
      // [SCENARIO 375015] Restored from archive Sales Order with notification to a user produces record link without notification flag
      Initialize;

      // [GIVEN] Sales Order with notification note ("Record Link".Notify = TRUE)
      CreateSalesOrder(SalesHeader,SalesHeader."Document Type"::Order);
      SetupNotificationOnRecordLink(SalesHeader,TRUE);

      // [GIVEN] Archived Sales Order with note having notification flag
      LibrarySales.ReleaseSalesDocument(SalesHeader);
      ArchiveManagement.StoreSalesDocument(SalesHeader,FALSE);
      FindSalesHeaderArchive(SalesHeaderArchive,SalesHeader);
      SetupNotificationOnRecordLink(SalesHeaderArchive,TRUE);
      LibrarySales.ReopenSalesDocument(SalesHeader);

      // [WHEN] Restore Sales Order
      ArchiveManagement.RestoreSalesDocument(SalesHeaderArchive);

      // [THEN] Restored Sales Order has a note without notification ("Record Link".Notify = FALSE)
      SalesHeader.FIND;
      VerifyNotificationOnRecordLink(SalesHeader,FALSE);
Member of Lib.Library - Sales


SelectCashReceiptJnlBatch@52 Method

The procedure SelectCashReceiptJnlBatch is available in codeunit 130509.

Syntax

SelectCashReceiptJnlBatch@52(
    VAR GenJournalBatch@1000 : Record 232 GenJournalBatch //Reference parameter of type Record
);

Parameters

GenJournalBatch
Reference parameter of type Record

Remarks

The relevant search keywords are: Select, Cash, Receipt, Journal, Batch.

For a clarification about how this function works, refer to the code listed below.

      LibraryJournals.SelectGenJournalBatch(GenJournalBatch,SelectCashReceiptJnlTemplate);

Example

There are no examples available.
Member of Lib.Library - Sales


SelectCashReceiptJnlTemplate@51 Method

The procedure SelectCashReceiptJnlTemplate is available in codeunit 130509.

Syntax

SelectCashReceiptJnlTemplate@51(
      //param element not supplied
);

Return Value

Code[10]

Remarks

The relevant search keywords are: Select, Cash, Receipt, Journal, Template.

For a clarification about how this function works, refer to the code listed below.

      EXIT(LibraryJournals.SelectGenJournalTemplate(GenJournalTemplate.Type::"Cash Receipts",PAGE::"Cash Receipt Journal"));

Example

There are no examples available.
Member of Lib.Library - Sales


SetAllowDocumentDeletionBeforeDate@88 Method

The procedure SetAllowDocumentDeletionBeforeDate is available in codeunit 130509.

Syntax

SetAllowDocumentDeletionBeforeDate@88(
    Date@1000 : Date Date //Input parameter of type Date
);

Parameters

Date
Input parameter of type Date

Remarks

The relevant search keywords are: Set, Allow, Document, Deletion, Before, Date.

For a clarification about how this function works, refer to the code listed below.

      SalesReceivablesSetup.GET;
      SalesReceivablesSetup.VALIDATE("Allow Document Deletion Before",Date);
      SalesReceivablesSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134387 to show one way of using this function.

      // Verify Error while delete Posted Sales Credit Memo without print the Document.

      // Setup: Create Customer, create Sales Credit Memo and Post.
      Initialize;
      DocumentNo := CreatePostSalesDocWithGL(SalesHeader,SalesHeader."Document Type"::"Credit Memo",TRUE);
      SalesCrMemoHeader.GET(DocumentNo);
      LibrarySales.SetAllowDocumentDeletionBeforeDate(SalesCrMemoHeader."Posting Date" + 1);

      // Exercise.
      ASSERTERROR SalesCrMemoHeader.DELETE(TRUE);

      // Verify. Verify Error while delete Posted Sales Credit Memo.
      Assert.ExpectedError(STRSUBSTNO(DeleteSalesCrMemoErr,DocumentNo));
Member of Lib.Library - Sales


SetAllowVATDifference@48 Method

The procedure SetAllowVATDifference is available in codeunit 130509.

Syntax

SetAllowVATDifference@48(
    AllowVATDifference@1000 : Boolean AllowVATDifference //Input parameter of type Boolean
);

Parameters

AllowVATDifference
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, Allow, VAT, Difference.

For a clarification about how this function works, refer to the code listed below.

      SalesReceivablesSetup.GET;
      SalesReceivablesSetup.VALIDATE("Allow VAT Difference",AllowVATDifference);
      SalesReceivablesSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134028 to show one way of using this function.

      Result := LibraryRandom.RandDec(2,2);  // Use any Random decimal value between 0.01 and 1.99, value is not important.
      LibraryERM.SetMaxVATDifferenceAllowed(Result);
      IF SalesAndReceivables THEN
        LibrarySales.SetAllowVATDifference(TRUE)
      ELSE
        LibraryPurchase.SetAllowVATDifference(TRUE);
Member of Lib.Library - Sales


SetApplnBetweenCurrencies@45 Method

The procedure SetApplnBetweenCurrencies is available in codeunit 130509.

Syntax

SetApplnBetweenCurrencies@45(
    ApplnBetweenCurrencies@1000 : Option ApplnBetweenCurrencies //Input parameter of type Option
);

Parameters

ApplnBetweenCurrencies
Input parameter of type Option

Remarks

The relevant search keywords are: Set, Application, Between, Currencies.

For a clarification about how this function works, refer to the code listed below.

      SalesReceivablesSetup.GET;
      SalesReceivablesSetup.VALIDATE("Appln. between Currencies",ApplnBetweenCurrencies);
      SalesReceivablesSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134024 to show one way of using this function.

      LibrarySetupStorage.Restore;

      // Lazy Setup.
      IF isInitialized THEN
        EXIT;

      LibrarySales.SetCreditWarningsToNoWarnings;
      LibrarySales.SetApplnBetweenCurrencies(SalesReceivablesSetup."Appln. between Currencies"::All);
      LibraryERMCountryData.UpdateGeneralLedgerSetup;
      LibraryERMCountryData.UpdateGeneralPostingSetup;
      LibrarySetupStorage.Save(DATABASE::"General Ledger Setup");
      LibrarySetupStorage.Save(DATABASE::"Sales & Receivables Setup");

      isInitialized := TRUE;
      COMMIT;
Member of Lib.Library - Sales


SetArchiveQuotesandOrders@26 Method

The procedure SetArchiveQuotesandOrders is available in codeunit 130509.

Syntax

SetArchiveQuotesandOrders@26(
    ArchiveQuotesAndOrders@1001 : Boolean ArchiveQuotesAndOrders //Input parameter of type Boolean
);

Parameters

ArchiveQuotesAndOrders
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, Archive, Quotesand, Orders.

For a clarification about how this function works, refer to the code listed below.

      SalesReceivablesSetup.GET;
      SalesReceivablesSetup.VALIDATE("Archive Quotes and Orders",ArchiveQuotesAndOrders);
      SalesReceivablesSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134481 to show one way of using this function.

      // [FEATURE] [Sales] [Order]
      // [SCENARIO 200401] System creates archive after posting final invoice when "Sales & Recievables Setup"."Archive Quotes and Orders" = TRUE

      // [GIVEN] Sales Order "SO" fully shipped and partially invoiced (1 archive exists)
      Initialize;
      LibrarySales.SetArchiveQuotesandOrders(TRUE);
      CreateSalesOrder(SalesHeader,SalesLine);
      SalesLine.VALIDATE("Qty. to Invoice",SalesLine."Qty. to Invoice" / 2);
      SalesLine.MODIFY(TRUE);
      LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);
      VerifySalesOrderArchive(SalesHeader,SalesLine,1);

      // [WHEN] Post final invoice
      LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      // [WHEN] 2nd archive created
      VerifySalesOrderArchive(SalesHeader,SalesLine,2);
Member of Lib.Library - Sales


SetCalcInvDiscount@46 Method

The procedure SetCalcInvDiscount is available in codeunit 130509.

Syntax

SetCalcInvDiscount@46(
    CalcInvDiscount@1000 : Boolean CalcInvDiscount //Input parameter of type Boolean
);

Parameters

CalcInvDiscount
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, Calc, Invoice, Discount.

For a clarification about how this function works, refer to the code listed below.

      SalesReceivablesSetup.GET;
      SalesReceivablesSetup.VALIDATE("Calc. Inv. Discount",CalcInvDiscount);
      SalesReceivablesSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134039 to show one way of using this function.

      // Check Inv. Discount Amount on Purchase CreditMemo Statistics after Posting Purchase Return Order.

      // Setup: Create Purchase Return Order and Credit Memo.
      Initialize;
      LibraryPurchase.SetCalcInvDiscount(TRUE);
      VendorNo := CreateVendAndInvoiceDiscount;
      InvoiceDiscountAmount := CreateAndPostPurchaseReturnOrder(PurchaseHeader."Document Type"::"Return Order",VendorNo);
      LibraryVariableStorage.Enqueue(InvoiceDiscountAmount);

      // Exercise: Create and Get Shiment Lines for Purchase Credit Memo.
      CreatePurchaseCreditMemoAndGetShipmentLines(PurchaseHeader,VendorNo);

      // Verify: Verify Inv. Discount Amount on Purchase Creditmemo Statistics using Purchase Statistics Page handler.
      PurchaseHeader.CalcInvDiscForHeader;
      PAGE.RUNMODAL(PAGE::"Purchase Statistics",PurchaseHeader);
Member of Lib.Library - Sales


SetCorrDocNoSales@11 Method

The procedure SetCorrDocNoSales is available in codeunit 130509.

Syntax

SetCorrDocNoSales@11(
    VAR SalesHeader@1000 : Record 36 SalesHeader //Reference parameter of type Record
);

Parameters

SalesHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Set, Corr, Document, No, Sales.

For a clarification about how this function works, refer to the code listed below.

      WITH SalesHeader DO
        IF "Document Type" IN ["Document Type"::"Credit Memo","Document Type"::"Return Order"] THEN;

Example

The below example is extracted from the test automation codeunit 136305 to show one way of using this function.

      // Test Line Discount Percent and Line Amount in Job Ledger Entry for Posted Credit Memo, that is created from Job Planning Line.

      // Setup: Create Job Planning Line for GL Account with Negative Quantity and Discount Amount, Create Sales Credit Memo from Job Planning Line.
      Initialize;
      CreateJobPlanningLineWithUnitPriceAndLineDiscountPct(JobPlanningLine,0);  // Take Zero for Line Discount Percent.
      UpdateQuantityAndDiscountOnPlanningLine(JobPlanningLine,-LibraryRandom.RandDec(10,2));  // Taking Random Discount Amount.
      CreateCreditMemoFromJobPlanningLine(JobPlanningLine);
      FindSalesHeader(SalesHeader,SalesLine."Document Type"::"Credit Memo",JobPlanningLine."Job No.",SalesLine.Type::"G/L Account");
      LibrarySales.SetCorrDocNoSales(SalesHeader);

      // 2. Exercise.
      DocumentNo := LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      // 3. Verify: Verify Unit Price, Discount Percent and Discount Amount after posting Sales Credit Memo on Job Ledger Entry.
      VerifyDiscountOnJobLedgerEntry(
        DocumentNo,JobPlanningLine."Job No.",JobPlanningLine."No.",JobPlanningLine."Unit Price",JobPlanningLine."Line Discount %",
        -JobPlanningLine."Line Discount Amount");
Member of Lib.Library - Sales


SetCreditWarnings@49 Method

The procedure SetCreditWarnings is available in codeunit 130509.

Syntax

SetCreditWarnings@49(
    CreditWarnings@1001 : Option CreditWarnings //Input parameter of type Option
);

Parameters

CreditWarnings
Input parameter of type Option

Remarks

The relevant search keywords are: Set, Credit, Warnings.

For a clarification about how this function works, refer to the code listed below.

      SalesReceivablesSetup.GET;
      SalesReceivablesSetup.VALIDATE("Credit Warnings",CreditWarnings);
      SalesReceivablesSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134377 to show one way of using this function.

      LibrarySales.SetCreditWarnings(SalesReceivablesSetup."Credit Warnings"::"Both Warnings");
Member of Lib.Library - Sales


SetCreditWarningsToNoWarnings@2 Method

The procedure SetCreditWarningsToNoWarnings is available in codeunit 130509.

Syntax

SetCreditWarningsToNoWarnings@2(
      //param element not supplied
);

Remarks

The relevant search keywords are: Set, Credit, Warnings, To, No, Warnings.

For a clarification about how this function works, refer to the code listed below.

      SalesReceivablesSetup.GET;
      SalesReceivablesSetup.VALIDATE("Credit Warnings",SalesReceivablesSetup."Credit Warnings"::"No Warning");
      SalesReceivablesSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134024 to show one way of using this function.

      LibrarySetupStorage.Restore;

      // Lazy Setup.
      IF isInitialized THEN
        EXIT;

      LibrarySales.SetCreditWarningsToNoWarnings;
      LibrarySales.SetApplnBetweenCurrencies(SalesReceivablesSetup."Appln. between Currencies"::All);
      LibraryERMCountryData.UpdateGeneralLedgerSetup;
      LibraryERMCountryData.UpdateGeneralPostingSetup;
      LibrarySetupStorage.Save(DATABASE::"General Ledger Setup");
      LibrarySetupStorage.Save(DATABASE::"Sales & Receivables Setup");

      isInitialized := TRUE;
      COMMIT;
Member of Lib.Library - Sales


SetExactCostReversingMandatory@54 Method

The procedure SetExactCostReversingMandatory is available in codeunit 130509.

Syntax

SetExactCostReversingMandatory@54(
    ExactCostReversingMandatory@1000 : Boolean ExactCostReversingMandatory //Input parameter of type Boolean
);

Parameters

ExactCostReversingMandatory
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, Exact, Cost, Reversing, Mandatory.

For a clarification about how this function works, refer to the code listed below.

      SalesReceivablesSetup.GET;
      SalesReceivablesSetup.VALIDATE("Exact Cost Reversing Mandatory",ExactCostReversingMandatory);
      SalesReceivablesSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137019 to show one way of using this function.

      // [FEATURE] [Item Tracking] [Exact Cost Reversing Mandatory]
      // [SCENARIO 210894] Negative Line of Posted Sales Invoice with Lot Tracking copies to Credit Memo when "Exact Cost Reversing Mandatory" is set

      Initialize;

      // [GIVEN] Item with Lot Tracking
      ItemNo := CreateTrackedItem;

      // [GIVEN] Posted Sales Invoice with Quantity = - 1 and "Lot No."
      PostSalesInvWithNegativeLineAndLotNo(InvNo,SalesLine,ItemNo);

      // [GIVEN] "Exact Cost Reversing Mandatory" is set
      LibrarySales.SetExactCostReversingMandatory(TRUE);

      // [GIVEN] Sales Credit Memo
      LibrarySales.CreateSalesHeader(
        SalesHeaderCorrection,SalesHeaderCorrection."Document Type"::"Credit Memo",SalesLine."Sell-to Customer No.");

      // [WHEN]  Copy Posted Sales Invoice to Sales Credit Memo
      LibrarySales.CopySalesDocument(SalesHeaderCorrection,DocType::"Posted Invoice",InvNo,TRUE,FALSE);

      // [THEN] Credit Memo created with Quantity = -1 and "Lot No."
      VerifySalesLineWithTrackedQty(SalesHeaderCorrection,SalesLine.Quantity);
Member of Lib.Library - Sales


SetExtDocNo@100 Method

The procedure SetExtDocNo is available in codeunit 130509.

Syntax

SetExtDocNo@100(
    ExtDocNoMandatory@1001 : Boolean ExtDocNoMandatory //Input parameter of type Boolean
);

Parameters

ExtDocNoMandatory
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, External, Document, No.

For a clarification about how this function works, refer to the code listed below.

      SalesReceivablesSetup.GET;
      SalesReceivablesSetup.VALIDATE("Ext. Doc. No. Mandatory",ExtDocNoMandatory);
      SalesReceivablesSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134103 to show one way of using this function.

      // [FEATURE] [Sales] [Release Document]
      // [SCENARIO 371945] Status of Sales Order should remain "Pending Prepayment" after document posting error when prepayment is posted and "External Document No." is empty.
      Initialize;

      // [GIVEN] Sales & Receivable Setup has option "Ext. Doc. No. Mandatory" set to TRUE.
      LibrarySales.SetExtDocNo(TRUE);

      LibrarySales.CreatePrepaymentVATSetup(GLAccount,VATPostingSetup."VAT Calculation Type"::"Normal VAT");
      CreateSalesOrderWithAccount(SalesHeader,SalesLine,GLAccount,LibraryRandom.RandIntInRange(10,90));

      // [GIVEN] Posted Prepayment Invoice. Sales Header has Status "Pending Prepayment".
      LibrarySales.PostSalesPrepaymentInvoice(SalesHeader);

      // [GIVEN] Cleared "External Document No." in Sales Header.
      SalesHeader.VALIDATE("External Document No.",'');
      SalesHeader.MODIFY(TRUE);

      // [WHEN] Post Sales Order (Ship and Invoice). Posting error raises.
      ASSERTERROR LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      // [THEN] Sales Header has Status "Pending Prepayment".
      SalesHeader.TESTFIELD(Status,SalesHeader.Status::"Pending Prepayment");
Member of Lib.Library - Sales


SetInvoiceRounding@47 Method

The procedure SetInvoiceRounding is available in codeunit 130509.

Syntax

SetInvoiceRounding@47(
    InvoiceRounding@1000 : Boolean InvoiceRounding //Input parameter of type Boolean
);

Parameters

InvoiceRounding
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, Invoice, Rounding.

For a clarification about how this function works, refer to the code listed below.

      SalesReceivablesSetup.GET;
      SalesReceivablesSetup.VALIDATE("Invoice Rounding",InvoiceRounding);
      SalesReceivablesSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134006 to show one way of using this function.

      LibrarySetupStorage.Restore;
      LibraryVariableStorage.Clear;

      // Lazy Setup.
      IF isInitialized THEN
        EXIT;

      LibrarySales.SetInvoiceRounding(FALSE);
      LibraryERMCountryData.CreateVATData;
      LibraryERMCountryData.UpdateSalesReceivablesSetup;
      LibraryERMCountryData.CreateGeneralPostingSetupData;
      LibraryERMCountryData.UpdateGeneralPostingSetup;
      LibraryERMCountryData.UpdateAccountInCustomerPostingGroup;
      LibraryERMCountryData.RemoveBlankGenJournalTemplate;
      LibraryERMCountryData.UpdateGeneralLedgerSetup;
      isInitialized := TRUE;
      LibrarySetupStorage.Save(DATABASE::"General Ledger Setup");
      LibrarySetupStorage.Save(DATABASE::"Source Code Setup");
      COMMIT;
Member of Lib.Library - Sales


SetPreventNegativeInventory@21 Method

The procedure SetPreventNegativeInventory is available in codeunit 130509.

Syntax

SetPreventNegativeInventory@21(
    PreventNegativeInventory@1001 : Boolean PreventNegativeInventory //Input parameter of type Boolean
);

Parameters

PreventNegativeInventory
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, Prevent, Negative, Inventory.

For a clarification about how this function works, refer to the code listed below.

      InventorySetup.GET;
      InventorySetup.VALIDATE("Prevent Negative Inventory",PreventNegativeInventory);
      InventorySetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 136302 to show one way of using this function.

      // [FEATURE] [Purchase Order]
      // [SCENARIO 380652] Purchase Order with negative quantity and job is posted together with a paired entry of item acquisition. The Order is fully applied to this acquisition.
      Initialize;

      // [GIVEN] Negative inventory is disallowed.
      // [GIVEN] Purchase Order for negative quantity with Job No. and Job Task No. selected.
      LibraryInventory.SetPreventNegativeInventory(TRUE);
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location);
      CreatePurchaseDocumentWithLocationAndJob(
        PurchaseHeader,PurchaseLine,PurchaseHeader."Document Type"::Order,Location.Code,-1);

      // [WHEN] Post the Purchase Order.
      DocumentNo := LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,FALSE);

      // [THEN] The Purchase Order is successfully posted.
      // [THEN] Item Ledger Entry with "Negative Adjmt." type and positive quantity with the Job No. (acquisition) is created.
      VerifyItemLedgerEntry(
        ItemLedgerEntry."Entry Type"::"Negative Adjmt.",PurchaseLine."No.",
        ItemLedgerEntry."Document Type"::"Purchase Receipt",DocumentNo,
        PurchaseLine."Job No.",-PurchaseLine.Quantity,0,0,-PurchaseLine."Line Amount");
      VerifyItemLedgerEntry(
        ItemLedgerEntry."Entry Type"::Purchase,PurchaseLine."No.",
        ItemLedgerEntry."Document Type"::"Purchase Receipt",DocumentNo,
        PurchaseLine."Job No.",PurchaseLine.Quantity,0,0,PurchaseLine."Line Amount");

      // [THEN] The Order is fully applied to the acquisition.
      VerifyItemApplicationEntry(PurchaseLine);
Member of Lib.Library - Sales


SetReturnOrderNoSeriesInSetup@73 Method

The procedure SetReturnOrderNoSeriesInSetup is available in codeunit 130509.

Syntax

SetReturnOrderNoSeriesInSetup@73(
      //param element not supplied
);

Remarks

The relevant search keywords are: Set, Return, Order, No, Series, In, Setup.

For a clarification about how this function works, refer to the code listed below.

      WITH SalesReceivablesSetup DO BEGIN
        GET;
        VALIDATE("Return Order Nos.",LibraryERM.CreateNoSeriesCode);
        VALIDATE("Posted Return Receipt Nos.",LibraryERM.CreateNoSeriesCode);
        MODIFY;
      END;

Example

There are no examples available.
Member of Lib.Library - Sales


SetStockoutWarning@4 Method

The procedure SetStockoutWarning is available in codeunit 130509.

Syntax

SetStockoutWarning@4(
    StockoutWarning@1001 : Boolean StockoutWarning //Input parameter of type Boolean
);

Parameters

StockoutWarning
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, Stockout, Warning.

For a clarification about how this function works, refer to the code listed below.

      SalesReceivablesSetup.GET;
      SalesReceivablesSetup.VALIDATE("Stockout Warning",StockoutWarning);
      SalesReceivablesSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134025 to show one way of using this function.

      // Test Unrealized VAT Amount in G/L Entry for Half Payment to Invoice using page testability having Unrealized VAT Type
      // as Percentage.

      // 1. Setup: Update Unrealized VAT Setup as TRUE on General Ledger Setup and Unrealized VAT Type as Percentage on VAT Posting
      // Create and post Sales Invoice.
      EnableUnrealizedSetup(VATPostingSetup,VATPostingSetup."Unrealized VAT Type"::Percentage,TRUE,FALSE);

      LibrarySales.SetStockoutWarning(FALSE);
      DocumentNo := CreateSalesInvoice(SalesHeader,VATPostingSetup);
      LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);
      FindSalesInvoiceLine(SalesInvoiceLine,DocumentNo);

      // 2. Exercise: Post and Apply Payment to Invoice for half the Invoice Amount.
      CreateAndPostPaymentJournaLine(
        GenJournalLine,SalesHeader."Sell-to Customer No.",'',-SalesInvoiceLine."Amount Including VAT" / 2);
      UnrealizedVATAmount := -ROUND(GenJournalLine.Amount * VATPostingSetup."VAT %" / (100 + VATPostingSetup."VAT %"));

      // Apply Payment on Invoice from Customer Ledger Entries Page.
      ApplyCustomerLedgerEntries(SalesHeader."Sell-to Customer No.",CustLedgerEntry."Document Type"::Payment);

      // 3. Verify: Verify G/L Entry for Unrealized VAT Amount.
      VerifyUnrealizedVATEntry(GenJournalLine."Document No.",VATPostingSetup."Sales VAT Unreal. Account",UnrealizedVATAmount);
Member of Lib.Library - Sales


UndoReturnReceiptLine@20 Method

The procedure UndoReturnReceiptLine is available in codeunit 130509.

Syntax

UndoReturnReceiptLine@20(
    VAR ReturnReceiptLine@1000 : Record 6661 ReturnReceiptLine //Reference parameter of type Record
);

Parameters

ReturnReceiptLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Undo, Return, Receipt, Line.

For a clarification about how this function works, refer to the code listed below.

      CODEUNIT.RUN(CODEUNIT::"Undo Return Receipt Line",ReturnReceiptLine);

Example

The below example is extracted from the test automation codeunit 134150 to show one way of using this function.

      WITH ReturnReceiptLine DO BEGIN
        SETRANGE("Document No.",DocumentNo);
        FINDSET;
        NEXT(LineNo - 1);
        SETRECFILTER;
      END;
      LibrarySales.UndoReturnReceiptLine(ReturnReceiptLine);
Member of Lib.Library - Sales


UndoSalesShipmentLine@18 Method

The procedure UndoSalesShipmentLine is available in codeunit 130509.

Syntax

UndoSalesShipmentLine@18(
    VAR SalesShipmentLine@1000 : Record 111 SalesShipmentLine //Reference parameter of type Record
);

Parameters

SalesShipmentLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Undo, Sales, Shipment, Line.

For a clarification about how this function works, refer to the code listed below.

      CODEUNIT.RUN(CODEUNIT::"Undo Sales Shipment Line",SalesShipmentLine);

Example

The below example is extracted from the test automation codeunit 134150 to show one way of using this function.

      SalesShipmentLine.SETRANGE("Document No.",DocumentNo);
      SalesShipmentLine.SETRANGE("No.",No);
      SalesShipmentLine.FINDFIRST;
      LibrarySales.UndoSalesShipmentLine(SalesShipmentLine);
Member of Lib.Library - Sales


Library - Service Class

Lib.Library - Service

COD131902 applies to RES,ERM,SCM,W1,All.
Contains all utility functions related to Service.

Methods

Name | Description
AutoReserveServiceLine@30 | The procedure AutoReserveServiceLine is available in codeunit 131902.
ChangeCustomer@11 | The procedure ChangeCustomer is available in codeunit 131902.
CreateBaseCalendar@15 | The procedure CreateBaseCalendar is available in codeunit 131902.
CreateCommentLineForServCntrct@32 | The procedure CreateCommentLineForServCntrct is available in codeunit 131902.
CreateCommentLineForServHeader@28 | The procedure CreateCommentLineForServHeader is available in codeunit 131902.
CreateContractGroup@10 | The procedure CreateContractGroup is available in codeunit 131902.
CreateContractLineCreditMemo@99 | The procedure CreateContractLineCreditMemo is available in codeunit 131902.
CreateContractServiceDiscount@20 | The procedure CreateContractServiceDiscount is available in codeunit 131902.
CreateCustomizedCalendarChange@55 | The procedure CreateCustomizedCalendarChange is available in codeunit 131902.
CreateDefaultServiceHour@25 | The procedure CreateDefaultServiceHour is available in codeunit 131902.
CreateDefaultYellowLocation@65 | The procedure CreateDefaultYellowLocation is available in codeunit 131902.
CreateExtendedTextForItem@27 | The procedure CreateExtendedTextForItem is available in codeunit 131902.
CreateExtendedTextHeaderItem@51 | The procedure CreateExtendedTextHeaderItem is available in codeunit 131902.
CreateExtendedTextLineItem@54 | The procedure CreateExtendedTextLineItem is available in codeunit 131902.
CreateFaultArea@73 | The procedure CreateFaultArea is available in codeunit 131902.
CreateFaultCode@33 | The procedure CreateFaultCode is available in codeunit 131902.
CreateFaultReasonCode@155 | The procedure CreateFaultReasonCode is available in codeunit 131902.
CreateFaultResolCodesRlship@36 | The procedure CreateFaultResolCodesRlship is available in codeunit 131902.
CreateFullWarehouseLocation@70 | The procedure CreateFullWarehouseLocation is available in codeunit 131902.
CreateLoaner@18 | The procedure CreateLoaner is available in codeunit 131902.
CreateOrderFromQuote@44 | The procedure CreateOrderFromQuote is available in codeunit 131902.
CreateReasonCode@43 | The procedure CreateReasonCode is available in codeunit 131902.
CreateRepairStatus@46 | The procedure CreateRepairStatus is available in codeunit 131902.
CreateResolutionCode@85 | The procedure CreateResolutionCode is available in codeunit 131902.
CreateResponsibilityCenter@49 | The procedure CreateResponsibilityCenter is available in codeunit 131902.
CreateServiceCommentLine@22 | The procedure CreateServiceCommentLine is available in codeunit 131902.
CreateServiceContractAcctGrp@7 | The procedure CreateServiceContractAcctGrp is available in codeunit 131902.
CreateServiceContractHeader@1 | The procedure CreateServiceContractHeader is available in codeunit 131902.
CreateServiceContractLine@6 | The procedure CreateServiceContractLine is available in codeunit 131902.
CreateServiceContractTemplate@14 | The procedure CreateServiceContractTemplate is available in codeunit 131902.
CreateServiceCost@31 | The procedure CreateServiceCost is available in codeunit 131902.
CreateServiceCreditMemoHeaderUsingPage@90 | The procedure CreateServiceCreditMemoHeaderUsingPage is available in codeunit 131902.
CreateServiceHeader@4 | The procedure CreateServiceHeader is available in codeunit 131902.
CreateServiceHour@23 | The procedure CreateServiceHour is available in codeunit 131902.
CreateServiceItem@2 | The procedure CreateServiceItem is available in codeunit 131902.
CreateServiceItemComponent@39 | The procedure CreateServiceItemComponent is available in codeunit 131902.
CreateServiceItemGroup@9 | The procedure CreateServiceItemGroup is available in codeunit 131902.
CreateServiceItemLine@5 | The procedure CreateServiceItemLine is available in codeunit 131902.
CreateServiceLine@3 | The procedure CreateServiceLine is available in codeunit 131902.
CreateServiceLineWithQuantity@13 | The procedure CreateServiceLineWithQuantity is available in codeunit 131902.
CreateServiceOrderFromReport@98 | The procedure CreateServiceOrderFromReport is available in codeunit 131902.
CreateServiceOrderHeaderUsingPage@92 | The procedure CreateServiceOrderHeaderUsingPage is available in codeunit 131902.
CreateServiceOrderType@64 | The procedure CreateServiceOrderType is available in codeunit 131902.
CreateServicePriceGroup@45 | The procedure CreateServicePriceGroup is available in codeunit 131902.
CreateServiceZone@16 | The procedure CreateServiceZone is available in codeunit 131902.
CreateServPriceAdjustmentGroup@57 | The procedure CreateServPriceAdjustmentGroup is available in codeunit 131902.
CreateServPriceAdjustmntDetail@52 | The procedure CreateServPriceAdjustmntDetail is available in codeunit 131902.
CreateServPriceGroupSetup@37 | The procedure CreateServPriceGroupSetup is available in codeunit 131902.
CreateStandardServiceCode@48 | The procedure CreateStandardServiceCode is available in codeunit 131902.
CreateStandardServiceItemGr@50 | The procedure CreateStandardServiceItemGr is available in codeunit 131902.
CreateStandardServiceLine@47 | The procedure CreateStandardServiceLine is available in codeunit 131902.
CreateSymptomCode@82 | The procedure CreateSymptomCode is available in codeunit 131902.
CreateTroubleshootingHeader@17 | The procedure CreateTroubleshootingHeader is available in codeunit 131902.
CreateTroubleshootingLine@21 | The procedure CreateTroubleshootingLine is available in codeunit 131902.
CreateTroubleshootingSetup@19 | The procedure CreateTroubleshootingSetup is available in codeunit 131902.
FindContractAccountGroup@24 | The procedure FindContractAccountGroup is available in codeunit 131902.
FindFaultReasonCode@63 | The procedure FindFaultReasonCode is available in codeunit 131902.
FindResolutionCode@130 | The procedure FindResolutionCode is available in codeunit 131902.
FindServiceContractLine@68 | The procedure FindServiceContractLine is available in codeunit 131902.
FindServiceCost@26 | The procedure FindServiceCost is available in codeunit 131902.
FindServiceItemGroup@56 | The procedure FindServiceItemGroup is available in codeunit 131902.
GetFirstWorkingDay@42 | The procedure GetFirstWorkingDay is available in codeunit 131902.
GetNextWorkingDay@41 | The procedure GetNextWorkingDay is available in codeunit 131902.
GetNonWrkngDayFollwdByWrkngDay@34 | The procedure GetNonWrkngDayFollwdByWrkngDay is available in codeunit 131902.
GetServiceHourForDate@40 | The procedure GetServiceHourForDate is available in codeunit 131902.
GetServiceOrderReportGrossAmount@100 | The procedure GetServiceOrderReportGrossAmount is available in codeunit 131902.
IsValidOnHolidays@38 | The procedure IsValidOnHolidays is available in codeunit 131902.
IsWorking@35 | The procedure IsWorking is available in codeunit 131902.
PostServiceOrder@8 | The procedure PostServiceOrder is available in codeunit 131902.
PostServiceOrderWithPassedLines@53 | The procedure PostServiceOrderWithPassedLines is available in codeunit 131902.
ReleaseServiceDocument@78 | The procedure ReleaseServiceDocument is available in codeunit 131902.
ReopenServiceDocument@59 | The procedure ReopenServiceDocument is available in codeunit 131902.
SetCorrDocNoService@58 | The procedure SetCorrDocNoService is available in codeunit 131902.
SetupServiceMgtNoSeries@12 | The procedure SetupServiceMgtNoSeries is available in codeunit 131902.
UndoShipmentLinesByServiceDocNo@108 | The procedure UndoShipmentLinesByServiceDocNo is available in codeunit 131902.
UndoShipmentLinesByServiceOrderNo@77 | The procedure UndoShipmentLinesByServiceOrderNo is available in codeunit 131902.

See Also

Lib


AutoReserveServiceLine@30 Method

The procedure AutoReserveServiceLine is available in codeunit 131902.

Syntax

AutoReserveServiceLine@30(
    ServiceLine@1000 : Record 5902 ServiceLine //Input parameter of type Record
);

Parameters

ServiceLine
Input parameter of type Record

Remarks

The relevant search keywords are: Auto, Reserve, Service, Line.

For a clarification about how this function works, refer to the code listed below.

      ServiceLine.AutoReserve;

Example

The below example is extracted from the test automation codeunit 136121 to show one way of using this function.

      // Exercise: Input a Quantity in Service Line that is less than Quantity in Order and Auto Reserve.
      ServiceLine.VALIDATE(Quantity,Quantity - 1);
      ServiceLine.MODIFY(TRUE);
      LibraryService.AutoReserveServiceLine(ServiceLine);

      // Verify: Check that the Reserved Quantity field in Service Line is updated with the correct Quantity and Reservation Entry is
      // created.
      ServiceLine.CALCFIELDS("Reserved Quantity");
      ServiceLine.TESTFIELD("Reserved Quantity",Quantity - 1);
      VerifyReservationEntry(ServiceLine,Quantity - 1);
Member of Lib.Library - Service


ChangeCustomer@11 Method

The procedure ChangeCustomer is available in codeunit 131902.

Syntax

ChangeCustomer@11(
    ServiceContractHeader@1000 : Record 5965 ServiceContractHeader, //Input parameter of type Record
    NewCustomerNo@1002 : Code[20] NewCustomerNo //Input parameter of type Code
);

Parameters

ServiceContractHeader
Input parameter of type Record
NewCustomerNo
Input parameter of type Code

Remarks

The relevant search keywords are: Change, Customer.

For a clarification about how this function works, refer to the code listed below.

      // Change Customer on Service Contract.
      ServContractManagement.ChangeCustNoOnServContract(NewCustomerNo,'',ServiceContractHeader)

Example

There are no examples available.
Member of Lib.Library - Service


CreateBaseCalendar@15 Method

The procedure CreateBaseCalendar is available in codeunit 131902.

Syntax

CreateBaseCalendar@15(
    VAR BaseCalendar@1000 : Record 7600 BaseCalendar //Reference parameter of type Record
);

Parameters

BaseCalendar
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Base, Calendar.

For a clarification about how this function works, refer to the code listed below.

      BaseCalendar.INIT;
      // Use the function GenerateRandomCode to get random and unique value for the Code field.
      BaseCalendar.VALIDATE(Code,LibraryUtility.GenerateRandomCode(BaseCalendar.FIELDNO(Code),DATABASE::"Base Calendar"));
      BaseCalendar.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137044 to show one way of using this function.

      // [FEATURE] [Base Calendar]
      // [SCENARIO 376713] Calculate order promising when requested delivery date is a non-working day
      Initialize;
      UpdateCompanyInformationCalcBucket(0);
      CreateItem(Item,Item."Replenishment System"::Purchase);
      Qty := LibraryRandom.RandDec(100,2);

      // [GIVEN] Sales order with Shipment Date = "D", Requested Delivery Date = "D"
      CreateSalesOrderWithRequestedDeliveryDate(SalesHeader,Item."No.",Qty,WORKDATE + 1,WORKDATE + 1);

      // [GIVEN] Create base calendar and mark date "D" as non-working
      LibraryService.CreateBaseCalendar(BaseCalendar);
      CreateNonWorkingDayInBaseCalendar(BaseCalendar.Code,SalesHeader."Shipment Date");
      UpdateCompanyInfoBaseCalendarCode(BaseCalendar.Code);

      // [GIVEN] Purchase order with Expected Receipt Date = "D" - 1
      CreatePurchaseOrder(PurchaseHeader,WORKDATE,'',Item."No.",Qty);

      // [WHEN] Calculate order promising line for the sales order
      CalcSalesHeaderAvailableToPromise(TempOrderPromisingLine,SalesHeader);

      // [THEN] Earliest shipment date = "D" + 1 (next working day)
      TempOrderPromisingLine.TESTFIELD("Earliest Shipment Date",SalesHeader."Shipment Date" + 1);
Member of Lib.Library - Service


CreateCommentLineForServCntrct@32 Method

The procedure CreateCommentLineForServCntrct is available in codeunit 131902.

Syntax

CreateCommentLineForServCntrct@32(
    VAR ServiceCommentLine@1002 : Record 5906 ServiceCommentLine, //Reference parameter of type Record
    ServiceContractLine@1001 : Record 5964 ServiceContractLine, //Input parameter of type Record
    Type@1000 : Option Type //Input parameter of type Option
);

Parameters

ServiceCommentLine
Reference parameter of type Record
ServiceContractLine
Input parameter of type Record
Type
Input parameter of type Option

Remarks

The relevant search keywords are: Create, Comment, Line, For, Serv, Cntrct.

For a clarification about how this function works, refer to the code listed below.

      CreateServiceCommentLine(
        ServiceCommentLine,ServiceCommentLine."Table Name"::"Service Contract",ServiceContractLine."Contract Type",
        ServiceContractLine."Contract No.",Type,ServiceContractLine."Line No.");

Example

The below example is extracted from the test automation codeunit 136102 to show one way of using this function.

      // Covers document number TC0076 - refer to TFS ID 21730.
      // [SCENARIO] The Test Case Save Service Contract Quote Details report in XML and XLSX format after adding comments Date in Service Contract header and check that some data exist in saved files.

      // 1. Setup: Create Service Contract Quote Header and Service Contract Quote Line.
      Initialize;
      CreateServiceContract(ServiceContractHeader,ServiceContractLine,ServiceContractHeader."Contract Type"::Quote);
      ModifyServiceContractHeader(ServiceContractHeader,ServiceContractHeader."Service Period");
      LibraryService.CreateCommentLineForServCntrct(ServiceCommentLine,ServiceContractLine,Type);
      ServiceCommentLine.VALIDATE(Date,ServiceContractHeader."Starting Date");
      ServiceCommentLine.MODIFY(TRUE);

      // 2. Exercise: Save Report as XML in local Temp folder.
      ServiceContractHeader.SETRANGE("Contract Type",ServiceContractHeader."Contract Type"::Contract);
      ServiceContractHeader.SETRANGE("Contract No.",ServiceContractHeader."Contract No.");
      CLEAR(ServiceContractQuoteDetail);
      ServiceContractQuoteDetail.SETTABLEVIEW(ServiceContractHeader);
      FilePath := TEMPORARYPATH + FORMAT(ServiceContractHeader."Contract Type") + ServiceContractHeader."Contract No." + '.xlsx';
      ServiceContractQuoteDetail.SAVEASEXCEL(FilePath);

      // 3. Verify: Verify that Saved file have some data.
      LibraryUtility.CheckFileNotEmpty(FilePath);
Member of Lib.Library - Service


CreateCommentLineForServHeader@28 Method

The procedure CreateCommentLineForServHeader is available in codeunit 131902.

Syntax

CreateCommentLineForServHeader@28(
    VAR ServiceCommentLine@1000 : Record 5906 ServiceCommentLine, //Reference parameter of type Record
    ServiceItemLine@1001 : Record 5901 ServiceItemLine, //Input parameter of type Record
    Type@1002 : Option Type //Input parameter of type Option
);

Parameters

ServiceCommentLine
Reference parameter of type Record
ServiceItemLine
Input parameter of type Record
Type
Input parameter of type Option

Remarks

The relevant search keywords are: Create, Comment, Line, For, Serv, Header.

For a clarification about how this function works, refer to the code listed below.

      CreateServiceCommentLine(
        ServiceCommentLine,ServiceCommentLine."Table Name"::"Service Header",ServiceItemLine."Document Type",
        ServiceItemLine."Document No.",Type,ServiceItemLine."Line No.");

Example

The below example is extracted from the test automation codeunit 136101 to show one way of using this function.

      LibraryService.CreateCommentLineForServHeader(ServiceCommentLine,ServiceItemLine,ServiceCommentLine.Type::Fault);
      LibraryService.CreateCommentLineForServHeader(ServiceCommentLine,ServiceItemLine,ServiceCommentLine.Type::Resolution);
      LibraryService.CreateCommentLineForServHeader(ServiceCommentLine,ServiceItemLine,ServiceCommentLine.Type::Accessory);
      LibraryService.CreateCommentLineForServHeader(ServiceCommentLine,ServiceItemLine,ServiceCommentLine.Type::Internal);
      LibraryService.CreateCommentLineForServHeader(ServiceCommentLine,ServiceItemLine,ServiceCommentLine.Type::"Service Item Loaner");
Member of Lib.Library - Service


CreateContractGroup@10 Method

The procedure CreateContractGroup is available in codeunit 131902.

Syntax

CreateContractGroup@10(
    VAR ContractGroup@1000 : Record 5966 ContractGroup //Reference parameter of type Record
);

Parameters

ContractGroup
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Contract, Group.

For a clarification about how this function works, refer to the code listed below.

      ContractGroup.INIT;

      // Use the function GenerateRandomCode to get random and unique value for the Code field.
      ContractGroup.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(ContractGroup.FIELDNO(Code),DATABASE::"Base Calendar"),
          1,LibraryUtility.GetFieldLength(DATABASE::"Base Calendar",ContractGroup.FIELDNO(Code))));
      ContractGroup.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136139 to show one way of using this function.

      // Test Contract Gain/Loss (Groups) Matrix after signing the Service Contract.

      // 1. Setup: Create Contract Group, Service Contract Header, Service Contract Line, update Contract Group Code on Service
      // Contract Header and sign the Service Contract.
      Initialize;
      LibraryService.CreateContractGroup(ContractGroup);
      LibraryService.CreateServiceContractHeader(ServiceContractHeader,ServiceContractHeader."Contract Type"::Contract,'');
      CreateServiceContractLine(ServiceContractHeader);
      UpdateContractGroupCode(ServiceContractHeader,ContractGroup.Code);
      UpdateServiceContractHeader(ServiceContractHeader);
      SignServContractDoc.SignContract(ServiceContractHeader);
      FindContractGainLossEntry(ContractGainLossEntry,ServiceContractHeader."Contract No.");

      // Assign global variable for page handler.
      Amount := ContractGainLossEntry.Amount;
      PeriodStart := ContractGainLossEntry."Change Date";

      // 2. Exercise: Run Show Matrix from Contract Gain/Loss (Groups) page with Period Start Date and Group filter.
      ContractGainLossGroups.OPENEDIT;
      ContractGainLossGroups.PeriodStart.SETVALUE(ContractGainLossEntry."Change Date");
      ContractGainLossGroups.GroupFilter.SETVALUE(ServiceContractHeader."Contract Group Code");
      COMMIT;
      ContractGainLossGroups.ShowMatrix.INVOKE;

      // 3. Verify: Verify value on Contract Gain/Loss (Groups) Matrix performed on Contract Gain/Loss (Groups) Matrix page handler.
Member of Lib.Library - Service


CreateContractLineCreditMemo@99 Method

The procedure CreateContractLineCreditMemo is available in codeunit 131902.

Syntax

CreateContractLineCreditMemo@99(
    VAR ServiceContractLine@1000 : Record 5964 ServiceContractLine, //Reference parameter of type Record
    Deleting@1001 : Boolean Deleting //Input parameter of type Boolean
);

Parameters

ServiceContractLine
Reference parameter of type Record
Deleting
Input parameter of type Boolean

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Contract, Line, Credit, Memo.

For a clarification about how this function works, refer to the code listed below.

      CreditMemoNo := ServContractManagement.CreateContractLineCreditMemo(ServiceContractLine,Deleting);
      EXIT(CreditMemoNo);

Example

The below example is extracted from the test automation codeunit 136100 to show one way of using this function.

      FindServiceContractLine(ServiceContractLine,ContractNo);
      ServiceContractLine.VALIDATE("Contract Expiration Date",ExpirationDate);
      ServiceContractLine.MODIFY(TRUE);

      ServContractManagement.CreateContractLineCreditMemo(ServiceContractLine,FALSE);
      FindServiceHeader(ServiceHeader,ServiceHeader."Document Type"::"Credit Memo",ServiceContractLine."Contract No.");
      LibraryService.PostServiceOrder(ServiceHeader,TRUE,FALSE,TRUE);
Member of Lib.Library - Service


CreateContractServiceDiscount@20 Method

The procedure CreateContractServiceDiscount is available in codeunit 131902.

Syntax

CreateContractServiceDiscount@20(
    VAR ContractServiceDiscount@1000 : Record 5972 ContractServiceDiscount, //Reference parameter of type Record
    ServiceContractHeader@1001 : Record 5965 ServiceContractHeader, //Input parameter of type Record
    Type@1002 : Option Type, //Input parameter of type Option
    No@1003 : Code[20] No //Input parameter of type Code
);

Parameters

ContractServiceDiscount
Reference parameter of type Record
ServiceContractHeader
Input parameter of type Record
Type
Input parameter of type Option
No
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Contract, Service, Discount.

For a clarification about how this function works, refer to the code listed below.

      ContractServiceDiscount.INIT;
      ContractServiceDiscount.VALIDATE("Contract Type",ServiceContractHeader."Contract Type");
      ContractServiceDiscount.VALIDATE("Contract No.",ServiceContractHeader."Contract No.");
      ContractServiceDiscount.VALIDATE(Type,Type);
      ContractServiceDiscount.VALIDATE("No.",No);
      ContractServiceDiscount.VALIDATE("Starting Date",ServiceContractHeader."Starting Date");
      ContractServiceDiscount.VALIDATE("Discount %",RANDOM(100));  // Validating as random because value is not important.
      ContractServiceDiscount.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136102 to show one way of using this function.

      // Covers document number TC0074 - refer to TFS ID 21730.
      // [SCENARIO] The Test Case checks Status and Change Status field is changed after Sign Contract.

      // 1. Setup: Create Service Contract, Service Hours, Service Discount and Sign Service Contract.
      Initialize;
      CreateServiceContract(ServiceContractHeader,ServiceContractLine,ServiceContractHeader."Contract Type"::Contract);
      CreateServiceContractLineItem(ServiceContractHeader);
      ModifyServiceContractHeader(ServiceContractHeader,ServiceContractHeader."Service Period");

      LibraryService.CreateServiceHour(ServiceHour,ServiceContractHeader,ServiceHour.Day::Monday);

      LibraryService.FindServiceItemGroup(ServiceItemGroup);
      LibraryService.CreateContractServiceDiscount(
        ContractServiceDiscount,ServiceContractHeader,ContractServiceDiscount.Type::"Service Item Group",ServiceItemGroup.Code);

      // 2. Exercise: Sign Service Contract.
      SignServContractDoc.SignContract(ServiceContractHeader);

      // 3. Verify: Check that Status and Change Status field is changed after Sign Contract.
      ServiceContractHeader.GET(ServiceContractHeader."Contract Type"::Contract,ServiceContractHeader."Contract No.");
      ServiceContractHeader.TESTFIELD(Status,ServiceContractHeader.Status::Signed);
      ServiceContractHeader.TESTFIELD("Change Status",ServiceContractHeader."Change Status"::Locked);
Member of Lib.Library - Service


CreateCustomizedCalendarChange@55 Method

The procedure CreateCustomizedCalendarChange is available in codeunit 131902.

Syntax

CreateCustomizedCalendarChange@55(
    BaseCalendarCode@1000 : Code[10] BaseCalendarCode, //Input parameter of type Code
    VAR CustomizedCalendarChange@1001 : Record 7602 CustomizedCalendarChange, //Reference parameter of type Record
    SourceType@1002 : Option SourceType, //Input parameter of type Option
    SourceCode@1003 : Code[10] SourceCode, //Input parameter of type Code
    AdditionalSourceCode@1004 : Code[10] AdditionalSourceCode, //Input parameter of type Code
    RecurringSystem@1005 : Option RecurringSystem, //Input parameter of type Option
    WeekDay@1006 : Option WeekDay, //Input parameter of type Option
    IsNonWorking@1007 : Boolean IsNonWorking //Input parameter of type Boolean
);

Parameters

BaseCalendarCode
Input parameter of type Code
CustomizedCalendarChange
Reference parameter of type Record
SourceType
Input parameter of type Option
SourceCode
Input parameter of type Code
AdditionalSourceCode
Input parameter of type Code
RecurringSystem
Input parameter of type Option
WeekDay
Input parameter of type Option
IsNonWorking
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, Customized, Calendar, Change.

For a clarification about how this function works, refer to the code listed below.

      WITH CustomizedCalendarChange DO BEGIN
        INIT;
        VALIDATE("Source Type",SourceType);
        VALIDATE("Source Code",SourceCode);
        VALIDATE("Additional Source Code",AdditionalSourceCode);
        VALIDATE("Base Calendar Code",BaseCalendarCode);
        VALIDATE("Recurring System",RecurringSystem);
        VALIDATE(Day,WeekDay);
        VALIDATE(Nonworking,IsNonWorking);
        INSERT(TRUE);
      END;

Example

The below example is extracted from the test automation codeunit 137050 to show one way of using this function.

      WITH CustomizedCalendarChange DO
        FOR WeekDay := Day::Monday TO Day::Sunday DO
          IF WeekDay <> SetWorkingDay THEN
            LibraryService.CreateCustomizedCalendarChange(
              BaseCalendarCode,CustomizedCalendarChange,"Source Type"::"Shipping Agent",
              ShippingAgentServices."Shipping Agent Code",ShippingAgentServices.Code,
              "Recurring System"::"Weekly Recurring",WeekDay,TRUE);
Member of Lib.Library - Service


CreateDefaultServiceHour@25 Method

The procedure CreateDefaultServiceHour is available in codeunit 131902.

Syntax

CreateDefaultServiceHour@25(
    VAR ServiceHour@1000 : Record 5910 ServiceHour, //Reference parameter of type Record
    Day@1001 : Option Day //Input parameter of type Option
);

Parameters

ServiceHour
Reference parameter of type Record
Day
Input parameter of type Option

Remarks

The relevant search keywords are: Create, Default, Service, Hour.

For a clarification about how this function works, refer to the code listed below.

      ServiceHour.INIT;
      // Use a random Starting Time that does not cause Ending Time to fall in the next day.
      ServiceHour.VALIDATE("Starting Time",000000T + RANDOM(LibraryUtility.ConvertHoursToMilliSec(12)));
      // Use a random Ending Time that does not fall in the next day.
      ServiceHour.VALIDATE("Ending Time",ServiceHour."Starting Time" + RANDOM(LibraryUtility.ConvertHoursToMilliSec(12)) - 1);
      ServiceHour.VALIDATE(Day,Day);
      ServiceHour.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136106 to show one way of using this function.

      NonWorkingDate := GetNonWorkingDay(WORKDATE);
      IF NOT LibraryService.GetServiceHourForDate(ServiceHour,NonWorkingDate) THEN BEGIN
        Date.GET(Date."Period Type"::Date,NonWorkingDate);
        EVALUATE(ServiceHour.Day,Date."Period Name");
        LibraryService.CreateDefaultServiceHour(ServiceHour,ServiceHour.Day);
        // Required field - value is not important for test case.
        ServiceHour.VALIDATE(
          "Ending Time",
          ServiceHour."Starting Time" + LibraryUtility.ConvertHoursToMilliSec(LibraryRandom.RandIntInRange(5,10)));
      END;
      ServiceHour.VALIDATE("Valid on Holidays",TRUE);
      ServiceHour.MODIFY(TRUE);
      EXIT(NonWorkingDate);
Member of Lib.Library - Service


CreateDefaultYellowLocation@65 Method

The procedure CreateDefaultYellowLocation is available in codeunit 131902.

Syntax

CreateDefaultYellowLocation@65(
    VAR Location@1000 : Record 14 Location //Reference parameter of type Record
);

Parameters

Location
Reference parameter of type Record

Return Value

Code[10]

Remarks

The relevant search keywords are: Create, Default, Yellow, Location.

For a clarification about how this function works, refer to the code listed below.

      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location);
      WITH Location DO BEGIN
        VALIDATE("Require Receive",TRUE);
        VALIDATE("Require Shipment",TRUE);
        VALIDATE("Require Put-away",TRUE);
        VALIDATE("Require Pick",TRUE);

        VALIDATE("Bin Mandatory",FALSE);
        VALIDATE("Use Put-away Worksheet",FALSE);
        VALIDATE("Directed Put-away and Pick",FALSE);
        VALIDATE("Use ADCS",FALSE);

        MODIFY(TRUE);
      END;

      LibraryWarehouse.CreateWarehouseEmployee(WarehouseEmployee,Location.Code,FALSE);

      EXIT(Location.Code);

Example

The below example is extracted from the test automation codeunit 136140 to show one way of using this function.

      EXIT(LibraryService.CreateDefaultYellowLocation(Location));
Member of Lib.Library - Service


CreateExtendedTextForItem@27 Method

The procedure CreateExtendedTextForItem is available in codeunit 131902.

Syntax

CreateExtendedTextForItem@27(
    ItemNo@1000 : Code[20] ItemNo //Input parameter of type Code
);

Parameters

ItemNo
Input parameter of type Code

Return Value

Text

Remarks

The relevant search keywords are: Create, Extended, Text, For, Item.

For a clarification about how this function works, refer to the code listed below.

      CreateExtendedTextHeaderItem(ExtendedTextHeader,ItemNo);
      CreateExtendedTextLineItem(ExtendedTextLine,ExtendedTextHeader);
      ExtendedTextLine.VALIDATE(Text,LibraryUtility.GenerateGUID);
      ExtendedTextLine.MODIFY;
      EXIT(ExtendedTextLine.Text);

Example

The below example is extracted from the test automation codeunit 137158 to show one way of using this function.

      // [FEATURE] [BOM] [Explode BOM] [Sales] [Extended Text]
      // [SCENARIO 382083] The Assembly BOM is exploded on the Sales Line after attached extended texts

      // [GIVEN] Assembly BOM with extended text
      Initialize;
      UpdateStockoutWarningOnSalesReceivableSetup(FALSE);
      CompItemNo := LibraryInventory.CreateItemNo;
      CreateAssemblyItemWithAsseblyBOM(AssemblyItem,CompItemNo,LibraryRandom.RandInt(10));
      ExtendedText := LibraryService.CreateExtendedTextForItem(AssemblyItem."No.");

      // [GIVEN] Sales Order with Assembly BOM and inserted extended text
      CreateSalesOrderWithInsertedExtendedText(SalesHeader,SalesLine,AssemblyItem."No.");

      // [WHEN] Explode Assembly BOM
      LibrarySales.ExplodeBOM(SalesLine);

      // [THEN] The Sales Line with component is inserted after extended text from BOM
      VerifySalesLineExtTextBeforeItem(SalesHeader,ExtendedText,CompItemNo);
Member of Lib.Library - Service


CreateExtendedTextHeaderItem@51 Method

The procedure CreateExtendedTextHeaderItem is available in codeunit 131902.

Syntax

CreateExtendedTextHeaderItem@51(
    VAR ExtendedTextHeader@1000 : Record 279 ExtendedTextHeader, //Reference parameter of type Record
    ItemNo@1001 : Code[20] ItemNo //Input parameter of type Code
);

Parameters

ExtendedTextHeader
Reference parameter of type Record
ItemNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Extended, Text, Header, Item.

For a clarification about how this function works, refer to the code listed below.

      ExtendedTextHeader.INIT;
      ExtendedTextHeader.VALIDATE("Table Name",ExtendedTextHeader."Table Name"::Item);
      ExtendedTextHeader.VALIDATE("No.",ItemNo);
      ExtendedTextHeader.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134326 to show one way of using this function.

      // Create Item.
      LibraryInventory.CreateItem(Item);
      Item.VALIDATE("Automatic Ext. Texts",TRUE);
      Item.MODIFY(TRUE);

      // Create Extended Text Header and Line.
      LibraryService.CreateExtendedTextHeaderItem(ExtendedTextHeader,Item."No.");
      ExtendedTextHeader.VALIDATE("Purchase Blanket Order",FALSE);
      ExtendedTextHeader.MODIFY(TRUE);
      LibraryService.CreateExtendedTextLineItem(ExtendedTextLine,ExtendedTextHeader);
      ExtendedTextLine.VALIDATE(Text,Item."No.");
      ExtendedTextLine.MODIFY(TRUE);
      EXIT(Item."No.");
Member of Lib.Library - Service


CreateExtendedTextLineItem@54 Method

The procedure CreateExtendedTextLineItem is available in codeunit 131902.

Syntax

CreateExtendedTextLineItem@54(
    VAR ExtendedTextLine@1002 : Record 280 ExtendedTextLine, //Reference parameter of type Record
    ExtendedTextHeader@1000 : Record 279 ExtendedTextHeader //Input parameter of type Record
);

Parameters

ExtendedTextLine
Reference parameter of type Record
ExtendedTextHeader
Input parameter of type Record

Remarks

The relevant search keywords are: Create, Extended, Text, Line, Item.

For a clarification about how this function works, refer to the code listed below.

      ExtendedTextLine.INIT;
      ExtendedTextLine.VALIDATE("Table Name",ExtendedTextHeader."Table Name");
      ExtendedTextLine.VALIDATE("No.",ExtendedTextHeader."No.");
      ExtendedTextLine.VALIDATE("Language Code",ExtendedTextHeader."Language Code");
      ExtendedTextLine.VALIDATE("Text No.",ExtendedTextHeader."Text No.");
      RecRef.GETTABLE(ExtendedTextLine);
      ExtendedTextLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,ExtendedTextLine.FIELDNO("Line No.")));
      ExtendedTextLine.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134326 to show one way of using this function.

      // Create Item.
      LibraryInventory.CreateItem(Item);
      Item.VALIDATE("Automatic Ext. Texts",TRUE);
      Item.MODIFY(TRUE);

      // Create Extended Text Header and Line.
      LibraryService.CreateExtendedTextHeaderItem(ExtendedTextHeader,Item."No.");
      ExtendedTextHeader.VALIDATE("Purchase Blanket Order",FALSE);
      ExtendedTextHeader.MODIFY(TRUE);
      LibraryService.CreateExtendedTextLineItem(ExtendedTextLine,ExtendedTextHeader);
      ExtendedTextLine.VALIDATE(Text,Item."No.");
      ExtendedTextLine.MODIFY(TRUE);
      EXIT(Item."No.");
Member of Lib.Library - Service


CreateFaultArea@73 Method

The procedure CreateFaultArea is available in codeunit 131902.

Syntax

CreateFaultArea@73(
    VAR FaultArea@1001 : Record 5915 FaultArea //Reference parameter of type Record
);

Parameters

FaultArea
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Fault, Area.

For a clarification about how this function works, refer to the code listed below.

      FaultArea.INIT;
      // Use the function GenerateRandomCode to get random and unique value for the Code field.
      FaultArea.VALIDATE(Code,LibraryUtility.GenerateRandomCode(FaultArea.FIELDNO(Code),DATABASE::"Fault Area"));
      FaultArea.VALIDATE(Description,FaultArea.Code);  // Validating Code as Description because value is not important.
      FaultArea.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136110 to show one way of using this function.

      // Covers document number TC0111 - refer to TFS ID 21727.
      // 1. Input Fault Reporting Level as None in Service Management Setup. Find Fault Area and Symptom Code.
      // 2. Try to insert a Fault Code record with Fault Code as not blank.
      // 3. Verify that the application generates an error on insertion of Fault Code record if Fault Reporting Level is set to None.

      // Setup: Input Fault Reporting Level as None in Service Management Setup.
      SetupServiceFaultReporting(ServiceMgtSetup,ServiceMgtSetup."Fault Reporting Level"::None);

      LibraryService.CreateFaultArea(FaultArea);
      LibraryService.CreateSymptomCode(SymptomCode);

      // Exercise: Insert Fault Code.
      ASSERTERROR LibraryService.CreateFaultCode(FaultCode,FaultArea.Code,SymptomCode.Code);

      // Verify: Check that the application generates an error on insertion of Fault Code record if Fault Reporting Level is set to None.
      Assert.AreEqual(
        STRSUBSTNO(FaultReportingLevelNoneError,FaultCode.TABLECAPTION,ServiceMgtSetup.FIELDCAPTION("Fault Reporting Level"),
          ServiceMgtSetup.TABLECAPTION,FORMAT(ServiceMgtSetup."Fault Reporting Level")),GETLASTERRORTEXT,UnknownError);
Member of Lib.Library - Service


CreateFaultCode@33 Method

The procedure CreateFaultCode is available in codeunit 131902.

Syntax

CreateFaultCode@33(
    VAR FaultCode@1000 : Record 5918 FaultCode, //Reference parameter of type Record
    FaultAreaCode@1001 : Code[10] FaultAreaCode, //Input parameter of type Code
    SymptomCode@1002 : Code[10] SymptomCode //Input parameter of type Code
);

Parameters

FaultCode
Reference parameter of type Record
FaultAreaCode
Input parameter of type Code
SymptomCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Fault, Code.

For a clarification about how this function works, refer to the code listed below.

      FaultCode.INIT;
      FaultCode.VALIDATE("Fault Area Code",FaultAreaCode);
      FaultCode.VALIDATE("Symptom Code",SymptomCode);
      FaultCode.VALIDATE(Code,LibraryUtility.GenerateRandomCode(FaultCode.FIELDNO(Code),DATABASE::"Fault Code"));
      FaultCode.VALIDATE(Description,FaultCode.Code);  // Validating Code as Description because value is not important.
      FaultCode.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136110 to show one way of using this function.

      // Covers document number TC0111 - refer to TFS ID 21727.
      // 1. Input Fault Reporting Level as None in Service Management Setup. Find Fault Area and Symptom Code.
      // 2. Try to insert a Fault Code record with Fault Code as not blank.
      // 3. Verify that the application generates an error on insertion of Fault Code record if Fault Reporting Level is set to None.

      // Setup: Input Fault Reporting Level as None in Service Management Setup.
      SetupServiceFaultReporting(ServiceMgtSetup,ServiceMgtSetup."Fault Reporting Level"::None);

      LibraryService.CreateFaultArea(FaultArea);
      LibraryService.CreateSymptomCode(SymptomCode);

      // Exercise: Insert Fault Code.
      ASSERTERROR LibraryService.CreateFaultCode(FaultCode,FaultArea.Code,SymptomCode.Code);

      // Verify: Check that the application generates an error on insertion of Fault Code record if Fault Reporting Level is set to None.
      Assert.AreEqual(
        STRSUBSTNO(FaultReportingLevelNoneError,FaultCode.TABLECAPTION,ServiceMgtSetup.FIELDCAPTION("Fault Reporting Level"),
          ServiceMgtSetup.TABLECAPTION,FORMAT(ServiceMgtSetup."Fault Reporting Level")),GETLASTERRORTEXT,UnknownError);
Member of Lib.Library - Service


CreateFaultReasonCode@155 Method

The procedure CreateFaultReasonCode is available in codeunit 131902.

Syntax

CreateFaultReasonCode@155(
    VAR FaultReasonCode@1000 : Record 5917 FaultReasonCode, //Reference parameter of type Record
    ExcludeWarrantyDiscount@1001 : Boolean ExcludeWarrantyDiscount, //Input parameter of type Boolean
    ExcludeContractDiscount@1002 : Boolean ExcludeContractDiscount //Input parameter of type Boolean
);

Parameters

FaultReasonCode
Reference parameter of type Record
ExcludeWarrantyDiscount
Input parameter of type Boolean
ExcludeContractDiscount
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, Fault, Reason, Code.

For a clarification about how this function works, refer to the code listed below.

      WITH FaultReasonCode DO BEGIN
        VALIDATE(Code,LibraryUtility.GenerateRandomCode(FIELDNO(Code),DATABASE::"Fault Reason Code"));
        VALIDATE(Description,Code);
        VALIDATE("Exclude Warranty Discount",ExcludeWarrantyDiscount);
        VALIDATE("Exclude Contract Discount",ExcludeContractDiscount);
        INSERT(TRUE);
      END;

Example

The below example is extracted from the test automation codeunit 136101 to show one way of using this function.

      // [FEATURE] [Line Discount] [UI]
      // [SCENARIO 362453] "Line Discount %" should not be changed by "Fault Reason Code" with "Exclude Contract Discount"
      Initialize;

      // [GIVEN] Service Order with Service Line with Line Discount % = 50
      CreateSimpleServiceOrder(ServiceLine,LineDiscountPercent);
      // [GIVEN] Fault Reason Code "C" excluding contract discount
      LibraryService.CreateFaultReasonCode(FaultReasonCode,FALSE,TRUE);

      // [WHEN] Fault Reason Code "C" set into Service Line through page
      LibraryVariableStorage.Enqueue(FaultReasonCode.Code);
      OpenServiceItemWorksheetPage(ServiceLine."Document No.");

      // [THEN] Line Discount must be equal to 50. (must not be changed)
      ServiceLine.FIND;
      Assert.AreEqual(LineDiscountPercent,ServiceLine."Line Discount %",ServiceLine.FIELDCAPTION("Line Discount %"));
Member of Lib.Library - Service


CreateFaultResolCodesRlship@36 Method

The procedure CreateFaultResolCodesRlship is available in codeunit 131902.

Syntax

CreateFaultResolCodesRlship@36(
    VAR FaultResolCodRelationship@1000 : Record 5920 FaultResolCodRelationship, //Reference parameter of type Record
    FaultCode@1001 : Record 5918 FaultCode, //Input parameter of type Record
    ResolutionCode@1002 : Code[10] ResolutionCode, //Input parameter of type Code
    ServiceItemGroupCode@1003 : Code[10] ServiceItemGroupCode //Input parameter of type Code
);

Parameters

FaultResolCodRelationship
Reference parameter of type Record
FaultCode
Input parameter of type Record
ResolutionCode
Input parameter of type Code
ServiceItemGroupCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Fault, Resol, Codes, Rlship.

For a clarification about how this function works, refer to the code listed below.

      FaultResolCodRelationship.INIT;
      FaultResolCodRelationship.VALIDATE("Fault Area Code",FaultCode."Fault Area Code");
      FaultResolCodRelationship.VALIDATE("Symptom Code",FaultCode."Symptom Code");
      FaultResolCodRelationship.VALIDATE("Fault Code",FaultCode.Code);
      FaultResolCodRelationship.VALIDATE("Resolution Code",ResolutionCode);
      FaultResolCodRelationship.VALIDATE("Service Item Group Code",ServiceItemGroupCode);
      FaultResolCodRelationship.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136122 to show one way of using this function.

      // Finding Fault Area Code, Symptom Code, Resolution Code,Service Item Group Code and creating Fault Code.
      LibraryService.CreateFaultArea(FaultArea);
      LibraryService.CreateSymptomCode(SymptomCode);
      LibraryService.CreateResolutionCode(ResolutionCode);
      LibraryService.CreateServiceItemGroup(ServiceItemGroupCode);
      LibraryService.CreateFaultCode(FaultCode,FaultArea.Code,SymptomCode.Code);
      LibraryService.CreateFaultResolCodesRlship(FaultResolCodRelationship,FaultCode,ResolutionCode.Code,ServiceItemGroupCode.Code);
Member of Lib.Library - Service


CreateFullWarehouseLocation@70 Method

The procedure CreateFullWarehouseLocation is available in codeunit 131902.

Syntax

CreateFullWarehouseLocation@70(
    VAR Location@1000 : Record 14 Location, //Reference parameter of type Record
    NumberOfBinsPerZone@1003 : Integer NumberOfBinsPerZone //Input parameter of type Integer
);

Parameters

Location
Reference parameter of type Record
NumberOfBinsPerZone
Input parameter of type Integer

Remarks

The relevant search keywords are: Create, Full, Warehouse, Location.

For a clarification about how this function works, refer to the code listed below.

      LibraryWarehouse.CreateFullWMSLocation(Location,NumberOfBinsPerZone);  // Value used for number of bin per zone.
      LibraryWarehouse.CreateWarehouseEmployee(WarehouseEmployee,Location.Code,FALSE);

Example

The below example is extracted from the test automation codeunit 136140 to show one way of using this function.

      LibraryService.CreateFullWarehouseLocation(Location,2);  // Value used for number of bin per zone.
Member of Lib.Library - Service


CreateLoaner@18 Method

The procedure CreateLoaner is available in codeunit 131902.

Syntax

CreateLoaner@18(
    VAR Loaner@1000 : Record 5913 Loaner //Reference parameter of type Record
);

Parameters

Loaner
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Loaner.

For a clarification about how this function works, refer to the code listed below.

      Loaner.INIT;
      Loaner.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136101 to show one way of using this function.

      LibraryService.CreateLoaner(Loaner);
      EXIT(Loaner."No.");
Member of Lib.Library - Service


CreateOrderFromQuote@44 Method

The procedure CreateOrderFromQuote is available in codeunit 131902.

Syntax

CreateOrderFromQuote@44(
    ServiceHeader@1000 : Record 5900 ServiceHeader //Input parameter of type Record
);

Parameters

ServiceHeader
Input parameter of type Record

Remarks

The relevant search keywords are: Create, Order, From, Quote.

For a clarification about how this function works, refer to the code listed below.

      CODEUNIT.RUN(CODEUNIT::"Service-Quote to Order",ServiceHeader);

Example

The below example is extracted from the test automation codeunit 136101 to show one way of using this function.

      // Covers document number CU5901 - refer to TFS ID 167035.
      // [SCENARIO 167035] Test Comments on Service Order create from Service Quote.

      // [GIVEN] Create Service Quote and Assign Loaner on Service Quote, Create Comments on Service Quote.
      CreateServiceQuoteWithComments(ServiceItemLine);
      SaveComments(TempServiceCommentLine,ServiceItemLine);

      // [WHEN] Create Service Order from Service Quote.
      ServiceHeader.GET(ServiceItemLine."Document Type",ServiceItemLine."Document No.");
      LibraryService.CreateOrderFromQuote(ServiceHeader);

      // [THEN] Verify that the Comments on Service Order is Comments assign on Service Quote.
      ServiceItemLine.SETRANGE("Service Item No.",ServiceItemLine."Service Item No.");
      ServiceItemLine.FINDFIRST;
      VerifyComments(TempServiceCommentLine,ServiceItemLine);

      // 4. Teardown: Receive Loaner.
      ReceiveLoanerOnServiceOrder(ServiceItemLine,ServiceItemLine."Service Item No.");
Member of Lib.Library - Service


CreateReasonCode@43 Method

The procedure CreateReasonCode is available in codeunit 131902.

Syntax

CreateReasonCode@43(
    VAR ReasonCode@1000 : Record 231 ReasonCode //Reference parameter of type Record
);

Parameters

ReasonCode
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Reason, Code.

For a clarification about how this function works, refer to the code listed below.

      ReasonCode.INIT;
      ReasonCode.VALIDATE(Code,LibraryUtility.GenerateRandomCode(ReasonCode.FIELDNO(Code),DATABASE::"Reason Code"));
      ReasonCode.VALIDATE(Description,ReasonCode.Code);  // Validating Code as Description because value is not important.
      ReasonCode.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136110 to show one way of using this function.

      // Covers document number TC0115 - refer to TFS ID 21727.
      // 1. Input Use Contract Cancel Reason as TRUE on Service Management Setup.
      // 2. Create Service Contract - Service Contract Header with Cancel Reason Code, Service Item, Service Contract Line.
      // 3. Check that the application allows the Contract to be cancelled if Cancel Reason Code is not blank.

      // Setup: Input Use Contract Cancel Reason as TRUE on Service Management Setup. Create Service Contract - Service Contract
      // Header, Service Item, Service Contract Line. Create a new Reason Code and enter it in the field Cancel Reason Code.
      Initialize;
      SetupServiceMgtCntrctCancelRsn(TRUE);
      LibraryService.CreateServiceContractHeader(ServiceContractHeader,ServiceContractHeader."Contract Type"::Contract,'');
      LibraryService.CreateServiceItem(ServiceItem,ServiceContractHeader."Customer No.");
      LibraryService.CreateServiceContractLine(ServiceContractLine,ServiceContractHeader,ServiceItem."No.");
      LibraryService.CreateReasonCode(ReasonCode);
      ServiceContractHeader.VALIDATE("Cancel Reason Code",ReasonCode.Code);

      // Exercise: Change the Status to Canceled.
      ServiceContractHeader.VALIDATE(Status,ServiceContractHeader.Status::Canceled);
      ServiceContractHeader.MODIFY(TRUE);

      // Verify: Check that the application allows the Contract to be cancelled if Cancel Reason Code is not blank.
      ServiceContractHeader.GET(ServiceContractHeader."Contract Type",ServiceContractHeader."Contract No.");
      ServiceContractHeader.TESTFIELD("Change Status",ServiceContractHeader."Change Status"::Locked);
Member of Lib.Library - Service


CreateRepairStatus@46 Method

The procedure CreateRepairStatus is available in codeunit 131902.

Syntax

CreateRepairStatus@46(
    VAR RepairStatus@1001 : Record 5927 RepairStatus //Reference parameter of type Record
);

Parameters

RepairStatus
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Repair, Status.

For a clarification about how this function works, refer to the code listed below.

      RepairStatus.INIT;
      // Use the function GenerateRandomCode to get random and unique value for the Code field.
      RepairStatus.VALIDATE(Code,LibraryUtility.GenerateRandomCode(RepairStatus.FIELDNO(Code),DATABASE::"Repair Status"));
      RepairStatus.VALIDATE(Description,RepairStatus.Code);  // Validating Code as Description because value is not important.
      RepairStatus.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136101 to show one way of using this function.

      RepairStatus.SETRANGE(Finished,TRUE);
      IF NOT RepairStatus.FINDFIRST THEN BEGIN
        LibraryService.CreateRepairStatus(RepairStatus);
        RepairStatus.VALIDATE(Finished,TRUE);
        RepairStatus.MODIFY(TRUE);
      END;
Member of Lib.Library - Service


CreateResolutionCode@85 Method

The procedure CreateResolutionCode is available in codeunit 131902.

Syntax

CreateResolutionCode@85(
    VAR ResolutionCode@1001 : Record 5919 ResolutionCode //Reference parameter of type Record
);

Parameters

ResolutionCode
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Resolution, Code.

For a clarification about how this function works, refer to the code listed below.

      ResolutionCode.INIT;
      // Use the function GenerateRandomCode to get random and unique value for the Code field.
      ResolutionCode.VALIDATE(Code,LibraryUtility.GenerateRandomCode(ResolutionCode.FIELDNO(Code),DATABASE::"Resolution Code"));
      ResolutionCode.VALIDATE(Description,ResolutionCode.Code);  // Validating Code as Description because value is not important.
      ResolutionCode.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136110 to show one way of using this function.

      // Test fault / resolution code relationship in a Service Order using Fault Reporting Level of Fault.

      // 1. Setup: Create Resolution Code, Fault Code, set Fault Reporting Level and create a Service Order.
      Initialize;
      ServiceMgtSetup.GET;
      LibrarySales.SetStockoutWarning(FALSE);
      LibraryService.CreateResolutionCode(ResolutionCode);
      DefaultFaultReportingLevel := ServiceMgtSetup."Fault Reporting Level";
      SetupServiceFaultReporting(ServiceMgtSetup,ServiceMgtSetup."Fault Reporting Level"::Fault);
      LibraryService.CreateFaultCode(FaultCode,'','');

      No := LibraryService.CreateServiceOrderHeaderUsingPage;
      CreateServiceItemLine(FaultCode,No,ResolutionCode.Code);
      InsertFaultReasonCode(No);
      OpenServiceItemLine(No);

      // 2. Exercise: Insert fault / resolution code relationship.
      InsertFaultResolutionRelation;

      // 3. Verify: Verify that the Fault Reason Code inserted on Service Item Line matches with value on Service Line.
      // Verify that the values on the fault / resolution code relationship page matches with values inserted.
      VerifyFaultReasonCode(No);
      VerifyFaultResolutionRelation(FaultCode,No);

      // 4. Tear Down: Restore the Fault Reporting Level to it's original value.
      SetupServiceFaultReporting(ServiceMgtSetup,DefaultFaultReportingLevel);
Member of Lib.Library - Service


CreateResponsibilityCenter@49 Method

The procedure CreateResponsibilityCenter is available in codeunit 131902.

Syntax

CreateResponsibilityCenter@49(
    VAR ResponsibilityCenter@1000 : Record 5714 ResponsibilityCenter //Reference parameter of type Record
);

Parameters

ResponsibilityCenter
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Responsibility, Center.

For a clarification about how this function works, refer to the code listed below.

      ResponsibilityCenter.INIT;
      ResponsibilityCenter.VALIDATE(
        Code,LibraryUtility.GenerateRandomCode(ResponsibilityCenter.FIELDNO(Code),DATABASE::"Responsibility Center"));
      ResponsibilityCenter.VALIDATE(Name,ResponsibilityCenter.Code);  // Validating Code as Name because value is not important.
      ResponsibilityCenter.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134331 to show one way of using this function.

      // [FEATURE] [Responsibility Center] [Archive]
      // [SCENARIO 375976] Purchase Order Archive shows entries depending on User's Responsibility Center
      Initialize;

      // [GIVEN] Responsibility Center "A" and "B"
      LibraryTimeSheet.CreateUserSetup(UserSetup,TRUE);
      OldPurchRespCtrFilter := UpdateUserSetupPurchRespCtrFilter(UserSetup,'');
      LibraryService.CreateResponsibilityCenter(ResponsibilityCenter[1]);
      LibraryService.CreateResponsibilityCenter(ResponsibilityCenter[2]);

      // [GIVEN] Archived Purchase Order for Responsibility Center "A"
      CreateAndArchivePurchOrderWithRespCenter(
        VendorNo[1],ResponsibilityCenter[1].Code);

      // [GIVEN] Archived Purchase Order for Responsibility Center "B"
      CreateAndArchivePurchOrderWithRespCenter(
        VendorNo[2],ResponsibilityCenter[2].Code);

      // [GIVEN] User is assigned to Responsibility Center "A"
      UpdateUserSetupPurchRespCtrFilter(UserSetup,ResponsibilityCenter[1].Code);

      // [WHEN] Purchase Order Archive page is opened
      PurchOrderArchives.OPENVIEW;

      // [THEN] Only entries for Responsibility Center "A" are shown
      PurchOrderArchives."Buy-from Vendor No.".ASSERTEQUALS(VendorNo[1]);
      Assert.IsFalse(PurchOrderArchives.NEXT,PurchOrderArchiveRespCenterErr);

      UpdateUserSetupPurchRespCtrFilter(UserSetup,OldPurchRespCtrFilter);
Member of Lib.Library - Service


CreateServiceCommentLine@22 Method

The procedure CreateServiceCommentLine is available in codeunit 131902.

Syntax

CreateServiceCommentLine@22(
    VAR ServiceCommentLine@1000 : Record 5906 ServiceCommentLine, //Reference parameter of type Record
    TableName@1001 : Option TableName, //Input parameter of type Option
    TableSubtype@1002 : Option TableSubtype, //Input parameter of type Option
    No@1003 : Code[20] No, //Input parameter of type Code
    Type@1004 : Option Type, //Input parameter of type Option
    TableLineNo@1005 : Integer TableLineNo //Input parameter of type Integer
);

Parameters

ServiceCommentLine
Reference parameter of type Record
TableName
Input parameter of type Option
TableSubtype
Input parameter of type Option
No
Input parameter of type Code
Type
Input parameter of type Option
TableLineNo
Input parameter of type Integer

Remarks

The relevant search keywords are: Create, Service, Comment, Line.

For a clarification about how this function works, refer to the code listed below.

      ServiceCommentLine.INIT;
      ServiceCommentLine.VALIDATE("Table Name",TableName);
      ServiceCommentLine.VALIDATE("Table Subtype",TableSubtype);
      ServiceCommentLine.VALIDATE("No.",No);
      ServiceCommentLine.VALIDATE(Type,Type);
      ServiceCommentLine.VALIDATE("Table Line No.",TableLineNo);
      RecRef.GETTABLE(ServiceCommentLine);
      ServiceCommentLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,ServiceCommentLine.FIELDNO("Line No.")));
      ServiceCommentLine.INSERT(TRUE);
      // Validate Comment as primary key to enable user to distinguish between comments because value is not important.
      ServiceCommentLine.VALIDATE(
        Comment,FORMAT(ServiceCommentLine."Table Name") + FORMAT(ServiceCommentLine."Table Subtype") + ServiceCommentLine."No." +
        FORMAT(ServiceCommentLine.Type) + FORMAT(ServiceCommentLine."Table Line No.") + FORMAT(ServiceCommentLine."Line No."));
      ServiceCommentLine.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - Service


CreateServiceContractAcctGrp@7 Method

The procedure CreateServiceContractAcctGrp is available in codeunit 131902.

Syntax

CreateServiceContractAcctGrp@7(
    VAR ServiceContractAccountGroup@1000 : Record 5973 ServiceContractAccountGroup //Reference parameter of type Record
);

Parameters

ServiceContractAccountGroup
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Service, Contract, Acct, Grp.

For a clarification about how this function works, refer to the code listed below.

      // Create Service Contract Account Group.
      ServiceContractAccountGroup.INIT;
      // Use the function GenerateRandomCode to get random and unique value for the Code field.
      ServiceContractAccountGroup.VALIDATE(
        Code,LibraryUtility.GenerateRandomCode(ServiceContractAccountGroup.FIELDNO(Code),DATABASE::"Service Contract Account Group"));
      ServiceContractAccountGroup.INSERT(TRUE);

      // Input Accounts as they are mandatory.
      ServiceContractAccountGroup.VALIDATE("Non-Prepaid Contract Acc.",LibraryERM.CreateGLAccountWithSalesSetup);
      ServiceContractAccountGroup.VALIDATE("Prepaid Contract Acc.",LibraryERM.CreateGLAccountWithSalesSetup);
      ServiceContractAccountGroup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 136101 to show one way of using this function.

      // Covers document number TC0117 - refer to TFS ID 21728.
      // [SCENARIO 21728] Test error occurs on Signing Service Contract with "Contract Rsp. Time Mandatory" True on Service Management Setup.

      // [GIVEN] Set "Contract Rsp. Time Mandatory" field True on Service Management Setup, Create and Update Response Time on Service Item.
      Initialize;
      ServiceMgtSetup.GET;
      ServiceMgtSetup.VALIDATE("Contract Rsp. Time Mandatory",TRUE);
      ServiceMgtSetup.MODIFY(TRUE);
      LibraryService.CreateServiceItem(ServiceItem,'');
      ServiceItem.VALIDATE("Response Time (Hours)",0);  // Use 0 to blank Response Time (Hours).
      ServiceItem.MODIFY(TRUE);
      LibraryService.CreateServiceContractAcctGrp(ServiceContractAccountGroup);

      // [WHEN] Create Service Contract Quote.
      LibraryService.CreateServiceContractHeader(
        ServiceContractHeader,ServiceContractHeader."Contract Type"::Quote,ServiceItem."Customer No.");
      ServiceContractHeader.VALIDATE("Serv. Contract Acc. Gr. Code",ServiceContractAccountGroup.Code);
      ServiceContractHeader.MODIFY(TRUE);

      LibraryService.CreateServiceContractLine(ServiceContractLine,ServiceContractHeader,ServiceItem."No.");
      ServiceContractLine.VALIDATE("Line Value",LibraryRandom.RandInt(100));  // Use Random to select Random Line Value.
      ServiceContractLine.MODIFY(TRUE);
      UpdateServiceContract(ServiceContractHeader);

      // [THEN] Verify that the Service Contract Quote shows "Contract Response Time" Mandatory error when we Make Contract from Quote.
      ASSERTERROR SignServContractDoc.SignContractQuote(ServiceContractHeader);
      Assert.AreEqual(
        STRSUBSTNO(
          RespTimeServiceTierTxt,ServiceContractLine."Contract Type",
          ServiceContractLine."Contract No.",ServiceContractLine."Line No."),
        ConvertMessage(GETLASTERRORTEXT),STRSUBSTNO(UnknownErr,GETLASTERRORTEXT));

      // 4. Teardown: Rollback "Contract Rsp. Time Mandatory" field as false on Service Management Setup.
      ServiceMgtSetup.VALIDATE("Contract Rsp. Time Mandatory",FALSE);
      ServiceMgtSetup.MODIFY(TRUE);
Member of Lib.Library - Service


CreateServiceContractHeader@1 Method

The procedure CreateServiceContractHeader is available in codeunit 131902.

Syntax

CreateServiceContractHeader@1(
    VAR ServiceContractHeader@1000 : Record 5965 ServiceContractHeader, //Reference parameter of type Record
    ContractType@1001 : Option ContractType, //Input parameter of type Option
    CustomerNo@1002 : Code[20] CustomerNo //Input parameter of type Code
);

Parameters

ServiceContractHeader
Reference parameter of type Record
ContractType
Input parameter of type Option
CustomerNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Service, Contract, Header.

For a clarification about how this function works, refer to the code listed below.

      ServiceContractHeader.INIT;
      ServiceContractHeader.VALIDATE("Contract Type",ContractType);
      ServiceContractHeader.INSERT(TRUE);
      IF CustomerNo = '' THEN
        CustomerNo := LibrarySales.CreateCustomerNo;
      ServiceContractHeader.VALIDATE("Customer No.",CustomerNo);
      // Validate one month as the default value of the Service Period.
      EVALUATE(ServiceContractHeader."Service Period",ServicePeriodOneMonth);
      // Validate default value of Service Contract Acc. Gr. Code. This field is a mandatory field for signing Contract.
      CreateServiceContractAcctGrp(ServiceContractAccountGroup);
      ServiceContractHeader.VALIDATE("Serv. Contract Acc. Gr. Code",ServiceContractAccountGroup.Code);
      ServiceContractHeader.VALIDATE("Your Reference",ServiceContractHeader."Customer No."); // Value is not important.
      UpdatePaymentChannelContract(ServiceContractHeader);
      ServiceContractHeader.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 136100 to show one way of using this function.

      // [FEATURE] [UT]
      // [SCENARIO 375949] Amount Per Period should be updated after adding Service Contract Line with Expiration Date before the end of contract

      Initialize;
      // [GIVEN] Service Contract with "Invoice Period" = Year, "Next Invoice Date Date" = 01/02, "Expiration Date" = 30/11
      LibrarySales.CreateCustomer(Customer);
      LibraryService.CreateServiceContractHeader(
        ServContractHeader,ServContractHeader."Contract Type"::Contract,Customer."No.");
      ServContractHeader.VALIDATE("Invoice Period",ServContractHeader."Invoice Period"::Year);
      ServContractHeader.VALIDATE("Expiration Date",CALCDATE('<CY-1M>',ServContractHeader."Next Invoice Date"));
      ServContractHeader.MODIFY(TRUE);

      // [WHEN] Create Service Contract Line with "Line Amount" = 1200
      LineAmount := CreateServiceContractLine(ServContractHeader,CreateServiceItem(Customer."No."));

      // [THEN] "Amount Per Period" in Service Contract = 1000
      ServContractHeader.FIND;
      ServContractHeader.TESTFIELD("Amount per Period",
        ROUND(LineAmount / 12 *
          ServContractMgt.NoOfMonthsAndMPartsInPeriod(ServContractHeader."Next Invoice Date",ServContractHeader."Expiration Date")));
Member of Lib.Library - Service


CreateServiceContractLine@6 Method

The procedure CreateServiceContractLine is available in codeunit 131902.

Syntax

CreateServiceContractLine@6(
    VAR ServiceContractLine@1000 : Record 5964 ServiceContractLine, //Reference parameter of type Record
    ServiceContractHeader@1001 : Record 5965 ServiceContractHeader, //Input parameter of type Record
    ServiceItemNo@1003 : Code[20] ServiceItemNo //Input parameter of type Code
);

Parameters

ServiceContractLine
Reference parameter of type Record
ServiceContractHeader
Input parameter of type Record
ServiceItemNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Service, Contract, Line.

For a clarification about how this function works, refer to the code listed below.

      ServiceContractLine.INIT;
      ServiceContractLine.VALIDATE("Contract Type",ServiceContractHeader."Contract Type");
      ServiceContractLine.VALIDATE("Contract No.",ServiceContractHeader."Contract No.");
      RecRef.GETTABLE(ServiceContractLine);
      // Use the function GetLastLineNo to get the value of the Line No. field.
      ServiceContractLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,ServiceContractLine.FIELDNO("Line No.")));
      ServiceContractLine.VALIDATE("Customer No.",ServiceContractHeader."Customer No.");
      ServiceContractLine.VALIDATE("Service Item No.",ServiceItemNo);
      ServiceContractLine.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136101 to show one way of using this function.

      // Covers document number TC0117 - refer to TFS ID 21728.
      // [SCENARIO 21728] Test error occurs on Signing Service Contract with "Contract Rsp. Time Mandatory" True on Service Management Setup.

      // [GIVEN] Set "Contract Rsp. Time Mandatory" field True on Service Management Setup, Create and Update Response Time on Service Item.
      Initialize;
      ServiceMgtSetup.GET;
      ServiceMgtSetup.VALIDATE("Contract Rsp. Time Mandatory",TRUE);
      ServiceMgtSetup.MODIFY(TRUE);
      LibraryService.CreateServiceItem(ServiceItem,'');
      ServiceItem.VALIDATE("Response Time (Hours)",0);  // Use 0 to blank Response Time (Hours).
      ServiceItem.MODIFY(TRUE);
      LibraryService.CreateServiceContractAcctGrp(ServiceContractAccountGroup);

      // [WHEN] Create Service Contract Quote.
      LibraryService.CreateServiceContractHeader(
        ServiceContractHeader,ServiceContractHeader."Contract Type"::Quote,ServiceItem."Customer No.");
      ServiceContractHeader.VALIDATE("Serv. Contract Acc. Gr. Code",ServiceContractAccountGroup.Code);
      ServiceContractHeader.MODIFY(TRUE);

      LibraryService.CreateServiceContractLine(ServiceContractLine,ServiceContractHeader,ServiceItem."No.");
      ServiceContractLine.VALIDATE("Line Value",LibraryRandom.RandInt(100));  // Use Random to select Random Line Value.
      ServiceContractLine.MODIFY(TRUE);
      UpdateServiceContract(ServiceContractHeader);

      // [THEN] Verify that the Service Contract Quote shows "Contract Response Time" Mandatory error when we Make Contract from Quote.
      ASSERTERROR SignServContractDoc.SignContractQuote(ServiceContractHeader);
      Assert.AreEqual(
        STRSUBSTNO(
          RespTimeServiceTierTxt,ServiceContractLine."Contract Type",
          ServiceContractLine."Contract No.",ServiceContractLine."Line No."),
        ConvertMessage(GETLASTERRORTEXT),STRSUBSTNO(UnknownErr,GETLASTERRORTEXT));

      // 4. Teardown: Rollback "Contract Rsp. Time Mandatory" field as false on Service Management Setup.
      ServiceMgtSetup.VALIDATE("Contract Rsp. Time Mandatory",FALSE);
      ServiceMgtSetup.MODIFY(TRUE);
Member of Lib.Library - Service


CreateServiceContractTemplate@14 Method

The procedure CreateServiceContractTemplate is available in codeunit 131902.

Syntax

CreateServiceContractTemplate@14(
    VAR ServiceContractTemplate@1000 : Record 5968 ServiceContractTemplate, //Reference parameter of type Record
    DefaultServicePeriod@1001 : DateFormula DefaultServicePeriod //Input parameter of type DateFormula
);

Parameters

ServiceContractTemplate
Reference parameter of type Record
DefaultServicePeriod
Input parameter of type DateFormula

Remarks

The relevant search keywords are: Create, Service, Contract, Template.

For a clarification about how this function works, refer to the code listed below.

      FindContractAccountGroup(ServiceContractAccountGroup);

      ServiceContractTemplate.INIT;
      ServiceContractTemplate.VALIDATE("Default Service Period",DefaultServicePeriod);
      // Service Contract Account Group is required for signing Contracts.
      ServiceContractTemplate.VALIDATE("Serv. Contract Acc. Gr. Code",ServiceContractAccountGroup.Code);
      ServiceContractTemplate.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136102 to show one way of using this function.

      EVALUATE(DefaultServicePeriod,'<3M>');
      LibraryService.CreateServiceContractTemplate(ServiceContractTemplate,DefaultServicePeriod);
      EVALUATE(ServiceContractTemplate."Price Update Period",'<6M>');
      ServiceContractTemplate.VALIDATE(Prepaid,TRUE);
      ServiceContractTemplate.VALIDATE("Combine Invoices",TRUE);
      ServiceContractTemplate.VALIDATE("Contract Lines on Invoice",TRUE);
      ServiceContractTemplate.MODIFY(TRUE);
Member of Lib.Library - Service


CreateServiceCost@31 Method

The procedure CreateServiceCost is available in codeunit 131902.

Syntax

CreateServiceCost@31(
    VAR ServiceCost@1000 : Record 5905 ServiceCost //Reference parameter of type Record
);

Parameters

ServiceCost
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Service, Cost.

For a clarification about how this function works, refer to the code listed below.

      ServiceCost.INIT;
      // Use the function GenerateRandomCode to get random and unique value for the Code field.
      ServiceCost.VALIDATE(Code,LibraryUtility.GenerateRandomCode(ServiceCost.FIELDNO(Code),DATABASE::"Service Cost"));
      ServiceCost.VALIDATE(Description,ServiceCost.Code);  // Validating Code as Description because value is not important.
      ServiceCost.VALIDATE("Account No.",LibraryERM.CreateGLAccountWithSalesSetup);
      ServiceCost.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136101 to show one way of using this function.

      LibraryERM.CreateGenProdPostingGroup(GenProdPostingGroup);
      LibraryERM.CreateGLAccount(GLAccount);
      GLAccount.VALIDATE("Gen. Prod. Posting Group",GenProdPostingGroup.Code);
      GLAccount.VALIDATE("VAT Prod. Posting Group",VATProdPostingGroupCode);
      GLAccount.MODIFY(TRUE);
      LibraryService.CreateServiceCost(ServiceCost);
      WITH ServiceCost DO BEGIN
        VALIDATE("Cost Type","Cost Type"::Travel);
        VALIDATE("Account No.",GLAccount."No.");
        VALIDATE("Service Zone Code",ServiceZoneCode);
        VALIDATE("Default Quantity",LibraryRandom.RandDecInRange(10,100,2));
        MODIFY(TRUE);
      END;
Member of Lib.Library - Service


CreateServiceCreditMemoHeaderUsingPage@90 Method

The procedure CreateServiceCreditMemoHeaderUsingPage is available in codeunit 131902.

Syntax

CreateServiceCreditMemoHeaderUsingPage@90(
      //param element not supplied
);

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Service, Credit, Memo, Header, Using, Page.

For a clarification about how this function works, refer to the code listed below.

      ServiceCreditMemo.OPENNEW;
      ServiceCreditMemo."Customer No.".ACTIVATE;
      ServiceCreditMemoNo := ServiceCreditMemo."No.".VALUE;
      ServiceCreditMemo.OK.INVOKE;

Example

The below example is extracted from the test automation codeunit 136104 to show one way of using this function.

      // [SCENARIO 143443] Create Service Credit Memo, post it and verify Item Ledger Entry.

      // [GIVEN] Find Item, create Service Contract, sign it and create Customer without Price Including VAT.
      Initialize;
      LibraryInventory.CreateItem(Item);
      CreateServiceContract(ServiceContractHeader,ServiceContractLine);
      SignServContractDoc.SignContract(ServiceContractHeader);
      CustomerNo := CustomerWithPriceIncludingVAT(FALSE);

      // [WHEN] Create Service Credit Memo with Contract No and post it.
      No := LibraryService.CreateServiceCreditMemoHeaderUsingPage;
      CreateCreditMemoLine(No,CustomerNo,ServiceLine.Type::Item,Item."No.");
      InsertContractNoOnServiceLine(No,ServiceContractHeader."Contract No.");
      ServiceCreditMemoOpenEdit(ServiceCreditMemo,No);
      Quantity := ServiceCreditMemo.ServLines.Quantity.ASDECIMAL;
      ServiceCreditMemo.Post.INVOKE;

      // [THEN] Verify the Item Ledger Entry for the posted Service Credit Memo.
      VerifyServiceCreditMemoItemLedgerEntry(No,Item."No.",Quantity);
Member of Lib.Library - Service


CreateServiceHeader@4 Method

The procedure CreateServiceHeader is available in codeunit 131902.

Syntax

CreateServiceHeader@4(
    VAR ServiceHeader@1000 : Record 5900 ServiceHeader, //Reference parameter of type Record
    DocumentType@1001 : Option DocumentType, //Input parameter of type Option
    CustomerNo@1002 : Code[20] CustomerNo //Input parameter of type Code
);

Parameters

ServiceHeader
Reference parameter of type Record
DocumentType
Input parameter of type Option
CustomerNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Service, Header.

For a clarification about how this function works, refer to the code listed below.

      ServiceHeader.INIT;
      ServiceHeader.VALIDATE("Document Type",DocumentType);
      ServiceHeader.INSERT(TRUE);
      IF CustomerNo = '' THEN
        CustomerNo := LibrarySales.CreateCustomerNo;
      ServiceHeader.VALIDATE("Customer No.",CustomerNo);
      ServiceHeader.VALIDATE("Your Reference",ServiceHeader."Customer No.");
      // Input mandatory fields for local builds.
      IF ServiceHeader."Payment Terms Code" = '' THEN BEGIN
        LibraryERM.FindPaymentTerms(PaymentTerms);
        ServiceHeader.VALIDATE("Payment Terms Code",PaymentTerms.Code);
      END;
      IF ServiceHeader."Payment Method Code" = '' THEN BEGIN
        LibraryERM.FindPaymentMethod(PaymentMethod);
        ServiceHeader.VALIDATE("Payment Method Code",PaymentMethod.Code);
      END;
      UpdatePaymentChannel(ServiceHeader);
      SetCorrDocNoService(ServiceHeader);
      ServiceHeader.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134028 to show one way of using this function.

      LibraryService.CreateServiceHeader(
        ServiceHeader,ServiceHeader."Document Type"::Invoice,CreateCustomer);
      LibraryService.CreateServiceLineWithQuantity(
        ServiceLine,ServiceHeader,ServiceLine.Type::Item,CreateItem,LibraryRandom.RandInt(10));
Member of Lib.Library - Service


CreateServiceHour@23 Method

The procedure CreateServiceHour is available in codeunit 131902.

Syntax

CreateServiceHour@23(
    VAR ServiceHour@1000 : Record 5910 ServiceHour, //Reference parameter of type Record
    ServiceContractHeader@1001 : Record 5965 ServiceContractHeader, //Input parameter of type Record
    Day@1002 : Option Day //Input parameter of type Option
);

Parameters

ServiceHour
Reference parameter of type Record
ServiceContractHeader
Input parameter of type Record
Day
Input parameter of type Option

Remarks

The relevant search keywords are: Create, Service, Hour.

For a clarification about how this function works, refer to the code listed below.

      ServiceHour.INIT;
      ServiceHour.VALIDATE("Service Contract Type",ServiceContractHeader."Contract Type" + 1);
      ServiceHour.VALIDATE("Service Contract No.",ServiceContractHeader."Contract No.");
      ServiceHour.VALIDATE("Starting Date",ServiceContractHeader."Starting Date");
      // Use a random Starting Time that does not cause Ending Time to fall in the next day.
      ServiceHour.VALIDATE("Starting Time",000000T + RANDOM(LibraryUtility.ConvertHoursToMilliSec(12)));
      // Use a random Ending Time that does not fall in the next day.
      ServiceHour.VALIDATE("Ending Time",ServiceHour."Starting Time" + RANDOM(LibraryUtility.ConvertHoursToMilliSec(12)) - 1);
      ServiceHour.VALIDATE(Day,Day);
      ServiceHour.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136102 to show one way of using this function.

      // Covers document number TC0074 - refer to TFS ID 21730.
      // [SCENARIO] The Test Case checks Status and Change Status field is changed after Sign Contract.

      // 1. Setup: Create Service Contract, Service Hours, Service Discount and Sign Service Contract.
      Initialize;
      CreateServiceContract(ServiceContractHeader,ServiceContractLine,ServiceContractHeader."Contract Type"::Contract);
      CreateServiceContractLineItem(ServiceContractHeader);
      ModifyServiceContractHeader(ServiceContractHeader,ServiceContractHeader."Service Period");

      LibraryService.CreateServiceHour(ServiceHour,ServiceContractHeader,ServiceHour.Day::Monday);

      LibraryService.FindServiceItemGroup(ServiceItemGroup);
      LibraryService.CreateContractServiceDiscount(
        ContractServiceDiscount,ServiceContractHeader,ContractServiceDiscount.Type::"Service Item Group",ServiceItemGroup.Code);

      // 2. Exercise: Sign Service Contract.
      SignServContractDoc.SignContract(ServiceContractHeader);

      // 3. Verify: Check that Status and Change Status field is changed after Sign Contract.
      ServiceContractHeader.GET(ServiceContractHeader."Contract Type"::Contract,ServiceContractHeader."Contract No.");
      ServiceContractHeader.TESTFIELD(Status,ServiceContractHeader.Status::Signed);
      ServiceContractHeader.TESTFIELD("Change Status",ServiceContractHeader."Change Status"::Locked);
Member of Lib.Library - Service


CreateServiceItem@2 Method

The procedure CreateServiceItem is available in codeunit 131902.

Syntax

CreateServiceItem@2(
    VAR ServiceItem@1000 : Record 5940 ServiceItem, //Reference parameter of type Record
    CustomerNo@1001 : Code[20] CustomerNo //Input parameter of type Code
);

Parameters

ServiceItem
Reference parameter of type Record
CustomerNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Service, Item.

For a clarification about how this function works, refer to the code listed below.

      ServiceItem.INIT;
      ServiceItem.INSERT(TRUE);
      IF CustomerNo = '' THEN
        CustomerNo := LibrarySales.CreateCustomerNo;
      ServiceItem.VALIDATE("Customer No.",CustomerNo);
      ServiceItem.VALIDATE(Description,ServiceItem."No.");  // Validating No. as Description because value is not important.
      ServiceItem.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134030 to show one way of using this function.

      // [SCENARIO 145131] Check that value of EU Service Field is TRUE after Posting Service Order.

      // [GIVEN] Setup: Update VAT Posting Setup, Create Service Order, Service Item, Service Item Line for the Customer.
      Initialize;
      EUService := SetupAndCreateServiceHeader(ServiceHeader,VATPostingSetup,ServiceHeader."Document Type"::Order);
      LibraryService.CreateServiceItem(ServiceItem,ServiceHeader."Customer No.");
      LibraryService.CreateServiceItemLine(ServiceItemLine,ServiceHeader,ServiceItem."No.");

      // [WHEN] Post Service Order
      // [THEN] Verify VAT Entries. Roll back VAT Posting Setup.
      PostAndVerifyVATEntry(ServiceHeader,VATPostingSetup,EUService,ServiceItemLine."Line No.");
Member of Lib.Library - Service


CreateServiceItemComponent@39 Method

The procedure CreateServiceItemComponent is available in codeunit 131902.

Syntax

CreateServiceItemComponent@39(
    VAR ServiceItemComponent@1004 : Record 5941 ServiceItemComponent, //Reference parameter of type Record
    ServiceItemNo@1000 : Code[20] ServiceItemNo, //Input parameter of type Code
    Type@1001 : Option Type, //Input parameter of type Option
    No@1002 : Code[20] No //Input parameter of type Code
);

Parameters

ServiceItemComponent
Reference parameter of type Record
ServiceItemNo
Input parameter of type Code
Type
Input parameter of type Option
No
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Service, Item, Component.

For a clarification about how this function works, refer to the code listed below.

      ServiceItemComponent.INIT;
      ServiceItemComponent.VALIDATE(Active,TRUE);
      ServiceItemComponent.VALIDATE("Parent Service Item No.",ServiceItemNo);
      RecRef.GETTABLE(ServiceItemComponent);
      ServiceItemComponent.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,ServiceItemComponent.FIELDNO("Line No.")));
      ServiceItemComponent.VALIDATE(Type,Type);
      ServiceItemComponent.VALIDATE("No.",No);
      ServiceItemComponent.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136101 to show one way of using this function.

      // 1. Setup: Find Customer and Item,Create Service Item and Service Item Component.
      Initialize;
      LibraryInventory.CreateItem(Item);
      CreateServiceItem(ServiceItem,LibrarySales.CreateCustomerNo,Item."No.");
      LibraryService.CreateServiceItemComponent(ServiceItemComponent,ServiceItem."No.",ServiceItemComponent.Type::Item,Item."No.");

      // 2. Exercise: Create and Post Service Order.
      // Set StringMenuOption For String Menu Handler.
      LibraryVariableStorage.Enqueue(StringMenuOption);
      LibraryVariableStorage.Enqueue(ServiceItem."No.");
      DocumentNo := CreateAndPostServiceOrder(ServiceItem);

      // 3. Verify: Verify Service Item Log Entries.
      // The value 5 and 16 is the event number for Service item component and Added to service order.
      VerifyServiceItemLogEntry(DocumentNo,5);
      VerifyServiceItemLogEntry(DocumentNo,16);
Member of Lib.Library - Service


CreateServiceItemGroup@9 Method

The procedure CreateServiceItemGroup is available in codeunit 131902.

Syntax

CreateServiceItemGroup@9(
    VAR ServiceItemGroup@1000 : Record 5904 ServiceItemGroup //Reference parameter of type Record
);

Parameters

ServiceItemGroup
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Service, Item, Group.

For a clarification about how this function works, refer to the code listed below.

      ServiceItemGroup.INIT;
      // Use the function GenerateRandomCode to get random and unique value for the Code field.
      ServiceItemGroup.VALIDATE(Code,LibraryUtility.GenerateRandomCode(ServiceItemGroup.FIELDNO(Code),DATABASE::"Service Item Group"));
      ServiceItemGroup.VALIDATE(Description,ServiceItemGroup.Code);  // Validating Code as Description because value is not important.
      ServiceItemGroup.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136103 to show one way of using this function.

      LibraryService.CreateServiceItemGroup(ServiceItemGroup);
      LibraryResource.CreateResourceSkill(
        ResourceSkill,ResourceSkill.Type::"Service Item Group",ServiceItemGroup.Code,CreateSkillCode);
      EXIT(ServiceItemGroup.Code);
Member of Lib.Library - Service


CreateServiceItemLine@5 Method

The procedure CreateServiceItemLine is available in codeunit 131902.

Syntax

CreateServiceItemLine@5(
    VAR ServiceItemLine@1000 : Record 5901 ServiceItemLine, //Reference parameter of type Record
    ServiceHeader@1002 : Record 5900 ServiceHeader, //Input parameter of type Record
    ServiceItemNo@1003 : Code[20] ServiceItemNo //Input parameter of type Code
);

Parameters

ServiceItemLine
Reference parameter of type Record
ServiceHeader
Input parameter of type Record
ServiceItemNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Service, Item, Line.

For a clarification about how this function works, refer to the code listed below.

      ServiceItemLine.INIT;
      ServiceItemLine.VALIDATE("Document Type",ServiceHeader."Document Type");
      ServiceItemLine.VALIDATE("Document No.",ServiceHeader."No.");
      RecRef.GETTABLE(ServiceItemLine);
      // Use the function GetLastLineNo to get the value of the Line No. field.
      ServiceItemLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,ServiceItemLine.FIELDNO("Line No.")));
      ServiceItemLine.INSERT(TRUE);
      ServiceItemLine.VALIDATE("Service Item No.",ServiceItemNo);
      ServiceItemLine.VALIDATE(
        Description,FORMAT(ServiceItemLine."Document Type") + ServiceItemLine."Document No." + FORMAT(ServiceItemLine."Line No."));
      ServiceItemLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134030 to show one way of using this function.

      // [SCENARIO 145131] Check that value of EU Service Field is TRUE after Posting Service Order.

      // [GIVEN] Setup: Update VAT Posting Setup, Create Service Order, Service Item, Service Item Line for the Customer.
      Initialize;
      EUService := SetupAndCreateServiceHeader(ServiceHeader,VATPostingSetup,ServiceHeader."Document Type"::Order);
      LibraryService.CreateServiceItem(ServiceItem,ServiceHeader."Customer No.");
      LibraryService.CreateServiceItemLine(ServiceItemLine,ServiceHeader,ServiceItem."No.");

      // [WHEN] Post Service Order
      // [THEN] Verify VAT Entries. Roll back VAT Posting Setup.
      PostAndVerifyVATEntry(ServiceHeader,VATPostingSetup,EUService,ServiceItemLine."Line No.");
Member of Lib.Library - Service


CreateServiceLine@3 Method

The procedure CreateServiceLine is available in codeunit 131902.

Syntax

CreateServiceLine@3(
    VAR ServiceLine@1000 : Record 5902 ServiceLine, //Reference parameter of type Record
    ServiceHeader@1001 : Record 5900 ServiceHeader, //Input parameter of type Record
    Type@1003 : Option Type, //Input parameter of type Option
    No@1004 : Code[20] No //Input parameter of type Code
);

Parameters

ServiceLine
Reference parameter of type Record
ServiceHeader
Input parameter of type Record
Type
Input parameter of type Option
No
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Service, Line.

For a clarification about how this function works, refer to the code listed below.

      // Create Service Line.
      CLEAR(ServiceLine);
      ServiceLine.INIT;
      ServiceLine.VALIDATE("Document Type",ServiceHeader."Document Type");
      ServiceLine.VALIDATE("Document No.",ServiceHeader."No.");
      RecRef.GETTABLE(ServiceLine);
      IF (Type = ServiceLine.Type::Item) AND (Item.GET(No) AND Customer.GET(ServiceHeader."Customer No.")) THEN BEGIN
        VATPostingSetup.SETRANGE("VAT Prod. Posting Group",Item."VAT Prod. Posting Group");
        VATPostingSetup.SETFILTER("VAT Bus. Posting Group",Customer."VAT Bus. Posting Group");
        IF FALSE = VATPostingSetup.FINDFIRST THEN
          LibraryJob.CreateVATPostingSetup(Customer."VAT Bus. Posting Group",Item."VAT Prod. Posting Group",VATPostingSetup);
        Customer.MODIFY(TRUE);
      END;

      // Use the function GetLastLineNo to get the value of the Line No. field.
      ServiceLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,ServiceLine.FIELDNO("Line No.")));
      ServiceLine.INSERT(TRUE);
      ServiceLine.VALIDATE(Type,Type);
      CASE Type OF
        ServiceLine.Type::Item:
          IF No = '' THEN
            No := LibraryInventory.CreateItemNo;
        ServiceLine.Type::Resource:
          IF No = '' THEN
            No := LibraryResource.CreateResourceNo;
      END;
      ServiceLine.VALIDATE("No.",No);
      ServiceLine.MODIFY(TRUE);

      //Create Gen.Posting Setup
      GeneralPostingSetup.SETRANGE("Gen. Bus. Posting Group",ServiceLine."Gen. Bus. Posting Group");
      GeneralPostingSetup.SETFILTER("Gen. Prod. Posting Group",ServiceLine."Gen. Prod. Posting Group");
      IF FALSE = GeneralPostingSetup.FINDFIRST THEN
        LibraryERM.CreateGeneralPostingSetup(GeneralPostingSetup,ServiceLine."Gen. Bus. Posting Group",ServiceLine."Gen. Prod. Posting Group");

Example

The below example is extracted from the test automation codeunit 134030 to show one way of using this function.

      LibraryService.CreateServiceLine(ServiceLine,ServiceHeader,Type,No);
      UpdateServiceLine(ServiceLine,ServiceItemLineNo);
Member of Lib.Library - Service


CreateServiceLineWithQuantity@13 Method

The procedure CreateServiceLineWithQuantity is available in codeunit 131902.

Syntax

CreateServiceLineWithQuantity@13(
    VAR ServiceLine@1003 : Record 5902 ServiceLine, //Reference parameter of type Record
    ServiceHeader@1002 : Record 5900 ServiceHeader, //Input parameter of type Record
    Type@1001 : Option Type, //Input parameter of type Option
    No@1000 : Code[20] No, //Input parameter of type Code
    Quantity@1004 : Integer Quantity //Input parameter of type Integer
);

Parameters

ServiceLine
Reference parameter of type Record
ServiceHeader
Input parameter of type Record
Type
Input parameter of type Option
No
Input parameter of type Code
Quantity
Input parameter of type Integer

Remarks

The relevant search keywords are: Create, Service, Line, Quantity.

For a clarification about how this function works, refer to the code listed below.

      CreateServiceLine(ServiceLine,ServiceHeader,Type,No);
      ServiceLine.VALIDATE(Quantity,Quantity);
      ServiceLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134028 to show one way of using this function.

      LibraryService.CreateServiceHeader(
        ServiceHeader,ServiceHeader."Document Type"::Invoice,CreateCustomer);
      LibraryService.CreateServiceLineWithQuantity(
        ServiceLine,ServiceHeader,ServiceLine.Type::Item,CreateItem,LibraryRandom.RandInt(10));
Member of Lib.Library - Service


CreateServiceOrderFromReport@98 Method

The procedure CreateServiceOrderFromReport is available in codeunit 131902.

Syntax

CreateServiceOrderFromReport@98(
    ServiceContractHeader@1001 : Record 5965 ServiceContractHeader, //Input parameter of type Record
    StartDate@1005 : Date StartDate, //Input parameter of type Date
    EndDate@1006 : Date EndDate, //Input parameter of type Date
    UseRequestPage@1007 : Boolean UseRequestPage //Input parameter of type Boolean
);

Parameters

ServiceContractHeader
Input parameter of type Record
StartDate
Input parameter of type Date
EndDate
Input parameter of type Date
UseRequestPage
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, Service, Order, From, Report.

For a clarification about how this function works, refer to the code listed below.

      CreateContractServiceOrders.SETTABLEVIEW(ServiceContractHeader);
      CreateContractServiceOrders.InitializeRequest(StartDate,EndDate,0);
      CreateContractServiceOrders.USEREQUESTPAGE(UseRequestPage);
      CreateContractServiceOrders.RUNMODAL;

Example

There are no examples available.
Member of Lib.Library - Service


CreateServiceOrderHeaderUsingPage@92 Method

The procedure CreateServiceOrderHeaderUsingPage is available in codeunit 131902.

Syntax

CreateServiceOrderHeaderUsingPage@92(
      //param element not supplied
);

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Service, Order, Header, Using, Page.

For a clarification about how this function works, refer to the code listed below.

      ServiceOrder.OPENNEW;
      ServiceOrder."Customer No.".ACTIVATE;
      ServiceOrderNo := ServiceOrder."No.".VALUE;
      ServiceOrder.OK.INVOKE;

Example

The below example is extracted from the test automation codeunit 136109 to show one way of using this function.

      // 1. Setup: Create a Service Order.
      Initialize;
      LibrarySales.SetStockoutWarning(FALSE);
      LibrarySales.CreateCustomer(Customer);
      No := LibraryService.CreateServiceOrderHeaderUsingPage;
      CreateServiceItemLine(No,Customer."No.");
      OpenServiceLine(No);

      // 2. Exercise: Undo Consumption of the Service Order consumed Quantity.
      PostedServiceShipment.OPENVIEW;
      PostedServiceShipment.FILTER.SETFILTER("Order No.",No);
      ServiceShipmentHeaderNo := PostedServiceShipment."No.".VALUE;
      PostedServiceShipment.ServShipmentItemLines.ServiceShipmentLines.INVOKE;

      // 3. Verify: Verify the undone Qty Consumed through the handler.
      // VERIFY: All ledger entries generated after undo matchup
      ItemLedgerEntry.SETRANGE("Document No.",ServiceShipmentHeaderNo);
      ItemLedgerEntry.SETRANGE("Document Type",ItemLedgerEntry."Document Type"::"Service Shipment");
      ItemLedgerEntry.FINDSET;

      Quantity := 0;
      InvoicedQuantity := 0;
      ExpectedCost := 0;
      ActualCost := 0;
      REPEAT
        Quantity += ItemLedgerEntry.Quantity;
        InvoicedQuantity += ItemLedgerEntry."Invoiced Quantity";

        ItemLedgerEntry.CALCFIELDS("Cost Amount (Expected)");
        ExpectedCost += ItemLedgerEntry."Cost Amount (Expected)";

        ItemLedgerEntry.CALCFIELDS("Cost Amount (Actual)");
        ActualCost += ItemLedgerEntry."Cost Amount (Actual)";

        ItemLedgerEntry.CALCFIELDS("Cost Amount (Expected) (ACY)");
        ExpectedCostACY += ItemLedgerEntry."Cost Amount (Expected) (ACY)";

        ItemLedgerEntry.CALCFIELDS("Cost Amount (Actual) (ACY)");
        ActualCostACY += ItemLedgerEntry."Cost Amount (Actual) (ACY)";

      UNTIL ItemLedgerEntry.NEXT = 0;

      Assert.AreEqual(0,Quantity,ItemLedgerEntry.FIELDCAPTION(Quantity));
      Assert.AreEqual(0,InvoicedQuantity,ItemLedgerEntry.FIELDCAPTION("Invoiced Quantity"));
      Assert.AreEqual(0,ExpectedCost,ItemLedgerEntry.FIELDCAPTION("Cost Amount (Expected)"));
      Assert.AreEqual(0,ExpectedCostACY,ItemLedgerEntry.FIELDCAPTION("Cost Amount (Expected) (ACY)"));
      Assert.AreEqual(0,ActualCost,ItemLedgerEntry.FIELDCAPTION("Cost Amount (Actual)"));
      Assert.AreEqual(0,ActualCostACY,ItemLedgerEntry.FIELDCAPTION("Cost Amount (Actual) (ACY)"));
Member of Lib.Library - Service


CreateServiceOrderType@64 Method

The procedure CreateServiceOrderType is available in codeunit 131902.

Syntax

CreateServiceOrderType@64(
    VAR ServiceOrderType@1000 : Record 5903 ServiceOrderType //Reference parameter of type Record
);

Parameters

ServiceOrderType
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Service, Order, Type.

For a clarification about how this function works, refer to the code listed below.

      ServiceOrderType.INIT;
      ServiceOrderType.VALIDATE(Code,LibraryUtility.GenerateRandomCode(ServiceOrderType.FIELDNO(Code),DATABASE::"Service Order Type"));
      ServiceOrderType.VALIDATE(Description,ServiceOrderType.Code);  // Validating Code as Description because value is not important.
      ServiceOrderType.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136102 to show one way of using this function.

      // [SCENARIO] Test Dimension on Service Contract after updating Service Order Type on Service Contract Header.

      // 1. Setup: Create Service Order Type, Default Dimension for Service Order Type and Service Contract.
      Initialize;
      LibraryService.CreateServiceOrderType(ServiceOrderType);
      CreateDefaultDimension(DefaultDimension,ServiceOrderType.Code);
      CreateServiceContract(ServiceContractHeader,ServiceContractLine,ServiceContractHeader."Contract Type"::Contract);
      ModifyServiceContractHeader(ServiceContractHeader,ServiceContractHeader."Service Period");

      // 2. Exercise: Update Service Order Type on Service Contract Header.
      UpdateServiceOrderType(ServiceContractHeader,ServiceOrderType.Code);

      // 3. Verify: Verify Dimension on Service Contract Header.
      VerifyDimensionSetEntry(DefaultDimension,ServiceContractHeader."Dimension Set ID");
Member of Lib.Library - Service


CreateServicePriceGroup@45 Method

The procedure CreateServicePriceGroup is available in codeunit 131902.

Syntax

CreateServicePriceGroup@45(
    VAR ServicePriceGroup@1000 : Record 6080 ServicePriceGroup //Reference parameter of type Record
);

Parameters

ServicePriceGroup
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Service, Price, Group.

For a clarification about how this function works, refer to the code listed below.

      ServicePriceGroup.INIT;
      // Use the function GenerateRandomCode to get random and unique value for the Code field.
      ServicePriceGroup.VALIDATE(
        Code,LibraryUtility.GenerateRandomCode(ServicePriceGroup.FIELDNO(Code),DATABASE::"Service Price Group"));
      ServicePriceGroup.VALIDATE(Description,ServicePriceGroup.Code);  // Validating Code as Description because value is not important.
      ServicePriceGroup.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136105 to show one way of using this function.

      // Covers document number TC0127 - refer to TFS ID 21728.
      // Test Unit Price and Amount on Service Line after Service Price Adjustment.

      // 1. Setup: Create Service Order - Create Service Price Group, Service Price Adjustmnet Group, Service Price Group Setup.
      Initialize;
      LibraryService.CreateServicePriceGroup(ServicePriceGroup);
      LibraryService.CreateServPriceAdjustmentGroup(ServicePriceAdjustmentGroup);
      CreateServicePriceGroupSetup(ServicePriceAdjustmentGroup.Code,ServicePriceGroup.Code,AdjustmentType::Fixed,FALSE,FALSE);
      CreateServiceHeader(ServiceHeader);
      CreateServItemLineWithPricGrou(ServiceItemLine2,ServiceHeader,ServicePriceGroup.Code);
      CreateItem(Item);

      CreateServiceLineWithOutDisc(ServiceLine,ServiceHeader,ServiceLine.Type::Item,Item."No.",ServiceItemLine2."Line No.");
      ServiceItemLine := ServiceItemLine2;

      // 2. Exercise: Service Price Adjustment on Service Order.
      ServicePriceManagement.ShowPriceAdjustment(ServiceItemLine2);

      // 3. Verify: Verify that the Unit Price and Amount on Service Line is Amount of Service Price Group Setup of Service Price
      // Group Code on Service Item Line.
      VerifyUnitPrice(ServiceItemLine2);
Member of Lib.Library - Service


CreateServiceZone@16 Method

The procedure CreateServiceZone is available in codeunit 131902.

Syntax

CreateServiceZone@16(
    VAR ServiceZone@1000 : Record 5957 ServiceZone //Reference parameter of type Record
);

Parameters

ServiceZone
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Service, Zone.

For a clarification about how this function works, refer to the code listed below.

      ServiceZone.INIT;
      // Use the function GenerateRandomCode to get random and unique value for the Code field.
      ServiceZone.VALIDATE(Code,LibraryUtility.GenerateRandomCode(ServiceZone.FIELDNO(Code),DATABASE::"Service Zone"));
      ServiceZone.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136101 to show one way of using this function.

      CreateVATPostingSetup(VATPostingSetup);
      LibraryService.CreateServiceZone(ServiceZone);
      CreateServiceCost(ServiceCost,ServiceZone.Code,VATPostingSetup."VAT Prod. Posting Group");
      LibraryService.CreateServiceItem(
        ServiceItem,CreateCustomerWithZoneCode(ServiceZone.Code,VATPostingSetup."VAT Bus. Posting Group"));
Member of Lib.Library - Service


CreateServPriceAdjustmentGroup@57 Method

The procedure CreateServPriceAdjustmentGroup is available in codeunit 131902.

Syntax

CreateServPriceAdjustmentGroup@57(
    VAR ServicePriceAdjustmentGroup@1000 : Record 6082 ServicePriceAdjustmentGroup //Reference parameter of type Record
);

Parameters

ServicePriceAdjustmentGroup
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Serv, Price, Adjustment, Group.

For a clarification about how this function works, refer to the code listed below.

      ServicePriceAdjustmentGroup.INIT;
      ServicePriceAdjustmentGroup.VALIDATE(
        Code,LibraryUtility.GenerateRandomCode(ServicePriceAdjustmentGroup.FIELDNO(Code),DATABASE::"Service Price Adjustment Group"));
      ServicePriceAdjustmentGroup.VALIDATE(
        Description,ServicePriceAdjustmentGroup.Code);  // Validating Code as Description because value is not important.
      ServicePriceAdjustmentGroup.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136105 to show one way of using this function.

      // Covers document number TC0127 - refer to TFS ID 21728.
      // Test Unit Price and Amount on Service Line after Service Price Adjustment.

      // 1. Setup: Create Service Order - Create Service Price Group, Service Price Adjustmnet Group, Service Price Group Setup.
      Initialize;
      LibraryService.CreateServicePriceGroup(ServicePriceGroup);
      LibraryService.CreateServPriceAdjustmentGroup(ServicePriceAdjustmentGroup);
      CreateServicePriceGroupSetup(ServicePriceAdjustmentGroup.Code,ServicePriceGroup.Code,AdjustmentType::Fixed,FALSE,FALSE);
      CreateServiceHeader(ServiceHeader);
      CreateServItemLineWithPricGrou(ServiceItemLine2,ServiceHeader,ServicePriceGroup.Code);
      CreateItem(Item);

      CreateServiceLineWithOutDisc(ServiceLine,ServiceHeader,ServiceLine.Type::Item,Item."No.",ServiceItemLine2."Line No.");
      ServiceItemLine := ServiceItemLine2;

      // 2. Exercise: Service Price Adjustment on Service Order.
      ServicePriceManagement.ShowPriceAdjustment(ServiceItemLine2);

      // 3. Verify: Verify that the Unit Price and Amount on Service Line is Amount of Service Price Group Setup of Service Price
      // Group Code on Service Item Line.
      VerifyUnitPrice(ServiceItemLine2);
Member of Lib.Library - Service


CreateServPriceAdjustmntDetail@52 Method

The procedure CreateServPriceAdjustmntDetail is available in codeunit 131902.

Syntax

CreateServPriceAdjustmntDetail@52(
    VAR ServPriceAdjustmentDetail@1000 : Record 6083 ServPriceAdjustmentDetail, //Reference parameter of type Record
    ServPriceAdjmtGrCode@1001 : Code[10] ServPriceAdjmtGrCode, //Input parameter of type Code
    Type@1002 : Option Type, //Input parameter of type Option
    No@1003 : Code[20] No //Input parameter of type Code
);

Parameters

ServPriceAdjustmentDetail
Reference parameter of type Record
ServPriceAdjmtGrCode
Input parameter of type Code
Type
Input parameter of type Option
No
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Serv, Price, Adjustmnt, Detail.

For a clarification about how this function works, refer to the code listed below.

      ServPriceAdjustmentDetail.INIT;
      ServPriceAdjustmentDetail.VALIDATE("Serv. Price Adjmt. Gr. Code",ServPriceAdjmtGrCode);
      ServPriceAdjustmentDetail.VALIDATE(Type,Type);
      ServPriceAdjustmentDetail.VALIDATE("No.",No);
      ServPriceAdjustmentDetail.INSERT(TRUE);

Example

There are no examples available.
Member of Lib.Library - Service


CreateServPriceGroupSetup@37 Method

The procedure CreateServPriceGroupSetup is available in codeunit 131902.

Syntax

CreateServPriceGroupSetup@37(
    VAR ServPriceGroupSetup@1000 : Record 6081 ServPriceGroupSetup, //Reference parameter of type Record
    ServicePriceGroupCode@1001 : Code[10] ServicePriceGroupCode, //Input parameter of type Code
    FaultAreaCode@1002 : Code[10] FaultAreaCode, //Input parameter of type Code
    CustPriceGroupCode@1003 : Code[10] CustPriceGroupCode //Input parameter of type Code
);

Parameters

ServPriceGroupSetup
Reference parameter of type Record
ServicePriceGroupCode
Input parameter of type Code
FaultAreaCode
Input parameter of type Code
CustPriceGroupCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Serv, Price, Group, Setup.

For a clarification about how this function works, refer to the code listed below.

      ServPriceGroupSetup.INIT;
      ServPriceGroupSetup.VALIDATE("Service Price Group Code",ServicePriceGroupCode);
      ServPriceGroupSetup.VALIDATE("Fault Area Code",FaultAreaCode);
      ServPriceGroupSetup.VALIDATE("Cust. Price Group Code",CustPriceGroupCode);
      ServPriceGroupSetup.VALIDATE("Starting Date",WORKDATE);
      ServPriceGroupSetup.VALIDATE(Amount,RANDOM(100));  // Validating as random because value is not important.
      ServPriceGroupSetup.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136105 to show one way of using this function.

      LibraryService.CreateServPriceGroupSetup(ServPriceGroupSetup,ServicePriceGroupCode,'','');
      ServPriceGroupSetup.VALIDATE("Serv. Price Adjmt. Gr. Code",ServicePriceAdjustGroupCode);
      ServPriceGroupSetup.VALIDATE("Adjustment Type",AdjustmentType);
      ServPriceGroupSetup.VALIDATE("Include Discounts",IncludeDiscount);
      ServPriceGroupSetup.VALIDATE("Include VAT",IncludeVAT);
      ServPriceGroupSetup.MODIFY(TRUE);
Member of Lib.Library - Service


CreateStandardServiceCode@48 Method

The procedure CreateStandardServiceCode is available in codeunit 131902.

Syntax

CreateStandardServiceCode@48(
    VAR StandardServiceCode@1000 : Record 5996 StandardServiceCode //Reference parameter of type Record
);

Parameters

StandardServiceCode
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Standard, Service, Code.

For a clarification about how this function works, refer to the code listed below.

      StandardServiceCode.INIT;
      // Use the function GenerateRandomCode to get random and unique value for the Code field.
      StandardServiceCode.VALIDATE(
        Code,LibraryUtility.GenerateRandomCode(StandardServiceCode.FIELDNO(Code),DATABASE::"Standard Service Code"));
      // Validating Code as Description because value is not important.
      StandardServiceCode.VALIDATE(Description,StandardServiceCode.Code);
      StandardServiceCode.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136112 to show one way of using this function.

      // 1. Setup: Set "Link Service to Service Item" field as False on Service Management Setup, Create Standard Service Code, Create
      // Standard Service Line for Create Standard Service Code, Create Service Order - Service Header and Service Item Line.
      Initialize;
      ServiceMgtSetup.GET;
      Customer.GET(CreateCustomer);
      SetupModified := ModifySetupLinkServiceItem(ServiceMgtSetup,Modified);
      LibraryService.CreateStandardServiceCode(StandardServiceCode);

      StandServiceItemGroupCode := StandardServiceCode.Code;
      LibraryService.CreateStandardServiceLine(StandardServiceLine,StandardServiceCode.Code);
      UpdateStandardServiceLine(StandardServiceLine,StandardServiceLine.Type::Item,LibraryInventory.CreateItem(Item));

      LibraryService.CreateServiceItem(ServiceItem,Customer."No.");
      LibraryService.CreateServiceHeader(ServiceHeader,ServiceHeader."Document Type"::Order,Customer."No.");
      LibraryService.CreateServiceItemLine(ServiceItemLine,ServiceHeader,ServiceItem."No.");
      StandardServiceCode.VALIDATE("Currency Code",ServiceHeader."Currency Code");
      StandardServiceCode.MODIFY(TRUE);

      // 2. Exercise: Run Service Line Form.
      StandardServiceItemGrCode.InsertServiceLines(ServiceItemLine);
Member of Lib.Library - Service


CreateStandardServiceItemGr@50 Method

The procedure CreateStandardServiceItemGr is available in codeunit 131902.

Syntax

CreateStandardServiceItemGr@50(
    VAR StandardServiceItemGrCode@1003 : Record 5998 StandardServiceItemGrCode, //Reference parameter of type Record
    ServiceItemGroupCode@1000 : Code[10] ServiceItemGroupCode, //Input parameter of type Code
    StandardServiceCode@1001 : Code[10] StandardServiceCode //Input parameter of type Code
);

Parameters

StandardServiceItemGrCode
Reference parameter of type Record
ServiceItemGroupCode
Input parameter of type Code
StandardServiceCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Standard, Service, Item, Gr.

For a clarification about how this function works, refer to the code listed below.

      StandardServiceItemGrCode.INIT;
      StandardServiceItemGrCode.VALIDATE("Service Item Group Code",ServiceItemGroupCode);
      StandardServiceItemGrCode.VALIDATE(Code,StandardServiceCode);
      StandardServiceItemGrCode.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136118 to show one way of using this function.

      LibraryService.CreateStandardServiceItemGr(
        StandardServiceItemGrCode,
        COPYSTR(LibraryVariableStorage.DequeueText,1,10),
        COPYSTR(LibraryVariableStorage.DequeueText,1,10));
      StandardServItemGrCodes.SETRECORD(StandardServiceItemGrCode);
      StandardServItemGrCodes.SETTABLEVIEW(StandardServiceItemGrCode);
      Response := ACTION::LookupOK;
Member of Lib.Library - Service


CreateStandardServiceLine@47 Method

The procedure CreateStandardServiceLine is available in codeunit 131902.

Syntax

CreateStandardServiceLine@47(
    VAR StandardServiceLine@1000 : Record 5997 StandardServiceLine, //Reference parameter of type Record
    StandardServiceCode@1001 : Code[10] StandardServiceCode //Input parameter of type Code
);

Parameters

StandardServiceLine
Reference parameter of type Record
StandardServiceCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Standard, Service, Line.

For a clarification about how this function works, refer to the code listed below.

      StandardServiceLine.INIT;
      StandardServiceLine.VALIDATE("Standard Service Code",StandardServiceCode);
      RecRef.GETTABLE(StandardServiceLine);
      StandardServiceLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,StandardServiceLine.FIELDNO("Line No.")));
      StandardServiceLine.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136112 to show one way of using this function.

      // 1. Setup: Set "Link Service to Service Item" field as False on Service Management Setup, Create Standard Service Code, Create
      // Standard Service Line for Create Standard Service Code, Create Service Order - Service Header and Service Item Line.
      Initialize;
      ServiceMgtSetup.GET;
      Customer.GET(CreateCustomer);
      SetupModified := ModifySetupLinkServiceItem(ServiceMgtSetup,Modified);
      LibraryService.CreateStandardServiceCode(StandardServiceCode);

      StandServiceItemGroupCode := StandardServiceCode.Code;
      LibraryService.CreateStandardServiceLine(StandardServiceLine,StandardServiceCode.Code);
      UpdateStandardServiceLine(StandardServiceLine,StandardServiceLine.Type::Item,LibraryInventory.CreateItem(Item));

      LibraryService.CreateServiceItem(ServiceItem,Customer."No.");
      LibraryService.CreateServiceHeader(ServiceHeader,ServiceHeader."Document Type"::Order,Customer."No.");
      LibraryService.CreateServiceItemLine(ServiceItemLine,ServiceHeader,ServiceItem."No.");
      StandardServiceCode.VALIDATE("Currency Code",ServiceHeader."Currency Code");
      StandardServiceCode.MODIFY(TRUE);

      // 2. Exercise: Run Service Line Form.
      StandardServiceItemGrCode.InsertServiceLines(ServiceItemLine);
Member of Lib.Library - Service


CreateSymptomCode@82 Method

The procedure CreateSymptomCode is available in codeunit 131902.

Syntax

CreateSymptomCode@82(
    VAR SymptomCode@1001 : Record 5916 SymptomCode //Reference parameter of type Record
);

Parameters

SymptomCode
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Symptom, Code.

For a clarification about how this function works, refer to the code listed below.

      SymptomCode.INIT;
      // Use the function GenerateRandomCode to get random and unique value for the Code field.
      SymptomCode.VALIDATE(Code,LibraryUtility.GenerateRandomCode(SymptomCode.FIELDNO(Code),DATABASE::"Symptom Code"));
      SymptomCode.VALIDATE(Description,SymptomCode.Code);  // Validating Code as Description because value is not important.
      SymptomCode.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136110 to show one way of using this function.

      // Covers document number TC0111 - refer to TFS ID 21727.
      // 1. Input Fault Reporting Level as None in Service Management Setup. Find Fault Area and Symptom Code.
      // 2. Try to insert a Fault Code record with Fault Code as not blank.
      // 3. Verify that the application generates an error on insertion of Fault Code record if Fault Reporting Level is set to None.

      // Setup: Input Fault Reporting Level as None in Service Management Setup.
      SetupServiceFaultReporting(ServiceMgtSetup,ServiceMgtSetup."Fault Reporting Level"::None);

      LibraryService.CreateFaultArea(FaultArea);
      LibraryService.CreateSymptomCode(SymptomCode);

      // Exercise: Insert Fault Code.
      ASSERTERROR LibraryService.CreateFaultCode(FaultCode,FaultArea.Code,SymptomCode.Code);

      // Verify: Check that the application generates an error on insertion of Fault Code record if Fault Reporting Level is set to None.
      Assert.AreEqual(
        STRSUBSTNO(FaultReportingLevelNoneError,FaultCode.TABLECAPTION,ServiceMgtSetup.FIELDCAPTION("Fault Reporting Level"),
          ServiceMgtSetup.TABLECAPTION,FORMAT(ServiceMgtSetup."Fault Reporting Level")),GETLASTERRORTEXT,UnknownError);
Member of Lib.Library - Service


CreateTroubleshootingHeader@17 Method

The procedure CreateTroubleshootingHeader is available in codeunit 131902.

Syntax

CreateTroubleshootingHeader@17(
    VAR TroubleshootingHeader@1000 : Record 5943 TroubleshootingHeader //Reference parameter of type Record
);

Parameters

TroubleshootingHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Troubleshooting, Header.

For a clarification about how this function works, refer to the code listed below.

      TroubleshootingHeader.INIT;
      TroubleshootingHeader.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136103 to show one way of using this function.

      LibraryService.CreateTroubleshootingHeader(TroubleshootingHeader);
      LibraryService.CreateTroubleshootingLine(TroubleshootingLine,TroubleshootingHeader."No.");

      // Create Troubleshooting Setup and assign the number of the Troubleshooting Header to it.
      LibraryService.CreateTroubleshootingSetup(TroubleshootingSetup,Type,No,TroubleshootingHeader."No.");
      TroubleshootingHeaderNo := TroubleshootingHeader."No.";
Member of Lib.Library - Service


CreateTroubleshootingLine@21 Method

The procedure CreateTroubleshootingLine is available in codeunit 131902.

Syntax

CreateTroubleshootingLine@21(
    VAR TroubleshootingLine@1000 : Record 5944 TroubleshootingLine, //Reference parameter of type Record
    TroubleshootingHeaderNo@1001 : Code[20] TroubleshootingHeaderNo //Input parameter of type Code
);

Parameters

TroubleshootingLine
Reference parameter of type Record
TroubleshootingHeaderNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Troubleshooting, Line.

For a clarification about how this function works, refer to the code listed below.

      TroubleshootingLine.INIT;
      TroubleshootingLine.VALIDATE("No.",TroubleshootingHeaderNo);
      RecRef.GETTABLE(TroubleshootingLine);
      TroubleshootingLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,TroubleshootingLine.FIELDNO("Line No.")));

      // Comment is blank so validate the Comment as a string containing the Troubleshooting Header No. and the Line No. as the
      // text for Comment is not important here. This enables the user to distinguish between different Comments.
      TroubleshootingLine.VALIDATE(Comment,TroubleshootingLine."No." + FORMAT(TroubleshootingLine."Line No."));
      TroubleshootingLine.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136103 to show one way of using this function.

      LibraryService.CreateTroubleshootingHeader(TroubleshootingHeader);
      LibraryService.CreateTroubleshootingLine(TroubleshootingLine,TroubleshootingHeader."No.");

      // Create Troubleshooting Setup and assign the number of the Troubleshooting Header to it.
      LibraryService.CreateTroubleshootingSetup(TroubleshootingSetup,Type,No,TroubleshootingHeader."No.");
      TroubleshootingHeaderNo := TroubleshootingHeader."No.";
Member of Lib.Library - Service


CreateTroubleshootingSetup@19 Method

The procedure CreateTroubleshootingSetup is available in codeunit 131902.

Syntax

CreateTroubleshootingSetup@19(
    VAR TroubleshootingSetup@1000 : Record 5945 TroubleshootingSetup, //Reference parameter of type Record
    Type@1001 : Option Type, //Input parameter of type Option
    No@1002 : Code[20] No, //Input parameter of type Code
    TroubleshootingNo@1003 : Code[20] TroubleshootingNo //Input parameter of type Code
);

Parameters

TroubleshootingSetup
Reference parameter of type Record
Type
Input parameter of type Option
No
Input parameter of type Code
TroubleshootingNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Troubleshooting, Setup.

For a clarification about how this function works, refer to the code listed below.

      TroubleshootingSetup.INIT;
      TroubleshootingSetup.VALIDATE(Type,Type);
      TroubleshootingSetup.VALIDATE("No.",No);
      TroubleshootingSetup.VALIDATE("Troubleshooting No.",TroubleshootingNo);
      TroubleshootingSetup.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136103 to show one way of using this function.

      LibraryService.CreateTroubleshootingHeader(TroubleshootingHeader);
      LibraryService.CreateTroubleshootingLine(TroubleshootingLine,TroubleshootingHeader."No.");

      // Create Troubleshooting Setup and assign the number of the Troubleshooting Header to it.
      LibraryService.CreateTroubleshootingSetup(TroubleshootingSetup,Type,No,TroubleshootingHeader."No.");
      TroubleshootingHeaderNo := TroubleshootingHeader."No.";
Member of Lib.Library - Service


FindContractAccountGroup@24 Method

The procedure FindContractAccountGroup is available in codeunit 131902.

Syntax

FindContractAccountGroup@24(
    VAR ServiceContractAccountGroup@1000 : Record 5973 ServiceContractAccountGroup //Reference parameter of type Record
);

Parameters

ServiceContractAccountGroup
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Contract, Account, Group.

For a clarification about how this function works, refer to the code listed below.

      // Filter Service Contract Account Group so that errors are not generated due to mandatory fields.
      ServiceContractAccountGroup.SETFILTER("Non-Prepaid Contract Acc.",'<>''''');
      ServiceContractAccountGroup.SETFILTER("Prepaid Contract Acc.",'<>''''');

      ServiceContractAccountGroup.FINDSET;

Example

The below example is extracted from the test automation codeunit 136100 to show one way of using this function.

      ConfirmType := ConfirmType::Create;
      CLEAR(ServiceContractHeader);
      ServiceContractHeader.INIT;
      ServiceContractHeader.VALIDATE("Contract Type",ServiceContractHeader."Contract Type"::Contract);
      ServiceContractHeader.VALIDATE("Customer No.",CustomerNo);
      ServiceContractHeader.INSERT(TRUE);
      EVALUATE(ServicePeriod,OneWeekTxt); // 1W is required field but not important for the test case
      ServiceContractHeader.VALIDATE("Service Period",ServicePeriod);

      // Account Group Required field for Signed Contracts
      LibraryService.FindContractAccountGroup(ServiceContractAccountGroup);
      ServiceContractHeader.VALIDATE("Serv. Contract Acc. Gr. Code",ServiceContractAccountGroup.Code);
      ServiceContractHeader.MODIFY(TRUE);
      EXIT(ServiceContractHeader."Contract No.");
Member of Lib.Library - Service


FindFaultReasonCode@63 Method

The procedure FindFaultReasonCode is available in codeunit 131902.

Syntax

FindFaultReasonCode@63(
    VAR FaultReasonCode@1000 : Record 5917 FaultReasonCode //Reference parameter of type Record
);

Parameters

FaultReasonCode
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Fault, Reason, Code.

For a clarification about how this function works, refer to the code listed below.

      FaultReasonCode.FINDSET;

Example

The below example is extracted from the test automation codeunit 136110 to show one way of using this function.

      FindServiceItemLineForOrder(ServiceItemLine,No);
      LibraryService.FindFaultReasonCode(FaultReasonCode);
      ServiceItemLine.VALIDATE("Fault Reason Code",FaultReasonCode.Code);
      ServiceItemLine.MODIFY(TRUE);
Member of Lib.Library - Service


FindResolutionCode@130 Method

The procedure FindResolutionCode is available in codeunit 131902.

Syntax

FindResolutionCode@130(
    VAR ResolutionCode@1000 : Record 5919 ResolutionCode //Reference parameter of type Record
);

Parameters

ResolutionCode
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Resolution, Code.

For a clarification about how this function works, refer to the code listed below.

      ResolutionCode.FINDSET;

Example

The below example is extracted from the test automation codeunit 136101 to show one way of using this function.

      LibraryService.FindResolutionCode(ResolutionCode);
      LibraryService.CreateServiceItemLine(ServiceItemLine,ServiceHeader,ServiceItemNo);
      ServiceItemLine.VALIDATE("Resolution Code",ResolutionCode.Code);
      ServiceItemLine.MODIFY(TRUE);
Member of Lib.Library - Service


FindServiceContractLine@68 Method

The procedure FindServiceContractLine is available in codeunit 131902.

Syntax

FindServiceContractLine@68(
    VAR ServiceContractLine@1000 : Record 5964 ServiceContractLine, //Reference parameter of type Record
    ContractType@1001 : Option ContractType, //Input parameter of type Option
    ContractNo@1002 : Code[20] ContractNo //Input parameter of type Code
);

Parameters

ServiceContractLine
Reference parameter of type Record
ContractType
Input parameter of type Option
ContractNo
Input parameter of type Code

Remarks

The relevant search keywords are: Find, Service, Contract, Line.

For a clarification about how this function works, refer to the code listed below.

      ServiceContractLine.SETRANGE("Contract Type",ContractType);
      ServiceContractLine.SETRANGE("Contract No.",ContractNo);
      ServiceContractLine.FINDFIRST;

Example

The below example is extracted from the test automation codeunit 136122 to show one way of using this function.

      LockOpenServContract.OpenServContract(ServiceContractHeader);
      LibraryService.FindServiceContractLine(
        ServiceContractLine,ServiceContractHeader."Contract Type",ServiceContractHeader."Contract No.");
      ServiceContractLine.VALIDATE("Contract Expiration Date",WORKDATE);
      ServiceContractLine.MODIFY(TRUE);
      PostServiceCrMemo(ServiceContractLine);
Member of Lib.Library - Service


FindServiceCost@26 Method

The procedure FindServiceCost is available in codeunit 131902.

Syntax

FindServiceCost@26(
    VAR ServiceCost@1000 : Record 5905 ServiceCost //Reference parameter of type Record
);

Parameters

ServiceCost
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Service, Cost.

For a clarification about how this function works, refer to the code listed below.

      // Filter Service Cost so that errors are not generated due to mandatory fields.
      ServiceCost.SETFILTER("Account No.",'<>''''');
      ServiceCost.SETRANGE("Service Zone Code",'');

      ServiceCost.FINDSET;

Example

The below example is extracted from the test automation codeunit 136101 to show one way of using this function.

      // [SCENARIO 259506] Test Discount Amount after Posting Service Order with Invoice Discount %.

      // [GIVEN] Modify Sales Receivables Setup, Create Customer, Item, Customer Invoice Discount, Service Order And Calculate Invoice Discount.
      Initialize;
      LibrarySales.SetCalcInvDiscount(TRUE);
      LibrarySales.CreateCustomer(Customer);
      LibraryInventory.CreateItem(Item);
      GeneralPostingSetup.GET(Customer."Gen. Bus. Posting Group",Item."Gen. Prod. Posting Group");
      DiscountPct := LibraryRandom.RandDec(10,2);  // Generate Random Value for Discount Percent.
      CreateCustomerInvoiceDiscount(Customer."No.",DiscountPct,0);  // Take Zero for Service Charge.
      CreateServiceItem(ServiceItem,Customer."No.",Item."No.");
      LibraryService.CreateServiceHeader(ServiceHeader,ServiceHeader."Document Type"::Order,Customer."No.");
      LibraryService.CreateServiceItemLine(ServiceItemLine,ServiceHeader,ServiceItem."No.");
      LibraryService.FindServiceCost(ServiceCost);
      CreateAndUpdateServiceLine(ServiceHeader,ServiceLine.Type::Cost,ServiceCost.Code,1,ServiceItemLine."Line No.",0);  // Take 1 for Quantity and 0 for Line Discount.
      GetServiceLine(ServiceLine,ServiceHeader);
      CODEUNIT.RUN(CODEUNIT::"Service-Calc. Discount",ServiceLine);
      DiscountAmount := (ServiceLine.Amount * DiscountPct / 100);
      // 2. Exercise.
      LibraryService.PostServiceOrder(ServiceHeader,TRUE,FALSE,TRUE);
      // [THEN] Verify Discount Amount after Posting.
      GeneralPostingSetup.GET(ServiceLine."Gen. Bus. Posting Group",ServiceLine."Gen. Prod. Posting Group");
      VerifyDiscountAmount(ServiceHeader."No.",DiscountAmount,GeneralPostingSetup."Sales Inv. Disc. Account");
Member of Lib.Library - Service


FindServiceItemGroup@56 Method

The procedure FindServiceItemGroup is available in codeunit 131902.

Syntax

FindServiceItemGroup@56(
    VAR ServiceItemGroup@1000 : Record 5904 ServiceItemGroup //Reference parameter of type Record
);

Parameters

ServiceItemGroup
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Service, Item, Group.

For a clarification about how this function works, refer to the code listed below.

      ServiceItemGroup.FINDSET;

Example

The below example is extracted from the test automation codeunit 136101 to show one way of using this function.

      LibraryInventory.CreateItem(Item);
      LibraryService.FindServiceItemGroup(ServiceItemGroup);
      LibraryService.CreateServiceItem(ServiceItem,CustomerNo);
      ServiceItem.VALIDATE("Item No.",Item."No.");
      ServiceItem.VALIDATE("Service Item Group Code",ServiceItemGroup.Code);
      ServiceItem.MODIFY(TRUE);
Member of Lib.Library - Service


GetFirstWorkingDay@42 Method

The procedure GetFirstWorkingDay is available in codeunit 131902.

Syntax

GetFirstWorkingDay@42(
    WorkingDate@1004 : Date WorkingDate //Input parameter of type Date
);

Parameters

WorkingDate
Input parameter of type Date

Return Value

Date

Remarks

The relevant search keywords are: Get, First, Working, Day.

For a clarification about how this function works, refer to the code listed below.

      // Gets the first working day.
      WHILE NOT (IsWorking(WorkingDate) AND GetServiceHourForDate(ServiceHour,WorkingDate)) DO
        WorkingDate := CALCDATE('<1D>',WorkingDate);
      EXIT(WorkingDate);

Example

The below example is extracted from the test automation codeunit 136106 to show one way of using this function.

      // Covers document number TC0120 - refer to TFS ID 21728.
      // Test that the Response Time on Service Item Line is Ending Time of the relevant Service Hour minus the time subtracted, for a
      // Working Day and Response Time (Hours) as any time falling within the Service Hours on the same day.

      // 1. Setup: Create Service Order for a Working Day - Service Item, Service Header, Service Item Line.
      Initialize;
      OrderDate := LibraryService.GetFirstWorkingDay(WORKDATE);
      CreateServiceHeaderGivenDate(ServiceItemLine,OrderDate);

      // 2. Exercise: Get Service Hour for the relevant Date and validate Response Time (Hours) as any time falling within the Service
      // Hours on the same day.
      LibraryService.GetServiceHourForDate(ServiceHour,OrderDate);
      ServiceItemLine.VALIDATE(
        "Response Time (Hours)",LibraryUtility.ConvertMilliSecToHours(ServiceHour."Ending Time" - ServiceHour."Starting Time") - 1);
      ServiceItemLine.MODIFY(TRUE);

      // 3. Verify: Verify that the Response Time on Service Item Line is Ending Time of the relevant Service Hour minus the time
      // subtracted.
      ServiceItemLine.TESTFIELD("Response Time",ServiceHour."Ending Time" - LibraryUtility.ConvertHoursToMilliSec(1));
Member of Lib.Library - Service


GetNextWorkingDay@41 Method

The procedure GetNextWorkingDay is available in codeunit 131902.

Syntax

GetNextWorkingDay@41(
    WorkingDate@1000 : Date WorkingDate //Input parameter of type Date
);

Parameters

WorkingDate
Input parameter of type Date

Return Value

Date

Remarks

The relevant search keywords are: Get, Next, Working, Day.

For a clarification about how this function works, refer to the code listed below.

      // Gets the next working day from the specified date.
      REPEAT
        WorkingDate := CALCDATE('<1D>',WorkingDate);
      UNTIL (
             IsWorking(WorkingDate) AND GetServiceHourForDate(ServiceHour,WorkingDate)) OR
            (NOT IsWorking(WorkingDate) AND IsValidOnHolidays(WorkingDate));
      EXIT(WorkingDate);

Example

The below example is extracted from the test automation codeunit 136106 to show one way of using this function.

      // Covers document number TC0120 - refer to TFS ID 21728.
      // Test that the Response Time on Service Item Line is Starting Time of the relevant Service Hour for next working day
      // plus the time added, for a Working Day that is followed by non working day.

      // 1. Setup: Create Service Order for a Working Day that is followed by non working day - Service Item, Service Header,
      // Service Item Line.
      Initialize;
      OrderDate := GetWorkingFollowedByNonWorking;
      CreateServiceHeaderGivenDate(ServiceItemLine,OrderDate);

      // 2. Exercise: Get Service Hour for the relevant Date and validate Response Time (Hours)) on Service Item Line as time falling
      // outside of the Working Hours.
      LibraryService.GetServiceHourForDate(ServiceHour,OrderDate);
      ServiceItemLine.VALIDATE(
        "Response Time (Hours)",LibraryUtility.ConvertMilliSecToHours(ServiceHour."Ending Time" - ServiceHour."Starting Time") + 1);
      ServiceItemLine.MODIFY(TRUE);

      // 3. Verify: Verify that the Response Time on Service Item Line is Starting Time of the relevant Service Hour for next working day
      // plus the time added.
      LibraryService.GetServiceHourForDate(ServiceHour,LibraryService.GetNextWorkingDay(OrderDate));
      ServiceItemLine.TESTFIELD("Response Time",ServiceHour."Starting Time" + LibraryUtility.ConvertHoursToMilliSec(1));
Member of Lib.Library - Service


GetNonWrkngDayFollwdByWrkngDay@34 Method

The procedure GetNonWrkngDayFollwdByWrkngDay is available in codeunit 131902.

Syntax

GetNonWrkngDayFollwdByWrkngDay@34(
      //param element not supplied
);

Return Value

Date

Remarks

The relevant search keywords are: Get, Non, Wrkng, Day, Follwd, By, Wrkng, Day.

For a clarification about how this function works, refer to the code listed below.

      // Returns a non-working day followed by a working day.
      WorkingDate := WORKDATE;
      LoopCounter := 0;
      MaxLoops := 366;
      REPEAT
        LoopCounter += 1;
        IF LoopCounter > MaxLoops THEN
          ERROR(STRSUBSTNO(NonWorkDayWorkDaySequenceNotFound,MaxLoops));
        WorkingDate := CALCDATE('<1D>',WorkingDate);
      UNTIL
            NOT (IsWorking(WorkingDate) OR IsValidOnHolidays(WorkingDate)) AND
            (IsWorking(CALCDATE('<1D>',WorkingDate)) AND GetServiceHourForDate(ServiceHour,CALCDATE('<1D>',WorkingDate)));
      EXIT(WorkingDate);

Example

The below example is extracted from the test automation codeunit 136106 to show one way of using this function.

      // Covers document number TC0120 - refer to TFS ID 21728.
      // Test that the Response Time on Service Item Line is Ending Time of the relevant Service Hour for next working day
      // minus the time subtracted, for a non working day that is followed by a working day.

      // 1. Setup: Create Service Order for a non working day that is followed by a working day - Service Item, Service Header,
      // Service Item Line.
      Initialize;
      OrderDate := LibraryService.GetNonWrkngDayFollwdByWrkngDay;
      CreateServiceHeaderGivenDate(ServiceItemLine,OrderDate);

      // 2. Exercise: Get Service Hour for the relevant Date. Validate Response Time (Hours) on Service Item Line as
      // time falling inside the Service Hours of next working day.
      LibraryService.GetServiceHourForDate(ServiceHour,LibraryService.GetNextWorkingDay(OrderDate));
      ServiceItemLine.VALIDATE(
        "Response Time (Hours)",LibraryUtility.ConvertMilliSecToHours(ServiceHour."Ending Time" - ServiceHour."Starting Time") - 1);
      ServiceItemLine.MODIFY(TRUE);

      // 3. Verify: Verify that the Response Time on Service Item Line is Starting Time of the relevant Service Hour for next working day
      // plus the time added.
      ServiceItemLine.TESTFIELD("Response Time",ServiceHour."Ending Time" - LibraryUtility.ConvertHoursToMilliSec(1));
Member of Lib.Library - Service


GetServiceHourForDate@40 Method

The procedure GetServiceHourForDate is available in codeunit 131902.

Syntax

GetServiceHourForDate@40(
    VAR ServiceHour@1003 : Record 5910 ServiceHour, //Reference parameter of type Record
    OrderDate@1004 : Date OrderDate //Input parameter of type Date
);

Parameters

ServiceHour
Reference parameter of type Record
OrderDate
Input parameter of type Date

Return Value

Boolean

Remarks

The relevant search keywords are: Get, Service, Hour, For, Date.

For a clarification about how this function works, refer to the code listed below.

      // Finds the Service Hour related to the Date and returns a Boolean.
      Date.GET(Date."Period Type"::Date,OrderDate);
      ServiceHour.SETRANGE("Service Contract Type",ServiceHour."Service Contract Type"::" ");
      ServiceHour.SETRANGE("Service Contract No.",'');
      ServiceHour.SETFILTER(Day,Date."Period Name");
      EXIT(ServiceHour.FINDFIRST);

Example

The below example is extracted from the test automation codeunit 136106 to show one way of using this function.

      // Covers document number TC0120 - refer to TFS ID 21728.
      // Test that the Response Time on Service Item Line is Ending Time of the relevant Service Hour minus the time subtracted, for a
      // Working Day and Response Time (Hours) as any time falling within the Service Hours on the same day.

      // 1. Setup: Create Service Order for a Working Day - Service Item, Service Header, Service Item Line.
      Initialize;
      OrderDate := LibraryService.GetFirstWorkingDay(WORKDATE);
      CreateServiceHeaderGivenDate(ServiceItemLine,OrderDate);

      // 2. Exercise: Get Service Hour for the relevant Date and validate Response Time (Hours) as any time falling within the Service
      // Hours on the same day.
      LibraryService.GetServiceHourForDate(ServiceHour,OrderDate);
      ServiceItemLine.VALIDATE(
        "Response Time (Hours)",LibraryUtility.ConvertMilliSecToHours(ServiceHour."Ending Time" - ServiceHour."Starting Time") - 1);
      ServiceItemLine.MODIFY(TRUE);

      // 3. Verify: Verify that the Response Time on Service Item Line is Ending Time of the relevant Service Hour minus the time
      // subtracted.
      ServiceItemLine.TESTFIELD("Response Time",ServiceHour."Ending Time" - LibraryUtility.ConvertHoursToMilliSec(1));
Member of Lib.Library - Service


GetServiceOrderReportGrossAmount@100 Method

The procedure GetServiceOrderReportGrossAmount is available in codeunit 131902.

Syntax

GetServiceOrderReportGrossAmount@100(
    ServiceLine@1001 : Record 5902 ServiceLine //Input parameter of type Record
);

Parameters

ServiceLine
Input parameter of type Record

Return Value

Decimal

Remarks

The relevant search keywords are: Get, Service, Order, Report, Gross, Amount.

For a clarification about how this function works, refer to the code listed below.

      CustInvDisc.GET(ServiceLine."Customer No.",ServiceLine."Currency Code",0);
      EXIT(ServiceLine."Amount Including VAT" - (ServiceLine."Amount Including VAT" * CustInvDisc."Discount %" / 100));

Example

The below example is extracted from the test automation codeunit 136900 to show one way of using this function.

      // Test to verify Invoice Discount Amount by printing Service Order report.

      // 1. Setup : Modify Sales Receivables Setup, Create Customer, Item, Customer Invoice Discount, Service Order and Calculate Invoice Discount.
      Initialize;
      UpdateCalculateInvoiceDiscount(TRUE);
      LibrarySales.CreateCustomer(Customer);
      LibraryInventory.CreateItem(Item);
      DiscountPct := LibraryRandom.RandIntInRange(5,10) + LibraryUtility.GenerateRandomFraction;  // Generate Random Value for Discount Percent.
      CreateCustomerInvoiceDiscount(Customer."No.",DiscountPct);
      CreateServiceItem(ServiceItem,Customer."No.",Item."No.");
      LibraryService.CreateServiceHeader(ServiceHeader,ServiceHeader."Document Type"::Order,Customer."No.");
      LibraryService.CreateServiceItemLine(ServiceItemLine,ServiceHeader,ServiceItem."No.");
      LibraryService.FindServiceCost(ServiceCost);
      CreateAndUpdateServiceLine(ServiceHeader,ServiceLine.Type::Cost,ServiceCost.Code,1,ServiceItemLine."Line No.");  // Take 1 for Quantity.
      GetServiceLine(ServiceLine,ServiceHeader."Document Type",ServiceHeader."No.");
      CODEUNIT.RUN(CODEUNIT::"Service-Calc. Discount",ServiceLine);

      // 2. Exercise : Run the Report.
      COMMIT;
      CLEAR(ServiceOrderReport);
      ServiceHeader.SETRANGE("No.",ServiceHeader."No.");
      ServiceOrderReport.SETTABLEVIEW(ServiceHeader);
      ServiceOrderReport.InitializeRequest(FALSE,ShowQty::Quantity);
      ServiceOrderReport.RUN;

      GrossAmount := LibraryService.GetServiceOrderReportGrossAmount(ServiceLine);

      // 3. Verify : Verify Gross Amount in Report.
      LibraryReportDataset.LoadDataSetFile;
      LibraryReportDataset.SetRange('DocumentNo_ServLine',ServiceLine."Document No.");
      Assert.IsTrue(LibraryReportDataset.GetNextRow,'find element with the service item no');
Member of Lib.Library - Service


IsValidOnHolidays@38 Method

The procedure IsValidOnHolidays is available in codeunit 131902.

Syntax

IsValidOnHolidays@38(
    DateToCheck@1000 : Date DateToCheck //Input parameter of type Date
);

Parameters

DateToCheck
Input parameter of type Date

Return Value

Boolean

Remarks

The relevant search keywords are: Is, Valid, On, Holidays.

For a clarification about how this function works, refer to the code listed below.

      // Checks if the Service Hour for the date has Valid on Holidays checked.
      IF GetServiceHourForDate(ServiceHour,DateToCheck) THEN
        EXIT(ServiceHour."Valid on Holidays");
      EXIT(FALSE);

Example

The below example is extracted from the test automation codeunit 136106 to show one way of using this function.

      WorkingDate := WORKDATE;
      REPEAT
        WorkingDate := CALCDATE('<1D>',WorkingDate);
      UNTIL
            (LibraryService.IsWorking(WorkingDate) AND LibraryService.GetServiceHourForDate(ServiceHour,WorkingDate)) AND
            NOT (LibraryService.IsWorking(CALCDATE('<1D>',WorkingDate)) AND
                 LibraryService.IsValidOnHolidays(CALCDATE('<1D>',WorkingDate)));
      EXIT(WorkingDate);
Member of Lib.Library - Service


IsWorking@35 Method

The procedure IsWorking is available in codeunit 131902.

Syntax

IsWorking@35(
    DateToCheck@1003 : Date DateToCheck //Input parameter of type Date
);

Parameters

DateToCheck
Input parameter of type Date

Return Value

Boolean

Remarks

The relevant search keywords are: Is, Working.

For a clarification about how this function works, refer to the code listed below.

      // Checks if the day is a working day.
      ServiceMgtSetup.GET;
      EXIT(
        NOT CalendarManagement.CheckCustomizedDateStatus(
          CustomizedCalendarChange."Source Type"::Service,'','',ServiceMgtSetup."Base Calendar Code",DateToCheck,Description));

Example

The below example is extracted from the test automation codeunit 136106 to show one way of using this function.

      WHILE LibraryService.IsWorking(NonWorkingDate) DO
        NonWorkingDate := CALCDATE('<1D>',NonWorkingDate);
      EXIT(NonWorkingDate);
Member of Lib.Library - Service


PostServiceOrder@8 Method

The procedure PostServiceOrder is available in codeunit 131902.

Syntax

PostServiceOrder@8(
    VAR ServiceHeader@1000 : Record 5900 ServiceHeader, //Reference parameter of type Record
    Ship@1002 : Boolean Ship, //Input parameter of type Boolean
    Consume@1003 : Boolean Consume, //Input parameter of type Boolean
    Invoice@1004 : Boolean Invoice //Input parameter of type Boolean
);

Parameters

ServiceHeader
Reference parameter of type Record
Ship
Input parameter of type Boolean
Consume
Input parameter of type Boolean
Invoice
Input parameter of type Boolean

Remarks

The relevant search keywords are: Post, Service, Order.

For a clarification about how this function works, refer to the code listed below.

      ServiceHeader.FIND;
      SetCorrDocNoService(ServiceHeader);
      ServicePost.PostWithLines(ServiceHeader,TempServiceLine,Ship,Consume,Invoice);

Example

The below example is extracted from the test automation codeunit 134030 to show one way of using this function.

      // Store Posted Document No. and Create Service Lines of Item and GL Account Type.
      PostedDocumentNo := NoSeriesManagement.GetNextNo(ServiceHeader."Posting No. Series",WORKDATE,FALSE);
      CreateAndUpdateServiceLine(
        ServiceHeader,ServiceLine.Type::Item,LineNo,CreateItem(VATPostingSetup."VAT Prod. Posting Group"));
      CreateAndUpdateServiceLine(ServiceHeader,ServiceLine.Type::"G/L Account",LineNo,
        LibraryERM.CreateGLAccountWithVATPostingSetup(VATPostingSetup,GLAccount."Gen. Posting Type"::Sale));

      // Exercise: Post the Service Document.
      LibraryService.PostServiceOrder(ServiceHeader,TRUE,FALSE,TRUE);

      // Verify: Check that value of EU Service Field = Yes in VAT Entry.
      ValidateVATEntry(PostedDocumentNo,EUService);
Member of Lib.Library - Service


PostServiceOrderWithPassedLines@53 Method

The procedure PostServiceOrderWithPassedLines is available in codeunit 131902.

Syntax

PostServiceOrderWithPassedLines@53(
    VAR ServiceHeader@1000 : Record 5900 ServiceHeader, //Reference parameter of type Record
    VAR TempServiceLine@1001 : TEMPORARY Record 5902 TempServiceLine, //Reference Temporary parameter of type Record
    Ship@1002 : Boolean Ship, //Input parameter of type Boolean
    Consume@1003 : Boolean Consume, //Input parameter of type Boolean
    Invoice@1004 : Boolean Invoice //Input parameter of type Boolean
);

Parameters

ServiceHeader
Reference parameter of type Record
TempServiceLine
Reference Temporary parameter of type Record
Ship
Input parameter of type Boolean
Consume
Input parameter of type Boolean
Invoice
Input parameter of type Boolean

Remarks

The relevant search keywords are: Post, Service, Order, Passed, Lines.

For a clarification about how this function works, refer to the code listed below.

      ServiceHeader.FIND;
      SetCorrDocNoService(ServiceHeader);
      ServicePost.PostWithLines(ServiceHeader,TempServiceLine,Ship,Consume,Invoice);

Example

The below example is extracted from the test automation codeunit 136107 to show one way of using this function.

      // [FEATURE] [Undo Shipment] [Service Shipment]
      // [SCENARIO 211697] Undoing shipment should create item ledger entries and resource ledger entries with the same posting date as on the original service shipment line.
      Initialize;

      // [GIVEN] Service Order with posting date = WORKDATE.
      CreateServiceOrder(ServiceHeader);

      // [GIVEN] Service lines with item and resource.
      CreateServiceLineForItem(ServiceLine,ServiceHeader);
      CreateServiceLineForResource(ServiceLine,ServiceHeader);

      // [GIVEN] The service lines are set to be partially shipped.
      UpdatePartialQtyToShip(ServiceLine);

      // [GIVEN] Posting Date on all service lines is set to "D" > WORKDATE.
      UpdatePostingDateOnServiceLines(ServiceLine,LibraryRandom.RandDateFrom(ServiceHeader."Posting Date",30));
      SaveServiceLineInTempTable(TempServiceLine,ServiceLine);

      // [GIVEN] The service lines are posted with Ship option.
      LibraryService.PostServiceOrderWithPassedLines(ServiceHeader,TempServiceLine,TRUE,FALSE,FALSE);

      // [WHEN] Undo Shipment.
      LibraryService.UndoShipmentLinesByServiceOrderNo(TempServiceLine."Document No.");

      // [THEN] Posting Date on reversed item and resource ledger entries is equal to "D".
      VerifyItemEntriesAfterUndoShipment(TempServiceLine."Document No.");
      VerifyResourceEntriesAfterUndoShipment(TempServiceLine."Document No.");
Member of Lib.Library - Service


ReleaseServiceDocument@78 Method

The procedure ReleaseServiceDocument is available in codeunit 131902.

Syntax

ReleaseServiceDocument@78(
    VAR ServiceHeader@1000 : Record 5900 ServiceHeader //Reference parameter of type Record
);

Parameters

ServiceHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Release, Service, Document.

For a clarification about how this function works, refer to the code listed below.

      ReleaseServiceDoc.PerformManualRelease(ServiceHeader);

Example

The below example is extracted from the test automation codeunit 136107 to show one way of using this function.

      // [FEATURE] [Warehouse]
      // [SCENARIO 380057] Warehouse Shipment is created for Service Order with Green location, item and zero "Qty. to Consume"
      Initialize;

      // [GIVEN] Service Order with item on Green location ("Require Shipment" = TRUE), "Qty. to Consume" = 0
      CreateServiceOrderWithGreenLocationAndQtyToConsume(ServiceHeader,0);
      // [GIVEN] Perform "Release to Ship" action
      LibraryService.ReleaseServiceDocument(ServiceHeader);

      // [WHEN] Perform "Create Whse. Shipment" action
      LibraryVariableStorage.Enqueue(STRSUBSTNO('%1 %2',1,WhseShptIsCreatedMsg));
      CreateWhseShipmentFromServiceHeader(ServiceHeader);
      // CreateWhseShpt_MessageHandler

      // [THEN] Warehouse shipment has been created
      // WarehouseShipmentPageHandler
      DummyWarehouseShipmentLine.SETRANGE("Location Code",ServiceHeader."Location Code");
      Assert.RecordIsNotEmpty(DummyWarehouseShipmentLine);
Member of Lib.Library - Service


ReopenServiceDocument@59 Method

The procedure ReopenServiceDocument is available in codeunit 131902.

Syntax

ReopenServiceDocument@59(
    VAR ServiceHeader@1000 : Record 5900 ServiceHeader //Reference parameter of type Record
);

Parameters

ServiceHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Reopen, Service, Document.

For a clarification about how this function works, refer to the code listed below.

      ReleaseServiceDoc.PerformManualReopen(ServiceHeader);

Example

The below example is extracted from the test automation codeunit 136140 to show one way of using this function.

      Initialize;

      // Setup: Create a service order with service lines
      CreateServiceOrderWithServiceLines(ServiceHeader);
      LibraryService.ReleaseServiceDocument(ServiceHeader);
      LibraryService.ReopenServiceDocument(ServiceHeader);

      // Execute: Delete a Released Order
      ServiceHeaderNo := ServiceHeader."No.";
      ServiceHeader.DELETE;

      // Verify: Delete has succeeded.
      Assert.AreEqual(FALSE,ServiceHeader.GET(ServiceHeader."Document Type",ServiceHeaderNo),'Unable to fetch record after delete');
Member of Lib.Library - Service


SetCorrDocNoService@58 Method

The procedure SetCorrDocNoService is available in codeunit 131902.

Syntax

SetCorrDocNoService@58(
    VAR ServiceHeader@1000 : Record 5900 ServiceHeader //Reference parameter of type Record
);

Parameters

ServiceHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Set, Corr, Document, No, Service.

For a clarification about how this function works, refer to the code listed below.

      IF ServiceHeader."Document Type" = ServiceHeader."Document Type"::"Credit Memo" THEN;

Example

There are no examples available.
Member of Lib.Library - Service


SetupServiceMgtNoSeries@12 Method

The procedure SetupServiceMgtNoSeries is available in codeunit 131902.

Syntax

SetupServiceMgtNoSeries@12(
      //param element not supplied
);

Remarks

The relevant search keywords are: Setup, Service, Management, No, Series.

For a clarification about how this function works, refer to the code listed below.

      // Setup Service Management.
      ServiceMgtSetup.GET;

      // Use GetGlobalNoSeriesCode to get No. Series code.
      IF ServiceMgtSetup."Service Item Nos." = '' THEN
        ServiceMgtSetup.VALIDATE("Service Item Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      IF ServiceMgtSetup."Service Order Nos." = '' THEN
        ServiceMgtSetup.VALIDATE("Service Order Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      IF ServiceMgtSetup."Posted Service Shipment Nos." = '' THEN
        ServiceMgtSetup.VALIDATE("Posted Service Shipment Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      IF ServiceMgtSetup."Posted Service Invoice Nos." = '' THEN
        ServiceMgtSetup.VALIDATE("Posted Service Invoice Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      IF ServiceMgtSetup."Troubleshooting Nos." = '' THEN
        ServiceMgtSetup.VALIDATE("Troubleshooting Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      IF ServiceMgtSetup."Service Contract Nos." = '' THEN
        ServiceMgtSetup.VALIDATE("Service Contract Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      IF ServiceMgtSetup."Service Quote Nos." = '' THEN
        ServiceMgtSetup.VALIDATE("Service Quote Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      IF ServiceMgtSetup."Contract Invoice Nos." = '' THEN
        ServiceMgtSetup.VALIDATE("Contract Invoice Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      IF ServiceMgtSetup."Contract Credit Memo Nos." = '' THEN
        ServiceMgtSetup.VALIDATE("Contract Credit Memo Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      IF ServiceMgtSetup."Prepaid Posting Document Nos." = '' THEN
        ServiceMgtSetup.VALIDATE("Prepaid Posting Document Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      IF ServiceMgtSetup."Contract Credit Memo Nos." = '' THEN
        ServiceMgtSetup.VALIDATE("Contract Credit Memo Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      IF ServiceMgtSetup."Posted Service Shipment Nos." = '' THEN
        ServiceMgtSetup.VALIDATE("Posted Service Shipment Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      IF ServiceMgtSetup."Contract Template Nos." = '' THEN
        ServiceMgtSetup.VALIDATE("Contract Template Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      IF ServiceMgtSetup."Loaner Nos." = '' THEN
        ServiceMgtSetup.VALIDATE("Loaner Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      ServiceMgtSetup.VALIDATE("Contract Serv. Ord.  Max. Days",365);  // Using Default 365 Days.

      // Create and Validate Base Calendar.
      IF ServiceMgtSetup."Base Calendar Code" = '' THEN BEGIN
        CreateBaseCalendar(BaseCalender);
        ServiceMgtSetup.VALIDATE("Base Calendar Code",BaseCalender.Code);
      END;

      ServiceMgtSetup.MODIFY(TRUE);

      LibrarySales.SetCreditWarningsToNoWarnings;

Example

The below example is extracted from the test automation codeunit 136101 to show one way of using this function.

      LibrarySetupStorage.Restore;
      LibraryVariableStorage.Clear;

      IF IsInitialized THEN
        EXIT;

      // Create Demonstration Database.
      LibraryERMCountryData.CreateVATData;
      LibraryERMCountryData.UpdateSalesReceivablesSetup;
      LibraryERMCountryData.UpdateGeneralPostingSetup;
      LibraryERMCountryData.CreateGeneralPostingSetupData;
      LibraryERMCountryData.UpdateGeneralLedgerSetup;
      LibraryService.SetupServiceMgtNoSeries;
      UpdateCustNoSeries;
      IsInitialized := TRUE;
      COMMIT;

      LibrarySetupStorage.Save(DATABASE::"General Ledger Setup");
      LibrarySetupStorage.Save(DATABASE::"Sales & Receivables Setup");
Member of Lib.Library - Service


UndoShipmentLinesByServiceDocNo@108 Method

The procedure UndoShipmentLinesByServiceDocNo is available in codeunit 131902.

Syntax

UndoShipmentLinesByServiceDocNo@108(
    ServiceDocumentNo@1001 : Code[20] ServiceDocumentNo //Input parameter of type Code
);

Parameters

ServiceDocumentNo
Input parameter of type Code

Remarks

The relevant search keywords are: Undo, Shipment, Lines, By, Service, Document, No.

For a clarification about how this function works, refer to the code listed below.

      ServiceShipmentLine.SETRANGE("Document No.",ServiceDocumentNo);
      CODEUNIT.RUN(CODEUNIT::"Undo Service Shipment Line",ServiceShipmentLine);

Example

The below example is extracted from the test automation codeunit 136140 to show one way of using this function.

      Initialize;

      // SETUP: Create Service order on WHITE Location and Release Service Order, Create Whse Shpment header.
      LocationCode := WMSFullLocation;
      Quantity := LibraryRandom.RandIntInRange(2,100);
      CreateItemAndSupply(Item,LocationCode,Quantity);

      CreateServiceOrderAndServiceLines(ServiceHeader,Item."No.",Quantity,LocationCode);
      LibraryService.ReleaseServiceDocument(ServiceHeader);

      WarehouseShipment.TRAP;
      CreateWarehouseShipmentFromServiceHeader(ServiceHeader);
      WarehouseShipmentHeader.GET(WarehouseShipment."No.");

      // EXECUTE: Create and Register Pick. Post the whse shpmnt twice with the ship option.
      // EXECUTE: Undo the Second posted service shipment only.
      LibraryWarehouse.CreatePick(WarehouseShipmentHeader);
      RegisterWarehouseActivity(ServiceHeader."No.",WarehouseActivityLine."Activity Type"::Pick);
      GetWarehouseShipmentLinesByShipmentHeader(WarehouseShipmentLine,WarehouseShipmentHeader);
      FirstShipmentQuantity := LibraryRandom.RandIntInRange(1,Quantity - 1);
      DeltaQuantity := Quantity - FirstShipmentQuantity;
      WarehouseShipmentLine.VALIDATE("Qty. to Ship",FirstShipmentQuantity);
      WarehouseShipmentLine.MODIFY(TRUE);
      LibraryWarehouse.PostWhseShipment(WarehouseShipmentHeader,FALSE);

      ServiceShipmentHeader.SETRANGE("Order No.",ServiceHeader."No.");
      ServiceShipmentHeader.FINDFIRST;
      ServiceShipmentHeaderNo := ServiceShipmentHeader."No.";

      GetAllServiceLinesOfTypeItem(ServiceLine,ServiceHeader);
      SaveServiceLineInTempTable(TempServiceLine,ServiceLine);
      GetAndVerifyWarehouseEntry(ServiceLine,WarehouseEntry,WarehouseEntry."Entry Type"::"Negative Adjmt.",-FirstShipmentQuantity);

      LibraryWarehouse.PostWhseShipment(WarehouseShipmentHeader,FALSE);
      CLEAR(WarehouseEntry);
      GetWarehouseEntries(ServiceLine,WarehouseEntry,WarehouseEntry."Entry Type"::"Negative Adjmt.");
      WarehouseEntry.FINDLAST;
      VerifyWarehouseEntry(ServiceLine,WarehouseEntry,WarehouseEntry."Entry Type"::"Negative Adjmt.",-DeltaQuantity);

      ServiceShipmentHeader.SETFILTER("Order No.",ServiceHeader."No.");
      ServiceShipmentHeader.SETFILTER("No.",'<>%1',ServiceShipmentHeaderNo);
      ServiceShipmentHeader.FINDFIRST;
      LibraryService.UndoShipmentLinesByServiceDocNo(ServiceShipmentHeader."No.");

      // VERIFY: Ledger entries are created correctly.
      // VERIFY: Quantity shipped in the first shipment is not affected  by undoing the second shipment.
      // VERIFY: Warehouse entries are created correctly
      Assert.AreEqual(
        ServiceLine."Quantity Shipped",FirstShipmentQuantity,
        'Verify undoing one shipment returns Quantity Shipped field to values prior to undo');
      Assert.AreEqual(ServiceLine."Qty. to Ship",0,'Verify undoing one shipment returns Qty. to Ship field to values prior to undo');
      Assert.AreEqual(
        ServiceLine."Quantity Invoiced",0,'Verify undoing one shipment returns Quantity Invoiced field to values prior to undo');
      Assert.AreEqual(
        ServiceLine."Qty. to Invoice",FirstShipmentQuantity,
        'Verify undoing one shipment returns Qty. to Invoice field to values prior to undo');

      VerifyUpdatedShipQtyAfterShip(TempServiceLine);
      VerifyQtyOnServiceShipmentLine(TempServiceLine,DeltaQuantity);
      VerifyQtyOnItemLedgerEntry(TempServiceLine,DeltaQuantity);
      VerifyValueEntry(TempServiceLine,DeltaQuantity);
      VerifyServiceLedgerEntry(TempServiceLine,DeltaQuantity);

      GetAndVerifyWarehouseEntry(ServiceLine,WarehouseEntry,WarehouseEntry."Entry Type"::"Positive Adjmt.",DeltaQuantity);
      Assert.AreEqual(1,WarehouseEntry.COUNT,'Only one warehouse reverse entry is created');

      CLEAR(WarehouseEntry);
      GetWarehouseEntries(ServiceLine,WarehouseEntry,WarehouseEntry."Entry Type"::"Negative Adjmt.");
      Assert.AreEqual(2,WarehouseEntry.COUNT,'2 warehouse entries are created');
Member of Lib.Library - Service


UndoShipmentLinesByServiceOrderNo@77 Method

The procedure UndoShipmentLinesByServiceOrderNo is available in codeunit 131902.

Syntax

UndoShipmentLinesByServiceOrderNo@77(
    ServiceOrderNo@1001 : Code[20] ServiceOrderNo //Input parameter of type Code
);

Parameters

ServiceOrderNo
Input parameter of type Code

Remarks

The relevant search keywords are: Undo, Shipment, Lines, By, Service, Order, No.

For a clarification about how this function works, refer to the code listed below.

      ServiceShipmentLine.SETRANGE("Order No.",ServiceOrderNo);
      CODEUNIT.RUN(CODEUNIT::"Undo Service Shipment Line",ServiceShipmentLine);

Example

The below example is extracted from the test automation codeunit 136107 to show one way of using this function.

      // [FEATURE] [Undo Shipment] [Service Shipment]
      // [SCENARIO 211697] Undoing shipment should create item ledger entries and resource ledger entries with the same posting date as on the original service shipment line.
      Initialize;

      // [GIVEN] Service Order with posting date = WORKDATE.
      CreateServiceOrder(ServiceHeader);

      // [GIVEN] Service lines with item and resource.
      CreateServiceLineForItem(ServiceLine,ServiceHeader);
      CreateServiceLineForResource(ServiceLine,ServiceHeader);

      // [GIVEN] The service lines are set to be partially shipped.
      UpdatePartialQtyToShip(ServiceLine);

      // [GIVEN] Posting Date on all service lines is set to "D" > WORKDATE.
      UpdatePostingDateOnServiceLines(ServiceLine,LibraryRandom.RandDateFrom(ServiceHeader."Posting Date",30));
      SaveServiceLineInTempTable(TempServiceLine,ServiceLine);

      // [GIVEN] The service lines are posted with Ship option.
      LibraryService.PostServiceOrderWithPassedLines(ServiceHeader,TempServiceLine,TRUE,FALSE,FALSE);

      // [WHEN] Undo Shipment.
      LibraryService.UndoShipmentLinesByServiceOrderNo(TempServiceLine."Document No.");

      // [THEN] Posting Date on reversed item and resource ledger entries is equal to "D".
      VerifyItemEntriesAfterUndoShipment(TempServiceLine."Document No.");
      VerifyResourceEntriesAfterUndoShipment(TempServiceLine."Document No.");
Member of Lib.Library - Service


Library - Setup Storage Class

Lib.Library - Setup Storage

COD131009 applies to W1,All.

Methods

Name | Description
Restore@3 | The procedure Restore is available in codeunit 131009.
Save@2 | The procedure Save is available in codeunit 131009.

See Also

Lib


Restore@3 Method

The procedure Restore is available in codeunit 131009.

Syntax

Restore@3(
      //param element not supplied
);

Remarks

The relevant search keywords are: Restore.

For a clarification about how this function works, refer to the code listed below.

      Index := TempIntegerStoredTables.COUNT;
      WHILE Index > 0 DO BEGIN
        RecordRefSource := RecordRefStorage[Index];
        RecordRefDestination.OPEN(RecordRefSource.NUMBER);
        CopyFields(RecordRefSource,RecordRefDestination);
        RecordRefDestination.MODIFY;
        RecordRefDestination.CLOSE;
        Index -= 1;
      END;

Example

The below example is extracted from the test automation codeunit 134000 to show one way of using this function.

      LibraryVariableStorage.Clear;
      LibrarySetupStorage.Restore;
      IF isInitialized THEN
        EXIT;
      LibraryERMCountryData.CreateVATData;
      LibraryERMCountryData.UpdateAccountInCustomerPostingGroup;
      LibraryERMCountryData.UpdateGeneralLedgerSetup;
      LibraryERMCountryData.UpdateGeneralPostingSetup;
      ModifyGenJnlBatchNoSeries;
      isInitialized := TRUE;
      COMMIT;

      LibrarySetupStorage.Save(DATABASE::"General Ledger Setup");
Member of Lib.Library - Setup Storage


Save@2 Method

The procedure Save is available in codeunit 131009.

Syntax

Save@2(
    TableId@1000 : Integer TableId //Input parameter of type Integer
);

Parameters

TableId
Input parameter of type Integer

Remarks

The relevant search keywords are: Save.

For a clarification about how this function works, refer to the code listed below.

      IF TempIntegerStoredTables.GET(TableId) THEN
        ERROR(STRSUBSTNO(TableBackupErr,TableId));

      RecRef.OPEN(TableId);
      Assert.AreEqual(1,RecRef.COUNT,OnlyOneEntryAllowedErr);
      RecRef.FIND;
      ValidatePrimaryKey(RecRef);

      TempIntegerStoredTables.Number := TableId;
      TempIntegerStoredTables.INSERT(TRUE);
      RecordRefStorage[TempIntegerStoredTables.COUNT] := RecRef;

Example

The below example is extracted from the test automation codeunit 134000 to show one way of using this function.

      LibraryVariableStorage.Clear;
      LibrarySetupStorage.Restore;
      IF isInitialized THEN
        EXIT;
      LibraryERMCountryData.CreateVATData;
      LibraryERMCountryData.UpdateAccountInCustomerPostingGroup;
      LibraryERMCountryData.UpdateGeneralLedgerSetup;
      LibraryERMCountryData.UpdateGeneralPostingSetup;
      ModifyGenJnlBatchNoSeries;
      isInitialized := TRUE;
      COMMIT;

      LibrarySetupStorage.Save(DATABASE::"General Ledger Setup");
Member of Lib.Library - Setup Storage


Library - Small Business Class

Lib.Library - Small Business

COD132213 applies to W1,All.

Methods

Name | Description
CreateCommentLine@26 | The procedure CreateCommentLine is available in codeunit 132213.
CreateCurrencyExchangeRate@18 | The procedure CreateCurrencyExchangeRate is available in codeunit 132213.
CreateCustomer@2 | The procedure CreateCustomer is available in codeunit 132213.
CreateCustomerSalesCode@25 | The procedure CreateCustomerSalesCode is available in codeunit 132213.
CreateCustomerTemplate@19 | The procedure CreateCustomerTemplate is available in codeunit 132213.
CreateCustomerTemplateLine@20 | The procedure CreateCustomerTemplateLine is available in codeunit 132213.
CreateExtendedTextHeader@23 | The procedure CreateExtendedTextHeader is available in codeunit 132213.
CreateExtendedTextLine@24 | The procedure CreateExtendedTextLine is available in codeunit 132213.
CreateGLAccount@46 | The procedure CreateGLAccount is available in codeunit 132213.
CreateGLAccountWithPostingSetup@50 | The procedure CreateGLAccountWithPostingSetup is available in codeunit 132213.
CreateItem@1 | The procedure CreateItem is available in codeunit 132213.
CreateItemAsService@5 | The procedure CreateItemAsService is available in codeunit 132213.
CreateItemCrossReference@22 | The procedure CreateItemCrossReference is available in codeunit 132213.
CreateJob@56 | The procedure CreateJob is available in codeunit 132213.
CreatePurchaseCrMemoHeader@34 | The procedure CreatePurchaseCrMemoHeader is available in codeunit 132213.
CreatePurchaseInvoiceHeader@39 | The procedure CreatePurchaseInvoiceHeader is available in codeunit 132213.
CreatePurchaseLine@38 | The procedure CreatePurchaseLine is available in codeunit 132213.
CreateResponsabilityCenter@27 | The procedure CreateResponsabilityCenter is available in codeunit 132213.
CreateSalesCommentLine@29 | The procedure CreateSalesCommentLine is available in codeunit 132213.
CreateSalesCrMemoHeader@21 | The procedure CreateSalesCrMemoHeader is available in codeunit 132213.
CreateSalesInvoiceHeader@3 | The procedure CreateSalesInvoiceHeader is available in codeunit 132213.
CreateSalesLine@16 | The procedure CreateSalesLine is available in codeunit 132213.
CreateSalesQuoteHeader@30 | The procedure CreateSalesQuoteHeader is available in codeunit 132213.
CreateSalesQuoteHeaderWithLines@28 | The procedure CreateSalesQuoteHeaderWithLines is available in codeunit 132213.
CreateStandardPurchaseCode@43 | The procedure CreateStandardPurchaseCode is available in codeunit 132213.
CreateStandardPurchaseLine@42 | The procedure CreateStandardPurchaseLine is available in codeunit 132213.
CreateStandardSalesCode@10 | The procedure CreateStandardSalesCode is available in codeunit 132213.
CreateStandardSalesLine@15 | The procedure CreateStandardSalesLine is available in codeunit 132213.
CreateVATPostingSetup@45 | The procedure CreateVATPostingSetup is available in codeunit 132213.
CreateVendor@32 | The procedure CreateVendor is available in codeunit 132213.
CreateVendorPurchaseCode@41 | The procedure CreateVendorPurchaseCode is available in codeunit 132213.
CreateVendorTemplate@4 | The procedure CreateVendorTemplate is available in codeunit 132213.
CreateVendorTemplateLine@8 | The procedure CreateVendorTemplateLine is available in codeunit 132213.
FindGenBusPostingGroup@36 | The procedure FindGenBusPostingGroup is available in codeunit 132213.
FindVATBusPostingGroupZeroVAT@6 | The procedure FindVATBusPostingGroupZeroVAT is available in codeunit 132213.
FindVATProdPostingGroupZeroVAT@48 | The procedure FindVATProdPostingGroupZeroVAT is available in codeunit 132213.
PostPurchaseInvoice@40 | The procedure PostPurchaseInvoice is available in codeunit 132213.
PostSalesInvoice@12 | The procedure PostSalesInvoice is available in codeunit 132213.
SetInvoiceDiscountToCustomer@9 | The procedure SetInvoiceDiscountToCustomer is available in codeunit 132213.
SetInvoiceDiscountToVendor@33 | The procedure SetInvoiceDiscountToVendor is available in codeunit 132213.
SetVATBusPostingGrPriceSetup@102 | The procedure SetVATBusPostingGrPriceSetup is available in codeunit 132213.

See Also

Lib


CreateCommentLine@26 Method

The procedure CreateCommentLine is available in codeunit 132213.

Syntax

CreateCommentLine@26(
    VAR CommentLine@1001 : Record 97 CommentLine, //Reference parameter of type Record
    TableName@1000 : Option TableName, //Input parameter of type Option
    No@1002 : Code[20] No //Input parameter of type Code
);

Parameters

CommentLine
Reference parameter of type Record
TableName
Input parameter of type Option
No
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Comment, Line.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(CommentLine);
      CommentLine.VALIDATE("Table Name",TableName);
      CommentLine.VALIDATE("No.",No);
      RecRef.GETTABLE(CommentLine);
      CommentLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,CommentLine.FIELDNO("Line No.")));
      CommentLine.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 138000 to show one way of using this function.

      Initialize;

      LibrarySmallBusiness.CreateCustomer(Cust);
      Cust.Name := Cust."No.";
      Cust.MODIFY(TRUE);

      LibrarySmallBusiness.CreateItem(Item);
      LibrarySmallBusiness.CreateCommentLine(CommentLine,CommentLine."Table Name"::Item,Item."No.");
      CommentLine.VALIDATE(Code,LibraryUtility.GenerateRandomCode(CommentLine.FIELDNO(Code),
          DATABASE::"Comment Line"));
      CommentLine.VALIDATE(Comment,LibraryUtility.GenerateRandomCode(CommentLine.FIELDNO(Comment),
          DATABASE::"Comment Line"));
      CommentLine.MODIFY(TRUE);

      MiniSalesInvoice.OPENNEW;
      MiniSalesInvoice."Sell-to Customer Name".SETVALUE(Cust.Name);

      MiniSalesInvoice.SalesLines.NEW;
      MiniSalesInvoice.SalesLines."No.".SETVALUE(Item."No.");
      MiniSalesInvoice.CLOSE;
Member of Lib.Library - Small Business


CreateCurrencyExchangeRate@18 Method

The procedure CreateCurrencyExchangeRate is available in codeunit 132213.

Syntax

CreateCurrencyExchangeRate@18(
    VAR CurrencyExchangeRate@1002 : Record 330 CurrencyExchangeRate, //Reference parameter of type Record
    CurrencyCode@1001 : Code[10] CurrencyCode, //Input parameter of type Code
    StartingDate@1000 : Date StartingDate //Input parameter of type Date
);

Parameters

CurrencyExchangeRate
Reference parameter of type Record
CurrencyCode
Input parameter of type Code
StartingDate
Input parameter of type Date

Remarks

The relevant search keywords are: Create, Currency, Exchange, Rate.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(CurrencyExchangeRate);
      CurrencyExchangeRate.VALIDATE("Currency Code",CurrencyCode);
      CurrencyExchangeRate.VALIDATE("Starting Date",StartingDate);
      CurrencyExchangeRate.VALIDATE("Exchange Rate Amount",LibraryRandom.RandDec(10,2));
      CurrencyExchangeRate.VALIDATE("Relational Exch. Rate Amount",
        CurrencyExchangeRate."Exchange Rate Amount" * LibraryRandom.RandDec(10,2));

      CurrencyExchangeRate.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 138004 to show one way of using this function.

      CurrencyExchangeRate.SETRANGE("Currency Code",CurrencyCode);
      CurrencyExchangeRate.SETFILTER("Starting Date",'<=%1',WORKDATE);
      IF NOT CurrencyExchangeRate.FINDFIRST THEN
        LibrarySmallBusiness.CreateCurrencyExchangeRate(CurrencyExchangeRate,CurrencyCode,WORKDATE);
Member of Lib.Library - Small Business


CreateCustomer@2 Method

The procedure CreateCustomer is available in codeunit 132213.

Syntax

CreateCustomer@2(
    VAR Customer@1000 : Record 18 Customer //Reference parameter of type Record
);

Parameters

Customer
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Customer.

For a clarification about how this function works, refer to the code listed below.

      LibrarySales.CreateCustomer(Customer);

Example

The below example is extracted from the test automation codeunit 134100 to show one way of using this function.

      // 1. Setup: Create a new Customer and Item. Create Sales Prepayment and Validate Prepayment % as per parameter passed.
      Initialize;
      CreateItem(Item);
      LibrarySales.CreateCustomer(Customer);
      CreatePrepayment(SalesPrepaymentPct,SalesPrepaymentPct."Sales Type"::Customer,Customer."No.",Item."No.",PrepaymentPercent);

      // 2. Exercise: Create Sales Header, Sales Line for Item.
      CreateSalesDocumentPrepayment(SalesHeader,SalesLine,Customer."No.",Item."No.");

      // 3. Verify: Check that the Prepayment % on Sales Line is same as defined on Sales Prepayment, the calculation for Prepmt.
      // Line Amount on Sales Line are as per Prepayment % inputted and Prepayment Percent on Sales Header.
      VerifyPrepaymentLineAmount(SalesLine,SalesPrepaymentPct."Prepayment %");
      VerifyPrepaymentPercent(SalesHeader,SalesLine,Customer."Prepayment %",SalesPrepaymentPct."Prepayment %");
Member of Lib.Library - Small Business


CreateCustomerSalesCode@25 Method

The procedure CreateCustomerSalesCode is available in codeunit 132213.

Syntax

CreateCustomerSalesCode@25(
    VAR StandardCustomerSalesCode@1000 : Record 172 StandardCustomerSalesCode, //Reference parameter of type Record
    CustomerNo@1001 : Code[20] CustomerNo, //Input parameter of type Code
    Code@1002 : Code[10] Code //Input parameter of type Code
);

Parameters

StandardCustomerSalesCode
Reference parameter of type Record
CustomerNo
Input parameter of type Code
Code
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Customer, Sales, Code.

For a clarification about how this function works, refer to the code listed below.

      StandardCustomerSalesCode.INIT;
      StandardCustomerSalesCode.VALIDATE("Customer No.",CustomerNo);
      StandardCustomerSalesCode.VALIDATE(Code,Code);
      StandardCustomerSalesCode.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 138000 to show one way of using this function.

      Initialize;

      // Create data
      LibrarySmallBusiness.CreateItem(Item);
      CreateCustomer(Customer);
      LibrarySmallBusiness.CreateStandardSalesCode(StandardSalesCode);
      LibrarySmallBusiness.CreateCustomerSalesCode(StandardCustomerSalesCode,Customer."No.",StandardSalesCode.Code);
      CreateStandardCodeWithItemAndDescr(StandardSalesCode,Item);

      // Exercise
      LibrarySmallBusiness.CreateSalesInvoiceHeader(SalesHeader,Customer);
      MiniSalesInvoice.OPENEDIT;
      MiniSalesInvoice.GOTORECORD(SalesHeader);
      MiniSalesInvoice.GetRecurringSalesLines.INVOKE;

      // Verify
      VerifyInvoiceLinesFromStandardCodes(SalesHeader,StandardSalesCode);
Member of Lib.Library - Small Business


CreateCustomerTemplate@19 Method

The procedure CreateCustomerTemplate is available in codeunit 132213.

Syntax

CreateCustomerTemplate@19(
    VAR ConfigTemplateHeader@1003 : Record 8618 ConfigTemplateHeader //Reference parameter of type Record
);

Parameters

ConfigTemplateHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Customer, Template.

For a clarification about how this function works, refer to the code listed below.

      LibraryRapidStart.CreateConfigTemplateHeader(ConfigTemplateHeader);
      ConfigTemplateHeader.VALIDATE("Table ID",DATABASE::Customer);
      ConfigTemplateHeader.MODIFY(TRUE);

      CreateCustomerTemplateLine(ConfigTemplateHeader,Customer.FIELDNO("Phone No."),
        Customer.FIELDNAME("Phone No."),'');
      CreateCustomerTemplateLine(ConfigTemplateHeader,Customer.FIELDNO("Our Account No."),
        Customer.FIELDNAME("Our Account No."),'');
      CreateCustomerTemplateLine(ConfigTemplateHeader,Customer.FIELDNO("Gen. Bus. Posting Group"),
        Customer.FIELDNAME("Gen. Bus. Posting Group"),FindGenBusPostingGroup);
      CreateCustomerTemplateLine(ConfigTemplateHeader,Customer.FIELDNO("Customer Posting Group"),
        Customer.FIELDNAME("Customer Posting Group"),LibrarySales.FindCustomerPostingGroup);

Example

The below example is extracted from the test automation codeunit 136101 to show one way of using this function.

      LibrarySales.CreateCustomer(Customer);
      LibrarySales.CreateCustomerTemplate(CustomerTemplate);
      CustomerTemplate.VALIDATE("Gen. Bus. Posting Group",Customer."Gen. Bus. Posting Group");
      CustomerTemplate.VALIDATE("Customer Posting Group",Customer."Customer Posting Group");
      CustomerTemplate.MODIFY(TRUE);
Member of Lib.Library - Small Business


CreateCustomerTemplateLine@20 Method

The procedure CreateCustomerTemplateLine is available in codeunit 132213.

Syntax

CreateCustomerTemplateLine@20(
    ConfigTemplateHeader@1000 : Record 8618 ConfigTemplateHeader, //Input parameter of type Record
    FieldNo@1002 : Integer FieldNo, //Input parameter of type Integer
    FieldName@1003 : Text[30] FieldName, //Input parameter of type Text
    DefaultValue@1004 : Text[50] DefaultValue //Input parameter of type Text
);

Parameters

ConfigTemplateHeader
Input parameter of type Record
FieldNo
Input parameter of type Integer
FieldName
Input parameter of type Text
DefaultValue
Input parameter of type Text

Remarks

The relevant search keywords are: Create, Customer, Template, Line.

For a clarification about how this function works, refer to the code listed below.

      LibraryRapidStart.CreateConfigTemplateLine(ConfigTemplateLine,ConfigTemplateHeader.Code);
      ConfigTemplateLine.VALIDATE("Field ID",FieldNo);
      ConfigTemplateLine.VALIDATE("Field Name",FieldName);
      IF DefaultValue <> '' THEN
        ConfigTemplateLine.VALIDATE("Default Value",DefaultValue)
      ELSE
        ConfigTemplateLine.VALIDATE("Default Value",LibraryUtility.GenerateRandomCode(FieldNo,DATABASE::Customer));
      ConfigTemplateLine.VALIDATE("Skip Relation Check",FALSE);
      ConfigTemplateLine.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - Small Business


CreateExtendedTextHeader@23 Method

The procedure CreateExtendedTextHeader is available in codeunit 132213.

Syntax

CreateExtendedTextHeader@23(
    VAR ExtendedTextHeader@1000 : Record 279 ExtendedTextHeader, //Reference parameter of type Record
    TableNameOption@1001 : Option TableNameOption, //Input parameter of type Option
    No@1002 : Code[20] No //Input parameter of type Code
);

Parameters

ExtendedTextHeader
Reference parameter of type Record
TableNameOption
Input parameter of type Option
No
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Extended, Text, Header.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(ExtendedTextHeader);
      ExtendedTextHeader.VALIDATE("Table Name",TableNameOption);
      ExtendedTextHeader.VALIDATE("No.",No);
      ExtendedTextHeader.VALIDATE("Sales Invoice",TRUE);
      ExtendedTextHeader.VALIDATE("Sales Quote",TRUE);
      ExtendedTextHeader.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134100 to show one way of using this function.

      GLAccount.GET(GLAccountNo);
      GLAccount.VALIDATE("Automatic Ext. Texts",TRUE);
      GLAccount.MODIFY(TRUE);

      LibrarySmallBusiness.CreateExtendedTextHeader(ExtendedTextHeader,ExtendedTextHeader."Table Name"::"G/L Account",GLAccount."No.");
      LibrarySmallBusiness.CreateExtendedTextLine(ExtendedTextLine,ExtendedTextHeader);
      EXIT(ExtendedTextLine.Text);
Member of Lib.Library - Small Business


CreateExtendedTextLine@24 Method

The procedure CreateExtendedTextLine is available in codeunit 132213.

Syntax

CreateExtendedTextLine@24(
    VAR ExtendedTextLine@1000 : Record 280 ExtendedTextLine, //Reference parameter of type Record
    ExtendedTextHeader@1001 : Record 279 ExtendedTextHeader //Input parameter of type Record
);

Parameters

ExtendedTextLine
Reference parameter of type Record
ExtendedTextHeader
Input parameter of type Record

Remarks

The relevant search keywords are: Create, Extended, Text, Line.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(ExtendedTextLine);
      ExtendedTextLine.VALIDATE("Table Name",ExtendedTextHeader."Table Name");
      ExtendedTextLine.VALIDATE("No.",ExtendedTextHeader."No.");
      ExtendedTextLine.VALIDATE("Language Code",ExtendedTextHeader."Language Code");
      ExtendedTextLine.VALIDATE("Text No.",ExtendedTextHeader."Text No.");
      RecRef.GETTABLE(ExtendedTextLine);
      ExtendedTextLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,ExtendedTextLine.FIELDNO("Line No.")));
      ExtendedTextLine.VALIDATE(Text,LibraryUtility.GenerateRandomCode(ExtendedTextLine.FIELDNO(Text),
          DATABASE::"Extended Text Line"));
      ExtendedTextLine.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134100 to show one way of using this function.

      GLAccount.GET(GLAccountNo);
      GLAccount.VALIDATE("Automatic Ext. Texts",TRUE);
      GLAccount.MODIFY(TRUE);

      LibrarySmallBusiness.CreateExtendedTextHeader(ExtendedTextHeader,ExtendedTextHeader."Table Name"::"G/L Account",GLAccount."No.");
      LibrarySmallBusiness.CreateExtendedTextLine(ExtendedTextLine,ExtendedTextHeader);
      EXIT(ExtendedTextLine.Text);
Member of Lib.Library - Small Business


CreateGLAccount@46 Method

The procedure CreateGLAccount is available in codeunit 132213.

Syntax

CreateGLAccount@46(
      //param element not supplied
);

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, General Ledger, Account.

For a clarification about how this function works, refer to the code listed below.

      EXIT(LibraryERM.CreateGLAccountNo);

Example

The below example is extracted from the test automation codeunit 134100 to show one way of using this function.

      // [FEATURE] [Sales] [Setup]
      // [SCENARIO] Setting up Sales Prepayment Account in a General Posting Setup.

      // 1. Setup: Find a GL Account.
      Initialize;
      LibraryERM.CreateGLAccount(GLAccount);

      // 2. Exercise: Setup Sales Prepayments Account in General Posting Setup.
      LibraryERM.FindGeneralPostingSetup(GeneralPostingSetup);
      SalesPrepaymentsAccountOld := AttachSalesPrepaymentAccountInSetup(GeneralPostingSetup,GLAccount."No.");

      // 3. Verify: Verify the Sales Prepayment Account in General Posting Setup.
      GeneralPostingSetup.TESTFIELD("Sales Prepayments Account",GLAccount."No.");

      // 4. Tear Down: Change back the Sales Prepayment Account in the General Posting Setup.
      GeneralPostingSetup.VALIDATE("Sales Prepayments Account",SalesPrepaymentsAccountOld);
      GeneralPostingSetup.MODIFY(TRUE);
Member of Lib.Library - Small Business


CreateGLAccountWithPostingSetup@50 Method

The procedure CreateGLAccountWithPostingSetup is available in codeunit 132213.

Syntax

CreateGLAccountWithPostingSetup@50(
    VAR GLAccount@1000 : Record 15 GLAccount //Reference parameter of type Record
);

Parameters

GLAccount
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, General Ledger, Account, Posting, Setup.

For a clarification about how this function works, refer to the code listed below.

      VATPostingSetup.SETFILTER("VAT %",'<>%1',0);
      IF NOT VATPostingSetup.FINDLAST THEN
        CreateVATPostingSetup(VATPostingSetup);

      WITH GLAccount DO BEGIN
        GET(CreateGLAccount);
        VALIDATE(Name,"No.");
        VALIDATE("Direct Posting",TRUE);
        VALIDATE("VAT Bus. Posting Group",VATPostingSetup."VAT Bus. Posting Group");
        VALIDATE("VAT Prod. Posting Group",VATPostingSetup."VAT Prod. Posting Group");
        MODIFY;
      END;

Example

There are no examples available.
Member of Lib.Library - Small Business


CreateItem@1 Method

The procedure CreateItem is available in codeunit 132213.

Syntax

CreateItem@1(
    VAR Item@1000 : Record 27 Item //Reference parameter of type Record
);

Parameters

Item
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Item.

For a clarification about how this function works, refer to the code listed below.

      LibraryInventory.CreateItemWithUnitPriceAndUnitCost(Item,LibraryRandom.RandDecInDecimalRange(1,10000,2),0);

Example

The below example is extracted from the test automation codeunit 134100 to show one way of using this function.

      LibraryInventory.CreateItem(Item);
      Item.VALIDATE("Unit Price",10 * LibraryRandom.RandDec(99,5)); // Using RANDOM value for Unit Price.
      Item.MODIFY(TRUE);
Member of Lib.Library - Small Business


CreateItemAsService@5 Method

The procedure CreateItemAsService is available in codeunit 132213.

Syntax

CreateItemAsService@5(
    VAR Item@1000 : Record 27 Item //Reference parameter of type Record
);

Parameters

Item
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Item, As, Service.

For a clarification about how this function works, refer to the code listed below.

      LibraryInventory.CreateItem(Item2);
      ItemNew.INIT;
      ItemNew.INSERT(TRUE);
      ItemNew.VALIDATE("Base Unit of Measure",FindUnitOfMeasure);
      ItemNew.VALIDATE("Unit Price",LibraryRandom.RandDecInDecimalRange(1.0,10000.0,2));
      ItemNew.VALIDATE(Type,Item.Type::Service);
      ItemNew.VALIDATE("Gen. Prod. Posting Group",Item2."Gen. Prod. Posting Group");
      IF ItemNew."VAT Prod. Posting Group" = '' THEN
        ItemNew.VALIDATE("VAT Prod. Posting Group",Item2."VAT Prod. Posting Group");
      ItemNew.Description := ItemNew."No.";
      ItemNew.MODIFY;
      Item.GET(ItemNew."No.");

Example

The below example is extracted from the test automation codeunit 138000 to show one way of using this function.

      Initialize;

      LibrarySmallBusiness.CreateItem(Item);
      LibrarySmallBusiness.CreateItemAsService(ItemAsService);

      MiniItemList.OPENVIEW;
      MiniItemList.GOTORECORD(ItemAsService);
      MiniItemList.Type.ASSERTEQUALS(ItemAsService.Type);
      MiniItemList.GOTORECORD(Item);
      MiniItemList.Type.ASSERTEQUALS(Item.Type);
Member of Lib.Library - Small Business


CreateItemCrossReference@22 Method

The procedure CreateItemCrossReference is available in codeunit 132213.

Syntax

CreateItemCrossReference@22(
    VAR ItemCrossReference@1000 : Record 5717 ItemCrossReference, //Reference parameter of type Record
    Item@1001 : Record 27 Item, //Input parameter of type Record
    Item2@1002 : Record 27 Item2, //Input parameter of type Record
    ReferenceType@1003 : Option ReferenceType //Input parameter of type Option
);

Parameters

ItemCrossReference
Reference parameter of type Record
Item
Input parameter of type Record
Item2
Input parameter of type Record
ReferenceType
Input parameter of type Option

Remarks

The relevant search keywords are: Create, Item, Cross, Reference.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(ItemCrossReference);
      ItemCrossReference.VALIDATE("Item No.",Item."No.");
      ItemCrossReference.VALIDATE("Cross-Reference Type",ReferenceType);
      ItemCrossReference.VALIDATE("Cross-Reference No.",Item2."No.");
      ItemCrossReference.INSERT(TRUE);

Example

There are no examples available.
Member of Lib.Library - Small Business


CreateJob@56 Method

The procedure CreateJob is available in codeunit 132213.

Syntax

CreateJob@56(
    VAR Job@1000 : Record 167 Job //Reference parameter of type Record
);

Parameters

Job
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Job.

For a clarification about how this function works, refer to the code listed below.

      LibraryJob.CreateJob(Job);

Example

The below example is extracted from the test automation codeunit 138015 to show one way of using this function.

      CreateResourceWithPrice(Resource,UnitPrice);
      LibrarySales.CreateCustomer(Cust);
      LibrarySales.CreateSalesHeader(SalesHeader,SalesHeader."Document Type"::Invoice,Cust."No.");
      LibrarySales.CreateSalesLine(SalesLine,SalesHeader,SalesLine.Type::Resource,Resource."No.",Qty);
      LibraryJob.CreateJob(Job);
      SalesLine.VALIDATE("Job No.",Job."No.");
      SalesLine.MODIFY(TRUE);
      SalesInvoiceHeader.GET(LibrarySmallBusiness.PostSalesInvoice(SalesHeader));
Member of Lib.Library - Small Business


CreatePurchaseCrMemoHeader@34 Method

The procedure CreatePurchaseCrMemoHeader is available in codeunit 132213.

Syntax

CreatePurchaseCrMemoHeader@34(
    VAR PurchHeader@1000 : Record 38 PurchHeader, //Reference parameter of type Record
    Vend@1001 : Record 23 Vend //Input parameter of type Record
);

Parameters

PurchHeader
Reference parameter of type Record
Vend
Input parameter of type Record

Remarks

The relevant search keywords are: Crediteate, Purchase, Credit, Memo, Header.

For a clarification about how this function works, refer to the code listed below.

      LibraryPurchase.CreatePurchHeader(PurchHeader,PurchHeader."Document Type"::"Credit Memo",Vend."No.");

Example

The below example is extracted from the test automation codeunit 138024 to show one way of using this function.

      NumberOfLines := LibraryRandom.RandIntInRange(1,30);

      LibrarySmallBusiness.CreatePurchaseCrMemoHeader(PurchaseHeader,Vendor);

      FOR I := 1 TO NumberOfLines DO
        LibrarySmallBusiness.CreatePurchaseLine(PurchaseLine,PurchaseHeader,Item,ItemQuantity);
Member of Lib.Library - Small Business


CreatePurchaseInvoiceHeader@39 Method

The procedure CreatePurchaseInvoiceHeader is available in codeunit 132213.

Syntax

CreatePurchaseInvoiceHeader@39(
    VAR PurchHeader@1000 : Record 38 PurchHeader, //Reference parameter of type Record
    Vend@1001 : Record 23 Vend //Input parameter of type Record
);

Parameters

PurchHeader
Reference parameter of type Record
Vend
Input parameter of type Record

Remarks

The relevant search keywords are: Create, Purchase, Invoice, Header.

For a clarification about how this function works, refer to the code listed below.

      LibraryPurchase.CreatePurchHeader(PurchHeader,PurchHeader."Document Type"::Invoice,Vend."No.");

Example

The below example is extracted from the test automation codeunit 137511 to show one way of using this function.

      Initialize;

      CreateItemWithCost(Item,1);
      LibraryPurch.CreateVendor(Vend);

      // It should not be possible to cancel a get receipt invoice that is associated to an order
      CreatePurchOrderForItem(Vend,Item,1,PurchHeader,PurchLine);
      LibraryPurch.PostPurchaseDocument(PurchHeader,TRUE,FALSE);

      PurchRcptLine.SETRANGE("Order No.",PurchLine."Document No.");
      PurchRcptLine.SETRANGE("Order Line No.",PurchLine."Line No.");
      PurchRcptLine.FINDFIRST;

      LibrarySmallBusiness.CreatePurchaseInvoiceHeader(PurchHeader,Vend);
      PurchGetRcpt.SetPurchHeader(PurchHeader);
      PurchGetRcpt.CreateInvLines(PurchRcptLine);
      PurchInvHeader.GET(LibraryPurch.PostPurchaseDocument(PurchHeader,TRUE,TRUE));
      COMMIT;

      GLEntry.FINDLAST;

      // EXERCISE
      ASSERTERROR CorrectPostedPurchInvoice.CancelPostedInvoiceStartNewInvoice(PurchInvHeader,PurchHeaderTmp);
      PurchCheckNothingIsCreated(Vend,GLEntry);

      // EXERCISE
      ASSERTERROR CorrectPostedPurchInvoice.CancelPostedInvoice(PurchInvHeader);
      PurchCheckNothingIsCreated(Vend,GLEntry);
Member of Lib.Library - Small Business


CreatePurchaseLine@38 Method

The procedure CreatePurchaseLine is available in codeunit 132213.

Syntax

CreatePurchaseLine@38(
    VAR PurchaseLine@1000 : Record 39 PurchaseLine, //Reference parameter of type Record
    PurchaseHeader@1001 : Record 38 PurchaseHeader, //Input parameter of type Record
    Item@1004 : Record 27 Item, //Input parameter of type Record
    Qty@1005 : Decimal Qty //Input parameter of type Decimal
);

Parameters

PurchaseLine
Reference parameter of type Record
PurchaseHeader
Input parameter of type Record
Item
Input parameter of type Record
Qty
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Purchase, Line.

For a clarification about how this function works, refer to the code listed below.

      // unable to use the page testability to perform this action because of following reason
      // PageTestability can't handle modal dialogs such as availability warnings when creating a sales invoice line.
      // Also, it can currently not return the Sales Line record (we need additional GetRecord or GetKey capability in PageTestability)
      LibraryPurchase.CreatePurchaseLine(PurchaseLine,PurchaseHeader,PurchaseLine.Type::Item,Item."No.",Qty);

Example

The below example is extracted from the test automation codeunit 134100 to show one way of using this function.

      // Verify the status Open error when one more purchase line added on Pending Preypayment Purchase Order.

      // Setup: Create Purchase order with Prepayment %.
      Initialize;

      CreatePrepmtVATSetup(LineGLAccount,LineGLAccount."Gen. Posting Type"::Purchase);
      ItemNo := CreateItemWithPostingSetup(LineGLAccount);
      CreatePurchaseHeader(
        CreateVendorWithPostingSetup(LineGLAccount),PurchaseHeader,
        PurchaseHeader."Document Type"::Order,FALSE,LibraryRandom.RandDec(10,2));
      CreatePurchaseLineItem(PurchaseLine,PurchaseHeader,ItemNo,LibraryRandom.RandDec(100,2));
      LibraryPurchase.PostPurchasePrepaymentInvoice(PurchaseHeader);

      // Exercise: Add one more purchase line.
      ASSERTERROR LibraryPurchase.CreatePurchaseLine(
          PurchaseLine,PurchaseHeader,PurchaseLine.Type::Item,PurchaseLine."No.",LibraryRandom.RandDec(100,2));

      // Verify: Verifying Open status error for prepayment.
      Assert.ExpectedError(
        STRSUBSTNO(
          PrepaymentStatusErr,PurchaseHeader.TABLECAPTION,PurchaseHeader."Document Type",PurchaseHeader."No."));
Member of Lib.Library - Small Business


CreateResponsabilityCenter@27 Method

The procedure CreateResponsabilityCenter is available in codeunit 132213.

Syntax

CreateResponsabilityCenter@27(
    VAR ResponsibilityCenter@1000 : Record 5714 ResponsibilityCenter //Reference parameter of type Record
);

Parameters

ResponsibilityCenter
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Responsability, Center.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(ResponsibilityCenter);
      ResponsibilityCenter.VALIDATE(Code,LibraryUtility.GenerateRandomCode(ResponsibilityCenter.FIELDNO(Code),
          DATABASE::"Responsibility Center"));
      ResponsibilityCenter.INSERT;

Example

The below example is extracted from the test automation codeunit 138000 to show one way of using this function.

      Initialize;

      LibrarySmallBusiness.CreateCustomer(Cust);
      Cust.Name := Cust."No.";
      Cust.MODIFY(TRUE);

      LibrarySmallBusiness.CreateItem(Item);

      UserSetup.RESET;
      UserSetup.SETRANGE("User ID",USERID);
      UserSetup.FINDFIRST;

      MiniSalesInvoice.OPENNEW;
      MiniSalesInvoice."Sell-to Customer Name".SETVALUE(Cust.Name);
      SalesHeader.SETRANGE("Sell-to Customer No.",Cust."No.");
      SalesHeader.FINDFIRST;
      MiniSalesInvoice.CLOSE;

      Assert.AreEqual(UserSetup."Sales Resp. Ctr. Filter",SalesHeader."Responsibility Center",'');

      LibrarySmallBusiness.CreateResponsabilityCenter(ResponsibilityCenter);

      SavedResponsibilityCenterCode := UserSetup."Sales Resp. Ctr. Filter";
      UserSetup.VALIDATE("Sales Resp. Ctr. Filter",ResponsibilityCenter.Code);
      UserSetup.MODIFY;

      MiniSalesInvoice.OPENEDIT;
      Assert.IsFalse(MiniSalesInvoice.GOTORECORD(SalesHeader),'');
      MiniSalesInvoice.CLOSE;

      // Tear Down
      UserSetup.VALIDATE("Sales Resp. Ctr. Filter",SavedResponsibilityCenterCode);
      UserSetup.MODIFY;
Member of Lib.Library - Small Business


CreateSalesCommentLine@29 Method

The procedure CreateSalesCommentLine is available in codeunit 132213.

Syntax

CreateSalesCommentLine@29(
    VAR SalesCommentLine@1000 : Record 44 SalesCommentLine, //Reference parameter of type Record
    SalesLine@1002 : Record 37 SalesLine //Input parameter of type Record
);

Parameters

SalesCommentLine
Reference parameter of type Record
SalesLine
Input parameter of type Record

Remarks

The relevant search keywords are: Create, Sales, Comment, Line.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(SalesCommentLine);
      SalesCommentLine.SETRANGE("Document Type",SalesLine."Document Type");
      SalesCommentLine.SETRANGE("No.",SalesLine."No.");
      SalesCommentLine.SETRANGE("Document Line No.",SalesLine."Line No.");
      IF SalesCommentLine.FINDLAST THEN
        NextLineNo := SalesCommentLine."Line No." + 10000
      ELSE
        NextLineNo := 10000;

      CLEAR(SalesCommentLine);
      SalesCommentLine.INIT;
      SalesCommentLine."Document Type" := SalesLine."Document Type";
      SalesCommentLine."No." := SalesLine."Document No.";
      SalesCommentLine."Document Line No." := SalesLine."Line No.";
      SalesCommentLine."Line No." := NextLineNo;
      SalesCommentLine.Date := LibraryUtility.GenerateRandomDate(WORKDATE + 10,WORKDATE + 20);
      SalesCommentLine.Comment := LibraryUtility.GenerateRandomCode(SalesCommentLine.FIELDNO(Comment),DATABASE::"Sales Comment Line");
      SalesCommentLine.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 138000 to show one way of using this function.

      Initialize;

      LibrarySmallBusiness.CreateCustomer(Cust);
      Cust.Name := Cust."No.";
      Cust.MODIFY(TRUE);
      LibrarySmallBusiness.CreateItem(Item);

      NoOfLines := LibraryRandom.RandIntInRange(2,10);
      ItemQuantity := LibraryRandom.RandIntInRange(2,100);

      LibrarySmallBusiness.CreateItem(Item);
      LibrarySmallBusiness.CreateSalesQuoteHeaderWithLines(QuoteSalesHeader,Cust,Item,ItemQuantity,NoOfLines);
      QuoteSalesLine.SETRANGE("Document Type",QuoteSalesLine."Document Type"::Quote);
      QuoteSalesLine.SETRANGE("Document No.",QuoteSalesHeader."No.");
      QuoteSalesLine.FINDFIRST;
      LibrarySmallBusiness.CreateSalesCommentLine(SalesCommentLine,QuoteSalesLine);
      TempSalesCommentLine := SalesCommentLine;

      MiniSalesQuote.OPENEDIT;
      MiniSalesQuote.GOTORECORD(QuoteSalesHeader);

      MiniSalesInvoice.TRAP;
      LibraryVariableStorage.Enqueue(TRUE);
      LibraryVariableStorage.Enqueue(TRUE);
      MiniSalesQuote.MakeInvoice.INVOKE;
      MiniSalesInvoice.CLOSE;

      InvoiceSalesHeader.SETRANGE("Sell-to Customer No.",Cust."No.");
      InvoiceSalesHeader.SETRANGE("Document Type",InvoiceSalesHeader."Document Type"::Invoice);
      Assert.AreEqual(1,InvoiceSalesHeader.COUNT,'Only one header record should be present');
      InvoiceSalesHeader.FINDFIRST;

      InvoiceSalesCommentLine.SETRANGE("Document Type",SalesCommentLine."Document Type"::Invoice);
      InvoiceSalesCommentLine.SETRANGE("No.",InvoiceSalesHeader."No.");
      Assert.AreEqual(1,InvoiceSalesCommentLine.COUNT,'Only one Comment line should be present');
      InvoiceSalesCommentLine.FINDFIRST;

      Assert.AreEqual(InvoiceSalesCommentLine.Date,TempSalesCommentLine.Date,'Date was not set');
      Assert.AreEqual(InvoiceSalesCommentLine.Comment,TempSalesCommentLine.Comment,'Comment text was not transfered');
Member of Lib.Library - Small Business


CreateSalesCrMemoHeader@21 Method

The procedure CreateSalesCrMemoHeader is available in codeunit 132213.

Syntax

CreateSalesCrMemoHeader@21(
    VAR SalesHeader@1000 : Record 36 SalesHeader, //Reference parameter of type Record
    Customer@1001 : Record 18 Customer //Input parameter of type Record
);

Parameters

SalesHeader
Reference parameter of type Record
Customer
Input parameter of type Record

Remarks

The relevant search keywords are: Crediteate, Sales, Credit, Memo, Header.

For a clarification about how this function works, refer to the code listed below.

      LibrarySales.CreateSalesHeader(SalesHeader,SalesHeader."Document Type"::"Credit Memo",Customer."No.");

Example

The below example is extracted from the test automation codeunit 138000 to show one way of using this function.

      LibrarySmallBusiness.CreateCustomer(Customer);
      LibrarySmallBusiness.CreateItem(Item);
      LibrarySmallBusiness.CreateSalesCrMemoHeader(SalesHeader,Customer);
      LibrarySmallBusiness.CreateSalesLine(SalesLine,SalesHeader,Item,LibraryRandom.RandInt(10));
      EXIT(LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE));
Member of Lib.Library - Small Business


CreateSalesInvoiceHeader@3 Method

The procedure CreateSalesInvoiceHeader is available in codeunit 132213.

Syntax

CreateSalesInvoiceHeader@3(
    VAR SalesHeader@1000 : Record 36 SalesHeader, //Reference parameter of type Record
    Customer@1001 : Record 18 Customer //Input parameter of type Record
);

Parameters

SalesHeader
Reference parameter of type Record
Customer
Input parameter of type Record

Remarks

The relevant search keywords are: Create, Sales, Invoice, Header.

For a clarification about how this function works, refer to the code listed below.

      LibrarySales.CreateSalesHeader(SalesHeader,SalesHeader."Document Type"::Invoice,Customer."No.");

Example

The below example is extracted from the test automation codeunit 138000 to show one way of using this function.

      Initialize;

      // Create Sales Invoice and copy to another Sales Quote
      CreateCustomer(Customer);
      LibrarySmallBusiness.CreateItem(Item);
      LibrarySmallBusiness.CreateSalesInvoiceHeader(SalesHeader,Customer);
      LibrarySmallBusiness.CreateSalesLine(SalesLine,SalesHeader,Item,LibraryRandom.RandDec(100,2));

      // Create the quote
      SalesHeader2.INIT;
      SalesHeader2.VALIDATE("Document Type",SalesHeader2."Document Type"::Quote);
      SalesHeader2.INSERT(TRUE);
      COMMIT;
      MiniSalesQuote.OPENEDIT;
      MiniSalesQuote.GOTORECORD(SalesHeader2);
      MiniSalesQuote.SalesLines.FIRST;

      // Enqueue for the request page handler
      LibraryVariableStorage.Enqueue(3); // doc type on the request page
      LibraryVariableStorage.Enqueue(SalesHeader."No.");
      LibraryVariableStorage.Enqueue('');
      LibraryVariableStorage.Enqueue('');
      LibraryVariableStorage.Enqueue(TRUE);
      LibraryVariableStorage.Enqueue(FALSE);
      COMMIT;
      MiniSalesQuote.CopyDocument.INVOKE;
      MiniSalesQuote.CLOSE;

      // Verify
      SalesHeader2.GET(SalesHeader2."Document Type",SalesHeader2."No.");
      VerifySalesDocumentsMatch(SalesHeader,SalesHeader2);
Member of Lib.Library - Small Business


CreateSalesLine@16 Method

The procedure CreateSalesLine is available in codeunit 132213.

Syntax

CreateSalesLine@16(
    VAR SalesLine@1000 : Record 37 SalesLine, //Reference parameter of type Record
    SalesHeader@1001 : Record 36 SalesHeader, //Input parameter of type Record
    Item@1004 : Record 27 Item, //Input parameter of type Record
    Quantity@1005 : Decimal Quantity //Input parameter of type Decimal
);

Parameters

SalesLine
Reference parameter of type Record
SalesHeader
Input parameter of type Record
Item
Input parameter of type Record
Quantity
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Sales, Line.

For a clarification about how this function works, refer to the code listed below.

      // unable to use the page testability to perform this action because of following reason
      // PageTestability can't handle modal dialogs such as availability warnings when creating a sales invoice line.
      // Also, it can currently not return the Sales Line record (we need additional GetRecord or GetKey capability in PageTestability)
      LibrarySales.CreateSalesLine(SalesLine,SalesHeader,SalesLine.Type::Item,Item."No.",Quantity);

Example

The below example is extracted from the test automation codeunit 134100 to show one way of using this function.

      // Verify the Open status error when one more sales line added on Pending Preypayment Sales Order.

      // Setup : Create sales order
      Initialize;
      CreatePrepmtVATSetup(LineGLAccount,LineGLAccount."Gen. Posting Type"::Sale);
      CreateSalesHeaderWithPrepaymentPercentage(SalesHeader,CreateCustomerWithPostingSetup(LineGLAccount));
      CreateSalesLinesWithQtyToShip(SalesLine,SalesHeader,LineGLAccount);
      LibrarySales.PostSalesPrepaymentInvoice(SalesHeader);

      // Exercise: Add one more sales line.
      ASSERTERROR LibrarySales.CreateSalesLine(SalesLine,SalesHeader,SalesLine.Type,SalesLine."No.",SalesLine.Quantity);

      // Verify: Verifying Open status error for prepayment.
      Assert.ExpectedError(
        STRSUBSTNO(PrepaymentStatusErr,SalesHeader.TABLECAPTION,SalesHeader."Document Type",SalesHeader."No."));
Member of Lib.Library - Small Business


CreateSalesQuoteHeader@30 Method

The procedure CreateSalesQuoteHeader is available in codeunit 132213.

Syntax

CreateSalesQuoteHeader@30(
    VAR SalesHeader@1000 : Record 36 SalesHeader, //Reference parameter of type Record
    Customer@1001 : Record 18 Customer //Input parameter of type Record
);

Parameters

SalesHeader
Reference parameter of type Record
Customer
Input parameter of type Record

Remarks

The relevant search keywords are: Create, Sales, Quote, Header.

For a clarification about how this function works, refer to the code listed below.

      LibrarySales.CreateSalesHeader(SalesHeader,SalesHeader."Document Type"::Quote,Customer."No.");

Example

The below example is extracted from the test automation codeunit 138000 to show one way of using this function.

      Initialize;

      LibrarySmallBusiness.CreateCustomer(Cust);
      Cust.Name := Cust."No.";
      Cust.MODIFY(TRUE);

      LibrarySmallBusiness.CreateSalesQuoteHeader(SalesHeader,Cust);

      MiniSalesQuotesList.OPENVIEW;
      MiniSalesQuotesList.FILTER.SETFILTER("No.",SalesHeader."No.");
      LibraryVariableStorage.Enqueue(FALSE);
      MiniSalesQuotesList.MakeInvoice.INVOKE;
Member of Lib.Library - Small Business


CreateSalesQuoteHeaderWithLines@28 Method

The procedure CreateSalesQuoteHeaderWithLines is available in codeunit 132213.

Syntax

CreateSalesQuoteHeaderWithLines@28(
    VAR SalesHeader@1000 : Record 36 SalesHeader, //Reference parameter of type Record
    Customer@1001 : Record 18 Customer, //Input parameter of type Record
    Item@1003 : Record 27 Item, //Input parameter of type Record
    NumberOfLines@1002 : Integer NumberOfLines, //Input parameter of type Integer
    ItemQuantity@1004 : Integer ItemQuantity //Input parameter of type Integer
);

Parameters

SalesHeader
Reference parameter of type Record
Customer
Input parameter of type Record
Item
Input parameter of type Record
NumberOfLines
Input parameter of type Integer
ItemQuantity
Input parameter of type Integer

Remarks

The relevant search keywords are: Create, Sales, Quote, Header, Lines.

For a clarification about how this function works, refer to the code listed below.

      LibrarySales.CreateSalesHeader(SalesHeader,SalesHeader."Document Type"::Quote,Customer."No.");

      FOR I := 1 TO NumberOfLines DO
        LibrarySales.CreateSalesLine(SalesLine,SalesHeader,SalesLine.Type::Item,Item."No.",ItemQuantity);

Example

The below example is extracted from the test automation codeunit 138000 to show one way of using this function.

      Initialize;

      LibrarySmallBusiness.CreateCustomer(Cust);
      Cust.Name := Cust."No.";
      Cust.MODIFY(TRUE);
      LibrarySmallBusiness.CreateItem(Item);

      NoOfLines := LibraryRandom.RandIntInRange(2,10);
      ItemQuantity := LibraryRandom.RandIntInRange(2,100);

      LibrarySmallBusiness.CreateItem(Item);
      LibrarySmallBusiness.CreateSalesQuoteHeaderWithLines(QuoteSalesHeader,Cust,Item,ItemQuantity,NoOfLines);
      LibrarySmallBusiness.CreateSalesQuoteHeaderWithLines(ReferenceQuoteSalesHeader,Cust,Item,ItemQuantity,NoOfLines);
      ReferenceQuoteSalesHeader."External Document No." := QuoteSalesHeader."External Document No.";
      ReferenceQuoteSalesHeader.MODIFY;

      MiniSalesQuote.OPENEDIT;
      MiniSalesQuote.GOTORECORD(QuoteSalesHeader);

      MiniSalesInvoice.TRAP;
      LibraryVariableStorage.Enqueue(TRUE);
      LibraryVariableStorage.Enqueue(TRUE);
      MiniSalesQuote.MakeInvoice.INVOKE;

      MiniSalesInvoice.CLOSE;

      InvoiceSalesHeader.SETRANGE("Sell-to Customer No.",Cust."No.");
      InvoiceSalesHeader.SETRANGE("Document Type",InvoiceSalesHeader."Document Type"::Invoice);
      Assert.AreEqual(1,InvoiceSalesHeader.COUNT,'Only one header record should be present');
      InvoiceSalesHeader.FINDFIRST;

      VerifySalesDocumentsMatch(ReferenceQuoteSalesHeader,InvoiceSalesHeader);
      Assert.AreEqual(
        InvoiceSalesHeader."Posting Date",WORKDATE,'Posting date should be assigned to workdate if it was not set by invoice');
Member of Lib.Library - Small Business


CreateStandardPurchaseCode@43 Method

The procedure CreateStandardPurchaseCode is available in codeunit 132213.

Syntax

CreateStandardPurchaseCode@43(
    VAR StandardPurchaseCode@1000 : Record 173 StandardPurchaseCode //Reference parameter of type Record
);

Parameters

StandardPurchaseCode
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Standard, Purchase, Code.

For a clarification about how this function works, refer to the code listed below.

      StandardPurchaseCode.INIT;
      StandardPurchaseCode.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(StandardPurchaseCode.FIELDNO(Code),DATABASE::"Standard Purchase Code"),
          1,
          LibraryUtility.GetFieldLength(DATABASE::"Standard Purchase Code",StandardPurchaseCode.FIELDNO(Code))));
      StandardPurchaseCode.VALIDATE(Description,StandardPurchaseCode.Code);
      StandardPurchaseCode.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 138000 to show one way of using this function.

      Initialize;

      // Create data
      LibrarySmallBusiness.CreateItem(Item);
      CreateVendor(Vendor);
      LibrarySmallBusiness.CreateStandardPurchaseCode(StandardPurchaseCode);
      LibrarySmallBusiness.CreateVendorPurchaseCode(StandardVendorPurchaseCode,Vendor."No.",StandardPurchaseCode.Code);
      CreatePurchaseStandardCodeWithItemAndDescr(StandardPurchaseCode,Item);

      // Exercise
      LibrarySmallBusiness.CreatePurchaseInvoiceHeader(PurchaseHeader,Vendor);
      MiniPurchaseInvoice.OPENEDIT;
      MiniPurchaseInvoice.GOTORECORD(PurchaseHeader);
      MiniPurchaseInvoice.GetRecurringPurchaseLines.INVOKE;

      // Verify
      VerifyPurchaseInvoiceLinesFromStandardCodes(PurchaseHeader,StandardPurchaseCode);
Member of Lib.Library - Small Business


CreateStandardPurchaseLine@42 Method

The procedure CreateStandardPurchaseLine is available in codeunit 132213.

Syntax

CreateStandardPurchaseLine@42(
    VAR StandardPurchaseLine@1000 : Record 174 StandardPurchaseLine, //Reference parameter of type Record
    StandardPurchaseCode@1001 : Code[10] StandardPurchaseCode //Input parameter of type Code
);

Parameters

StandardPurchaseLine
Reference parameter of type Record
StandardPurchaseCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Standard, Purchase, Line.

For a clarification about how this function works, refer to the code listed below.

      StandardPurchaseLine.INIT;
      StandardPurchaseLine.VALIDATE("Standard Purchase Code",StandardPurchaseCode);
      RecRef.GETTABLE(StandardPurchaseLine);
      StandardPurchaseLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,StandardPurchaseLine.FIELDNO("Line No.")));
      StandardPurchaseLine.INSERT(TRUE);

Example

There are no examples available.
Member of Lib.Library - Small Business


CreateStandardSalesCode@10 Method

The procedure CreateStandardSalesCode is available in codeunit 132213.

Syntax

CreateStandardSalesCode@10(
    VAR StandardSalesCode@1000 : Record 170 StandardSalesCode //Reference parameter of type Record
);

Parameters

StandardSalesCode
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Standard, Sales, Code.

For a clarification about how this function works, refer to the code listed below.

      StandardSalesCode.INIT;
      StandardSalesCode.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(StandardSalesCode.FIELDNO(Code),DATABASE::"Standard Sales Code"),
          1,
          LibraryUtility.GetFieldLength(DATABASE::"Standard Sales Code",StandardSalesCode.FIELDNO(Code))));
      StandardSalesCode.VALIDATE(Description,StandardSalesCode.Code);
      StandardSalesCode.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 138000 to show one way of using this function.

      Initialize;

      // Create data
      LibrarySmallBusiness.CreateItem(Item);
      CreateCustomer(Customer);
      LibrarySmallBusiness.CreateStandardSalesCode(StandardSalesCode);
      LibrarySmallBusiness.CreateCustomerSalesCode(StandardCustomerSalesCode,Customer."No.",StandardSalesCode.Code);
      CreateStandardCodeWithItemAndDescr(StandardSalesCode,Item);

      // Exercise
      LibrarySmallBusiness.CreateSalesInvoiceHeader(SalesHeader,Customer);
      MiniSalesInvoice.OPENEDIT;
      MiniSalesInvoice.GOTORECORD(SalesHeader);
      MiniSalesInvoice.GetRecurringSalesLines.INVOKE;

      // Verify
      VerifyInvoiceLinesFromStandardCodes(SalesHeader,StandardSalesCode);
Member of Lib.Library - Small Business


CreateStandardSalesLine@15 Method

The procedure CreateStandardSalesLine is available in codeunit 132213.

Syntax

CreateStandardSalesLine@15(
    VAR StandardSalesLine@1000 : Record 171 StandardSalesLine, //Reference parameter of type Record
    StandardSalesCode@1001 : Code[10] StandardSalesCode //Input parameter of type Code
);

Parameters

StandardSalesLine
Reference parameter of type Record
StandardSalesCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Standard, Sales, Line.

For a clarification about how this function works, refer to the code listed below.

      StandardSalesLine.INIT;
      StandardSalesLine.VALIDATE("Standard Sales Code",StandardSalesCode);
      RecRef.GETTABLE(StandardSalesLine);
      StandardSalesLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,StandardSalesLine.FIELDNO("Line No.")));
      StandardSalesLine.INSERT(TRUE);

Example

There are no examples available.
Member of Lib.Library - Small Business


CreateVATPostingSetup@45 Method

The procedure CreateVATPostingSetup is available in codeunit 132213.

Syntax

CreateVATPostingSetup@45(
    VAR VATPostingSetup@1000 : Record 325 VATPostingSetup //Reference parameter of type Record
);

Parameters

VATPostingSetup
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, VAT, Posting, Setup.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.CreateVATPostingSetupWithAccounts(
        VATPostingSetup,VATPostingSetup."VAT Calculation Type"::"Normal VAT",LibraryRandom.RandIntInRange(1,25));

Example

The below example is extracted from the test automation codeunit 136101 to show one way of using this function.

      LibraryService.CreateServiceHeader(ServiceHeader,ServiceHeader."Document Type"::Order,LibrarySales.CreateCustomerNo);
      LibraryInventory.CreateItem(Item);
      IF NOT VATPostingSetup.GET(ServiceHeader."VAT Bus. Posting Group",Item."VAT Prod. Posting Group") THEN
        LibraryERM.CreateVATPostingSetup(VATPostingSetup,ServiceHeader."VAT Bus. Posting Group",Item."VAT Prod. Posting Group");
      LibraryService.CreateServiceLine(ServiceLine,ServiceHeader,ServiceLine.Type::Item,Item."No.");
Member of Lib.Library - Small Business


CreateVendor@32 Method

The procedure CreateVendor is available in codeunit 132213.

Syntax

CreateVendor@32(
    VAR Vendor@1000 : Record 23 Vendor //Reference parameter of type Record
);

Parameters

Vendor
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Vendor.

For a clarification about how this function works, refer to the code listed below.

      LibraryPurchase.CreateVendor(Vendor);

Example

The below example is extracted from the test automation codeunit 134100 to show one way of using this function.

      // Verify that receipts with different "Prices Including VAT" value can be combined into purchase invoice

      // [GIVEN] Receive two purchase orders with single line and different values of "Prices Including VAT"
      // [GIVEN] Create purchase invoice with Prices Including VAT
      // [GIVEN] Get receipt line with the sames "Prices Including VAT"
      Initialize;
      LibraryPurchase.CreateVendor(Vendor);
      PostedDocNo[1] :=
        CreateAndReceivePurchOrderWithSpecificPricesInclVAT(PurchOrderHeader[1],Vendor."No.",TRUE);
      PostedDocNo[2] :=
        CreateAndReceivePurchOrderWithSpecificPricesInclVAT(PurchOrderHeader[2],Vendor."No.",FALSE);
      LibraryPurchase.CreatePurchHeader(
        PurchaseInvoiceHeader,PurchaseInvoiceHeader."Document Type"::Invoice,Vendor."No.");
      PurchaseInvoiceHeader.VALIDATE("Prices Including VAT",TRUE);
      PurchaseInvoiceHeader.MODIFY(TRUE);
      GetReceiptLines(PurchOrderHeader[1],PurchaseInvoiceHeader);

      // [WHEN] Get receipt line from order with different "Prices Incl. VAT"
      GetReceiptLines(PurchOrderHeader[2],PurchaseInvoiceHeader);

      // [THEN] Verify connection to "Receipt No." in invoice
      FOR i := 1 TO ARRAYLEN(PostedDocNo) DO
        VerifyInvLineFromReceipt(PurchaseInvoiceHeader."No.",PostedDocNo[i]);
Member of Lib.Library - Small Business


CreateVendorPurchaseCode@41 Method

The procedure CreateVendorPurchaseCode is available in codeunit 132213.

Syntax

CreateVendorPurchaseCode@41(
    VAR StandardVendorPurchaseCode@1000 : Record 175 StandardVendorPurchaseCode, //Reference parameter of type Record
    VendorNo@1001 : Code[20] VendorNo, //Input parameter of type Code
    Code@1002 : Code[10] Code //Input parameter of type Code
);

Parameters

StandardVendorPurchaseCode
Reference parameter of type Record
VendorNo
Input parameter of type Code
Code
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Vendor, Purchase, Code.

For a clarification about how this function works, refer to the code listed below.

      StandardVendorPurchaseCode.INIT;
      StandardVendorPurchaseCode.VALIDATE("Vendor No.",VendorNo);
      StandardVendorPurchaseCode.VALIDATE(Code,Code);
      StandardVendorPurchaseCode.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 138000 to show one way of using this function.

      Initialize;

      // Create data
      LibrarySmallBusiness.CreateItem(Item);
      CreateVendor(Vendor);
      LibrarySmallBusiness.CreateStandardPurchaseCode(StandardPurchaseCode);
      LibrarySmallBusiness.CreateVendorPurchaseCode(StandardVendorPurchaseCode,Vendor."No.",StandardPurchaseCode.Code);
      CreatePurchaseStandardCodeWithItemAndDescr(StandardPurchaseCode,Item);

      // Exercise
      LibrarySmallBusiness.CreatePurchaseInvoiceHeader(PurchaseHeader,Vendor);
      MiniPurchaseInvoice.OPENEDIT;
      MiniPurchaseInvoice.GOTORECORD(PurchaseHeader);
      MiniPurchaseInvoice.GetRecurringPurchaseLines.INVOKE;

      // Verify
      VerifyPurchaseInvoiceLinesFromStandardCodes(PurchaseHeader,StandardPurchaseCode);
Member of Lib.Library - Small Business


CreateVendorTemplate@4 Method

The procedure CreateVendorTemplate is available in codeunit 132213.

Syntax

CreateVendorTemplate@4(
    VAR ConfigTemplateHeader@1003 : Record 8618 ConfigTemplateHeader //Reference parameter of type Record
);

Parameters

ConfigTemplateHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Vendor, Template.

For a clarification about how this function works, refer to the code listed below.

      LibraryRapidStart.CreateConfigTemplateHeader(ConfigTemplateHeader);
      ConfigTemplateHeader.VALIDATE("Table ID",DATABASE::Vendor);
      ConfigTemplateHeader.MODIFY(TRUE);

      CreateVendorTemplateLine(ConfigTemplateHeader,Vend.FIELDNO("Phone No."),
        Vend.FIELDNAME("Phone No."),'');
      CreateVendorTemplateLine(ConfigTemplateHeader,Vend.FIELDNO("Our Account No."),
        Vend.FIELDNAME("Our Account No."),'');
      CreateVendorTemplateLine(ConfigTemplateHeader,Vend.FIELDNO("Gen. Bus. Posting Group"),
        Vend.FIELDNAME("Gen. Bus. Posting Group"),FindGenBusPostingGroup);
      CreateVendorTemplateLine(ConfigTemplateHeader,Vend.FIELDNO("Vendor Posting Group"),
        Vend.FIELDNAME("Vendor Posting Group"),LibraryPurchase.FindVendorPostingGroup);

Example

The below example is extracted from the test automation codeunit 138000 to show one way of using this function.

      Initialize;
      CreateVendor(Vendor);
      LibrarySmallBusiness.CreateVendorTemplate(ConfigTemplateHeader);

      // Exercise.
      PayToVendorName := LibraryUtility.GenerateRandomCode(Vendor.FIELDNO(Name),DATABASE::Vendor);
      LibraryVariableStorage.Enqueue(TRUE); // for the confirm handler when asking whether to create a pay-to vendor on the fly
      LibraryVariableStorage.Enqueue(TRUE); // for the confirm handler when asking whether you want to change the pay-to vendor no.

      MiniPurchaseInvoice.OPENNEW;
      MiniPurchaseInvoice.PurchLines.FIRST;
      MiniPurchaseInvoice."Buy-from Vendor Name".SETVALUE(Vendor.Name);
      MiniPurchaseInvoice."Pay-to Name".SETVALUE(PayToVendorName);

      // Verify.
      LibraryVariableStorage.Dequeue(PayToVendorNo);
      PayToVendor.GET(PayToVendorNo);
      VerifyVendorAgainstTemplate(PayToVendor,ConfigTemplateHeader);
      VerifyMiniPurchaseInvoiceAgainstPayToVendor(MiniPurchaseInvoice,PayToVendor);
Member of Lib.Library - Small Business


CreateVendorTemplateLine@8 Method

The procedure CreateVendorTemplateLine is available in codeunit 132213.

Syntax

CreateVendorTemplateLine@8(
    ConfigTemplateHeader@1000 : Record 8618 ConfigTemplateHeader, //Input parameter of type Record
    FieldNo@1002 : Integer FieldNo, //Input parameter of type Integer
    FieldName@1003 : Text[30] FieldName, //Input parameter of type Text
    DefaultValue@1004 : Text[50] DefaultValue //Input parameter of type Text
);

Parameters

ConfigTemplateHeader
Input parameter of type Record
FieldNo
Input parameter of type Integer
FieldName
Input parameter of type Text
DefaultValue
Input parameter of type Text

Remarks

The relevant search keywords are: Create, Vendor, Template, Line.

For a clarification about how this function works, refer to the code listed below.

      LibraryRapidStart.CreateConfigTemplateLine(ConfigTemplateLine,ConfigTemplateHeader.Code);
      ConfigTemplateLine.VALIDATE("Field ID",FieldNo);
      ConfigTemplateLine.VALIDATE("Field Name",FieldName);
      IF DefaultValue <> '' THEN
        ConfigTemplateLine.VALIDATE("Default Value",DefaultValue)
      ELSE
        ConfigTemplateLine.VALIDATE("Default Value",LibraryUtility.GenerateRandomCode(FieldNo,DATABASE::Vendor));
      ConfigTemplateLine.VALIDATE("Skip Relation Check",FALSE);
      ConfigTemplateLine.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - Small Business


FindGenBusPostingGroup@36 Method

The procedure FindGenBusPostingGroup is available in codeunit 132213.

Syntax

FindGenBusPostingGroup@36(
      //param element not supplied
);

Return Value

Code[10]

Remarks

The relevant search keywords are: Find, General, Business, Posting, Group.

For a clarification about how this function works, refer to the code listed below.

      GeneralPostingSetup.FINDLAST;
      EXIT(GeneralPostingSetup."Gen. Bus. Posting Group");

Example

There are no examples available.
Member of Lib.Library - Small Business


FindVATBusPostingGroupZeroVAT@6 Method

The procedure FindVATBusPostingGroupZeroVAT is available in codeunit 132213.

Syntax

FindVATBusPostingGroupZeroVAT@6(
    VATProdPostingGroupCode@1001 : Code[10] VATProdPostingGroupCode //Input parameter of type Code
);

Parameters

VATProdPostingGroupCode
Input parameter of type Code

Return Value

Code[10]

Remarks

The relevant search keywords are: Find, VAT, Business, Posting, Group, Zero, VAT.

For a clarification about how this function works, refer to the code listed below.

      VATPostingSetup.SETFILTER("VAT Bus. Posting Group",'<>%1','');
      VATPostingSetup.SETRANGE("VAT Prod. Posting Group",VATProdPostingGroupCode);
      VATPostingSetup.SETRANGE("VAT Calculation Type",VATPostingSetup."VAT Calculation Type"::"Normal VAT");
      VATPostingSetup.SETRANGE("VAT %",0);
      IF NOT VATPostingSetup.FINDLAST THEN
        CreateZeroVATPostingSetupByProdGroupCode(VATPostingSetup,VATProdPostingGroupCode);
      EXIT(VATPostingSetup."VAT Bus. Posting Group");

Example

The below example is extracted from the test automation codeunit 138004 to show one way of using this function.

      Initialize;
      SetupDataForDiscountTypePct(Item,ItemQuantity,Customer,DiscPct);
      CreateInvoiceWithRandomNumberOfLines(SalesHeader,Item,Customer,ItemQuantity,NumberOfLines);

      OpenSalesInvoice(SalesHeader,MiniSalesInvoice);

      AnswerYesToConfirmDialog;
      MiniSalesInvoice."VAT Bus. Posting Group".SETVALUE(
        LibrarySmallBusiness.FindVATBusPostingGroupZeroVAT(Item."VAT Prod. Posting Group"));
      TotalAmount := NumberOfLines * ItemQuantity * Item."Unit Price";
      CheckInvoiceDiscountTypePercentage(DiscPct,TotalAmount,MiniSalesInvoice,FALSE,'');
Member of Lib.Library - Small Business


FindVATProdPostingGroupZeroVAT@48 Method

The procedure FindVATProdPostingGroupZeroVAT is available in codeunit 132213.

Syntax

FindVATProdPostingGroupZeroVAT@48(
    VATBusPostingGroupCode@1000 : Code[10] VATBusPostingGroupCode //Input parameter of type Code
);

Parameters

VATBusPostingGroupCode
Input parameter of type Code

Return Value

Code[10]

Remarks

The relevant search keywords are: Find, VAT, Product, Posting, Group, Zero, VAT.

For a clarification about how this function works, refer to the code listed below.

      WITH VATPostingSetup DO BEGIN
        SETFILTER("VAT Bus. Posting Group",VATBusPostingGroupCode);
        SETFILTER("VAT Prod. Posting Group",'<>%1','');
        SETRANGE("VAT Calculation Type","VAT Calculation Type"::"Normal VAT");
        SETRANGE("VAT %",0);
        IF NOT FINDLAST THEN
          CreateZeroVATPostingSetupByBusGroupCode(VATPostingSetup,VATBusPostingGroupCode);
        EXIT("VAT Prod. Posting Group");
      END;

Example

There are no examples available.
Member of Lib.Library - Small Business


PostPurchaseInvoice@40 Method

The procedure PostPurchaseInvoice is available in codeunit 132213.

Syntax

PostPurchaseInvoice@40(
    VAR PurchaseHeader@1000 : Record 38 PurchaseHeader //Reference parameter of type Record
);

Parameters

PurchaseHeader
Reference parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Post, Purchase, Invoice.

For a clarification about how this function works, refer to the code listed below.

      EXIT(LibraryPurchase.PostPurchaseDocument(PurchaseHeader,FALSE,TRUE));

Example

The below example is extracted from the test automation codeunit 138015 to show one way of using this function.

      PurchSetup.GET;
      PurchSetup.VALIDATE("Ext. Doc. No. Mandatory",FALSE);
      PurchSetup.MODIFY(TRUE);

      LibrarySmallBusiness.CreateVendor(Vend);

      LibrarySmallBusiness.CreatePurchaseInvoiceHeader(PurchHeader,Vend);
      LibrarySmallBusiness.CreatePurchaseLine(PurchLine,PurchHeader,Item,Qty);

      PurchLine.VALIDATE("Unit Cost",UnitCost);
      PurchLine.MODIFY(TRUE);
      LibrarySmallBusiness.PostPurchaseInvoice(PurchHeader);
Member of Lib.Library - Small Business


PostSalesInvoice@12 Method

The procedure PostSalesInvoice is available in codeunit 132213.

Syntax

PostSalesInvoice@12(
    VAR SalesHeader@1000 : Record 36 SalesHeader //Reference parameter of type Record
);

Parameters

SalesHeader
Reference parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Post, Sales, Invoice.

For a clarification about how this function works, refer to the code listed below.

      EXIT(LibrarySales.PostSalesDocument(SalesHeader,FALSE,TRUE));

Example

The below example is extracted from the test automation codeunit 138000 to show one way of using this function.

      // [FEATURE] [Mini Customer Card]
      // [SCENARIO] Mini Customer Card should be open for Customer that is sorted by "Balance Due" and has different Balance and "Balance Due"
      Initialize;

      // [GIVEN] Create Customer which Balance and "Balance Due" are different by posting 2 sales invoices:
      LibrarySmallBusiness.CreateCustomer(Customer);
      LibrarySmallBusiness.CreateItem(TestItem);
      // [GIVEN] Sales Invoice posted on WORKDATE
      LibrarySmallBusiness.CreateSalesInvoiceHeader(SalesHeader,Customer);
      LibrarySmallBusiness.CreateSalesLine(SalesLine,SalesHeader,TestItem,LibraryRandom.RandInt(100));
      LibrarySmallBusiness.PostSalesInvoice(SalesHeader);
      // [GIVEN] Sales Invoice posted on (WORKDATE + 1)
      WORKDATE := WORKDATE + 1;
      LibrarySmallBusiness.CreateSalesInvoiceHeader(SalesHeader,Customer);
      LibrarySmallBusiness.CreateSalesLine(SalesLine,SalesHeader,TestItem,LibraryRandom.RandInt(100));
      LibrarySmallBusiness.PostSalesInvoice(SalesHeader);
      WORKDATE := WORKDATE - 1;

      // [GIVEN] Sort Customers by "Balance Due" in the Mini Customer List
      MiniCustomerList.OPENVIEW;
      MiniCustomerList.FILTER.SETFILTER("No.",Customer."No."); // decrease number of shown customers
      MiniCustomerList.FILTER.SETCURRENTKEY("Balance Due");

      // [WHEN] Run action View to open the Mini Customer Card
      // [THEN] The Card is open and shows Customers data
      VerifySortedCustomerList(MiniCustomerList);
Member of Lib.Library - Small Business


SetInvoiceDiscountToCustomer@9 Method

The procedure SetInvoiceDiscountToCustomer is available in codeunit 132213.

Syntax

SetInvoiceDiscountToCustomer@9(
    VAR Customer@1000 : Record 18 Customer, //Reference parameter of type Record
    DiscPct@1004 : Decimal DiscPct, //Input parameter of type Decimal
    MinimumAmount@1002 : Decimal MinimumAmount, //Input parameter of type Decimal
    CurrencyCode@1003 : Code[10] CurrencyCode //Input parameter of type Code
);

Parameters

Customer
Reference parameter of type Record
DiscPct
Input parameter of type Decimal
MinimumAmount
Input parameter of type Decimal
CurrencyCode
Input parameter of type Code

Remarks

The relevant search keywords are: Set, Invoice, Discount, To, Customer.

For a clarification about how this function works, refer to the code listed below.

      MiniCustomerCard.OPENEDIT;
      MiniCustomerCard.GOTORECORD(Customer);
      CustInvoiceDisc.TRAP;
      MiniCustomerCard."Page Cust. Invoice Discounts".INVOKE;
      WITH CustInvoiceDisc DO BEGIN
        NEW;
        "Currency Code".SETVALUE(CurrencyCode);
        "Minimum Amount".SETVALUE(MinimumAmount);
        "Discount %".SETVALUE(DiscPct);
        OK.INVOKE;
      END;
      MiniCustomerCard.OK.INVOKE;

Example

The below example is extracted from the test automation codeunit 138003 to show one way of using this function.

      Initialize;
      DiscPct1 := LibraryRandom.RandDecInDecimalRange(1,50,2);
      DiscPct2 := LibraryRandom.RandDecInDecimalRange(51,99,2);
      ItemUnitPrice := LibraryRandom.RandDecInRange(10,10000,2);
      ItemQuantity := LibraryRandom.RandIntInRange(1,100);

      NumberOfLines := 1;
      MinAmount1 := ItemUnitPrice * ItemQuantity * NumberOfLines - 1;
      MinAmount2 := ItemUnitPrice * ItemQuantity * NumberOfLines;

      LibrarySmallBusiness.CreateCustomer(Customer);
      LibrarySmallBusiness.SetInvoiceDiscountToCustomer(Customer,DiscPct1,MinAmount1,'');
      LibrarySmallBusiness.SetInvoiceDiscountToCustomer(Customer,DiscPct2,MinAmount2,'');

      CreateNewInvoiceWithLines(SalesHeader,Customer,NumberOfLines,ItemUnitPrice,ItemQuantity);

      SalesLine.SETRANGE("Document No.",SalesHeader."No.");
      SalesLine.SETRANGE("Document Type",SalesHeader."Document Type");
      SalesLine.FINDFIRST;

      SalesLine.VALIDATE("Line Amount",MinAmount1);
      SalesLine.MODIFY(TRUE);
      MiniSalesCalcDiscByType.ApplyDefaultInvoiceDiscount(0,SalesHeader);
      VerifyCustomerDiscountPercentage(SalesHeader,DiscPct1);

      SalesLine.VALIDATE("Line Amount",MinAmount2);
      SalesLine.MODIFY(TRUE);

      MiniSalesCalcDiscByType.ApplyDefaultInvoiceDiscount(0,SalesHeader);
      VerifyCustomerDiscountPercentage(SalesHeader,DiscPct2);
Member of Lib.Library - Small Business


SetInvoiceDiscountToVendor@33 Method

The procedure SetInvoiceDiscountToVendor is available in codeunit 132213.

Syntax

SetInvoiceDiscountToVendor@33(
    VAR Vendor@1000 : Record 23 Vendor, //Reference parameter of type Record
    DiscPct@1004 : Decimal DiscPct, //Input parameter of type Decimal
    MinimumAmount@1002 : Decimal MinimumAmount, //Input parameter of type Decimal
    CurrencyCode@1003 : Code[10] CurrencyCode //Input parameter of type Code
);

Parameters

Vendor
Reference parameter of type Record
DiscPct
Input parameter of type Decimal
MinimumAmount
Input parameter of type Decimal
CurrencyCode
Input parameter of type Code

Remarks

The relevant search keywords are: Set, Invoice, Discount, To, Vendor.

For a clarification about how this function works, refer to the code listed below.

      MiniVendorCard.OPENEDIT;
      MiniVendorCard.GOTORECORD(Vendor);
      VendInvoiceDisc.TRAP;
      MiniVendorCard."Page Vend. Invoice Discounts".INVOKE;
      WITH VendInvoiceDisc DO BEGIN
        NEW;
        "Currency Code".SETVALUE(CurrencyCode);
        "Minimum Amount".SETVALUE(MinimumAmount);
        "Discount %".SETVALUE(DiscPct);
        OK.INVOKE;
      END;
      MiniVendorCard.OK.INVOKE;

Example

The below example is extracted from the test automation codeunit 138013 to show one way of using this function.

      Initialize;
      DiscPct1 := LibraryRandom.RandDecInDecimalRange(1,50,2);
      DiscPct2 := LibraryRandom.RandDecInDecimalRange(51,99,2);
      ItemUnitPrice := LibraryRandom.RandDecInRange(10,10000,2);
      ItemQuantity := LibraryRandom.RandIntInRange(1,100);

      NumberOfLines := 1;
      MinAmount1 := ItemUnitPrice * ItemQuantity * NumberOfLines - 1;
      MinAmount2 := ItemUnitPrice * ItemQuantity * NumberOfLines;

      LibrarySmallBusiness.CreateVendor(Vendor);
      LibrarySmallBusiness.SetInvoiceDiscountToVendor(Vendor,DiscPct1,MinAmount1,'');
      LibrarySmallBusiness.SetInvoiceDiscountToVendor(Vendor,DiscPct2,MinAmount2,'');

      CreateNewInvoiceWithLines(PurchaseHeader,Vendor,NumberOfLines,ItemUnitPrice,ItemQuantity);

      PurchaseLine.SETRANGE("Document No.",PurchaseHeader."No.");
      PurchaseLine.SETRANGE("Document Type",PurchaseHeader."Document Type");
      PurchaseLine.FINDFIRST;

      PurchaseLine."Line Amount" := MinAmount1;
      PurchaseLine.MODIFY;
      MiniPurchCalcDiscByType.ApplyDefaultInvoiceDiscount(0,PurchaseHeader);
      VerifyVendorDiscountPercentage(PurchaseHeader,DiscPct1);

      PurchaseLine."Line Amount" := MinAmount2 + 1;
      PurchaseLine.MODIFY;

      MiniPurchCalcDiscByType.ApplyDefaultInvoiceDiscount(0,PurchaseHeader);
      VerifyVendorDiscountPercentage(PurchaseHeader,DiscPct2);
Member of Lib.Library - Small Business


SetVATBusPostingGrPriceSetup@102 Method

The procedure SetVATBusPostingGrPriceSetup is available in codeunit 132213.

Syntax

SetVATBusPostingGrPriceSetup@102(
    VATProdPostingGroupCode@1000 : Code[10] VATProdPostingGroupCode, //Input parameter of type Code
    PricesIncludingVAT@1001 : Boolean PricesIncludingVAT //Input parameter of type Boolean
);

Parameters

VATProdPostingGroupCode
Input parameter of type Code
PricesIncludingVAT
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, VAT, Business, Posting, Gr, Price, Setup.

For a clarification about how this function works, refer to the code listed below.

      IF NOT PricesIncludingVAT THEN
        EXIT;

      SalesSetup.GET;
      IF NOT VATPostingSetup.GET(SalesSetup."VAT Bus. Posting Gr. (Price)",VATProdPostingGroupCode) THEN BEGIN
        VATPostingSetup.INIT;
        VATPostingSetup.VALIDATE("VAT Bus. Posting Group",SalesSetup."VAT Bus. Posting Gr. (Price)");
        VATPostingSetup.VALIDATE("VAT Prod. Posting Group",VATProdPostingGroupCode);
        VATPostingSetup.INSERT;
      END;

Example

The below example is extracted from the test automation codeunit 138012 to show one way of using this function.

      LibraryInventory.CreateItem(Item2);
      CreateBlankItem(Item);
      Item.VALIDATE("Base Unit of Measure",Item2."Base Unit of Measure");
      Item.VALIDATE("Inventory Posting Group",Item2."Inventory Posting Group");
      Item.VALIDATE("Item Disc. Group",EnsureRecordExistAndGetValue(ItemDiscGroup.FIELDNO(Code),DATABASE::"Item Discount Group"));
      Item.VALIDATE("Allow Invoice Disc.",NOT Item."Allow Invoice Disc.");
      Item.VALIDATE("Price/Profit Calculation",LibraryRandom.RandIntInRange(0,1));
      Item.VALIDATE("Costing Method",LibraryRandom.RandIntInRange(0,1));
      Item.VALIDATE("Indirect Cost %",LibraryRandom.RandDecInRange(1,100,1));
      Item.VALIDATE("Gen. Prod. Posting Group",Item2."Gen. Prod. Posting Group");
      Item.VALIDATE("Automatic Ext. Texts",NOT Item."Automatic Ext. Texts");
      Item.VALIDATE("VAT Prod. Posting Group",Item2."VAT Prod. Posting Group");
      LibrarySmallBusiness.SetVATBusPostingGrPriceSetup(Item."VAT Prod. Posting Group",NOT Item."Price Includes VAT");
      Item.VALIDATE("Price Includes VAT",NOT Item."Price Includes VAT");
      Item.MODIFY(TRUE);
Member of Lib.Library - Small Business


Library - TCS Class

Lib.Library - TCS

COD143008 applies to ERM,IN.

Methods

Name | Description
CreateCurrencyAndExchangeRate@1500000 | The procedure CreateCurrencyAndExchangeRate is available in codeunit 143008.
CreateCustomer@1500009 | The procedure CreateCustomer is available in codeunit 143008.
CreateIncomeTaxAccountingPeriod@1500002 | The procedure CreateIncomeTaxAccountingPeriod is available in codeunit 143008.
CreateIncomeTaxPeriodSetup@1500003 | The procedure CreateIncomeTaxPeriodSetup is available in codeunit 143008.
CreateInitialSetup@1500001 | The procedure CreateInitialSetup is available in codeunit 143008.
CreateNODNOCSetup@1500008 | The procedure CreateNODNOCSetup is available in codeunit 143008.
CreateNoseries@1500418 | The procedure CreateNoseries is available in codeunit 143008.
CreateTaxJournalBatchTCSAdj@1500421 | The procedure CreateTaxJournalBatchTCSAdj is available in codeunit 143008.
CreateTaxJournalTemplateTCSAdj@1500420 | The procedure CreateTaxJournalTemplateTCSAdj is available in codeunit 143008.
CreateTCANNo@1500063 | The procedure CreateTCANNo is available in codeunit 143008.
CreateTCSNatureCollection@1500006 | The procedure CreateTCSNatureCollection is available in codeunit 143008.
CreateTCSNatureCollectionAndTCSSetup@1500005 | The procedure CreateTCSNatureCollectionAndTCSSetup is available in codeunit 143008.
CreateTCSSetUp@1500007 | The procedure CreateTCSSetUp is available in codeunit 143008.
Form27EQReportFieldsValidation@1500017 | The procedure Form27EQReportFieldsValidation is available in codeunit 143008.
GetCurrentFinancialYear@1500036 | The procedure GetCurrentFinancialYear is available in codeunit 143008.
GetCurrentQuarter@1500033 | The procedure GetCurrentQuarter is available in codeunit 143008.
GetIncomeTaxAccPeriod@1500021 | The procedure GetIncomeTaxAccPeriod is available in codeunit 143008.
GetRequiredDateFromWorkDate@1500010 | The procedure GetRequiredDateFromWorkDate is available in codeunit 143008.
PayTCS@1500045 | The procedure PayTCS is available in codeunit 143008.
RoundTCS@1500030 | The procedure RoundTCS is available in codeunit 143008.
UpdateAccountNumberInTCSSetup@1500004 | The procedure UpdateAccountNumberInTCSSetup is available in codeunit 143008.
UpdateNODNOCLines@1500011 | The procedure UpdateNODNOCLines is available in codeunit 143008.

See Also

Lib


CreateCurrencyAndExchangeRate@1500000 Method

The procedure CreateCurrencyAndExchangeRate is available in codeunit 143008.

Syntax

CreateCurrencyAndExchangeRate@1500000(
    VAR Currency@1500001 : Record 4 Currency //Reference parameter of type Record
);

Parameters

Currency
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Currency, Exchange, Rate.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.CreateCurrency(Currency);
      LibraryERM.FindGLAccount(GLAccount);
      Currency.VALIDATE("Residual Gains Account",GLAccount."No.");
      Currency.VALIDATE("Residual Losses Account",Currency."Residual Gains Account");
      Currency.MODIFY(TRUE);
      LibraryERM.CreateRandomExchangeRate(Currency.Code);

Example

The below example is extracted from the test automation codeunit 144063 to show one way of using this function.

      //[SCENARIO 64616] Check if the system is handling Additional Reporting Currency while calculating TCS from General Journal
      //[FEATURE] [TCS] [GENERAL JOURNAL]

      //[GIVEN] Created TCS Setup and Currency
      Initialize;
      TCSAmount := LibraryRandom.RandDec(15000,0);
      LibraryTCS.CreateCurrencyAndExchangeRate(Currency);

      //[WHEN] Update Additional Currency in GL Setup and Post General Journal Line
      LibraryVariableStorage.Enqueue(AddReportingCurrencyConfirmMsg);
      RestoreGeneralLedgerSetup(Currency.Code);
      CreateJournalLineDocuments(GenJnlLine,GenJnlLine."Document Type"::Invoice,GenJnlTemplate."Sub Type"::" ",
        NodNocHeader."No.",TCSAmount,GenJnlLine."Bal. Account Type"::"G/L Account",TcsNatureOfCollection.Code);
      LibraryERM.PostGeneralJnlLine(GenJnlLine);

      //[GIVEN] GL Entry has been created
      VerifyGLEntryCount(GenJnlLine."Document No.",3);
Member of Lib.Library - TCS


CreateCustomer@1500009 Method

The procedure CreateCustomer is available in codeunit 143008.

Syntax

CreateCustomer@1500009(
      //param element not supplied
);

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Customer.

For a clarification about how this function works, refer to the code listed below.

      LibrarySales.CreateCustomer(Customer);
      Customer.VALIDATE("P.A.N. No.",LibraryUtility.GenerateRandomCode(Customer.FIELDNO("P.A.N. No."),DATABASE::Customer));
      Customer.MODIFY(TRUE);
      EXIT(Customer."No.");

Example

The below example is extracted from the test automation codeunit 144024 to show one way of using this function.

      LibrarySales.CreateCustomer(Customer);
      Customer.VALIDATE("P.A.N. No.",'PANAPPLIED');
      Customer.MODIFY(TRUE);
      EXIT(Customer."No.");
Member of Lib.Library - TCS


CreateIncomeTaxAccountingPeriod@1500002 Method

The procedure CreateIncomeTaxAccountingPeriod is available in codeunit 143008.

Syntax

CreateIncomeTaxAccountingPeriod@1500002(
      //param element not supplied
);

Remarks

The relevant search keywords are: Create, Income, Tax, Accounting, Period.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.CreateIncomeTaxAccountingPeriod(IncomeTaxAccountingPeriod);
      IncomeTaxAccountingPeriod.VALIDATE("Starting Date",WORKDATE);
      IncomeTaxAccountingPeriod.VALIDATE("Ending Date",GetRequiredDateFromWorkDate(LibraryRandom.RandInt(5)));
      IncomeTaxAccountingPeriod.VALIDATE("Financial Year for eTDS/TCS",FORMAT(DATE2DMY(IncomeTaxAccountingPeriod."Starting Date",3)));
      IncomeTaxAccountingPeriod.VALIDATE("Assessment Year for eTDS/TCS",
        FORMAT(DATE2DMY(IncomeTaxAccountingPeriod."Ending Date",3) + 1));
      IncomeTaxAccountingPeriod.MODIFY(TRUE);
      CreateIncomeTaxPeriodSetup(IncomeTaxAccountingPeriod."No.");

Example

The below example is extracted from the test automation codeunit 144015 to show one way of using this function.

      LibraryERM.CreateIncomeTaxAccountingPeriod(IncomeTaxAccountingPeriod);
      IncomeTaxAccountingPeriod.VALIDATE("Starting Date",WORKDATE);
      IncomeTaxAccountingPeriod.VALIDATE("Ending Date",LibraryRandom.RandDate(5));
      IncomeTaxAccountingPeriod.MODIFY(TRUE);
      CreateIncomeTaxPeriodSetup(IncomeTaxAccountingPeriod."No.");
Member of Lib.Library - TCS


CreateIncomeTaxPeriodSetup@1500003 Method

The procedure CreateIncomeTaxPeriodSetup is available in codeunit 143008.

Syntax

CreateIncomeTaxPeriodSetup@1500003(
    IncomeTaxAccountingPeriodNo@150000 : Integer IncomeTaxAccountingPeriodNo //Input parameter of type Integer
);

Parameters

IncomeTaxAccountingPeriodNo
Input parameter of type Integer

Remarks

The relevant search keywords are: Create, Income, Tax, Period, Setup.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.CreateIncomeTaxPeriod(IncomeTaxPeriodSetup,IncomeTaxAccountingPeriodNo,IncomeTaxPeriodSetup.Quarter::Q1);
      IncomeTaxPeriodSetup."Starting Date" := WORKDATE;
      IncomeTaxPeriodSetup."Ending Date" := GetRequiredDateFromWorkDate(LibraryRandom.RandInt(2));
      IncomeTaxPeriodSetup.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - TCS


CreateInitialSetup@1500001 Method

The procedure CreateInitialSetup is available in codeunit 143008.

Syntax

CreateInitialSetup@1500001(
    VAR NODNOCHeader@1500000 : Record 13786 NODNOCHeader, //Reference parameter of type Record
    VAR TCSNatureCollection@1500001 : Record 16507 TCSNatureCollection, //Reference parameter of type Record
    VAR TCSSetup@1500006 : Record 16508 TCSSetup, //Reference parameter of type Record
    VAR AssesseeCode@1500003 : Record 13727 AssesseeCode, //Reference parameter of type Record
    ThresholdOverlook@1500005 : Boolean ThresholdOverlook, //Input parameter of type Boolean
    SurchargeOverlook@1500004 : Boolean SurchargeOverlook, //Input parameter of type Boolean
    MonthlyCertificate@1500002 : Boolean MonthlyCertificate //Input parameter of type Boolean
);

Parameters

NODNOCHeader
Reference parameter of type Record
TCSNatureCollection
Reference parameter of type Record
TCSSetup
Reference parameter of type Record
AssesseeCode
Reference parameter of type Record
ThresholdOverlook
Input parameter of type Boolean
SurchargeOverlook
Input parameter of type Boolean
MonthlyCertificate
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, Initial, Setup.

For a clarification about how this function works, refer to the code listed below.

      CreateIncomeTaxAccountingPeriod;
      LibraryERM.CreateAssesseeCode(AssesseeCode);
      CreateTCSNatureCollectionAndTCSSetup(TCSNatureCollection,TCSSetup,TCSNatureCollection."TCS Type"::E,AssesseeCode.Code);
      CreateNODNOCSetup(
        NODNOCHeader,NODNOCHeader.Type::Customer,CreateCustomer,AssesseeCode.Code,TCSNatureCollection.Code,
        ThresholdOverlook,SurchargeOverlook,MonthlyCertificate);

Example

The below example is extracted from the test automation codeunit 144011 to show one way of using this function.

      LibrarySetupStorage.Restore;
      IF isInitialized THEN
        EXIT;
      CompanyInformation.GET;
      CreateDeductoryCodeInCompanyInformation;
      GeneralLedgerSetup.GET;
      LibraryTCS.CreateInitialSetup(NodNocHeader,TcsNatureOfCollection,TCSSetup,AssesseeCode,TRUE,TRUE,FALSE);
      isInitialized := TRUE;

      LibrarySetupStorage.Save(DATABASE::"Company Information");
Member of Lib.Library - TCS


CreateNODNOCSetup@1500008 Method

The procedure CreateNODNOCSetup is available in codeunit 143008.

Syntax

CreateNODNOCSetup@1500008(
    VAR NODNOCHeader@150000 : Record 13786 NODNOCHeader, //Reference parameter of type Record
    Type@150001 : Option Type, //Input parameter of type Option
    No@150002 : Code[20] No, //Input parameter of type Code
    AssesseeCode@150003 : Code[10] AssesseeCode, //Input parameter of type Code
    TCSNatureCode@150004 : Code[10] TCSNatureCode, //Input parameter of type Code
    ThresholdOverlook@150005 : Boolean ThresholdOverlook, //Input parameter of type Boolean
    SurchargeOverlook@150006 : Boolean SurchargeOverlook, //Input parameter of type Boolean
    MonthlyCertificate@150007 : Boolean MonthlyCertificate //Input parameter of type Boolean
);

Parameters

NODNOCHeader
Reference parameter of type Record
Type
Input parameter of type Option
No
Input parameter of type Code
AssesseeCode
Input parameter of type Code
TCSNatureCode
Input parameter of type Code
ThresholdOverlook
Input parameter of type Boolean
SurchargeOverlook
Input parameter of type Boolean
MonthlyCertificate
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, NODNOC, Setup.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.CreateNODNOCHeader(NODNOCHeader,Type,No);
      NODNOCHeader.VALIDATE("Assesse Code",AssesseeCode);
      NODNOCHeader.MODIFY(TRUE);
      LibraryERM.CreateNODNOCLines(NODNOCLines,NODNOCHeader,TCSNatureCode);
      LibraryTDS.UpdateNODNOCLines(NODNOCLines,NODNOCHeader.Type,ThresholdOverlook,SurchargeOverlook,MonthlyCertificate);

Example

The below example is extracted from the test automation codeunit 144026 to show one way of using this function.

      LibraryERM.CreateAssesseeCode(AssesseeCode);
      LibraryTCS.CreateTCSNatureCollectionAndTCSSetup(
        TcsNatureOfCollection,TCSSetup,TcsNatureOfCollection."TCS Type"::E,AssesseeCode.Code);
      LibraryTCS.CreateNODNOCSetup(
        NodNocHeader,NodNocHeader.Type::Customer,LibraryTCS.CreateCustomer,AssesseeCode.Code,TcsNatureOfCollection.Code,
        TRUE,TRUE,FALSE);
Member of Lib.Library - TCS


CreateNoseries@1500418 Method

The procedure CreateNoseries is available in codeunit 143008.

Syntax

CreateNoseries@1500418(
      //param element not supplied
);

Return Value

Code[10]

Remarks

The relevant search keywords are: Create, Noseries.

For a clarification about how this function works, refer to the code listed below.

      LibraryUtility.CreateNoSeries(NoSeries,TRUE,TRUE,FALSE);
      LibraryUtility.CreateNoSeriesLine(NoSeriesLine,NoSeries.Code,'00001','99999');
      EXIT(NoSeries.Code);

Example

There are no examples available.
Member of Lib.Library - TCS


CreateTaxJournalBatchTCSAdj@1500421 Method

The procedure CreateTaxJournalBatchTCSAdj is available in codeunit 143008.

Syntax

CreateTaxJournalBatchTCSAdj@1500421(
    VAR TaxJournalBatch@1500220 : Record 16586 TaxJournalBatch, //Reference parameter of type Record
    JournalTemplateName@1500221 : Code[10] JournalTemplateName //Input parameter of type Code
);

Parameters

TaxJournalBatch
Reference parameter of type Record
JournalTemplateName
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Tax, Journal, Batch, TCS, Adj.

For a clarification about how this function works, refer to the code listed below.

      WITH TaxJournalBatch DO BEGIN
        INIT;
        VALIDATE("Journal Template Name",JournalTemplateName);
        VALIDATE(
          Name,COPYSTR(
            LibraryUtility.GenerateRandomCode(FIELDNO(Name),DATABASE::"Tax Journal Batch"),1,
            LibraryUtility.GetFieldLength(DATABASE::"Tax Journal Batch",FIELDNO(Name))));
        VALIDATE(Description,Name);
        INSERT(TRUE);
        VALIDATE("No. Series",CreateNoseries);
        MODIFY(TRUE);
      END;

Example

The below example is extracted from the test automation codeunit 144061 to show one way of using this function.

      LibrarySetupStorage.Restore;
      IF isInitialized THEN
        EXIT;
      GLSetup.GET;
      CompanyInformation.GET;
      CreateDeductoryCodeAndUpdateOnCompanyInformation;
      LibraryTCS.CreateIncomeTaxAccountingPeriod;
      LibraryERM.CreateAssesseeCode(AssesseeCode);
      LibraryTCS.CreateTCSNatureCollectionAndTCSSetup(TcsNatureOfCollection,TCSSetup,TCSSetup."TCS Type"::E,AssesseeCode.Code);
      LibraryTCS.CreateNODNOCSetup(NodNocHeader,NodNocHeader.Type::Customer,CreateCustomerWithTaxDetails,AssesseeCode.Code,
        TcsNatureOfCollection.Code,TRUE,TRUE,TRUE);
      LibraryTCS.CreateTaxJournalTemplateTCSAdj(TaxJournalTemplate);
      LibraryTCS.CreateTaxJournalBatchTCSAdj(TaxJournalBatch,TaxJournalTemplate.Name);
      isInitialized := TRUE;
      COMMIT;
      LibrarySetupStorage.Save(DATABASE::"Company Information");
Member of Lib.Library - TCS


CreateTaxJournalTemplateTCSAdj@1500420 Method

The procedure CreateTaxJournalTemplateTCSAdj is available in codeunit 143008.

Syntax

CreateTaxJournalTemplateTCSAdj@1500420(
    VAR TaxJournalTemplate@1500222 : Record 16585 TaxJournalTemplate //Reference parameter of type Record
);

Parameters

TaxJournalTemplate
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Tax, Journal, Template, TCS, Adj.

For a clarification about how this function works, refer to the code listed below.

      WITH TaxJournalTemplate DO BEGIN
        INIT;
        VALIDATE(
          Name,COPYSTR(
            LibraryUtility.GenerateRandomCode(FIELDNO(Name),DATABASE::"Tax Journal Template"),1,
            LibraryUtility.GetFieldLength(DATABASE::"Tax Journal Template",FIELDNO(Name))));
        VALIDATE(Description,Name);
        INSERT(TRUE);
        VALIDATE(Type,Type::"TCS Adjustments");
        MODIFY(TRUE);
      END;

Example

The below example is extracted from the test automation codeunit 144061 to show one way of using this function.

      LibrarySetupStorage.Restore;
      IF isInitialized THEN
        EXIT;
      GLSetup.GET;
      CompanyInformation.GET;
      CreateDeductoryCodeAndUpdateOnCompanyInformation;
      LibraryTCS.CreateIncomeTaxAccountingPeriod;
      LibraryERM.CreateAssesseeCode(AssesseeCode);
      LibraryTCS.CreateTCSNatureCollectionAndTCSSetup(TcsNatureOfCollection,TCSSetup,TCSSetup."TCS Type"::E,AssesseeCode.Code);
      LibraryTCS.CreateNODNOCSetup(NodNocHeader,NodNocHeader.Type::Customer,CreateCustomerWithTaxDetails,AssesseeCode.Code,
        TcsNatureOfCollection.Code,TRUE,TRUE,TRUE);
      LibraryTCS.CreateTaxJournalTemplateTCSAdj(TaxJournalTemplate);
      LibraryTCS.CreateTaxJournalBatchTCSAdj(TaxJournalBatch,TaxJournalTemplate.Name);
      isInitialized := TRUE;
      COMMIT;
      LibrarySetupStorage.Save(DATABASE::"Company Information");
Member of Lib.Library - TCS


CreateTCANNo@1500063 Method

The procedure CreateTCANNo is available in codeunit 143008.

Syntax

CreateTCANNo@1500063(
      //param element not supplied
);

Return Value

Code[10]

Remarks

The relevant search keywords are: Create, TCAN, No.

For a clarification about how this function works, refer to the code listed below.

      WITH TCANNo DO BEGIN
        INIT;
        VALIDATE(Code,LibraryUtility.GenerateRandomCode(FIELDNO(Code),DATABASE::"T.C.A.N. No."));
        VALIDATE(Description,Code);
        INSERT(TRUE);
        EXIT(Code);
      END;

Example

The below example is extracted from the test automation codeunit 144074 to show one way of using this function.

      ReportFrequency := Quater;
      FinancialYear := LibraryTCS.GetCurrentFinancialYear;
      FullName := COPYSTR(LibraryUtility.GenerateRandomAlphabeticText(20,0),1,20);
      Designation := COPYSTR(LibraryUtility.GenerateRandomAlphabeticText(10,0),1,10);
      PrintingDate := WORKDATE;
      TCANNo := CompanyInformation."T.C.A.N. No.";
      PRNNo := COPYSTR(LibraryUtility.GenerateRandomAlphabeticText(20,0),1,20);
      CASE FieldNumber OF
        1:
          ReportFrequency := ReportFrequency::" ";
        2:
          FinancialYear := '';
        3:
          FullName := '';
        4:
          Designation := '';
        5:
          PrintingDate := 0D;
        6:
          TCANNo := '';
        7:
          TCANNo := LibraryTCS.CreateTCANNo;
        8:
          FinancialYear := FORMAT(DATE2DMY(CALCDATE('<1Y>',WORKDATE),3));
        9:
          PRNNo := '';
      END;
      LibraryVariableStorage.Enqueue(FinancialYear);
      LibraryVariableStorage.Enqueue(ReportFrequency);
      EnqueueValuesInUpdateForm27EQ(FileeTCS,FullName,Designation,PrintingDate,TCANNo,PRNNo);
      EXIT(PRNNo);
Member of Lib.Library - TCS


CreateTCSNatureCollection@1500006 Method

The procedure CreateTCSNatureCollection is available in codeunit 143008.

Syntax

CreateTCSNatureCollection@1500006(
    VAR TCSNatureOfCollection@1500000 : Record 16507 TCSNatureOfCollection //Reference parameter of type Record
);

Parameters

TCSNatureOfCollection
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, TCS, Nature, Collection.

For a clarification about how this function works, refer to the code listed below.

      TCSNatureOfCollection.INIT;
      TCSNatureOfCollection.VALIDATE(
        Code,
        COPYSTR(LibraryUtility.GenerateRandomCode(TCSNatureOfCollection.FIELDNO(Code),DATABASE::"TCS Nature Of Collection"),
        1,
        LibraryUtility.GetFieldLength(DATABASE::"TCS Nature Of Collection",TCSNatureOfCollection.FIELDNO(Code))));
      TCSNatureOfCollection.VALIDATE(Description,TCSNatureOfCollection.Code);
      TCSNatureOfCollection.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 144051 to show one way of using this function.

      LibraryTCS.CreateIncomeTaxAccountingPeriod;
      LibraryERM.CreateAssesseeCode(AssesseeCode);
      LibraryTCS.CreateTCSNatureCollection(TcsNatureOfCollection);
      TcsNatureOfCollection.VALIDATE("TCS Type",TcsNatureOfCollection."TCS Type"::E);
      TcsNatureOfCollection.MODIFY(TRUE);
      CreateTCSSetUp(TCSSetup,TcsNatureOfCollection.Code,AssesseeCode.Code,TcsNatureOfCollection."TCS Type",ConcessionCode);
      LibraryTCS.CreateNODNOCSetup(NodNocHeader,NodNocHeader.Type::Customer,LibraryTCS.CreateCustomer,AssesseeCode.Code,
        TcsNatureOfCollection.Code,TRUE,TRUE,TRUE);
      IF ConcessionCode <> '' THEN
        UpdateNODNOCLines(NodNocHeader,ConcessionCode);
Member of Lib.Library - TCS


CreateTCSNatureCollectionAndTCSSetup@1500005 Method

The procedure CreateTCSNatureCollectionAndTCSSetup is available in codeunit 143008.

Syntax

CreateTCSNatureCollectionAndTCSSetup@1500005(
    VAR TCSNatureCollection@150000 : Record 16507 TCSNatureCollection, //Reference parameter of type Record
    VAR TCSSetup@150001 : Record 16508 TCSSetup, //Reference parameter of type Record
    TCSType@150002 : Option TCSType, //Input parameter of type Option
    AssesseeCode@150003 : Code[10] AssesseeCode //Input parameter of type Code
);

Parameters

TCSNatureCollection
Reference parameter of type Record
TCSSetup
Reference parameter of type Record
TCSType
Input parameter of type Option
AssesseeCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, TCS, Nature, Collection, TCS, Setup.

For a clarification about how this function works, refer to the code listed below.

      CreateTCSNatureCollection(TCSNatureCollection);
      TCSNatureCollection.VALIDATE("TCS Type",TCSType);
      TCSNatureCollection.MODIFY(TRUE);
      CreateTCSSetUp(TCSSetup,TCSNatureCollection.Code,AssesseeCode,TCSType);

Example

The below example is extracted from the test automation codeunit 144026 to show one way of using this function.

      LibraryERM.CreateAssesseeCode(AssesseeCode);
      LibraryTCS.CreateTCSNatureCollectionAndTCSSetup(
        TcsNatureOfCollection,TCSSetup,TcsNatureOfCollection."TCS Type"::E,AssesseeCode.Code);
      LibraryTCS.CreateNODNOCSetup(
        NodNocHeader,NodNocHeader.Type::Customer,LibraryTCS.CreateCustomer,AssesseeCode.Code,TcsNatureOfCollection.Code,
        TRUE,TRUE,FALSE);
Member of Lib.Library - TCS


CreateTCSSetUp@1500007 Method

The procedure CreateTCSSetUp is available in codeunit 143008.

Syntax

CreateTCSSetUp@1500007(
    VAR TCSSetup@150003 : Record 16508 TCSSetup, //Reference parameter of type Record
    TCSNatureCollectionCode@150002 : Code[10] TCSNatureCollectionCode, //Input parameter of type Code
    AssesseeCode@150001 : Code[10] AssesseeCode, //Input parameter of type Code
    TCSType@1500000 : Option TCSType //Input parameter of type Option
);

Parameters

TCSSetup
Reference parameter of type Record
TCSNatureCollectionCode
Input parameter of type Code
AssesseeCode
Input parameter of type Code
TCSType
Input parameter of type Option

Remarks

The relevant search keywords are: Create, TCS, Set, Up.

For a clarification about how this function works, refer to the code listed below.

      TCSSetup.INIT;
      TCSSetup.VALIDATE("TCS Nature of Collection",TCSNatureCollectionCode);
      TCSSetup.VALIDATE("Assessee Code",AssesseeCode);
      TCSSetup.VALIDATE("Effective Date",TODAY);
      TCSSetup.VALIDATE("Concessional Code",'');
      TCSSetup.VALIDATE("TCS %",LibraryRandom.RandInt(5));
      TCSSetup.VALIDATE("TCS Threshold Amount",LibraryRandom.RandDec(100000,2));
      TCSSetup.VALIDATE("Surcharge %",LibraryRandom.RandInt(5));
      TCSSetup.VALIDATE("Surcharge Threshold Amount",LibraryRandom.RandDec(200000,2));
      TCSSetup.VALIDATE("eCESS %",LibraryRandom.RandInt(5));
      TCSSetup.VALIDATE("TCS Type",TCSType);
      TCSSetup.VALIDATE("TCS Account No.",LibraryERM.CreateGLAccountNo);
      TCSSetup.VALIDATE("No. Series",LibraryERM.CreateNoSeriesCode);
      TCSSetup.VALIDATE("SHE Cess %",LibraryRandom.RandInt(5));
      TCSSetup.INSERT(TRUE);

Example

There are no examples available.
Member of Lib.Library - TCS


Form27EQReportFieldsValidation@1500017 Method

The procedure Form27EQReportFieldsValidation is available in codeunit 143008.

Syntax

Form27EQReportFieldsValidation@1500017(
      //param element not supplied
);

Remarks

The relevant search keywords are: Form27EQ, Report, Fields, Validation.

For a clarification about how this function works, refer to the code listed below.

      CompanyInfo.GET;
      WITH CompanyInfo DO BEGIN
        VALIDATE("Phone No.",PhoneNoTxt);
        VALIDATE("E-Mail",EmailTxt);
        VALIDATE("Location Code",LocationTxt);
        VALIDATE(Address,AddressTxt);
        MODIFY(TRUE);
        Location.GET("Location Code");
        Location.VALIDATE("T.C.A.N. No.","T.C.A.N. No.");
        Location.MODIFY(TRUE);
        COMMIT;
      END;

Example

The below example is extracted from the test automation codeunit 144011 to show one way of using this function.

      // [SCENARIO 163772] Error is generated when Payment Journal is created and Challan is updtaed for TCS Payment after Posting Sales Order With TCS
      // [FEATURE] [Sales Order] [Payment Journal] [TCS] [Update Challan] [Update Challan Register]

      // [GIVEN] Created Setup for TCS And Posted Sales Order With TCS
      Initialize;
      UpdateTCSAccNo;

      // [WHEN] Create Payment Journal and post,Generate e-TCS 27EQ, Update TCS Filing ,modify Company And Customerinfo
      DocumentNo := CreateAndPostSalesDocument(SalesHeader,SalesLine,SalesHeader."Document Type"::Order);
      CreateJournalForTCSPaymentWithBalAcc(GenJournalLine,GenJournalTemplate.Type::Payments,GenJournalTemplate."Sub Type"::" ");
      LibraryVariableStorage.Enqueue(GenJournalLine."Journal Template Name");
      LibraryTCS.PayTCS(GenJournalLine."Journal Batch Name");
      VerifyTCSAmountAndPost(GenJournalLine."Document No.",DocumentNo);
      UpdateTCSRegisterAndGenerateCertificate(GenJournalLine."Document No.");
      LibraryTCS.Form27EQReportFieldsValidation;
      REPORT.RUN(REPORT::"Form 27EQ");
      FileName := TEMPORARYPATH + LibraryUtility.GenerateGUID + '.txt';
      LibraryVariableStorage.Enqueue(FileName);
      COMMIT;
      REPORT.RUN(REPORT::"Generate e-TCS 27EQ",TRUE,FALSE,TCSBatchHeader);
      REPORT.RUN(REPORT::"Update TCS Filing",TRUE,TRUE,Form27EQEntry);
      ModifyCompanyAddPhone;
      ModifyCustomerAddPAN;
      COMMIT;
      REPORT.RUN(REPORT::"Form 27EQ");

      // [THEN] Error is generated when E-TCS 27EQ is run after TCS filing
      FileName := TEMPORARYPATH + LibraryUtility.GenerateGUID + '.txt';
      LibraryVariableStorage.Enqueue(FileName);
      COMMIT;
      ASSERTERROR REPORT.RUN(REPORT::"Generate e-TCS 27EQ",TRUE,TRUE,TCSBatchHeader);
      Assert.AreNotEqual(0,STRPOS(GETLASTERRORTEXT,ErrorTxt),ErrorMisMatchTxt);
Member of Lib.Library - TCS


GetCurrentFinancialYear@1500036 Method

The procedure GetCurrentFinancialYear is available in codeunit 143008.

Syntax

GetCurrentFinancialYear@1500036(
      //param element not supplied
);

Return Value

Code[6]

Remarks

The relevant search keywords are: Get, Current, Financial, Year.

For a clarification about how this function works, refer to the code listed below.

      IncomeTaxAccountingPeriod.SETFILTER("Starting Date",'<=%1',WORKDATE);
      IncomeTaxAccountingPeriod.FINDLAST;
      EXIT(IncomeTaxAccountingPeriod."Financial Year for eTDS/TCS");

Example

The below example is extracted from the test automation codeunit 144074 to show one way of using this function.

      ReportFrequency := Quater;
      FinancialYear := LibraryTCS.GetCurrentFinancialYear;
      FullName := COPYSTR(LibraryUtility.GenerateRandomAlphabeticText(20,0),1,20);
      Designation := COPYSTR(LibraryUtility.GenerateRandomAlphabeticText(10,0),1,10);
      PrintingDate := WORKDATE;
      TCANNo := CompanyInformation."T.C.A.N. No.";
      PRNNo := COPYSTR(LibraryUtility.GenerateRandomAlphabeticText(20,0),1,20);
      CASE FieldNumber OF
        1:
          ReportFrequency := ReportFrequency::" ";
        2:
          FinancialYear := '';
        3:
          FullName := '';
        4:
          Designation := '';
        5:
          PrintingDate := 0D;
        6:
          TCANNo := '';
        7:
          TCANNo := LibraryTCS.CreateTCANNo;
        8:
          FinancialYear := FORMAT(DATE2DMY(CALCDATE('<1Y>',WORKDATE),3));
        9:
          PRNNo := '';
      END;
      LibraryVariableStorage.Enqueue(FinancialYear);
      LibraryVariableStorage.Enqueue(ReportFrequency);
      EnqueueValuesInUpdateForm27EQ(FileeTCS,FullName,Designation,PrintingDate,TCANNo,PRNNo);
      EXIT(PRNNo);
Member of Lib.Library - TCS


GetCurrentQuarter@1500033 Method

The procedure GetCurrentQuarter is available in codeunit 143008.

Syntax

GetCurrentQuarter@1500033(
    VAR CurrentQuarter@1500000 : Option CurrentQuarter //Reference parameter of type Option
);

Parameters

CurrentQuarter
Reference parameter of type Option

Remarks

The relevant search keywords are: Get, Current, Quarter.

For a clarification about how this function works, refer to the code listed below.

      IncomeTaxPeriodSetup.SETFILTER("Starting Date",'<=%1',WORKDATE);
      IncomeTaxPeriodSetup.FINDLAST;
      CurrentQuarter := IncomeTaxPeriodSetup.Quarter;

Example

The below example is extracted from the test automation codeunit 144011 to show one way of using this function.

      Form27EQ."PAN No.".SETVALUE(CompanyInformation."P.A.N. No.");
      Form27EQ.Control1500010.SETVALUE(CompanyInformation."T.C.A.N. No.");
      LibraryTCS.GetCurrentQuarter(CurrentQuarter);
      Form27EQ.Control1500004.SETVALUE(CurrentQuarter);
      Form27EQ.Control1500012.SETVALUE(LibraryTCS.GetCurrentFinancialYear);
      Form27EQ.Control1500002.SETVALUE(COPYSTR(LibraryUtility.GenerateRandomAlphabeticText(30,0),1,30));
      Form27EQ.Control1500001.SETVALUE(COPYSTR(LibraryUtility.GenerateRandomAlphabeticText(10,0),1,10));
      Form27EQ.Control1500000.SETVALUE(WORKDATE);
      Form27EQ.Control1500009.SETVALUE(LibraryRandom.RandIntInRange(1000000000,2000000000));
      Form27EQ.SAVEASXML(LibraryReportDataset.GetParametersFileName,LibraryReportDataset.GetFileName);
Member of Lib.Library - TCS


GetIncomeTaxAccPeriod@1500021 Method

The procedure GetIncomeTaxAccPeriod is available in codeunit 143008.

Syntax

GetIncomeTaxAccPeriod@1500021(
      //param element not supplied
);

Return Value

Text

Remarks

The relevant search keywords are: Get, Income, Tax, Account, Period.

For a clarification about how this function works, refer to the code listed below.

      IncomeTaxAccountingPeriod.RESET;
      IncomeTaxAccountingPeriod.SETFILTER("Ending Date",'>=%1',WORKDATE);
      IncomeTaxAccountingPeriod.SETFILTER("Starting Date",'<=%1',WORKDATE);
      ASSERTERROR IncomeTaxAccountingPeriod.FINDFIRST;
      EXIT(GETLASTERRORTEXT);

Example

The below example is extracted from the test automation codeunit 144054 to show one way of using this function.

      // [SCENARIO 163745] TCS - Tax Collection at Source - Verify warning message when income tax accounting period is not defined
      // [FEATURE] [TCS - Transactions]
      Initialize;

      // [GIVEN] Created NODNOC Header,TCS Nature of Collection,TCS Setup,Assessee Code
      IncomeTaxErr := LibraryTCS.GetIncomeTaxAccPeriod;
      LibraryERM.CreateAssesseeCode(AssesseeCode);
      LibraryTCS.CreateTCSNatureCollectionAndTCSSetup(
        TcsNatureOfCollection,TCSSetup,TcsNatureOfCollection."TCS Type"::E,AssesseeCode.Code);
      LibraryTCS.CreateNODNOCSetup(
        NodNocHeader,NodNocHeader.Type::Customer,LibraryTCS.CreateCustomer,AssesseeCode.Code,TcsNatureOfCollection.Code,
        TRUE,TRUE,FALSE);

      // [WHEN] Create Sales Credit Memo and Post
      CreateSalesOrderWithLocation(
        SalesHeader,SalesHeader."Document Type"::"Credit Memo",NodNocHeader."No.",
        LibraryRandom.RandDec(400000,2),TcsNatureOfCollection.Code);
      ASSERTERROR LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      // [THEN] Expected Error, There is not Income Tax Accounting Period Exist
      Assert.ExpectedError(IncomeTaxErr);
Member of Lib.Library - TCS


GetRequiredDateFromWorkDate@1500010 Method

The procedure GetRequiredDateFromWorkDate is available in codeunit 143008.

Syntax

GetRequiredDateFromWorkDate@1500010(
    Days@150000 : Integer Days //Input parameter of type Integer
);

Parameters

Days
Input parameter of type Integer

Return Value

Date

Remarks

The relevant search keywords are: Get, Required, Date, From, Work, Date.

For a clarification about how this function works, refer to the code listed below.

      NewDate := CALCDATE('<' + FORMAT(Days) + 'D>',WORKDATE);

Example

The below example is extracted from the test automation codeunit 144074 to show one way of using this function.

      IncomeTaxAccPeriod.SETRANGE("Financial Year for eTDS/TCS",LibraryTCS.GetCurrentFinancialYear);
      IncomeTaxAccPeriod.FINDFIRST;
      GenerateCertificateNos.PartyType.SETVALUE(PartyType::Customer);
      GenerateCertificateNos.Control1280005.SETVALUE(NodNocHeader."No.");
      GenerateCertificateNos.Control1280007.SETVALUE(TCSSetup."TCS Type");
      GenerateCertificateNos.StartDate.SETVALUE(IncomeTaxAccPeriod."Starting Date");
      GenerateCertificateNos.EndDate.SETVALUE(LibraryTCS.GetRequiredDateFromWorkDate(LibraryRandom.RandInt(1)));
      GenerateCertificateNos.ReceiptNumber.SETVALUE(COPYSTR(LibraryUtility.GenerateRandomAlphabeticText(8,0),1,8));
      GenerateCertificateNos.OK.INVOKE;
Member of Lib.Library - TCS


PayTCS@1500045 Method

The procedure PayTCS is available in codeunit 143008.

Syntax

PayTCS@1500045(
    JournalBatchName@1500126 : Code[20] JournalBatchName //Input parameter of type Code
);

Parameters

JournalBatchName
Input parameter of type Code

Remarks

The relevant search keywords are: Pay, TCS.

For a clarification about how this function works, refer to the code listed below.

      COMMIT;
      PaymentJournal.OPENEDIT;
      PaymentJournal.CurrentJnlBatchName.SETVALUE(JournalBatchName);
      PayTCS.TRAP;
      PaymentJournal.Action1500045.INVOKE;
      PayTCS.Action1500147.INVOKE;

Example

The below example is extracted from the test automation codeunit 144011 to show one way of using this function.

      // [SCENARIO 163772] Error is generated when Payment Journal is created and Challan is updtaed for TCS Payment after Posting Sales Order With TCS
      // [FEATURE] [Sales Order] [Payment Journal] [TCS] [Update Challan] [Update Challan Register]

      // [GIVEN] Created Setup for TCS And Posted Sales Order With TCS
      Initialize;
      UpdateTCSAccNo;

      // [WHEN] Create Payment Journal and post,Generate e-TCS 27EQ, Update TCS Filing ,modify Company And Customerinfo
      DocumentNo := CreateAndPostSalesDocument(SalesHeader,SalesLine,SalesHeader."Document Type"::Order);
      CreateJournalForTCSPaymentWithBalAcc(GenJournalLine,GenJournalTemplate.Type::Payments,GenJournalTemplate."Sub Type"::" ");
      LibraryVariableStorage.Enqueue(GenJournalLine."Journal Template Name");
      LibraryTCS.PayTCS(GenJournalLine."Journal Batch Name");
      VerifyTCSAmountAndPost(GenJournalLine."Document No.",DocumentNo);
      UpdateTCSRegisterAndGenerateCertificate(GenJournalLine."Document No.");
      LibraryTCS.Form27EQReportFieldsValidation;
      REPORT.RUN(REPORT::"Form 27EQ");
      FileName := TEMPORARYPATH + LibraryUtility.GenerateGUID + '.txt';
      LibraryVariableStorage.Enqueue(FileName);
      COMMIT;
      REPORT.RUN(REPORT::"Generate e-TCS 27EQ",TRUE,FALSE,TCSBatchHeader);
      REPORT.RUN(REPORT::"Update TCS Filing",TRUE,TRUE,Form27EQEntry);
      ModifyCompanyAddPhone;
      ModifyCustomerAddPAN;
      COMMIT;
      REPORT.RUN(REPORT::"Form 27EQ");

      // [THEN] Error is generated when E-TCS 27EQ is run after TCS filing
      FileName := TEMPORARYPATH + LibraryUtility.GenerateGUID + '.txt';
      LibraryVariableStorage.Enqueue(FileName);
      COMMIT;
      ASSERTERROR REPORT.RUN(REPORT::"Generate e-TCS 27EQ",TRUE,TRUE,TCSBatchHeader);
      Assert.AreNotEqual(0,STRPOS(GETLASTERRORTEXT,ErrorTxt),ErrorMisMatchTxt);
Member of Lib.Library - TCS


RoundTCS@1500030 Method

The procedure RoundTCS is available in codeunit 143008.

Syntax

RoundTCS@1500030(
    Amount@1500000 : Decimal Amount //Input parameter of type Decimal
);

Parameters

Amount
Input parameter of type Decimal

Return Value

Decimal

Remarks

The relevant search keywords are: Round, TCS.

For a clarification about how this function works, refer to the code listed below.

      GLSetup.GET;
      EXIT(ROUND(Amount,GLSetup."TCS Rounding Precision"));

Example

The below example is extracted from the test automation codeunit 144024 to show one way of using this function.

      WITH ExpectedTCSEntry DO BEGIN
        "TCS Base Amount" := TaxBaseAmount;
        "TCS %" := TCSSetup."TCS %";
        "TCS Amount" := LibraryTCS.RoundTCS(TCSSetup."TCS %" / 100 * "TCS Base Amount");
        IF SurchargeOverlook THEN BEGIN
          "Surcharge %" := TCSSetup."Surcharge %";
          "Surcharge Amount" := LibraryTCS.RoundTCS(TCSSetup."Surcharge %" / 100 * "TCS Amount");
        END;
        "eCESS %" := TCSSetup."eCESS %";
        "eCESS Amount" := LibraryTCS.RoundTCS(TCSSetup."eCESS %" / 100 * ("TCS Amount" + "Surcharge Amount"));
        "SHE Cess %" := TCSSetup."SHE Cess %";
        "SHE Cess Amount" := LibraryTCS.RoundTCS(TCSSetup."SHE Cess %" / 100 * ("TCS Amount" + "Surcharge Amount"));
        "Total TCS Including SHE CESS" := "TCS Amount" + "eCESS Amount" + "SHE Cess Amount" + "Surcharge Amount";
      END;
Member of Lib.Library - TCS


UpdateAccountNumberInTCSSetup@1500004 Method

The procedure UpdateAccountNumberInTCSSetup is available in codeunit 143008.

Syntax

UpdateAccountNumberInTCSSetup@1500004(
    VAR TcsSetup@1500000 : Record 16508 TcsSetup //Reference parameter of type Record
);

Parameters

TcsSetup
Reference parameter of type Record

Remarks

The relevant search keywords are: Update, Account, Number, In, TCS, Setup.

For a clarification about how this function works, refer to the code listed below.

      TcsSetup.VALIDATE("TCS Account No.",LibraryERM.CreateGLAccountNo);
      TcsSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 144064 to show one way of using this function.

      // [SCENARIO 164364] e-filing changes with respect to FVU 3.3 - Validate generation of e-TCS (27EQ) in print format with the mandatory fields
      // [FEATURE] [TCS Transactions]

      // [GIVEN] Created Income Tax accounting period ,NODNOC ,TCS Nature of Collection,Assesse Code,TCS Setup For TCS Payment and to Generate form 27EQ Report
      Initialize;
      LibraryTCS.CreateInitialSetup(NodNocHeader,TcsNatureOfCollection,TCSSetup,AssesseeCode,TRUE,TRUE,TRUE);
      LibraryTCS.UpdateAccountNumberInTCSSetup(TCSSetup);

      // [WHEN] Create Sales Invoice and Post,Update TCS challan details
      DocumentNo :=
        CreateAndPostSalesDocWithTCS(SalesHeader,NodNocHeader."No.",TcsNatureOfCollection.Code,
          SalesHeader."Document Type"::Invoice);
      CreatePaymentJnlAndPay(GenJournalLine,TCSSetup."TCS Account No.",TcsNatureOfCollection.Code,FALSE,WORKDATE,0);
      UpdateTCSChallanDtls(GenJournalLine."Document No.",WORKDATE);
      LibraryTCS.Form27EQReportFieldsValidation;
      EnqueueValuesInFormReqPageHandlersInForm27EQ(DocumentNo);
      REPORT.RUN(REPORT::"Form 27EQ");

      // [THEN] Created TCS Batch Header with TCS Collector Phone No.,TCS Collector E-Mail,Responsible Person Phone No.,Responsible Person E-Mail.
      VerifyReportDataInForm27EQ;
Member of Lib.Library - TCS


UpdateNODNOCLines@1500011 Method

The procedure UpdateNODNOCLines is available in codeunit 143008.

Syntax

UpdateNODNOCLines@1500011(
    VAR NODNOCLines@150001 : Record 13785 NODNOCLines, //Reference parameter of type Record
    Type@150000 : Option Type //Input parameter of type Option
);

Parameters

NODNOCLines
Reference parameter of type Record
Type
Input parameter of type Option

Remarks

The relevant search keywords are: Update, NODNOC, Lines.

For a clarification about how this function works, refer to the code listed below.

      NODNOCLines.SETRANGE("No.",NODNOCLines."No.");
      NODNOCLines.SETRANGE(Type,Type);
      NODNOCLines.FINDSET;
      NODNOCLines.MODIFYALL("Monthly Certificate",TRUE);
      NODNOCLines.MODIFYALL("Threshold Overlook",TRUE);
      NODNOCLines.MODIFYALL("Surcharge Overlook",TRUE);

Example

There are no examples available.
Member of Lib.Library - TCS


Library - Text File Validation Class

Lib.Library - Text File Validation

COD131003 applies to ERM,W1,All.
// Contains functions for text file validation.

Methods

Name | Description
CountNoOfLinesWithValue@1002 | The procedure CountNoOfLinesWithValue is available in codeunit 131003.
DoesFileContainValue@3 | The procedure DoesFileContainValue is available in codeunit 131003.
FindLineContainingValue@2 | The procedure FindLineContainingValue is available in codeunit 131003.
FindLineNoWithValue@1012 | The procedure FindLineNoWithValue is available in codeunit 131003.
FindLineWithValue@1001 | The procedure FindLineWithValue is available in codeunit 131003.
FindLineWithValues@1011 | The procedure FindLineWithValues is available in codeunit 131003.
NewFindLineWithValue@1 | The procedure NewFindLineWithValue is available in codeunit 131003.
ReadField@1005 | The procedure ReadField is available in codeunit 131003.
ReadLine@1003 | The procedure ReadLine is available in codeunit 131003.
ReadTextFile@4 | The procedure ReadTextFile is available in codeunit 131003.
ReadValue@1000 | The procedure ReadValue is available in codeunit 131003.
ReadValueFromLine@1008 | The procedure ReadValueFromLine is available in codeunit 131003.

See Also

Lib


CountNoOfLinesWithValue@1002 Method

The procedure CountNoOfLinesWithValue is available in codeunit 131003.

Syntax

CountNoOfLinesWithValue@1002(
    FileName@1001 : Text FileName, //Input parameter of type Text
    Value@1003 : Text[1024] Value, //Input parameter of type Text
    StartingPosition@1004 : Integer StartingPosition, //Input parameter of type Integer
    FieldLength@1005 : Integer FieldLength //Input parameter of type Integer
);

Parameters

FileName
Input parameter of type Text
Value
Input parameter of type Text
StartingPosition
Input parameter of type Integer
FieldLength
Input parameter of type Integer

Return Value

Integer

Remarks

The relevant search keywords are: Count, No, Of, Lines, Value.

For a clarification about how this function works, refer to the code listed below.

      NoOfLines := 0;
      File.TEXTMODE(TRUE);
      File.OPEN(FileName);
      File.CREATEINSTREAM(InStr);
      WHILE NOT InStr.EOS DO BEGIN
        InStr.READTEXT(Line);
        FieldValue := COPYSTR(Line,StartingPosition,FieldLength);
        IF FieldValue = Value THEN
          NoOfLines += 1;
      END;

Example

There are no examples available.
Member of Lib.Library - Text File Validation


DoesFileContainValue@3 Method

The procedure DoesFileContainValue is available in codeunit 131003.

Syntax

DoesFileContainValue@3(
    FileName@1000 : Text FileName, //Input parameter of type Text
    Value@1003 : Text Value //Input parameter of type Text
);

Parameters

FileName
Input parameter of type Text
Value
Input parameter of type Text

Return Value

Boolean

Remarks

The relevant search keywords are: Does, File, Contain, Value.

For a clarification about how this function works, refer to the code listed below.

      StreamReader := StreamReader.StreamReader(FileName);
      Line := StreamReader.ReadLine;
      WHILE NOT ISNULL(Line) DO BEGIN
        Line := StreamReader.ReadLine;
        IF NOT ISNULL(Line) THEN
          IF Line.Contains(Value) THEN
            EXIT(TRUE);
      END;

      EXIT(FALSE);

Example

There are no examples available.
Member of Lib.Library - Text File Validation


FindLineContainingValue@2 Method

The procedure FindLineContainingValue is available in codeunit 131003.

Syntax

FindLineContainingValue@2(
    FileName@1000 : Text FileName, //Input parameter of type Text
    StartingPosition@1001 : Integer StartingPosition, //Input parameter of type Integer
    FieldLength@1002 : Integer FieldLength, //Input parameter of type Integer
    Value@1003 : Text Value //Input parameter of type Text
);

Parameters

FileName
Input parameter of type Text
StartingPosition
Input parameter of type Integer
FieldLength
Input parameter of type Integer
Value
Input parameter of type Text

Return Value

Text

Remarks

The relevant search keywords are: Find, Line, Containing, Value.

For a clarification about how this function works, refer to the code listed below.

      File.TEXTMODE(TRUE);
      File.OPEN(FileName);
      File.READ(Line);
      File.CREATEINSTREAM(InStr);
      WHILE (NOT InStr.EOS) AND (STRPOS(FieldValue,Value) = 0) DO BEGIN
        InStr.READTEXT(Line);
        FieldValue := COPYSTR(Line,StartingPosition,FieldLength);
      END;
      IF STRPOS(FieldValue,Value) = 0 THEN
        Line := '';  // If value is not found in the file, this will return an empty line.

Example

There are no examples available.
Member of Lib.Library - Text File Validation


FindLineNoWithValue@1012 Method

The procedure FindLineNoWithValue is available in codeunit 131003.

Syntax

FindLineNoWithValue@1012(
    FileName@1000 : Text[1024] FileName, //Input parameter of type Text
    StartingPosition@1001 : Integer StartingPosition, //Input parameter of type Integer
    FieldLength@1002 : Integer FieldLength, //Input parameter of type Integer
    Value@1003 : Text[1024] Value, //Input parameter of type Text
    Occurrence@1004 : Integer Occurrence //Input parameter of type Integer
);

Parameters

FileName
Input parameter of type Text
StartingPosition
Input parameter of type Integer
FieldLength
Input parameter of type Integer
Value
Input parameter of type Text
Occurrence
Input parameter of type Integer

Return Value

Integer

Remarks

The relevant search keywords are: Find, Line, No, Value.

For a clarification about how this function works, refer to the code listed below.

      OccurrenceNo := 0;
      File.TEXTMODE(TRUE);
      File.OPEN(FileName);
      File.READ(Line);
      LineNo := 0;
      File.CREATEINSTREAM(InStr);
      WHILE (NOT InStr.EOS) AND (OccurrenceNo <> Occurrence) DO BEGIN
        InStr.READTEXT(Line);
        FieldValue := COPYSTR(Line,StartingPosition,FieldLength);
        LineNo += 1;
        IF FieldValue = Value THEN
          OccurrenceNo += 1;
      END;
      IF (FieldValue <> Value) OR (OccurrenceNo <> Occurrence) THEN
        LineNo := 0;  // If value is not found in the file, this will return 0

Example

There are no examples available.
Member of Lib.Library - Text File Validation


FindLineWithValue@1001 Method

The procedure FindLineWithValue is available in codeunit 131003.

Syntax

FindLineWithValue@1001(
    FileName@1000 : Text FileName, //Input parameter of type Text
    StartingPosition@1001 : Integer StartingPosition, //Input parameter of type Integer
    FieldLength@1002 : Integer FieldLength, //Input parameter of type Integer
    Value@1003 : Text Value //Input parameter of type Text
);

Parameters

FileName
Input parameter of type Text
StartingPosition
Input parameter of type Integer
FieldLength
Input parameter of type Integer
Value
Input parameter of type Text

Return Value

Text

Remarks

The relevant search keywords are: Find, Line, Value.

For a clarification about how this function works, refer to the code listed below.

      File.TEXTMODE(TRUE);
      File.OPEN(FileName);
      File.READ(Line);
      File.CREATEINSTREAM(InStr);
      WHILE (NOT InStr.EOS) AND (FieldValue <> Value) DO BEGIN
        InStr.READTEXT(Line);
        FieldValue := COPYSTR(Line,StartingPosition,FieldLength);
      END;
      IF FieldValue <> Value THEN
        Line := '';  // If value is not found in the file, this will return an empty line.

Example

There are no examples available.
Member of Lib.Library - Text File Validation


FindLineWithValues@1011 Method

The procedure FindLineWithValues is available in codeunit 131003.

Syntax

FindLineWithValues@1011(
    FileName@1000 : Text[1024] FileName, //Input parameter of type Text
    StartingPosition@1001 : ARRAY [5] OF Integer StartingPosition, //Input Array parameter of type Integer
    FieldLength@1002 : ARRAY [5] OF Integer FieldLength, //Input Array parameter of type Integer
    ExpectedValue@1003 : ARRAY [5] OF Text ExpectedValue //Input Array parameter of type Text
);

Parameters

FileName
Input parameter of type Text
StartingPosition
Input Array parameter of type Integer
FieldLength
Input Array parameter of type Integer
ExpectedValue
Input Array parameter of type Text

Return Value

Text[1024]

Remarks

The relevant search keywords are: Find, Line, Values.

For a clarification about how this function works, refer to the code listed below.

      File.TEXTMODE(TRUE);
      File.OPEN(FileName);
      File.READ(Line);
      File.CREATEINSTREAM(InStr);
      WHILE (NOT InStr.EOS) AND NOT AreEqual DO BEGIN
        InStr.READTEXT(Line);
        GetFieldValues(Line,StartingPosition,FieldLength,ActualValue);
        AreEqual := AreEqualValues(ActualValue,ExpectedValue);
      END;
      IF NOT AreEqual THEN
        Line := '';  // If value is not found in the file, this will return an empty line.

Example

There are no examples available.
Member of Lib.Library - Text File Validation


NewFindLineWithValue@1 Method

The procedure NewFindLineWithValue is available in codeunit 131003.

Syntax

NewFindLineWithValue@1(
    FileName@1000 : Text FileName, //Input parameter of type Text
    StartingPosition@1001 : Integer StartingPosition, //Input parameter of type Integer
    FieldLength@1002 : Integer FieldLength, //Input parameter of type Integer
    Value@1003 : Text Value //Input parameter of type Text
);

Parameters

FileName
Input parameter of type Text
StartingPosition
Input parameter of type Integer
FieldLength
Input parameter of type Integer
Value
Input parameter of type Text

Return Value

Text

Remarks

The relevant search keywords are: New, Find, Line, Value.

For a clarification about how this function works, refer to the code listed below.

      NewFileName := COPYSTR(FileName,1);
      NewValue := COPYSTR(Value,1);

      EXIT(FindLineWithValue(NewFileName,StartingPosition,FieldLength,NewValue));

Example

There are no examples available.
Member of Lib.Library - Text File Validation


ReadField@1005 Method

The procedure ReadField is available in codeunit 131003.

Syntax

ReadField@1005(
    Line@1000 : Text Line, //Input parameter of type Text
    FieldPosition@1001 : Integer FieldPosition, //Input parameter of type Integer
    Delimiter@1002 : Text[1] Delimiter //Input parameter of type Text
);

Parameters

Line
Input parameter of type Text
FieldPosition
Input parameter of type Integer
Delimiter
Input parameter of type Text

Return Value

Text

Remarks

The relevant search keywords are: Read, Field.

For a clarification about how this function works, refer to the code listed below.

      CurrFieldPos := 1;
      REPEAT
        Pos := STRPOS(Line,Delimiter);
        LastField := Pos = 0;
        IF LastField THEN BEGIN
          IF FieldPosition <> CurrFieldPos THEN
            ERROR(STRSUBSTNO(NoSuchFieldPositionErr,FieldPosition));
          FieldValue := Line;
        END ELSE
          FieldValue := COPYSTR(Line,1,Pos - 1);
        Line := COPYSTR(Line,Pos + 1);
        CurrFieldPos += 1;
      UNTIL FieldPosition < CurrFieldPos;
      EXIT(FieldValue);

Example

The below example is extracted from the test automation codeunit 144049 to show one way of using this function.

      Line := LibraryTextFileValidation.ReadLine(FileName,2);
      Assert.AreEqual(LastProvRcpNo,LibraryTextFileValidation.ReadField(Line,9,'^'),'Wrong field 9');
      Assert.AreEqual(FilledRegularStatementPrevQ,LibraryTextFileValidation.ReadField(Line,52,'^'),'Wrong field 52');
Member of Lib.Library - Text File Validation


ReadLine@1003 Method

The procedure ReadLine is available in codeunit 131003.

Syntax

ReadLine@1003(
    FileName@1004 : Text FileName, //Input parameter of type Text
    LineNumber@1005 : Integer LineNumber //Input parameter of type Integer
);

Parameters

FileName
Input parameter of type Text
LineNumber
Input parameter of type Integer

Return Value

Text[1024]

Remarks

The relevant search keywords are: Read, Line.

For a clarification about how this function works, refer to the code listed below.

      File.TEXTMODE(TRUE);
      File.OPEN(FileName);
      File.CREATEINSTREAM(InStr);
      FOR i := 1 TO LineNumber DO
        InStr.READTEXT(Line);

Example

The below example is extracted from the test automation codeunit 134662 to show one way of using this function.

      Line := LibraryTextFileValidation.ReadLine(DataExch."File Name",1);
      Assert.AreNotEqual(0,STRPOS(Line,FirstValue),STRSUBSTNO(ValueNotFoundErr,FirstValue,Line));

      Line := LibraryTextFileValidation.ReadLine(DataExch."File Name",2);
      Assert.AreNotEqual(0,STRPOS(Line,SecondValue),STRSUBSTNO(ValueNotFoundErr,SecondValue,Line));
Member of Lib.Library - Text File Validation


ReadTextFile@4 Method

The procedure ReadTextFile is available in codeunit 131003.

Syntax

ReadTextFile@4(
    FilePath@1000 : Text FilePath, //Input parameter of type Text
    VAR Content@1001 : BigText Content //Reference parameter of type BigText
);

Parameters

FilePath
Input parameter of type Text
Content
Reference parameter of type BigText

Remarks

The relevant search keywords are: Read, Text, File.

For a clarification about how this function works, refer to the code listed below.

      File.OPEN(FilePath);
      File.CREATEINSTREAM(InStr);
      ContentLocal.READ(InStr); // needed for PreCAL to avoid 'VAR BigText...' complications
      Content := ContentLocal;
      File.CLOSE;
      ERASE(FilePath);

Example

There are no examples available.
Member of Lib.Library - Text File Validation


ReadValue@1000 Method

The procedure ReadValue is available in codeunit 131003.

Syntax

ReadValue@1000(
    Line@1000 : Text[1024] Line, //Input parameter of type Text
    StartingPosition@1001 : Integer StartingPosition, //Input parameter of type Integer
    Length@1002 : Integer Length //Input parameter of type Integer
);

Parameters

Line
Input parameter of type Text
StartingPosition
Input parameter of type Integer
Length
Input parameter of type Integer

Return Value

Text[1024]

Remarks

The relevant search keywords are: Read, Value.

For a clarification about how this function works, refer to the code listed below.

      FieldValue := COPYSTR(Line,StartingPosition,Length);

Example

There are no examples available.
Member of Lib.Library - Text File Validation


ReadValueFromLine@1008 Method

The procedure ReadValueFromLine is available in codeunit 131003.

Syntax

ReadValueFromLine@1008(
    FileName@1001 : Text[1024] FileName, //Input parameter of type Text
    LineNumber@1000 : Integer LineNumber, //Input parameter of type Integer
    StartingPosition@1003 : Integer StartingPosition, //Input parameter of type Integer
    Length@1004 : Integer Length //Input parameter of type Integer
);

Parameters

FileName
Input parameter of type Text
LineNumber
Input parameter of type Integer
StartingPosition
Input parameter of type Integer
Length
Input parameter of type Integer

Return Value

Text[1024]

Remarks

The relevant search keywords are: Read, Value, From, Line.

For a clarification about how this function works, refer to the code listed below.

      Line := ReadLine(FileName,LineNumber);
      FieldValue := ReadValue(Line,StartingPosition,Length);

Example

The below example is extracted from the test automation codeunit 144047 to show one way of using this function.

      ActualValue := LibraryTextFileValidation.ReadValueFromLine(FileName,LineNo,StartingPosition,1);
      Assert.AreEqual(ConcessionalCode,ActualValue,ValueNotFoundErr);
Member of Lib.Library - Text File Validation


Library - Time Sheet Class

Lib.Library - Time Sheet

COD131904 applies to RES,W1,All.

Methods

Name | Description
CheckAssemblyTimeSheetLine@62 | The procedure CheckAssemblyTimeSheetLine is available in codeunit 131904.
CheckServiceTimeSheetLine@63 | The procedure CheckServiceTimeSheetLine is available in codeunit 131904.
CreateJobJournalLine@8 | The procedure CreateJobJournalLine is available in codeunit 131904.
CreateJobPlanningLine@12 | The procedure CreateJobPlanningLine is available in codeunit 131904.
CreateServiceOrder@11 | The procedure CreateServiceOrder is available in codeunit 131904.
CreateTimeSheet@4 | The procedure CreateTimeSheet is available in codeunit 131904.
CreateTimeSheetDetail@6 | The procedure CreateTimeSheetDetail is available in codeunit 131904.
CreateTimeSheetLine@5 | The procedure CreateTimeSheetLine is available in codeunit 131904.
CreateTimeSheetResource@3 | The procedure CreateTimeSheetResource is available in codeunit 131904.
CreateUserSetup@2 | The procedure CreateUserSetup is available in codeunit 131904.
CreateWorkType@26 | The procedure CreateWorkType is available in codeunit 131904.
FindCauseOfAbsence@67 | The procedure FindCauseOfAbsence is available in codeunit 131904.
FindHRUnitOfMeasure@9 | The procedure FindHRUnitOfMeasure is available in codeunit 131904.
FindJob@128 | The procedure FindJob is available in codeunit 131904.
FindJobJournalBatch@78 | The procedure FindJobJournalBatch is available in codeunit 131904.
FindJobJournalTemplate@66 | The procedure FindJobJournalTemplate is available in codeunit 131904.
FindJobTask@137 | The procedure FindJobTask is available in codeunit 131904.
GetAccountingPeriod@7 | The procedure GetAccountingPeriod is available in codeunit 131904.
GetRandomDecimal@83 | The procedure GetRandomDecimal is available in codeunit 131904.
GetTimeSheetNoSeries@49 | The procedure GetTimeSheetNoSeries is available in codeunit 131904.
InitAssemblyBackwayScenario@65 | The procedure InitAssemblyBackwayScenario is available in codeunit 131904.
InitBackwayScenario@52 | The procedure InitBackwayScenario is available in codeunit 131904.
Initialize@1 | The procedure Initialize is available in codeunit 131904.
InitJobScenario@68 | The procedure InitJobScenario is available in codeunit 131904.
InitResourceScenario@69 | The procedure InitResourceScenario is available in codeunit 131904.
InitScenarioWTForJob@25 | The procedure InitScenarioWTForJob is available in codeunit 131904.
InitScenarioWTForServiceOrder@27 | The procedure InitScenarioWTForServiceOrder is available in codeunit 131904.
InitServiceScenario@10 | The procedure InitServiceScenario is available in codeunit 131904.
SubmitAndApproveTimeSheetLine@13 | The procedure SubmitAndApproveTimeSheetLine is available in codeunit 131904.

See Also

Lib


CheckAssemblyTimeSheetLine@62 Method

The procedure CheckAssemblyTimeSheetLine is available in codeunit 131904.

Syntax

CheckAssemblyTimeSheetLine@62(
    TimeSheetHeader@1007 : Record 950 TimeSheetHeader, //Input parameter of type Record
    AssemblyHeaderNo@1005 : Code[20] AssemblyHeaderNo, //Input parameter of type Code
    AssemblyLineNo@1004 : Integer AssemblyLineNo, //Input parameter of type Integer
    AssemblyLineQuantity@1000 : Decimal AssemblyLineQuantity //Input parameter of type Decimal
);

Parameters

TimeSheetHeader
Input parameter of type Record
AssemblyHeaderNo
Input parameter of type Code
AssemblyLineNo
Input parameter of type Integer
AssemblyLineQuantity
Input parameter of type Decimal

Remarks

The relevant search keywords are: Check, Assembly, Time, Sheet, Line.

For a clarification about how this function works, refer to the code listed below.

      TimeSheetLine.SETRANGE("Time Sheet No.",TimeSheetHeader."No.");
      TimeSheetLine.SETRANGE("Assembly Order No.",AssemblyHeaderNo);
      TimeSheetLine.SETRANGE("Assembly Order Line No.",AssemblyLineNo);
      TimeSheetLine.FINDLAST;
      TimeSheetLine.CALCFIELDS("Total Quantity");

      Assert.AreEqual(AssemblyLineQuantity,TimeSheetLine."Total Quantity",
        STRSUBSTNO(TimeSheetFieldValueErr,TimeSheetLine.FIELDCAPTION("Total Quantity")));
      Assert.IsTrue(TimeSheetLine.Chargeable,STRSUBSTNO(TimeSheetFieldValueErr,TimeSheetLine.FIELDCAPTION(Chargeable)));
      Assert.AreEqual(TimeSheetLine.Status::Approved,TimeSheetLine.Status,
        STRSUBSTNO(TimeSheetFieldValueErr,TimeSheetLine.FIELDCAPTION(Status)));
      Assert.IsTrue(TimeSheetLine.Posted,STRSUBSTNO(TimeSheetFieldValueErr,TimeSheetLine.FIELDCAPTION(Posted)));

Example

The below example is extracted from the test automation codeunit 136502 to show one way of using this function.

      Initialize;
      // create an assembly order with a resource line (Resource has property Use Time Sheet = TRUE), the time sheet of the resource exists
      LibraryTimeSheet.InitAssemblyBackwayScenario(TimeSheetHeader,AssemblyHeader,AssemblyLine,TRUE);

      // get values from assembly line (with type 'Resource') of the assembly order
      SavedAssemblyLine.COPY(AssemblyLine);

      LibraryAssembly.PostAssemblyHeader(AssemblyHeader,'');

      LibraryTimeSheet.CheckAssemblyTimeSheetLine(TimeSheetHeader,SavedAssemblyLine."Document No.",SavedAssemblyLine."Line No.",
        SavedAssemblyLine."Quantity to Consume");
Member of Lib.Library - Time Sheet


CheckServiceTimeSheetLine@63 Method

The procedure CheckServiceTimeSheetLine is available in codeunit 131904.

Syntax

CheckServiceTimeSheetLine@63(
    TimeSheetHeader@1007 : Record 950 TimeSheetHeader, //Input parameter of type Record
    ServiceHeaderNo@1005 : Code[20] ServiceHeaderNo, //Input parameter of type Code
    ServiceLineNo@1004 : Integer ServiceLineNo, //Input parameter of type Integer
    ServiceLineQuantity@1000 : Decimal ServiceLineQuantity, //Input parameter of type Decimal
    Chargeable@1001 : Boolean Chargeable //Input parameter of type Boolean
);

Parameters

TimeSheetHeader
Input parameter of type Record
ServiceHeaderNo
Input parameter of type Code
ServiceLineNo
Input parameter of type Integer
ServiceLineQuantity
Input parameter of type Decimal
Chargeable
Input parameter of type Boolean

Remarks

The relevant search keywords are: Check, Service, Time, Sheet, Line.

For a clarification about how this function works, refer to the code listed below.

      TimeSheetLine.SETRANGE("Time Sheet No.",TimeSheetHeader."No.");
      TimeSheetLine.SETRANGE("Service Order No.",ServiceHeaderNo);
      TimeSheetLine.SETRANGE("Service Order Line No.",ServiceLineNo);
      TimeSheetLine.FINDLAST;
      TimeSheetLine.CALCFIELDS("Total Quantity");

      Assert.AreEqual(ServiceLineQuantity,TimeSheetLine."Total Quantity",
        STRSUBSTNO(TimeSheetFieldValueErr,TimeSheetLine.FIELDCAPTION("Total Quantity")));
      Assert.AreEqual(Chargeable,TimeSheetLine.Chargeable,
        STRSUBSTNO(TimeSheetFieldValueErr,TimeSheetLine.FIELDCAPTION(Chargeable)));
      Assert.AreEqual(TimeSheetLine.Status::Approved,TimeSheetLine.Status,
        STRSUBSTNO(TimeSheetFieldValueErr,TimeSheetLine.FIELDCAPTION(Status)));
      Assert.IsTrue(TimeSheetLine.Posted,STRSUBSTNO(TimeSheetFieldValueErr,TimeSheetLine.FIELDCAPTION(Posted)));

Example

The below example is extracted from the test automation codeunit 136502 to show one way of using this function.

      // [FEATURE] [Order] [Service]
      // [SCENARIO] Verify time sheet total quantity after ship and consume service order with timesheet resource.

      Initialize;
      LibraryTimeSheet.InitBackwayScenario(TimeSheetHeader,ServiceHeader,ServiceLine);

      ServiceLine.VALIDATE("Qty. to Consume",ServiceLine.Quantity);
      ServiceLine.MODIFY;

      // get values from service order
      SavedServiceLine.COPY(ServiceLine);

      LibraryService.PostServiceOrder(ServiceHeader,TRUE,TRUE,FALSE);

      LibraryTimeSheet.CheckServiceTimeSheetLine(TimeSheetHeader,SavedServiceLine."Document No.",SavedServiceLine."Line No.",
        SavedServiceLine."Qty. to Consume",FALSE);
Member of Lib.Library - Time Sheet


CreateJobJournalLine@8 Method

The procedure CreateJobJournalLine is available in codeunit 131904.

Syntax

CreateJobJournalLine@8(
    VAR JobJournalLine@1000 : Record 210 JobJournalLine, //Reference parameter of type Record
    JournalTemplateName@1002 : Code[10] JournalTemplateName, //Input parameter of type Code
    JournalBatchName@1003 : Code[10] JournalBatchName //Input parameter of type Code
);

Parameters

JobJournalLine
Reference parameter of type Record
JournalTemplateName
Input parameter of type Code
JournalBatchName
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Job, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      JobJournalLine.INIT;
      JobJournalLine.VALIDATE("Journal Template Name",JournalTemplateName);
      JobJournalLine.VALIDATE("Journal Batch Name",JournalBatchName);
      RecRef.GETTABLE(JobJournalLine);
      JobJournalLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,JobJournalLine.FIELDNO("Line No.")));
      JobJournalLine.INSERT(TRUE);

Example

There are no examples available.
Member of Lib.Library - Time Sheet


CreateJobPlanningLine@12 Method

The procedure CreateJobPlanningLine is available in codeunit 131904.

Syntax

CreateJobPlanningLine@12(
    VAR JobPlanningLine@1004 : Record 1003 JobPlanningLine, //Reference parameter of type Record
    JobNo@1000 : Code[20] JobNo, //Input parameter of type Code
    JobTaskNo@1001 : Code[20] JobTaskNo, //Input parameter of type Code
    ResourceNo@1002 : Code[20] ResourceNo, //Input parameter of type Code
    PlanningDate@1003 : Date PlanningDate //Input parameter of type Date
);

Parameters

JobPlanningLine
Reference parameter of type Record
JobNo
Input parameter of type Code
JobTaskNo
Input parameter of type Code
ResourceNo
Input parameter of type Code
PlanningDate
Input parameter of type Date

Remarks

The relevant search keywords are: Create, Job, Planning, Line.

For a clarification about how this function works, refer to the code listed below.

      JobPlanningLine.SETRANGE("Job No.",JobNo);
      JobPlanningLine.SETRANGE("Job Task No.",JobTaskNo);
      IF JobPlanningLine.FINDLAST THEN;
      LineNo := JobPlanningLine."Line No." + 10000;

      JobPlanningLine.INIT;
      JobPlanningLine."Job No." := JobNo;
      JobPlanningLine."Job Task No." := JobTaskNo;
      JobPlanningLine."Line No." := LineNo;
      JobPlanningLine.Type := JobPlanningLine.Type::Resource;
      JobPlanningLine."No." := ResourceNo;
      JobPlanningLine."Planning Date" := PlanningDate;
      JobPlanningLine.INSERT;

Example

The below example is extracted from the test automation codeunit 136404 to show one way of using this function.

      LibraryJob.CreateJob(Job);

      // Assigning values to global variables. Use random value for Quantity.
      LibraryVariableStorage.Enqueue(Job."No.");
      LibraryJob.CreateJobTask(Job,JobTask);
      LibraryJob.CreateJobPlanningLine(LibraryJob.PlanningLineTypeSchedule,LibraryJob.ResourceType,JobTask,JobPlanningLine);
      JobPlanningLine.VALIDATE("No.",No2);
      JobPlanningLine.VALIDATE(Quantity,LibraryRandom.RandInt(100) + LibraryUtility.GenerateRandomFraction);
      JobPlanningLine.MODIFY(TRUE);
      LibraryVariableStorage.Enqueue(JobPlanningLine.Quantity);
Member of Lib.Library - Time Sheet


CreateServiceOrder@11 Method

The procedure CreateServiceOrder is available in codeunit 131904.

Syntax

CreateServiceOrder@11(
    VAR ServiceHeader@1000 : Record 5900 ServiceHeader, //Reference parameter of type Record
    PostingDate@1004 : Date PostingDate //Input parameter of type Date
);

Parameters

ServiceHeader
Reference parameter of type Record
PostingDate
Input parameter of type Date

Remarks

The relevant search keywords are: Create, Service, Order.

For a clarification about how this function works, refer to the code listed below.

      LibrarySales.CreateCustomer(Customer);
      LibraryService.CreateServiceHeader(ServiceHeader,ServiceHeader."Document Type"::Order,Customer."No.");
      ServiceHeader.VALIDATE("Posting Date",PostingDate);
      ServiceHeader.MODIFY;
      LibraryService.CreateServiceItem(ServiceItem,Customer."No.");
      LibraryService.CreateServiceItemLine(ServiceItemLine,ServiceHeader,ServiceItem."No.");

Example

The below example is extracted from the test automation codeunit 136500 to show one way of using this function.

      // [FEATURE] [Time Sheet] [Service Order]
      // [SCENARIO] "Create lines from time sheets" for Service Order creates service order lines, after posting Service Order TS lines are posted.

      // test for function "Create lines from time sheets" for Service Order
      SetUp;

      LibraryTimeSheet.CreateTimeSheet(TimeSheetHeader,FALSE);
      LibraryTimeSheet.CreateServiceOrder(ServiceHeader,CALCDATE('<+3D>',TimeSheetHeader."Starting Date"));

      // create time sheet line with type Service
      LibraryTimeSheet.CreateTimeSheetLine(TimeSheetHeader,TimeSheetLine,TimeSheetLine.Type::Service,'','','','');
      TimeSheetLine.VALIDATE("Service Order No.",ServiceHeader."No.");
      TimeSheetLine.MODIFY;

      // create details for 2 days
      LibraryTimeSheet.CreateTimeSheetDetail(
        TimeSheetLine,TimeSheetHeader."Starting Date",LibraryTimeSheet.GetRandomDecimal);
      LibraryTimeSheet.CreateTimeSheetDetail(
        TimeSheetLine,TimeSheetHeader."Starting Date" + 1,LibraryTimeSheet.GetRandomDecimal);
      // submit and approve
      TimeSheetApprovalMgt.Submit(TimeSheetLine);
      TimeSheetApprovalMgt.Approve(TimeSheetLine);

      // create lines from time sheet
      TimeSheetMgt.CreateServDocLinesFromTS(ServiceHeader);
      LibraryService.PostServiceOrder(ServiceHeader,TRUE,FALSE,TRUE);

      TimeSheetLine.FIND;
      // Posted should be Yes
      Assert.IsTrue(TimeSheetLine.Posted,Text008);

      TearDown;
Member of Lib.Library - Time Sheet


CreateTimeSheet@4 Method

The procedure CreateTimeSheet is available in codeunit 131904.

Syntax

CreateTimeSheet@4(
    VAR TimeSheetHeader@1005 : Record 950 TimeSheetHeader, //Reference parameter of type Record
    UseCurrentUserID@1004 : Boolean UseCurrentUserID //Input parameter of type Boolean
);

Parameters

TimeSheetHeader
Reference parameter of type Record
UseCurrentUserID
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, Time, Sheet.

For a clarification about how this function works, refer to the code listed below.

      // function creates user setup, time sheet resource and time sheet header

      // create user setup
      CreateUserSetup(UserSetup,UseCurrentUserID);

      // resource - person
      CreateTimeSheetResource(Resource);
      Resource.VALIDATE("Time Sheet Owner User ID",UserSetup."User ID");
      Resource.VALIDATE("Time Sheet Approver User ID",USERID);
      Resource.MODIFY;

      // find first open accounting period
      GetAccountingPeriod(AccountingPeriod);

      // find first DOW after accounting period starting date
      Date.SETRANGE("Period Type",Date."Period Type"::Date);
      Date.SETFILTER("Period Start",'%1..',AccountingPeriod."Starting Date");
      Date.SETRANGE("Period No.",ResourcesSetup."Time Sheet First Weekday" + 1);
      Date.FINDFIRST;

      WORKDATE := Date."Period Start";

      // create time sheet
      CreateTimeSheets.InitParameters(Date."Period Start",1,Resource."No.",FALSE,TRUE);
      CreateTimeSheets.USEREQUESTPAGE(FALSE);
      CreateTimeSheets.RUN;

      // find created time sheet
      TimeSheetHeader.SETRANGE("Resource No.",Resource."No.");
      TimeSheetHeader.FINDFIRST;

Example

The below example is extracted from the test automation codeunit 136500 to show one way of using this function.

      // test for function "Copy lines from previous time sheet"
      SetUp;

      // create source time sheet
      LibraryTimeSheet.CreateTimeSheet(FromTimeSheetHeader,FALSE);

      // create time sheet lines with different types
      AddRowsWithDifferentTypes(FromTimeSheetHeader,FromTimeSheetLine);

      // create destanation time sheet
      CreateTimeSheets(FromTimeSheetHeader."Ending Date" + 1,1,FromTimeSheetHeader."Resource No.");

      ToTimeSheetHeader.SETRANGE("Resource No.",FromTimeSheetHeader."Resource No.");
      ToTimeSheetHeader.FINDLAST;

      // run Copy lines function
      TimeSheetMgt.CopyPrevTimeSheetLines(ToTimeSheetHeader);

      // verify that lines are copied
      ToTimeSheetLine.SETRANGE("Time Sheet No.",ToTimeSheetHeader."No.");
      Assert.IsTrue(ToTimeSheetLine.FINDSET,Text006);

      FromTimeSheetLine.SETRANGE("Time Sheet No.",FromTimeSheetHeader."No.");
      FromTimeSheetLine.FINDSET;

      // verify that all needed fields were copied
      REPEAT
        ToTimeSheetLine.TESTFIELD(Type,FromTimeSheetLine.Type);
        ToTimeSheetLine.TESTFIELD("Job No.",FromTimeSheetLine."Job No.");
        ToTimeSheetLine.TESTFIELD("Job Task No.",FromTimeSheetLine."Job Task No.");
        ToTimeSheetLine.TESTFIELD("Cause of Absence Code",FromTimeSheetLine."Cause of Absence Code");
        ToTimeSheetLine.TESTFIELD(Description,FromTimeSheetLine.Description);
        ToTimeSheetLine.TESTFIELD(Chargeable,FromTimeSheetLine.Chargeable);
        FromTimeSheetLine.NEXT;
      UNTIL ToTimeSheetLine.NEXT = 0;

      TearDown;
Member of Lib.Library - Time Sheet


CreateTimeSheetDetail@6 Method

The procedure CreateTimeSheetDetail is available in codeunit 131904.

Syntax

CreateTimeSheetDetail@6(
    TimeSheetLine@1001 : Record 951 TimeSheetLine, //Input parameter of type Record
    Date@1002 : Date Date, //Input parameter of type Date
    Quantity@1004 : Decimal Quantity //Input parameter of type Decimal
);

Parameters

TimeSheetLine
Input parameter of type Record
Date
Input parameter of type Date
Quantity
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Time, Sheet, Detail.

For a clarification about how this function works, refer to the code listed below.

      TimeSheetDetail.INIT;
      TimeSheetDetail."Time Sheet No." := TimeSheetLine."Time Sheet No.";
      TimeSheetDetail."Time Sheet Line No." := TimeSheetLine."Line No.";
      TimeSheetDetail.Date := Date;
      TimeSheetDetail.CopyFromTimeSheetLine(TimeSheetLine);
      TimeSheetDetail.Quantity := Quantity;
      TimeSheetDetail.INSERT;

Example

The below example is extracted from the test automation codeunit 136500 to show one way of using this function.

      // [FEATURE] [Time Sheet] [Service Order]
      // [SCENARIO] "Create lines from time sheets" for Service Order creates service order lines, after posting Service Order TS lines are posted.

      // test for function "Create lines from time sheets" for Service Order
      SetUp;

      LibraryTimeSheet.CreateTimeSheet(TimeSheetHeader,FALSE);
      LibraryTimeSheet.CreateServiceOrder(ServiceHeader,CALCDATE('<+3D>',TimeSheetHeader."Starting Date"));

      // create time sheet line with type Service
      LibraryTimeSheet.CreateTimeSheetLine(TimeSheetHeader,TimeSheetLine,TimeSheetLine.Type::Service,'','','','');
      TimeSheetLine.VALIDATE("Service Order No.",ServiceHeader."No.");
      TimeSheetLine.MODIFY;

      // create details for 2 days
      LibraryTimeSheet.CreateTimeSheetDetail(
        TimeSheetLine,TimeSheetHeader."Starting Date",LibraryTimeSheet.GetRandomDecimal);
      LibraryTimeSheet.CreateTimeSheetDetail(
        TimeSheetLine,TimeSheetHeader."Starting Date" + 1,LibraryTimeSheet.GetRandomDecimal);
      // submit and approve
      TimeSheetApprovalMgt.Submit(TimeSheetLine);
      TimeSheetApprovalMgt.Approve(TimeSheetLine);

      // create lines from time sheet
      TimeSheetMgt.CreateServDocLinesFromTS(ServiceHeader);
      LibraryService.PostServiceOrder(ServiceHeader,TRUE,FALSE,TRUE);

      TimeSheetLine.FIND;
      // Posted should be Yes
      Assert.IsTrue(TimeSheetLine.Posted,Text008);

      TearDown;
Member of Lib.Library - Time Sheet


CreateTimeSheetLine@5 Method

The procedure CreateTimeSheetLine is available in codeunit 131904.

Syntax

CreateTimeSheetLine@5(
    TimeSheetHeader@1000 : Record 950 TimeSheetHeader, //Input parameter of type Record
    VAR TimeSheetLine@1001 : Record 951 TimeSheetLine, //Reference parameter of type Record
    Type@1002 : Option Type, //Input parameter of type Option
    JobNo@1004 : Code[20] JobNo, //Input parameter of type Code
    JobTaskNo@1005 : Code[20] JobTaskNo, //Input parameter of type Code
    ServiceOrderNo@1006 : Code[20] ServiceOrderNo, //Input parameter of type Code
    CauseOfAbsenceCode@1007 : Code[10] CauseOfAbsenceCode //Input parameter of type Code
);

Parameters

TimeSheetHeader
Input parameter of type Record
TimeSheetLine
Reference parameter of type Record
Type
Input parameter of type Option
JobNo
Input parameter of type Code
JobTaskNo
Input parameter of type Code
ServiceOrderNo
Input parameter of type Code
CauseOfAbsenceCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Time, Sheet, Line.

For a clarification about how this function works, refer to the code listed below.

      LineNo := TimeSheetHeader.GetLastLineNo + 10000;

      TimeSheetLine.INIT;
      TimeSheetLine."Time Sheet No." := TimeSheetHeader."No.";
      TimeSheetLine."Line No." := LineNo;
      TimeSheetLine.Type := Type;
      CASE Type OF
        Type::Job:
          BEGIN
            TimeSheetLine.VALIDATE("Job No.",JobNo);
            TimeSheetLine.VALIDATE("Job Task No.",JobTaskNo);
          END;
        Type::Service:
          TimeSheetLine.VALIDATE("Service Order No.",ServiceOrderNo);
        Type::Absence:
          TimeSheetLine.VALIDATE("Cause of Absence Code",CauseOfAbsenceCode);
      END;
      TimeSheetLine.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136500 to show one way of using this function.

      // [FEATURE] [Time Sheet] [Service Order]
      // [SCENARIO] "Create lines from time sheets" for Service Order creates service order lines, after posting Service Order TS lines are posted.

      // test for function "Create lines from time sheets" for Service Order
      SetUp;

      LibraryTimeSheet.CreateTimeSheet(TimeSheetHeader,FALSE);
      LibraryTimeSheet.CreateServiceOrder(ServiceHeader,CALCDATE('<+3D>',TimeSheetHeader."Starting Date"));

      // create time sheet line with type Service
      LibraryTimeSheet.CreateTimeSheetLine(TimeSheetHeader,TimeSheetLine,TimeSheetLine.Type::Service,'','','','');
      TimeSheetLine.VALIDATE("Service Order No.",ServiceHeader."No.");
      TimeSheetLine.MODIFY;

      // create details for 2 days
      LibraryTimeSheet.CreateTimeSheetDetail(
        TimeSheetLine,TimeSheetHeader."Starting Date",LibraryTimeSheet.GetRandomDecimal);
      LibraryTimeSheet.CreateTimeSheetDetail(
        TimeSheetLine,TimeSheetHeader."Starting Date" + 1,LibraryTimeSheet.GetRandomDecimal);
      // submit and approve
      TimeSheetApprovalMgt.Submit(TimeSheetLine);
      TimeSheetApprovalMgt.Approve(TimeSheetLine);

      // create lines from time sheet
      TimeSheetMgt.CreateServDocLinesFromTS(ServiceHeader);
      LibraryService.PostServiceOrder(ServiceHeader,TRUE,FALSE,TRUE);

      TimeSheetLine.FIND;
      // Posted should be Yes
      Assert.IsTrue(TimeSheetLine.Posted,Text008);

      TearDown;
Member of Lib.Library - Time Sheet


CreateTimeSheetResource@3 Method

The procedure CreateTimeSheetResource is available in codeunit 131904.

Syntax

CreateTimeSheetResource@3(
    VAR Resource@1001 : Record 156 Resource //Reference parameter of type Record
);

Parameters

Resource
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Time, Sheet, Resource.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.FindVATPostingSetup(VATPostingSetup,VATPostingSetup."VAT Calculation Type"::"Normal VAT");
      LibraryResource.CreateResource(Resource,VATPostingSetup."VAT Bus. Posting Group");
      // take base unit of measure from table 5220 to be allowed register employee absence
      FindHRUnitOfMeasure(HumanResourceUnitOfMeasure);
      IF NOT ResourceUnitOfMeasure.GET(Resource."No.",HumanResourceUnitOfMeasure.Code) THEN
        LibraryResource.CreateResourceUnitOfMeasure(
          ResourceUnitOfMeasure,Resource."No.",HumanResourceUnitOfMeasure.Code,1);
      Resource.VALIDATE("Base Unit of Measure",HumanResourceUnitOfMeasure.Code);
      Resource."Use Time Sheet" := TRUE;
      Resource.MODIFY;

Example

The below example is extracted from the test automation codeunit 136500 to show one way of using this function.

      // it should not be possible to specify the same Time Sheet Owner User ID for several resources with type = Person
      SetUp;

      // create resource and link it to the user
      CreateTimeSheetResource(Resource,FALSE);

      // create another resource
      LibraryTimeSheet.CreateTimeSheetResource(Resource2);

      // try to specify the same user id
      ASSERTERROR Resource2.VALIDATE("Time Sheet Owner User ID",Resource."Time Sheet Owner User ID");

      TearDown;
Member of Lib.Library - Time Sheet


CreateUserSetup@2 Method

The procedure CreateUserSetup is available in codeunit 131904.

Syntax

CreateUserSetup@2(
    VAR UserSetup@1000 : Record 91 UserSetup, //Reference parameter of type Record
    CurrUserID@1001 : Boolean CurrUserID //Input parameter of type Boolean
);

Parameters

UserSetup
Reference parameter of type Record
CurrUserID
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, User, Setup.

For a clarification about how this function works, refer to the code listed below.

      UserSetup.INIT;
      IF CurrUserID THEN BEGIN
        UserSetup."User ID" := USERID;
        UserSetup."Time Sheet Admin." := TRUE;
      END ELSE
        UserSetup."User ID" :=
          COPYSTR(
            LibraryUtility.GenerateRandomCode(UserSetup.FIELDNO("User ID"),DATABASE::"User Setup"),1,MAXSTRLEN(UserSetup."User ID"));
      IF UserSetup.INSERT THEN;

Example

The below example is extracted from the test automation codeunit 134331 to show one way of using this function.

      // [FEATURE] [Responsibility Center] [Archive]
      // [SCENARIO 375976] Purchase Order Archive shows entries depending on User's Responsibility Center
      Initialize;

      // [GIVEN] Responsibility Center "A" and "B"
      LibraryTimeSheet.CreateUserSetup(UserSetup,TRUE);
      OldPurchRespCtrFilter := UpdateUserSetupPurchRespCtrFilter(UserSetup,'');
      LibraryService.CreateResponsibilityCenter(ResponsibilityCenter[1]);
      LibraryService.CreateResponsibilityCenter(ResponsibilityCenter[2]);

      // [GIVEN] Archived Purchase Order for Responsibility Center "A"
      CreateAndArchivePurchOrderWithRespCenter(
        VendorNo[1],ResponsibilityCenter[1].Code);

      // [GIVEN] Archived Purchase Order for Responsibility Center "B"
      CreateAndArchivePurchOrderWithRespCenter(
        VendorNo[2],ResponsibilityCenter[2].Code);

      // [GIVEN] User is assigned to Responsibility Center "A"
      UpdateUserSetupPurchRespCtrFilter(UserSetup,ResponsibilityCenter[1].Code);

      // [WHEN] Purchase Order Archive page is opened
      PurchOrderArchives.OPENVIEW;

      // [THEN] Only entries for Responsibility Center "A" are shown
      PurchOrderArchives."Buy-from Vendor No.".ASSERTEQUALS(VendorNo[1]);
      Assert.IsFalse(PurchOrderArchives.NEXT,PurchOrderArchiveRespCenterErr);

      UpdateUserSetupPurchRespCtrFilter(UserSetup,OldPurchRespCtrFilter);
Member of Lib.Library - Time Sheet


CreateWorkType@26 Method

The procedure CreateWorkType is available in codeunit 131904.

Syntax

CreateWorkType@26(
    VAR WorkType@1000 : Record 200 WorkType, //Reference parameter of type Record
    ResourceBUOM@1001 : Code[10] ResourceBUOM //Input parameter of type Code
);

Parameters

WorkType
Reference parameter of type Record
ResourceBUOM
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Work, Type.

For a clarification about how this function works, refer to the code listed below.

      WorkType.INIT;
      WorkType.VALIDATE(Code,COPYSTR(FORMAT(CREATEGUID),1,MAXSTRLEN(WorkType.Code)));
      WorkType.INSERT(TRUE);
      WorkType.VALIDATE(Description,'test work type');
      WorkType.VALIDATE("Unit of Measure Code",ResourceBUOM);
      WorkType.MODIFY;

Example

The below example is extracted from the test automation codeunit 136500 to show one way of using this function.

      SetUp;
      LibraryTimeSheet.InitScenarioWTForJob(TimeSheetHeader);

      // create work type
      Resource.GET(TimeSheetHeader."Resource No.");
      LibraryTimeSheet.CreateWorkType(WorkType,Resource."Base Unit of Measure");

      // find time sheet
      WORKDATE := TimeSheetHeader."Starting Date";
      ManagerTSbyJob.OPENEDIT;

      // change chargeable and work type on the manager page by job
      ManagerTSbyJob.FILTER.SETFILTER("Time Sheet No.",TimeSheetHeader."No.");
      ManagerTSbyJob.FILTER.SETFILTER(Status,'Submitted');
      GlobalWorkTypeCode := WorkType.Code;
      GlobalChargeable := FALSE;
      ManagerTSbyJob.Description.ASSISTEDIT;
      ManagerTSbyJob.Action37.INVOKE;

      TimeSheetLine.SETRANGE("Time Sheet No.",TimeSheetHeader."No.");
      TimeSheetLine.FINDFIRST;
      TimeSheetLine.TESTFIELD("Work Type Code",GlobalWorkTypeCode);
      TimeSheetLine.TESTFIELD(Chargeable,GlobalChargeable);

      TearDown;
Member of Lib.Library - Time Sheet


FindCauseOfAbsence@67 Method

The procedure FindCauseOfAbsence is available in codeunit 131904.

Syntax

FindCauseOfAbsence@67(
    VAR CauseOfAbsence@1000 : Record 5206 CauseOfAbsence //Reference parameter of type Record
);

Parameters

CauseOfAbsence
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Cause, Of, Absence.

For a clarification about how this function works, refer to the code listed below.

      WITH CauseOfAbsence DO BEGIN
        FINDFIRST;
        IF "Unit of Measure Code" = '' THEN BEGIN
          HumanResourceUnitOfMeasure.FINDFIRST;
          VALIDATE("Unit of Measure Code",HumanResourceUnitOfMeasure.Code);
          MODIFY(TRUE);
        END;
      END;

Example

The below example is extracted from the test automation codeunit 136404 to show one way of using this function.

      LibraryTimeSheet.FindCauseOfAbsence(CauseOfAbsence);
      WITH CauseOfAbsence DO BEGIN
        IF "Unit of Measure Code" = '' THEN BEGIN
          HumanResourceUnitOfMeasure.FINDFIRST;
          VALIDATE("Unit of Measure Code",HumanResourceUnitOfMeasure.Code);
          MODIFY(TRUE);
        END;
        EXIT(Code);
      END;
Member of Lib.Library - Time Sheet


FindHRUnitOfMeasure@9 Method

The procedure FindHRUnitOfMeasure is available in codeunit 131904.

Syntax

FindHRUnitOfMeasure@9(
    VAR HumanResourceUnitOfMeasure@1000 : Record 5220 HumanResourceUnitOfMeasure //Reference parameter of type Record
);

Parameters

HumanResourceUnitOfMeasure
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, HR, Unit, Of, Measure.

For a clarification about how this function works, refer to the code listed below.

      HumanResourceUnitOfMeasure.FINDFIRST;

Example

There are no examples available.
Member of Lib.Library - Time Sheet


FindJob@128 Method

The procedure FindJob is available in codeunit 131904.

Syntax

FindJob@128(
    VAR Job@1000 : Record 167 Job //Reference parameter of type Record
);

Parameters

Job
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Job.

For a clarification about how this function works, refer to the code listed below.

      Job.SETFILTER("Person Responsible",'<>''''');
      Job.FINDFIRST;

Example

The below example is extracted from the test automation codeunit 136500 to show one way of using this function.

      // test for function "Create lines from job planning"
      InitCreateFromJobPlanningSetup;

      // create time sheet
      LibraryTimeSheet.CreateTimeSheet(TimeSheetHeader,FALSE);

      // find job and task
      LibraryTimeSheet.FindJob(Job);
      LibraryTimeSheet.FindJobTask(Job."No.",JobTask);
      // creat job planning for 2 first time sheet days
      FOR Date := TimeSheetHeader."Starting Date" TO TimeSheetHeader."Starting Date" + 1 DO
        LibraryTimeSheet.CreateJobPlanningLine(
          JobPlanningLine,
          Job."No.",
          JobTask."Job Task No.",
          TimeSheetHeader."Resource No.",
          Date);

      // run function Create lines from job planning
      TimeSheetMgt.CreateLinesFromJobPlanning(TimeSheetHeader);

      // verify that only 1 line has been created
      TimeSheetLine.SETRANGE("Time Sheet No.",TimeSheetHeader."No.");
      TimeSheetLine.SETRANGE(Type,TimeSheetLine.Type::Job);
      TimeSheetLine.SETRANGE("Job No.",Job."No.");
      TimeSheetLine.SETRANGE("Job Task No.",JobTask."Job Task No.");
      Assert.IsTrue(TimeSheetLine.COUNT = 1,Text007);

      TearDown;
Member of Lib.Library - Time Sheet


FindJobJournalBatch@78 Method

The procedure FindJobJournalBatch is available in codeunit 131904.

Syntax

FindJobJournalBatch@78(
    VAR JobJournalBatch@1000 : Record 237 JobJournalBatch, //Reference parameter of type Record
    JournalTemplateName@1001 : Code[10] JournalTemplateName //Input parameter of type Code
);

Parameters

JobJournalBatch
Reference parameter of type Record
JournalTemplateName
Input parameter of type Code

Remarks

The relevant search keywords are: Find, Job, Journal, Batch.

For a clarification about how this function works, refer to the code listed below.

      JobJournalBatch.SETRANGE("Journal Template Name",JournalTemplateName);
      JobJournalBatch.FINDFIRST;

Example

The below example is extracted from the test automation codeunit 136503 to show one way of using this function.

      JobJournalTemplate.SETRANGE(Recurring,FALSE);
      LibraryTimeSheet.FindJobJournalTemplate(JobJournalTemplate);
      LibraryTimeSheet.FindJobJournalBatch(JobJournalBatch,JobJournalTemplate.Name);
Member of Lib.Library - Time Sheet


FindJobJournalTemplate@66 Method

The procedure FindJobJournalTemplate is available in codeunit 131904.

Syntax

FindJobJournalTemplate@66(
    VAR JobJournalTemplate@1000 : Record 209 JobJournalTemplate //Reference parameter of type Record
);

Parameters

JobJournalTemplate
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Job, Journal, Template.

For a clarification about how this function works, refer to the code listed below.

      JobJournalTemplate.FINDFIRST;

Example

The below example is extracted from the test automation codeunit 136503 to show one way of using this function.

      JobJournalTemplate.SETRANGE(Recurring,FALSE);
      LibraryTimeSheet.FindJobJournalTemplate(JobJournalTemplate);
      LibraryTimeSheet.FindJobJournalBatch(JobJournalBatch,JobJournalTemplate.Name);
Member of Lib.Library - Time Sheet


FindJobTask@137 Method

The procedure FindJobTask is available in codeunit 131904.

Syntax

FindJobTask@137(
    JobNo@1001 : Code[20] JobNo, //Input parameter of type Code
    VAR JobTask@1000 : Record 1001 JobTask //Reference parameter of type Record
);

Parameters

JobNo
Input parameter of type Code
JobTask
Reference parameter of type Record

Remarks

The relevant search keywords are: Find, Job, Task.

For a clarification about how this function works, refer to the code listed below.

      JobTask.SETRANGE("Job No.",JobNo);
      JobTask.SETRANGE("Job Task Type",JobTask."Job Task Type"::Posting);
      JobTask.FINDFIRST;

Example

The below example is extracted from the test automation codeunit 136500 to show one way of using this function.

      // test for function "Create lines from job planning"
      InitCreateFromJobPlanningSetup;

      // create time sheet
      LibraryTimeSheet.CreateTimeSheet(TimeSheetHeader,FALSE);

      // find job and task
      LibraryTimeSheet.FindJob(Job);
      LibraryTimeSheet.FindJobTask(Job."No.",JobTask);
      // creat job planning for 2 first time sheet days
      FOR Date := TimeSheetHeader."Starting Date" TO TimeSheetHeader."Starting Date" + 1 DO
        LibraryTimeSheet.CreateJobPlanningLine(
          JobPlanningLine,
          Job."No.",
          JobTask."Job Task No.",
          TimeSheetHeader."Resource No.",
          Date);

      // run function Create lines from job planning
      TimeSheetMgt.CreateLinesFromJobPlanning(TimeSheetHeader);

      // verify that only 1 line has been created
      TimeSheetLine.SETRANGE("Time Sheet No.",TimeSheetHeader."No.");
      TimeSheetLine.SETRANGE(Type,TimeSheetLine.Type::Job);
      TimeSheetLine.SETRANGE("Job No.",Job."No.");
      TimeSheetLine.SETRANGE("Job Task No.",JobTask."Job Task No.");
      Assert.IsTrue(TimeSheetLine.COUNT = 1,Text007);

      TearDown;
Member of Lib.Library - Time Sheet


GetAccountingPeriod@7 Method

The procedure GetAccountingPeriod is available in codeunit 131904.

Syntax

GetAccountingPeriod@7(
    VAR AccountingPeriod@1000 : Record 50 AccountingPeriod //Reference parameter of type Record
);

Parameters

AccountingPeriod
Reference parameter of type Record

Remarks

The relevant search keywords are: Get, Accounting, Period.

For a clarification about how this function works, refer to the code listed below.

      // find first open accounting period
      AccountingPeriod.SETRANGE(Closed,FALSE);
      IF NOT AccountingPeriod.FINDFIRST THEN BEGIN
        // if accounting period is not found then create new one
        AccountingPeriod.RESET;
        IF AccountingPeriod.FINDLAST THEN
          StartingDate := CALCDATE('<+1M>',AccountingPeriod."Starting Date")
        ELSE
          StartingDate := CALCDATE('<CM>',TODAY);
        AccountingPeriod.INIT;
        AccountingPeriod."Starting Date" := StartingDate;
        AccountingPeriod.INSERT;
      END;

Example

The below example is extracted from the test automation codeunit 136500 to show one way of using this function.

      // find first open accounting period
      LibraryTimeSheet.GetAccountingPeriod(AccountingPeriod);

      // find first DOW after accounting period starting date
      Date.SETRANGE("Period Type",Date."Period Type"::Date);
      Date.SETFILTER("Period Start",'%1..',AccountingPeriod."Starting Date");
      Date.SETRANGE("Period No.",ResourcesSetup."Time Sheet First Weekday" + 1);
      Date.FINDFIRST;

      EXIT(Date."Period Start");
Member of Lib.Library - Time Sheet


GetRandomDecimal@83 Method

The procedure GetRandomDecimal is available in codeunit 131904.

Syntax

GetRandomDecimal@83(
      //param element not supplied
);

Return Value

Decimal

Remarks

The relevant search keywords are: Get, Random, Decimal.

For a clarification about how this function works, refer to the code listed below.

      EXIT(RANDOM(9999) / 100);

Example

The below example is extracted from the test automation codeunit 136500 to show one way of using this function.

      // test for time sheet flow chart calculation procedure
      SetUp;

      // create time sheet
      LibraryTimeSheet.CreateTimeSheet(TimeSheetHeader,FALSE);

      SetupTimeSheetChart(TimeSheetChartSetup,USERID,TimeSheetHeader."Starting Date");

      // init quiantities
      OpenQty := LibraryTimeSheet.GetRandomDecimal;
      SubmittedQty := LibraryTimeSheet.GetRandomDecimal;
      RejectedQty := LibraryTimeSheet.GetRandomDecimal;
      ApprovedQty := LibraryTimeSheet.GetRandomDecimal;
      ScheduledQty := LibraryTimeSheet.GetRandomDecimal;
      PostedQty := ROUND(ApprovedQty / 3);

      // create capacity for resource
      CreateResCapacity(TimeSheetHeader."Resource No.",TimeSheetHeader."Starting Date",ScheduledQty);

      // open line
      CreateTSResLineWithDetail(TimeSheetHeader,TimeSheetLine,OpenQty);

      // submitted line
      CreateTSResLineWithDetail(TimeSheetHeader,TimeSheetLine,SubmittedQty);
      TimeSheetApprovalMgt.Submit(TimeSheetLine);

      // rejected line
      CreateTSResLineWithDetail(TimeSheetHeader,TimeSheetLine,RejectedQty);
      TimeSheetApprovalMgt.Submit(TimeSheetLine);
      TimeSheetApprovalMgt.Reject(TimeSheetLine);

      // approved line
      CreateTSResLineWithDetail(TimeSheetHeader,TimeSheetLine,ApprovedQty);
      TimeSheetApprovalMgt.Submit(TimeSheetLine);
      TimeSheetApprovalMgt.Approve(TimeSheetLine);

      // emulate posting
      TimeSheetDetail.GET(TimeSheetLine."Time Sheet No.",TimeSheetLine."Line No.",TimeSheetLine."Time Sheet Starting Date");
      TimeSheetMgt.CreateTSPostingEntry(TimeSheetDetail,PostedQty,TimeSheetDetail.Date,'','');

      TimeSheetHeader.CALCFIELDS(Quantity);

      // verify numbers for Show by Status
      TimeSheetChartSetup."Show by" := TimeSheetChartSetup."Show by"::Status;
      VerifyFlowChartCalcAmount(OpenQty,TimeSheetChartSetup,TimeSheetHeader."Resource No.",MeasureType::Open);
      VerifyFlowChartCalcAmount(SubmittedQty,TimeSheetChartSetup,TimeSheetHeader."Resource No.",MeasureType::Submitted);
      VerifyFlowChartCalcAmount(RejectedQty,TimeSheetChartSetup,TimeSheetHeader."Resource No.",MeasureType::Rejected);
      VerifyFlowChartCalcAmount(ApprovedQty,TimeSheetChartSetup,TimeSheetHeader."Resource No.",MeasureType::Approved);
      VerifyFlowChartCalcAmount(ScheduledQty,TimeSheetChartSetup,TimeSheetHeader."Resource No.",MeasureType::Scheduled);
      // verify numbers for Show by Posted
      TimeSheetChartSetup."Show by" := TimeSheetChartSetup."Show by"::Posted;
      VerifyFlowChartCalcAmount(PostedQty,TimeSheetChartSetup,TimeSheetHeader."Resource No.",MeasureType::Posted);
      VerifyFlowChartCalcAmount(
        TimeSheetHeader.Quantity - PostedQty,TimeSheetChartSetup,TimeSheetHeader."Resource No.",MeasureType::"Not posted");

      TearDown;
Member of Lib.Library - Time Sheet


GetTimeSheetNoSeries@49 Method

The procedure GetTimeSheetNoSeries is available in codeunit 131904.

Syntax

GetTimeSheetNoSeries@49(
      //param element not supplied
);

Return Value

Code[10]

Remarks

The relevant search keywords are: Get, Time, Sheet, No, Series.

For a clarification about how this function works, refer to the code listed below.

      IF NOT NoSeries.GET(NoSeriesCode) THEN BEGIN
        LibraryUtility.CreateNoSeries(NoSeries,TRUE,FALSE,FALSE);
        NoSeries.RENAME(NoSeriesCode);
        LibraryUtility.CreateNoSeriesLine(NoSeriesLine,NoSeries.Code,'','')
      END;

      EXIT(NoSeries.Code)

Example

There are no examples available.
Member of Lib.Library - Time Sheet


InitAssemblyBackwayScenario@65 Method

The procedure InitAssemblyBackwayScenario is available in codeunit 131904.

Syntax

InitAssemblyBackwayScenario@65(
    VAR TimeSheetHeader@1016 : Record 950 TimeSheetHeader, //Reference parameter of type Record
    VAR AssemblyHeader@1015 : Record 900 AssemblyHeader, //Reference parameter of type Record
    VAR AssemblyLine@1009 : Record 901 AssemblyLine, //Reference parameter of type Record
    TimeSheetExists@1005 : Boolean TimeSheetExists //Input parameter of type Boolean
);

Parameters

TimeSheetHeader
Reference parameter of type Record
AssemblyHeader
Reference parameter of type Record
AssemblyLine
Reference parameter of type Record
TimeSheetExists
Input parameter of type Boolean

Remarks

The relevant search keywords are: Init, Assembly, Backway, Scenario.

For a clarification about how this function works, refer to the code listed below.

      IF TimeSheetExists THEN BEGIN
        // create time sheet
        CreateTimeSheet(TimeSheetHeader,FALSE);
        Resource.GET(TimeSheetHeader."Resource No.");
        Date := TimeSheetHeader."Starting Date";
      END ELSE BEGIN
        // set up without tine sheet; create resource
        Date := WORKDATE;
        CreateUserSetup(UserSetup,FALSE);
        CreateTimeSheetResource(Resource);
        Resource.VALIDATE("Time Sheet Owner User ID",UserSetup."User ID");
        Resource.VALIDATE("Time Sheet Approver User ID",USERID);
      END;

      LibraryERM.FindGeneralPostingSetupInvtFull(GeneralPostingSetup);
      Resource.VALIDATE("Gen. Prod. Posting Group",GeneralPostingSetup."Gen. Prod. Posting Group");
      Resource.MODIFY;

      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location);

      // get items on the location (pos.adjmt.)
      LibraryInventory.SelectItemJournalTemplateName(ItemJournalTemplate,ItemJournalTemplate.Type::Item);
      LibraryInventory.SelectItemJournalBatchName(ItemJournalBatch,ItemJournalTemplate.Type,ItemJournalTemplate.Name);
      LibraryInventory.ClearItemJournal(ItemJournalTemplate,ItemJournalBatch);

      FOR ItemCount := 1 TO 2 DO BEGIN
        LibraryInventory.CreateItem(Item[ItemCount]);
        LibraryInventory.CreateItemJournalLine(ItemJournalLine,ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name,
          ItemJournalLine."Entry Type"::"Positive Adjmt.",Item[ItemCount]."No.",10);
        ItemJournalLine.VALIDATE("Location Code",Location.Code);
        ItemJournalLine.MODIFY;
      END;

      LibraryInventory.PostItemJournalLine(ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name);

      // create complicated item
      LibraryManufacturing.CreateBOMComponent(BOMComponent,Item[1]."No.",BOMComponent.Type::Item,Item[2]."No.",2,'');

      // create assembly order with lines
      LibraryAssembly.CreateAssemblyHeader(AssemblyHeader,CALCDATE('<+7D>',Date),Item[1]."No.",Location.Code,2,'');
      AssemblyHeader.VALIDATE("Posting Date",CALCDATE('<+3D>',Date));
      AssemblyHeader.MODIFY;
      LibraryAssembly.CreateAssemblyLine(
        AssemblyHeader,AssemblyLine,AssemblyLine.Type::Resource,Resource."No.",Resource."Base Unit of Measure",8,8,'Working resource');

Example

The below example is extracted from the test automation codeunit 136500 to show one way of using this function.

      // test for time sheet flow chart calculation procedure
      SetUp;

      // init quiantities
      ResourceQty := LibraryTimeSheet.GetRandomDecimal;
      JobQty := LibraryTimeSheet.GetRandomDecimal;
      AbsenceQty := LibraryTimeSheet.GetRandomDecimal;
      ServiceQty := LibraryTimeSheet.GetRandomDecimal;
      ScheduledQty := LibraryTimeSheet.GetRandomDecimal;

      LibraryTimeSheet.InitAssemblyBackwayScenario(TimeSheetHeader,AssemblyHeader,AssemblyLine,TRUE);
      SetupTimeSheetChart(TimeSheetChartSetup,USERID,TimeSheetHeader."Starting Date");

      // create capacity for resource
      CreateResCapacity(TimeSheetHeader."Resource No.",TimeSheetHeader."Starting Date",ScheduledQty);

      // resource line:
      CreateTSResLineWithDetail(TimeSheetHeader,TimeSheetLine,ResourceQty);

      // job line:
      CreateTSJobLineWithDetail(TimeSheetHeader,TimeSheetLine,JobQty);

      // absence line:
      CreateTSAbsenceLineWithDetail(TimeSheetHeader,TimeSheetLine,AbsenceQty);

      // service line:
      LibraryTimeSheet.CreateServiceOrder(ServiceHeader,TimeSheetHeader."Starting Date");
      // create time sheet line with type Service
      LibraryTimeSheet.CreateTimeSheetLine(TimeSheetHeader,TimeSheetLine,TimeSheetLine.Type::Service,'','','','');
      TimeSheetLine.VALIDATE("Service Order No.",ServiceHeader."No.");
      TimeSheetLine.MODIFY;
      LibraryTimeSheet.CreateTimeSheetDetail(TimeSheetLine,TimeSheetHeader."Starting Date",ServiceQty);

      // assembly line:
      AssemblyQty := AssemblyLine.Quantity;
      LibraryAssembly.PostAssemblyHeader(AssemblyHeader,'');

      TimeSheetChartSetup."Show by" := TimeSheetChartSetup."Show by"::Type;

      VerifyFlowChartCalcAmount(ResourceQty,TimeSheetChartSetup,TimeSheetHeader."Resource No.",MeasureType::Resource);
      VerifyFlowChartCalcAmount(JobQty,TimeSheetChartSetup,TimeSheetHeader."Resource No.",MeasureType::Job);
      VerifyFlowChartCalcAmount(AbsenceQty,TimeSheetChartSetup,TimeSheetHeader."Resource No.",MeasureType::Absence);
      VerifyFlowChartCalcAmount(ServiceQty,TimeSheetChartSetup,TimeSheetHeader."Resource No.",MeasureType::Service);
      VerifyFlowChartCalcAmount(AssemblyQty,TimeSheetChartSetup,TimeSheetHeader."Resource No.",MeasureType::"Assembly Order");

      TearDown;
Member of Lib.Library - Time Sheet


InitBackwayScenario@52 Method

The procedure InitBackwayScenario is available in codeunit 131904.

Syntax

InitBackwayScenario@52(
    VAR TimeSheetHeader@1008 : Record 950 TimeSheetHeader, //Reference parameter of type Record
    VAR ServiceHeader@1006 : Record 5900 ServiceHeader, //Reference parameter of type Record
    VAR ServiceLine@1001 : Record 5902 ServiceLine //Reference parameter of type Record
);

Parameters

TimeSheetHeader
Reference parameter of type Record
ServiceHeader
Reference parameter of type Record
ServiceLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Init, Backway, Scenario.

For a clarification about how this function works, refer to the code listed below.

      // create time sheet
      CreateTimeSheet(TimeSheetHeader,FALSE);

      // create service order
      CreateServiceOrder(ServiceHeader,CALCDATE('<+3D>',TimeSheetHeader."Starting Date"));
      // create service line
      LibraryService.CreateServiceLine(ServiceLine,ServiceHeader,ServiceLine.Type::Resource,TimeSheetHeader."Resource No.");
      ServiceLine.VALIDATE("Service Item Line No.",10000);
      ServiceLine.VALIDATE(Quantity,GetRandomDecimal);
      ServiceLine.MODIFY;

Example

The below example is extracted from the test automation codeunit 136502 to show one way of using this function.

      // [FEATURE] [Order] [Service]
      // [SCENARIO] Verify time sheet total quantity after ship and consume service order with timesheet resource.

      Initialize;
      LibraryTimeSheet.InitBackwayScenario(TimeSheetHeader,ServiceHeader,ServiceLine);

      ServiceLine.VALIDATE("Qty. to Consume",ServiceLine.Quantity);
      ServiceLine.MODIFY;

      // get values from service order
      SavedServiceLine.COPY(ServiceLine);

      LibraryService.PostServiceOrder(ServiceHeader,TRUE,TRUE,FALSE);

      LibraryTimeSheet.CheckServiceTimeSheetLine(TimeSheetHeader,SavedServiceLine."Document No.",SavedServiceLine."Line No.",
        SavedServiceLine."Qty. to Consume",FALSE);
Member of Lib.Library - Time Sheet


Initialize@1 Method

The procedure Initialize is available in codeunit 131904.

Syntax

Initialize@1(
      //param element not supplied
);

Remarks

The relevant search keywords are: Initialize.

For a clarification about how this function works, refer to the code listed below.

      IF Initialized THEN
        EXIT;

      IF NOT ResourcesSetup.GET THEN BEGIN
        ResourcesSetup.INIT;
        ResourcesSetup.INSERT;
      END;

      IF ResourcesSetup."Time Sheet Nos." = '' THEN BEGIN
        ResourcesSetup.VALIDATE("Time Sheet Nos.",GetTimeSheetNoSeries);
        ResourcesSetup.MODIFY;
      END;

      Initialized := TRUE;
      LibraryERMCountryData.CreateVATData;

      COMMIT;

Example

The below example is extracted from the test automation codeunit 136500 to show one way of using this function.

      IF IsInitialized THEN
        EXIT;

      IsInitialized := TRUE;

      LibraryTimeSheet.Initialize;
      LibraryERMCountryData.UpdateGeneralPostingSetup;
      LibraryERMCountryData.UpdateLocalData;
      ResourcesSetup.GET;
      // create current user id setup for approver
      LibraryTimeSheet.CreateUserSetup(UserSetup,TRUE);
      LibraryERMCountryData.UpdateSalesReceivablesSetup;
      COMMIT;
Member of Lib.Library - Time Sheet


InitJobScenario@68 Method

The procedure InitJobScenario is available in codeunit 131904.

Syntax

InitJobScenario@68(
    VAR TimeSheetHeader@1008 : Record 950 TimeSheetHeader, //Reference parameter of type Record
    VAR TimeSheetLine@1006 : Record 951 TimeSheetLine //Reference parameter of type Record
);

Parameters

TimeSheetHeader
Reference parameter of type Record
TimeSheetLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Init, Job, Scenario.

For a clarification about how this function works, refer to the code listed below.

      // create time sheet
      CreateTimeSheet(TimeSheetHeader,FALSE);

      // create time sheet line with type Job
      // find job and task
      FindJob(Job);
      FindJobTask(Job."No.",JobTask);
      // job's responsible person (resource) must have Owner ID filled in
      Resource.GET(Job."Person Responsible");
      Resource."Time Sheet Owner User ID" := USERID;
      Resource.MODIFY;
      CreateTimeSheetLine(TimeSheetHeader,TimeSheetLine,TimeSheetLine.Type::Job,Job."No.",
        JobTask."Job Task No.",'','');

      // set quantity for line
      CreateTimeSheetDetail(TimeSheetLine,TimeSheetHeader."Starting Date",GetRandomDecimal);
      // submit and approve line
      TimeSheetApprovalMgt.Submit(TimeSheetLine);
      TimeSheetApprovalMgt.Approve(TimeSheetLine);

Example

The below example is extracted from the test automation codeunit 136502 to show one way of using this function.

      Initialize;
      LibraryTimeSheet.InitJobScenario(TimeSheetHeader,TimeSheetLine);

      // create resource journal lines based on approved time sheet line
      SuggestJobJournalLines(JobJnlLine,TimeSheetHeader,TimeSheetLine);

      // find and post created journal lines
      FilterJobJournalLineByBatchTemplate(JobJnlLine,JobJnlLine."Journal Template Name",JobJnlLine."Journal Batch Name");
      JobJnlLine.SETRANGE(Type,JobJnlLine.Type::Resource);
      JobJnlLine.SETRANGE("No.",TimeSheetHeader."Resource No.");
      JobJnlLine.FINDFIRST;
      // change quantity to the next higher
      JobJnlLine.VALIDATE(Quantity,TimeSheetLine."Total Quantity" + 10);
      JobJnlLine.MODIFY;

      ASSERTERROR JobJnlPostLine.RunWithCheck(JobJnlLine);
      Assert.IsTrue(STRPOS(GETLASTERRORTEXT,Text023) > 0,Text021);
Member of Lib.Library - Time Sheet


InitResourceScenario@69 Method

The procedure InitResourceScenario is available in codeunit 131904.

Syntax

InitResourceScenario@69(
    VAR TimeSheetHeader@1008 : Record 950 TimeSheetHeader, //Reference parameter of type Record
    VAR TimeSheetLine@1001 : Record 951 TimeSheetLine, //Reference parameter of type Record
    UseCurrentUserID@1000 : Boolean UseCurrentUserID //Input parameter of type Boolean
);

Parameters

TimeSheetHeader
Reference parameter of type Record
TimeSheetLine
Reference parameter of type Record
UseCurrentUserID
Input parameter of type Boolean

Remarks

The relevant search keywords are: Init, Resource, Scenario.

For a clarification about how this function works, refer to the code listed below.

      // create time sheet
      CreateTimeSheet(TimeSheetHeader,UseCurrentUserID);

      // create time sheet lines with type Resource
      CreateTimeSheetLine(TimeSheetHeader,TimeSheetLine,TimeSheetLine.Type::Resource,'','','','');
      TimeSheetLine.Description := TimeSheetHeader."Resource No.";
      TimeSheetLine.MODIFY;

      // set quantity for line
      CreateTimeSheetDetail(TimeSheetLine,TimeSheetHeader."Starting Date",GetRandomDecimal);
      // submit and approve line
      TimeSheetApprovalMgt.Submit(TimeSheetLine);
      TimeSheetApprovalMgt.Approve(TimeSheetLine);

Example

The below example is extracted from the test automation codeunit 136502 to show one way of using this function.

      Initialize;
      LibraryTimeSheet.InitResourceScenario(TimeSheetHeader,TimeSheetLine,FALSE);

      FindResourceJournalBatch(ResJnlBatch);
      ResJnlLine."Journal Template Name" := ResJnlBatch."Journal Template Name";
      ResJnlLine."Journal Batch Name" := ResJnlBatch.Name;
      SuggestResourceJournalLines(ResJnlLine,TimeSheetHeader);

      // find and post created journal lines
      ResJnlLine.SETRANGE("Journal Template Name",ResJnlLine."Journal Template Name");
      ResJnlLine.SETRANGE("Journal Batch Name",ResJnlLine."Journal Batch Name");
      ResJnlLine.SETRANGE("Resource No.",TimeSheetHeader."Resource No.");
      ResJnlLine.FINDFIRST;
      // change quantity to the next higher
      ResJnlLine.VALIDATE(Quantity,TimeSheetLine."Total Quantity" + 10);
      ResJnlLine.MODIFY;

      ASSERTERROR ResJnlPostLine.RunWithCheck(ResJnlLine);
      Assert.IsTrue(STRPOS(GETLASTERRORTEXT,Text023) > 0,Text021);
Member of Lib.Library - Time Sheet


InitScenarioWTForJob@25 Method

The procedure InitScenarioWTForJob is available in codeunit 131904.

Syntax

InitScenarioWTForJob@25(
    VAR TimeSheetHeader@1008 : Record 950 TimeSheetHeader //Reference parameter of type Record
);

Parameters

TimeSheetHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Init, Scenario, WT, For, Job.

For a clarification about how this function works, refer to the code listed below.

      // create time sheet
      CreateTimeSheet(TimeSheetHeader,FALSE);

      FOR RowCount := 1 TO 2 DO BEGIN
        // create time sheet line with type Job
        // find job and task
        FindJob(Job);
        FindJobTask(Job."No.",JobTask);
        // job's responsible person (resource) must have Owner ID filled in
        Resource.GET(Job."Person Responsible");
        Resource."Time Sheet Owner User ID" := USERID;
        Resource.MODIFY;
        CreateTimeSheetLine(TimeSheetHeader,TimeSheetLine[RowCount],TimeSheetLine[RowCount].Type::Job,Job."No.",
          JobTask."Job Task No.",'','');
        // change work type
        IF RowCount = 2 THEN BEGIN
          // create work type
          Resource.GET(TimeSheetHeader."Resource No.");
          CreateWorkType(WorkType,Resource."Base Unit of Measure");
          TimeSheetLine[RowCount].VALIDATE(Chargeable,FALSE);
          TimeSheetLine[RowCount].VALIDATE("Work Type Code",WorkType.Code);
        END;
        TimeSheetLine[RowCount].MODIFY;
        CreateTimeSheetDetail(TimeSheetLine[RowCount],TimeSheetHeader."Starting Date",GetRandomDecimal);
        CreateTimeSheetDetail(TimeSheetLine[RowCount],TimeSheetHeader."Starting Date" + 1,GetRandomDecimal);
        TimeSheetApprovalMgt.Submit(TimeSheetLine[RowCount]);
      END;

Example

The below example is extracted from the test automation codeunit 136500 to show one way of using this function.

      SetUp;
      LibraryTimeSheet.InitScenarioWTForJob(TimeSheetHeader);

      // create work type
      Resource.GET(TimeSheetHeader."Resource No.");
      LibraryTimeSheet.CreateWorkType(WorkType,Resource."Base Unit of Measure");

      // find time sheet
      WORKDATE := TimeSheetHeader."Starting Date";
      ManagerTSbyJob.OPENEDIT;

      // change chargeable and work type on the manager page by job
      ManagerTSbyJob.FILTER.SETFILTER("Time Sheet No.",TimeSheetHeader."No.");
      ManagerTSbyJob.FILTER.SETFILTER(Status,'Submitted');
      GlobalWorkTypeCode := WorkType.Code;
      GlobalChargeable := FALSE;
      ManagerTSbyJob.Description.ASSISTEDIT;
      ManagerTSbyJob.Action37.INVOKE;

      TimeSheetLine.SETRANGE("Time Sheet No.",TimeSheetHeader."No.");
      TimeSheetLine.FINDFIRST;
      TimeSheetLine.TESTFIELD("Work Type Code",GlobalWorkTypeCode);
      TimeSheetLine.TESTFIELD(Chargeable,GlobalChargeable);

      TearDown;
Member of Lib.Library - Time Sheet


InitScenarioWTForServiceOrder@27 Method

The procedure InitScenarioWTForServiceOrder is available in codeunit 131904.

Syntax

InitScenarioWTForServiceOrder@27(
    VAR TimeSheetHeader@1008 : Record 950 TimeSheetHeader, //Reference parameter of type Record
    VAR ServiceHeader@1006 : Record 5900 ServiceHeader //Reference parameter of type Record
);

Parameters

TimeSheetHeader
Reference parameter of type Record
ServiceHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Init, Scenario, WT, For, Service, Order.

For a clarification about how this function works, refer to the code listed below.

      // create time sheet
      CreateTimeSheet(TimeSheetHeader,FALSE);

      // create work type
      Resource.GET(TimeSheetHeader."Resource No.");

      CreateServiceOrder(ServiceHeader,CALCDATE('<+3D>',TimeSheetHeader."Starting Date"));

      // create time sheets' lines with type Resource, some kind of Work Type and different chargeables
      CreateTimeSheetLine(TimeSheetHeader,TimeSheetLine,TimeSheetLine.Type::Service,'','',ServiceHeader."No.",'');
      TimeSheetLine.VALIDATE("Service Order No.",ServiceHeader."No.");
      TimeSheetLine.MODIFY;
      // set quantities for lines
      CreateTimeSheetDetail(TimeSheetLine,TimeSheetHeader."Starting Date",GetRandomDecimal);
      TimeSheetApprovalMgt.Submit(TimeSheetLine);

Example

The below example is extracted from the test automation codeunit 136500 to show one way of using this function.

      SetUp;
      LibraryTimeSheet.InitScenarioWTForServiceOrder(TimeSheetHeader,ServiceHeader);

      // create work type
      Resource.GET(TimeSheetHeader."Resource No.");
      LibraryTimeSheet.CreateWorkType(WorkType,Resource."Base Unit of Measure");

      // change chargeable and work type on the manager page
      WORKDATE := TimeSheetHeader."Starting Date";
      ManagerTimeSheet.OPENEDIT;
      ManagerTimeSheet.CurrTimeSheetNo.VALUE := TimeSheetHeader."No.";
      ManagerTimeSheet.FILTER.SETFILTER(Status,'Submitted');
      ManagerTimeSheet.FIRST;
      GlobalWorkTypeCode := WorkType.Code;
      GlobalChargeable := FALSE;
      ManagerTimeSheet.Description.ASSISTEDIT;
      ManagerTimeSheet.Approve.INVOKE;

      // compare table and page results
      TimeSheetLine.SETRANGE("Time Sheet No.",TimeSheetHeader."No.");
      TimeSheetLine.FINDFIRST;
      TimeSheetLine.TESTFIELD("Work Type Code",GlobalWorkTypeCode);
      TimeSheetLine.TESTFIELD(Chargeable,GlobalChargeable);

      TearDown;
Member of Lib.Library - Time Sheet


InitServiceScenario@10 Method

The procedure InitServiceScenario is available in codeunit 131904.

Syntax

InitServiceScenario@10(
    VAR TimeSheetHeader@1008 : Record 950 TimeSheetHeader, //Reference parameter of type Record
    VAR TimeSheetLine@1000 : Record 951 TimeSheetLine, //Reference parameter of type Record
    VAR ServiceHeader@1006 : Record 5900 ServiceHeader //Reference parameter of type Record
);

Parameters

TimeSheetHeader
Reference parameter of type Record
TimeSheetLine
Reference parameter of type Record
ServiceHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Init, Service, Scenario.

For a clarification about how this function works, refer to the code listed below.

      // create time sheet
      CreateTimeSheet(TimeSheetHeader,FALSE);

      // create service order
      IF ServiceHeader."No." = '' THEN
        CreateServiceOrder(ServiceHeader,CALCDATE('<+3D>',TimeSheetHeader."Starting Date"));

      // create time sheet line with type Service
      CreateTimeSheetLine(TimeSheetHeader,TimeSheetLine,TimeSheetLine.Type::Service,'','',ServiceHeader."No.",'');
      TimeSheetLine.VALIDATE("Service Order No.",ServiceHeader."No.");
      CreateTimeSheetDetail(TimeSheetLine,TimeSheetHeader."Starting Date",GetRandomDecimal);
      TimeSheetApprovalMgt.Submit(TimeSheetLine);
      TimeSheetApprovalMgt.Approve(TimeSheetLine);

Example

The below example is extracted from the test automation codeunit 136500 to show one way of using this function.

      SetUp;
      // test for function "Create lines from time sheets" for Service Order for few time sheets
      LibraryTimeSheet.InitServiceScenario(TimeSheetHeader,TimeSheetLine,ServiceHeader);
      TimeSheetNo[1] := TimeSheetHeader."No.";

      ServiceHeader.FIND;

      LibraryTimeSheet.InitServiceScenario(TimeSheetHeader,TimeSheetLine,ServiceHeader);
      TimeSheetNo[2] := TimeSheetHeader."No.";

      TimeSheetMgt.CreateServDocLinesFromTS(ServiceHeader);

      VerifyServiceLinesQtyForFewTS(ServiceHeader."No.",TimeSheetNo);

      TearDown;
Member of Lib.Library - Time Sheet


SubmitAndApproveTimeSheetLine@13 Method

The procedure SubmitAndApproveTimeSheetLine is available in codeunit 131904.

Syntax

SubmitAndApproveTimeSheetLine@13(
    TimeSheetLine@1000 : Record 951 TimeSheetLine //Input parameter of type Record
);

Parameters

TimeSheetLine
Input parameter of type Record

Remarks

The relevant search keywords are: Submit, Approve, Time, Sheet, Line.

For a clarification about how this function works, refer to the code listed below.

      TimeSheetApprovalMgt.Submit(TimeSheetLine);
      TimeSheetApprovalMgt.Approve(TimeSheetLine);

Example

The below example is extracted from the test automation codeunit 136502 to show one way of using this function.

      // [FEATURE] [Job] [Line Discount]
      // [SCENARIO 371948] Suggest Job Journal Line from Time Sheet with Line Discount %
      Initialize;
      LibraryTimeSheet.CreateTimeSheet(TimeSheetHeader,FALSE);

      // [GIVEN] Job, Job Task and Job Resource Price with Line Discount % = "X"
      LibraryJob.CreateJob(Job);
      LibraryJob.CreateJobTask(Job,JobTask);
      CreateJobResourcePriceWithLineDiscountPct(
        JobResourcePrice,JobTask."Job No.",JobTask."Job Task No.",
        JobResourcePrice.Type::Resource,TimeSheetHeader."Resource No.");

      // [GIVEN] Approved and Submitted Time Sheet with Time Sheet Line for created Job Task
      LibraryTimeSheet.CreateTimeSheetLine(
        TimeSheetHeader,TimeSheetLine,TimeSheetLine.Type::Job,
        Job."No.",JobTask."Job Task No.",'','');
      LibraryTimeSheet.CreateTimeSheetDetail(TimeSheetLine,TimeSheetHeader."Starting Date",1);
      LibraryTimeSheet.SubmitAndApproveTimeSheetLine(TimeSheetLine);

      // [WHEN] Suggest Job Journal Line from Time Sheet
      SuggestJobJournalLines(JobJnlLine,TimeSheetHeader,TimeSheetLine);

      // [THEN] Created Job Journal Line has field Line Discount % = "X"
      FilterJobJournalLineByBatchTemplate(JobJnlLine,JobJnlLine."Journal Template Name",JobJnlLine."Journal Batch Name");
      JobJnlLine.FINDFIRST;
      JobJnlLine.TESTFIELD("Line Discount %",JobResourcePrice."Line Discount %");
Member of Lib.Library - Time Sheet


Library - Trees Class

Lib.Library - Trees

COD132208 applies to SCM,W1,All.

Methods

Name | Description
AddCostToRouting@32 | The procedure AddCostToRouting is available in codeunit 132208.
AddOverhead@38 | The procedure AddOverhead is available in codeunit 132208.
AddScrapForItems@31 | The procedure AddScrapForItems is available in codeunit 132208.
AddScrapForMachineCenters@55 | The procedure AddScrapForMachineCenters is available in codeunit 132208.
AddScrapForProdBOM@53 | The procedure AddScrapForProdBOM is available in codeunit 132208.
AddScrapForRoutings@51 | The procedure AddScrapForRoutings is available in codeunit 132208.
AddSubcontracting@20 | The procedure AddSubcontracting is available in codeunit 132208.
AddTreeVariants@2 | The procedure AddTreeVariants is available in codeunit 132208.
CreateMixedTree@94 | The procedure CreateMixedTree is available in codeunit 132208.
CreateNodeSupply@4 | The procedure CreateNodeSupply is available in codeunit 132208.
CreateSupply@5 | The procedure CreateSupply is available in codeunit 132208.
GetQtyPerInTree@1 | The procedure GetQtyPerInTree is available in codeunit 132208.
GetTree@91 | The procedure GetTree is available in codeunit 132208.
GetTreeCost@92 | The procedure GetTreeCost is available in codeunit 132208.
GetTreeCostWithScrap@33 | The procedure GetTreeCostWithScrap is available in codeunit 132208.

See Also

Lib


AddCostToRouting@32 Method

The procedure AddCostToRouting is available in codeunit 132208.

Syntax

AddCostToRouting@32(
    VAR TempWorkCenter@1000 : TEMPORARY Record 99000754 TempWorkCenter, //Reference Temporary parameter of type Record
    VAR TempMachineCenter@1001 : TEMPORARY Record 99000758 TempMachineCenter //Reference Temporary parameter of type Record
);

Parameters

TempWorkCenter
Reference Temporary parameter of type Record
TempMachineCenter
Reference Temporary parameter of type Record

Remarks

The relevant search keywords are: Add, Cost, To, Routing.

For a clarification about how this function works, refer to the code listed below.

      IF TempWorkCenter.FINDSET THEN
        REPEAT
          WorkCenter.GET(TempWorkCenter."No.");
          WorkCenter.VALIDATE("Direct Unit Cost",LibraryRandom.RandInt(5));
          WorkCenter.MODIFY(TRUE);
        UNTIL TempWorkCenter.NEXT = 0;

      IF TempMachineCenter.FINDSET THEN
        REPEAT
          MachineCenter.GET(TempMachineCenter."No.");
          MachineCenter.VALIDATE("Direct Unit Cost",LibraryRandom.RandInt(5));
          MachineCenter.MODIFY(TRUE);
        UNTIL TempMachineCenter.NEXT = 0;

Example

The below example is extracted from the test automation codeunit 137110 to show one way of using this function.

      // Setup.
      Initialize;
      LibraryTrees.CreateMixedTree(Item,TopItemReplSystem,Item."Costing Method"::Standard,Depth,ChildLeaves,RoutingLines);
      LibraryTrees.GetTree(TempItem,TempResource,TempWorkCenter,TempMachineCenter,Item);
      LibraryTrees.AddCostToRouting(TempWorkCenter,TempMachineCenter);
      CalcStandardCost.CalcItem(Item."No.",(Item."Replenishment System" = Item."Replenishment System"::Assembly));

      // Exercise: Create the BOM tree.
      CalculateTree(BOMBuf,Item);

      // Verify: Navigate through the tree and check the results.
      VerifyTree(BOMBuf,Item);
      VerifyTopItem(BOMBuf,Item);
Member of Lib.Library - Trees


AddOverhead@38 Method

The procedure AddOverhead is available in codeunit 132208.

Syntax

AddOverhead@38(
    VAR TempItem@1001 : TEMPORARY Record 27 TempItem, //Reference Temporary parameter of type Record
    VAR TempResource@1002 : TEMPORARY Record 156 TempResource, //Reference Temporary parameter of type Record
    VAR TempWorkCenter@1000 : TEMPORARY Record 99000754 TempWorkCenter, //Reference Temporary parameter of type Record
    VAR TempMachineCenter@1004 : TEMPORARY Record 99000758 TempMachineCenter //Reference Temporary parameter of type Record
);

Parameters

TempItem
Reference Temporary parameter of type Record
TempResource
Reference Temporary parameter of type Record
TempWorkCenter
Reference Temporary parameter of type Record
TempMachineCenter
Reference Temporary parameter of type Record

Remarks

The relevant search keywords are: Add, Overhead.

For a clarification about how this function works, refer to the code listed below.

      IF TempItem.FINDSET THEN
        REPEAT
          LibraryAssembly.ModifyItem(TempItem."No.",TRUE,LibraryRandom.RandInt(5),LibraryRandom.RandInt(5));
        UNTIL TempItem.NEXT = 0;

      IF TempResource.FINDSET THEN
        REPEAT
          Resource.GET(TempResource."No.");
          Resource.VALIDATE("Indirect Cost %",LibraryRandom.RandInt(5));
          Resource.MODIFY(TRUE);
        UNTIL TempResource.NEXT = 0;

      IF TempWorkCenter.FINDSET THEN
        REPEAT
          WorkCenter.GET(TempWorkCenter."No.");
          WorkCenter.VALIDATE("Indirect Cost %",LibraryRandom.RandInt(5));
          WorkCenter.VALIDATE("Overhead Rate",LibraryRandom.RandInt(5));
          WorkCenter.MODIFY(TRUE);
        UNTIL TempWorkCenter.NEXT = 0;

      IF TempMachineCenter.FINDSET THEN
        REPEAT
          MachineCenter.GET(TempMachineCenter."No.");
          MachineCenter.VALIDATE("Indirect Cost %",LibraryRandom.RandInt(5));
          MachineCenter.VALIDATE("Overhead Rate",LibraryRandom.RandInt(5));
          MachineCenter.MODIFY(TRUE);
        UNTIL TempMachineCenter.NEXT = 0;

Example

The below example is extracted from the test automation codeunit 137110 to show one way of using this function.

      // Setup.
      Initialize;
      LibraryTrees.CreateMixedTree(Item,TopItemReplSystem,Item."Costing Method"::Standard,Depth,ChildLeaves,RoutingLines);
      LibraryTrees.GetTree(TempItem,TempResource,TempWorkCenter,TempMachineCenter,Item);
      LibraryTrees.AddCostToRouting(TempWorkCenter,TempMachineCenter);
      LibraryTrees.AddOverhead(TempItem,TempResource,TempWorkCenter,TempMachineCenter);
      CalcStandardCost.CalcItem(Item."No.",(Item."Replenishment System" = Item."Replenishment System"::Assembly));

      // Exercise: Create the BOM tree.
      CalculateTree(BOMBuf,Item);

      // Verify: Navigate through the tree and check the results.
      VerifyTree(BOMBuf,Item);
      VerifyTopItem(BOMBuf,Item);
Member of Lib.Library - Trees


AddScrapForItems@31 Method

The procedure AddScrapForItems is available in codeunit 132208.

Syntax

AddScrapForItems@31(
    VAR TempItem@1000 : TEMPORARY Record 27 TempItem //Reference Temporary parameter of type Record
);

Parameters

TempItem
Reference Temporary parameter of type Record

Remarks

The relevant search keywords are: Add, Scrap, For, Items.

For a clarification about how this function works, refer to the code listed below.

      IF TempItem.FINDSET THEN
        REPEAT
          Item.GET(TempItem."No.");
          Item.VALIDATE("Scrap %",LibraryRandom.RandInt(10));
          Item.MODIFY(TRUE);
        UNTIL TempItem.NEXT = 0;

Example

The below example is extracted from the test automation codeunit 137110 to show one way of using this function.

      // Setup.
      Initialize;
      LibraryTrees.CreateMixedTree(Item,TopItemReplSystem,Item."Costing Method"::Standard,Depth,ChildLeaves,RoutingLines);
      LibraryTrees.GetTree(TempItem,TempResource,TempWorkCenter,TempMachineCenter,Item);
      LibraryTrees.AddCostToRouting(TempWorkCenter,TempMachineCenter);
      LibraryTrees.AddScrapForItems(TempItem);
      CalcStandardCost.CalcItem(Item."No.",(Item."Replenishment System" = Item."Replenishment System"::Assembly));

      // Exercise: Create the BOM tree.
      CalculateTree(BOMBuf,Item);

      // Verify: Navigate through the tree and check the results.
      VerifyTree(BOMBuf,Item);
      VerifyTreeWithScrap(BOMBuf,Item);
Member of Lib.Library - Trees


AddScrapForMachineCenters@55 Method

The procedure AddScrapForMachineCenters is available in codeunit 132208.

Syntax

AddScrapForMachineCenters@55(
    VAR TempMachineCenter@1000 : TEMPORARY Record 99000758 TempMachineCenter //Reference Temporary parameter of type Record
);

Parameters

TempMachineCenter
Reference Temporary parameter of type Record

Remarks

The relevant search keywords are: Add, Scrap, For, Machine, Centers.

For a clarification about how this function works, refer to the code listed below.

      IF TempMachineCenter.FINDSET THEN
        REPEAT
          MachineCenter.GET(TempMachineCenter."No.");
          MachineCenter.VALIDATE("Scrap %",LibraryRandom.RandInt(10));
          MachineCenter.VALIDATE("Fixed Scrap Quantity",LibraryRandom.RandInt(10));
          MachineCenter.MODIFY(TRUE);
        UNTIL TempMachineCenter.NEXT = 0;

Example

The below example is extracted from the test automation codeunit 137110 to show one way of using this function.

      // Setup.
      Initialize;
      LibraryTrees.CreateMixedTree(Item,TopItemReplSystem,Item."Costing Method"::Standard,Depth,ChildLeaves,RoutingLines);
      LibraryTrees.GetTree(TempItem,TempResource,TempWorkCenter,TempMachineCenter,Item);
      LibraryTrees.AddCostToRouting(TempWorkCenter,TempMachineCenter);
      LibraryTrees.AddScrapForMachineCenters(TempMachineCenter);
      CalcStandardCost.CalcItem(Item."No.",(Item."Replenishment System" = Item."Replenishment System"::Assembly));

      // Exercise: Create the BOM tree.
      CalculateTree(BOMBuf,Item);

      // Verify: Navigate through the tree and check the results.
      VerifyTree(BOMBuf,Item);
      VerifyTopItem(BOMBuf,Item);
Member of Lib.Library - Trees


AddScrapForProdBOM@53 Method

The procedure AddScrapForProdBOM is available in codeunit 132208.

Syntax

AddScrapForProdBOM@53(
    VAR TempItem@1000 : TEMPORARY Record 27 TempItem //Reference Temporary parameter of type Record
);

Parameters

TempItem
Reference Temporary parameter of type Record

Remarks

The relevant search keywords are: Add, Scrap, For, Product, BOM.

For a clarification about how this function works, refer to the code listed below.

      IF TempItem.FINDSET THEN
        REPEAT
          IF ProdBOMHeader.GET(TempItem."Production BOM No.") THEN BEGIN
            ProdBOMHeader.VALIDATE(Status,ProdBOMHeader.Status::"Under Development");
            ProdBOMHeader.MODIFY(TRUE);
            ProdBOMLine.SETRANGE("Production BOM No.",ProdBOMHeader."No.");
            ProdBOMLine.SETRANGE(Type,ProdBOMLine.Type::Item);
            IF ProdBOMLine.FINDSET THEN
              REPEAT
                ProdBOMLine.VALIDATE("Scrap %",LibraryRandom.RandInt(10));
                ProdBOMLine.MODIFY(TRUE);
              UNTIL ProdBOMLine.NEXT = 0;
            ProdBOMHeader.VALIDATE(Status,ProdBOMHeader.Status::Certified);
            ProdBOMHeader.MODIFY(TRUE);
          END;
        UNTIL TempItem.NEXT = 0;

Example

The below example is extracted from the test automation codeunit 137110 to show one way of using this function.

      // Setup.
      Initialize;
      LibraryTrees.CreateMixedTree(Item,TopItemReplSystem,Item."Costing Method"::Standard,Depth,ChildLeaves,RoutingLines);
      LibraryTrees.GetTree(TempItem,TempResource,TempWorkCenter,TempMachineCenter,Item);
      LibraryTrees.AddCostToRouting(TempWorkCenter,TempMachineCenter);
      LibraryTrees.AddScrapForProdBOM(TempItem);
      CalcStandardCost.CalcItem(Item."No.",(Item."Replenishment System" = Item."Replenishment System"::Assembly));

      // Exercise: Create the BOM tree.
      CalculateTree(BOMBuf,Item);

      // Verify: Navigate through the tree and check the results.
      VerifyTree(BOMBuf,Item);
      VerifyTreeWithScrap(BOMBuf,Item);
Member of Lib.Library - Trees


AddScrapForRoutings@51 Method

The procedure AddScrapForRoutings is available in codeunit 132208.

Syntax

AddScrapForRoutings@51(
    VAR TempItem@1000 : TEMPORARY Record 27 TempItem //Reference Temporary parameter of type Record
);

Parameters

TempItem
Reference Temporary parameter of type Record

Remarks

The relevant search keywords are: Add, Scrap, For, Routings.

For a clarification about how this function works, refer to the code listed below.

      IF TempItem.FINDSET THEN
        REPEAT
          IF RoutingHeader.GET(TempItem."Routing No.") THEN BEGIN
            RoutingHeader.VALIDATE(Status,RoutingHeader.Status::"Under Development");
            RoutingHeader.MODIFY(TRUE);
            RoutingLine.SETRANGE("Routing No.",RoutingHeader."No.");
            IF RoutingLine.FINDSET THEN
              REPEAT
                RoutingLine.VALIDATE("Scrap Factor %",LibraryRandom.RandInt(10));
                RoutingLine.MODIFY(TRUE);
              UNTIL RoutingLine.NEXT = 0;
            RoutingHeader.VALIDATE(Status,RoutingHeader.Status::Certified);
            RoutingHeader.MODIFY(TRUE);
          END;
        UNTIL TempItem.NEXT = 0;

Example

The below example is extracted from the test automation codeunit 137110 to show one way of using this function.

      // Setup.
      Initialize;
      LibraryTrees.CreateMixedTree(Item,TopItemReplSystem,Item."Costing Method"::Standard,Depth,ChildLeaves,RoutingLines);
      LibraryTrees.GetTree(TempItem,TempResource,TempWorkCenter,TempMachineCenter,Item);
      LibraryTrees.AddCostToRouting(TempWorkCenter,TempMachineCenter);
      LibraryTrees.AddScrapForRoutings(TempItem);
      CalcStandardCost.CalcItem(Item."No.",(Item."Replenishment System" = Item."Replenishment System"::Assembly));

      // Exercise: Create the BOM tree.
      CalculateTree(BOMBuf,Item);

      // Verify: Navigate through the tree and check the results.
      VerifyTree(BOMBuf,Item);
      VerifyTreeWithScrap(BOMBuf,Item);
Member of Lib.Library - Trees


AddSubcontracting@20 Method

The procedure AddSubcontracting is available in codeunit 132208.

Syntax

AddSubcontracting@20(
    VAR TempWorkCenter@1000 : TEMPORARY Record 99000754 TempWorkCenter //Reference Temporary parameter of type Record
);

Parameters

TempWorkCenter
Reference Temporary parameter of type Record

Remarks

The relevant search keywords are: Add, Subcontracting.

For a clarification about how this function works, refer to the code listed below.

      IF TempWorkCenter.FINDSET THEN BEGIN
        TempWorkCenter.NEXT(RANDOM(TempWorkCenter.COUNT));
        WorkCenter.GET(TempWorkCenter."No.");
        LibraryPurchase.CreateSubcontractor(Vendor);
        WorkCenter.VALIDATE("Subcontractor No.",Vendor."No.");
        WorkCenter.MODIFY(TRUE);
      END;

Example

The below example is extracted from the test automation codeunit 137110 to show one way of using this function.

      // Setup.
      Initialize;
      LibraryTrees.CreateMixedTree(Item,TopItemReplSystem,Item."Costing Method"::Standard,Depth,ChildLeaves,RoutingLines);
      LibraryTrees.GetTree(TempItem,TempResource,TempWorkCenter,TempMachineCenter,Item);
      LibraryTrees.AddCostToRouting(TempWorkCenter,TempMachineCenter);
      LibraryTrees.AddSubcontracting(TempWorkCenter);
      CalcStandardCost.CalcItem(Item."No.",(Item."Replenishment System" = Item."Replenishment System"::Assembly));

      // Exercise: Create the BOM tree.
      CalculateTree(BOMBuf,Item);

      // Verify: Navigate through the tree and check the results.
      VerifyTree(BOMBuf,Item);
      VerifyTopItem(BOMBuf,Item);
Member of Lib.Library - Trees


AddTreeVariants@2 Method

The procedure AddTreeVariants is available in codeunit 132208.

Syntax

AddTreeVariants@2(
    ParentItemNo@1000 : Code[20] ParentItemNo //Input parameter of type Code
);

Parameters

ParentItemNo
Input parameter of type Code

Remarks

The relevant search keywords are: Add, Tree, Variants.

For a clarification about how this function works, refer to the code listed below.

      Item.GET(ParentItemNo);
      CASE Item."Replenishment System" OF
        Item."Replenishment System"::Assembly:
          BEGIN
            BOMComponent.SETRANGE("Parent Item No.",Item."No.");
            BOMComponent.SETRANGE(Type,BOMComponent.Type::Item);
            IF BOMComponent.FINDSET THEN
              REPEAT
                LibraryInventory.CreateItemVariant(ItemVariant,BOMComponent."No.");
                BOMComponent.VALIDATE("Variant Code",ItemVariant.Code);
                BOMComponent.MODIFY;
                AddTreeVariants(BOMComponent."No.");
              UNTIL BOMComponent.NEXT = 0;
          END;
        Item."Replenishment System"::"Prod. Order":
          BEGIN
            ProdBOMHeader.GET(Item."Production BOM No.");
            ProdBOMHeader.VALIDATE(Status,ProdBOMHeader.Status::New);
            ProdBOMHeader.MODIFY;
            ProdBOMLine.SETRANGE("Production BOM No.",Item."Production BOM No.");
            ProdBOMLine.SETRANGE(Type,ProdBOMLine.Type::Item);
            IF ProdBOMLine.FINDSET THEN
              REPEAT
                LibraryInventory.CreateItemVariant(ItemVariant,ProdBOMLine."No.");
                ProdBOMLine.VALIDATE("Variant Code",ItemVariant.Code);
                ProdBOMLine.MODIFY(TRUE);
                AddTreeVariants(ProdBOMLine."No.");
              UNTIL ProdBOMLine.NEXT = 0;
            ProdBOMHeader.VALIDATE(Status,ProdBOMHeader.Status::Certified);
            ProdBOMHeader.MODIFY;
          END;
      END;

Example

The below example is extracted from the test automation codeunit 137107 to show one way of using this function.

      // Setup.
      Initialize;
      AbleToMake := LibraryRandom.RandIntInRange(10,25);

      LibraryAssembly.SetupPostingToGL(GenProdPostingGroup,InventoryPostingGroup,InventoryPostingGroup,'');
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location);
      LibraryAssembly.CreateItem(
        Item,Item."Costing Method"::Standard,Item."Replenishment System"::Assembly,GenProdPostingGroup,InventoryPostingGroup);
      LibraryInventory.CreateItemVariant(ItemVariant,Item."No.");
      LibraryTrees.CreateMixedTree(Item,Item."Replenishment System"::Assembly,Item."Costing Method"::Standard,Depth,ChildLeaves,2);
      LibraryTrees.AddTreeVariants(Item."No.");
      LibraryTrees.CreateNodeSupply(Item."No.",Location.Code,WORKDATE,SourceType,AbleToMake,BottleneckFactor,DirectAvailFactor);

      Item.SETRANGE("No.",Item."No.");
      EVALUATE(DueDateDelayDateFormula,DueDateDelay);
      Item.SETRANGE("Date Filter",0D,CALCDATE(DueDateDelayDateFormula,WORKDATE));

      IF TestVariant THEN
        LibraryInventory.CreateItemVariant(ItemVariant,Item."No.");
      Item.SETRANGE("Variant Filter",ItemVariant.Code);

      IF TestLocation THEN
        LibraryWarehouse.CreateLocation(Location);
      Item.SETRANGE("Location Filter",Location.Code);

      IF TestLocation OR (DueDateDelay <> '<0D>') THEN
        AbleToMake := 0;

      // Exercise: Create the BOM tree.
      CalculateBOMTree.SetShowTotalAvailability(ShowTotalAvailability);
      CalculateBOMTree.GenerateTreeForItems(Item,BOMBuffer,TreeType::Availability);

      // Verify: Navigate through the tree and check the results.
      VerifyTree(BOMBuffer,Item."No.",ShowTotalAvailability,BottleneckFactor,AbleToMake,1,DirectAvailFactor,0);
      VerifyNode(BOMBuffer,Item."No.",0,AbleToMake * BottleneckFactor,1,1);
      BOMBuffer."Location Code" := Location.Code;
      BOMBuffer.MODIFY;
Member of Lib.Library - Trees


CreateMixedTree@94 Method

The procedure CreateMixedTree is available in codeunit 132208.

Syntax

CreateMixedTree@94(
    VAR Item@1001 : Record 27 Item, //Reference parameter of type Record
    TopItemReplSystem@1006 : Option TopItemReplSystem, //Input parameter of type Option
    CostingMethod@1005 : Option CostingMethod, //Input parameter of type Option
    TreeDepth@1000 : Integer TreeDepth, //Input parameter of type Integer
    NoOfComps@1007 : Integer NoOfComps, //Input parameter of type Integer
    NoOfRoutingLines@1011 : Integer NoOfRoutingLines //Input parameter of type Integer
);

Parameters

Item
Reference parameter of type Record
TopItemReplSystem
Input parameter of type Option
CostingMethod
Input parameter of type Option
TreeDepth
Input parameter of type Integer
NoOfComps
Input parameter of type Integer
NoOfRoutingLines
Input parameter of type Integer

Remarks

The relevant search keywords are: Create, Mixed, Tree.

For a clarification about how this function works, refer to the code listed below.

      // Create top item and its assembly / prod BOM.
      LibraryAssembly.CreateItem(Item,CostingMethod,TopItemReplSystem,'','');
      Item.VALIDATE("Lot Size",LibraryRandom.RandInt(10));
      Item.MODIFY(TRUE);

      IF TopItemReplSystem = Item."Replenishment System"::"Prod. Order" THEN BEGIN
        LibraryAssembly.CreateRouting(Item,NoOfRoutingLines);
        LibraryAssembly.CreateBOM(Item,NoOfComps);
      END ELSE
        LibraryAssembly.CreateAssemblyList(Item."Costing Method"::Standard,Item."No.",TRUE,NoOfComps,NoOfComps,NoOfComps,1,'','');

      // Recurrence exit condition.
      IF TreeDepth = 0 THEN
        EXIT;

      // Create left branch of sub tree.
      CreateMixedTree(Item1,Item."Replenishment System"::"Prod. Order",CostingMethod,TreeDepth - 1,NoOfComps,NoOfRoutingLines);
      Item1.FIND;

      // Create right branch of sub tree.
      CreateMixedTree(Item2,Item."Replenishment System"::Assembly,CostingMethod,TreeDepth - 1,NoOfComps,NoOfRoutingLines);
      Item2.FIND;

      // Connect the 2 sub trees to the parent item.
      CASE Item."Replenishment System" OF
        Item."Replenishment System"::"Prod. Order":
          BEGIN
            ProdBOMHeader.GET(Item."Production BOM No.");
            ProdBOMHeader.VALIDATE(Status,ProdBOMHeader.Status::"Under Development");
            ProdBOMHeader.MODIFY(TRUE);
            LibraryManufacturing.CreateProductionBOMLine(
              ProdBOMHeader,ProdBOMLine,'',ProdBOMLine.Type::Item,Item1."No.",LibraryRandom.RandInt(5));
            LibraryManufacturing.CreateProductionBOMLine(
              ProdBOMHeader,ProdBOMLine,'',ProdBOMLine.Type::Item,Item2."No.",LibraryRandom.RandInt(5));
            ProdBOMHeader.VALIDATE(Status,ProdBOMHeader.Status::Certified);
            ProdBOMHeader.MODIFY(TRUE);
          END;
        Item."Replenishment System"::Assembly:
          BEGIN
            LibraryAssembly.CreateAssemblyListComponent(
              BOMComponent.Type::Item,Item1."No.",Item."No.",'',BOMComponent."Resource Usage Type"::Direct,
              LibraryRandom.RandInt(5),TRUE);
            LibraryAssembly.CreateAssemblyListComponent(
              BOMComponent.Type::Item,Item2."No.",Item."No.",'',BOMComponent."Resource Usage Type"::Direct,
              LibraryRandom.RandInt(5),TRUE);
          END;
      END;

Example

The below example is extracted from the test automation codeunit 137107 to show one way of using this function.

      // Setup.
      Initialize;
      AbleToMake := LibraryRandom.RandIntInRange(10,25);

      LibraryAssembly.SetupPostingToGL(GenProdPostingGroup,InventoryPostingGroup,InventoryPostingGroup,'');
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location);
      LibraryAssembly.CreateItem(
        Item,Item."Costing Method"::Standard,Item."Replenishment System"::Assembly,GenProdPostingGroup,InventoryPostingGroup);
      LibraryInventory.CreateItemVariant(ItemVariant,Item."No.");
      LibraryTrees.CreateMixedTree(Item,Item."Replenishment System"::Assembly,Item."Costing Method"::Standard,Depth,ChildLeaves,2);
      LibraryTrees.AddTreeVariants(Item."No.");
      LibraryTrees.CreateNodeSupply(Item."No.",Location.Code,WORKDATE,SourceType,AbleToMake,BottleneckFactor,DirectAvailFactor);

      Item.SETRANGE("No.",Item."No.");
      EVALUATE(DueDateDelayDateFormula,DueDateDelay);
      Item.SETRANGE("Date Filter",0D,CALCDATE(DueDateDelayDateFormula,WORKDATE));

      IF TestVariant THEN
        LibraryInventory.CreateItemVariant(ItemVariant,Item."No.");
      Item.SETRANGE("Variant Filter",ItemVariant.Code);

      IF TestLocation THEN
        LibraryWarehouse.CreateLocation(Location);
      Item.SETRANGE("Location Filter",Location.Code);

      IF TestLocation OR (DueDateDelay <> '<0D>') THEN
        AbleToMake := 0;

      // Exercise: Create the BOM tree.
      CalculateBOMTree.SetShowTotalAvailability(ShowTotalAvailability);
      CalculateBOMTree.GenerateTreeForItems(Item,BOMBuffer,TreeType::Availability);

      // Verify: Navigate through the tree and check the results.
      VerifyTree(BOMBuffer,Item."No.",ShowTotalAvailability,BottleneckFactor,AbleToMake,1,DirectAvailFactor,0);
      VerifyNode(BOMBuffer,Item."No.",0,AbleToMake * BottleneckFactor,1,1);
      BOMBuffer."Location Code" := Location.Code;
      BOMBuffer.MODIFY;
Member of Lib.Library - Trees


CreateNodeSupply@4 Method

The procedure CreateNodeSupply is available in codeunit 132208.

Syntax

CreateNodeSupply@4(
    ParentItemNo@1000 : Code[20] ParentItemNo, //Input parameter of type Code
    LocationCode@1006 : Code[10] LocationCode, //Input parameter of type Code
    DueDate@1010 : Date DueDate, //Input parameter of type Date
    SourceType@1009 : Option SourceType, //Input parameter of type Option
    Qty@1001 : Decimal Qty, //Input parameter of type Decimal
    BottleneckFactor@1004 : Decimal BottleneckFactor, //Input parameter of type Decimal
    DirectAvailFactor@1005 : Decimal DirectAvailFactor //Input parameter of type Decimal
);

Parameters

ParentItemNo
Input parameter of type Code
LocationCode
Input parameter of type Code
DueDate
Input parameter of type Date
SourceType
Input parameter of type Option
Qty
Input parameter of type Decimal
BottleneckFactor
Input parameter of type Decimal
DirectAvailFactor
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Node, Supply.

For a clarification about how this function works, refer to the code listed below.

      MfgSetup.GET;
      BOMComponent.SETRANGE("Parent Item No.",ParentItemNo);
      BOMComponent.SETRANGE(Type,BOMComponent.Type::Item);

      IF BOMComponent.FINDSET THEN
        REPEAT
          BOMComponent.CALCFIELDS("Assembly BOM");
          IF BOMComponent."Assembly BOM" THEN BEGIN
            DirectAvailability := Qty * BottleneckFactor * DirectAvailFactor;
            CreateNodeSupply(
              BOMComponent."No.",LocationCode,CALCDATE('<-' + FORMAT(MfgSetup."Default Safety Lead Time") + '>',DueDate),SourceType,
              (Qty * BottleneckFactor - DirectAvailability) * BOMComponent."Quantity per",1,DirectAvailFactor);

            IF DirectAvailability > 0 THEN BEGIN
              CreateSupply(
                BOMComponent."No.",BOMComponent."Variant Code",LocationCode,
                CALCDATE('<-' + FORMAT(MfgSetup."Default Safety Lead Time") + '>',DueDate),SourceType,
                DirectAvailability * BOMComponent."Quantity per");
              // Create un-available supply: by variant, location.
              CreateSupply(
                BOMComponent."No.",'',LocationCode,CALCDATE('<-' + FORMAT(MfgSetup."Default Safety Lead Time") + '>',DueDate),
                SourceType,(DirectAvailability + 1) * BOMComponent."Quantity per");
              CreateSupply(
                BOMComponent."No.",BOMComponent."Variant Code",'',
                CALCDATE('<-' + FORMAT(MfgSetup."Default Safety Lead Time") + '>',DueDate),SourceType,
                (DirectAvailability + 1) * BOMComponent."Quantity per");
            END;
          END ELSE BEGIN
            CreateSupply(
              BOMComponent."No.",BOMComponent."Variant Code",LocationCode,
              CALCDATE('<-' + FORMAT(MfgSetup."Default Safety Lead Time") + '>',DueDate),SourceType,Qty * BOMComponent."Quantity per");
            // Create  un-available supply: by variant, location.
            CreateSupply(
              BOMComponent."No.",'',LocationCode,CALCDATE('<-' + FORMAT(MfgSetup."Default Safety Lead Time") + '>',DueDate),
              SourceType,(Qty + 1) * BOMComponent."Quantity per");
            CreateSupply(
              BOMComponent."No.",BOMComponent."Variant Code",'',
              CALCDATE('<-' + FORMAT(MfgSetup."Default Safety Lead Time") + '>',DueDate),SourceType,
              (Qty + 1) * BOMComponent."Quantity per");
          END;

        UNTIL BOMComponent.NEXT = 0;

Example

The below example is extracted from the test automation codeunit 137107 to show one way of using this function.

      // Setup.
      Initialize;
      AbleToMake := LibraryRandom.RandIntInRange(10,25);

      LibraryAssembly.SetupPostingToGL(GenProdPostingGroup,InventoryPostingGroup,InventoryPostingGroup,'');
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location);
      LibraryAssembly.CreateItem(
        Item,Item."Costing Method"::Standard,Item."Replenishment System"::Assembly,GenProdPostingGroup,InventoryPostingGroup);
      LibraryInventory.CreateItemVariant(ItemVariant,Item."No.");
      LibraryTrees.CreateMixedTree(Item,Item."Replenishment System"::Assembly,Item."Costing Method"::Standard,Depth,ChildLeaves,2);
      LibraryTrees.AddTreeVariants(Item."No.");
      LibraryTrees.CreateNodeSupply(Item."No.",Location.Code,WORKDATE,SourceType,AbleToMake,BottleneckFactor,DirectAvailFactor);

      Item.SETRANGE("No.",Item."No.");
      EVALUATE(DueDateDelayDateFormula,DueDateDelay);
      Item.SETRANGE("Date Filter",0D,CALCDATE(DueDateDelayDateFormula,WORKDATE));

      IF TestVariant THEN
        LibraryInventory.CreateItemVariant(ItemVariant,Item."No.");
      Item.SETRANGE("Variant Filter",ItemVariant.Code);

      IF TestLocation THEN
        LibraryWarehouse.CreateLocation(Location);
      Item.SETRANGE("Location Filter",Location.Code);

      IF TestLocation OR (DueDateDelay <> '<0D>') THEN
        AbleToMake := 0;

      // Exercise: Create the BOM tree.
      CalculateBOMTree.SetShowTotalAvailability(ShowTotalAvailability);
      CalculateBOMTree.GenerateTreeForItems(Item,BOMBuffer,TreeType::Availability);

      // Verify: Navigate through the tree and check the results.
      VerifyTree(BOMBuffer,Item."No.",ShowTotalAvailability,BottleneckFactor,AbleToMake,1,DirectAvailFactor,0);
      VerifyNode(BOMBuffer,Item."No.",0,AbleToMake * BottleneckFactor,1,1);
      BOMBuffer."Location Code" := Location.Code;
      BOMBuffer.MODIFY;
Member of Lib.Library - Trees


CreateSupply@5 Method

The procedure CreateSupply is available in codeunit 132208.

Syntax

CreateSupply@5(
    ItemNo@1000 : Code[20] ItemNo, //Input parameter of type Code
    VariantCode@1002 : Code[10] VariantCode, //Input parameter of type Code
    LocationCode@1001 : Code[10] LocationCode, //Input parameter of type Code
    DueDate@1003 : Date DueDate, //Input parameter of type Date
    ItemSupplyType@1005 : Option ItemSupplyType, //Input parameter of type Option
    Qty@1004 : Decimal Qty //Input parameter of type Decimal
);

Parameters

ItemNo
Input parameter of type Code
VariantCode
Input parameter of type Code
LocationCode
Input parameter of type Code
DueDate
Input parameter of type Date
ItemSupplyType
Input parameter of type Option
Qty
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Supply.

For a clarification about how this function works, refer to the code listed below.

      CASE ItemSupplyType OF
        SupplyType::Inventory:
          BEGIN
            LibraryInventory.SelectItemJournalTemplateName(ItemJournalTemplate,ItemJournalTemplate.Type::Item);
            LibraryInventory.SelectItemJournalBatchName(
              ItemJournalBatch,ItemJournalBatch."Template Type"::Item,ItemJournalTemplate.Name);
            LibraryInventory.CreateItemJournalLine(
              ItemJournalLine,ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name,
              ItemJournalLine."Entry Type"::"Positive Adjmt.",ItemNo,Qty);

            ItemJournalLine.VALIDATE("Location Code",LocationCode);
            ItemJournalLine.VALIDATE("Variant Code",VariantCode);
            ItemJournalLine.VALIDATE("Posting Date",DueDate);
            ItemJournalLine.MODIFY(TRUE);

            LibraryInventory.PostItemJournalLine(ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name);
          END;
        SupplyType::Purchase:
          BEGIN
            LibraryPurchase.CreatePurchHeader(PurchaseHeader,PurchaseHeader."Document Type"::Order,'');
            LibraryPurchase.CreatePurchaseLine(PurchaseLine,PurchaseHeader,PurchaseLine.Type::Item,ItemNo,Qty);
            PurchaseLine.VALIDATE("Location Code",LocationCode);
            PurchaseLine.VALIDATE("Variant Code",VariantCode);
            PurchaseLine.VALIDATE("Expected Receipt Date",DueDate);
            PurchaseLine.MODIFY(TRUE);
          END;
        SupplyType::"Prod. Order":
          BEGIN
            LibraryManufacturing.CreateProductionOrder(
              ProductionOrder,ProductionOrder.Status::Released,ProductionOrder."Source Type"::Item,ItemNo,Qty);
            ProductionOrder.VALIDATE("Due Date",DueDate);
            ProductionOrder.VALIDATE("Location Code",LocationCode);
            ProductionOrder.MODIFY(TRUE);

            LibraryManufacturing.RefreshProdOrder(ProductionOrder,FALSE,TRUE,FALSE,FALSE,FALSE);
            ProdOrderLine.SETRANGE(Status,ProductionOrder.Status);
            ProdOrderLine.SETRANGE("Prod. Order No.",ProductionOrder."No.");
            IF ProdOrderLine.FINDFIRST THEN BEGIN
              ProdOrderLine.VALIDATE("Variant Code",VariantCode);
              ProdOrderLine.MODIFY(TRUE);
            END;
          END;
      END;

Example

The below example is extracted from the test automation codeunit 137107 to show one way of using this function.

      SetupAbleToMake(BOMBuffer,FALSE,FALSE,SupplyType::Purchase,1,TRUE,'<0D>',1,1,0.4);
      EVALUATE(DueDateDelayDateFormula,DueDateDelay);
      LibraryManufacturing.CreateProductionOrder(
        ProductionOrder,ProductionOrder.Status::Released,ProductionOrder."Source Type"::Item,BOMBuffer."No.",
        BOMBuffer."Able to Make Top Item");
      LibraryManufacturing.RefreshProdOrder(ProductionOrder,FALSE,TRUE,FALSE,TRUE,FALSE);

      FindProdOrderLine(ProdOrderLine,ProductionOrder);
      LibraryManufacturing.UpdateProdOrderLine(ProdOrderLine,ProdOrderLine.FIELDNO("Location Code"),BOMBuffer."Location Code");
      LibraryManufacturing.UpdateProdOrderLine(ProdOrderLine,ProdOrderLine.FIELDNO("Variant Code"),BOMBuffer."Variant Code");
      LibraryManufacturing.UpdateProdOrderLine(
        ProdOrderLine,ProdOrderLine.FIELDNO("Due Date"),CALCDATE(DueDateDelayDateFormula,WORKDATE));

      LibraryManufacturing.CreateProductionOrderComponent(
        ProdOrderComponent,ProductionOrder.Status,ProductionOrder."No.",ProdOrderLine."Line No.");
      LibraryInventory.CreateItem(Item);
      ProdOrderComponent.VALIDATE("Item No.",Item."No.");
      ProdOrderComponent.VALIDATE("Quantity per",RANDOM(5));
      ProdOrderComponent.MODIFY(TRUE);
      LibraryTrees.CreateSupply(
        Item."No.",'',BOMBuffer."Location Code",WORKDATE,SupplyType::Inventory,
        ProductionOrder.Quantity * ProdOrderComponent."Quantity per");

      IF TestLocation THEN BEGIN
        LibraryWarehouse.CreateLocation(Location);
        LibraryManufacturing.UpdateProdOrderLine(ProdOrderLine,ProdOrderLine.FIELDNO("Location Code"),Location.Code);
      END;

      AbleToMake := ProductionOrder.Quantity;

      // Exercise.
      CalculateBOMTree.SetShowTotalAvailability(TRUE);
      CalculateBOMTree.GenerateTreeForProdLine(ProdOrderLine,BOMBuffer,TreeType::Availability);

      // Verify: Check top item.
      VerifyTopItem(BOMBuffer,ProdOrderLine."Item No.",AbleToMake,0,TRUE);

      // Verify: BOM Level - Able to Make page.
      ReleasedProductionOrder.OPENEDIT;
      ReleasedProductionOrder.FILTER.SETFILTER("No.",ProductionOrder."No.");

      ReleasedProductionOrder.ProdOrderLines.ItemAvailabilityByBOMLevel.INVOKE;
      ReleasedProductionOrder.OK.INVOKE;
Member of Lib.Library - Trees


GetQtyPerInTree@1 Method

The procedure GetQtyPerInTree is available in codeunit 132208.

Syntax

GetQtyPerInTree@1(
    VAR QtyPerParent@1003 : Decimal QtyPerParent, //Reference parameter of type Decimal
    VAR QtyPerTopItem@1002 : Decimal QtyPerTopItem, //Reference parameter of type Decimal
    ParentItemNo@1000 : Code[20] ParentItemNo, //Input parameter of type Code
    CompItemNo@1001 : Code[20] CompItemNo //Input parameter of type Code
);

Parameters

QtyPerParent
Reference parameter of type Decimal
QtyPerTopItem
Reference parameter of type Decimal
ParentItemNo
Input parameter of type Code
CompItemNo
Input parameter of type Code

Remarks

The relevant search keywords are: Get, Quantity, Per, In, Tree.

For a clarification about how this function works, refer to the code listed below.

      Item.GET(ParentItemNo);
      CASE Item."Replenishment System" OF
        Item."Replenishment System"::Assembly:
          BEGIN
            BOMComponent.SETRANGE("Parent Item No.",ParentItemNo);
            BOMComponent.SETRANGE(Type,BOMComponent.Type::Item);
            IF BOMComponent.FINDSET THEN
              REPEAT
                Item1.GET(BOMComponent."No.");
                IF Item1."No." = CompItemNo THEN BEGIN
                  QtyPerParent := BOMComponent."Quantity per";
                  QtyPerTopItem *= BOMComponent."Quantity per";
                  EXIT;
                END;
                RecQtyPerTopItem := BOMComponent."Quantity per" * QtyPerTopItem;
                GetQtyPerInTree(QtyPerParent,RecQtyPerTopItem,Item1."No.",CompItemNo);
              UNTIL BOMComponent.NEXT = 0;
          END;
        Item."Replenishment System"::"Prod. Order":
          BEGIN
            ProdBOMLine.SETRANGE("Production BOM No.",Item."Production BOM No.");
            ProdBOMLine.SETRANGE(Type,ProdBOMLine.Type::Item);
            IF ProdBOMLine.FINDSET THEN
              REPEAT
                Item1.GET(ProdBOMLine."No.");
                IF Item1."No." = CompItemNo THEN BEGIN
                  QtyPerParent := ProdBOMLine."Quantity per";
                  QtyPerTopItem *= ProdBOMLine."Quantity per";
                  EXIT;
                END;
                RecQtyPerTopItem := ProdBOMLine."Quantity per" * QtyPerTopItem;
                GetQtyPerInTree(QtyPerParent,RecQtyPerTopItem,Item1."No.",CompItemNo);
              UNTIL ProdBOMLine.NEXT = 0;
          END;
        Item."Replenishment System"::Purchase:
          IF Item."No." = CompItemNo THEN
            EXIT;
      END;

Example

The below example is extracted from the test automation codeunit 137391 to show one way of using this function.

      LibraryVariableStorage.Dequeue(VariantVar);
      ItemNo := VariantVar;

      BOMStructure.EXPAND(TRUE);
      BOMStructure.FILTER.SETFILTER(Type,FORMAT(BOMBuffer.Type::Item));
      WHILE BOMStructure.NEXT DO BEGIN
        LibraryTrees.GetQtyPerInTree(QtyPerParent,QtyPerTopItem,ItemNo,FORMAT(BOMStructure."No."));
        Assert.AreEqual(
          QtyPerParent,BOMStructure."Qty. per Parent".ASDECIMAL,'Wrong Qty per parent on page for item ' + FORMAT(BOMStructure."No."));
        Assert.AreEqual(FALSE,BOMStructure.HasWarning.ASBOOLEAN,'Unexpected warning present in item ' + FORMAT(BOMStructure."No."));
      END;

      COMMIT;
      BOMStructure.Action30.INVOKE; // Call Show Warnings for code coverage purposes.

      // Enqueue parameters for report.
      LibraryVariableStorage.Enqueue(ShowCostShareAs::"Single-level");
      LibraryVariableStorage.Enqueue(ShowLevelAs::"BOM Leaves");
      LibraryVariableStorage.Enqueue(TRUE);
      BOMStructure.Action13.INVOKE; // Call BOM Cost Shares distribution report for code coverage purposes.
      BOMStructure.OK.INVOKE;
Member of Lib.Library - Trees


GetTree@91 Method

The procedure GetTree is available in codeunit 132208.

Syntax

GetTree@91(
    VAR TempItem@1001 : TEMPORARY Record 27 TempItem, //Reference Temporary parameter of type Record
    VAR TempResource@1002 : TEMPORARY Record 156 TempResource, //Reference Temporary parameter of type Record
    VAR TempWorkCenter@1029 : TEMPORARY Record 99000754 TempWorkCenter, //Reference Temporary parameter of type Record
    VAR TempMachineCenter@1030 : TEMPORARY Record 99000758 TempMachineCenter, //Reference Temporary parameter of type Record
    Item@1000 : Record 27 Item //Input parameter of type Record
);

Parameters

TempItem
Reference Temporary parameter of type Record
TempResource
Reference Temporary parameter of type Record
TempWorkCenter
Reference Temporary parameter of type Record
TempMachineCenter
Reference Temporary parameter of type Record
Item
Input parameter of type Record

Remarks

The relevant search keywords are: Get, Tree.

For a clarification about how this function works, refer to the code listed below.

      TempItem := Item;
      TempItem.INSERT;

      CASE Item."Replenishment System" OF
        Item."Replenishment System"::Assembly:
          BEGIN
            BOMComponent.SETRANGE("Parent Item No.",Item."No.");
            BOMComponent.SETRANGE(Type,BOMComponent.Type::Item);
            IF BOMComponent.FINDSET THEN
              REPEAT
                Item1.GET(BOMComponent."No.");
                GetTree(TempItem,TempResource,TempWorkCenter,TempMachineCenter,Item1);
              UNTIL BOMComponent.NEXT = 0;

            BOMComponent.SETRANGE(Type,BOMComponent.Type::Resource);
            IF BOMComponent.FINDSET THEN
              REPEAT
                Resource.GET(BOMComponent."No.");
                TempResource := Resource;
                TempResource.INSERT;
              UNTIL BOMComponent.NEXT = 0;
          END;
        Item."Replenishment System"::"Prod. Order":
          BEGIN
            ProdBOMLine.SETRANGE("Production BOM No.",Item."Production BOM No.");
            ProdBOMLine.SETRANGE(Type,ProdBOMLine.Type::Item);
            IF ProdBOMLine.FINDSET THEN
              REPEAT
                Item1.GET(ProdBOMLine."No.");
                GetTree(TempItem,TempResource,TempWorkCenter,TempMachineCenter,Item1);
              UNTIL ProdBOMLine.NEXT = 0;

            RoutingLine.SETRANGE("Routing No.",Item."Routing No.");
            RoutingLine.SETRANGE(Type,RoutingLine.Type::"Work Center");
            IF RoutingLine.FINDSET THEN
              REPEAT
                WorkCenter.GET(RoutingLine."No.");
                TempWorkCenter := WorkCenter;
                TempWorkCenter.INSERT;
              UNTIL RoutingLine.NEXT = 0;

            RoutingLine.SETRANGE(Type,RoutingLine.Type::"Machine Center");
            IF RoutingLine.FINDSET THEN
              REPEAT
                MachineCenter.GET(RoutingLine."No.");
                TempMachineCenter := MachineCenter;
                TempMachineCenter.INSERT;
              UNTIL RoutingLine.NEXT = 0;
          END;
      END;

Example

The below example is extracted from the test automation codeunit 137110 to show one way of using this function.

      // Setup.
      Initialize;
      LibraryTrees.CreateMixedTree(Item,TopItemReplSystem,Item."Costing Method"::Standard,Depth,ChildLeaves,RoutingLines);
      LibraryTrees.GetTree(TempItem,TempResource,TempWorkCenter,TempMachineCenter,Item);
      LibraryTrees.AddCostToRouting(TempWorkCenter,TempMachineCenter);
      CalcStandardCost.CalcItem(Item."No.",(Item."Replenishment System" = Item."Replenishment System"::Assembly));

      // Exercise: Create the BOM tree.
      CalculateTree(BOMBuf,Item);

      // Verify: Navigate through the tree and check the results.
      VerifyTree(BOMBuf,Item);
      VerifyTopItem(BOMBuf,Item);
Member of Lib.Library - Trees


GetTreeCost@92 Method

The procedure GetTreeCost is available in codeunit 132208.

Syntax

GetTreeCost@92(
    VAR RolledUpMaterialCost@1011 : Decimal RolledUpMaterialCost, //Reference parameter of type Decimal
    VAR RolledUpCapacityCost@1010 : Decimal RolledUpCapacityCost, //Reference parameter of type Decimal
    VAR RolledUpCapOvhd@1013 : Decimal RolledUpCapOvhd, //Reference parameter of type Decimal
    VAR RolledUpMfgOvhd@1025 : Decimal RolledUpMfgOvhd, //Reference parameter of type Decimal
    VAR SglLevelMaterialCost@1020 : Decimal SglLevelMaterialCost, //Reference parameter of type Decimal
    VAR SglLevelCapCost@1021 : Decimal SglLevelCapCost, //Reference parameter of type Decimal
    VAR SglLevelCapOvhd@1022 : Decimal SglLevelCapOvhd, //Reference parameter of type Decimal
    VAR SglLevelMfgOvhd@1027 : Decimal SglLevelMfgOvhd, //Reference parameter of type Decimal
    Item@1000 : Record 27 Item //Input parameter of type Record
);

Parameters

RolledUpMaterialCost
Reference parameter of type Decimal
RolledUpCapacityCost
Reference parameter of type Decimal
RolledUpCapOvhd
Reference parameter of type Decimal
RolledUpMfgOvhd
Reference parameter of type Decimal
SglLevelMaterialCost
Reference parameter of type Decimal
SglLevelCapCost
Reference parameter of type Decimal
SglLevelCapOvhd
Reference parameter of type Decimal
SglLevelMfgOvhd
Reference parameter of type Decimal
Item
Input parameter of type Record

Return Value

Decimal

Remarks

The relevant search keywords are: Get, Tree, Cost.

For a clarification about how this function works, refer to the code listed below.

      IF Item."Lot Size" = 0 THEN
        LotSize := 1
      ELSE
        LotSize := Item."Lot Size";

      CASE Item."Replenishment System" OF
        Item."Replenishment System"::Assembly:
          BEGIN
            BOMComponent.SETRANGE("Parent Item No.",Item."No.");
            BOMComponent.SETRANGE(Type,BOMComponent.Type::Item);
            IF BOMComponent.FINDSET THEN
              REPEAT
                Item1.GET(BOMComponent."No.");
                LocalRolledUpMaterialCost := 0;
                LocalRolledUpCapCost := 0;
                LocalRolledUpCapOvhd := 0;
                LocalRolledUpMfgOvhd := 0;
                LocalCost := 0;
                TreeCost +=
                  BOMComponent."Quantity per" *
                  GetTreeCost(
                    LocalRolledUpMaterialCost,LocalRolledUpCapCost,LocalRolledUpCapOvhd,LocalRolledUpMfgOvhd,LocalCost,LocalCost,
                    LocalCost,LocalCost,Item1);
                SglLevelMaterialCost += BOMComponent."Quantity per" * Item1."Unit Cost";
                RolledUpMaterialCost += BOMComponent."Quantity per" * LocalRolledUpMaterialCost;
                RolledUpCapacityCost += BOMComponent."Quantity per" * LocalRolledUpCapCost;
                RolledUpCapOvhd += BOMComponent."Quantity per" * LocalRolledUpCapOvhd;
                RolledUpMfgOvhd += BOMComponent."Quantity per" * LocalRolledUpMfgOvhd;
              UNTIL BOMComponent.NEXT = 0;

            BOMComponent.SETRANGE(Type,BOMComponent.Type::Resource);
            IF BOMComponent.FINDSET THEN
              REPEAT
                Resource.GET(BOMComponent."No.");

                IF (BOMComponent."Resource Usage Type" = BOMComponent."Resource Usage Type"::Fixed) AND (Item."Lot Size" <> 0) THEN
                  ResLotSize := Item."Lot Size"
                ELSE
                  ResLotSize := 1;

                LibraryAssembly.GetCostInformation(
                  UnitCost,Overhead,IndirectCost,BOMComponent.Type::Resource,BOMComponent."No.",'','');
                TreeCost += BOMComponent."Quantity per" * UnitCost / ResLotSize;
                SglLevelCapCost += BOMComponent."Quantity per" * (UnitCost - Overhead) / ResLotSize;
                SglLevelCapOvhd += BOMComponent."Quantity per" * Overhead / ResLotSize;
                RolledUpCapacityCost += BOMComponent."Quantity per" * (UnitCost - Overhead) / ResLotSize;
                RolledUpCapOvhd += BOMComponent."Quantity per" * Overhead / ResLotSize;
              UNTIL BOMComponent.NEXT = 0;

            RolledUpMfgOvhd +=
              (RolledUpMaterialCost + RolledUpCapacityCost + RolledUpCapOvhd + RolledUpMfgOvhd) *
              Item."Indirect Cost %" / 100 + Item."Overhead Rate";
            SglLevelMfgOvhd += Item."Single-Level Mfg. Ovhd Cost";
            RolledUpCapacityCost -= Item."Single-Level Subcontrd. Cost";
          END;
        Item."Replenishment System"::"Prod. Order":
          BEGIN
            ProdBOMLine.SETRANGE("Production BOM No.",Item."Production BOM No.");
            ProdBOMLine.SETRANGE(Type,ProdBOMLine.Type::Item);
            IF ProdBOMLine.FINDSET THEN
              REPEAT
                Item1.GET(ProdBOMLine."No.");
                LocalRolledUpMaterialCost := 0;
                LocalRolledUpCapCost := 0;
                LocalRolledUpCapOvhd := 0;
                LocalRolledUpMfgOvhd := 0;
                LocalCost := 0;
                TreeCost +=
                  ProdBOMLine."Quantity per" *
                  GetTreeCost(
                    LocalRolledUpMaterialCost,LocalRolledUpCapCost,LocalRolledUpCapOvhd,LocalRolledUpMfgOvhd,LocalCost,LocalCost,
                    LocalCost,LocalCost,Item1);
                SglLevelMaterialCost += ProdBOMLine."Quantity per" * Item1."Unit Cost";
                RolledUpMaterialCost += ProdBOMLine."Quantity per" * LocalRolledUpMaterialCost;
                RolledUpCapacityCost += ProdBOMLine."Quantity per" * LocalRolledUpCapCost;
                RolledUpCapOvhd += ProdBOMLine."Quantity per" * LocalRolledUpCapOvhd;
                RolledUpMfgOvhd += ProdBOMLine."Quantity per" * LocalRolledUpMfgOvhd;
              UNTIL ProdBOMLine.NEXT = 0;

            RoutingLine.SETRANGE("Routing No.",Item."Routing No.");
            RoutingLine.SETRANGE(Type,RoutingLine.Type::"Work Center");
            IF RoutingLine.FINDSET THEN
              REPEAT
                WorkCenter.GET(RoutingLine."No.");
                RolledUpCapacityCost += (RoutingLine."Run Time" + RoutingLine."Setup Time" / LotSize) * WorkCenter."Direct Unit Cost";
                RolledUpCapOvhd +=
                  (RoutingLine."Run Time" + RoutingLine."Setup Time" / LotSize) *
                  (WorkCenter."Unit Cost" - WorkCenter."Direct Unit Cost");
                SglLevelCapCost += (RoutingLine."Run Time" + RoutingLine."Setup Time" / LotSize) * WorkCenter."Direct Unit Cost";
                SglLevelCapOvhd +=
                  (RoutingLine."Run Time" + RoutingLine."Setup Time" / LotSize) *
                  (WorkCenter."Unit Cost" - WorkCenter."Direct Unit Cost");
              UNTIL RoutingLine.NEXT = 0;

            RoutingLine.SETRANGE(Type,RoutingLine.Type::"Machine Center");
            IF RoutingLine.FINDSET THEN
              REPEAT
                MachineCenter.GET(RoutingLine."No.");
                RolledUpCapacityCost +=
                  (RoutingLine."Run Time" + RoutingLine."Setup Time" / LotSize) * MachineCenter."Direct Unit Cost";
                RolledUpCapOvhd +=
                  (RoutingLine."Run Time" + RoutingLine."Setup Time" / LotSize) *
                  (MachineCenter."Unit Cost" - MachineCenter."Direct Unit Cost");
                SglLevelCapCost += (RoutingLine."Run Time" + RoutingLine."Setup Time" / LotSize) * MachineCenter."Direct Unit Cost";
                SglLevelCapOvhd +=
                  (RoutingLine."Run Time" + RoutingLine."Setup Time" / LotSize) *
                  (MachineCenter."Unit Cost" - MachineCenter."Direct Unit Cost");
              UNTIL RoutingLine.NEXT = 0;

            RolledUpMfgOvhd +=
              (RolledUpMaterialCost + RolledUpCapacityCost + RolledUpCapOvhd + RolledUpMfgOvhd) *
              Item."Indirect Cost %" / 100 + Item."Overhead Rate";
            SglLevelMfgOvhd += Item."Single-Level Mfg. Ovhd Cost";
            RolledUpCapacityCost -= Item."Single-Level Subcontrd. Cost";
          END;
        Item."Replenishment System"::Purchase:
          BEGIN
            LibraryAssembly.GetCostInformation(UnitCost,Overhead,IndirectCost,BOMComponent.Type::Item,Item."No.",'','');
            SglLevelMaterialCost := UnitCost;
            RolledUpMaterialCost := UnitCost;
            EXIT(UnitCost);
          END;
      END;

      RoundingPrecision := LibraryERM.GetUnitAmountRoundingPrecision;
      RolledUpMaterialCost := ROUND(RolledUpMaterialCost,RoundingPrecision);
      RolledUpCapacityCost := ROUND(RolledUpCapacityCost,RoundingPrecision);
      RolledUpCapOvhd := ROUND(RolledUpCapOvhd,RoundingPrecision);
      RolledUpMfgOvhd := ROUND(RolledUpMfgOvhd,RoundingPrecision);
      SglLevelMaterialCost := ROUND(SglLevelMaterialCost,RoundingPrecision);
      SglLevelCapCost := ROUND(SglLevelCapCost,RoundingPrecision);
      SglLevelCapOvhd := ROUND(SglLevelCapOvhd,RoundingPrecision);
      SglLevelMfgOvhd := ROUND(SglLevelMfgOvhd,RoundingPrecision);

      EXIT(ROUND(TreeCost * (1 + Item."Indirect Cost %" / 100) + Item."Overhead Rate",RoundingPrecision));

Example

The below example is extracted from the test automation codeunit 137110 to show one way of using this function.

      Item.GET(Item."No.");
      LibraryTrees.GetTreeCost(
        RolledUpMaterialCost,RolledUpCapacityCost,RolledUpCapOvhd,RolledUpMfgOvhd,SglLevelMaterialCost,SglLevelCapCost,
        SglLevelCapOvhd,SglLevelMfgOvhd,Item);
      BOMBuf.SETRANGE(Type,BOMBuf.Type::Item);
      BOMBuf.SETRANGE("No.",Item."No.");
      BOMBuf.FINDFIRST;

      RoundingFactor := 100 * LibraryERM.GetUnitAmountRoundingPrecision;
      Assert.AreNearlyEqual(RolledUpMaterialCost,BOMBuf."Rolled-up Material Cost",RoundingFactor,
        STRSUBSTNO(ERRWrongCostShareCalc,Item.FIELDCAPTION("Rolled-up Material Cost"),Item."No."));
      Assert.AreNearlyEqual(RolledUpCapacityCost,BOMBuf."Rolled-up Capacity Cost",RoundingFactor,
        STRSUBSTNO(ERRWrongCostShareCalc,Item.FIELDCAPTION("Rolled-up Capacity Cost"),Item."No."));
      Assert.AreNearlyEqual(RolledUpMfgOvhd,BOMBuf."Rolled-up Mfg. Ovhd Cost",RoundingFactor,
        STRSUBSTNO(ERRWrongCostShareCalc,Item.FIELDCAPTION("Rolled-up Mfg. Ovhd Cost"),Item."No."));
      Assert.AreNearlyEqual(RolledUpCapOvhd,BOMBuf."Rolled-up Capacity Ovhd. Cost",RoundingFactor,
        STRSUBSTNO(ERRWrongCostShareCalc,Item.FIELDCAPTION("Rolled-up Cap. Overhead Cost"),Item."No."));

      Assert.AreNearlyEqual(SglLevelMaterialCost,BOMBuf."Single-Level Material Cost",RoundingFactor,
        STRSUBSTNO(ERRWrongCostShareCalc,Item.FIELDCAPTION("Single-Level Material Cost"),Item."No."));
      Assert.AreNearlyEqual(SglLevelCapCost,BOMBuf."Single-Level Capacity Cost",RoundingFactor,
        STRSUBSTNO(ERRWrongCostShareCalc,Item.FIELDCAPTION("Single-Level Capacity Cost"),Item."No."));
      Assert.AreNearlyEqual(SglLevelMfgOvhd,BOMBuf."Single-Level Mfg. Ovhd Cost",RoundingFactor,
        STRSUBSTNO(ERRWrongCostShareCalc,Item.FIELDCAPTION("Single-Level Mfg. Ovhd Cost"),Item."No."));
      Assert.AreNearlyEqual(SglLevelCapOvhd,BOMBuf."Single-Level Cap. Ovhd Cost",RoundingFactor,
        STRSUBSTNO(ERRWrongCostShareCalc,Item.FIELDCAPTION("Single-Level Cap. Ovhd Cost"),Item."No."));
Member of Lib.Library - Trees


GetTreeCostWithScrap@33 Method

The procedure GetTreeCostWithScrap is available in codeunit 132208.

Syntax

GetTreeCostWithScrap@33(
    VAR RolledUpScrapAmount@1001 : Decimal RolledUpScrapAmount, //Reference parameter of type Decimal
    VAR SingleLevelScrapAmount@1002 : Decimal SingleLevelScrapAmount, //Reference parameter of type Decimal
    Item@1000 : Record 27 Item //Input parameter of type Record
);

Parameters

RolledUpScrapAmount
Reference parameter of type Decimal
SingleLevelScrapAmount
Reference parameter of type Decimal
Item
Input parameter of type Record

Remarks

The relevant search keywords are: Get, Tree, Cost, Scrap.

For a clarification about how this function works, refer to the code listed below.

      LocalCost := 0;
      CASE Item."Replenishment System" OF
        Item."Replenishment System"::Assembly:
          BEGIN
            BOMComponent.SETRANGE("Parent Item No.",Item."No.");
            BOMComponent.SETRANGE(Type,BOMComponent.Type::Item);
            IF BOMComponent.FINDSET THEN
              REPEAT
                Item1.GET(BOMComponent."No.");
                LocalRolledUpScrapAmount := 0;
                GetTreeCostWithScrap(LocalRolledUpScrapAmount,LocalCost,Item1);
                RolledUpScrapAmount += BOMComponent."Quantity per" * LocalRolledUpScrapAmount;
              UNTIL BOMComponent.NEXT = 0;

            BOMComponent.SETRANGE(Type,BOMComponent.Type::Resource);
            IF BOMComponent.FINDSET THEN
              REPEAT
                Resource.GET(BOMComponent."No.");

                IF (BOMComponent."Resource Usage Type" = BOMComponent."Resource Usage Type"::Fixed) AND (Item."Lot Size" <> 0) THEN
                  LotSize := Item."Lot Size"
                ELSE
                  LotSize := 1;

                LibraryAssembly.GetCostInformation(
                  UnitCost,Overhead,IndirectCost,BOMComponent.Type::Resource,BOMComponent."No.",'','');
                RolledUpScrapAmount += BOMComponent."Quantity per" * UnitCost / LotSize;
              UNTIL BOMComponent.NEXT = 0;
          END;
        Item."Replenishment System"::"Prod. Order":
          BEGIN
            RoutingLine.SETRANGE("Routing No.",Item."Routing No.");
            RoutingScrapPercentage := GetCombinedScrapPercentage(RoutingLine);

            ProdBOMLine.SETRANGE("Production BOM No.",Item."Production BOM No.");
            ProdBOMLine.SETRANGE(Type,ProdBOMLine.Type::Item);
            IF ProdBOMLine.FINDSET THEN
              REPEAT
                Item1.GET(ProdBOMLine."No.");
                LocalRolledUpScrapAmount := 0;
                GetTreeCostWithScrap(LocalRolledUpScrapAmount,LocalCost,Item1);
                RolledUpScrapAmount +=
                  ProdBOMLine."Quantity per" *
                  RoutingScrapPercentage * LocalRolledUpScrapAmount * (1 + Item."Scrap %" / 100) * (1 + ProdBOMLine."Scrap %" / 100);

                IF Item1."Replenishment System" = Item1."Replenishment System"::Purchase THEN
                  SingleLevelScrapAmount +=
                    ProdBOMLine."Quantity per" *
                    RoutingScrapPercentage * Item1."Unit Cost" * (Item."Scrap %" / 100) * (ProdBOMLine."Scrap %" / 100);
              UNTIL ProdBOMLine.NEXT = 0;

            ProcessedScrapPercentage := 1;
            IF RoutingLine.FINDSET THEN
              REPEAT
                IF RoutingLine.Type = RoutingLine.Type::"Work Center" THEN BEGIN
                  WorkCenter.GET(RoutingLine."No.");
                  RolledUpScrapAmount +=
                    (RoutingLine."Run Time" *
                     RoutingScrapPercentage / ProcessedScrapPercentage + RoutingLine."Setup Time" / Item."Lot Size") *
                    WorkCenter."Unit Cost" * (1 + Item."Scrap %" / 100);
                END ELSE BEGIN
                  MachineCenter.GET(RoutingLine."No.");
                  RolledUpScrapAmount +=
                    (RoutingLine."Run Time" *
                     RoutingScrapPercentage / ProcessedScrapPercentage + RoutingLine."Setup Time" / Item."Lot Size") *
                    MachineCenter."Unit Cost" * (1 + Item."Scrap %" / 100);
                END;
                ProcessedScrapPercentage *= 1 + RoutingLine."Scrap Factor %" / 100;
              UNTIL RoutingLine.NEXT = 0;
          END;
        Item."Replenishment System"::Purchase:
          RolledUpScrapAmount := Item."Unit Cost";
      END;

      RolledUpScrapAmount := ROUND(RolledUpScrapAmount,LibraryERM.GetUnitAmountRoundingPrecision);

Example

The below example is extracted from the test automation codeunit 137110 to show one way of using this function.

      LibraryTrees.GetTreeCostWithScrap(RolledUpTreeCostWithScrap,SglLevelScrapCost,Item);
      BOMBuf.SETRANGE(Type,BOMBuf.Type::Item);
      BOMBuf.SETRANGE("No.",Item."No.");
      BOMBuf.FINDFIRST;

      // Seem the verification of Scrap cost is wrong here
      // Assert.AreNearlyEqual(SglLevelScrapCost,BOMBuf."Single-Level Scrap Cost",LibraryERM.GetAmountRoundingPrecision,
      // STRSUBSTNO(ERRWrongCostShareCalc,BOMBuf.FIELDCAPTION("Single-Level Scrap Cost"),Item."No."));
      // Assert.AreNearlyEqual(RolledUpTreeCostWithScrap,BOMBuf."Unit Cost",LibraryERM.GetAmountRoundingPrecision,
      // STRSUBSTNO(ERRWrongCostShareCalc,BOMBuf.FIELDCAPTION("Rolled-up Scrap Cost"),Item."No."));
Member of Lib.Library - Trees


Library - Utility Class

Lib.Library - Utility

COD131000 applies to RES,ERM,SCM,W1,All.
Contains all generic utility functions.

Methods

Name | Description
CheckFieldExistenceInTable@1 | The procedure CheckFieldExistenceInTable is available in codeunit 131000.
CheckFileNotEmpty@24 | The procedure CheckFileNotEmpty is available in codeunit 131000.
CompareTwoRecords@11 | The procedure CompareTwoRecords is available in codeunit 131000.
ConvertHoursToMilliSec@26 | The procedure ConvertHoursToMilliSec is available in codeunit 131000.
ConvertMilliSecToHours@27 | The procedure ConvertMilliSecToHours is available in codeunit 131000.
ConvertNumericToText@28 | The procedure ConvertNumericToText is available in codeunit 131000.
CreateCodeRecord@8 | The procedure CreateCodeRecord is available in codeunit 131000.
CreateNoSeries@30 | The procedure CreateNoSeries is available in codeunit 131000.
CreateNoSeriesLine@29 | The procedure CreateNoSeriesLine is available in codeunit 131000.
CreateNoSeriesRelationship@5 | The procedure CreateNoSeriesRelationship is available in codeunit 131000.
ExistsDecimalValueInArray@46 | The procedure ExistsDecimalValueInArray is available in codeunit 131000.
FillMaxText@34 | The procedure FillMaxText is available in codeunit 131000.
FindControl@20 | The procedure FindControl is available in codeunit 131000.
FindEditable@25 | The procedure FindEditable is available in codeunit 131000.
FindFieldNoInTable@2 | The procedure FindFieldNoInTable is available in codeunit 131000.
FindMaxValueForField@17 | The procedure FindMaxValueForField is available in codeunit 131000.
FindMinValueForField@19 | The procedure FindMinValueForField is available in codeunit 131000.
FindOrCreateCodeRecord@18 | The procedure FindOrCreateCodeRecord is available in codeunit 131000.
FindRecord@6 | The procedure FindRecord is available in codeunit 131000.
FindVisible@23 | The procedure FindVisible is available in codeunit 131000.
GenerateGUID@51 | The procedure GenerateGUID is available in codeunit 131000.
GenerateMOD97CompliantCode@12 | The procedure GenerateMOD97CompliantCode is available in codeunit 131000.
GenerateRandomAlphabeticText@93 | The procedure GenerateRandomAlphabeticText is available in codeunit 131000.
GenerateRandomCode@36 | The procedure GenerateRandomCode is available in codeunit 131000.
GenerateRandomCode20@43 | The procedure GenerateRandomCode20 is available in codeunit 131000.
GenerateRandomCodeWithLength@37 | The procedure GenerateRandomCodeWithLength is available in codeunit 131000.
GenerateRandomDate@9 | The procedure GenerateRandomDate is available in codeunit 131000.
GenerateRandomEmail@39 | The procedure GenerateRandomEmail is available in codeunit 131000.
GenerateRandomFraction@22 | The procedure GenerateRandomFraction is available in codeunit 131000.
GenerateRandomNumericText@47 | The procedure GenerateRandomNumericText is available in codeunit 131000.
GenerateRandomText@58 | The procedure GenerateRandomText is available in codeunit 131000.
GenerateRandomXMLText@59 | The procedure GenerateRandomXMLText is available in codeunit 131000.
GetFieldLength@3 | The procedure GetFieldLength is available in codeunit 131000.
GetGlobalNoSeriesCode@44 | The procedure GetGlobalNoSeriesCode is available in codeunit 131000.
GetInetRoot@42 | The procedure GetInetRoot is available in codeunit 131000.
GetLastTransactionNo@103 | The procedure GetLastTransactionNo is available in codeunit 131000.
GetMaxFieldOptionIndex@33 | The procedure GetMaxFieldOptionIndex is available in codeunit 131000.
GetMaxOptionIndex@32 | The procedure GetMaxOptionIndex is available in codeunit 131000.
GetNewLineNo@10 | The procedure GetNewLineNo is available in codeunit 131000.
GetNewRecNo@35 | The procedure GetNewRecNo is available in codeunit 131000.
GetNextNoFromNoSeries@38 | The procedure GetNextNoFromNoSeries is available in codeunit 131000.
GetNextNoSeriesPurchaseDate@13 | The procedure GetNextNoSeriesPurchaseDate is available in codeunit 131000.
GetNextNoSeriesSalesDate@15 | The procedure GetNextNoSeriesSalesDate is available in codeunit 131000.
GetPropertyValueForControl@21 | The procedure GetPropertyValueForControl is available in codeunit 131000.
GetPropertyValueForField@16 | The procedure GetPropertyValueForField is available in codeunit 131000.
LineBreak@53 | The procedure LineBreak is available in codeunit 131000.
UpdateSetupNoSeriesCode@31 | The procedure UpdateSetupNoSeriesCode is available in codeunit 131000.

See Also

Lib


CheckFieldExistenceInTable@1 Method

The procedure CheckFieldExistenceInTable is available in codeunit 131000.

Syntax

CheckFieldExistenceInTable@1(
    TableNo@1000 : Integer TableNo, //Input parameter of type Integer
    FieldName@1001 : Text[30] FieldName //Input parameter of type Text
);

Parameters

TableNo
Input parameter of type Integer
FieldName
Input parameter of type Text

Return Value

Boolean

Remarks

The relevant search keywords are: Check, Field, Existence, In, Table.

For a clarification about how this function works, refer to the code listed below.

      Field.SETRANGE(TableNo,TableNo);
      Field.SETRANGE(FieldName,FieldName);
      EXIT(Field.FINDFIRST);

Example

The below example is extracted from the test automation codeunit 137031 to show one way of using this function.

      IF ReasonCode.COUNT = 0 THEN
        EXIT;

      ReasonCode.NEXT(RANDOM(ReasonCode.COUNT));
      PurchaseHeader.VALIDATE("Reason Code",ReasonCode.Code);

      PurchInvHeader.SETRANGE("Buy-from Vendor No.",PurchaseHeader."Buy-from Vendor No.");

      IF PurchInvHeader.FINDFIRST AND
         LibraryUtility.CheckFieldExistenceInTable(DATABASE::"Purchase Header",'Adjustment Applies-to')
      THEN BEGIN
        RecRef.GETTABLE(PurchaseHeader);
        FieldRef := RecRef.FIELD(LibraryUtility.FindFieldNoInTable(DATABASE::"Purchase Header",'Adjustment Applies-to'));
        FieldRef.VALIDATE(PurchInvHeader."No.");
        RecRef.SETTABLE(PurchaseHeader);

        PurchaseHeader.MODIFY(TRUE);
      END;
Member of Lib.Library - Utility


CheckFileNotEmpty@24 Method

The procedure CheckFileNotEmpty is available in codeunit 131000.

Syntax

CheckFileNotEmpty@24(
    FileName@1001 : Text FileName //Input parameter of type Text
);

Parameters

FileName
Input parameter of type Text

Return Value

Boolean

Remarks

The relevant search keywords are: Check, File, Not, Empty.

For a clarification about how this function works, refer to the code listed below.

      // The parameter FileName should contain the full File Name including path.
      IF FileName = '' THEN
        EXIT(FALSE);
      IF File.OPEN(FileName) THEN
        IF File.LEN > 0 THEN
          EXIT(TRUE);
      EXIT(FALSE);

Example

The below example is extracted from the test automation codeunit 134008 to show one way of using this function.

      // Covers documents TC_ID= 122631,122632,122633.
      // Check that VAT Settlement Report has been generated and saved with some data after apply General Journal Lines.

      // Setup.
      Initialize;

      // Create, Post and Apply General journal Lines.
      PostApplyGenJournalLine(GenJournalLine,GenJournalLine."Document Type"::Invoice,GenJournalLine."Document Type"::Payment,
        LibraryRandom.RandInt(500));

      VatPostingSetup.SETFILTER("VAT %",'>0');
      VatPostingSetup.FINDLAST;
      CalcandPostVATSettlement.SETTABLEVIEW(VatPostingSetup);
      CalcandPostVATSettlement.InitializeRequest(
        WORKDATE,WORKDATE,WORKDATE,GenJournalLine."Document No.",GenJournalLine."Bal. Account No.",FALSE,FALSE);
      CalcandPostVATSettlement.USEREQUESTPAGE(FALSE);

      FilePath := TEMPORARYPATH + FORMAT(VatPostingSetup.TABLENAME) + '.xlsx';
      CalcandPostVATSettlement.SAVEASEXCEL(FilePath);

      // Verify: Verify that Saved files have some data.
      LibraryUtility.CheckFileNotEmpty(FilePath);

      // Cleanup: Delete Additional Currency and Unrealized VAT set to False from General Ledger Setup and Unrealized VAT type from
      // VAT Posting Setup.
      ModifyVATPostingSetup(UnrealizedVATType::" ");
      ModifyGeneralLedegerSetup('',FALSE);
Member of Lib.Library - Utility


CompareTwoRecords@11 Method

The procedure CompareTwoRecords is available in codeunit 131000.

Syntax

CompareTwoRecords@11(
    RecRef1@1000 : RecordRef RecRef1, //Input parameter of type RecordRef
    RecRef2@1001 : RecordRef RecRef2, //Input parameter of type RecordRef
    FieldCountsToBeIgnored@1002 : Integer FieldCountsToBeIgnored, //Input parameter of type Integer
    DiscardDateTimeFields@1008 : Boolean DiscardDateTimeFields, //Input parameter of type Boolean
    VAR FieldNumbersNotMatched@1007 : ARRAY [200] OF Integer FieldNumbersNotMatched, //Reference Array parameter of type Integer
    VAR Value1@1010 : ARRAY [200] OF Variant Value1, //Reference Array parameter of type Variant
    VAR Value2@1011 : ARRAY [200] OF Variant Value2, //Reference Array parameter of type Variant
    VAR MismatchCount@1006 : Integer MismatchCount //Reference parameter of type Integer
);

Parameters

RecRef1
Input parameter of type RecordRef
RecRef2
Input parameter of type RecordRef
FieldCountsToBeIgnored
Input parameter of type Integer
DiscardDateTimeFields
Input parameter of type Boolean
FieldNumbersNotMatched
Reference Array parameter of type Integer
Value1
Reference Array parameter of type Variant
Value2
Reference Array parameter of type Variant
MismatchCount
Reference parameter of type Integer

Return Value

Boolean

Remarks

The relevant search keywords are: Compare, Two, Records.

For a clarification about how this function works, refer to the code listed below.

      index1 := RecRef1.KEYINDEX(1).FIELDCOUNT + 1;
      index2 := RecRef2.KEYINDEX(1).FIELDCOUNT + 1;
      FldCount := RecRef1.FIELDCOUNT;
      IF RecRef2.FIELDCOUNT < RecRef1.FIELDCOUNT THEN
        FldCount := RecRef2.FIELDCOUNT;
      CLEAR(FieldNumbersNotMatched);
      CLEAR(Value1);
      CLEAR(Value2);
      MismatchCount := 0;
      WHILE (index1 <= FldCount) AND (index2 <= FldCount) DO BEGIN
        IF RecRef1.FIELDINDEX(index1).NUMBER > RecRef2.FIELDINDEX(index2).NUMBER THEN BEGIN
          index2 := index2 + 1;
          continue := TRUE;
        END ELSE
          IF RecRef2.FIELDINDEX(index2).NUMBER > RecRef1.FIELDINDEX(index1).NUMBER THEN BEGIN
            index1 := index1 + 1;
            continue := TRUE;
          END;
        IF NOT continue THEN BEGIN
          FieldRef1 := RecRef1.FIELDINDEX(index1);
          FieldRef2 := RecRef2.FIELDINDEX(index2);
          IF FORMAT(FieldRef1.TYPE) <> FORMAT(FieldRef2.TYPE) THEN
            ERROR(ERR_NotCompatible,FieldRef1.NUMBER,FORMAT(FieldRef1.TYPE),FORMAT(FieldRef2.TYPE));
          fieldType := UPPERCASE(FORMAT(FieldRef1.TYPE));
          IF DiscardDateTimeFields AND ((fieldType = 'DATE') OR (fieldType = 'TIME') OR (fieldType = 'DATETIME')) THEN
            continue := TRUE;
          IF NOT continue THEN
            IF FieldRef1.VALUE <> FieldRef2.VALUE THEN BEGIN
              MismatchCount := MismatchCount + 1;
              FieldNumbersNotMatched[MismatchCount] := FieldRef1.NUMBER;
              Value1[MismatchCount] := FieldRef1.VALUE;
              Value2[MismatchCount] := FieldRef2.VALUE;
            END;
          index1 := index1 + 1;
          index2 := index2 + 1;
        END;
        continue := FALSE;
      END;
      IF MismatchCount > FieldCountsToBeIgnored THEN
        EXIT(FALSE);
      EXIT(TRUE);

Example

There are no examples available.
Member of Lib.Library - Utility


ConvertHoursToMilliSec@26 Method

The procedure ConvertHoursToMilliSec is available in codeunit 131000.

Syntax

ConvertHoursToMilliSec@26(
    TimePeriod@1000 : Decimal TimePeriod //Input parameter of type Decimal
);

Parameters

TimePeriod
Input parameter of type Decimal

Return Value

Decimal

Remarks

The relevant search keywords are: Convert, Hours, To, Milli, Sec.

For a clarification about how this function works, refer to the code listed below.

      EXIT(TimePeriod * 3600000);

Example

The below example is extracted from the test automation codeunit 136106 to show one way of using this function.

      // Covers document number TC0120 - refer to TFS ID 21728.
      // Test that the Response Time on Service Item Line is Ending Time of the relevant Service Hour minus the time subtracted, for a
      // Working Day and Response Time (Hours) as any time falling within the Service Hours on the same day.

      // 1. Setup: Create Service Order for a Working Day - Service Item, Service Header, Service Item Line.
      Initialize;
      OrderDate := LibraryService.GetFirstWorkingDay(WORKDATE);
      CreateServiceHeaderGivenDate(ServiceItemLine,OrderDate);

      // 2. Exercise: Get Service Hour for the relevant Date and validate Response Time (Hours) as any time falling within the Service
      // Hours on the same day.
      LibraryService.GetServiceHourForDate(ServiceHour,OrderDate);
      ServiceItemLine.VALIDATE(
        "Response Time (Hours)",LibraryUtility.ConvertMilliSecToHours(ServiceHour."Ending Time" - ServiceHour."Starting Time") - 1);
      ServiceItemLine.MODIFY(TRUE);

      // 3. Verify: Verify that the Response Time on Service Item Line is Ending Time of the relevant Service Hour minus the time
      // subtracted.
      ServiceItemLine.TESTFIELD("Response Time",ServiceHour."Ending Time" - LibraryUtility.ConvertHoursToMilliSec(1));
Member of Lib.Library - Utility


ConvertMilliSecToHours@27 Method

The procedure ConvertMilliSecToHours is available in codeunit 131000.

Syntax

ConvertMilliSecToHours@27(
    TimePeriod@1000 : Decimal TimePeriod //Input parameter of type Decimal
);

Parameters

TimePeriod
Input parameter of type Decimal

Return Value

Decimal

Remarks

The relevant search keywords are: Convert, Milli, Sec, To, Hours.

For a clarification about how this function works, refer to the code listed below.

      EXIT(TimePeriod / 3600000);

Example

The below example is extracted from the test automation codeunit 136106 to show one way of using this function.

      // Covers document number TC0120 - refer to TFS ID 21728.
      // Test that the Response Time on Service Item Line is Ending Time of the relevant Service Hour minus the time subtracted, for a
      // Working Day and Response Time (Hours) as any time falling within the Service Hours on the same day.

      // 1. Setup: Create Service Order for a Working Day - Service Item, Service Header, Service Item Line.
      Initialize;
      OrderDate := LibraryService.GetFirstWorkingDay(WORKDATE);
      CreateServiceHeaderGivenDate(ServiceItemLine,OrderDate);

      // 2. Exercise: Get Service Hour for the relevant Date and validate Response Time (Hours) as any time falling within the Service
      // Hours on the same day.
      LibraryService.GetServiceHourForDate(ServiceHour,OrderDate);
      ServiceItemLine.VALIDATE(
        "Response Time (Hours)",LibraryUtility.ConvertMilliSecToHours(ServiceHour."Ending Time" - ServiceHour."Starting Time") - 1);
      ServiceItemLine.MODIFY(TRUE);

      // 3. Verify: Verify that the Response Time on Service Item Line is Ending Time of the relevant Service Hour minus the time
      // subtracted.
      ServiceItemLine.TESTFIELD("Response Time",ServiceHour."Ending Time" - LibraryUtility.ConvertHoursToMilliSec(1));
Member of Lib.Library - Utility


ConvertNumericToText@28 Method

The procedure ConvertNumericToText is available in codeunit 131000.

Syntax

ConvertNumericToText@28(
    NumericCode@1000 : Text NumericCode //Input parameter of type Text
);

Parameters

NumericCode
Input parameter of type Text

Return Value

Text

Remarks

The relevant search keywords are: Convert, Numeric, To, Text.

For a clarification about how this function works, refer to the code listed below.

      EXIT(CONVERTSTR(NumericCode,'0123456789','ABCDEFGHIJ'));

Example

There are no examples available.
Member of Lib.Library - Utility


CreateCodeRecord@8 Method

The procedure CreateCodeRecord is available in codeunit 131000.

Syntax

CreateCodeRecord@8(
    TableID@1001 : Integer TableID //Input parameter of type Integer
);

Parameters

TableID
Input parameter of type Integer

Return Value

Code[10]

Remarks

The relevant search keywords are: Create, Code, Record.

For a clarification about how this function works, refer to the code listed below.

      VerifyRecordHasCodeKey(TableID,RecRef,FieldRef);
      FieldRef.VALIDATE(GenerateRandomCode(FieldRef.NUMBER,TableID));
      RecRef.INSERT(TRUE);
      EXIT(FieldRef.VALUE);

Example

There are no examples available.
Member of Lib.Library - Utility


CreateNoSeries@30 Method

The procedure CreateNoSeries is available in codeunit 131000.

Syntax

CreateNoSeries@30(
    VAR NoSeries@1003 : Record 308 NoSeries, //Reference parameter of type Record
    Default@1002 : Boolean Default, //Input parameter of type Boolean
    Manual@1001 : Boolean Manual, //Input parameter of type Boolean
    DateOrder@1000 : Boolean DateOrder //Input parameter of type Boolean
);

Parameters

NoSeries
Reference parameter of type Record
Default
Input parameter of type Boolean
Manual
Input parameter of type Boolean
DateOrder
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, No, Series.

For a clarification about how this function works, refer to the code listed below.

      NoSeries.INIT;
      NoSeries.VALIDATE(Code,GenerateRandomCode(NoSeries.FIELDNO(Code),DATABASE::"No. Series"));
      NoSeries.VALIDATE("Default Nos.",Default);
      NoSeries.VALIDATE("Manual Nos.",Manual);
      NoSeries.VALIDATE("Date Order",DateOrder);
      NoSeries.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134073 to show one way of using this function.

      LibraryERM.CreateGenJournalBatch(GenJnlBatch,LibraryERM.SelectGenJnlTemplate);

      LibraryERM.CreateBankAccount(BankAcc);
      GenJnlBatch.VALIDATE("Bal. Account Type",GenJnlBatch."Bal. Account Type"::"Bank Account");
      GenJnlBatch.VALIDATE("Bal. Account No.",BankAcc."No.");
      GenJnlBatch.MODIFY(TRUE);

      LibraryUtility.CreateNoSeries(NoSeries,TRUE,FALSE,FALSE);
      LibraryUtility.CreateNoSeriesLine(NoSeriesLine,NoSeries.Code,'','');
      GenJnlBatch.VALIDATE("No. Series",NoSeries.Code);
      GenJnlBatch.MODIFY(TRUE);
Member of Lib.Library - Utility


CreateNoSeriesLine@29 Method

The procedure CreateNoSeriesLine is available in codeunit 131000.

Syntax

CreateNoSeriesLine@29(
    VAR NoSeriesLine@1003 : Record 309 NoSeriesLine, //Reference parameter of type Record
    SeriesCode@1002 : Code[10] SeriesCode, //Input parameter of type Code
    StartingNo@1001 : Code[20] StartingNo, //Input parameter of type Code
    EndingNo@1000 : Code[20] EndingNo //Input parameter of type Code
);

Parameters

NoSeriesLine
Reference parameter of type Record
SeriesCode
Input parameter of type Code
StartingNo
Input parameter of type Code
EndingNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, No, Series, Line.

For a clarification about how this function works, refer to the code listed below.

      NoSeriesLine.INIT;
      NoSeriesLine.VALIDATE("Series Code",SeriesCode);
      RecRef.GETTABLE(NoSeriesLine);
      NoSeriesLine.VALIDATE("Line No.",GetNewLineNo(RecRef,NoSeriesLine.FIELDNO("Line No.")));

      IF StartingNo = '' THEN
        NoSeriesLine.VALIDATE("Starting No.",PADSTR(INSSTR(SeriesCode,'00000000',3),10))
      ELSE
        NoSeriesLine.VALIDATE("Starting No.",StartingNo);

      IF EndingNo = '' THEN
        NoSeriesLine.VALIDATE("Ending No.",PADSTR(INSSTR(SeriesCode,'99999999',3),10))
      ELSE
        NoSeriesLine.VALIDATE("Ending No.",EndingNo);

      NoSeriesLine.INSERT(TRUE)

Example

The below example is extracted from the test automation codeunit 134073 to show one way of using this function.

      LibraryERM.CreateGenJournalBatch(GenJnlBatch,LibraryERM.SelectGenJnlTemplate);

      LibraryERM.CreateBankAccount(BankAcc);
      GenJnlBatch.VALIDATE("Bal. Account Type",GenJnlBatch."Bal. Account Type"::"Bank Account");
      GenJnlBatch.VALIDATE("Bal. Account No.",BankAcc."No.");
      GenJnlBatch.MODIFY(TRUE);

      LibraryUtility.CreateNoSeries(NoSeries,TRUE,FALSE,FALSE);
      LibraryUtility.CreateNoSeriesLine(NoSeriesLine,NoSeries.Code,'','');
      GenJnlBatch.VALIDATE("No. Series",NoSeries.Code);
      GenJnlBatch.MODIFY(TRUE);
Member of Lib.Library - Utility


CreateNoSeriesRelationship@5 Method

The procedure CreateNoSeriesRelationship is available in codeunit 131000.

Syntax

CreateNoSeriesRelationship@5(
    Code@1002 : Code[10] Code, //Input parameter of type Code
    SeriesCode@1000 : Code[10] SeriesCode //Input parameter of type Code
);

Parameters

Code
Input parameter of type Code
SeriesCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, No, Series, Relationship.

For a clarification about how this function works, refer to the code listed below.

      NoSeriesRelationship.INIT;
      NoSeriesRelationship.VALIDATE(Code,Code);
      NoSeriesRelationship.VALIDATE("Series Code",SeriesCode);
      NoSeriesRelationship.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134982 to show one way of using this function.

      // Check No. Series Report with Related No. Series.

      // Setup: Create Two new No. Series and create relation in them.
      Initialize;
      NoSeriesCode := CreateNoSeries;
      RelatedNoSeriesCode := CreateNoSeries;
      LibraryUtility.CreateNoSeriesRelationship(NoSeriesCode,RelatedNoSeriesCode);

      // Exercise.
      SaveNoSeriesReport(NoSeriesCode);

      // Verify: Verify Related No. Series Code in Report.
      LibraryReportDataset.LoadDataSetFile;
      LibraryReportDataset.SetRange('Related_No__SeriesCaption',RelatedNoSeriesTok);
      IF NOT LibraryReportDataset.GetNextRow THEN
        ERROR(STRSUBSTNO(RowNotFoundErr,'Related_No__SeriesCaption',RelatedNoSeriesTok));
      LibraryReportDataset.AssertCurrentRowValue('NoSeriesLine2_Series_Code',RelatedNoSeriesCode);
Member of Lib.Library - Utility


ExistsDecimalValueInArray@46 Method

The procedure ExistsDecimalValueInArray is available in codeunit 131000.

Syntax

ExistsDecimalValueInArray@46(
    RowValueSet@1001 : ARRAY [250] OF Text[250] RowValueSet, //Input Array parameter of type Text
    Value@1002 : Decimal Value //Input parameter of type Decimal
);

Parameters

RowValueSet
Input Array parameter of type Text
Value
Input parameter of type Decimal

Return Value

Boolean

Remarks

The relevant search keywords are: Exists, Decimal, Value, In, Array.

For a clarification about how this function works, refer to the code listed below.

      REPEAT
        Counter += 1;
        IF EVALUATE(CurrentValue,RowValueSet[Counter]) THEN;
      UNTIL (CurrentValue = Value) OR (Counter = ARRAYLEN(RowValueSet));
      EXIT(CurrentValue = Value);

Example

There are no examples available.
Member of Lib.Library - Utility


FillMaxText@34 Method

The procedure FillMaxText is available in codeunit 131000.

Syntax

FillMaxText@34(
    RecVar@1000 : Variant RecVar, //Input parameter of type Variant
    FieldNo@1001 : Integer FieldNo //Input parameter of type Integer
);

Parameters

RecVar
Input parameter of type Variant
FieldNo
Input parameter of type Integer

Remarks

The relevant search keywords are: Fill, Max, Text.

For a clarification about how this function works, refer to the code listed below.

      RecRef.GETTABLE(RecVar);
      FieldRef := RecRef.FIELD(FieldNo);
      FieldRef.VALUE := GenerateRandomText(FieldRef.LENGTH);
      RecRef.MODIFY;

Example

The below example is extracted from the test automation codeunit 134332 to show one way of using this function.

      LibrarySales.CreateSalesHeader(SalesHeader,SalesHeader."Document Type"::Order,LibrarySales.CreateCustomerNo);
      LibrarySales.CreateSalesLine(
        SalesLine,SalesHeader,SalesLine.Type::Item,
        LibraryInventory.CreateItemNo,LibraryRandom.RandIntInRange(2,5));
      LibrarySales.CreateSalesLine(SalesLine,SalesHeader,SalesLine.Type,SalesLine."No.",0);
      SalesLine.VALIDATE("No.",'');
      SalesLine.MODIFY;
      LibraryUtility.FillMaxText(SalesLine,SalesLine.FIELDNO(Description));
      SalesLine.FIND;

      CustomerNo := SalesHeader."Sell-to Customer No.";
      Description := SalesLine.Description;
      EXIT(LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE));
Member of Lib.Library - Utility


FindControl@20 Method

The procedure FindControl is available in codeunit 131000.

Syntax

FindControl@20(
    ObjectNo@1004 : Integer ObjectNo, //Input parameter of type Integer
    FieldNo@1000 : Integer FieldNo //Input parameter of type Integer
);

Parameters

ObjectNo
Input parameter of type Integer
FieldNo
Input parameter of type Integer

Return Value

Boolean

Remarks

The relevant search keywords are: Find, Control.

For a clarification about how this function works, refer to the code listed below.

      TestString := '';
      ObjectMetadata.GET(ObjectMetadata."Object Type"::Page,ObjectNo);
      ObjectMetadata.CALCFIELDS(Metadata);
      IF ObjectMetadata.Metadata.HASVALUE THEN
        ObjectMetadata.Metadata.CREATEINSTREAM(MetaDataInstream);
      WHILE NOT MetaDataInstream.EOS DO BEGIN
        MetaDataInstream.READTEXT(TestString);
        IF STRPOS(TestString,'DataColumnName="' + FORMAT(FieldNo) + '"') <> 0 THEN
          EXIT(TRUE);
      END;
      EXIT(FALSE);

Example

There are no examples available.
Member of Lib.Library - Utility


FindEditable@25 Method

The procedure FindEditable is available in codeunit 131000.

Syntax

FindEditable@25(
    ObjectNo@1001 : Integer ObjectNo, //Input parameter of type Integer
    FieldNo@1000 : Integer FieldNo //Input parameter of type Integer
);

Parameters

ObjectNo
Input parameter of type Integer
FieldNo
Input parameter of type Integer

Return Value

Boolean

Remarks

The relevant search keywords are: Find, Editable.

For a clarification about how this function works, refer to the code listed below.

      // Find and return the Editable property for a page control. Generate an error if page control does not exists.
      Editable := GetPropertyValueForControl(ObjectNo,FieldNo,'Editable="',TRUE);
      IF Editable = 'FALSE' THEN
        EXIT(FALSE);
      IF (Editable = '') OR (Editable = 'TRUE') THEN
        EXIT(TRUE);

Example

There are no examples available.
Member of Lib.Library - Utility


FindFieldNoInTable@2 Method

The procedure FindFieldNoInTable is available in codeunit 131000.

Syntax

FindFieldNoInTable@2(
    TableNo@1001 : Integer TableNo, //Input parameter of type Integer
    FieldName@1000 : Text[30] FieldName //Input parameter of type Text
);

Parameters

TableNo
Input parameter of type Integer
FieldName
Input parameter of type Text

Return Value

Integer

Remarks

The relevant search keywords are: Find, Field, No, In, Table.

For a clarification about how this function works, refer to the code listed below.

      Field.SETRANGE(TableNo,TableNo);
      Field.SETRANGE(FieldName,FieldName);
      Field.FINDFIRST;
      EXIT(Field."No.");

Example

The below example is extracted from the test automation codeunit 137031 to show one way of using this function.

      IF ReasonCode.COUNT = 0 THEN
        EXIT;

      ReasonCode.NEXT(RANDOM(ReasonCode.COUNT));
      PurchaseHeader.VALIDATE("Reason Code",ReasonCode.Code);

      PurchInvHeader.SETRANGE("Buy-from Vendor No.",PurchaseHeader."Buy-from Vendor No.");

      IF PurchInvHeader.FINDFIRST AND
         LibraryUtility.CheckFieldExistenceInTable(DATABASE::"Purchase Header",'Adjustment Applies-to')
      THEN BEGIN
        RecRef.GETTABLE(PurchaseHeader);
        FieldRef := RecRef.FIELD(LibraryUtility.FindFieldNoInTable(DATABASE::"Purchase Header",'Adjustment Applies-to'));
        FieldRef.VALIDATE(PurchInvHeader."No.");
        RecRef.SETTABLE(PurchaseHeader);

        PurchaseHeader.MODIFY(TRUE);
      END;
Member of Lib.Library - Utility


FindMaxValueForField@17 Method

The procedure FindMaxValueForField is available in codeunit 131000.

Syntax

FindMaxValueForField@17(
    ObjectNo@1001 : Integer ObjectNo, //Input parameter of type Integer
    FieldNo@1000 : Integer FieldNo //Input parameter of type Integer
);

Parameters

ObjectNo
Input parameter of type Integer
FieldNo
Input parameter of type Integer

Return Value

Integer

Remarks

The relevant search keywords are: Find, Max, Value, For, Field.

For a clarification about how this function works, refer to the code listed below.

      EVALUATE(MaximumValue,GetPropertyValueForField(ObjectNo,FieldNo,'MaxValue="',FALSE));
      EXIT(MaximumValue);

Example

The below example is extracted from the test automation codeunit 134100 to show one way of using this function.

      // [FEATURE] [Sales] [Prepayment %]
      // [SCENARIO] The maximum value of Prepayment % in Customer is 100.

      Assert.AreEqual(
        100,
        LibraryUtility.FindMaxValueForField(DATABASE::Customer,Customer.FIELDNO("Prepayment %")),
        STRSUBSTNO(MaximumValueErr,Customer.FIELDCAPTION("Prepayment %"),Customer.TABLECAPTION,100));
Member of Lib.Library - Utility


FindMinValueForField@19 Method

The procedure FindMinValueForField is available in codeunit 131000.

Syntax

FindMinValueForField@19(
    ObjectNo@1001 : Integer ObjectNo, //Input parameter of type Integer
    FieldNo@1000 : Integer FieldNo //Input parameter of type Integer
);

Parameters

ObjectNo
Input parameter of type Integer
FieldNo
Input parameter of type Integer

Return Value

Integer

Remarks

The relevant search keywords are: Find, Min, Value, For, Field.

For a clarification about how this function works, refer to the code listed below.

      EVALUATE(MinimumValue,GetPropertyValueForField(ObjectNo,FieldNo,'MinValue="',FALSE));
      EXIT(MinimumValue);

Example

The below example is extracted from the test automation codeunit 134100 to show one way of using this function.

      // [FEATURE] [Sales] [Prepayment %]
      // [SCENARIO] The minimum value of Prepayment % in Customer is 0.

      Assert.AreEqual(
        0,
        LibraryUtility.FindMinValueForField(DATABASE::Customer,Customer.FIELDNO("Prepayment %")),
        STRSUBSTNO(MinimumValueErr,Customer.FIELDCAPTION("Prepayment %"),Customer.TABLECAPTION,0));
Member of Lib.Library - Utility


FindOrCreateCodeRecord@18 Method

The procedure FindOrCreateCodeRecord is available in codeunit 131000.

Syntax

FindOrCreateCodeRecord@18(
    TableID@1001 : Integer TableID //Input parameter of type Integer
);

Parameters

TableID
Input parameter of type Integer

Return Value

Code[10]

Remarks

The relevant search keywords are: Find, Or, Create, Code, Record.

For a clarification about how this function works, refer to the code listed below.

      VerifyRecordHasCodeKey(TableID,RecRef,FieldRef);
      IF NOT RecRef.FINDFIRST THEN BEGIN
        FieldRef.VALIDATE(GenerateRandomCode(FieldRef.NUMBER,TableID));
        RecRef.INSERT(TRUE);
      END;
      EXIT(FieldRef.VALUE);

Example

There are no examples available.
Member of Lib.Library - Utility


FindRecord@6 Method

The procedure FindRecord is available in codeunit 131000.

Syntax

FindRecord@6(
    VAR RecRef@1000 : RecordRef RecRef //Reference parameter of type RecordRef
);

Parameters

RecRef
Reference parameter of type RecordRef

Remarks

The relevant search keywords are: Find, Record.

For a clarification about how this function works, refer to the code listed below.

      RecRef.FINDFIRST;

Example

The below example is extracted from the test automation codeunit 134476 to show one way of using this function.

      Purchasing.INIT;
      Purchasing.SETRANGE("Drop Shipment",TRUE);
      RecordRef.GETTABLE(Purchasing);
      LibraryUtility.FindRecord(RecordRef);
      RecordRef.SETTABLE(Purchasing);
      EXIT(Purchasing.Code);
Member of Lib.Library - Utility


FindVisible@23 Method

The procedure FindVisible is available in codeunit 131000.

Syntax

FindVisible@23(
    ObjectNo@1002 : Integer ObjectNo, //Input parameter of type Integer
    FieldNo@1001 : Integer FieldNo //Input parameter of type Integer
);

Parameters

ObjectNo
Input parameter of type Integer
FieldNo
Input parameter of type Integer

Return Value

Boolean

Remarks

The relevant search keywords are: Find, Visible.

For a clarification about how this function works, refer to the code listed below.

      Visible := GetPropertyValueForControl(ObjectNo,FieldNo,'Visible="',TRUE);
      IF Visible = 'FALSE' THEN
        EXIT(FALSE);
      IF (Visible = '') OR (Visible = 'TRUE') THEN
        EXIT(TRUE);

Example

There are no examples available.
Member of Lib.Library - Utility


GenerateGUID@51 Method

The procedure GenerateGUID is available in codeunit 131000.

Syntax

GenerateGUID@51(
      //param element not supplied
);

Return Value

Code[10]

Remarks

The relevant search keywords are: Generate, GUID.

For a clarification about how this function works, refer to the code listed below.

      IF NOT NoSeries.GET('GUID') THEN BEGIN
        NoSeries.INIT;
        NoSeries.VALIDATE(Code,'GUID');
        NoSeries.VALIDATE("Default Nos.",TRUE);
        NoSeries.VALIDATE("Manual Nos.",TRUE);
        NoSeries.INSERT(TRUE);

        CreateNoSeriesLine(NoSeriesLine,NoSeries.Code,'','');
      END;

      EXIT(NoSeriesMgt.GetNextNo(NoSeries.Code,WORKDATE,TRUE));

Example

The below example is extracted from the test automation codeunit 134000 to show one way of using this function.

      CustLedgEntry."Applies-to ID" := LibraryUtility.GenerateGUID;
      CustLedgEntry.MODIFY;
Member of Lib.Library - Utility


GenerateMOD97CompliantCode@12 Method

The procedure GenerateMOD97CompliantCode is available in codeunit 131000.

Syntax

GenerateMOD97CompliantCode@12(
      //param element not supplied
);

Return Value

Code[10]

Remarks

The relevant search keywords are: Generate, MOD97, Compliant, Code.

For a clarification about how this function works, refer to the code listed below.

      CompliantCodeBody := LibraryRandom.RandIntInRange(1,100000000);
      CodeMod97Compliant := CONVERTSTR(FORMAT(CompliantCodeBody,8,'<Integer>'),' ','0');
      CodeMod97Compliant += CONVERTSTR(FORMAT(97 - CompliantCodeBody MOD 97,2,'<Integer>'),' ','0');

Example

There are no examples available.
Member of Lib.Library - Utility


GenerateRandomAlphabeticText@93 Method

The procedure GenerateRandomAlphabeticText is available in codeunit 131000.

Syntax

GenerateRandomAlphabeticText@93(
    Length@1000 : Integer Length, //Input parameter of type Integer
    Option@1004 : Option Option //Input parameter of type Option
);

Parameters

Length
Input parameter of type Integer
Option
Input parameter of type Option

Return Value

Text

Remarks

The relevant search keywords are: Generate, Random, Alphabetic, Text.

For a clarification about how this function works, refer to the code listed below.

      CASE Option OF
        Option::Capitalized:
          BEGIN
            ASCIICodeFrom := 65;
            ASCIICodeTo := 90;
          END;
        Option::Literal:
          BEGIN
            ASCIICodeFrom := 97;
            ASCIICodeTo := 122;
          END;
        ELSE
          EXIT;
      END;
      FOR i := 1 TO Length DO BEGIN
        Number := LibraryRandom.RandIntInRange(ASCIICodeFrom,ASCIICodeTo);
        String[i] := Number;
      END;

Example

The below example is extracted from the test automation codeunit 134080 to show one way of using this function.

      // [SCENARIO 221966] Posting Description with long Currency Code and Amount is not truncated on run "Adjust Exchange Rates" report
      Initialize;

      // [GIVEN] Currency Code "XXX" with length 3+
      CurrencyCode := CreateCurrency;
      Assert.IsTrue(STRLEN(CurrencyCode) > 2,'The length of currency code must be greater than 2');

      // [GIVEN] Posted Gen. Journal Line with Currency Code "XXX" and Amount "YYY"
      CreateGenAndModifyExchRate(
        GenJournalLine,GenJournalLine."Account Type"::"Bank Account",CreateBankAccount(CurrencyCode),
        GenJournalLine."Document Type"::" ",LibraryRandom.RandDec(100,2),LibraryRandom.RandInt(50));
      AdjExchDocNo := LibraryUtility.GenerateGUID;

      // [GIVEN] Posting Description template string "D" = "RANDDESC %1 %2"
      DescLen := MAXSTRLEN(GLEntry.Description) - STRLEN(STRSUBSTNO(' %1 %2',GenJournalLine."Currency Code",GenJournalLine.Amount));
      Description := COPYSTR(LibraryUtility.GenerateRandomAlphabeticText(DescLen,0) + ' %1 %2',1);

      ExpectedDescription := STRSUBSTNO(Description,GenJournalLine."Currency Code",GenJournalLine.Amount);

      // [WHEN] "Adjust Exchange Rates" report run with "D" as Description
      LibraryERM.RunAdjustExchangeRates(CurrencyCode,0D,WORKDATE,Description,WORKDATE,AdjExchDocNo,FALSE);

      // [THEN] Description in G/L entries is equal to "RANDDESC XXX YYY"
      GLEntry.SETRANGE("Document No.",AdjExchDocNo);
      GLEntry.SETRANGE("Posting Date",WORKDATE);
      GLEntry.FINDSET;
      REPEAT
        GLEntry.TESTFIELD(Description,PADSTR(ExpectedDescription,MAXSTRLEN(GLEntry.Description)));
      UNTIL GLEntry.NEXT = 0;
Member of Lib.Library - Utility


GenerateRandomCode@36 Method

The procedure GenerateRandomCode is available in codeunit 131000.

Syntax

GenerateRandomCode@36(
    FieldNo@1001 : Integer FieldNo, //Input parameter of type Integer
    TableNo@1000 : Integer TableNo //Input parameter of type Integer
);

Parameters

FieldNo
Input parameter of type Integer
TableNo
Input parameter of type Integer

Return Value

Code[10]

Remarks

The relevant search keywords are: Generate, Random, Code.

For a clarification about how this function works, refer to the code listed below.

      // Create a random and unique code for the any code field.

      RecRef.OPEN(TableNo,TRUE,COMPANYNAME);
      CLEAR(FieldRef);
      FieldRef := RecRef.FIELD(FieldNo);

      REPEAT
        IF FieldRef.LENGTH < 10 THEN
          FieldRef.SETRANGE(COPYSTR(GenerateGUID,10 - FieldRef.LENGTH + 1)) // Cut characters on the left side.
        ELSE
          FieldRef.SETRANGE(GenerateGUID);
      UNTIL RecRef.ISEMPTY;

      EXIT(FieldRef.GETFILTER)

Example

The below example is extracted from the test automation codeunit 134001 to show one way of using this function.

      WITH VendLedgEntry DO BEGIN
        INIT;
        RecRef.GETTABLE(VendLedgEntry);
        "Entry No." := LibraryUtility.GetNewLineNo(RecRef,FIELDNO("Entry No."));
        "Posting Date" := WORKDATE;
        "Pmt. Discount Date" := WORKDATE;
        Open := TRUE;
        "Document No." :=
          LibraryUtility.GenerateRandomCode(FIELDNO("Document No."),DATABASE::"Vendor Ledger Entry");
        INSERT;
        VALIDATE("Remaining Amount",LibraryRandom.RandDec(100,2));
        MODIFY(TRUE);
      END;
Member of Lib.Library - Utility


GenerateRandomCode20@43 Method

The procedure GenerateRandomCode20 is available in codeunit 131000.

Syntax

GenerateRandomCode20@43(
    FieldNo@1001 : Integer FieldNo, //Input parameter of type Integer
    TableNo@1000 : Integer TableNo //Input parameter of type Integer
);

Parameters

FieldNo
Input parameter of type Integer
TableNo
Input parameter of type Integer

Return Value

Code[20]

Remarks

The relevant search keywords are: Generate, Random, Code20.

For a clarification about how this function works, refer to the code listed below.

      // Create a random and unique 20 code for the any code field.
      RecRef.OPEN(TableNo,FALSE,COMPANYNAME);
      CLEAR(FieldRef);
      FieldRef := RecRef.FIELD(FieldNo);
      REPEAT
        FieldRef.SETRANGE(PADSTR(GenerateGUID,FieldRef.LENGTH,'0'));
      UNTIL RecRef.ISEMPTY;

      EXIT(FieldRef.GETFILTER);

Example

The below example is extracted from the test automation codeunit 134902 to show one way of using this function.

      // [FEATURE] [Dimension]
      // [SCENARIO 229097] Verify created Dimension Filter with more than 250 characters
      Initialize;

      // [GIVEN] Create new Acc. Schedule for G/L Account
      CreateAccountScheduleWithGLAccount(AccScheduleLine);

      // [GIVEN] Create 25 random Dimension Values without totalings
      FOR i := 1 TO 25 DO BEGIN
        CreateDimValueWithCodeAndType(
          StandardDimValue[i],
          LibraryUtility.GenerateRandomCode20(StandardDimValue[i].FIELDNO(Code),DATABASE::"Dimension Value"),
          StandardDimValue[i]."Dimension Value Type"::Standard);
        DimFilterTxt += StandardDimValue[i].Code + '|';
      END;
      DimFilterTxt := COPYSTR(DimFilterTxt,1,STRLEN(DimFilterTxt) - 1);

      // [GIVEN] Choose only odd Dimension Values from sorted created array so Acc. Schedule Overview filter will not be optimized
      ResultDimValue.SETFILTER(Code,DimFilterTxt);
      ResultDimValue.SETFILTER("Dimension Code",StandardDimValue[1]."Dimension Code");
      ResultDimValue.FINDSET;
      DimFilterTxt := '';
      FOR i := 1 TO 25 DO BEGIN
        IF i MOD 2 = 1 THEN
          DimFilterTxt += ResultDimValue.Code + '|';
        ResultDimValue.NEXT
      END;
      DimFilterTxt := COPYSTR(DimFilterTxt,1,STRLEN(DimFilterTxt) - 1);

      // [GIVEN] Run Acc. Schedule Overview
      AccScheduleOverview.TRAP;
      OpenAccountScheduleOverviewPage(AccScheduleLine."Schedule Name");

      // [WHEN] Acc. Schedule Overview Dim1Filter is set to filter choosen dimension values
      AccScheduleOverview.Dim1Filter.SETVALUE(DimFilterTxt);

      // [THEN] Acc. Schedule Overview "Dimension 1 Filter" created, has 13 * 20 + 12 = 272 characters and filters only choosen dimension values
      Assert.AreEqual(272,STRLEN(AccScheduleOverview.FILTER.GETFILTER("Dimension 1 Filter")),Dim1FilterErr);

      ResultDimValue.RESET;
      ResultDimValue.SETFILTER(Code,AccScheduleOverview.FILTER.GETFILTER("Dimension 1 Filter"));
      ResultDimValue.SETFILTER("Dimension Code",StandardDimValue[1]."Dimension Code");
      Assert.AreEqual(13,ResultDimValue.COUNT,Dim1FilterErr);
      FOR i := 1 TO 25 DO BEGIN
        IF i MOD 2 = 1 THEN
          VerifyDimValueExistInFilteredTable(ResultDimValue,StandardDimValue[i].Code);
      END;

      AccScheduleOverview.OK.INVOKE;

      // Tear down
      ResultDimValue.RESET;
      ResultDimValue.DELETEALL;
Member of Lib.Library - Utility


GenerateRandomCodeWithLength@37 Method

The procedure GenerateRandomCodeWithLength is available in codeunit 131000.

Syntax

GenerateRandomCodeWithLength@37(
    FieldNo@1001 : Integer FieldNo, //Input parameter of type Integer
    TableNo@1000 : Integer TableNo, //Input parameter of type Integer
    CodeLength@1002 : Integer CodeLength //Input parameter of type Integer
);

Parameters

FieldNo
Input parameter of type Integer
TableNo
Input parameter of type Integer
CodeLength
Input parameter of type Integer

Return Value

Code[10]

Remarks

The relevant search keywords are: Generate, Random, Code, Length.

For a clarification about how this function works, refer to the code listed below.

      // Create a random and unique code for the any code field.
      RecRef.OPEN(TableNo,FALSE,COMPANYNAME);
      CLEAR(FieldRef);
      FieldRef := RecRef.FIELD(FieldNo);
      REPEAT
        NewCode := COPYSTR(GenerateRandomXMLText(CodeLength),1,MAXSTRLEN(NewCode));
        FieldRef.SETRANGE(NewCode);
      UNTIL RecRef.ISEMPTY;

      EXIT(NewCode);

Example

There are no examples available.
Member of Lib.Library - Utility


GenerateRandomDate@9 Method

The procedure GenerateRandomDate is available in codeunit 131000.

Syntax

GenerateRandomDate@9(
    MinDate@1000 : Date MinDate, //Input parameter of type Date
    MaxDate@1001 : Date MaxDate //Input parameter of type Date
);

Parameters

MinDate
Input parameter of type Date
MaxDate
Input parameter of type Date

Return Value

Date

Remarks

The relevant search keywords are: Generate, Random, Date.

For a clarification about how this function works, refer to the code listed below.

      EVALUATE(DateFormulaMinDate,'<-1D>');
      EVALUATE(DateFormulaRandomDate,'<' + FORMAT(RANDOM(MaxDate - MinDate + 1)) + 'D>');
      EXIT(CALCDATE(DateFormulaRandomDate,CALCDATE(DateFormulaMinDate,MinDate)));

Example

The below example is extracted from the test automation codeunit 134700 to show one way of using this function.

      WITH CustLedgerEntry DO BEGIN
        IF FINDLAST THEN;
        INIT;
        "Entry No." += 1;
        "Customer No." := CreateCustomer;
        "Document Type" := DocumentType;
        Open := IsOpen;
        IF IsOpen THEN
          "Remaining Amount" := LibraryRandom.RandDec(100,2);
        "Document No." :=
          LibraryUtility.GenerateRandomCode(FIELDNO("Document No."),DATABASE::"Cust. Ledger Entry");
        Description :=
          LibraryUtility.GenerateRandomCode(FIELDNO(Description),DATABASE::"Cust. Ledger Entry");
        "Due Date" := LibraryUtility.GenerateRandomDate(WORKDATE,WORKDATE + LibraryRandom.RandInt(10));
        "Remaining Pmt. Disc. Possible" := LibraryRandom.RandDec(MaxPaymentDiscountAmount,2);
        "Pmt. Discount Date" :=
          LibraryUtility.GenerateRandomDate(WORKDATE - LibraryRandom.RandInt(10),WORKDATE);
        INSERT;

        EXIT("Entry No.");
      END
Member of Lib.Library - Utility


GenerateRandomEmail@39 Method

The procedure GenerateRandomEmail is available in codeunit 131000.

Syntax

GenerateRandomEmail@39(
      //param element not supplied
);

Return Value

Text[45]

Remarks

The relevant search keywords are: Generate, Random, Email.

For a clarification about how this function works, refer to the code listed below.

      EXIT(GenerateRandomAlphabeticText(20,1) + '@' + GenerateRandomAlphabeticText(20,1) + '.' + GenerateRandomAlphabeticText(3,1));

Example

There are no examples available.
Member of Lib.Library - Utility


GenerateRandomFraction@22 Method

The procedure GenerateRandomFraction is available in codeunit 131000.

Syntax

GenerateRandomFraction@22(
      //param element not supplied
);

Return Value

Decimal

Remarks

The relevant search keywords are: Generate, Random, Fraction.

For a clarification about how this function works, refer to the code listed below.

      EXIT(RANDOM(99) / 100);  // Generate any fraction between 0.01 to .99.

Example

The below example is extracted from the test automation codeunit 134100 to show one way of using this function.

      // [FEATURE] [Sales] [Sales Prepayment %]
      // [SCENARIO 128392] Prepayment Invoice using combinations of Item Setup.

      // 1. Setup: Create new Customer and Item, modify Prepayment Percent of Customer, create Customer Price Group, modify the customer
      // Create Sales Prepayment for Sales Type Customer Price Group and All Customers and validate Prepayment Percent.
      Initialize;
      LibrarySales.CreateCustomer(Customer);
      PrepaymentPercent := LibraryRandom.RandDec(99,5);  // Using Random Number Generator for Prepayment Percent.
      PrepaymentPercent2 := PrepaymentPercent - LibraryUtility.GenerateRandomFraction;
      PrepaymentPercentInCustomer(Customer,PrepaymentPercent);
      LibrarySales.CreateCustomerPriceGroup(CustomerPriceGroup);
      CustomerPrepaymentPriceGroup(Customer,CustomerPriceGroup.Code);
      CreateItem(Item);

      // Using Random Number Generator for Prepaymnet Percent.
      CreatePrepayment(
        SalesPrepaymentPct,SalesPrepaymentPct."Sales Type"::"Customer Price Group",
        CustomerPriceGroup.Code,Item."No.",PrepaymentPercent2);
      CreatePrepayment(
        SalesPrepaymentPct,SalesPrepaymentPct."Sales Type"::"All Customers",
        '',SalesPrepaymentPct."Item No.",PrepaymentPercent2 + LibraryRandom.RandInt(5));

      // 2. Exercise: Create Sales Header, Sales Line for created Item, post the Sales Prepayment invoice.
      CreateSalesDocumentPrepayment(SalesHeader,SalesLine,Customer."No.",SalesPrepaymentPct."Item No.");
      PrepmtLineAmount := SalesLine."Prepmt. Line Amount";
      LibrarySales.PostSalesPrepaymentInvoice(SalesHeader);

      // 3. Verify: Check the Prepmt Line Amount, Prepmt Amt to Deduct, Prepmt Amt Inv in Sales Line, check the corresponding GL Entry,
      // VAT Entry, Customer Ledger Entry, Detailed Customer Ledger Entry.
      VerifyPrepaymentAmount(SalesHeader."No.",PrepmtLineAmount);
      ASSERTERROR VerifyLedgerEntries(SalesHeader."No.",PrepmtLineAmount,SalesHeader."Posting Date");
Member of Lib.Library - Utility


GenerateRandomNumericText@47 Method

The procedure GenerateRandomNumericText is available in codeunit 131000.

Syntax

GenerateRandomNumericText@47(
    Length@1000 : Integer Length //Input parameter of type Integer
);

Parameters

Length
Input parameter of type Integer

Return Value

Text

Remarks

The relevant search keywords are: Generate, Random, Numeric, Text.

For a clarification about how this function works, refer to the code listed below.

      FOR i := 1 TO Length DO
        String[i] := LibraryRandom.RandIntInRange(48,57);

Example

There are no examples available.
Member of Lib.Library - Utility


GenerateRandomText@58 Method

The procedure GenerateRandomText is available in codeunit 131000.

Syntax

GenerateRandomText@58(
    Length@1000 : Integer Length //Input parameter of type Integer
);

Parameters

Length
Input parameter of type Integer

Return Value

Text

Remarks

The relevant search keywords are: Generate, Random, Text.

For a clarification about how this function works, refer to the code listed below.

      // Create a random string of length <length>.
      FOR i := 1 TO Length DO
        String[i] := LibraryRandom.RandIntInRange(33,126); // ASCII: ! (33) to ~ (126)

      EXIT(String)

Example

The below example is extracted from the test automation codeunit 134152 to show one way of using this function.

      SalesHeader.INIT;
      EXIT(COPYSTR(LibraryUtility.GenerateRandomText(
            MAXSTRLEN(SalesHeader."External Document No.")),1,MAXSTRLEN(SalesHeader."External Document No.")));
Member of Lib.Library - Utility


GenerateRandomXMLText@59 Method

The procedure GenerateRandomXMLText is available in codeunit 131000.

Syntax

GenerateRandomXMLText@59(
    Length@1000 : Integer Length //Input parameter of type Integer
);

Parameters

Length
Input parameter of type Integer

Return Value

Text

Remarks

The relevant search keywords are: Generate, Random, XML, Text.

For a clarification about how this function works, refer to the code listed below.

      // Create a random string of length <length> containing characters allowed by XML
      FOR i := 1 TO Length DO BEGIN
        Number := LibraryRandom.RandIntInRange(0,61);
        CASE Number OF
          0..9:
            Number += 48; // 0-9
          10..35:
            Number += 65 - 10; // A-Z
          36..61:
            Number += 97 - 36; // a-z
        END;
        String[i] := Number;
      END;

Example

The below example is extracted from the test automation codeunit 134403 to show one way of using this function.

      // [SCENARIO 109389] Message to recipient is stored in the exported file
      Init;
      RequiredMessageLength := 140;

      // [GIVEN] A Payment Journal Line
      // [GIVEN] bal. bank account using the SEPA CT export format
      CreateGenJnlLine(GenJnlLine);

      // [GIVEN] 140 characters in "Message to recipient"
      GenJnlLine.VALIDATE("Message to Recipient",LibraryUtility.GenerateRandomXMLText(RequiredMessageLength));
      GenJnlLine.MODIFY(TRUE);
      Assert.AreEqual(RequiredMessageLength,STRLEN(GenJnlLine."Message to Recipient"),InvalidLengthErr);

      // [WHEN] The Payment Journal Line is exported
      GenJnlLine.SETRANGE("Document No.",GenJnlLine."Document No.");
      GenJnlLine.SETRANGE("Document Type",GenJnlLine."Document Type");
      TempBlob.INIT;
      TempBlob.Blob.CREATEOUTSTREAM(OutStr);
      XMLPORT.EXPORT(BankAccount.GetPaymentExportXMLPortID,OutStr,GenJnlLine);

      // [THEN] The exported file contains an ustrd tag with all 140 characters
      LibraryXPathXMLReader.InitializeWithBlob(TempBlob,NamespaceTxt);
      LibraryXPathXMLReader.GetNodeList('//Ustrd',NodeList);

      ContainsReqCharacters := FALSE;
      FOR i := 1 TO NodeList.Count DO
        IF GenJnlLine."Message to Recipient" = NodeList.Item(i - 1).InnerText THEN
          ContainsReqCharacters := TRUE;

      Assert.IsTrue(ContainsReqCharacters,MessageToRecipientNotFoundErr);
Member of Lib.Library - Utility


GetFieldLength@3 Method

The procedure GetFieldLength is available in codeunit 131000.

Syntax

GetFieldLength@3(
    TableNo@1000 : Integer TableNo, //Input parameter of type Integer
    FieldNo@1001 : Integer FieldNo //Input parameter of type Integer
);

Parameters

TableNo
Input parameter of type Integer
FieldNo
Input parameter of type Integer

Return Value

Integer

Remarks

The relevant search keywords are: Get, Field, Length.

For a clarification about how this function works, refer to the code listed below.

      RecRef.OPEN(TableNo);
      FieldRef := RecRef.FIELD(FieldNo);
      EXIT(FieldRef.LENGTH);

Example

The below example is extracted from the test automation codeunit 134039 to show one way of using this function.

      LibraryPurchase.CreatePurchHeader(PurchaseHeader,PurchaseHeader."Document Type"::"Credit Memo",VendorNo);
      PurchaseHeader.VALIDATE(
        "Vendor Cr. Memo No.",
        COPYSTR(LibraryUtility.GenerateRandomCode(PurchaseHeader.FIELDNO("Vendor Invoice No."),DATABASE::"Purchase Header"),1,
          LibraryUtility.GetFieldLength(DATABASE::"Purchase Header",PurchaseHeader.FIELDNO("Vendor Invoice No."))));
      PurchaseHeader.MODIFY(TRUE);
      PurchaseLine.VALIDATE("Document Type",PurchaseHeader."Document Type");
      PurchaseLine.VALIDATE("Document No.",PurchaseHeader."No.");
      CODEUNIT.RUN(CODEUNIT::"Purch.-Get Return Shipments",PurchaseLine);
Member of Lib.Library - Utility


GetGlobalNoSeriesCode@44 Method

The procedure GetGlobalNoSeriesCode is available in codeunit 131000.

Syntax

GetGlobalNoSeriesCode@44(
      //param element not supplied
);

Return Value

Code[10]

Remarks

The relevant search keywords are: Get, Global, No, Series, Code.

For a clarification about how this function works, refer to the code listed below.

      // Init, get the global no series
      IF NOT NoSeries.GET('GLOBAL') THEN BEGIN
        NoSeries.INIT;
        NoSeries.VALIDATE(Code,'GLOBAL');
        NoSeries.VALIDATE("Default Nos.",TRUE);
        NoSeries.VALIDATE("Manual Nos.",TRUE);
        NoSeries.INSERT(TRUE);
        CreateNoSeriesLine(NoSeriesLine,NoSeries.Code,'','');
      END;

      EXIT(NoSeries.Code)

Example

The below example is extracted from the test automation codeunit 134102 to show one way of using this function.

      // Check Posted Prepayment Invoice Nos after creating new No. Series for Posted Prepayment Purchase Invoice in Purchase and Payables Setup.

      // Setup: Create new No. Series for Posted Prepayment Purchase Invoice and update in Purchase and Payables Setup, create Purchase Order and update Purchase Prepayment account in General Posting Setup.
      Initialize;
      PostedPrepmtInvNos := LibraryUtility.GetGlobalNoSeriesCode;
      OldPostedPrepmtInvNos := PostedPrepmtInvNosInPurchaseSetup(PostedPrepmtInvNos);
      CreatePurchaseDocument(PurchaseLine,'');
      GLAccount.GET(LibraryERM.CreateGLAccountWithPurchSetup);
      PurchasePrepmtAccount :=
        UpdatePurchasePrepmtAccount(GLAccount."No.",PurchaseLine."Gen. Bus. Posting Group",PurchaseLine."Gen. Prod. Posting Group");
      PurchaseHeader.GET(PurchaseLine."Document Type",PurchaseLine."Document No.");

      // Exercise: Post Prepayment Purchase Invoice.
      PurchasePostPrepayments.Invoice(PurchaseHeader);

      // Verify: Verify the Posted Prepayment Invoice Nos.
      VerifyPrepaymentInvoice(PurchaseHeader."No.",PostedPrepmtInvNos);

      // Tear Down: Reset the Posted Prepayment Invoice Nos from the Purchase and Payables Setup and Purchse Prepayment Account in General Posting Setup.
      PostedPrepmtInvNosInPurchaseSetup(OldPostedPrepmtInvNos);
      UpdatePurchasePrepmtAccount(
        PurchasePrepmtAccount,PurchaseLine."Gen. Bus. Posting Group",PurchaseLine."Gen. Prod. Posting Group");
Member of Lib.Library - Utility


GetInetRoot@42 Method

The procedure GetInetRoot is available in codeunit 131000.

Syntax

GetInetRoot@42(
      //param element not supplied
);

Return Value

Text

Remarks

The relevant search keywords are: Get, Inet, Root.

For a clarification about how this function works, refer to the code listed below.

      EXIT(APPLICATIONPATH + '\..\..\..\..\..\');

Example

There are no examples available.
Member of Lib.Library - Utility


GetLastTransactionNo@103 Method

The procedure GetLastTransactionNo is available in codeunit 131000.

Syntax

GetLastTransactionNo@103(
      //param element not supplied
);

Return Value

Integer

Remarks

The relevant search keywords are: Get, Last, Transaction, No.

For a clarification about how this function works, refer to the code listed below.

      IF GLEntry.FINDLAST THEN
        EXIT(GLEntry."Transaction No.");

      EXIT(0);

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      // Setup
      LastTransactionNo := Initialize;
      PostedPurchaseDocNo :=
        ApplyAdvPmtToInvoice(
          PaymentGenJournalLine,BaseAmount,TaxAmount,SBCAmount,KKCAmount,
          DocumentType,RevChargeType,PoT);
      ApplyTransactionNo := ReverseServiceTaxHelper.GetLastTransactionNo;

      // Exercise
      ReverseServiceTaxHelper.UnapplyVendorLedgerEntry(PaymentGenJournalLine."Document No.");

      // Verify
      VerifyUnapply(PaymentGenJournalLine,BaseAmount,TaxAmount,
        ApplyTransactionNo,LastTransactionNo,RevChargeType,PostedPurchaseDocNo,PoT);

      VerifyUnapplySBCKKC(PaymentGenJournalLine,SBCAmount,KKCAmount,RevChargeType,PoT);
Member of Lib.Library - Utility


GetMaxFieldOptionIndex@33 Method

The procedure GetMaxFieldOptionIndex is available in codeunit 131000.

Syntax

GetMaxFieldOptionIndex@33(
    TableNo@1000 : Integer TableNo, //Input parameter of type Integer
    FieldNo@1001 : Integer FieldNo //Input parameter of type Integer
);

Parameters

TableNo
Input parameter of type Integer
FieldNo
Input parameter of type Integer

Return Value

Integer

Remarks

The relevant search keywords are: Get, Max, Field, Option, Index.

For a clarification about how this function works, refer to the code listed below.

      RecRef.OPEN(TableNo);
      FieldRef := RecRef.FIELD(FieldNo);

      Field.GET(TableNo,FieldNo);
      IF Field.Type <> Field.Type::Option THEN
        ERROR(STRSUBSTNO(FieldOptionTypeErr,FieldRef.NAME,RecRef.NAME));
      EXIT(GetMaxOptionIndex(FieldRef.OPTIONCAPTION));

Example

There are no examples available.
Member of Lib.Library - Utility


GetMaxOptionIndex@32 Method

The procedure GetMaxOptionIndex is available in codeunit 131000.

Syntax

GetMaxOptionIndex@32(
    OptionString@1000 : Text OptionString //Input parameter of type Text
);

Parameters

OptionString
Input parameter of type Text

Return Value

Integer

Remarks

The relevant search keywords are: Get, Max, Option, Index.

For a clarification about how this function works, refer to the code listed below.

      EXIT(STRLEN(DELCHR(OptionString,'=',DELCHR(OptionString,'=',','))));

Example

There are no examples available.
Member of Lib.Library - Utility


GetNewLineNo@10 Method

The procedure GetNewLineNo is available in codeunit 131000.

Syntax

GetNewLineNo@10(
    RecRef@1001 : RecordRef RecRef, //Input parameter of type RecordRef
    FieldNo@1009 : Integer FieldNo //Input parameter of type Integer
);

Parameters

RecRef
Input parameter of type RecordRef
FieldNo
Input parameter of type Integer

Return Value

Integer

Remarks

The relevant search keywords are: Get, New, Line, No.

For a clarification about how this function works, refer to the code listed below.

      // Find the value of Line No. for a new line in the Record passed as Record Ref.
      // 1. It is assumed that the field passed is part of the primary key.
      // 2. It is assumed that all the primary key fields except Line No. field are already validated on the record.
      RecRef2.OPEN(RecRef.NUMBER,FALSE,COMPANYNAME);
      KeyRef := RecRef.KEYINDEX(1);  // The Primary Key always has index as 1.
      FOR FieldCount := 1 TO KeyRef.FIELDCOUNT DO BEGIN
        FieldRef := KeyRef.FIELDINDEX(FieldCount);
        IF FieldRef.NUMBER <> FieldNo THEN BEGIN
          FieldRef2 := RecRef2.FIELD(FieldRef.NUMBER);
          FieldRef2.SETRANGE(FieldRef.VALUE);  // Set filter on fields other than Line No with value as filled in on RecRef.
        END ELSE
          LineNumberFound := TRUE;
      END;

      IF NOT LineNumberFound THEN BEGIN
        FieldRef := RecRef2.FIELD(FieldNo);
        ERROR(STRSUBSTNO(KeyNotFoundError,FieldRef.NAME,RecRef2.NAME));
      END;

      IF RecRef2.FINDLAST THEN BEGIN
        FieldRef := RecRef2.FIELD(FieldNo);
        FieldCount := FieldRef.VALUE;
      END ELSE
        FieldCount := 0;
      EXIT(FieldCount + 10000);  // Add 10000 to the last Line No.

Example

The below example is extracted from the test automation codeunit 134001 to show one way of using this function.

      WITH VendLedgEntry DO BEGIN
        INIT;
        RecRef.GETTABLE(VendLedgEntry);
        "Entry No." := LibraryUtility.GetNewLineNo(RecRef,FIELDNO("Entry No."));
        "Posting Date" := WORKDATE;
        "Pmt. Discount Date" := WORKDATE;
        Open := TRUE;
        "Document No." :=
          LibraryUtility.GenerateRandomCode(FIELDNO("Document No."),DATABASE::"Vendor Ledger Entry");
        INSERT;
        VALIDATE("Remaining Amount",LibraryRandom.RandDec(100,2));
        MODIFY(TRUE);
      END;
Member of Lib.Library - Utility


GetNewRecNo@35 Method

The procedure GetNewRecNo is available in codeunit 131000.

Syntax

GetNewRecNo@35(
    RecVariant@1000 : Variant RecVariant, //Input parameter of type Variant
    FieldNo@1001 : Integer FieldNo //Input parameter of type Integer
);

Parameters

RecVariant
Input parameter of type Variant
FieldNo
Input parameter of type Integer

Return Value

Integer

Remarks

The relevant search keywords are: Get, New, Rec, No.

For a clarification about how this function works, refer to the code listed below.

      RecRef.GETTABLE(RecVariant);
      EXIT(GetNewLineNo(RecRef,FieldNo));

Example

The below example is extracted from the test automation codeunit 134092 to show one way of using this function.

      DimensionSetEntry.INIT;
      LibraryUtility.GetNewRecNo(DimensionSetEntry,DimensionSetEntry.FIELDNO("Dimension Set ID"));
      DimensionSetEntry."Dimension Code" := DimCode;
      DimensionSetEntry."Dimension Value Code" := DimValue;
      DimensionSetEntry.INSERT;
      EXIT(DimensionSetEntry."Dimension Set ID");
Member of Lib.Library - Utility


GetNextNoFromNoSeries@38 Method

The procedure GetNextNoFromNoSeries is available in codeunit 131000.

Syntax

GetNextNoFromNoSeries@38(
    NoSeriesCode@1001 : Code[10] NoSeriesCode, //Input parameter of type Code
    PostingDate@1002 : Date PostingDate //Input parameter of type Date
);

Parameters

NoSeriesCode
Input parameter of type Code
PostingDate
Input parameter of type Date

Return Value

Code[20]

Remarks

The relevant search keywords are: Get, Next, No, From, No, Series.

For a clarification about how this function works, refer to the code listed below.

      EXIT(NoSeriesManagement.GetNextNo(NoSeriesCode,PostingDate,FALSE));

Example

There are no examples available.
Member of Lib.Library - Utility


GetNextNoSeriesPurchaseDate@13 Method

The procedure GetNextNoSeriesPurchaseDate is available in codeunit 131000.

Syntax

GetNextNoSeriesPurchaseDate@13(
    NoSeriesCode@1000 : Code[10] NoSeriesCode //Input parameter of type Code
);

Parameters

NoSeriesCode
Input parameter of type Code

Return Value

Date

Remarks

The relevant search keywords are: Get, Next, No, Series, Purchase, Date.

For a clarification about how this function works, refer to the code listed below.

      NoSeries.GET(NoSeriesCode);
      NoSeries.TESTFIELD("Date Order",FALSE); // Use of Date Order is only tested on IT
      EXIT(WORKDATE);

Example

There are no examples available.
Member of Lib.Library - Utility


GetNextNoSeriesSalesDate@15 Method

The procedure GetNextNoSeriesSalesDate is available in codeunit 131000.

Syntax

GetNextNoSeriesSalesDate@15(
    NoSeriesCode@1000 : Code[10] NoSeriesCode //Input parameter of type Code
);

Parameters

NoSeriesCode
Input parameter of type Code

Return Value

Date

Remarks

The relevant search keywords are: Get, Next, No, Series, Sales, Date.

For a clarification about how this function works, refer to the code listed below.

      NoSeries.GET(NoSeriesCode);
      NoSeries.TESTFIELD("Date Order",FALSE); // Use of Date Order is only tested on IT
      EXIT(WORKDATE);

Example

There are no examples available.
Member of Lib.Library - Utility


GetPropertyValueForControl@21 Method

The procedure GetPropertyValueForControl is available in codeunit 131000.

Syntax

GetPropertyValueForControl@21(
    ObjectNo@1001 : Integer ObjectNo, //Input parameter of type Integer
    FieldNo@1000 : Integer FieldNo, //Input parameter of type Integer
    PropertyName@1005 : Text[30] PropertyName, //Input parameter of type Text
    SuppressError@1003 : Boolean SuppressError //Input parameter of type Boolean
);

Parameters

ObjectNo
Input parameter of type Integer
FieldNo
Input parameter of type Integer
PropertyName
Input parameter of type Text
SuppressError
Input parameter of type Boolean

Return Value

Text[30]

Remarks

The relevant search keywords are: Get, Property, Value, For, Control.

For a clarification about how this function works, refer to the code listed below.

      EXIT(GetPropertyValue(ObjectMetadata."Object Type"::Page,ObjectNo,FieldNo,PropertyName,SuppressError));

Example

There are no examples available.
Member of Lib.Library - Utility


GetPropertyValueForField@16 Method

The procedure GetPropertyValueForField is available in codeunit 131000.

Syntax

GetPropertyValueForField@16(
    ObjectNo@1001 : Integer ObjectNo, //Input parameter of type Integer
    FieldNo@1000 : Integer FieldNo, //Input parameter of type Integer
    PropertyName@1002 : Text[30] PropertyName, //Input parameter of type Text
    SuppressError@1007 : Boolean SuppressError //Input parameter of type Boolean
);

Parameters

ObjectNo
Input parameter of type Integer
FieldNo
Input parameter of type Integer
PropertyName
Input parameter of type Text
SuppressError
Input parameter of type Boolean

Return Value

Text[30]

Remarks

The relevant search keywords are: Get, Property, Value, For, Field.

For a clarification about how this function works, refer to the code listed below.

      EXIT(GetPropertyValue(ObjectMetadata."Object Type"::Table,ObjectNo,FieldNo,PropertyName,SuppressError));

Example

There are no examples available.
Member of Lib.Library - Utility


LineBreak@53 Method

The procedure LineBreak is available in codeunit 131000.

Syntax

LineBreak@53(
      //param element not supplied
);

Return Value

Text

Remarks

The relevant search keywords are: Line, Break.

For a clarification about how this function works, refer to the code listed below.

      NewLine := 10;
      EXIT(FORMAT(NewLine));

Example

There are no examples available.
Member of Lib.Library - Utility


UpdateSetupNoSeriesCode@31 Method

The procedure UpdateSetupNoSeriesCode is available in codeunit 131000.

Syntax

UpdateSetupNoSeriesCode@31(
    TableID@1000 : Integer TableID, //Input parameter of type Integer
    FieldID@1001 : Integer FieldID //Input parameter of type Integer
);

Parameters

TableID
Input parameter of type Integer
FieldID
Input parameter of type Integer

Remarks

The relevant search keywords are: Update, Setup, No, Series, Code.

For a clarification about how this function works, refer to the code listed below.

      RecRef.OPEN(TableID);
      RecRef.FIND;
      FieldRef := RecRef.FIELD(FieldID);
      NoSeriesCode := GetGlobalNoSeriesCode;
      IF FORMAT(FieldRef.VALUE) <> NoSeriesCode THEN BEGIN
        FieldRef.VALUE(NoSeriesCode);
        RecRef.MODIFY;
      END;

Example

There are no examples available.
Member of Lib.Library - Utility


Library - Variable Storage Class

Lib.Library - Variable Storage

COD131004 applies to ERM,SCM,RES,W1,All.

Methods

Name | Description
AssertEmpty@12 | The procedure AssertEmpty is available in codeunit 131004.
AssertFull@4 | The procedure AssertFull is available in codeunit 131004.
AssertNotOverflow@16 | The procedure AssertNotOverflow is available in codeunit 131004.
AssertNotUnderflow@17 | The procedure AssertNotUnderflow is available in codeunit 131004.
AssertPeekAvailable@23 | The procedure AssertPeekAvailable is available in codeunit 131004.
Clear@8 | The procedure Clear is available in codeunit 131004.
Dequeue@3 | The procedure Dequeue is available in codeunit 131004.
DequeueBoolean@7 | The procedure DequeueBoolean is available in codeunit 131004.
DequeueDate@68 | The procedure DequeueDate is available in codeunit 131004.
DequeueDecimal@72 | The procedure DequeueDecimal is available in codeunit 131004.
DequeueInteger@6 | The procedure DequeueInteger is available in codeunit 131004.
DequeueText@21 | The procedure DequeueText is available in codeunit 131004.
DequeueTime@70 | The procedure DequeueTime is available in codeunit 131004.
Enqueue@2 | The procedure Enqueue is available in codeunit 131004.
Length@1 | The procedure Length is available in codeunit 131004.
MaxLength@5 | The procedure MaxLength is available in codeunit 131004.
Peek@18 | The procedure Peek is available in codeunit 131004.
PeekBoolean@9 | The procedure PeekBoolean is available in codeunit 131004.
PeekDate@11 | The procedure PeekDate is available in codeunit 131004.
PeekDecimal@14 | The procedure PeekDecimal is available in codeunit 131004.
PeekInteger@13 | The procedure PeekInteger is available in codeunit 131004.
PeekText@15 | The procedure PeekText is available in codeunit 131004.
PeekTime@10 | The procedure PeekTime is available in codeunit 131004.

See Also

Lib


AssertEmpty@12 Method

The procedure AssertEmpty is available in codeunit 131004.

Syntax

AssertEmpty@12(
      //param element not supplied
);

Remarks

The relevant search keywords are: Assert, Empty.

For a clarification about how this function works, refer to the code listed below.

      Assert.AreEqual(0,TotalCount,AssertEmptyError);

Example

The below example is extracted from the test automation codeunit 134000 to show one way of using this function.

      // [FEATURE] [Application] [Cash Receipt]
      // [SCENARIO 230936] When deleting the value in "Applies-to-ID" field on the PAG 232 manually, "Amount to Apply" must be reset to zero

      // [GIVEN] Posted Sales Invoice
      Initialize;

      PostInvoice(GenJournalLine);
      ExpectedAmount := GenJournalLine.Amount;

      // [GIVEN] Create Cash Receipt Journal Line
      CreateCashReceiptJnlLine(GenJournalLine,GenJournalLine."Account No.");
      LibraryVariableStorage.Enqueue(GenJournalLine."Journal Template Name");
      COMMIT;

      CashReceiptJournal.OPENEDIT;
      CashReceiptJournal."Applies-to Doc. Type".SETVALUE(GenJournalLine."Applies-to Doc. Type"::Invoice);

      // [GIVEN] Open "Apply Customer Entries" page
      LibraryVariableStorage.Enqueue(ExpectedAmount);
      CashReceiptJournal."Codeunit Gen. Jnl.-Apply".INVOKE;

      // [GIVEN] Use "Set Applies-to ID"
      // Done in ApplyCustomerEntriesWithSetAppliesToIDModalPageHandler

      // [WHEN] Manually remove "Applies-to ID"
      // Done in ApplyCustomerEntriesWithSetAppliesToIDModalPageHandler

      // [THEN] "Amount to apply" on "Apply Customer Entries" page is 0
      // Done in ApplyCustomerEntriesWithSetAppliesToIDModalPageHandler

      LibraryVariableStorage.AssertEmpty;
Member of Lib.Library - Variable Storage


AssertFull@4 Method

The procedure AssertFull is available in codeunit 131004.

Syntax

AssertFull@4(
      //param element not supplied
);

Remarks

The relevant search keywords are: Assert, Full.

For a clarification about how this function works, refer to the code listed below.

      Assert.AreEqual(MaxLength,TotalCount,AssertFullError);

Example

There are no examples available.
Member of Lib.Library - Variable Storage


AssertNotOverflow@16 Method

The procedure AssertNotOverflow is available in codeunit 131004.

Syntax

AssertNotOverflow@16(
      //param element not supplied
);

Remarks

The relevant search keywords are: Assert, Not, Overflow.

For a clarification about how this function works, refer to the code listed below.

      Assert.IsFalse(TotalCount + 1 > MaxLength,OverflowError);

Example

There are no examples available.
Member of Lib.Library - Variable Storage


AssertNotUnderflow@17 Method

The procedure AssertNotUnderflow is available in codeunit 131004.

Syntax

AssertNotUnderflow@17(
      //param element not supplied
);

Remarks

The relevant search keywords are: Assert, Not, Underflow.

For a clarification about how this function works, refer to the code listed below.

      Assert.IsTrue(TotalCount > 0,UnderflowError);

Example

There are no examples available.
Member of Lib.Library - Variable Storage


AssertPeekAvailable@23 Method

The procedure AssertPeekAvailable is available in codeunit 131004.

Syntax

AssertPeekAvailable@23(
    Index@1000 : Integer Index //Input parameter of type Integer
);

Parameters

Index
Input parameter of type Integer

Remarks

The relevant search keywords are: Assert, Peek, Available.

For a clarification about how this function works, refer to the code listed below.

      Assert.IsTrue(Index > 0,OutOfBoundsErr);
      Assert.IsTrue(Index <= TotalCount,OutOfBoundsErr);

Example

There are no examples available.
Member of Lib.Library - Variable Storage


Clear@8 Method

The procedure Clear is available in codeunit 131004.

Syntax

Clear@8(
      //param element not supplied
);

Remarks

The relevant search keywords are: Clear.

For a clarification about how this function works, refer to the code listed below.

      StartIndex := 0;
      EndIndex := 0;
      TotalCount := 0;

Example

The below example is extracted from the test automation codeunit 134000 to show one way of using this function.

      LibraryVariableStorage.Clear;
      LibrarySetupStorage.Restore;
      IF isInitialized THEN
        EXIT;
      LibraryERMCountryData.CreateVATData;
      LibraryERMCountryData.UpdateAccountInCustomerPostingGroup;
      LibraryERMCountryData.UpdateGeneralLedgerSetup;
      LibraryERMCountryData.UpdateGeneralPostingSetup;
      ModifyGenJnlBatchNoSeries;
      isInitialized := TRUE;
      COMMIT;

      LibrarySetupStorage.Save(DATABASE::"General Ledger Setup");
Member of Lib.Library - Variable Storage


Dequeue@3 Method

The procedure Dequeue is available in codeunit 131004.

Syntax

Dequeue@3(
    VAR Variable@1000 : Variant Variable //Reference parameter of type Variant
);

Parameters

Variable
Reference parameter of type Variant

Remarks

The relevant search keywords are: Dequeue.

For a clarification about how this function works, refer to the code listed below.

      StartIndex := (StartIndex MOD MaxLength) + 1;
      AssertNotUnderflow;
      Variable := Variables[StartIndex];
      TotalCount -= 1;

Example

The below example is extracted from the test automation codeunit 134006 to show one way of using this function.

      LibraryVariableStorage.Dequeue(SetAppliesToIDValue);
      SetAppliesToID := SetAppliesToIDValue;  // Assign Variant to Boolean.
      IF SetAppliesToID THEN
        ApplyCustomerEntries."Set Applies-to ID".INVOKE;
      ApplyCustomerEntries.OK.INVOKE;
Member of Lib.Library - Variable Storage


DequeueBoolean@7 Method

The procedure DequeueBoolean is available in codeunit 131004.

Syntax

DequeueBoolean@7(
      //param element not supplied
);

Return Value

Boolean

Remarks

The relevant search keywords are: Dequeue, Boolean.

For a clarification about how this function works, refer to the code listed below.

      Dequeue(ExpectedValue);
      EXIT(ExpectedValue);

Example

The below example is extracted from the test automation codeunit 134228 to show one way of using this function.

      CASE Question OF
        ConfirmCloseAccPeriodQst:
          Reply := TRUE;
        ConfirmDeleteGLAccountQst:
          Reply := LibraryVariableStorage.DequeueBoolean;
        ELSE
          ERROR(STRSUBSTNO(UnexpectedConfirmErr,Question));
      END;
Member of Lib.Library - Variable Storage


DequeueDate@68 Method

The procedure DequeueDate is available in codeunit 131004.

Syntax

DequeueDate@68(
      //param element not supplied
);

Return Value

Date

Remarks

The relevant search keywords are: Dequeue, Date.

For a clarification about how this function works, refer to the code listed below.

      Dequeue(ExpectedValue);
      EXIT(ExpectedValue);

Example

The below example is extracted from the test automation codeunit 137073 to show one way of using this function.

      // Calculate Regenerative Plan using page. Required where Forecast is used.
      StartingDate := LibraryVariableStorage.DequeueDate;
      LibraryVariableStorage.Dequeue(ItemNo);
      LibraryVariableStorage.Dequeue(ItemNo2);
      CalculatePlanPlanWksh.Item.SETFILTER("No.",STRSUBSTNO(ItemFilterTxt,ItemNo,ItemNo2));
      CalculatePlanPlanWksh.StartingDate.SETVALUE(StartingDate);
      CalculatePlanPlanWksh.EndingDate.SETVALUE(CALCDATE('<CM>',StartingDate));
      CalculatePlanPlanWksh.OK.INVOKE;
Member of Lib.Library - Variable Storage


DequeueDecimal@72 Method

The procedure DequeueDecimal is available in codeunit 131004.

Syntax

DequeueDecimal@72(
      //param element not supplied
);

Return Value

Decimal

Remarks

The relevant search keywords are: Dequeue, Decimal.

For a clarification about how this function works, refer to the code listed below.

      Dequeue(ExpectedValue);
      EXIT(ExpectedValue);

Example

The below example is extracted from the test automation codeunit 134331 to show one way of using this function.

      // Verifying VAT Entry fields.
      FindVATEntry(VATEntry,DocumentNo,VATEntry.Type::Purchase);
      VATAmount := LibraryVariableStorage.DequeueDecimal;
      Assert.AreNearlyEqual(
        VATAmount,VATEntry.Amount,LibraryERM.GetAmountRoundingPrecision,
        STRSUBSTNO(AmountErr,VATEntry.FIELDCAPTION(Amount),VATAmount,VATEntry.TABLECAPTION));
Member of Lib.Library - Variable Storage


DequeueInteger@6 Method

The procedure DequeueInteger is available in codeunit 131004.

Syntax

DequeueInteger@6(
      //param element not supplied
);

Return Value

Integer

Remarks

The relevant search keywords are: Dequeue, Integer.

For a clarification about how this function works, refer to the code listed below.

      Dequeue(ExpectedValue);
      EXIT(ExpectedValue);

Example

The below example is extracted from the test automation codeunit 134327 to show one way of using this function.

      Choice := LibraryVariableStorage.DequeueInteger;
Member of Lib.Library - Variable Storage


DequeueText@21 Method

The procedure DequeueText is available in codeunit 131004.

Syntax

DequeueText@21(
      //param element not supplied
);

Return Value

Text

Remarks

The relevant search keywords are: Dequeue, Text.

For a clarification about how this function works, refer to the code listed below.

      Dequeue(ExpectedValue);
      EXIT(FORMAT(ExpectedValue));

Example

The below example is extracted from the test automation codeunit 134386 to show one way of using this function.

      IF LibraryVariableStorage.Length = 1 THEN
        Flag := LibraryVariableStorage.DequeueBoolean
      ELSE BEGIN
        LibraryVariableStorage.DequeueText; // dummy dequeue
        Flag := LibraryVariableStorage.DequeueBoolean;
      END;

      IF Flag THEN
        // Enter Quantity To Create Page is Handled in 'EnterQuantityToCreatePageHandler'.
        ItemTrackingLines."Assign Serial No.".INVOKE
      ELSE
        ItemTrackingLines."Select Entries".INVOKE;  // Item Tracking Summary Page is handled in 'ItemTrackingSummaryPageHandler'.
      LibraryVariableStorage.Enqueue(ItemTrackingLines."Serial No.".VALUE);
      ItemTrackingLines.OK.INVOKE;
Member of Lib.Library - Variable Storage


DequeueTime@70 Method

The procedure DequeueTime is available in codeunit 131004.

Syntax

DequeueTime@70(
      //param element not supplied
);

Return Value

Time

Remarks

The relevant search keywords are: Dequeue, Time.

For a clarification about how this function works, refer to the code listed below.

      Dequeue(ExpectedValue);
      EXIT(ExpectedValue);

Example

The below example is extracted from the test automation codeunit 137076 to show one way of using this function.

      LibraryVariableStorage.Dequeue(QueuedVar);
      MachineCenterNo := QueuedVar;
      AbsenceDate := LibraryVariableStorage.DequeueDate;
      AbsenceStartingTime := LibraryVariableStorage.DequeueTime;
      AbsenceEndingTime := LibraryVariableStorage.DequeueTime;

      AbsencePage.GOTOKEY(1,MachineCenterNo,AbsenceDate,AbsenceStartingTime,AbsenceEndingTime);
      AbsencePage.Update.INVOKE;
Member of Lib.Library - Variable Storage


Enqueue@2 Method

The procedure Enqueue is available in codeunit 131004.

Syntax

Enqueue@2(
    Variable@1000 : Variant Variable //Input parameter of type Variant
);

Parameters

Variable
Input parameter of type Variant

Remarks

The relevant search keywords are: Enqueue.

For a clarification about how this function works, refer to the code listed below.

      EndIndex := (EndIndex MOD MaxLength) + 1;
      AssertNotOverflow;
      Variables[EndIndex] := Variable;
      TotalCount += 1;

Example

The below example is extracted from the test automation codeunit 134000 to show one way of using this function.

      // [FEATURE] [Application] [Cash Receipt]
      // [SCENARIO 363069] Verify that External Doc No transferred when setting 'Applies-to Doc. No.' value in Cash Receipt Journal.

      // [GIVEN] Invoice customer ('External Document No.' non-empty).
      Initialize;
      PostInvoice(GenJournalLine);
      ExpectedExtDocNo := GenJournalLine."External Document No.";
      PostedDocNo := GenJournalLine."Document No.";

      // [GIVEN] Create Cash Receipt Journal Line for the customer.
      CreateCashReceiptJnlLine(GenJournalLine,GenJournalLine."Account No.");
      LibraryVariableStorage.Enqueue(GenJournalLine."Journal Template Name");
      COMMIT;

      CashReceiptJournal.OPENEDIT;
      CashReceiptJournal."Applies-to Doc. Type".SETVALUE(GenJournalLine."Applies-to Doc. Type"::Invoice);

      // [WHEN] Set 'Applies-to Doc. No.' manually to Posted Invoice doc. no.
      CashReceiptJournal."Applies-to Doc. No.".SETVALUE(PostedDocNo);
      CashReceiptJournal.OK.INVOKE;

      // [THEN] External doc. no. transferred to 'Applied-to Ext. Doc. No.', but Amount is not.
      VerifyExtDocNoAmount(GenJournalLine,ExpectedExtDocNo,0);
Member of Lib.Library - Variable Storage


Length@1 Method

The procedure Length is available in codeunit 131004.

Syntax

Length@1(
      //param element not supplied
);

Return Value

Integer

Remarks

The relevant search keywords are: Length.

For a clarification about how this function works, refer to the code listed below.

      EXIT(TotalCount);

Example

The below example is extracted from the test automation codeunit 134802 to show one way of using this function.

      DataExchLineDef.SETRANGE("Data Exch. Def Code",DataExchDefCode);
      DataExchLineDef.SETRANGE("Line Type",DataExchLineDef."Line Type"::Detail);
      DataExchLineDef.FINDFIRST;
      DataExchLineDef.VALIDATE("Column Count",DataExchLineDef."Column Count" + 1);
      DataExchLineDef.MODIFY(TRUE);

      DataExchColumnDef.InsertRec(
        DataExchLineDef."Data Exch. Def Code",DataExchLineDef.Code,DataExchLineDef."Column Count",'Record Type Code',
        TRUE,DataExchColumnDef."Data Type"::Text,'','','');
      DataExchColumnDef.VALIDATE(Length,1);
      DataExchColumnDef.MODIFY(TRUE);

      DataExchMapping.SETRANGE("Data Exch. Def Code",DataExchLineDef."Data Exch. Def Code");
      DataExchMapping.SETRANGE("Data Exch. Line Def Code",DataExchLineDef.Code);
      DataExchMapping.FINDFIRST;
      DataExchFieldMapping.InsertRec(
        DataExchLineDef."Data Exch. Def Code",DataExchLineDef.Code,DataExchMapping."Table ID",
        DataExchColumnDef."Column No.",4,FALSE,0);

      TransformationRule.INIT;
      TransformationRule.VALIDATE(Code,LibraryUtility.GenerateGUID);
      TransformationRule.VALIDATE("Transformation Type",TransformationRule."Transformation Type"::Replace);
      TransformationRule.VALIDATE("Find Value",'O');
      TransformationRule.VALIDATE("Replace Value",ReplaceValue);
      TransformationRule.INSERT;

      DataExchFieldMapping.VALIDATE("Transformation Rule",TransformationRule.Code);
      DataExchFieldMapping.MODIFY(TRUE);

      ReplacePosition := 0;
      DataExchColumnDef.SETRANGE("Data Exch. Def Code",DataExchLineDef."Data Exch. Def Code");
      DataExchColumnDef.SETRANGE("Data Exch. Line Def Code",DataExchLineDef.Code);
      DataExchColumnDef.FINDSET;
      REPEAT
        ReplacePosition += DataExchColumnDef.Length;
      UNTIL DataExchColumnDef.NEXT = 0;
Member of Lib.Library - Variable Storage


MaxLength@5 Method

The procedure MaxLength is available in codeunit 131004.

Syntax

MaxLength@5(
      //param element not supplied
);

Return Value

Integer

Remarks

The relevant search keywords are: Max, Length.

For a clarification about how this function works, refer to the code listed below.

      EXIT(ARRAYLEN(Variables));

Example

There are no examples available.
Member of Lib.Library - Variable Storage


Peek@18 Method

The procedure Peek is available in codeunit 131004.

Syntax

Peek@18(
    VAR Variable@1000 : Variant Variable, //Reference parameter of type Variant
    Index@1001 : Integer Index //Input parameter of type Integer
);

Parameters

Variable
Reference parameter of type Variant
Index
Input parameter of type Integer

Remarks

The relevant search keywords are: Peek.

For a clarification about how this function works, refer to the code listed below.

      AssertPeekAvailable(Index);
      Variable := Variables[((StartIndex + (Index - 1)) MOD MaxLength) + 1];

Example

The below example is extracted from the test automation codeunit 136102 to show one way of using this function.

      Initialize;
      // [SCENARIO] Create 2 contracts with different currencies:
      LibraryVariableStorage.Enqueue(2);
      FOR i := 1 TO 2 DO BEGIN
        PrepareServiceContractsForInvoiceGeneration(ServiceContractHeader,i,2);
        IF i = 1 THEN
          CustomerNo := ServiceContractHeader."Customer No."
        ELSE BEGIN
          ServiceContractHeader."Currency Code" := LibraryERM.CreateCurrencyWithRandomExchRates;
          ServiceContractHeader."Customer No." := CustomerNo;
          ServiceContractHeader."Bill-to Customer No." := CustomerNo;
        END;
        ServiceContractHeader.MODIFY(TRUE);
      END;
      COMMIT;
      CreateContractInvoices.SetOptions(WORKDATE,WORKDATE,0); // 0 => Create invoices
      CreateContractInvoices.SetHideDialog(TRUE);
      CLEAR(ServiceContractHeader);
      ServiceContractHeader.SETRANGE("Contract Type",ServiceContractHeader."Contract Type"::Contract);
      FOR i := 1 TO 2 DO
        LibraryVariableStorage.Peek(ContractNo[i],i + 1);
      ServiceContractHeader.SETFILTER("Contract No.",'%1|%2',ContractNo[1],ContractNo[2]);
      ASSERTERROR CreateContractInvoices.RUN;
      Assert.ExpectedError('has service contracts with different currency codes');
      Assert.ExpectedError('Limit the Create Contract Invoices batch job to certain currency codes');
      Assert.ExpectedError('or clear the Combine Invoices field on the involved service contracts');
Member of Lib.Library - Variable Storage


PeekBoolean@9 Method

The procedure PeekBoolean is available in codeunit 131004.

Syntax

PeekBoolean@9(
    Index@1001 : Integer Index //Input parameter of type Integer
);

Parameters

Index
Input parameter of type Integer

Return Value

Boolean

Remarks

The relevant search keywords are: Peek, Boolean.

For a clarification about how this function works, refer to the code listed below.

      Peek(ExpectedValue,Index);
      EXIT(ExpectedValue);

Example

There are no examples available.
Member of Lib.Library - Variable Storage


PeekDate@11 Method

The procedure PeekDate is available in codeunit 131004.

Syntax

PeekDate@11(
    Index@1001 : Integer Index //Input parameter of type Integer
);

Parameters

Index
Input parameter of type Integer

Return Value

Date

Remarks

The relevant search keywords are: Peek, Date.

For a clarification about how this function works, refer to the code listed below.

      Peek(ExpectedValue,Index);
      EXIT(ExpectedValue);

Example

There are no examples available.
Member of Lib.Library - Variable Storage


PeekDecimal@14 Method

The procedure PeekDecimal is available in codeunit 131004.

Syntax

PeekDecimal@14(
    Index@1001 : Integer Index //Input parameter of type Integer
);

Parameters

Index
Input parameter of type Integer

Return Value

Decimal

Remarks

The relevant search keywords are: Peek, Decimal.

For a clarification about how this function works, refer to the code listed below.

      Peek(ExpectedValue,Index);
      EXIT(ExpectedValue);

Example

The below example is extracted from the test automation codeunit 137069 to show one way of using this function.

      ProductionJournal.FILTER.SETFILTER("Entry Type",FORMAT(ItemJournalLine."Entry Type"::Consumption));
      Quantity := LibraryVariableStorage.PeekDecimal(3); // third index variable
      ProductionJournal.ItemTrackingLines.INVOKE;
      ProductionJournal.Quantity.SETVALUE(Quantity);
      LibraryVariableStorage.Enqueue(PostingQst); // Enqueued for ConfirmHandler
      LibraryVariableStorage.Enqueue(JournalPostedMsg); // Enqueued for MessageHandler
      ProductionJournal.Post.INVOKE;
Member of Lib.Library - Variable Storage


PeekInteger@13 Method

The procedure PeekInteger is available in codeunit 131004.

Syntax

PeekInteger@13(
    Index@1001 : Integer Index //Input parameter of type Integer
);

Parameters

Index
Input parameter of type Integer

Return Value

Integer

Remarks

The relevant search keywords are: Peek, Integer.

For a clarification about how this function works, refer to the code listed below.

      Peek(ExpectedValue,Index);
      EXIT(ExpectedValue);

Example

The below example is extracted from the test automation codeunit 137154 to show one way of using this function.

      UpdateNoSeriesOnItemJournalBatch(ItemJournalBatch,'');
      LibraryInventory.CreateItemJournalLine(
        ItemJournalLine,ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name,EntryType,ItemNo,Quantity);
      ItemJournalLine.VALIDATE("Location Code",LocationCode);
      ItemJournalLine.VALIDATE("Bin Code",BinCode);
      ItemJournalLine.MODIFY(TRUE);
      IF LibraryVariableStorage.Length > 0 THEN BEGIN
        AssignExpDate := (LibraryVariableStorage.PeekInteger(1) = ItemTrackingMode::"Assign Lot No. & Expiration Date");
        ItemJournalLine.OpenItemTrackingLines(FALSE);  // Use from Item Journal.
        IF AssignExpDate THEN BEGIN
          EVALUATE(LotNo,LibraryVariableStorage.PeekText(2));
          SetExpirationDateReservationEntry(ItemNo,LotNo);
        END;
      END;
      LibraryInventory.PostItemJournalLine(ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name);
Member of Lib.Library - Variable Storage


PeekText@15 Method

The procedure PeekText is available in codeunit 131004.

Syntax

PeekText@15(
    Index@1001 : Integer Index //Input parameter of type Integer
);

Parameters

Index
Input parameter of type Integer

Return Value

Text

Remarks

The relevant search keywords are: Peek, Text.

For a clarification about how this function works, refer to the code listed below.

      Peek(ExpectedValue,Index);
      EXIT(FORMAT(ExpectedValue));

Example

The below example is extracted from the test automation codeunit 134100 to show one way of using this function.

      PostedPurchaseInvoices.FILTER.SETFILTER("No.",LibraryVariableStorage.PeekText(1));
      PostedPurchaseInvoices."No.".ASSERTEQUALS('');
Member of Lib.Library - Variable Storage


PeekTime@10 Method

The procedure PeekTime is available in codeunit 131004.

Syntax

PeekTime@10(
    Index@1001 : Integer Index //Input parameter of type Integer
);

Parameters

Index
Input parameter of type Integer

Return Value

Time

Remarks

The relevant search keywords are: Peek, Time.

For a clarification about how this function works, refer to the code listed below.

      Peek(ExpectedValue,Index);
      EXIT(ExpectedValue);

Example

There are no examples available.
Member of Lib.Library - Variable Storage


Library - Warehouse Class

Lib.Library - Warehouse

COD132204 applies to SCM,COSTING,W1,All.
Unsupported version tags:
Contains all utility functions related to Warehouse Management.

Methods

Name | Description
AutoFillQtyInventoryActivity@88 | The procedure AutoFillQtyInventoryActivity is available in codeunit 132204.
AutofillQtyToRecvWhseReceipt@78 | The procedure AutofillQtyToRecvWhseReceipt is available in codeunit 132204.
AutofillQtyToShipWhseShipment@51 | The procedure AutofillQtyToShipWhseShipment is available in codeunit 132204.
CalculateBinReplenishment@156 | The procedure CalculateBinReplenishment is available in codeunit 132204.
CalculateCountingPeriodOnWarehousePhysicalInventoryJournal@18 | The procedure CalculateCountingPeriodOnWarehousePhysicalInventoryJournal is available in codeunit 132204.
CalculateCrossDockLines@20 | The procedure CalculateCrossDockLines is available in codeunit 132204.
CalculateInventory@19 | The procedure CalculateInventory is available in codeunit 132204.
CalculatePlannedDate@22 | The procedure CalculatePlannedDate is available in codeunit 132204.
CalculateWhseAdjustment@107 | The procedure CalculateWhseAdjustment is available in codeunit 132204.
CalculateWhseAdjustmentItemJournal@36 | The procedure CalculateWhseAdjustmentItemJournal is available in codeunit 132204.
ChangeUnitOfMeasure@12 | The procedure ChangeUnitOfMeasure is available in codeunit 132204.
CreateAndUpdateTransferRoute@60 | The procedure CreateAndUpdateTransferRoute is available in codeunit 132204.
CreateBin@67 | The procedure CreateBin is available in codeunit 132204.
CreateBinContent@23 | The procedure CreateBinContent is available in codeunit 132204.
CreateBinCreationWorksheetLine@130 | The procedure CreateBinCreationWorksheetLine is available in codeunit 132204.
CreateBinTemplate@11 | The procedure CreateBinTemplate is available in codeunit 132204.
CreateBinType@98 | The procedure CreateBinType is available in codeunit 132204.
CreateFullWMSLocation@118 | The procedure CreateFullWMSLocation is available in codeunit 132204.
CreateInboundWhseReqFromProdO@139 | The procedure CreateInboundWhseReqFromProdO is available in codeunit 132204.
CreateInternalMovementHeader@75 | The procedure CreateInternalMovementHeader is available in codeunit 132204.
CreateInternalMovementLine@70 | The procedure CreateInternalMovementLine is available in codeunit 132204.
CreateInTransitLocation@30 | The procedure CreateInTransitLocation is available in codeunit 132204.
CreateInventoryMovementHeader@87 | The procedure CreateInventoryMovementHeader is available in codeunit 132204.
CreateInvtMvmtFromInternalMvmt@82 | The procedure CreateInvtMvmtFromInternalMvmt is available in codeunit 132204.
CreateInvtPutAwayPick@141 | The procedure CreateInvtPutAwayPick is available in codeunit 132204.
CreateInvtPutPickMovement@80 | The procedure CreateInvtPutPickMovement is available in codeunit 132204.
CreateInvtPutPickPurchaseOrder@34 | The procedure CreateInvtPutPickPurchaseOrder is available in codeunit 132204.
CreateInvtPutPickSalesOrder@29 | The procedure CreateInvtPutPickSalesOrder is available in codeunit 132204.
CreateLocation@17 | The procedure CreateLocation is available in codeunit 132204.
CreateLocationWithInventoryPostingSetup@33 | The procedure CreateLocationWithInventoryPostingSetup is available in codeunit 132204.
CreateLocationWMS@44 | The procedure CreateLocationWMS is available in codeunit 132204.
CreateMovementWorksheetLine@45 | The procedure CreateMovementWorksheetLine is available in codeunit 132204.
CreateNumberOfBins@114 | The procedure CreateNumberOfBins is available in codeunit 132204.
CreatePick@64 | The procedure CreatePick is available in codeunit 132204.
CreatePickFromPickWorksheet@9 | The procedure CreatePickFromPickWorksheet is available in codeunit 132204.
CreatePutAwayTemplateHeader@96 | The procedure CreatePutAwayTemplateHeader is available in codeunit 132204.
CreatePutAwayTemplateLine@101 | The procedure CreatePutAwayTemplateLine is available in codeunit 132204.
CreateTransferHeader@42 | The procedure CreateTransferHeader is available in codeunit 132204.
CreateTransferLine@41 | The procedure CreateTransferLine is available in codeunit 132204.
CreateTransferLocations@39 | The procedure CreateTransferLocations is available in codeunit 132204.
CreateTransferRoute@40 | The procedure CreateTransferRoute is available in codeunit 132204.
CreateWarehouseClass@10 | The procedure CreateWarehouseClass is available in codeunit 132204.
CreateWarehouseEmployee@58 | The procedure CreateWarehouseEmployee is available in codeunit 132204.
CreateWarehouseReceiptHeader@155 | The procedure CreateWarehouseReceiptHeader is available in codeunit 132204.
CreateWarehouseShipmentHeader@3 | The procedure CreateWarehouseShipmentHeader is available in codeunit 132204.
CreateWarehouseShipmentLine@38 | The procedure CreateWarehouseShipmentLine is available in codeunit 132204.
CreateWarehouseSourceFilter@5 | The procedure CreateWarehouseSourceFilter is available in codeunit 132204.
CreateWhseInternalPickHeader@66 | The procedure CreateWhseInternalPickHeader is available in codeunit 132204.
CreateWhseInternalPickLine@63 | The procedure CreateWhseInternalPickLine is available in codeunit 132204.
CreateWhseInternalPutawayHdr@62 | The procedure CreateWhseInternalPutawayHdr is available in codeunit 132204.
CreateWhseInternalPutawayLine@61 | The procedure CreateWhseInternalPutawayLine is available in codeunit 132204.
CreateWhseJournalBatch@104 | The procedure CreateWhseJournalBatch is available in codeunit 132204.
CreateWhseJournalLine@102 | The procedure CreateWhseJournalLine is available in codeunit 132204.
CreateWhseMovement@35 | The procedure CreateWhseMovement is available in codeunit 132204.
CreateWhsePick@81 | The procedure CreateWhsePick is available in codeunit 132204.
CreateWhsePickFromProduction@92 | The procedure CreateWhsePickFromProduction is available in codeunit 132204.
CreateWhseReceiptFromPO@109 | The procedure CreateWhseReceiptFromPO is available in codeunit 132204.
CreateWhseReceiptFromSalesReturnOrder@162 | The procedure CreateWhseReceiptFromSalesReturnOrder is available in codeunit 132204.
CreateWhseReceiptFromTO@2 | The procedure CreateWhseReceiptFromTO is available in codeunit 132204.
CreateWhseShipmentFromPurchaseReturnOrder@161 | The procedure CreateWhseShipmentFromPurchaseReturnOrder is available in codeunit 132204.
CreateWhseShipmentFromServiceOrder@47 | The procedure CreateWhseShipmentFromServiceOrder is available in codeunit 132204.
CreateWhseShipmentFromSO@79 | The procedure CreateWhseShipmentFromSO is available in codeunit 132204.
CreateWhseShipmentFromTO@99 | The procedure CreateWhseShipmentFromTO is available in codeunit 132204.
CreateWhseWorksheetLine@14 | The procedure CreateWhseWorksheetLine is available in codeunit 132204.
CreateWhseWorksheetName@146 | The procedure CreateWhseWorksheetName is available in codeunit 132204.
CreateZone@97 | The procedure CreateZone is available in codeunit 132204.
DeleteEmptyWhseRegisters@117 | The procedure DeleteEmptyWhseRegisters is available in codeunit 132204.
FindBin@119 | The procedure FindBin is available in codeunit 132204.
FindWhseActivityBySourceDoc@57 | The procedure FindWhseActivityBySourceDoc is available in codeunit 132204.
FindWhseActivityLineBySourceDoc@56 | The procedure FindWhseActivityLineBySourceDoc is available in codeunit 132204.
FindWhseReceiptNoBySourceDoc@46 | The procedure FindWhseReceiptNoBySourceDoc is available in codeunit 132204.
FindWhseShipmentNoBySourceDoc@32 | The procedure FindWhseShipmentNoBySourceDoc is available in codeunit 132204.
GetBinContentInternalMovement@76 | The procedure GetBinContentInternalMovement is available in codeunit 132204.
GetBinContentTransferOrder@16 | The procedure GetBinContentTransferOrder is available in codeunit 132204.
GetInboundSourceDocuments@154 | The procedure GetInboundSourceDocuments is available in codeunit 132204.
GetOutboundSourceDocuments@157 | The procedure GetOutboundSourceDocuments is available in codeunit 132204.
GetSourceDocInventoryMovement@89 | The procedure GetSourceDocInventoryMovement is available in codeunit 132204.
GetSourceDocInventoryPick@74 | The procedure GetSourceDocInventoryPick is available in codeunit 132204.
GetSourceDocInventoryPutAway@25 | The procedure GetSourceDocInventoryPutAway is available in codeunit 132204.
GetSourceDocumentsReceipt@7 | The procedure GetSourceDocumentsReceipt is available in codeunit 132204.
GetSourceDocumentsShipment@4 | The procedure GetSourceDocumentsShipment is available in codeunit 132204.
GetWhseDocsPickWorksheet@31 | The procedure GetWhseDocsPickWorksheet is available in codeunit 132204.
GetZoneForBin@147 | The procedure GetZoneForBin is available in codeunit 132204.
NoSeriesSetup@13 | The procedure NoSeriesSetup is available in codeunit 132204.
PostAndPrintInventoryActivity@124 | The procedure PostAndPrintInventoryActivity is available in codeunit 132204.
PostInventoryActivity@69 | The procedure PostInventoryActivity is available in codeunit 132204.
PostTransferOrder@43 | The procedure PostTransferOrder is available in codeunit 132204.
PostWhseAdjustment@48 | The procedure PostWhseAdjustment is available in codeunit 132204.
PostWhseJournalLine@28 | The procedure PostWhseJournalLine is available in codeunit 132204.
PostWhseRcptWithConfirmMsg@8 | The procedure PostWhseRcptWithConfirmMsg is available in codeunit 132204.
PostWhseReceipt@112 | The procedure PostWhseReceipt is available in codeunit 132204.
PostWhseShipment@1 | The procedure PostWhseShipment is available in codeunit 132204.
PostWhseShptWithShipInvoiceMsg@6 | The procedure PostWhseShptWithShipInvoiceMsg is available in codeunit 132204.
RegisterWhseActivity@65 | The procedure RegisterWhseActivity is available in codeunit 132204.
RegisterWhseJournalLine@108 | The procedure RegisterWhseJournalLine is available in codeunit 132204.
ReleaseTransferOrder@100 | The procedure ReleaseTransferOrder is available in codeunit 132204.
ReleaseWarehouseInternalPick@21 | The procedure ReleaseWarehouseInternalPick is available in codeunit 132204.
ReleaseWarehouseInternalPutAway@26 | The procedure ReleaseWarehouseInternalPutAway is available in codeunit 132204.
ReleaseWarehouseShipment@151 | The procedure ReleaseWarehouseShipment is available in codeunit 132204.
ReopenTransferOrder@37 | The procedure ReopenTransferOrder is available in codeunit 132204.
ReopenWhseShipment@83 | The procedure ReopenWhseShipment is available in codeunit 132204.
RunDateCompressWhseEntries@27 | The procedure RunDateCompressWhseEntries is available in codeunit 132204.
SelectBinType@68 | The procedure SelectBinType is available in codeunit 132204.
SelectWhseJournalBatchName@105 | The procedure SelectWhseJournalBatchName is available in codeunit 132204.
SelectWhseJournalTemplateName@106 | The procedure SelectWhseJournalTemplateName is available in codeunit 132204.
SelectWhseWorksheetName@143 | The procedure SelectWhseWorksheetName is available in codeunit 132204.
SelectWhseWorksheetTemplate@144 | The procedure SelectWhseWorksheetTemplate is available in codeunit 132204.
SetQtyHandleInventoryMovement@91 | The procedure SetQtyHandleInventoryMovement is available in codeunit 132204.
SetQtyToHandleInternalMovement@90 | The procedure SetQtyToHandleInternalMovement is available in codeunit 132204.
SetQtyToHandleWhseActivity@85 | The procedure SetQtyToHandleWhseActivity is available in codeunit 132204.
SetRequireReceiveOnWarehouseSetup@54 | The procedure SetRequireReceiveOnWarehouseSetup is available in codeunit 132204.
SetRequireShipmentOnWarehouseSetup@53 | The procedure SetRequireShipmentOnWarehouseSetup is available in codeunit 132204.
WhseCalculateInventory@153 | The procedure WhseCalculateInventory is available in codeunit 132204.
WhseGetBinContent@158 | The procedure WhseGetBinContent is available in codeunit 132204.
WhseGetBinContentFromItemJournalLine@15 | The procedure WhseGetBinContentFromItemJournalLine is available in codeunit 132204.
WhseSourceCreateDocument@159 | The procedure WhseSourceCreateDocument is available in codeunit 132204.

See Also

Lib


AutoFillQtyInventoryActivity@88 Method

The procedure AutoFillQtyInventoryActivity is available in codeunit 132204.

Syntax

AutoFillQtyInventoryActivity@88(
    WarehouseActivityHeader@1000 : Record 5766 WarehouseActivityHeader //Input parameter of type Record
);

Parameters

WarehouseActivityHeader
Input parameter of type Record

Remarks

The relevant search keywords are: Auto, Fill, Quantity, Inventory, Activity.

For a clarification about how this function works, refer to the code listed below.

      AutoFillQtyHandleWhseActivity(WarehouseActivityHeader);

Example

The below example is extracted from the test automation codeunit 137005 to show one way of using this function.

      // [FEATURE] [Warehouse] [Pick] [Production Order]
      // This is implementation for Scenario 1, bug 40394 from "Navision Corsica" database

      Initialize;

      // Step 1 - Create item hiercarchy: BOM with hierachy: PARENT and CHILD
      // Add a new UOM to child item = KG
      CreateItemHierarchy(ProdBOMHeader,ParentItem,ChildItem,RANDOM(10));
      LibraryInventory.CreateItemUnitOfMeasure(ItemUOM,ChildItem."No.",KGConst,3);

      // Step 2 - Create location with require pick and require put-away
      CreatePickPutAwayLocation(Location);

      // Step 3 - Add 1000 PCS of child item into inventory by posting item journal into created location
      LibraryInventory.FindItemJournalTemplate(ItemJournalTemplate);
      ItemJournalBatch.SETRANGE("Journal Template Name",ItemJournalTemplate.Name);
      ItemJournalBatch.FINDFIRST;
      LibraryInventory.CreateItemJournalLine(
        ItemJournalLine,ItemJournalTemplate.Name,ItemJournalBatch.Name,ItemJournalLine."Entry Type"::"Positive Adjmt.",
        ChildItem."No.",1000);
      ItemJournalLine.VALIDATE("Location Code",Location.Code);
      ItemJournalLine.MODIFY(TRUE);
      LibraryInventory.PostItemJournalLine(ItemJournalTemplate.Name,ItemJournalBatch.Name);

      // Step 4 - Create released production order for new item and refresh it
      CreateReleasedProdOrderAndRefresh(ProductionOrder,ParentItem,Location.Code,RANDOM(10));

      // Step 5 - change the UOM to KG on the component lines
      ChangeUOMOnComponentLines(ProductionOrder,KGConst);

      // Step 6 - create the inventory pick
      WarehouseRequest.SETFILTER("Source Document",'%1|%2',
        WarehouseRequest."Source Document"::"Prod. Consumption",
        WarehouseRequest."Source Document"::"Prod. Output");
      WarehouseRequest.SETRANGE("Source No.",ProductionOrder."No.");
      LibraryWarehouse.CreateInvtPutPickMovement(
        WarehouseRequest."Source Document"::"Prod. Consumption",ProductionOrder."No.",FALSE,TRUE,FALSE);

      // Step 7 - autofill qty to handle and post pick
      Assert.IsTrue(FindAndSelInvActvOnSrcNoAndLoc(WarehouseActivityHeader,
          WarehouseActivityHeader."Source Document"::"Prod. Consumption",ProductionOrder."No.",Location.Code),
        NoPutAwayCreatedForPrdOrdConst);

      LibraryWarehouse.AutoFillQtyInventoryActivity(WarehouseActivityHeader);
      LibraryWarehouse.PostInventoryActivity(WarehouseActivityHeader,TRUE);

      // Step 8 - verify that the pick has been posted - it has been deleted
      Assert.IsFalse(FindAndSelInvActvOnSrcNoAndLoc(WarehouseActivityHeader,
          WarehouseActivityHeader."Source Document"::"Prod. Consumption",ProductionOrder."No.",Location.Code),
        PutAwayNotDeletedConst);

      // Step 9 - Verify that pick has been posted - in history
      Assert.IsTrue(
        FindAndSelPstPickOnSrcNoAndLoc(PostedInvtPickHeader,
          PostedInvtPickHeader."Source Document"::"Prod. Consumption",ProductionOrder."No.",Location.Code),
        PickNotFoundInHistoryConst);
Member of Lib.Library - Warehouse


AutofillQtyToRecvWhseReceipt@78 Method

The procedure AutofillQtyToRecvWhseReceipt is available in codeunit 132204.

Syntax

AutofillQtyToRecvWhseReceipt@78(
    VAR WarehouseReceiptHeader@1000 : Record 7316 WarehouseReceiptHeader //Reference parameter of type Record
);

Parameters

WarehouseReceiptHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Autofill, Quantity, To, Recv, Warehouse, Receipt.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(WarehouseReceiptLine);
      WarehouseReceiptLine.SETRANGE("No.",WarehouseReceiptHeader."No.");
      WarehouseReceiptLine.FINDLAST;
      WarehouseReceiptLine2.COPY(WarehouseReceiptLine);
      WarehouseReceiptLine.AutofillQtyToReceive(WarehouseReceiptLine2);

Example

The below example is extracted from the test automation codeunit 137064 to show one way of using this function.

      // Create Random Quantity, Create Purchase Order, Create Warehouse Receipt form Purchase Order, Change Qty to Receive On Whse Receipt Line.
      Quantity := 10 + LibraryRandom.RandDec(10,2);
      Quantity2 := Quantity + LibraryRandom.RandDec(10,2);
      QtyToReceive := LibraryRandom.RandDec(5,2);

      LibraryInventory.CreateItem(Item);
      CreateAndReleasePurchaseOrder(
        PurchaseHeader,Item."No.",Item."No.",Location.Code,'',Quantity,Quantity2,Item."Base Unit of Measure");
      LibraryWarehouse.CreateWhseReceiptFromPO(PurchaseHeader);

      FindWarehouseReceiptHeader(WarehouseReceiptHeader,Location.Code);
      ChangeQtyToReceiveOnWhseReceiptLine(WarehouseReceiptLine,WarehouseReceiptHeader."No.",QtyToReceive);  // Change Qty to Receive on Whse Receipt line.
      LibraryWarehouse.PostWhseReceipt(WarehouseReceiptHeader);

      // Exercise.
      LibraryWarehouse.AutofillQtyToRecvWhseReceipt(WarehouseReceiptHeader);

      // Verify: Verify Warehouse Receipt Line for Quantities.
      VerifyWarehouseReceiptLine(WarehouseReceiptHeader."No.",Item."No.",Quantity,Quantity,Quantity,0);
      VerifyWarehouseReceiptLine(
        WarehouseReceiptHeader."No.",Item."No.",Quantity2,Quantity2 - QtyToReceive,Quantity2 - QtyToReceive,QtyToReceive)
Member of Lib.Library - Warehouse


AutofillQtyToShipWhseShipment@51 Method

The procedure AutofillQtyToShipWhseShipment is available in codeunit 132204.

Syntax

AutofillQtyToShipWhseShipment@51(
    VAR WarehouseShipmentHeader@1000 : Record 7320 WarehouseShipmentHeader //Reference parameter of type Record
);

Parameters

WarehouseShipmentHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Autofill, Quantity, To, Ship, Warehouse, Shipment.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(WarehouseShipmentLine);
      WarehouseShipmentLine.SETRANGE("No.",WarehouseShipmentHeader."No.");
      WarehouseShipmentLine.FINDLAST;
      WarehouseShipmentLine2.COPY(WarehouseShipmentLine);
      WarehouseShipmentLine.AutofillQtyToHandle(WarehouseShipmentLine2);

Example

The below example is extracted from the test automation codeunit 137064 to show one way of using this function.

      // Create Random Quantity, Create Sales Order, Create Warehouse Shipment form Sales Order, Create Pick and update Quantity to Handle on Warehouse Activity Line and Auto fill Quantity To Ship Warehouse Shipment.
      Quantity := 10 + LibraryRandom.RandDec(10,2);
      Quantity2 := Quantity + LibraryRandom.RandDec(10,2);
      QtyToHandle := LibraryRandom.RandDec(5,2);
      QtyToHandle2 := QtyToHandle + LibraryRandom.RandDec(5,2);

      CreateAndReleaseSalesOrder(SalesHeader,Item."No.",Item."No.",Location.Code,Quantity,Quantity2);
      LibraryWarehouse.CreateWhseShipmentFromSO(SalesHeader);
      FindWarehouseShipmentHeader(WarehouseShipmentHeader,Location.Code);
      LibraryWarehouse.CreatePick(WarehouseShipmentHeader);

      FindWarehouseActivityHeader(WarehouseActivityHeader,Location.Code,WarehouseActivityHeader.Type::Pick);
      UpdateQuantityToHandleOnWhseActivityLine(WarehouseActivityHeader,Quantity,QtyToHandle);
      UpdateQuantityToHandleOnWhseActivityLine(WarehouseActivityHeader,Quantity2,QtyToHandle2);
      LibraryWarehouse.RegisterWhseActivity(WarehouseActivityHeader);

      // Exercise: Auto fill Qty To Ship on Warehouse Shipment.
      LibraryWarehouse.AutofillQtyToShipWhseShipment(WarehouseShipmentHeader);

      // Verify: Verify Warehouse Shipment Line for Quantities.
      VerifyWarehouseShipmentLine(WarehouseShipmentHeader."No.",Item."No.",Quantity,Quantity,QtyToHandle,QtyToHandle,0);  // Value important for Test.
      VerifyWarehouseShipmentLine(WarehouseShipmentHeader."No.",Item."No.",Quantity2,Quantity2,QtyToHandle2,QtyToHandle2,0);  // Value important for Test.
Member of Lib.Library - Warehouse


CalculateBinReplenishment@156 Method

The procedure CalculateBinReplenishment is available in codeunit 132204.

Syntax

CalculateBinReplenishment@156(
    BinContent@1002 : Record 7302 BinContent, //Input parameter of type Record
    WhseWorksheetName@1001 : Record 7327 WhseWorksheetName, //Input parameter of type Record
    LocationCode@1003 : Code[10] LocationCode, //Input parameter of type Code
    AllowBreakBulk@1004 : Boolean AllowBreakBulk, //Input parameter of type Boolean
    HideDialog@1005 : Boolean HideDialog, //Input parameter of type Boolean
    DoNotFillQtyToHandle@1006 : Boolean DoNotFillQtyToHandle //Input parameter of type Boolean
);

Parameters

BinContent
Input parameter of type Record
WhseWorksheetName
Input parameter of type Record
LocationCode
Input parameter of type Code
AllowBreakBulk
Input parameter of type Boolean
HideDialog
Input parameter of type Boolean
DoNotFillQtyToHandle
Input parameter of type Boolean

Remarks

The relevant search keywords are: Calculate, Bin, Replenishment.

For a clarification about how this function works, refer to the code listed below.

      CalculateBinReplenishment.InitializeRequest(
        WhseWorksheetName."Worksheet Template Name",WhseWorksheetName.Name,LocationCode,AllowBreakBulk,HideDialog,
        DoNotFillQtyToHandle);
      CalculateBinReplenishment.SETTABLEVIEW(BinContent);
      CalculateBinReplenishment.USEREQUESTPAGE(FALSE);
      CalculateBinReplenishment.RUN;

Example

The below example is extracted from the test automation codeunit 137064 to show one way of using this function.

      LibraryWarehouse.SelectWhseWorksheetTemplate(WhseWorksheetTemplate,WhseWorksheetTemplate.Type::Movement);
      LibraryWarehouse.SelectWhseWorksheetName(WhseWorksheetName,WhseWorksheetTemplate.Name,LocationCode);
      LibraryWarehouse.CalculateBinReplenishment(DummyBinContent,WhseWorksheetName,LocationCode,TRUE,TRUE,FALSE);
Member of Lib.Library - Warehouse


CalculateCountingPeriodOnWarehousePhysicalInventoryJournal@18 Method

The procedure CalculateCountingPeriodOnWarehousePhysicalInventoryJournal is available in codeunit 132204.

Syntax

CalculateCountingPeriodOnWarehousePhysicalInventoryJournal@18(
    VAR WarehouseJournalLine@1001 : Record 7311 WarehouseJournalLine //Reference parameter of type Record
);

Parameters

WarehouseJournalLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Calculate, Counting, Period, On, Warehouse, Physical, Inventory, Journal.

For a clarification about how this function works, refer to the code listed below.

      COMMIT;  // Commit is required.
      CLEAR(PhysInvtCountManagement);
      PhysInvtCountManagement.InitFromWhseJnl(WarehouseJournalLine);
      PhysInvtCountManagement.RUN;

Example

The below example is extracted from the test automation codeunit 137153 to show one way of using this function.

      CreateWarehouseJournalBatch(WarehouseJournalBatch,WarehouseJournalTemplate.Type::"Physical Inventory",LocationCode);
      WarehouseJournalBatch.VALIDATE("No. Series",LibraryUtility.GetGlobalNoSeriesCode);
      WarehouseJournalBatch.MODIFY(TRUE);
      WarehouseJournalLine.INIT;
      WarehouseJournalLine.VALIDATE("Journal Template Name",WarehouseJournalBatch."Journal Template Name");
      WarehouseJournalLine.VALIDATE("Journal Batch Name",WarehouseJournalBatch.Name);
      WarehouseJournalLine.VALIDATE("Location Code",LocationCode);
      LibraryWarehouse.CalculateCountingPeriodOnWarehousePhysicalInventoryJournal(WarehouseJournalLine);
Member of Lib.Library - Warehouse


CalculateCrossDockLines@20 Method

The procedure CalculateCrossDockLines is available in codeunit 132204.

Syntax

CalculateCrossDockLines@20(
    VAR WhseCrossDockOpportunity@1001 : Record 5768 WhseCrossDockOpportunity, //Reference parameter of type Record
    NewTemplateName@1004 : Code[10] NewTemplateName, //Input parameter of type Code
    NewNameNo@1003 : Code[20] NewNameNo, //Input parameter of type Code
    NewLocationCode@1002 : Code[10] NewLocationCode //Input parameter of type Code
);

Parameters

WhseCrossDockOpportunity
Reference parameter of type Record
NewTemplateName
Input parameter of type Code
NewNameNo
Input parameter of type Code
NewLocationCode
Input parameter of type Code

Remarks

The relevant search keywords are: Calculate, Cross, Dock, Lines.

For a clarification about how this function works, refer to the code listed below.

      WhseCrossDockManagement.CalculateCrossDockLines(WhseCrossDockOpportunity,NewTemplateName,NewNameNo,NewLocationCode);

Example

The below example is extracted from the test automation codeunit 137048 to show one way of using this function.

      WhseCrossDockMgt.CalculateCrossDockLines(WhseCrossDockOpp,'',WarehouseReceiptNo,LocationCode);
Member of Lib.Library - Warehouse


CalculateInventory@19 Method

The procedure CalculateInventory is available in codeunit 132204.

Syntax

CalculateInventory@19(
    VAR ItemJournalLine@1002 : Record 83 ItemJournalLine, //Reference parameter of type Record
    VAR Item@1001 : Record 27 Item, //Reference parameter of type Record
    NewPostingDate@1004 : Date NewPostingDate, //Input parameter of type Date
    DocNo@1005 : Code[20] DocNo, //Input parameter of type Code
    ItemsNotOnInvt@1006 : Boolean ItemsNotOnInvt //Input parameter of type Boolean
);

Parameters

ItemJournalLine
Reference parameter of type Record
Item
Reference parameter of type Record
NewPostingDate
Input parameter of type Date
DocNo
Input parameter of type Code
ItemsNotOnInvt
Input parameter of type Boolean

Remarks

The relevant search keywords are: Calculate, Inventory.

For a clarification about how this function works, refer to the code listed below.

      COMMIT;  // Commit required before running this Report.
      CLEAR(CalculateInventory);
      IF Item.HASFILTER THEN
        TmpItem.COPYFILTERS(Item)
      ELSE BEGIN
        Item.GET(Item."No.");
        TmpItem.SETRANGE("No.",Item."No.");
      END;
      CalculateInventory.SETTABLEVIEW(TmpItem);
      CalculateInventory.InitializeRequest(NewPostingDate,DocNo,ItemsNotOnInvt);
      CalculateInventory.SetItemJnlLine(ItemJournalLine);
      CalculateInventory.USEREQUESTPAGE(FALSE);
      CalculateInventory.RUN;

Example

The below example is extracted from the test automation codeunit 134475 to show one way of using this function.

      // Find Item journal Batch and create Item Journal and Calculate Inventory.
      SelectAndClearItemJournalBatch(ItemJournalBatch,ItemJournalBatch."Template Type"::"Phys. Inventory");
      ItemJournalLine.INIT;
      ItemJournalLine.VALIDATE("Journal Template Name",ItemJournalBatch."Journal Template Name");
      ItemJournalLine.VALIDATE("Journal Batch Name",ItemJournalBatch.Name);
      LibraryInventory.CalculateInventory(ItemJournalLine,ItemNo,WORKDATE,TRUE);

      // Find created Item Journal Line.
      ItemJournalLine.SETRANGE("Journal Template Name",ItemJournalBatch."Journal Template Name");
      ItemJournalLine.SETRANGE("Journal Batch Name",ItemJournalBatch.Name);
      ItemJournalLine.FINDFIRST;

      // Update Item Journal Line and attach Dimension.
      ItemJournalLine.VALIDATE(
        "Document No.",NoSeriesManagement.GetNextNo(ItemJournalBatch."No. Series",ItemJournalLine."Posting Date",FALSE));
      ItemJournalLine.VALIDATE("Qty. (Phys. Inventory)",0);
      ItemJournalLine.VALIDATE("Unit Amount",LibraryRandom.RandDec(10,2));
      ItemJournalLine.VALIDATE(
        "Dimension Set ID",
        LibraryDimension.CreateDimSet(
          ItemJournalLine."Dimension Set ID",DefaultDimension."Dimension Code",DefaultDimension."Dimension Value Code"));
      ItemJournalLine.MODIFY(TRUE);
Member of Lib.Library - Warehouse


CalculatePlannedDate@22 Method

The procedure CalculatePlannedDate is available in codeunit 132204.

Syntax

CalculatePlannedDate@22(
    OrgDateExpression@1008 : Text[30] OrgDateExpression, //Input parameter of type Text
    OrgDate@1007 : Date OrgDate, //Input parameter of type Date
    FirstSourceType@1006 : Option FirstSourceType, //Input parameter of type Option
    FirstSourceCode@1005 : Code[20] FirstSourceCode, //Input parameter of type Code
    FirstAddCode@1004 : Code[20] FirstAddCode, //Input parameter of type Code
    SecondSourceType@1003 : Option SecondSourceType, //Input parameter of type Option
    SecondSourceCode@1002 : Code[20] SecondSourceCode, //Input parameter of type Code
    SecondAddCode@1001 : Code[20] SecondAddCode, //Input parameter of type Code
    CheckBothCalendars@1000 : Boolean CheckBothCalendars //Input parameter of type Boolean
);

Parameters

OrgDateExpression
Input parameter of type Text
OrgDate
Input parameter of type Date
FirstSourceType
Input parameter of type Option
FirstSourceCode
Input parameter of type Code
FirstAddCode
Input parameter of type Code
SecondSourceType
Input parameter of type Option
SecondSourceCode
Input parameter of type Code
SecondAddCode
Input parameter of type Code
CheckBothCalendars
Input parameter of type Boolean

Return Value

Date

Remarks

The relevant search keywords are: Calculate, Planned, Date.

For a clarification about how this function works, refer to the code listed below.

      PlannedDate :=
        CalendarManagement.CalcDateBOC(
          OrgDateExpression,OrgDate,FirstSourceType,FirstSourceCode,FirstAddCode,SecondSourceType,SecondSourceCode,SecondAddCode,
          CheckBothCalendars);

Example

The below example is extracted from the test automation codeunit 137154 to show one way of using this function.

      PlannedShipmentDate :=
        LibraryWarehouse.CalculatePlannedDate(
          FORMAT(OutboundWhseHandlingTime),WORKDATE,CustomizedCalendarChange."Source Type"::Location,SalesLine."Location Code",'',
          CustomizedCalendarChange."Source Type"::"Shipping Agent",ShippingAgentServices."Shipping Agent Code",
          ShippingAgentServices.Code,TRUE);

      PlannedDeliveryDate :=
        LibraryWarehouse.CalculatePlannedDate(
          FORMAT(ShippingAgentServices."Shipping Time"),PlannedShipmentDate,CustomizedCalendarChange."Source Type"::"Shipping Agent",
          ShippingAgentServices."Shipping Agent Code",
          ShippingAgentServices.Code,CustomizedCalendarChange."Source Type"::Customer,SalesLine."Sell-to Customer No.",'',TRUE);  // 0D required for test.

      SalesLine.TESTFIELD("Outbound Whse. Handling Time",OutboundWhseHandlingTime);
      SalesLine.TESTFIELD("Shipping Time",ShippingAgentServices."Shipping Time");
      SalesLine.TESTFIELD("Shipment Date",WORKDATE);
      SalesLine.TESTFIELD("Planned Shipment Date",PlannedShipmentDate);
      SalesLine.TESTFIELD("Planned Delivery Date",PlannedDeliveryDate);
Member of Lib.Library - Warehouse


CalculateWhseAdjustment@107 Method

The procedure CalculateWhseAdjustment is available in codeunit 132204.

Syntax

CalculateWhseAdjustment@107(
    VAR Item@1001 : Record 27 Item, //Reference parameter of type Record
    ItemJournalBatch@1005 : Record 233 ItemJournalBatch //Input parameter of type Record
);

Parameters

Item
Reference parameter of type Record
ItemJournalBatch
Input parameter of type Record

Remarks

The relevant search keywords are: Calculate, Warehouse, Adjustment.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(ItemJournalLine);
      ItemJournalLine.INIT;
      ItemJournalLine.VALIDATE("Journal Template Name",ItemJournalBatch."Journal Template Name");
      ItemJournalLine.VALIDATE("Journal Batch Name",ItemJournalBatch.Name);

      COMMIT;
      CalcWhseAdjmt.SetItemJnlLine(ItemJournalLine);
      IF (DocumentNo = '') AND (ItemJournalBatch."No. Series" <> '') THEN
        DocumentNo := NoSeriesMgt.GetNextNo(ItemJournalBatch."No. Series",WORKDATE,FALSE);
      CalcWhseAdjmt.InitializeRequest(WORKDATE,DocumentNo);
      IF Item.HASFILTER THEN
        TmpItem.COPYFILTERS(Item)
      ELSE BEGIN
        Item.GET(Item."No.");
        TmpItem.SETRANGE("No.",Item."No.");
      END;

      CalcWhseAdjmt.SETTABLEVIEW(TmpItem);
      CalcWhseAdjmt.USEREQUESTPAGE(FALSE);
      CalcWhseAdjmt.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 136140 to show one way of using this function.

      LibraryWarehouse.RegisterWhseJournalLine(
        WarehouseJournalBatch."Journal Template Name",WarehouseJournalBatch.Name,LocationCode,TRUE);
      ItemJournalSetup;
      LibraryWarehouse.CalculateWhseAdjustment(Item,ItemJournalBatch);
      LibraryInventory.PostItemJournalLine(ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name);
Member of Lib.Library - Warehouse


CalculateWhseAdjustmentItemJournal@36 Method

The procedure CalculateWhseAdjustmentItemJournal is available in codeunit 132204.

Syntax

CalculateWhseAdjustmentItemJournal@36(
    VAR Item@1004 : Record 27 Item, //Reference parameter of type Record
    NewPostingDate@1002 : Date NewPostingDate, //Input parameter of type Date
    DocumentNo@1003 : Text[20] DocumentNo //Input parameter of type Text
);

Parameters

Item
Reference parameter of type Record
NewPostingDate
Input parameter of type Date
DocumentNo
Input parameter of type Text

Remarks

The relevant search keywords are: Calculate, Warehouse, Adjustment, Item, Journal.

For a clarification about how this function works, refer to the code listed below.

      LibraryAssembly.SetupItemJournal(ItemJournalTemplate,ItemJournalBatch);
      ItemJournalLine.VALIDATE("Journal Template Name",ItemJournalBatch."Journal Template Name");
      ItemJournalLine.VALIDATE("Journal Batch Name",ItemJournalBatch.Name);

      COMMIT;
      CalculateWhseAdjustment.SetItemJnlLine(ItemJournalLine);
      IF DocumentNo = '' THEN
        DocumentNo := NoSeriesMgt.GetNextNo(ItemJournalBatch."No. Series",NewPostingDate,FALSE);
      CalculateWhseAdjustment.InitializeRequest(NewPostingDate,DocumentNo);
      IF Item.HASFILTER THEN
        TmpItem.COPYFILTERS(Item)
      ELSE BEGIN
        Item.GET(Item."No.");
        TmpItem.SETRANGE("No.",Item."No.");
      END;

      CalculateWhseAdjustment.SETTABLEVIEW(TmpItem);
      CalculateWhseAdjustment.USEREQUESTPAGE(FALSE);
      CalculateWhseAdjustment.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 137502 to show one way of using this function.

      FindItemJournal(ItemJournalTemplate,ItemJournalBatch);
      Location.GET(LocationCode);
      IF Location."Directed Put-away and Pick" THEN BEGIN
        FindWhseJournal(WhseJournalTemplate,WhseJournalBatch,LocationCode);
        LibraryWarehouse.CreateWhseJournalLine(
          WarehouseJournalLine,WhseJournalTemplate.Name,WhseJournalBatch.Name,
          LocationCode,'',BinCode,WarehouseJournalLine."Entry Type"::"Positive Adjmt.",Item."No.",Quantity);
        LibraryWarehouse.PostWhseJournalLine(WhseJournalTemplate.Name,WhseJournalBatch.Name,Location.Code);
        LibraryWarehouse.CalculateWhseAdjustmentItemJournal(Item,WORKDATE,'');
      END ELSE BEGIN
        LibraryInventory.CreateItemJournalLine(ItemJournalLine,ItemJournalTemplate.Name,ItemJournalBatch.Name,
          ItemJournalLine."Entry Type"::"Positive Adjmt.",Item."No.",Quantity);
        ItemJournalLine.VALIDATE("Location Code",LocationCode);
        ItemJournalLine.VALIDATE("Bin Code",BinCode);
        ItemJournalLine.MODIFY(TRUE);
      END;
      LibraryInventory.PostItemJournalLine(ItemJournalTemplate.Name,ItemJournalBatch.Name);
Member of Lib.Library - Warehouse


ChangeUnitOfMeasure@12 Method

The procedure ChangeUnitOfMeasure is available in codeunit 132204.

Syntax

ChangeUnitOfMeasure@12(
    VAR WarehouseActivityLine@1002 : Record 5767 WarehouseActivityLine //Reference parameter of type Record
);

Parameters

WarehouseActivityLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Change, Unit, Of, Measure.

For a clarification about how this function works, refer to the code listed below.

      COMMIT;
      CLEAR(WhseChangeUnitOfMeasure);
      WhseChangeUnitOfMeasure.DefWhseActLine(WarehouseActivityLine);
      WhseChangeUnitOfMeasure.RUNMODAL;
      IF WhseChangeUnitOfMeasure.ChangeUOMCode(WarehouseActivityLine2) THEN
        WarehouseActivityLine.ChangeUOMCode(WarehouseActivityLine,WarehouseActivityLine2);

Example

The below example is extracted from the test automation codeunit 137048 to show one way of using this function.

      // Setup : Create Location, Item, Purchase Order, Create and Post Warehouse Receipt.
      CreateItem(Item);
      CreateItemUnitOfMeasure(ItemUnitOfMeasure,Item."No.");
      NewUnitOfMeasure := ItemUnitOfMeasure.Code;   // Use Global Value for Handler Function.
      CreateAndReleasePurchaseOrder(PurchaseHeader,PurchaseLine,LocationWhite.Code,Item."No.");
      CreateAndPostWhseReceiptFromPO(PurchaseHeader);
      FindWhseActivityLine(
        WarehouseActivityLine,WarehouseActivityLine."Activity Type"::"Put-away",LocationWhite.Code,PurchaseHeader."No.",
        WarehouseActivityLine."Action Type"::Place);
      ExpectedQuantity := WarehouseActivityLine.Quantity / ItemUnitOfMeasure."Qty. per Unit of Measure";

      // Exercise for ChangeUOMAndCreatePutAway;
      LibraryWarehouse.ChangeUnitOfMeasure(WarehouseActivityLine);

      IF RegisterPutAway THEN BEGIN
        // Exercise: Register Put Away.
        RegisterWarehouseActivity(PurchaseHeader."No.",WarehouseActivityHeader.Type::"Put-away");

        // Verify : Verify That Register Put Document is same as Put Away Document after change Unit Of Measure.
        VerifyRegisteredWhseActivityLine(
          WarehouseActivityLine,ItemUnitOfMeasure.Code,ItemUnitOfMeasure."Qty. per Unit of Measure",ExpectedQuantity);
      END ELSE
        VerifyWhseActivityLine(WarehouseActivityLine,NewUnitOfMeasure,ItemUnitOfMeasure."Qty. per Unit of Measure",ExpectedQuantity);
Member of Lib.Library - Warehouse


CreateAndUpdateTransferRoute@60 Method

The procedure CreateAndUpdateTransferRoute is available in codeunit 132204.

Syntax

CreateAndUpdateTransferRoute@60(
    VAR TransferRoute@1005 : Record 5742 TransferRoute, //Reference parameter of type Record
    TransferFrom@1001 : Code[10] TransferFrom, //Input parameter of type Code
    TransferTo@1000 : Code[10] TransferTo, //Input parameter of type Code
    InTransitCode@1004 : Code[10] InTransitCode, //Input parameter of type Code
    ShippingAgentCode@1002 : Code[10] ShippingAgentCode, //Input parameter of type Code
    ShippingAgentServiceCode@1003 : Code[10] ShippingAgentServiceCode //Input parameter of type Code
);

Parameters

TransferRoute
Reference parameter of type Record
TransferFrom
Input parameter of type Code
TransferTo
Input parameter of type Code
InTransitCode
Input parameter of type Code
ShippingAgentCode
Input parameter of type Code
ShippingAgentServiceCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Update, Transfer, Route.

For a clarification about how this function works, refer to the code listed below.

      CreateTransferRoute(TransferRoute,TransferFrom,TransferTo);
      TransferRoute.VALIDATE("In-Transit Code",InTransitCode);
      TransferRoute.VALIDATE("Shipping Agent Code",ShippingAgentCode);
      TransferRoute.VALIDATE("Shipping Agent Service Code",ShippingAgentServiceCode);
      TransferRoute.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137157 to show one way of using this function.

      // Verify Planned Delivery Date when Item with SKUs by locations and inter-location transfer
      Initialize;
      LocationBlue.FIND;
      LocationRed.FIND;

      // Create Critical Item, SKU by Location: RED, BLUE
      CreateItemCritical(Item);
      LibraryInventory.CreateStockkeepingUnitForLocationAndVariant(SKUBlue,LocationBlue.Code,Item."No.",'');
      LibraryInventory.CreateStockkeepingUnitForLocationAndVariant(SKURed,LocationRed.Code,Item."No.",'');

      // Create Route Transfer from BLUE to RED
      LibraryWarehouse.CreateAndUpdateTransferRoute(TransferRoute,LocationBlue.Code,LocationRed.Code,LocationIntransit.Code,'','');
      UpdateInboundAndOutboundWarehouseHandlingTimeOnLocation(LocationBlue);
      UpdateSKUReplenishmentSystemWithTransfer(SKURed,LocationBlue.Code);

      // Create Sales Order on RED
      CreateSalesOrder(SalesHeader,SalesLine,WORKDATE,0D,Item."No.",LocationRed.Code,LibraryRandom.RandDec(100,2));
      RunOrderPromisingFromSalesLine(SalesLine,OrderPromising::CapableToPromise,FALSE);

      // Verify that Planned Delivery Date considering BLUE outbound time transfer
      VerifyOrderPromisingLine(GetEarliestDeliveryDate(Item,LocationBlue.Code,FALSE),WORKDATE,SalesLine.Quantity);
Member of Lib.Library - Warehouse


CreateBin@67 Method

The procedure CreateBin is available in codeunit 132204.

Syntax

CreateBin@67(
    VAR Bin@1000 : Record 7354 Bin, //Reference parameter of type Record
    LocationCode@1001 : Code[10] LocationCode, //Input parameter of type Code
    BinCode@1002 : Code[20] BinCode, //Input parameter of type Code
    ZoneCode@1003 : Code[10] ZoneCode, //Input parameter of type Code
    BinTypeCode@1004 : Code[10] BinTypeCode //Input parameter of type Code
);

Parameters

Bin
Reference parameter of type Record
LocationCode
Input parameter of type Code
BinCode
Input parameter of type Code
ZoneCode
Input parameter of type Code
BinTypeCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Bin.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(Bin);
      Bin.INIT;
      Bin.VALIDATE("Location Code",LocationCode);
      IF BinCode = '' THEN
        BinCode := LibraryUtility.GenerateRandomCode(Bin.FIELDNO(Code),DATABASE::Bin);
      Bin.VALIDATE(Code,BinCode);
      Bin.VALIDATE("Zone Code",ZoneCode);
      Bin.VALIDATE("Bin Type Code",BinTypeCode);
      Bin.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134327 to show one way of using this function.

      LibraryWarehouse.CreateBin(Bin,CreateLocationWithBinMandatory,LibraryUtility.GenerateGUID,'','');
      LibraryWarehouse.CreateBinContent(BinContent,Bin."Location Code",'',Bin.Code,Item."No.",'',Item."Base Unit of Measure");
      BinContent.VALIDATE(Default,TRUE);
      BinContent.MODIFY(TRUE);
Member of Lib.Library - Warehouse


CreateBinContent@23 Method

The procedure CreateBinContent is available in codeunit 132204.

Syntax

CreateBinContent@23(
    VAR BinContent@1004 : Record 7302 BinContent, //Reference parameter of type Record
    LocationCode@1000 : Code[10] LocationCode, //Input parameter of type Code
    ZoneCode@1006 : Code[10] ZoneCode, //Input parameter of type Code
    BinCode@1002 : Code[20] BinCode, //Input parameter of type Code
    ItemNo@1003 : Code[20] ItemNo, //Input parameter of type Code
    VariantCode@1001 : Code[10] VariantCode, //Input parameter of type Code
    UnitOfMeasureCode@1005 : Code[10] UnitOfMeasureCode //Input parameter of type Code
);

Parameters

BinContent
Reference parameter of type Record
LocationCode
Input parameter of type Code
ZoneCode
Input parameter of type Code
BinCode
Input parameter of type Code
ItemNo
Input parameter of type Code
VariantCode
Input parameter of type Code
UnitOfMeasureCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Bin, Content.

For a clarification about how this function works, refer to the code listed below.

      BinContent.INIT;
      BinContent.VALIDATE("Location Code",LocationCode);
      BinContent.VALIDATE("Bin Code",BinCode);
      BinContent.VALIDATE("Item No.",ItemNo);
      BinContent.VALIDATE("Variant Code",VariantCode);
      BinContent.VALIDATE("Unit of Measure Code",UnitOfMeasureCode);
      IF ZoneCode = '' THEN BEGIN
        Bin.GET(LocationCode,BinCode);
        ZoneCode := Bin."Zone Code";
      END;
      BinContent.VALIDATE("Zone Code",ZoneCode);
      BinContent.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134327 to show one way of using this function.

      LibraryWarehouse.CreateBin(Bin,CreateLocationWithBinMandatory,LibraryUtility.GenerateGUID,'','');
      LibraryWarehouse.CreateBinContent(BinContent,Bin."Location Code",'',Bin.Code,Item."No.",'',Item."Base Unit of Measure");
      BinContent.VALIDATE(Default,TRUE);
      BinContent.MODIFY(TRUE);
Member of Lib.Library - Warehouse


CreateBinCreationWorksheetLine@130 Method

The procedure CreateBinCreationWorksheetLine is available in codeunit 132204.

Syntax

CreateBinCreationWorksheetLine@130(
    VAR BinCreationWorksheetLine@1004 : Record 7338 BinCreationWorksheetLine, //Reference parameter of type Record
    WorksheetTemplateName@1000 : Code[10] WorksheetTemplateName, //Input parameter of type Code
    Name@1001 : Code[10] Name, //Input parameter of type Code
    LocationCode@1002 : Code[10] LocationCode, //Input parameter of type Code
    BinCode@1005 : Code[20] BinCode //Input parameter of type Code
);

Parameters

BinCreationWorksheetLine
Reference parameter of type Record
WorksheetTemplateName
Input parameter of type Code
Name
Input parameter of type Code
LocationCode
Input parameter of type Code
BinCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Bin, Creation, Worksheet, Line.

For a clarification about how this function works, refer to the code listed below.

      BinCreationWorksheetLine.INIT;
      BinCreationWorksheetLine.VALIDATE("Worksheet Template Name",WorksheetTemplateName);
      BinCreationWorksheetLine.VALIDATE(Name,Name);
      BinCreationWorksheetLine.VALIDATE("Location Code",LocationCode);
      BinCreationWorksheetLine.VALIDATE("Bin Code",BinCode);
      RecRef.GETTABLE(BinCreationWorksheetLine);
      BinCreationWorksheetLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,BinCreationWorksheetLine.FIELDNO("Line No.")));
      BinCreationWorksheetLine.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137303 to show one way of using this function.

      // Taking Random value for Maximum Cubage and Maximum Weight.
      BinCreationWkshTemplate.SETRANGE(Type,BinCreationWkshTemplate.Type::Bin);
      BinCreationWkshTemplate.FINDFIRST;
      BinCreationWkshName.FINDFIRST;
      Location.SETRANGE("Bin Mandatory",TRUE);
      Location.FINDFIRST;
      Bin.SETRANGE("Location Code",Location.Code);
      Bin.FINDFIRST;
      LibraryWarehouse.CreateBinCreationWorksheetLine(
        BinCreationWorksheetLine,BinCreationWkshTemplate.Name,BinCreationWkshName.Name,Location.Code,Bin.Code);
      BinCreationWorksheetLine.VALIDATE("Maximum Cubage",LibraryRandom.RandDec(100,2));
      BinCreationWorksheetLine.VALIDATE("Maximum Weight",LibraryRandom.RandDec(100,2));
      BinCreationWorksheetLine.MODIFY(TRUE);
Member of Lib.Library - Warehouse


CreateBinTemplate@11 Method

The procedure CreateBinTemplate is available in codeunit 132204.

Syntax

CreateBinTemplate@11(
    VAR BinTemplate@1002 : Record 7335 BinTemplate, //Reference parameter of type Record
    LocationCode@1000 : Code[10] LocationCode //Input parameter of type Code
);

Parameters

BinTemplate
Reference parameter of type Record
LocationCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Bin, Template.

For a clarification about how this function works, refer to the code listed below.

      BinTemplate.INIT;
      BinTemplate.VALIDATE(Code,LibraryUtility.GenerateRandomCode(BinTemplate.FIELDNO(Code),DATABASE::Location));
      BinTemplate.INSERT(TRUE);
      BinTemplate.VALIDATE("Location Code",LocationCode);
      BinTemplate.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137407 to show one way of using this function.

      CreateAndUpdateLocationWithSetup(Location,TRUE,FALSE,FALSE);
      LibraryWarehouse.CreateBinTemplate(BinTemplate,Location.Code);
      BinTemplateCode := BinTemplate.Code;  // BinTemplateCode used in CalculateBinRequestPageHandler.
Member of Lib.Library - Warehouse


CreateBinType@98 Method

The procedure CreateBinType is available in codeunit 132204.

Syntax

CreateBinType@98(
    VAR BinType@1000 : Record 7303 BinType, //Reference parameter of type Record
    Receive@1001 : Boolean Receive, //Input parameter of type Boolean
    Ship@1002 : Boolean Ship, //Input parameter of type Boolean
    PutAway@1003 : Boolean PutAway, //Input parameter of type Boolean
    Pick@1004 : Boolean Pick //Input parameter of type Boolean
);

Parameters

BinType
Reference parameter of type Record
Receive
Input parameter of type Boolean
Ship
Input parameter of type Boolean
PutAway
Input parameter of type Boolean
Pick
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, Bin, Type.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(BinType);
      BinType.INIT;

      BinType.VALIDATE(Code,LibraryUtility.GenerateRandomCode(BinType.FIELDNO(Code),DATABASE::"Bin Type"));
      BinType.VALIDATE(Description,BinType.Code);
      BinType.VALIDATE(Receive,Receive);
      BinType.VALIDATE(Ship,Ship);
      BinType.VALIDATE("Put Away",PutAway);
      BinType.VALIDATE(Pick,Pick);
      BinType.INSERT(TRUE);

Example

There are no examples available.
Member of Lib.Library - Warehouse


CreateFullWMSLocation@118 Method

The procedure CreateFullWMSLocation is available in codeunit 132204.

Syntax

CreateFullWMSLocation@118(
    VAR Location@1000 : Record 14 Location, //Reference parameter of type Record
    BinsPerZone@1004 : Integer BinsPerZone //Input parameter of type Integer
);

Parameters

Location
Reference parameter of type Record
BinsPerZone
Input parameter of type Integer

Remarks

The relevant search keywords are: Create, Full, WMS, Location.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(Location);
      Location.INIT;

      CreateLocationWithInventoryPostingSetup(Location);
      // Skip validate trigger for bin mandatory to improve performance.
      Location."Bin Mandatory" := TRUE;
      Location.VALIDATE("Directed Put-away and Pick",TRUE);
      Location.VALIDATE("Use Cross-Docking",TRUE);
      Location.MODIFY(TRUE);

      // Create Zones and bins
      // Fill in Bins fast tab
      // 1. Adjustment
      CreateZone(Zone,'ADJUSTMENT',Location.Code,SelectBinType(FALSE,FALSE,FALSE,FALSE),'','',0,FALSE);
      CreateNumberOfBins(Location.Code,Zone.Code,SelectBinType(FALSE,FALSE,FALSE,FALSE),BinsPerZone,FALSE);
      FindBin(Bin,Location.Code,Zone.Code,1);
      Location.VALIDATE("Adjustment Bin Code",Bin.Code);

      // 2. Bulk zone
      CreateZone(Zone,'BULK',Location.Code,SelectBinType(FALSE,FALSE,TRUE,FALSE),'','',50,FALSE);
      CreateNumberOfBins(Location.Code,Zone.Code,SelectBinType(FALSE,FALSE,TRUE,FALSE),BinsPerZone,FALSE);

      // 3. Cross-dock zone
      CreateZone(Zone,'CROSS-DOCK',Location.Code,SelectBinType(FALSE,FALSE,TRUE,TRUE),'','',0,TRUE);
      CreateNumberOfBins(Location.Code,Zone.Code,SelectBinType(FALSE,FALSE,TRUE,TRUE),BinsPerZone,TRUE);
      FindBin(Bin,Location.Code,Zone.Code,1);
      Location.VALIDATE("Cross-Dock Bin Code",Bin.Code);

      // 4. Pick zone
      CreateZone(Zone,'PICK',Location.Code,SelectBinType(FALSE,FALSE,TRUE,TRUE),'','',100,FALSE);
      CreateNumberOfBins(Location.Code,Zone.Code,SelectBinType(FALSE,FALSE,TRUE,TRUE),BinsPerZone,FALSE);

      // 5. Production zone
      CreateZone(Zone,'PRODUCTION',Location.Code,SelectBinType(FALSE,FALSE,FALSE,FALSE),'','',5,FALSE);
      CreateNumberOfBins(Location.Code,Zone.Code,SelectBinType(FALSE,FALSE,FALSE,FALSE),BinsPerZone,FALSE);
      FindBin(Bin,Location.Code,Zone.Code,1);
      Location.VALIDATE("Open Shop Floor Bin Code",Bin.Code);
      FindBin(Bin,Location.Code,Zone.Code,2);
      Location.VALIDATE("To-Production Bin Code",Bin.Code);
      FindBin(Bin,Location.Code,Zone.Code,3);
      Location.VALIDATE("From-Production Bin Code",Bin.Code);

      // 6. QC zone
      CreateZone(Zone,'QC',Location.Code,SelectBinType(FALSE,FALSE,FALSE,FALSE),'','',0,FALSE);
      CreateNumberOfBins(Location.Code,Zone.Code,SelectBinType(FALSE,FALSE,FALSE,FALSE),BinsPerZone,FALSE);
      FindBin(Bin,Location.Code,Zone.Code,1);
      Location.VALIDATE("To-Assembly Bin Code",Bin.Code);
      FindBin(Bin,Location.Code,Zone.Code,2);
      Location.VALIDATE("From-Assembly Bin Code",Bin.Code);

      // 7. Receive Zone
      CreateZone(Zone,'RECEIVE',Location.Code,SelectBinType(TRUE,FALSE,FALSE,FALSE),'','',10,FALSE);
      CreateNumberOfBins(Location.Code,Zone.Code,SelectBinType(TRUE,FALSE,FALSE,FALSE),BinsPerZone,FALSE);
      FindBin(Bin,Location.Code,Zone.Code,1);
      Location.VALIDATE("Receipt Bin Code",Bin.Code);

      // 8. Ship Zone
      CreateZone(Zone,'SHIP',Location.Code,SelectBinType(FALSE,TRUE,FALSE,FALSE),'','',200,FALSE);
      CreateNumberOfBins(Location.Code,Zone.Code,SelectBinType(FALSE,TRUE,FALSE,FALSE),BinsPerZone,FALSE);
      FindBin(Bin,Location.Code,Zone.Code,1);
      Location.VALIDATE("Shipment Bin Code",Bin.Code);

      // 9. Stage zone
      CreateZone(Zone,'STAGE',Location.Code,SelectBinType(FALSE,TRUE,FALSE,FALSE),'','',5,FALSE);
      CreateNumberOfBins(Location.Code,Zone.Code,SelectBinType(FALSE,TRUE,FALSE,FALSE),BinsPerZone,FALSE);

      // Bin policies fast tab
      // Created the STD put-away template - same as the one in the demo data
      CreatePutAwayTemplateHeader(PutAwayTemplateHeader);
      CreatePutAwayTemplateLine(PutAwayTemplateHeader,PutAwayTemplateLine,TRUE,FALSE,TRUE,TRUE,TRUE,FALSE);
      CreatePutAwayTemplateLine(PutAwayTemplateHeader,PutAwayTemplateLine,TRUE,FALSE,TRUE,TRUE,FALSE,FALSE);
      CreatePutAwayTemplateLine(PutAwayTemplateHeader,PutAwayTemplateLine,FALSE,TRUE,TRUE,TRUE,FALSE,FALSE);
      CreatePutAwayTemplateLine(PutAwayTemplateHeader,PutAwayTemplateLine,FALSE,TRUE,TRUE,FALSE,FALSE,FALSE);
      CreatePutAwayTemplateLine(PutAwayTemplateHeader,PutAwayTemplateLine,FALSE,TRUE,FALSE,FALSE,FALSE,TRUE);
      CreatePutAwayTemplateLine(PutAwayTemplateHeader,PutAwayTemplateLine,FALSE,TRUE,FALSE,FALSE,FALSE,FALSE);
      Location.VALIDATE("Put-away Template Code",PutAwayTemplateHeader.Code);

      Location.VALIDATE("Allow Breakbulk",TRUE);

      Location.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134328 to show one way of using this function.

      // SETUP:
      LibraryWarehouse.CreateFullWMSLocation(Location,3);
      PurchaseHeader.INIT;
      PurchaseHeader."Document Type" := PurchaseHeader."Document Type"::Invoice;
      PurchaseHeader.Status := PurchaseHeader.Status::Open;
      VendorNo := LibraryPurchase.CreateVendorNo;
      PurchaseHeader.VALIDATE("Buy-from Vendor No.",VendorNo);
      i := 0;
      REPEAT
        i += 1;
        PurchaseHeader."No." := 'TEST' + FORMAT(i);
      UNTIL PurchaseHeader.INSERT;
      PurchaseLine.INIT;
      PurchaseLine."Document Type" := PurchaseLine."Document Type"::Invoice;
      PurchaseLine."Document No." := PurchaseHeader."No.";
      PurchaseLine."Line No." := 10000;
      PurchaseLine.Type := PurchaseLine.Type::Item;
      LibraryInventory.CreateItem(Item);
      PurchaseLine."No." := Item."No.";
      PurchaseLine."Location Code" := Location.Code;
      PurchaseLine."Pay-to Vendor No." := VendorNo;
      PurchaseLine.INSERT;
      PurchaseInvoice.OPENEDIT;
      PurchaseInvoice.GOTORECORD(PurchaseHeader);
      // EXECUTE:
      PurchaseInvoice.PurchLines.Quantity.SETVALUE(100);
      // VERIFY: In the test method
Member of Lib.Library - Warehouse


CreateInboundWhseReqFromProdO@139 Method

The procedure CreateInboundWhseReqFromProdO is available in codeunit 132204.

Syntax

CreateInboundWhseReqFromProdO@139(
    ProductionOrder@1000 : Record 5405 ProductionOrder //Input parameter of type Record
);

Parameters

ProductionOrder
Input parameter of type Record

Remarks

The relevant search keywords are: Create, Inbound, Warehouse, Req, From, ProdO.

For a clarification about how this function works, refer to the code listed below.

      IF WhseOutputProdRelease.CheckWhseRqst(ProductionOrder) THEN
        MESSAGE(Text005)
      ELSE BEGIN
        CLEAR(WhseOutputProdRelease);
        IF WhseOutputProdRelease.Release(ProductionOrder) THEN
          MESSAGE(Text003)
        ELSE
          MESSAGE(Text004);
      END;

Example

The below example is extracted from the test automation codeunit 137005 to show one way of using this function.

      // [FEATURE] [Warehouse] [Put-Away] [Production Order] [UOM]
      // This is implementation for Scenario 2, bug 40394 from "Navision Corsica" database

      Initialize;

      // SCENARIO 2

      // Step 1 - Create item with base UOM=PCS and additional UOM=KG
      LibraryInventory.CreateItem(Item);
      LibraryInventory.CreateItemUnitOfMeasure(ItemUOM,Item."No.",KGConst,3);

      // Step 2 - Create location with require pick and require put-away
      CreatePickPutAwayLocation(Location);

      // Step 3 - Create released production order for new item and refresh it
      CreateReleasedProdOrderAndRefresh(ProductionOrder,Item,Location.Code,RANDOM(10));

      // Step 4 - change the UOM to KG on the production line
      ChangeUOMOnProdLine(ProductionOrder,KGConst);

      // Step 5 - Create the inbound whse req for the PO
      LibraryWarehouse.CreateInboundWhseReqFromProdO(ProductionOrder);

      // Step 6 - create the inventory put-away
      WarehouseRequest.SETFILTER("Source Document",'%1|%2',
        WarehouseRequest."Source Document"::"Prod. Consumption",
        WarehouseRequest."Source Document"::"Prod. Output");
      WarehouseRequest.SETRANGE("Source No.",ProductionOrder."No.");
      LibraryWarehouse.CreateInvtPutAwayPick(WarehouseRequest,TRUE,FALSE,FALSE);

      // Step 7 - autofill qty to handle and post put-away
      Assert.IsTrue(FindAndSelInvActvOnSrcNoAndLoc(WarehouseActivityHeader,
          WarehouseActivityHeader."Source Document"::"Prod. Output",ProductionOrder."No.",Location.Code),
        NoPickCreatedForProdOrdConst);

      LibraryWarehouse.AutoFillQtyInventoryActivity(WarehouseActivityHeader);
      LibraryWarehouse.PostInventoryActivity(WarehouseActivityHeader,TRUE);

      // Step 8 - verify that the put-away has been posted - it has been deleted
      Assert.IsFalse(FindAndSelInvActvOnSrcNoAndLoc(WarehouseActivityHeader,
          WarehouseActivityHeader."Source Document"::"Prod. Output",ProductionOrder."No.",Location.Code),
        PickNotDeletedConst);

      // Step 9 - Verify that put-away has been posted - in history
      Assert.IsTrue(
        FindAndSelPostPAwOnSrcNoAndLoc(PostedInvtPutAwayHeader,
          PostedInvtPutAwayHeader."Source Document"::"Prod. Output",ProductionOrder."No.",Location.Code),
        PutAwayNotFoundInHistConst);
Member of Lib.Library - Warehouse


CreateInternalMovementHeader@75 Method

The procedure CreateInternalMovementHeader is available in codeunit 132204.

Syntax

CreateInternalMovementHeader@75(
    VAR InternalMovementHeader@1000 : Record 7346 InternalMovementHeader, //Reference parameter of type Record
    LocationCode@1001 : Code[10] LocationCode, //Input parameter of type Code
    ToBinCode@1002 : Code[20] ToBinCode //Input parameter of type Code
);

Parameters

InternalMovementHeader
Reference parameter of type Record
LocationCode
Input parameter of type Code
ToBinCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Internal, Movement, Header.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(InternalMovementHeader);
      InternalMovementHeader.VALIDATE("Location Code",LocationCode);
      InternalMovementHeader.VALIDATE("To Bin Code",ToBinCode);
      InternalMovementHeader.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137030 to show one way of using this function.

      LibraryWarehouse.CreateInternalMovementHeader(InternalMovementHeader,Location.Code,ToBin.Code);
      LibraryWarehouse.GetBinContentInternalMovement(InternalMovementHeader,Location.Code,Item."No.",BinContentFilter);
Member of Lib.Library - Warehouse


CreateInternalMovementLine@70 Method

The procedure CreateInternalMovementLine is available in codeunit 132204.

Syntax

CreateInternalMovementLine@70(
    InternalMovementHeader@1000 : Record 7346 InternalMovementHeader, //Input parameter of type Record
    VAR InternalMovementLine@1002 : Record 7347 InternalMovementLine, //Reference parameter of type Record
    ItemNo@1001 : Code[20] ItemNo, //Input parameter of type Code
    FromBinCode@1005 : Code[20] FromBinCode, //Input parameter of type Code
    ToBinCode@1006 : Code[20] ToBinCode, //Input parameter of type Code
    Qty@1003 : Decimal Qty //Input parameter of type Decimal
);

Parameters

InternalMovementHeader
Input parameter of type Record
InternalMovementLine
Reference parameter of type Record
ItemNo
Input parameter of type Code
FromBinCode
Input parameter of type Code
ToBinCode
Input parameter of type Code
Qty
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Internal, Movement, Line.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(InternalMovementLine);
      InternalMovementLine.VALIDATE("No.",InternalMovementHeader."No.");
      RecRef.GETTABLE(InternalMovementLine);
      InternalMovementLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,InternalMovementLine.FIELDNO("Line No.")));
      InternalMovementLine.VALIDATE("Item No.",ItemNo);
      InternalMovementLine.VALIDATE("From Bin Code",FromBinCode);
      InternalMovementLine.VALIDATE("To Bin Code",ToBinCode);
      InternalMovementLine.VALIDATE(Quantity,Qty);
      InternalMovementLine.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137030 to show one way of using this function.

      LibraryWarehouse.CreateInternalMovementHeader(InternalMovementHeader,Location.Code,ToBin.Code);
      LibraryWarehouse.CreateInternalMovementLine(
        InternalMovementHeader,InternalMovementLine,Item."No.",FromBin.Code,ToBin.Code,Quantity);
      InternalMovementLine.VALIDATE("From Bin Code",FromBin.Code);
      InternalMovementLine.VALIDATE("To Bin Code",ToBin.Code);
      InternalMovementLine.MODIFY(TRUE);
Member of Lib.Library - Warehouse


CreateInTransitLocation@30 Method

The procedure CreateInTransitLocation is available in codeunit 132204.

Syntax

CreateInTransitLocation@30(
    VAR Location@1000 : Record 14 Location //Reference parameter of type Record
);

Parameters

Location
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, In, Transit, Location.

For a clarification about how this function works, refer to the code listed below.

      CreateLocationWithInventoryPostingSetup(Location);
      Location.VALIDATE("Use As In-Transit",TRUE);
      Location.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137001 to show one way of using this function.

      // Test for SE bug 266685.
      // 1. Setup demo data. Add a number of locations.
      // 2. Setup app parameters.
      // 3. Create item with costing method Average.
      // 4. Create and post purchase order for item, for the last location.
      // 5. Create and post transfer order from the last location, back and forth to all the other locations.
      // 6. Adjust cost-item entries.
      // 7. Validate unit cost.
      // 8. Validate item ledger entries for item.

      // Setup.
      Initialize;
      SetupParameters(InventorySetup."Automatic Cost Adjustment"::Never,AvgCostCalcType);

      // Create locations.
      TempLocation.DELETEALL;
      FOR count := 1 TO 4 DO BEGIN
        LibraryWarehouse.CreateLocation(Location);
        LibraryInventory.UpdateInventoryPostingSetup(Location);
        TempLocation := Location;
        TempLocation.INSERT;
      END;

      // Create in-transit location.
      LibraryWarehouse.CreateInTransitLocation(Location1);
      CreateItem(Item,Item."Costing Method"::Average,Item."Replenishment System"::Purchase);

      // Create and post purchase order for item, for the last location.
      CreateSingleLinePurchaseOrder(PurchaseHeader,Item."No.",PurchaseLine.Type::Item);
      UpdatePurchaseLine(PurchaseLine,PurchaseHeader,Item."No.",Location.Code);
      PostPurchaseOrder(PurchInvHeader,PurchaseHeader);

      // Create and post transfer order from the last location, back and forth to all the other locations.
      TempLocation.SETFILTER(Code,'<>%1',Location.Code);
      IF TempLocation.FINDSET THEN
        REPEAT
          LibraryWarehouse.CreateTransferHeader(TransferHeader,Location.Code,TempLocation.Code,Location1.Code);
          LibraryWarehouse.CreateTransferLine(TransferHeader,TransferLine,Item."No.",PurchaseLine.Quantity);
          LibraryWarehouse.PostTransferOrder(TransferHeader,TRUE,TRUE);

          LibraryWarehouse.CreateTransferHeader(TransferHeader,TempLocation.Code,Location.Code,Location1.Code);
          LibraryWarehouse.CreateTransferLine(TransferHeader,TransferLine,Item."No.",PurchaseLine.Quantity);
          LibraryWarehouse.PostTransferOrder(TransferHeader,TRUE,TRUE);
        UNTIL TempLocation.NEXT = 0;

      // Execute: Adjust.
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');

      // Validate: Item unit cost.
      Item.GET(Item."No.");
      Assert.AreEqual(CalcUnitCost(Item."No."),Item."Unit Cost",'Wrong item average cost.');

      // Validate: Number of entries.
      Assert.AreEqual(
        GetNoOfEntries(
          Item."No.",ValueEntry."Item Ledger Entry Type"::Transfer,ValueEntry."Entry Type"::"Direct Cost",
          ValueEntry."Document Type"::"Transfer Shipment"),12,
        STRSUBSTNO(ErrorValueEntries,12,'Transfer','Direct Cost','Transfer Shipment',Item."No."));
      Assert.AreEqual(
        GetNoOfEntries(
          Item."No.",ValueEntry."Item Ledger Entry Type"::Transfer,ValueEntry."Entry Type"::"Direct Cost",
          ValueEntry."Document Type"::"Transfer Receipt"),12,
        STRSUBSTNO(ErrorValueEntries,12,'Transfer','Direct Cost','Transfer Receipt',Item."No."));

      // Tear Down.
      SetupParameters(InventorySetup."Automatic Cost Adjustment"::Never,InventorySetup."Average Cost Calc. Type"::Item);
Member of Lib.Library - Warehouse


CreateInventoryMovementHeader@87 Method

The procedure CreateInventoryMovementHeader is available in codeunit 132204.

Syntax

CreateInventoryMovementHeader@87(
    VAR WarehouseActivityHeader@1000 : Record 5766 WarehouseActivityHeader, //Reference parameter of type Record
    LocationCode@1001 : Code[10] LocationCode //Input parameter of type Code
);

Parameters

WarehouseActivityHeader
Reference parameter of type Record
LocationCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Inventory, Movement, Header.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(WarehouseActivityHeader);
      WarehouseActivityHeader.VALIDATE("Location Code",LocationCode);
      WarehouseActivityHeader.VALIDATE(Type,WarehouseActivityHeader.Type::"Invt. Movement");
      WarehouseActivityHeader.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137030 to show one way of using this function.

      // Test setup
      TestSetup;
      PC5(ParentItem);

      FindBin(FromBin,Location,FALSE,1);
      FindBin(ToBin,Location,FALSE,3);

      FindChild(ParentItem,ChildItem,1);
      AddInventoryNonDirectLocation(ChildItem,Location,FromBin,20);

      // create Released Production Order and refresh it
      CreateRelProdOrderAndRefresh(ProductionOrder,ParentItem."No.",10,Location.Code,ToBin.Code);
      SetBinCodeOnCompLines(ProductionOrder,ToBin);

      // Create inventory movement - no location code
      LibraryWarehouse.CreateInventoryMovementHeader(WarehouseActivityHeader,'');

      // check that get source doc returns error
      AssertCannotCreateInvtMvmtMan(WarehouseActivityHeader,MSG_MUST_SPECIFY_LOCATION);
Member of Lib.Library - Warehouse


CreateInvtMvmtFromInternalMvmt@82 Method

The procedure CreateInvtMvmtFromInternalMvmt is available in codeunit 132204.

Syntax

CreateInvtMvmtFromInternalMvmt@82(
    VAR InternalMovementHeader@1001 : Record 7346 InternalMovementHeader //Reference parameter of type Record
);

Parameters

InternalMovementHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Invt, Movement, From, Internal, Movement.

For a clarification about how this function works, refer to the code listed below.

      CreateInvtPickMovement.CreateInvtMvntWithoutSource(InternalMovementHeader);

Example

The below example is extracted from the test automation codeunit 137030 to show one way of using this function.

      COMMIT; // as assert error will roll-back
      ASSERTERROR
        LibraryWarehouse.CreateInvtMvmtFromInternalMvmt(InternalMovementHeader);
      Assert.IsTrue(STRPOS(GETLASTERRORTEXT,MSG_THERE_NOTHING_TO_HANDLE) > 0,GETLASTERRORTEXT);

      CLEARLASTERROR;
Member of Lib.Library - Warehouse


CreateInvtPutAwayPick@141 Method

The procedure CreateInvtPutAwayPick is available in codeunit 132204.

Syntax

CreateInvtPutAwayPick@141(
    VAR WarehouseRequest@1002 : Record 5765 WarehouseRequest, //Reference parameter of type Record
    PutAway@1004 : Boolean PutAway, //Input parameter of type Boolean
    Pick@1005 : Boolean Pick, //Input parameter of type Boolean
    Movement@1006 : Boolean Movement //Input parameter of type Boolean
);

Parameters

WarehouseRequest
Reference parameter of type Record
PutAway
Input parameter of type Boolean
Pick
Input parameter of type Boolean
Movement
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, Invt, Put, Away, Pick.

For a clarification about how this function works, refer to the code listed below.

      COMMIT;
      CreateInvtPutAwayPickMvmt.InitializeRequest(PutAway,Pick,Movement,FALSE,FALSE);
      IF WarehouseRequest.HASFILTER THEN
        TmpWarehouseRequest.COPYFILTERS(WarehouseRequest)
      ELSE BEGIN
        WarehouseRequest.GET(WarehouseRequest.Type,
          WarehouseRequest."Location Code",
          WarehouseRequest."Source Type",
          WarehouseRequest."Source Subtype",
          WarehouseRequest."Source No.");
        TmpWarehouseRequest.SETRANGE(Type,WarehouseRequest.Type);
        TmpWarehouseRequest.SETRANGE("Location Code",WarehouseRequest."Location Code");
        TmpWarehouseRequest.SETRANGE("Source Type",WarehouseRequest."Source Type");
        TmpWarehouseRequest.SETRANGE("Source Subtype",WarehouseRequest."Source Subtype");
        TmpWarehouseRequest.SETRANGE("Source No.",WarehouseRequest."Source No.");
      END;
      CreateInvtPutAwayPickMvmt.SETTABLEVIEW(TmpWarehouseRequest);
      CreateInvtPutAwayPickMvmt.USEREQUESTPAGE(FALSE);
      CreateInvtPutAwayPickMvmt.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 134900 to show one way of using this function.

      // [FEATURE] [Sales] [Prepayment] [Inventory Pick]
      // [SCENARIO 379696] Invt. Pick should be created when "Check Prepmt. when Posting" is marked and Prepayment is paid.
      Initialize;

      // [GIVEN] "Check Prepmt. when Posting" is marked.
      Qty := LibraryRandom.RandInt(100);
      SetCheckPrepmtWhenPostingSales(TRUE);
      CreatePostingSetup(LineGLAccount);
      // [GIVEN] Location with "Require Pick".
      LocationCode := CreateLocationRequirePick;
      // [GIVEN] Item with "VAT Prod. Posting Group" and Item Inventory in Location.
      CreateItemAndItemInventory(
        Item,LocationCode,Qty,LineGLAccount."Gen. Prod. Posting Group",LineGLAccount."VAT Prod. Posting Group");
      // [GIVEN] Create Sales Order for Item with unpaid Prepayment.
      CreateSalesOrderWithUnpaidPrepayment(SalesHeader,LineGLAccount,LocationCode,Item."No.",Qty);
      // [GIVEN] Create payment and release Sales Order.
      CreatePaymentAndReleaseSalesOrder(SalesHeader);
      COMMIT;

      // [WHEN] Create Inventory Pick
      LibraryVariableStorage.Enqueue(NoOfPicksCreatedMsg);
      SalesHeader.CreateInvtPutAwayPick;

      // [THEN] Message "Number of Invt. Pick activities created..." is appeared.
      RemovePrepmtVATSetup(LineGLAccount);
Member of Lib.Library - Warehouse


CreateInvtPutPickMovement@80 Method

The procedure CreateInvtPutPickMovement is available in codeunit 132204.

Syntax

CreateInvtPutPickMovement@80(
    SourceDocument@1002 : Option SourceDocument, //Input parameter of type Option
    SourceNo@1001 : Code[20] SourceNo, //Input parameter of type Code
    PutAway@1004 : Boolean PutAway, //Input parameter of type Boolean
    Pick@1005 : Boolean Pick, //Input parameter of type Boolean
    Movement@1006 : Boolean Movement //Input parameter of type Boolean
);

Parameters

SourceDocument
Input parameter of type Option
SourceNo
Input parameter of type Code
PutAway
Input parameter of type Boolean
Pick
Input parameter of type Boolean
Movement
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, Invt, Put, Pick, Movement.

For a clarification about how this function works, refer to the code listed below.

      WhseRequest.RESET;
      WhseRequest.INIT;
      WhseRequest.SETCURRENTKEY("Source Document","Source No.");
      WhseRequest.SETRANGE("Source Document",SourceDocument);
      WhseRequest.SETRANGE("Source No.",SourceNo);
      CreateInvtPutAwayPickMvmt.SETTABLEVIEW(WhseRequest);
      CreateInvtPutAwayPickMvmt.InitializeRequest(PutAway,Pick,Movement,FALSE,FALSE);
      CreateInvtPutAwayPickMvmt.USEREQUESTPAGE(FALSE);
      CreateInvtPutAwayPickMvmt.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 137005 to show one way of using this function.

      // [FEATURE] [Warehouse] [Pick] [Production Order]
      // This is implementation for Scenario 1, bug 40394 from "Navision Corsica" database

      Initialize;

      // Step 1 - Create item hiercarchy: BOM with hierachy: PARENT and CHILD
      // Add a new UOM to child item = KG
      CreateItemHierarchy(ProdBOMHeader,ParentItem,ChildItem,RANDOM(10));
      LibraryInventory.CreateItemUnitOfMeasure(ItemUOM,ChildItem."No.",KGConst,3);

      // Step 2 - Create location with require pick and require put-away
      CreatePickPutAwayLocation(Location);

      // Step 3 - Add 1000 PCS of child item into inventory by posting item journal into created location
      LibraryInventory.FindItemJournalTemplate(ItemJournalTemplate);
      ItemJournalBatch.SETRANGE("Journal Template Name",ItemJournalTemplate.Name);
      ItemJournalBatch.FINDFIRST;
      LibraryInventory.CreateItemJournalLine(
        ItemJournalLine,ItemJournalTemplate.Name,ItemJournalBatch.Name,ItemJournalLine."Entry Type"::"Positive Adjmt.",
        ChildItem."No.",1000);
      ItemJournalLine.VALIDATE("Location Code",Location.Code);
      ItemJournalLine.MODIFY(TRUE);
      LibraryInventory.PostItemJournalLine(ItemJournalTemplate.Name,ItemJournalBatch.Name);

      // Step 4 - Create released production order for new item and refresh it
      CreateReleasedProdOrderAndRefresh(ProductionOrder,ParentItem,Location.Code,RANDOM(10));

      // Step 5 - change the UOM to KG on the component lines
      ChangeUOMOnComponentLines(ProductionOrder,KGConst);

      // Step 6 - create the inventory pick
      WarehouseRequest.SETFILTER("Source Document",'%1|%2',
        WarehouseRequest."Source Document"::"Prod. Consumption",
        WarehouseRequest."Source Document"::"Prod. Output");
      WarehouseRequest.SETRANGE("Source No.",ProductionOrder."No.");
      LibraryWarehouse.CreateInvtPutPickMovement(
        WarehouseRequest."Source Document"::"Prod. Consumption",ProductionOrder."No.",FALSE,TRUE,FALSE);

      // Step 7 - autofill qty to handle and post pick
      Assert.IsTrue(FindAndSelInvActvOnSrcNoAndLoc(WarehouseActivityHeader,
          WarehouseActivityHeader."Source Document"::"Prod. Consumption",ProductionOrder."No.",Location.Code),
        NoPutAwayCreatedForPrdOrdConst);

      LibraryWarehouse.AutoFillQtyInventoryActivity(WarehouseActivityHeader);
      LibraryWarehouse.PostInventoryActivity(WarehouseActivityHeader,TRUE);

      // Step 8 - verify that the pick has been posted - it has been deleted
      Assert.IsFalse(FindAndSelInvActvOnSrcNoAndLoc(WarehouseActivityHeader,
          WarehouseActivityHeader."Source Document"::"Prod. Consumption",ProductionOrder."No.",Location.Code),
        PutAwayNotDeletedConst);

      // Step 9 - Verify that pick has been posted - in history
      Assert.IsTrue(
        FindAndSelPstPickOnSrcNoAndLoc(PostedInvtPickHeader,
          PostedInvtPickHeader."Source Document"::"Prod. Consumption",ProductionOrder."No.",Location.Code),
        PickNotFoundInHistoryConst);
Member of Lib.Library - Warehouse


CreateInvtPutPickPurchaseOrder@34 Method

The procedure CreateInvtPutPickPurchaseOrder is available in codeunit 132204.

Syntax

CreateInvtPutPickPurchaseOrder@34(
    VAR PurchaseHeader@1001 : Record 38 PurchaseHeader //Reference parameter of type Record
);

Parameters

PurchaseHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Invt, Put, Pick, Purchase, Order.

For a clarification about how this function works, refer to the code listed below.

      PurchaseHeader.TESTFIELD(Status,PurchaseHeader.Status::Released);

      WhseRequest.RESET;
      WhseRequest.SETCURRENTKEY("Source Document","Source No.");
      CASE PurchaseHeader."Document Type" OF
        PurchaseHeader."Document Type"::Order:
          WhseRequest.SETRANGE("Source Document",WhseRequest."Source Document"::"Purchase Order");
        PurchaseHeader."Document Type"::"Return Order":
          WhseRequest.SETRANGE("Source Document",WhseRequest."Source Document"::"Purchase Return Order");
      END;
      WhseRequest.SETRANGE("Source No.",PurchaseHeader."No.");
      CreateInvtPutPick.SETTABLEVIEW(WhseRequest);
      CreateInvtPutPick.InitializeRequest(TRUE,TRUE,FALSE,FALSE,FALSE);
      CreateInvtPutPick.USEREQUESTPAGE(FALSE);
      CreateInvtPutPick.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 137200 to show one way of using this function.

      BinRec.SETRANGE("Location Code",LocationRec.Code);
      BinRec.FINDFIRST;

      // creating purchase order with 2 lines
      LibraryPurchase.CreatePurchHeader(PurchaseHeaderRec,PurchaseHeaderRec."Document Type"::Order,'');
      LibraryPurchase.CreatePurchaseLine(PurchaseLineRec,PurchaseHeaderRec,PurchaseLineRec.Type::Item,ItemRecComp1."No.",11);
      PurchaseLineRec.VALIDATE("Location Code",LocationRec.Code);
      PurchaseLineRec.VALIDATE("Bin Code",BinRec.Code);
      PurchaseLineRec.VALIDATE("Direct Unit Cost",11);
      PurchaseLineRec.MODIFY(TRUE);

      LibraryPurchase.CreatePurchaseLine(PurchaseLineRec,PurchaseHeaderRec,PurchaseLineRec.Type::Item,ItemRecComp2."No.",13);
      PurchaseLineRec.VALIDATE("Location Code",LocationRec.Code);
      PurchaseLineRec.VALIDATE("Bin Code",BinRec.Code);
      PurchaseLineRec.VALIDATE("Direct Unit Cost",13);
      PurchaseLineRec.MODIFY(TRUE);

      // creating inventory put-away
      LibraryPurchase.ReleasePurchaseDocument(PurchaseHeaderRec);
      LibraryWarehouse.CreateInvtPutPickPurchaseOrder(PurchaseHeaderRec);

      // posting inventory put-away
      WarehouseActivityHeaderRec.SETRANGE("Location Code",LocationRec.Code);
      WarehouseActivityHeaderRec.FINDFIRST;
      WarehouseActivityHeaderRec.VALIDATE("External Document No.2",PurchaseHeaderRec."No.");
      WarehouseActivityHeaderRec.MODIFY(TRUE);

      LibraryWarehouse.AutoFillQtyInventoryActivity(WarehouseActivityHeaderRec);
      LibraryWarehouse.PostInventoryActivity(WarehouseActivityHeaderRec,TRUE);
Member of Lib.Library - Warehouse


CreateInvtPutPickSalesOrder@29 Method

The procedure CreateInvtPutPickSalesOrder is available in codeunit 132204.

Syntax

CreateInvtPutPickSalesOrder@29(
    VAR SalesHeader@1001 : Record 36 SalesHeader //Reference parameter of type Record
);

Parameters

SalesHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Invt, Put, Pick, Sales, Order.

For a clarification about how this function works, refer to the code listed below.

      SalesHeader.TESTFIELD(Status,SalesHeader.Status::Released);

      WhseRequest.RESET;
      WhseRequest.SETCURRENTKEY("Source Document","Source No.");
      CASE SalesHeader."Document Type" OF
        SalesHeader."Document Type"::Order:
          WhseRequest.SETRANGE("Source Document",WhseRequest."Source Document"::"Sales Order");
        SalesHeader."Document Type"::"Return Order":
          WhseRequest.SETRANGE("Source Document",WhseRequest."Source Document"::"Sales Return Order");
      END;
      WhseRequest.SETRANGE("Source No.",SalesHeader."No.");
      CreateInvtPutPick.SETTABLEVIEW(WhseRequest);
      CreateInvtPutPick.InitializeRequest(TRUE,TRUE,FALSE,FALSE,FALSE);
      CreateInvtPutPick.USEREQUESTPAGE(FALSE);
      CreateInvtPutPick.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 137501 to show one way of using this function.

      Initialize;
      CLEAR(Location);
      SetupLocation(Location,FALSE,FALSE,TRUE);
      SetupWarehouse(Location.Code);
      LibraryInventory.CreateItem(Item);
      LibraryPurchase.CreatePurchHeader(PurchaseHeader,PurchaseHeader."Document Type"::Order,'');
      LibraryPurchase.CreatePurchaseLine(PurchaseLine,PurchaseHeader,PurchaseLine.Type::Item,Item."No.",10);
      PurchaseLine.VALIDATE("Location Code",Location.Code);
      PurchaseLine.MODIFY(TRUE);
      LibraryPurchase.ReleasePurchaseDocument(PurchaseHeader);
      LibraryWarehouse.CreateInvtPutPickPurchaseOrder(PurchaseHeader);

      RegisterWhseActivity(
        WhseActivityLine."Activity Type"::"Invt. Put-away",39,WhseActivityLine."Source Document"::"Purchase Order",
        PurchaseHeader."No.",10,'','PICK');

      // Set up behaviour based on test type
      CASE TestType OF
        TestType::Partial:
          BEGIN
            FirstSOQty := 7;
            SecondSOQty := 5;
          END;
        TestType::Positive:
          BEGIN
            FirstSOQty := 6;
            SecondSOQty := 4;
          END;
        TestType::Negative:
          BEGIN
            FirstSOQty := 10;
            SecondSOQty := 5;
          END;
      END;

      LibrarySales.CreateSalesHeader(SalesHeader,SalesHeader."Document Type"::Order,'');
      LibrarySales.CreateSalesLine(SalesLine,SalesHeader,SalesLine.Type::Item,Item."No.",FirstSOQty);
      SalesLine.VALIDATE("Location Code",Location.Code);
      SalesLine.MODIFY(TRUE);
      LibrarySales.AutoReserveSalesLine(SalesLine);
      LibrarySales.ReleaseSalesDocument(SalesHeader);
      LibraryWarehouse.CreateInvtPutPickSalesOrder(SalesHeader);

      CLEAR(SalesHeader);
      LibrarySales.CreateSalesHeader(SalesHeader,SalesHeader."Document Type"::Order,'');
      LibrarySales.CreateSalesLine(SalesLine,SalesHeader,SalesLine.Type::Item,Item."No.",SecondSOQty);
      SalesLine.VALIDATE("Location Code",Location.Code);
      SalesLine.MODIFY(TRUE);
      LibrarySales.ReleaseSalesDocument(SalesHeader);
      LibraryWarehouse.CreateInvtPutPickSalesOrder(SalesHeader);

      CASE TestType OF
        TestType::Positive:
          BEGIN
            LibraryWarehouse.CreateInvtPutPickSalesOrder(SalesHeader);
            CheckPick(WhseActivityLine."Action Type"::Take,SalesHeader."No.",SalesLine.Quantity);
          END;
        TestType::Partial:
          BEGIN
            LibraryWarehouse.CreateInvtPutPickSalesOrder(SalesHeader);
            CheckPick(WhseActivityLine."Action Type"::Take,SalesHeader."No.",3);
          END;
        TestType::Negative:
          LibraryWarehouse.CreateInvtPutPickSalesOrder(SalesHeader);
      END;
Member of Lib.Library - Warehouse


CreateLocation@17 Method

The procedure CreateLocation is available in codeunit 132204.

Syntax

CreateLocation@17(
    VAR Location@1000 : Record 14 Location //Reference parameter of type Record
);

Parameters

Location
Reference parameter of type Record

Return Value

Code[10]

Remarks

The relevant search keywords are: Create, Location.

For a clarification about how this function works, refer to the code listed below.

      CreateLocationCodeAndName(Location);
      EXIT(Location.Code);

Example

The below example is extracted from the test automation codeunit 134326 to show one way of using this function.

      // [SCENARIO 362692] Fields "Location Code", "Unit of Measure", "Direct Unit Cost", "Line Discount %" are copied from Blanket Order to Purchase Order when Blanket Order and Line set manually
      Initialize;
      ItemNo := LibraryInventory.CreateItemNo;
      LibraryInventory.CreateItemUnitOfMeasureCode(ItemUnitOfMeasure,ItemNo,1);
      LibraryWarehouse.CreateLocation(Location);

      // [GIVEN] Purchase Blanket Order for item "X"
      CreatePurchaseBlanketOrder(PurchaseHeaderBlanket,PurchaseLineBlanket,1,LibraryPurchase.CreateVendorNo,ItemNo); // 1 line is enough for test
      PurchaseLineBlanket.VALIDATE("Location Code",Location.Code);
      PurchaseLineBlanket.VALIDATE("Unit of Measure Code",ItemUnitOfMeasure.Code);
      PurchaseLineBlanket.VALIDATE("Direct Unit Cost",LibraryRandom.RandDec(100,2));
      PurchaseLineBlanket.VALIDATE("Line Discount %",LibraryRandom.RandDec(100,2));
      PurchaseLineBlanket.MODIFY(TRUE);

      // [GIVEN] Purchase Order with a line for the item "X"
      LibraryPurchase.CreatePurchHeader(
        PurchaseHeader,PurchaseHeader."Document Type"::Order,PurchaseHeaderBlanket."Buy-from Vendor No.");
      LibraryPurchase.CreatePurchaseLine(
        PurchaseLine,PurchaseHeader,PurchaseLine.Type::Item,PurchaseLineBlanket."No.",PurchaseLineBlanket.Quantity);

      // [WHEN] "Blanket Order Line No." is set manually
      UpdatePurchaseLineWithBlanketOrder(
        PurchaseLine,PurchaseHeaderBlanket."No.",PurchaseLineBlanket."Line No.");

      // [THEN] Fields "Location Code", "Unit of Measure", "Direct Unit Cost", "Line Discount %", "Line Discount Amount" are copied from Blanket Order Line
      WITH PurchaseLine DO BEGIN
        Assert.AreEqual(
          PurchaseLineBlanket."Location Code","Location Code",FIELDCAPTION("Location Code"));
        Assert.AreEqual(
          PurchaseLineBlanket."Unit of Measure","Unit of Measure",FIELDCAPTION("Unit of Measure"));
        Assert.AreEqual(
          PurchaseLineBlanket."Direct Unit Cost","Direct Unit Cost",FIELDCAPTION("Direct Unit Cost"));
        Assert.AreEqual(
          PurchaseLineBlanket."Line Discount %","Line Discount %",FIELDCAPTION("Line Discount %"));
        Assert.AreEqual(
          PurchaseLineBlanket."Line Discount Amount","Line Discount Amount",FIELDCAPTION("Line Discount Amount"));
      END;
Member of Lib.Library - Warehouse


CreateLocationWithInventoryPostingSetup@33 Method

The procedure CreateLocationWithInventoryPostingSetup is available in codeunit 132204.

Syntax

CreateLocationWithInventoryPostingSetup@33(
    VAR Location@1000 : Record 14 Location //Reference parameter of type Record
);

Parameters

Location
Reference parameter of type Record

Return Value

Code[10]

Remarks

The relevant search keywords are: Create, Location, Inventory, Posting, Setup.

For a clarification about how this function works, refer to the code listed below.

      CreateLocationCodeAndName(Location);
      LibraryInventory.UpdateInventoryPostingSetup(Location);
      EXIT(Location.Code);

Example

The below example is extracted from the test automation codeunit 134093 to show one way of using this function.

      Initialize;

      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location);
      InventoryPostingSetup.SETRANGE("Location Code",Location.Code);
      InventoryPostingSetup.FINDFIRST;
      LibraryVariableStorage.Enqueue(InventoryPostingSetup.FIELDNAME("Inventory Account"));

      // Execute
      CalcGLAccWhereUsed.CheckGLAcc(InventoryPostingSetup."Inventory Account");

      // Validate in page handler
Member of Lib.Library - Warehouse


CreateLocationWMS@44 Method

The procedure CreateLocationWMS is available in codeunit 132204.

Syntax

CreateLocationWMS@44(
    VAR Location@1000 : Record 14 Location, //Reference parameter of type Record
    BinMandatory@1005 : Boolean BinMandatory, //Input parameter of type Boolean
    RequirePutAway@1001 : Boolean RequirePutAway, //Input parameter of type Boolean
    RequirePick@1002 : Boolean RequirePick, //Input parameter of type Boolean
    RequireReceive@1003 : Boolean RequireReceive, //Input parameter of type Boolean
    RequireShipment@1004 : Boolean RequireShipment //Input parameter of type Boolean
);

Parameters

Location
Reference parameter of type Record
BinMandatory
Input parameter of type Boolean
RequirePutAway
Input parameter of type Boolean
RequirePick
Input parameter of type Boolean
RequireReceive
Input parameter of type Boolean
RequireShipment
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, Location, WMS.

For a clarification about how this function works, refer to the code listed below.

      CreateLocationWithInventoryPostingSetup(Location);
      IF RequirePutAway THEN
        Location.VALIDATE("Require Put-away",TRUE);
      IF RequirePick THEN
        Location.VALIDATE("Require Pick",TRUE);
      IF RequireReceive THEN
        Location.VALIDATE("Require Receive",TRUE);
      IF RequireShipment THEN
        Location.VALIDATE("Require Shipment",TRUE);
      Location."Bin Mandatory" := BinMandatory;
      Location.MODIFY;

Example

The below example is extracted from the test automation codeunit 136101 to show one way of using this function.

      // [FEATURE] [Credit Limit] [UI]
      // [SCENARIO 378946] Credit limit warning page is opened once when validate Service Line with exceeded Quantity
      Initialize;
      UpdateSalesReceivablesSetup;

      // [GIVEN] Customer with Credit Limit
      // [GIVEN] Service Order (used Location with "Require Shipment" = TRUE). Service Line "Quantity" = 1.
      LibraryWarehouse.CreateLocationWMS(Location,FALSE,FALSE,FALSE,FALSE,TRUE);
      CreateServiceOrderWithItem(ServiceHeader,LibrarySales.CreateCustomerNo,Location.Code,LibraryInventory.CreateItemNo,1);
      UpdateCustomerCreditLimit(
        ServiceHeader."Customer No.",CalcTotalLineAmount(ServiceHeader."Document Type",ServiceHeader."No."));
      GetServiceLine(ServiceLine,ServiceHeader);
      Quantity := ServiceLine.Quantity;
      // [GIVEN] Modify Service Line "Quantity" = 2 (through the Service Line page)
      LibraryVariableStorage.Enqueue(Quantity + LibraryERM.GetAmountRoundingPrecision);
      LibraryVariableStorage.Enqueue(ServiceHeader."Customer No.");
      ServiceOrder.OPENEDIT;
      ServiceOrder.GOTORECORD(ServiceHeader);
      ServiceOrder.ServItemLines."Service Lines".INVOKE;
      ServiceOrder.CLOSE;
      // [GIVEN] Credit Limit warning page is opened

      // [WHEN] Close credit limit warning page with "OK" action.
      // "CheckCreditLimit_ReplyYes_MPH" handler

      // [THEN] No error occurs and Service Line "Quantity" = 2. No more credit limit warning page is shown.
      ServiceLine.FIND;
      Assert.AreEqual(
        Quantity + LibraryERM.GetAmountRoundingPrecision,
        ServiceLine.Quantity,
        ServiceLine.FIELDCAPTION("Unit Price"));
      Assert.AreEqual(1,LibraryVariableStorage.Length,CustCheckCrLimitOnceErr);
Member of Lib.Library - Warehouse


CreateMovementWorksheetLine@45 Method

The procedure CreateMovementWorksheetLine is available in codeunit 132204.

Syntax

CreateMovementWorksheetLine@45(
    VAR WhseWorksheetLine@1002 : Record 7326 WhseWorksheetLine, //Reference parameter of type Record
    FromBin@1003 : Record 7354 FromBin, //Input parameter of type Record
    ToBin@1004 : Record 7354 ToBin, //Input parameter of type Record
    ItemNo@1005 : Code[20] ItemNo, //Input parameter of type Code
    VariantCode@1006 : Code[10] VariantCode, //Input parameter of type Code
    Quantity@1007 : Decimal Quantity //Input parameter of type Decimal
);

Parameters

WhseWorksheetLine
Reference parameter of type Record
FromBin
Input parameter of type Record
ToBin
Input parameter of type Record
ItemNo
Input parameter of type Code
VariantCode
Input parameter of type Code
Quantity
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Movement, Worksheet, Line.

For a clarification about how this function works, refer to the code listed below.

      LibraryWarehouse.SelectWhseWorksheetTemplate(WhseWorksheetTemplate,WhseWorksheetTemplate.Type::Movement);
      LibraryWarehouse.SelectWhseWorksheetName(WhseWorksheetName,WhseWorksheetTemplate.Name,FromBin."Location Code");
      LibraryWarehouse.CreateWhseWorksheetLine(
        WhseWorksheetLine,WhseWorksheetName."Worksheet Template Name",WhseWorksheetName.Name,WhseWorksheetName."Location Code",0);
      WhseWorksheetLine.VALIDATE("Item No.",ItemNo);
      WhseWorksheetLine.VALIDATE("Variant Code",VariantCode);
      WhseWorksheetLine.VALIDATE("From Zone Code",FromBin."Zone Code");
      WhseWorksheetLine.VALIDATE("From Bin Code",FromBin.Code);
      WhseWorksheetLine.VALIDATE("To Zone Code",ToBin."Zone Code");
      WhseWorksheetLine.VALIDATE("To Bin Code",ToBin.Code);
      WhseWorksheetLine.VALIDATE(Quantity,Quantity);
      WhseWorksheetLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137154 to show one way of using this function.

      // Create Item with Item Variant. Update Inventory for Item with Variant. Create and register Movement.
      LibraryInventory.CreateItem(Item);
      LibraryInventory.CreateItemVariant(ItemVariant,Item."No.");
      Quantity := LibraryRandom.RandDec(100,2);
      Quantity2 := LibraryRandom.RandDec(100,2);
      FindBin(Bin,LocationWhite.Code);
      LibraryWarehouse.CreateBin(Bin2,Bin."Location Code",LibraryUtility.GenerateGUID,Bin."Zone Code",Bin."Bin Type Code");
      UpdateInventoryUsingWarehouseJournal(Bin,Item,ItemVariant.Code,Item."Base Unit of Measure",Quantity + Quantity2);  // Value required for test.
      LibraryWarehouse.CreateMovementWorksheetLine(WhseWorksheetLine,Bin,Bin2,Item."No.",ItemVariant.Code,Quantity);
      CreateAndRegisterMovement(WhseWorksheetLine,Item."No.");
      Bin3.GET(LocationWhite.Code,LocationWhite."Open Shop Floor Bin Code");

      // Exercise.
      CreatePickFromWarehouseInternalPick(WhseInternalPickHeader,Bin3,Item."No.",ItemVariant.Code,Quantity + Quantity2);  // Value required for test.

      // Verify.
      VerifyPickLineWithBin(
        Bin2,WarehouseActivityLine."Action Type"::Take,WhseInternalPickHeader."No.",Item."No.",ItemVariant.Code,
        Item."Base Unit of Measure",Quantity,FALSE);
      VerifyPickLineWithBin(
        Bin3,WarehouseActivityLine."Action Type"::Place,WhseInternalPickHeader."No.",Item."No.",ItemVariant.Code,
        Item."Base Unit of Measure",Quantity,FALSE);
      VerifyPickLineWithBin(
        Bin,WarehouseActivityLine."Action Type"::Take,WhseInternalPickHeader."No.",Item."No.",ItemVariant.Code,
        Item."Base Unit of Measure",Quantity2,FALSE);
      VerifyPickLineWithBin(
        Bin3,WarehouseActivityLine."Action Type"::Place,WhseInternalPickHeader."No.",Item."No.",ItemVariant.Code,
        Item."Base Unit of Measure",Quantity2,TRUE);  // Use True for Move Next Line.

      IF RegisterPick THEN BEGIN
        // Exercise.
        RegisterWarehouseActivity(
          WarehouseActivityLine,WarehouseActivityLine."Source Document"::" ",WhseInternalPickHeader."No.",
          WarehouseActivityLine."Activity Type"::Pick);

        // Verify.
        VerifyRegisteredPickLine(
          WarehouseActivityLine."Action Type"::Take,WarehouseActivityLine."Source Document"::" ",WhseInternalPickHeader."No.",Bin2,
          Item."No.",ItemVariant.Code,Item."Base Unit of Measure",'',Quantity,FALSE);
        VerifyRegisteredPickLine(
          WarehouseActivityLine."Action Type"::Place,WarehouseActivityLine."Source Document"::" ",WhseInternalPickHeader."No.",Bin3,
          Item."No.",ItemVariant.Code,Item."Base Unit of Measure",'',Quantity,FALSE);
        VerifyRegisteredPickLine(
          WarehouseActivityLine."Action Type"::Take,WarehouseActivityLine."Source Document"::" ",WhseInternalPickHeader."No.",Bin,
          Item."No.",ItemVariant.Code,Item."Base Unit of Measure",'',Quantity2,FALSE);
        VerifyRegisteredPickLine(
          WarehouseActivityLine."Action Type"::Place,WarehouseActivityLine."Source Document"::" ",WhseInternalPickHeader."No.",Bin3,
          Item."No.",ItemVariant.Code,Item."Base Unit of Measure",'',Quantity2,TRUE);  // Move Next Line.
      END;
Member of Lib.Library - Warehouse


CreateNumberOfBins@114 Method

The procedure CreateNumberOfBins is available in codeunit 132204.

Syntax

CreateNumberOfBins@114(
    LocationCode@1001 : Code[10] LocationCode, //Input parameter of type Code
    ZoneCode@1003 : Code[10] ZoneCode, //Input parameter of type Code
    BinTypeCode@1004 : Code[10] BinTypeCode, //Input parameter of type Code
    NoOfBins@1005 : Integer NoOfBins, //Input parameter of type Integer
    IsCrossDock@1006 : Boolean IsCrossDock //Input parameter of type Boolean
);

Parameters

LocationCode
Input parameter of type Code
ZoneCode
Input parameter of type Code
BinTypeCode
Input parameter of type Code
NoOfBins
Input parameter of type Integer
IsCrossDock
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, Number, Of, Bins.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(Bin);
      Bin.INIT;
      Bin.SETRANGE("Location Code",LocationCode);
      ExistingBinCount := Bin.COUNT + 1;

      FOR i := 1 TO NoOfBins DO BEGIN
        CreateBin(Bin,LocationCode,'Bin' + FORMAT(ExistingBinCount),ZoneCode,BinTypeCode);
        ExistingBinCount := ExistingBinCount + 1;
        IF IsCrossDock THEN BEGIN
          Bin.VALIDATE("Cross-Dock Bin",TRUE);
          Bin.MODIFY(TRUE);
        END;
      END;

Example

The below example is extracted from the test automation codeunit 137033 to show one way of using this function.

      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location);
      Location."Bin Mandatory" := TRUE;
      Location.VALIDATE("Directed Put-away and Pick",TRUE);
      Location.VALIDATE("Use Cross-Docking",TRUE);
      Location.MODIFY(TRUE);

      LibraryWarehouse.CreateZone(Zone,'',Location.Code,LibraryWarehouse.SelectBinType(FALSE,FALSE,FALSE,FALSE),'','',0,FALSE);
      LibraryWarehouse.CreateNumberOfBins(Location.Code,Zone.Code,LibraryWarehouse.SelectBinType(FALSE,FALSE,FALSE,FALSE),2,FALSE);
      LibraryWarehouse.FindBin(Bin,Location.Code,Zone.Code,1);
      BinCode1 := Bin.Code;
      Location.VALIDATE("Adjustment Bin Code",Bin.Code);
      Location.MODIFY(TRUE);

      LibraryWarehouse.FindBin(Bin,Location.Code,Zone.Code,2);
      BinCode2 := Bin.Code;
Member of Lib.Library - Warehouse


CreatePick@64 Method

The procedure CreatePick is available in codeunit 132204.

Syntax

CreatePick@64(
    VAR WarehouseShipmentHeader@1000 : Record 7320 WarehouseShipmentHeader //Reference parameter of type Record
);

Parameters

WarehouseShipmentHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Pick.

For a clarification about how this function works, refer to the code listed below.

      WarehouseShipmentLine.SETRANGE("No.",WarehouseShipmentHeader."No.");
      WarehouseShipmentLine.FINDFIRST;
      WhseShptLine.COPY(WarehouseShipmentLine);
      WhseShptHeader.GET(WhseShptLine."No.");
      IF WhseShptHeader.Status = WhseShptHeader.Status::Open THEN
        WhseShipmentRelease.Release(WhseShptHeader);
      WarehouseShipmentLine.SetHideValidationDialog(TRUE);
      WarehouseShipmentLine.CreatePickDoc(WhseShptLine,WhseShptHeader);

Example

The below example is extracted from the test automation codeunit 136140 to show one way of using this function.

      Initialize;

      // SETUP: Create Service order on WHITE Location and Release Service Order, Create Whse Shpment header using Get Source Doc
      LocationCode := WMSFullLocation;
      Quantity := RANDOM(100);
      CreateItemAndSupply(Item,LocationCode,Quantity);

      CreateServiceOrderAndServiceLines(ServiceHeader,Item."No.",Quantity,LocationCode);
      LibraryService.ReleaseServiceDocument(ServiceHeader);

      CreateWareHouseShipmentHeader(WarehouseShipmentHeader,LocationCode);
      AddWarehouseShipmentLineUsingGetSourceDocument(WarehouseShipmentHeader,ServiceHeader."No.",ServiceOrderInGrid);

      // EXECUTE: Create Pick, Register Pick and post Warehouse shipment with ship option.
      LibraryWarehouse.CreatePick(WarehouseShipmentHeader);
      RegisterWarehouseActivity(ServiceHeader."No.",WarehouseActivityLine."Activity Type"::Pick);
      LibraryWarehouse.PostWhseShipment(WarehouseShipmentHeader,FALSE);

      // Verify: All service lines are present in warehouse shipment and the quantities match
      GetAllServiceLinesOfTypeItem(ServiceLine,ServiceHeader);
      Assert.AreEqual(Quantity,ServiceLine."Quantity Shipped",ServiceLine.FIELDCAPTION("Quantity Shipped"));
      Assert.AreEqual(Quantity,ServiceLine."Qty. Shipped Not Invoiced",ServiceLine.FIELDCAPTION("Qty. Shipped Not Invoiced"));
Member of Lib.Library - Warehouse


CreatePickFromPickWorksheet@9 Method

The procedure CreatePickFromPickWorksheet is available in codeunit 132204.

Syntax

CreatePickFromPickWorksheet@9(
    VAR WhseWorksheetLine@1000 : Record 7326 WhseWorksheetLine, //Reference parameter of type Record
    LineNo@1014 : Integer LineNo, //Input parameter of type Integer
    WkshTemplateName@1015 : Code[10] WkshTemplateName, //Input parameter of type Code
    Name@1016 : Code[10] Name, //Input parameter of type Code
    LocationCode@1017 : Code[10] LocationCode, //Input parameter of type Code
    AssignedID@1013 : Code[10] AssignedID, //Input parameter of type Code
    MaxNoOfLines@1012 : Integer MaxNoOfLines, //Input parameter of type Integer
    MaxNoOfSourceDoc@1011 : Integer MaxNoOfSourceDoc, //Input parameter of type Integer
    SortPick@1010 : Option SortPick, //Input parameter of type Option
    PerShipTo@1009 : Boolean PerShipTo, //Input parameter of type Boolean
    PerItem@1008 : Boolean PerItem, //Input parameter of type Boolean
    PerZone@1007 : Boolean PerZone, //Input parameter of type Boolean
    PerBin@1006 : Boolean PerBin, //Input parameter of type Boolean
    PerWhseDoc@1005 : Boolean PerWhseDoc, //Input parameter of type Boolean
    PerDate@1004 : Boolean PerDate, //Input parameter of type Boolean
    PrintPick@1003 : Boolean PrintPick //Input parameter of type Boolean
);

Parameters

WhseWorksheetLine
Reference parameter of type Record
LineNo
Input parameter of type Integer
WkshTemplateName
Input parameter of type Code
Name
Input parameter of type Code
LocationCode
Input parameter of type Code
AssignedID
Input parameter of type Code
MaxNoOfLines
Input parameter of type Integer
MaxNoOfSourceDoc
Input parameter of type Integer
SortPick
Input parameter of type Option
PerShipTo
Input parameter of type Boolean
PerItem
Input parameter of type Boolean
PerZone
Input parameter of type Boolean
PerBin
Input parameter of type Boolean
PerWhseDoc
Input parameter of type Boolean
PerDate
Input parameter of type Boolean
PrintPick
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, Pick, From, Pick, Worksheet.

For a clarification about how this function works, refer to the code listed below.

      WhseWorksheetLine2 := WhseWorksheetLine;
      WhseWorksheetLine2.SETRANGE("Worksheet Template Name",WkshTemplateName);
      WhseWorksheetLine2.SETRANGE(Name,Name);
      WhseWorksheetLine2.SETRANGE("Location Code",LocationCode);
      IF LineNo <> 0 THEN
        WhseWorksheetLine2.SETRANGE("Line No.",LineNo);

      CreatePick.InitializeReport(
        AssignedID,MaxNoOfLines,MaxNoOfSourceDoc,SortPick,PerShipTo,PerItem,
        PerZone,PerBin,PerWhseDoc,PerDate,PrintPick,FALSE,FALSE);
      CreatePick.USEREQUESTPAGE(FALSE);
      CreatePick.SetWkshPickLine(WhseWorksheetLine2);
      CreatePick.RUNMODAL;
      CLEAR(CreatePick);

      WhseWorksheetLine := WhseWorksheetLine2;

Example

The below example is extracted from the test automation codeunit 137048 to show one way of using this function.

      // Setup : Create Item, Update Inventory, Warehouse Shipment and Select Document from Pick Selection Page.
      Initialize;
      CreateItem(Item);
      Quantity := LibraryRandom.RandDec(100,2);
      LibraryWarehouse.FindBin(Bin,LocationOrange.Code,'',1);
      UpdateItemInventory(Item."No.",LocationOrange.Code,Bin.Code,Quantity);

      CreateAndReleaseSalesOrder(SalesHeader,salesLine,LocationOrange.Code,Item."No.",Quantity,WORKDATE);
      WarehouseShipmentNo := FindWarehouseShipmentNo;
      WhseShipFromSOWithNewBinCode(BinCode,SalesHeader,WarehouseShipmentNo,LocationOrange.Code);
      ReleaseWarehouseShipment(WarehouseShipmentHeader,WarehouseShipmentNo);
      LocationCode2 := LocationOrange.Code;  // Assign value to global variable for use in handler.

      // Create Pick Worksheet Template, Getsource Document and Select the Pick Line from Pick Selection Page.
      CreateWhseWorksheetName(WhseWorksheetName,LocationOrange.Code);
      GetSourceDocOutbound.GetSingleWhsePickDoc(
        WhseWorksheetName."Worksheet Template Name",WhseWorksheetName.Name,LocationOrange.Code);
      FindWhseWorksheetLine(WhseWorksheetLine,WhseWorksheetName,LocationOrange.Code);

      // Exercise : Create Pick From Pick Worksheet.
      LibraryWarehouse.CreatePickFromPickWorksheet(
        WhseWorksheetLine,10000,WhseWorksheetName."Worksheet Template Name",WhseWorksheetName.Name,
        LocationOrange.Code,'',0,0,0,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE);

      // Verify: Check that Take and Place Bin Code is same as expected.
      VerifyBinCode(
        WarehouseActivityLine."Activity Type"::Pick,WarehouseActivityLine."Action Type"::Take,LocationOrange.Code,SalesHeader."No.",
        Bin.Code);
      VerifyBinCode(
        WarehouseActivityLine."Activity Type"::Pick,WarehouseActivityLine."Action Type"::Place,LocationOrange.Code,SalesHeader."No.",
        BinCode);
Member of Lib.Library - Warehouse


CreatePutAwayTemplateHeader@96 Method

The procedure CreatePutAwayTemplateHeader is available in codeunit 132204.

Syntax

CreatePutAwayTemplateHeader@96(
    VAR PutAwayTemplateHeader@1000 : Record 7307 PutAwayTemplateHeader //Reference parameter of type Record
);

Parameters

PutAwayTemplateHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Put, Away, Template, Header.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(PutAwayTemplateHeader);
      PutAwayTemplateHeader.INIT;

      PutAwayTemplateHeader.VALIDATE(Code,
        LibraryUtility.GenerateRandomCode(PutAwayTemplateHeader.FIELDNO(Code),DATABASE::"Put-away Template Header"));
      PutAwayTemplateHeader.VALIDATE(Description,PutAwayTemplateHeader.Code);
      PutAwayTemplateHeader.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137152 to show one way of using this function.

      LibraryWarehouse.CreatePutAwayTemplateHeader(PutAwayTemplateHeader);
      LibraryWarehouse.CreatePutAwayTemplateLine(
        PutAwayTemplateHeader,PutAwayTemplateLine,Fixed,FindFloatingBin,TRUE,TRUE,FindBinLessthanMinQty,FindEmptyBin);
Member of Lib.Library - Warehouse


CreatePutAwayTemplateLine@101 Method

The procedure CreatePutAwayTemplateLine is available in codeunit 132204.

Syntax

CreatePutAwayTemplateLine@101(
    PutAwayTemplateHeader@1001 : Record 7307 PutAwayTemplateHeader, //Input parameter of type Record
    VAR PutAwayTemplateLine@1000 : Record 7308 PutAwayTemplateLine, //Reference parameter of type Record
    FindFixedBin@1003 : Boolean FindFixedBin, //Input parameter of type Boolean
    FindFloatingBin@1004 : Boolean FindFloatingBin, //Input parameter of type Boolean
    FindSameItem@1005 : Boolean FindSameItem, //Input parameter of type Boolean
    FindUnitofMeasureMatch@1006 : Boolean FindUnitofMeasureMatch, //Input parameter of type Boolean
    FindBinLessthanMinQty@1007 : Boolean FindBinLessthanMinQty, //Input parameter of type Boolean
    FindEmptyBin@1008 : Boolean FindEmptyBin //Input parameter of type Boolean
);

Parameters

PutAwayTemplateHeader
Input parameter of type Record
PutAwayTemplateLine
Reference parameter of type Record
FindFixedBin
Input parameter of type Boolean
FindFloatingBin
Input parameter of type Boolean
FindSameItem
Input parameter of type Boolean
FindUnitofMeasureMatch
Input parameter of type Boolean
FindBinLessthanMinQty
Input parameter of type Boolean
FindEmptyBin
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, Put, Away, Template, Line.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(PutAwayTemplateLine);
      PutAwayTemplateLine.INIT;

      PutAwayTemplateLine.VALIDATE("Put-away Template Code",PutAwayTemplateHeader.Code);
      RecRef.GETTABLE(PutAwayTemplateLine);
      PutAwayTemplateLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,PutAwayTemplateLine.FIELDNO("Line No.")));
      PutAwayTemplateLine.VALIDATE("Find Fixed Bin",FindFixedBin);
      PutAwayTemplateLine.VALIDATE("Find Floating Bin",FindFloatingBin);
      PutAwayTemplateLine.VALIDATE("Find Same Item",FindSameItem);
      PutAwayTemplateLine.VALIDATE("Find Unit of Measure Match",FindUnitofMeasureMatch);
      PutAwayTemplateLine.VALIDATE("Find Bin w. Less than Min. Qty",FindBinLessthanMinQty);
      PutAwayTemplateLine.VALIDATE("Find Empty Bin",FindEmptyBin);
      PutAwayTemplateLine.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137152 to show one way of using this function.

      LibraryWarehouse.CreatePutAwayTemplateHeader(PutAwayTemplateHeader);
      LibraryWarehouse.CreatePutAwayTemplateLine(
        PutAwayTemplateHeader,PutAwayTemplateLine,Fixed,FindFloatingBin,TRUE,TRUE,FindBinLessthanMinQty,FindEmptyBin);
Member of Lib.Library - Warehouse


CreateTransferHeader@42 Method

The procedure CreateTransferHeader is available in codeunit 132204.

Syntax

CreateTransferHeader@42(
    VAR TransferHeader@1000 : Record 5740 TransferHeader, //Reference parameter of type Record
    FromLocation@1001 : Text[10] FromLocation, //Input parameter of type Text
    ToLocation@1002 : Text[10] ToLocation, //Input parameter of type Text
    InTransitCode@1003 : Text[10] InTransitCode //Input parameter of type Text
);

Parameters

TransferHeader
Reference parameter of type Record
FromLocation
Input parameter of type Text
ToLocation
Input parameter of type Text
InTransitCode
Input parameter of type Text

Remarks

The relevant search keywords are: Create, Transfer, Header.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(TransferHeader);
      TransferHeader.INIT;
      TransferHeader.INSERT(TRUE);
      TransferHeader.VALIDATE("Transfer-from Code",FromLocation);
      TransferHeader.VALIDATE("Transfer-to Code",ToLocation);
      TransferHeader.VALIDATE("In-Transit Code",InTransitCode);
      TransferHeader.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 136121 to show one way of using this function.

      Location2.SETRANGE("Use As In-Transit",TRUE);
      Location2.FINDFIRST;
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location);
      LibraryWarehouse.CreateTransferHeader(TransferHeader,FromLocationCode,Location.Code,Location2.Code);
      LibraryWarehouse.CreateTransferLine(TransferHeader,TransferLine,ItemNo,OriginalQuantity);
      TransferLine.VALIDATE("Receipt Date",CALCDATE('<' + FORMAT(RANDOM(5)) + 'M>',WORKDATE));  // Used Random to calculate Receipt Date.
      TransferLine.VALIDATE("Qty. to Ship",OriginalQuantity);
      TransferLine.MODIFY(TRUE);
Member of Lib.Library - Warehouse


CreateTransferLine@41 Method

The procedure CreateTransferLine is available in codeunit 132204.

Syntax

CreateTransferLine@41(
    VAR TransferHeader@1000 : Record 5740 TransferHeader, //Reference parameter of type Record
    VAR TransferLine@1001 : Record 5741 TransferLine, //Reference parameter of type Record
    ItemNo@1002 : Text[20] ItemNo, //Input parameter of type Text
    Quantity@1004 : Decimal Quantity //Input parameter of type Decimal
);

Parameters

TransferHeader
Reference parameter of type Record
TransferLine
Reference parameter of type Record
ItemNo
Input parameter of type Text
Quantity
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Transfer, Line.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(TransferLine);
      TransferLine.INIT;
      TransferLine.VALIDATE("Document No.",TransferHeader."No.");
      RecRef.GETTABLE(TransferLine);
      TransferLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,TransferLine.FIELDNO("Line No.")));
      TransferLine.INSERT(TRUE);
      TransferLine.VALIDATE("Item No.",ItemNo);
      TransferLine.VALIDATE(Quantity,Quantity);
      TransferLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 136121 to show one way of using this function.

      Location2.SETRANGE("Use As In-Transit",TRUE);
      Location2.FINDFIRST;
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location);
      LibraryWarehouse.CreateTransferHeader(TransferHeader,FromLocationCode,Location.Code,Location2.Code);
      LibraryWarehouse.CreateTransferLine(TransferHeader,TransferLine,ItemNo,OriginalQuantity);
      TransferLine.VALIDATE("Receipt Date",CALCDATE('<' + FORMAT(RANDOM(5)) + 'M>',WORKDATE));  // Used Random to calculate Receipt Date.
      TransferLine.VALIDATE("Qty. to Ship",OriginalQuantity);
      TransferLine.MODIFY(TRUE);
Member of Lib.Library - Warehouse


CreateTransferLocations@39 Method

The procedure CreateTransferLocations is available in codeunit 132204.

Syntax

CreateTransferLocations@39(
    VAR FromLocation@1004 : Record 14 FromLocation, //Reference parameter of type Record
    VAR ToLocation@1001 : Record 14 ToLocation, //Reference parameter of type Record
    VAR InTransitLocation@1002 : Record 14 InTransitLocation //Reference parameter of type Record
);

Parameters

FromLocation
Reference parameter of type Record
ToLocation
Reference parameter of type Record
InTransitLocation
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Transfer, Locations.

For a clarification about how this function works, refer to the code listed below.

      CreateLocationWithInventoryPostingSetup(FromLocation);
      CreateLocationWithInventoryPostingSetup(ToLocation);
      CreateInTransitLocation(InTransitLocation);

Example

The below example is extracted from the test automation codeunit 137001 to show one way of using this function.

      // [FEATURE] [Adjust Cost Item Entries] [Item Charges] [Transfer] [FIFO] [Purchase]
      // [SCENARIO] Check Unit cost and Value entries for FIFO Item after purchase, transfer and Adjust Cost

      // [GIVEN] Demo data and app parameters set-up. 2 simple locations, 1 in-transit location.
      Initialize;

      SetupParameters(InventorySetup."Automatic Cost Adjustment"::Never,InventorySetup."Average Cost Calc. Type"::Item);

      LibraryWarehouse.CreateTransferLocations(Location,Location1,Location2);

      // [GIVEN] Item with costing method FIFO.
      CreateItem(Item,Item."Costing Method"::FIFO,Item."Replenishment System"::Purchase);

      // [GIVEN] Posted purchase order for FIFO item, for location A.
      CreateSingleLinePurchaseOrder(PurchaseHeader,Item."No.",PurchaseLine.Type::Item);
      UpdatePurchaseLine(PurchaseLine,PurchaseHeader,Item."No.",Location.Code);
      PostPurchaseOrder(PurchInvHeader,PurchaseHeader);

      // [GIVEN] Posted a transfer order from location A to location B.
      CreateSingleLineTransferOrder(TransferHeader,TransferLine,Location,Location1,Location2,Item);
      LibraryWarehouse.PostTransferOrder(TransferHeader,TRUE,TRUE);

      // [GIVEN] Item charge added to the purchase order and purchase order invoiced.
      LibraryInventory.CreateItemCharge(ItemCharge);
      CreateSingleLinePurchaseOrder(PurchaseHeader,ItemCharge."No.",PurchaseLine.Type::"Charge (Item)");
      AssignItemCharges(PurchaseHeader,Item."No.");
      PostPurchaseOrder(PurchInvHeader1,PurchaseHeader);

      // [WHEN] Adjust cost-item entries is run.
      LibraryCosting.AdjustCostItemEntries(Item."No.",'');

      // [THEN] Unit cost and value entries for item are correct.
      CheckTransferValueEntries(
        PurchInvHeader,
        PurchInvHeader1,
        ValueEntry."Document Type"::"Transfer Shipment",
        Item."No.",
        Location.Code,
        TransferLine.Quantity,
        -1);
      CheckTransferValueEntries(
        PurchInvHeader,PurchInvHeader1,ValueEntry."Document Type"::"Transfer Shipment",
        Item."No.",Location2.Code,TransferLine.Quantity,1);
      CheckTransferValueEntries(
        PurchInvHeader,
        PurchInvHeader1,
        ValueEntry."Document Type"::"Transfer Receipt",
        Item."No.",
        Location2.Code,
        TransferLine.Quantity,
        -1);
      CheckTransferValueEntries(
        PurchInvHeader,
        PurchInvHeader1,
        ValueEntry."Document Type"::"Transfer Receipt",
        Item."No.",
        Location1.Code,
        TransferLine.Quantity,
        1);

      // [THEN] Item ledger entries number is correct for item.
      Assert.AreEqual(
        GetNoOfEntries(
          Item."No.",
          ValueEntry."Item Ledger Entry Type"::Transfer,
          ValueEntry."Entry Type"::"Direct Cost",
          ValueEntry."Document Type"::"Transfer Shipment"),4,
        STRSUBSTNO(ErrorValueEntries,4,'Transfer','Direct Cost','Transfer Shipment',Item."No."));
      Assert.AreEqual(
        GetNoOfEntries(
          Item."No.",
          ValueEntry."Item Ledger Entry Type"::Transfer,
          ValueEntry."Entry Type"::"Direct Cost",
          ValueEntry."Document Type"::"Transfer Receipt"),4,
        STRSUBSTNO(ErrorValueEntries,4,'Transfer','Direct Cost','Transfer Receipt',Item."No."));

      // Tier Down.
      SetupParameters(InventorySetup."Automatic Cost Adjustment"::Never,InventorySetup."Average Cost Calc. Type"::Item);
Member of Lib.Library - Warehouse


CreateTransferRoute@40 Method

The procedure CreateTransferRoute is available in codeunit 132204.

Syntax

CreateTransferRoute@40(
    VAR TransferRoute@1000 : Record 5742 TransferRoute, //Reference parameter of type Record
    TransferFrom@1001 : Code[10] TransferFrom, //Input parameter of type Code
    TransferTo@1002 : Code[10] TransferTo //Input parameter of type Code
);

Parameters

TransferRoute
Reference parameter of type Record
TransferFrom
Input parameter of type Code
TransferTo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Transfer, Route.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(TransferRoute);
      TransferRoute.INIT;
      TransferRoute.VALIDATE("Transfer-from Code",TransferFrom);
      TransferRoute.VALIDATE("Transfer-to Code",TransferTo);
      TransferRoute.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137008 to show one way of using this function.

      // [FEATURE] [Requisition Worksheet]
      // [SCENARIO 259107] Replenishment via transfer should be planned for item on a location with inbound handling time and "Respect Planning Parameters for Supply Triggered Safety Stock"

      Initialize;

      // [GIVEN] Location "A"
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location[1]);
      // [GIVEN] Location "B" with 1 day inbound handling time
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location[2]);
      EVALUATE(Location[2]."Inbound Whse. Handling Time",'<1D>');
      Location[2].MODIFY(TRUE);
      LibraryInventory.CreateTransferRoute(TransferRoute,Location[1].Code,Location[2].Code);

      // [GIVEN] Item "I" with a stockkeeping unit on the location "B"
      // [GIVEN] Item is configured to be replenished by a transfer from location "A". Reordering policy is "Maximum Qty.", "Maximum Inventory" is "X"
      LibraryInventory.CreateItem(Item);
      LibraryInventory.CreateStockkeepingUnitForLocationAndVariant(SKU,Location[2].Code,Item."No.",'');
      SKU.VALIDATE("Reordering Policy",SKU."Reordering Policy"::"Maximum Qty.");
      SKU.VALIDATE("Reorder Point",LibraryRandom.RandIntInRange(10,20));
      SKU.VALIDATE("Maximum Inventory",SKU."Reorder Point" * 2);
      SKU.VALIDATE("Replenishment System",SKU."Replenishment System"::Transfer);
      SKU.VALIDATE("Transfer-from Code",Location[1].Code);
      SKU.MODIFY(TRUE);

      // [GIVEN] Sales order for item "I" on location "B", "Quantity" = "Y"
      LibrarySales.CreateSalesHeader(SalesHeader,SalesHeader."Document Type"::Order,LibrarySales.CreateCustomerNo);
      CreateSalesLineOnLocation(SalesLine,SalesHeader,Item."No.",LibraryRandom.RandInt(20),Location[2].Code);

      // [WHEN] Calculate requisition plan for item "I" and location "B" with the option "Respect Planning Parameters for Supply Triggered Safety Stock"
      CalculatePlanInRequisitionWorksheet(Item,Location[2].Code,WORKDATE,WORKDATE + 1);

      // [THEN] Quantity planned for replenishment "X" + "Y", transfer is planned on work date
      RequisitionLine.SETRANGE(Type,RequisitionLine.Type::Item);
      RequisitionLine.SETRANGE("No.",Item."No.");
      RequisitionLine.FINDFIRST;
      RequisitionLine.TESTFIELD(Quantity,SKU."Maximum Inventory" + SalesLine.Quantity);
      RequisitionLine.TESTFIELD("Due Date",WORKDATE);
Member of Lib.Library - Warehouse


CreateWarehouseClass@10 Method

The procedure CreateWarehouseClass is available in codeunit 132204.

Syntax

CreateWarehouseClass@10(
    VAR WarehouseClass@1000 : Record 7304 WarehouseClass //Reference parameter of type Record
);

Parameters

WarehouseClass
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Warehouse, Class.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(WarehouseClass);
      WarehouseClass.INIT;
      WarehouseClass.VALIDATE(Code,LibraryUtility.GenerateRandomCode(WarehouseClass.FIELDNO(Code),DATABASE::"Warehouse Class"));
      WarehouseClass.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137056 to show one way of using this function.

      LibraryWarehouse.CreateWarehouseClass(WarehouseClass);
      LibraryInventory.CreateProductGroup(ProductGroup,'');
      ProductGroup.VALIDATE("Warehouse Class Code",WarehouseClass.Code);
      ProductGroup.MODIFY(TRUE);
Member of Lib.Library - Warehouse


CreateWarehouseEmployee@58 Method

The procedure CreateWarehouseEmployee is available in codeunit 132204.

Syntax

CreateWarehouseEmployee@58(
    VAR WarehouseEmployee@1000 : Record 7301 WarehouseEmployee, //Reference parameter of type Record
    LocationCode@1001 : Code[10] LocationCode, //Input parameter of type Code
    IsDefault@1002 : Boolean IsDefault //Input parameter of type Boolean
);

Parameters

WarehouseEmployee
Reference parameter of type Record
LocationCode
Input parameter of type Code
IsDefault
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, Warehouse, Employee.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(WarehouseEmployee);
      IF USERID = '' THEN
        EXIT; // for native database
      IF WarehouseEmployee.GET(USERID,LocationCode) THEN
        EXIT;

      WarehouseEmployee.RESET;
      WarehouseEmployee.SETRANGE("User ID",USERID);
      WarehouseEmployee.SETRANGE(Default,TRUE);
      IF WarehouseEmployee.FINDSET AND IsDefault THEN
        EXIT;

      WarehouseEmployee.INIT;
      WarehouseEmployee.VALIDATE("User ID",USERID);
      WarehouseEmployee.VALIDATE("Location Code",LocationCode);
      WarehouseEmployee.VALIDATE(Default,IsDefault);
      WarehouseEmployee.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134327 to show one way of using this function.

      // Test if Post a Purchase Order with Warehouse Location and verify Posted Purchase Receipt Entry.

      // Setup
      Initialize;

      // Exercise: Create Purchase Order for Warehouse Location. Using RANDOM Quantity for Purchase Line, value is not important.
      CreatePurchaseDocument(PurchaseHeader,PurchaseLine,CreateVendor,PurchaseHeader."Document Type"::Order);
      ModifyLocationOnPurchaseLine(PurchaseLine);
      LibraryWarehouse.CreateWarehouseEmployee(WarehouseEmployee,PurchaseLine."Location Code",FALSE);
      PostedDocumentNo := NoSeriesManagement.GetNextNo(PurchaseHeader."Receiving No. Series",WORKDATE,FALSE);
      LibraryPurchase.ReleasePurchaseDocument(PurchaseHeader);
      LibraryWarehouse.CreateWhseReceiptFromPO(PurchaseHeader);

      // Post Warehouse Document as Receive.
      ReceiveWarehouseDocument(PurchaseHeader."No.",PurchaseLine."Line No.");

      // Verify: Verify Quantity Posted Receipt Document.
      PurchRcptLine.SETRANGE("Document No.",PostedDocumentNo);
      PurchRcptLine.FINDFIRST;
      PurchaseLine.GET(PurchaseLine."Document Type",PurchaseLine."Document No.",PurchaseLine."Line No.");
      Assert.AreEqual(
        PurchaseLine."Quantity Received",PurchRcptLine.Quantity,STRSUBSTNO(FieldErr,PurchaseLine.TABLECAPTION,
          PurchRcptLine.TABLECAPTION));

      // Tear Down: Rollback Setup changes for Location and Warehouse Employee.
      ModifyWarehouseLocation(FALSE);
      WarehouseEmployee.GET(USERID,PurchaseLine."Location Code");
      WarehouseEmployee.DELETE;
Member of Lib.Library - Warehouse


CreateWarehouseReceiptHeader@155 Method

The procedure CreateWarehouseReceiptHeader is available in codeunit 132204.

Syntax

CreateWarehouseReceiptHeader@155(
    VAR WarehouseReceiptHeader@1000 : Record 7316 WarehouseReceiptHeader //Reference parameter of type Record
);

Parameters

WarehouseReceiptHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Warehouse, Receipt, Header.

For a clarification about how this function works, refer to the code listed below.

      WarehouseReceiptHeader.INIT;
      WarehouseReceiptHeader.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134900 to show one way of using this function.

      LibraryWarehouse.CreateWarehouseReceiptHeader(WarehouseReceiptHeader);
      WarehouseReceiptHeader.VALIDATE("Location Code",LocationCode);
      WarehouseReceiptHeader.MODIFY(TRUE);
Member of Lib.Library - Warehouse


CreateWarehouseShipmentHeader@3 Method

The procedure CreateWarehouseShipmentHeader is available in codeunit 132204.

Syntax

CreateWarehouseShipmentHeader@3(
    VAR WarehouseShipmentHeader@1000 : Record 7320 WarehouseShipmentHeader //Reference parameter of type Record
);

Parameters

WarehouseShipmentHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Warehouse, Shipment, Header.

For a clarification about how this function works, refer to the code listed below.

      WarehouseShipmentHeader.INIT;
      WarehouseShipmentHeader.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136140 to show one way of using this function.

      LibraryWarehouse.CreateWarehouseShipmentHeader(WarehouseShipmentHeader);
      WarehouseShipmentHeader.VALIDATE("Location Code",LocationCode);
      WarehouseShipmentHeader.MODIFY(TRUE);
      EXIT(WarehouseShipmentHeader."No.");
Member of Lib.Library - Warehouse


CreateWarehouseShipmentLine@38 Method

The procedure CreateWarehouseShipmentLine is available in codeunit 132204.

Syntax

CreateWarehouseShipmentLine@38(
    VAR WhseShptLine@1000 : Record 7321 WhseShptLine, //Reference parameter of type Record
    WhseShptHeader@1001 : Record 7320 WhseShptHeader //Input parameter of type Record
);

Parameters

WhseShptLine
Reference parameter of type Record
WhseShptHeader
Input parameter of type Record

Remarks

The relevant search keywords are: Create, Warehouse, Shipment, Line.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(WhseShptLine);
      WhseShptLine."No." := WhseShptHeader."No.";
      RecRef.GETTABLE(WhseShptLine);
      WhseShptLine."Line No." := LibraryUtility.GetNewLineNo(RecRef,WhseShptLine.FIELDNO("Line No."));
      WhseShptLine.INSERT(TRUE);

Example

There are no examples available.
Member of Lib.Library - Warehouse


CreateWarehouseSourceFilter@5 Method

The procedure CreateWarehouseSourceFilter is available in codeunit 132204.

Syntax

CreateWarehouseSourceFilter@5(
    VAR WarehouseSourceFilter@1000 : Record 5771 WarehouseSourceFilter, //Reference parameter of type Record
    Type@1001 : Option Type //Input parameter of type Option
);

Parameters

WarehouseSourceFilter
Reference parameter of type Record
Type
Input parameter of type Option

Remarks

The relevant search keywords are: Create, Warehouse, Source, Filter.

For a clarification about how this function works, refer to the code listed below.

      // Create Warehouse source filter to get Source Document.
      WarehouseSourceFilter.INIT;
      WarehouseSourceFilter.VALIDATE(Type,Type);
      WarehouseSourceFilter.VALIDATE(
        Code,LibraryUtility.GenerateRandomCode(WarehouseSourceFilter.FIELDNO(Code),DATABASE::"Warehouse Source Filter"));
      WarehouseSourceFilter.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136140 to show one way of using this function.

      Initialize;

      // SETUP: Create Service order and Sales order on WHITE Location
      LibraryInventory.CreateItem(Item);
      CreateServiceOrderAndServiceLines(ServiceHeader,Item."No.",RANDOM(100),WMSFullLocation);
      CreateAndReleaseSalesOrder(SalesHeader,Item."No.",WMSFullLocation,RANDOM(100),FALSE);

      // EXECUTE: Create Warehouse shipment on this order
      LibraryService.ReleaseServiceDocument(ServiceHeader);
      CreateWareHouseShipmentHeader(WarehouseShipmentHeader,WMSFullLocation);
      LibraryWarehouse.CreateWarehouseSourceFilter(WarehouseSourceFilter,WarehouseSourceFilter.Type::Outbound);
      WarehouseSourceFilter.VALIDATE("Service Orders",TRUE);
      WarehouseSourceFilter.VALIDATE("Sales Orders",FALSE);
      WarehouseSourceFilter.VALIDATE("Source No. Filter",ServiceHeader."No." + '|' + SalesHeader."No.");
      WarehouseSourceFilter.MODIFY(TRUE);
      LibraryWarehouse.GetSourceDocumentsShipment(WarehouseShipmentHeader,WarehouseSourceFilter,WMSFullLocation);

      // Verify: Whse shipments have been created and only service line has been pulled in
      GetWarehouseShipmentLinesByShipmentHeader(WarehouseShipmentLine,WarehouseShipmentHeader);
      GetAllServiceLinesOfTypeItem(ServiceLine,ServiceHeader);
      Assert.AreEqual(1,WarehouseShipmentLine.COUNT,'Only one line has been pulled into the warehouse shipment');
      VerifyWarehouseShipmentLines(WarehouseShipmentLine,ServiceLine);
Member of Lib.Library - Warehouse


CreateWhseInternalPickHeader@66 Method

The procedure CreateWhseInternalPickHeader is available in codeunit 132204.

Syntax

CreateWhseInternalPickHeader@66(
    VAR WhseInternalPickHeader@1000 : Record 7333 WhseInternalPickHeader, //Reference parameter of type Record
    LocationCode@1001 : Code[10] LocationCode //Input parameter of type Code
);

Parameters

WhseInternalPickHeader
Reference parameter of type Record
LocationCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Warehouse, Internal, Pick, Header.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(WhseInternalPickHeader);
      WhseInternalPickHeader.VALIDATE("Location Code",LocationCode);
      WhseInternalPickHeader.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137016 to show one way of using this function.

      Location.GET(LocationCode);
      CASE DocumentType OF
        DocumentType::Shipment:
          BEGIN
            CreateReserveSalesOrder(SalesHeader,SalesLine,ItemNo,LocationCode,Qty,QtyToReserve);
            LibrarySales.ReleaseSalesDocument(SalesHeader);
            LibraryWarehouse.CreateWhseShipmentFromSO(SalesHeader);
            WhseShipmentLine.SETRANGE("Source Document",WhseShipmentLine."Source Document"::"Sales Order");
            WhseShipmentLine.SETRANGE("Source No.",SalesHeader."No.");
            WhseShipmentLine.FINDFIRST;
            TempWhseShipmentLine := WhseShipmentLine;
            TempWhseShipmentLine.INSERT;
            IF WhseShipmentLine."Bin Code" = '' THEN BEGIN
              GetZoneAndBin(ZoneCode,BinCode,LocationCode,ItemNo,FALSE);
              IF BinCode <> '' THEN
                WhseShipmentLine."Bin Code" := BinCode;
            END;
            WhseShipmentLine.MODIFY(TRUE);
            WhseShipmentHeader.GET(WhseShipmentLine."No.");
            BinContent.SETRANGE("Location Code",LocationCode);
            BinContent.SETRANGE("Item No.",ItemNo);
            BinContent.SETFILTER("Bin Code",'<>%1',WhseShipmentLine."Bin Code");
            IF Location."Bin Mandatory" AND
               (BinContent.COUNT = 0)
            THEN BEGIN // Item exists in the same bin as specified on the warehouse shipment line.
              ASSERTERROR LibraryWarehouse.CreatePick(WhseShipmentHeader);
              Assert.IsTrue(STRPOS(GETLASTERRORTEXT,ErrorNothingToHandle) > 0,
                'Creating picks with same bin on Take & Place lines not allowed');
              CLEARLASTERROR;
              Bin.SETRANGE("Location Code",LocationCode);
              Bin.SETFILTER(Code,'<>%1',WhseShipmentLine."Bin Code");
              Bin.FINDFIRST;
              WhseShipmentHeader.GET(WhseShipmentLine."No.");
              LibraryWarehouse.ReopenWhseShipment(WhseShipmentHeader);
              WhseShipmentLine.VALIDATE("Bin Code",Bin.Code);
              WhseShipmentLine.MODIFY(TRUE);
            END;
            LibraryWarehouse.CreatePick(WhseShipmentHeader);
            RegisterWhseActivity(
              WhseActivityLine."Activity Type"::Pick,WhseActivityLine."Source Document"::"Sales Order",
              WhseActivityLine."Whse. Document Type"::Shipment,SalesHeader."No.",WhseShipmentHeader."No.",'','',QtyToHandle);
          END;
        DocumentType::"Int. Pick":
          BEGIN
            LibraryWarehouse.CreateWhseInternalPickHeader(WhseInternalPickHeader,LocationCode);
            GetZoneAndBin(ZoneCode,BinCode,LocationCode,'',FALSE);
            WhseInternalPickHeader."To Zone Code" := ZoneCode;
            WhseInternalPickHeader."To Bin Code" := BinCode;
            WhseInternalPickHeader.MODIFY(TRUE);
            LibraryWarehouse.CreateWhseInternalPickLine(WhseInternalPickHeader,WhseInternalPickLine,ItemNo,Qty);
            TempWhseInternalPickLine := WhseInternalPickLine;
            TempWhseInternalPickLine.INSERT;
            CreatePickFromInternalPick(WhseInternalPickHeader);
            RegisterWhseActivity(
              WhseActivityLine."Activity Type"::Pick,WhseActivityLine."Source Document"::" ",
              WhseActivityLine."Whse. Document Type"::"Internal Pick",WhseInternalPickHeader."No.",WhseInternalPickHeader."No.",
              '','',QtyToHandle);
          END;
        DocumentType::"Sales Order":
          BEGIN
            CreateReserveSalesOrder(SalesHeader,SalesLine,ItemNo,LocationCode,Qty,QtyToReserve);
            LibrarySales.ReleaseSalesDocument(SalesHeader);
            TempSalesLine := SalesLine;
            TempSalesLine.INSERT;
            CreateInvtPutPick(WhseActivityLine."Source Document"::"Sales Order",SalesHeader."No.");
            RegisterWhseActivity(
              WhseActivityLine."Activity Type"::"Invt. Pick",WhseActivityLine."Source Document"::"Sales Order",
              WhseActivityLine."Whse. Document Type"::" ",SalesHeader."No.",'','','',QtyToHandle);
          END;
        DocumentType::"Transfer Order":
          BEGIN
            CreateReserveTransferOrder(
              TransferHeader,TransferLine,ItemNo,LocationCode,Qty,QtyToReserve);
            ReleaseTransferDocument.RUN(TransferHeader);
            TempTransferLine := TransferLine;
            TempTransferLine.INSERT;
            CreateInvtPutPick(WhseActivityLine."Source Document"::"Outbound Transfer",TransferHeader."No.");
            RegisterWhseActivity(
              WhseActivityLine."Activity Type"::"Invt. Pick",WhseActivityLine."Source Document"::"Outbound Transfer",
              WhseActivityLine."Whse. Document Type"::" ",TransferHeader."No.",'','','',QtyToHandle);
          END;
        DocumentType::"Rel. Prod. Order":
          BEGIN
            CreateReserveProdOrder(ProductionOrder,LocationCode,ItemNo,Qty,QtyToReserve);
            ProdOrderComponent.SETRANGE("Prod. Order No.",ProductionOrder."No.");
            ProdOrderComponent.SETRANGE(Status,ProductionOrder.Status);
            ProdOrderComponent.SETRANGE("Item No.",ItemNo);
            ProdOrderComponent.FINDFIRST;
            TempProdOrderComponent := ProdOrderComponent;
            TempProdOrderComponent.INSERT;
            ProductionOrder.SetHideValidationDialog(TRUE);
            ProductionOrder.CreatePick(USERID,0,FALSE,FALSE,FALSE);
            IF NOT Location."Directed Put-away and Pick" THEN
              GetZoneAndBin(ZoneCode,BinCode,LocationCode,ItemNo,FALSE)
            ELSE
              BinCode := '';
            RegisterWhseActivity(
              WhseActivityLine."Activity Type"::Pick,WhseActivityLine."Source Document"::"Prod. Consumption",
              WhseActivityLine."Whse. Document Type"::Production,ProductionOrder."No.",ProductionOrder."No.",'',BinCode,QtyToHandle);
          END;
        DocumentType::"Rel. Prod. Order - Invt.":
          BEGIN
            CreateReserveProdOrder(ProductionOrder,LocationCode,ItemNo,Qty,QtyToReserve);
            ProdOrderComponent.SETRANGE("Prod. Order No.",ProductionOrder."No.");
            ProdOrderComponent.SETRANGE(Status,ProductionOrder.Status);
            ProdOrderComponent.SETRANGE("Item No.",ItemNo);
            ProdOrderComponent.FINDFIRST;
            TempProdOrderComponent := ProdOrderComponent;
            TempProdOrderComponent.INSERT;
            CreateInvtPutPick(WhseActivityLine."Source Document"::"Prod. Consumption",ProductionOrder."No.");
            RegisterWhseActivity(
              WhseActivityLine."Activity Type"::"Invt. Pick",WhseActivityLine."Source Document"::"Prod. Consumption",
              WhseActivityLine."Whse. Document Type"::" ",ProductionOrder."No.",'','','',QtyToHandle);
          END;
      END
Member of Lib.Library - Warehouse


CreateWhseInternalPickLine@63 Method

The procedure CreateWhseInternalPickLine is available in codeunit 132204.

Syntax

CreateWhseInternalPickLine@63(
    WhseInternalPickHeader@1000 : Record 7333 WhseInternalPickHeader, //Input parameter of type Record
    VAR WhseInternalPickLine@1002 : Record 7334 WhseInternalPickLine, //Reference parameter of type Record
    ItemNo@1001 : Code[20] ItemNo, //Input parameter of type Code
    Qty@1003 : Decimal Qty //Input parameter of type Decimal
);

Parameters

WhseInternalPickHeader
Input parameter of type Record
WhseInternalPickLine
Reference parameter of type Record
ItemNo
Input parameter of type Code
Qty
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Warehouse, Internal, Pick, Line.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(WhseInternalPickLine);
      WhseInternalPickLine.VALIDATE("No.",WhseInternalPickHeader."No.");
      RecRef.GETTABLE(WhseInternalPickLine);
      WhseInternalPickLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,WhseInternalPickLine.FIELDNO("Line No.")));
      WhseInternalPickLine.VALIDATE("Item No.",ItemNo);
      WhseInternalPickLine.VALIDATE(Quantity,Qty);
      WhseInternalPickLine.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137016 to show one way of using this function.

      Location.GET(LocationCode);
      CASE DocumentType OF
        DocumentType::Shipment:
          BEGIN
            CreateReserveSalesOrder(SalesHeader,SalesLine,ItemNo,LocationCode,Qty,QtyToReserve);
            LibrarySales.ReleaseSalesDocument(SalesHeader);
            LibraryWarehouse.CreateWhseShipmentFromSO(SalesHeader);
            WhseShipmentLine.SETRANGE("Source Document",WhseShipmentLine."Source Document"::"Sales Order");
            WhseShipmentLine.SETRANGE("Source No.",SalesHeader."No.");
            WhseShipmentLine.FINDFIRST;
            TempWhseShipmentLine := WhseShipmentLine;
            TempWhseShipmentLine.INSERT;
            IF WhseShipmentLine."Bin Code" = '' THEN BEGIN
              GetZoneAndBin(ZoneCode,BinCode,LocationCode,ItemNo,FALSE);
              IF BinCode <> '' THEN
                WhseShipmentLine."Bin Code" := BinCode;
            END;
            WhseShipmentLine.MODIFY(TRUE);
            WhseShipmentHeader.GET(WhseShipmentLine."No.");
            BinContent.SETRANGE("Location Code",LocationCode);
            BinContent.SETRANGE("Item No.",ItemNo);
            BinContent.SETFILTER("Bin Code",'<>%1',WhseShipmentLine."Bin Code");
            IF Location."Bin Mandatory" AND
               (BinContent.COUNT = 0)
            THEN BEGIN // Item exists in the same bin as specified on the warehouse shipment line.
              ASSERTERROR LibraryWarehouse.CreatePick(WhseShipmentHeader);
              Assert.IsTrue(STRPOS(GETLASTERRORTEXT,ErrorNothingToHandle) > 0,
                'Creating picks with same bin on Take & Place lines not allowed');
              CLEARLASTERROR;
              Bin.SETRANGE("Location Code",LocationCode);
              Bin.SETFILTER(Code,'<>%1',WhseShipmentLine."Bin Code");
              Bin.FINDFIRST;
              WhseShipmentHeader.GET(WhseShipmentLine."No.");
              LibraryWarehouse.ReopenWhseShipment(WhseShipmentHeader);
              WhseShipmentLine.VALIDATE("Bin Code",Bin.Code);
              WhseShipmentLine.MODIFY(TRUE);
            END;
            LibraryWarehouse.CreatePick(WhseShipmentHeader);
            RegisterWhseActivity(
              WhseActivityLine."Activity Type"::Pick,WhseActivityLine."Source Document"::"Sales Order",
              WhseActivityLine."Whse. Document Type"::Shipment,SalesHeader."No.",WhseShipmentHeader."No.",'','',QtyToHandle);
          END;
        DocumentType::"Int. Pick":
          BEGIN
            LibraryWarehouse.CreateWhseInternalPickHeader(WhseInternalPickHeader,LocationCode);
            GetZoneAndBin(ZoneCode,BinCode,LocationCode,'',FALSE);
            WhseInternalPickHeader."To Zone Code" := ZoneCode;
            WhseInternalPickHeader."To Bin Code" := BinCode;
            WhseInternalPickHeader.MODIFY(TRUE);
            LibraryWarehouse.CreateWhseInternalPickLine(WhseInternalPickHeader,WhseInternalPickLine,ItemNo,Qty);
            TempWhseInternalPickLine := WhseInternalPickLine;
            TempWhseInternalPickLine.INSERT;
            CreatePickFromInternalPick(WhseInternalPickHeader);
            RegisterWhseActivity(
              WhseActivityLine."Activity Type"::Pick,WhseActivityLine."Source Document"::" ",
              WhseActivityLine."Whse. Document Type"::"Internal Pick",WhseInternalPickHeader."No.",WhseInternalPickHeader."No.",
              '','',QtyToHandle);
          END;
        DocumentType::"Sales Order":
          BEGIN
            CreateReserveSalesOrder(SalesHeader,SalesLine,ItemNo,LocationCode,Qty,QtyToReserve);
            LibrarySales.ReleaseSalesDocument(SalesHeader);
            TempSalesLine := SalesLine;
            TempSalesLine.INSERT;
            CreateInvtPutPick(WhseActivityLine."Source Document"::"Sales Order",SalesHeader."No.");
            RegisterWhseActivity(
              WhseActivityLine."Activity Type"::"Invt. Pick",WhseActivityLine."Source Document"::"Sales Order",
              WhseActivityLine."Whse. Document Type"::" ",SalesHeader."No.",'','','',QtyToHandle);
          END;
        DocumentType::"Transfer Order":
          BEGIN
            CreateReserveTransferOrder(
              TransferHeader,TransferLine,ItemNo,LocationCode,Qty,QtyToReserve);
            ReleaseTransferDocument.RUN(TransferHeader);
            TempTransferLine := TransferLine;
            TempTransferLine.INSERT;
            CreateInvtPutPick(WhseActivityLine."Source Document"::"Outbound Transfer",TransferHeader."No.");
            RegisterWhseActivity(
              WhseActivityLine."Activity Type"::"Invt. Pick",WhseActivityLine."Source Document"::"Outbound Transfer",
              WhseActivityLine."Whse. Document Type"::" ",TransferHeader."No.",'','','',QtyToHandle);
          END;
        DocumentType::"Rel. Prod. Order":
          BEGIN
            CreateReserveProdOrder(ProductionOrder,LocationCode,ItemNo,Qty,QtyToReserve);
            ProdOrderComponent.SETRANGE("Prod. Order No.",ProductionOrder."No.");
            ProdOrderComponent.SETRANGE(Status,ProductionOrder.Status);
            ProdOrderComponent.SETRANGE("Item No.",ItemNo);
            ProdOrderComponent.FINDFIRST;
            TempProdOrderComponent := ProdOrderComponent;
            TempProdOrderComponent.INSERT;
            ProductionOrder.SetHideValidationDialog(TRUE);
            ProductionOrder.CreatePick(USERID,0,FALSE,FALSE,FALSE);
            IF NOT Location."Directed Put-away and Pick" THEN
              GetZoneAndBin(ZoneCode,BinCode,LocationCode,ItemNo,FALSE)
            ELSE
              BinCode := '';
            RegisterWhseActivity(
              WhseActivityLine."Activity Type"::Pick,WhseActivityLine."Source Document"::"Prod. Consumption",
              WhseActivityLine."Whse. Document Type"::Production,ProductionOrder."No.",ProductionOrder."No.",'',BinCode,QtyToHandle);
          END;
        DocumentType::"Rel. Prod. Order - Invt.":
          BEGIN
            CreateReserveProdOrder(ProductionOrder,LocationCode,ItemNo,Qty,QtyToReserve);
            ProdOrderComponent.SETRANGE("Prod. Order No.",ProductionOrder."No.");
            ProdOrderComponent.SETRANGE(Status,ProductionOrder.Status);
            ProdOrderComponent.SETRANGE("Item No.",ItemNo);
            ProdOrderComponent.FINDFIRST;
            TempProdOrderComponent := ProdOrderComponent;
            TempProdOrderComponent.INSERT;
            CreateInvtPutPick(WhseActivityLine."Source Document"::"Prod. Consumption",ProductionOrder."No.");
            RegisterWhseActivity(
              WhseActivityLine."Activity Type"::"Invt. Pick",WhseActivityLine."Source Document"::"Prod. Consumption",
              WhseActivityLine."Whse. Document Type"::" ",ProductionOrder."No.",'','','',QtyToHandle);
          END;
      END
Member of Lib.Library - Warehouse


CreateWhseInternalPutawayHdr@62 Method

The procedure CreateWhseInternalPutawayHdr is available in codeunit 132204.

Syntax

CreateWhseInternalPutawayHdr@62(
    VAR WhseInternalPutAwayHeader@1000 : Record 7331 WhseInternalPutAwayHeader, //Reference parameter of type Record
    LocationCode@1001 : Code[10] LocationCode //Input parameter of type Code
);

Parameters

WhseInternalPutAwayHeader
Reference parameter of type Record
LocationCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Warehouse, Internal, Putaway, Hdr.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(WhseInternalPutAwayHeader);
      WhseInternalPutAwayHeader.VALIDATE("Location Code",LocationCode);
      WhseInternalPutAwayHeader.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137048 to show one way of using this function.

      // Test and verify an error message pops up when create Internal Put-away with Non-warehouse.

      // Setup & Exercise: Create Whse. Internal Putaway with Non-Warehouse.
      // Verify: Verify the error message.
      Initialize;
      ASSERTERROR LibraryWarehouse.CreateWhseInternalPutawayHdr(WhseInternalPutAwayHeader,LocationOrange.Code);
      Assert.ExpectedError(NonWarehouseErr);
Member of Lib.Library - Warehouse


CreateWhseInternalPutawayLine@61 Method

The procedure CreateWhseInternalPutawayLine is available in codeunit 132204.

Syntax

CreateWhseInternalPutawayLine@61(
    WhseInternalPutAwayHeader@1000 : Record 7331 WhseInternalPutAwayHeader, //Input parameter of type Record
    VAR WhseInternalPutAwayLine@1002 : Record 7332 WhseInternalPutAwayLine, //Reference parameter of type Record
    ItemNo@1001 : Code[20] ItemNo, //Input parameter of type Code
    Qty@1003 : Decimal Qty //Input parameter of type Decimal
);

Parameters

WhseInternalPutAwayHeader
Input parameter of type Record
WhseInternalPutAwayLine
Reference parameter of type Record
ItemNo
Input parameter of type Code
Qty
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Warehouse, Internal, Putaway, Line.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(WhseInternalPutAwayLine);
      WhseInternalPutAwayLine.VALIDATE("No.",WhseInternalPutAwayHeader."No.");
      RecRef.GETTABLE(WhseInternalPutAwayLine);
      WhseInternalPutAwayLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,WhseInternalPutAwayLine.FIELDNO("Line No.")));
      WhseInternalPutAwayLine.VALIDATE("Item No.",ItemNo);
      WhseInternalPutAwayLine.VALIDATE(Quantity,Qty);
      WhseInternalPutAwayLine.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137048 to show one way of using this function.

      // Setup: Create Item, find Zone, find Bin, update Inventory, create Warehouse Internal Put Away and release.
      Initialize;
      CreateItem(Item);
      UpdateInventoryOnLocationWithWhseAdjustment(LocationWhite,Item,100 + LibraryRandom.RandDec(100,2));  // For large Quantity.
      Bin.GET(LocationWhite.Code,LocationWhite."Cross-Dock Bin Code");
      CreateWhseInternalPutawayHeader(WhseInternalPutAwayHeader,Bin."Zone Code",Bin.Code);
      Quantity := LibraryRandom.RandDec(100,2);
      LibraryWarehouse.CreateWhseInternalPutawayLine(WhseInternalPutAwayHeader,WhseInternalPutAwayLine,Item."No.",Quantity);
      WhseIntPutAwayRelease.Release(WhseInternalPutAwayHeader);

      // Exercise: Create Put Away from Warehouse Internal Put Away.
      WhseInternalPutAwayLine.CreatePutAwayDoc(WhseInternalPutAwayLine);

      // Verify: Verify the values on Warehouse Activity Line.
      WarehouseActivityLine.SETRANGE("Location Code",LocationWhite.Code);
      WarehouseActivityLine.FINDFIRST;
      VerifyWhseActivityLine(WarehouseActivityLine,Item."Base Unit of Measure",1,WarehouseActivityLine.Quantity);  // Value 1 is Quantity Per Unit Of Measure.
Member of Lib.Library - Warehouse


CreateWhseJournalBatch@104 Method

The procedure CreateWhseJournalBatch is available in codeunit 132204.

Syntax

CreateWhseJournalBatch@104(
    VAR WarehouseJournalBatch@1000 : Record 7310 WarehouseJournalBatch, //Reference parameter of type Record
    WarehouseJournalTemplateName@1001 : Code[10] WarehouseJournalTemplateName, //Input parameter of type Code
    LocationCode@1002 : Code[10] LocationCode //Input parameter of type Code
);

Parameters

WarehouseJournalBatch
Reference parameter of type Record
WarehouseJournalTemplateName
Input parameter of type Code
LocationCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Warehouse, Journal, Batch.

For a clarification about how this function works, refer to the code listed below.

      // Create Item Journal Batch with a random Name of String length less than 10.
      WarehouseJournalBatch.INIT;
      WarehouseJournalBatch.VALIDATE("Journal Template Name",WarehouseJournalTemplateName);
      WarehouseJournalBatch.VALIDATE(
        Name,COPYSTR(LibraryUtility.GenerateRandomCode(WarehouseJournalBatch.FIELDNO(Name),DATABASE::"Warehouse Journal Batch"),1,
          MAXSTRLEN(WarehouseJournalBatch.Name)));
      WarehouseJournalBatch.VALIDATE("Location Code",LocationCode);
      WarehouseJournalBatch.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137047 to show one way of using this function.

      LibraryWarehouse.SelectWhseJournalTemplateName(WarehouseJournalTemplate,WarehouseJournalTemplate.Type::Item);
      LibraryWarehouse.CreateWhseJournalBatch(WarehouseJournalBatch,WarehouseJournalTemplate.Name,LocationCode);
      LibraryWarehouse.CreateWhseJournalLine(
        WarehouseJournalLine,WarehouseJournalBatch."Journal Template Name",WarehouseJournalBatch.Name,LocationCode,'',
        BinCode,WarehouseJournalLine."Entry Type"::"Positive Adjmt.",ItemNo,Quantity);
Member of Lib.Library - Warehouse


CreateWhseJournalLine@102 Method

The procedure CreateWhseJournalLine is available in codeunit 132204.

Syntax

CreateWhseJournalLine@102(
    VAR WarehouseJournalLine@1000 : Record 7311 WarehouseJournalLine, //Reference parameter of type Record
    JournalTemplateName@1001 : Code[10] JournalTemplateName, //Input parameter of type Code
    JournalBatchName@1002 : Code[10] JournalBatchName, //Input parameter of type Code
    LocationCode@1006 : Code[10] LocationCode, //Input parameter of type Code
    ZoneCode@1009 : Code[10] ZoneCode, //Input parameter of type Code
    BinCode@1010 : Code[20] BinCode, //Input parameter of type Code
    EntryType@1007 : Option EntryType, //Input parameter of type Option
    ItemNo@1005 : Text[20] ItemNo, //Input parameter of type Text
    NewQuantity@1004 : Decimal NewQuantity //Input parameter of type Decimal
);

Parameters

WarehouseJournalLine
Reference parameter of type Record
JournalTemplateName
Input parameter of type Code
JournalBatchName
Input parameter of type Code
LocationCode
Input parameter of type Code
ZoneCode
Input parameter of type Code
BinCode
Input parameter of type Code
EntryType
Input parameter of type Option
ItemNo
Input parameter of type Text
NewQuantity
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Warehouse, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      IF NOT WarehouseJournalBatch.GET(JournalTemplateName,JournalBatchName,LocationCode) THEN BEGIN
        WarehouseJournalBatch.INIT;
        WarehouseJournalBatch.VALIDATE("Journal Template Name",JournalTemplateName);
        WarehouseJournalBatch.SetupNewBatch;
        WarehouseJournalBatch.VALIDATE(Name,JournalBatchName);
        WarehouseJournalBatch.VALIDATE(Description,JournalBatchName + ' journal');
        WarehouseJournalBatch.VALIDATE("Location Code",LocationCode);
        WarehouseJournalBatch.INSERT(TRUE);
      END;

      CLEAR(WarehouseJournalLine);
      WarehouseJournalLine.INIT;
      WarehouseJournalLine.VALIDATE("Journal Template Name",JournalTemplateName);
      WarehouseJournalLine.VALIDATE("Journal Batch Name",JournalBatchName);
      WarehouseJournalLine.VALIDATE("Location Code",LocationCode);
      WarehouseJournalLine.VALIDATE("Zone Code",ZoneCode);
      WarehouseJournalLine.VALIDATE("Bin Code",BinCode);

      WarehouseJournalLine.TemplateSelection(PAGE::"Whse. Item Journal",0,WarehouseJournalLine,JnlSelected);
      Assert.IsTrue(JnlSelected,'Journal was not selected');
      WarehouseJournalLine.OpenJnl(JournalBatchName,LocationCode,WarehouseJournalLine);
      COMMIT;
      WarehouseJournalLine.SetUpNewLine(WarehouseJournalLine);

      RecRef.GETTABLE(WarehouseJournalLine);
      WarehouseJournalLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,WarehouseJournalLine.FIELDNO("Line No.")));
      WarehouseJournalLine.INSERT(TRUE);
      WarehouseJournalLine.VALIDATE("Registering Date",WORKDATE);
      WarehouseJournalLine.VALIDATE("Entry Type",EntryType);
      IF NoSeries.GET(WarehouseJournalBatch."No. Series") THEN
        DocumentNo := NoSeriesManagement.GetNextNo(WarehouseJournalBatch."No. Series",WarehouseJournalLine."Registering Date",FALSE)
      ELSE
        DocumentNo := 'Default Document No.';
      WarehouseJournalLine.VALIDATE("Whse. Document No.",DocumentNo);
      WarehouseJournalLine.VALIDATE("Item No.",ItemNo);
      WarehouseJournalLine.VALIDATE(Quantity,NewQuantity);
      WarehouseJournalLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 136140 to show one way of using this function.

      WarehouseJournalSetup(Location.Code);
      LibraryWarehouse.CreateWhseJournalLine(
        WarehouseJournalLine,WarehouseJournalBatch."Journal Template Name",WarehouseJournalBatch.Name,Location.Code,ZoneCode,BinCode,
        WarehouseJournalLine."Entry Type"::"Positive Adjmt.",Item."No.",Quantity);
      CalculateAndPostWhseAdjustment(Item,Location.Code);
Member of Lib.Library - Warehouse


CreateWhseMovement@35 Method

The procedure CreateWhseMovement is available in codeunit 132204.

Syntax

CreateWhseMovement@35(
    BatchName@1002 : Text[30] BatchName, //Input parameter of type Text
    LocationCode@1003 : Text[30] LocationCode, //Input parameter of type Text
    SortActivity@1005 : Option SortActivity, //Input parameter of type Option
    BreakBulkFilter@1006 : Boolean BreakBulkFilter, //Input parameter of type Boolean
    DoNotFillQtyToHandle@1007 : Boolean DoNotFillQtyToHandle //Input parameter of type Boolean
);

Parameters

BatchName
Input parameter of type Text
LocationCode
Input parameter of type Text
SortActivity
Input parameter of type Option
BreakBulkFilter
Input parameter of type Boolean
DoNotFillQtyToHandle
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, Warehouse, Movement.

For a clarification about how this function works, refer to the code listed below.

      WhseWorksheetLine.SETFILTER(Quantity,'>0');
      WhseWorksheetTemplate.SETRANGE(Type,WhseWorksheetTemplate.Type::Movement);
      WhseWorksheetTemplate.FINDFIRST;
      WhseWorksheetLine.SETRANGE("Worksheet Template Name",WhseWorksheetTemplate.Name);
      WhseWorksheetLine.SETRANGE(Name,BatchName);
      WhseWorksheetLine.SETRANGE("Location Code",LocationCode);
      WhseWorksheetLine.FINDFIRST;

      WhseSrcCreateDocument.SetWhseWkshLine(WhseWorksheetLine);
      WhseSrcCreateDocument.Initialize(USERID,SortActivity,FALSE,DoNotFillQtyToHandle,BreakBulkFilter);
      WhseSrcCreateDocument.USEREQUESTPAGE(FALSE);
      WhseSrcCreateDocument.RUNMODAL;
      WhseSrcCreateDocument.GetResultMessage(WarehouseActivityHeader.Type::Movement);

Example

The below example is extracted from the test automation codeunit 137065 to show one way of using this function.

      LibraryWarehouse.SelectWhseWorksheetTemplate(WhseWorksheetTemplate,WhseWorksheetTemplate.Type::Movement);
      LibraryWarehouse.SelectWhseWorksheetName(WhseWorksheetName,WhseWorksheetTemplate.Name,BinContent."Location Code");
      LibraryWarehouse.CalculateBinReplenishment(BinContent,WhseWorksheetName,BinContent."Location Code",FALSE,TRUE,FALSE);
      LibraryWarehouse.CreateWhseMovement(WhseWorksheetName.Name,BinContent."Location Code",0,FALSE,FALSE);
Member of Lib.Library - Warehouse


CreateWhsePick@81 Method

The procedure CreateWhsePick is available in codeunit 132204.

Syntax

CreateWhsePick@81(
    VAR WarehouseShipmentHeader@1000 : Record 7320 WarehouseShipmentHeader //Reference parameter of type Record
);

Parameters

WarehouseShipmentHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Warehouse, Pick.

For a clarification about how this function works, refer to the code listed below.

      WarehouseShipmentLineRec.SETRANGE("No.",WarehouseShipmentHeader."No.");
      WarehouseShipmentLineRec.FINDFIRST;
      WhseShptLine.COPY(WarehouseShipmentLineRec);
      WhseShptHeader.GET(WhseShptLine."No.");
      IF WhseShptHeader.Status = WhseShptHeader.Status::Open THEN
        WhseShipmentRelease.Release(WhseShptHeader);
      WarehouseShipmentLineRec.SetHideValidationDialog(TRUE);
      WarehouseShipmentLineRec.CreatePickDoc(WhseShptLine,WhseShptHeader);

Example

The below example is extracted from the test automation codeunit 137021 to show one way of using this function.

      // Setup
      Initialize;

      // Test setup
      TestSetup;
      LFLItemSetup(Item,TRUE,'','','',0,0,0);
      LibraryWarehouse.FindBin(Bin,LocationWhite.Code,'PICK',1);
      SetDefaultLocation(LocationWhite.Code);

      // Add inventory
      AddInventoryDirectedLocation(Item,LocationWhite.Code,'PICK',Bin.Code,10);

      // Exercise
      CreateSalesReturnOrder(SalesHeader,Item,2,CALCDATE(PlanningStartDate,CALCDATE('<+1W+1D>',WORKDATE)),LocationOne.Code);
      CreateTransferOrder(
        TransferHeader,Item."No.",LocationWhite.Code,LocationOne.Code,CALCDATE(PlanningStartDate,CALCDATE('<+1W+1D>',WORKDATE)),2);
      LibraryWarehouse.ReleaseTransferOrder(TransferHeader);
      LibraryWarehouse.CreateWhseShipmentFromTO(TransferHeader);
      GetLastWhseShipmentCreated(WarehouseShipmentHeader,LocationWhite);
      LibraryWarehouse.CreateWhsePick(WarehouseShipmentHeader);
      RegisterWarehousePick(LocationWhite,1);
      SalesPlan(Item,2,CALCDATE(PlanningStartDate,CALCDATE('<+1W+1D>',WORKDATE)),LocationOne.Code,LocationOne.Code);

      // Verify planning worksheet lines - check in doc section more info on the TDS
      AssertNoLinesForItem(Item);
Member of Lib.Library - Warehouse


CreateWhsePickFromProduction@92 Method

The procedure CreateWhsePickFromProduction is available in codeunit 132204.

Syntax

CreateWhsePickFromProduction@92(
    ProductionOrder@1000 : Record 5405 ProductionOrder //Input parameter of type Record
);

Parameters

ProductionOrder
Input parameter of type Record

Remarks

The relevant search keywords are: Create, Warehouse, Pick, From, Production.

For a clarification about how this function works, refer to the code listed below.

      ProductionOrder.SetHideValidationDialog(TRUE);
      ProductionOrder.CreatePick(USERID,0,FALSE,FALSE,FALSE);

Example

The below example is extracted from the test automation codeunit 137021 to show one way of using this function.

      // Setup
      Initialize;

      // Test setup
      TestSetup;
      LFLItemSetup(Item,TRUE,'','','',0,0,0);
      CreateBOM(ProductionBOMHeader,ChildItem,1);
      SetBOMOnItem(Item,ProductionBOMHeader);
      LibraryWarehouse.FindBin(Bin,LocationWhite.Code,'PICK',1);
      SetDefaultLocation(LocationWhite.Code);

      // Add inventory
      AddInventoryDirectedLocation(ChildItem,LocationWhite.Code,'PICK',Bin.Code,10);

      // Exercise
      CreateSalesReturnOrder(
        SalesHeader,Item,1,CALCDATE(PlanningStartDate,CALCDATE('<+1W+1D>',WORKDATE)),LocationWhite.Code);
      CreateRelProdOrderAndRefresh(
        ProductionOrder,Item."No.",1,CALCDATE(PlanningStartDate,CALCDATE('<+1W+1D>',WORKDATE)),LocationWhite.Code,'');
      LibraryWarehouse.CreateWhsePickFromProduction(ProductionOrder);
      SalesPlan(Item,1,CALCDATE(PlanningStartDate,CALCDATE('<+1W+1D>',WORKDATE)),LocationWhite.Code,LocationWhite.Code);

      // Verify planning worksheet lines - check in doc section more info on the TDS
      AssertNumberOfLinesForItem(Item,1);
      AssertPlanningLine(Item,RequisitionLine."Action Message"::Cancel,0D,
        CALCDATE(PlanningStartDate,CALCDATE('<+1W+1D>',WORKDATE)),1,0,RequisitionLine."Ref. Order Type"::"Prod. Order",'',1);
Member of Lib.Library - Warehouse


CreateWhseReceiptFromPO@109 Method

The procedure CreateWhseReceiptFromPO is available in codeunit 132204.

Syntax

CreateWhseReceiptFromPO@109(
    VAR PurchaseHeader@1000 : Record 38 PurchaseHeader //Reference parameter of type Record
);

Parameters

PurchaseHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Warehouse, Receipt, From, Purchase Order.

For a clarification about how this function works, refer to the code listed below.

      GetSourceDocInbound.CreateFromPurchOrderHideDialog(PurchaseHeader);

Example

The below example is extracted from the test automation codeunit 134327 to show one way of using this function.

      // Test if Post a Purchase Order with Warehouse Location and verify Posted Purchase Receipt Entry.

      // Setup
      Initialize;

      // Exercise: Create Purchase Order for Warehouse Location. Using RANDOM Quantity for Purchase Line, value is not important.
      CreatePurchaseDocument(PurchaseHeader,PurchaseLine,CreateVendor,PurchaseHeader."Document Type"::Order);
      ModifyLocationOnPurchaseLine(PurchaseLine);
      LibraryWarehouse.CreateWarehouseEmployee(WarehouseEmployee,PurchaseLine."Location Code",FALSE);
      PostedDocumentNo := NoSeriesManagement.GetNextNo(PurchaseHeader."Receiving No. Series",WORKDATE,FALSE);
      LibraryPurchase.ReleasePurchaseDocument(PurchaseHeader);
      LibraryWarehouse.CreateWhseReceiptFromPO(PurchaseHeader);

      // Post Warehouse Document as Receive.
      ReceiveWarehouseDocument(PurchaseHeader."No.",PurchaseLine."Line No.");

      // Verify: Verify Quantity Posted Receipt Document.
      PurchRcptLine.SETRANGE("Document No.",PostedDocumentNo);
      PurchRcptLine.FINDFIRST;
      PurchaseLine.GET(PurchaseLine."Document Type",PurchaseLine."Document No.",PurchaseLine."Line No.");
      Assert.AreEqual(
        PurchaseLine."Quantity Received",PurchRcptLine.Quantity,STRSUBSTNO(FieldErr,PurchaseLine.TABLECAPTION,
          PurchRcptLine.TABLECAPTION));

      // Tear Down: Rollback Setup changes for Location and Warehouse Employee.
      ModifyWarehouseLocation(FALSE);
      WarehouseEmployee.GET(USERID,PurchaseLine."Location Code");
      WarehouseEmployee.DELETE;
Member of Lib.Library - Warehouse


CreateWhseReceiptFromSalesReturnOrder@162 Method

The procedure CreateWhseReceiptFromSalesReturnOrder is available in codeunit 132204.

Syntax

CreateWhseReceiptFromSalesReturnOrder@162(
    VAR SalesHeader@1001 : Record 36 SalesHeader //Reference parameter of type Record
);

Parameters

SalesHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Warehouse, Receipt, From, Sales, Return, Order.

For a clarification about how this function works, refer to the code listed below.

      GetSourceDocInbound.CreateFromSalesReturnOrderHideDialog(SalesHeader);

Example

The below example is extracted from the test automation codeunit 137052 to show one way of using this function.

      // Setup: Create Item with Tracking Code, Create and Post Sales Order with Tracking, Post Warehouse Shipment.
      Initialize;
      Quantity := 2 * LibraryRandom.RandInt(10);  // Value required for Test. More than one Quantity.
      CreateItem(Item,ItemTrackingCodeSerialSpecific.Code,Item."Costing Method"::FIFO);
      // Assign Global variable for Page Handler.
      SetGlobalValue(Item."No.",TRUE,FALSE,FALSE,AssignTracking::None,0,FALSE);  // Create New Lot No -True, Assign Tracking as None and Tracking Quantity not required.
      CreateAndPostItemJournalLine(
        ItemJournalLine."Entry Type"::"Positive Adjmt.",Item."No.",LocationGreen.Code,Quantity,0,FALSE,AssignTracking::SerialNo);

      CreateAndReleaseSalesOrder(SalesHeader,SalesLine,Item."No.",LocationGreen.Code,Quantity);
      SalesLine.OpenItemTrackingLines;  // Assign Tracking on Page Handler ItemTrackingPageHandler.
      LibraryWarehouse.CreateWhseShipmentFromSO(SalesHeader);
      CreatePickFromWarehouseShipment(
        WarehouseShipmentHeader,SalesHeader."No.",WarehouseActivityLine."Source Document"::"Sales Order");
      RegisterWarehouseActivityAndPostWhseShipment(
        WarehouseShipmentHeader,SalesHeader."No.",WarehouseActivityLine."Source Document"::"Sales Order");

      // Exercise: Post Sales Order.
      PostSalesDocument(SalesHeader."Document Type",SalesHeader."No.",FALSE,TRUE);

      // Verify: Verify Tracking line on Posted Sales Shipment.
      SetGlobalValue(Item."No.",FALSE,FALSE,FALSE,AssignTracking::SerialNo,SalesLine.Quantity,FALSE);
      SelectSalesShipmentLine(SalesShipmentLine,SalesHeader."No.");
      SalesShipmentLine.ShowItemTrackingLines;  // Verify Item Tracking line on Page handler PostedLinesPageHandler.
      DocumentNo := SalesShipmentLine."Document No.";  // Assign Global variable for Page Handler.

      // Create and Post Sales Return Order with Tracking, Post Warehouse Receipt and Assign Global variable for Page Handler.
      CreateAndReleaseSalesReturnOrder(SalesHeader,SalesLine,Item."No.",LocationGreen.Code,1);  // Partial Quantity required for Test.
      SetGlobalValue(Item."No.",FALSE,TRUE,TRUE,AssignTracking::None,0,FALSE);  // Partial -True, Verify Qty To Handle -True and Tracking Quantity not required.
      SalesLine.OpenItemTrackingLines;  // Assign Tracking on Page Handler.
      LibraryWarehouse.CreateWhseReceiptFromSalesReturnOrder(SalesHeader);
      FindWhseReceiptHeaderForSalesReturn(WarehouseReceiptHeader,SalesHeader."No.");
      PostWhseReceiptAndRegisterWarehouseActivity(
        WarehouseReceiptHeader,SalesHeader."No.",WarehouseActivityLine."Source Document"::"Sales Return Order");

      // Exercise: Post Sales Return Order.
      PostSalesDocument(SalesHeader."Document Type",SalesHeader."No.",FALSE,TRUE);

      // Verify: Verify Serial and Lot No in Item Ledger Entry.
      FindReturnReceiptHeader(ReturnReceiptHeader,SalesHeader."No.");
      VerifySerialAndLotNoOnItemLedgerEntry(
        Item."No.",ItemLedgerEntry."Document Type"::"Sales Return Receipt",ReturnReceiptHeader."No.",
        ItemLedgerEntry."Document Type"::"Sales Shipment",SalesShipmentLine."Document No.");
Member of Lib.Library - Warehouse


CreateWhseReceiptFromTO@2 Method

The procedure CreateWhseReceiptFromTO is available in codeunit 132204.

Syntax

CreateWhseReceiptFromTO@2(
    VAR TransferHeader@1000 : Record 5740 TransferHeader //Reference parameter of type Record
);

Parameters

TransferHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Warehouse, Receipt, From, TO.

For a clarification about how this function works, refer to the code listed below.

      GetSourceDocInbound.CreateFromInbndTransferOrderHideDialog(TransferHeader);

Example

The below example is extracted from the test automation codeunit 137038 to show one way of using this function.

      // [FEATURE] [Transfer]
      // [SCENARIO 377487] "Qty. to Ship" in transfer order can be updated when transferring from a non-WMS location and a warehouse receipt exists in the destination location

      // [GIVEN] Location "L1" without WMS setup
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location);
      // [GIVEN] Location "L2" with warehouse receipt requirement
      LibraryWarehouse.CreateLocationWMS(WMSLocation,FALSE,FALSE,FALSE,TRUE,FALSE);

      Qty := LibraryRandom.RandIntInRange(100,200);
      CreateItemWithPositiveInventory(Item,Location.Code,Qty * 2);

      // [GIVEN] Create transfer order from "L1" to "L2". Quantity = "Q", set "Qty. to Ship" = "Q" / 2
      CreateTransferOrderNoRoute(TransferHeader,TransferLine,Location.Code,WMSLocation.Code,Item."No.",Qty * 2);

      // [GIVEN] Post transfer shipment
      TransferLine.VALIDATE("Qty. to Ship",Qty);
      TransferLine.MODIFY(TRUE);
      LibraryInventory.PostTransferHeader(TransferHeader,TRUE,FALSE);

      // [GIVEN] Create warehouse receipt on location "L2" from transfer order
      LibraryWarehouse.CreateWhseReceiptFromTO(TransferHeader);

      TransferOrder.OPENEDIT;
      TransferOrder.GOTORECORD(TransferHeader);
      // [WHEN] Change "Qty. to Ship" in transfer order line
      Qty := LibraryRandom.RandInt(TransferLine."Qty. to Ship" - 1);
      TransferOrder.TransferLines."Qty. to Ship".SETVALUE(Qty);
      TransferOrder.OK.INVOKE;

      // [THEN] New value is accepted
      TransferLine.FIND;
      TransferLine.TESTFIELD("Qty. to Ship",Qty);
Member of Lib.Library - Warehouse


CreateWhseShipmentFromPurchaseReturnOrder@161 Method

The procedure CreateWhseShipmentFromPurchaseReturnOrder is available in codeunit 132204.

Syntax

CreateWhseShipmentFromPurchaseReturnOrder@161(
    VAR PurchaseHeader@1001 : Record 38 PurchaseHeader //Reference parameter of type Record
);

Parameters

PurchaseHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Warehouse, Shipment, From, Purchase, Return, Order.

For a clarification about how this function works, refer to the code listed below.

      GetSourceDocOutbound.CreateFromPurchReturnOrderHideDialog(PurchaseHeader);

Example

The below example is extracted from the test automation codeunit 137052 to show one way of using this function.

      // Setup: Create Item with Tracking Code, Create and Post Purchase Order with Tracking, Post Warehouse Receipt.
      Initialize;
      Quantity := 2 * LibraryRandom.RandInt(10);  // Value required for Test. More than one Quantity.
      CreateItem(Item,ItemTrackingCodeSerialSpecific.Code,Item."Costing Method"::FIFO);

      // Assign Global variable for Page Handler.
      SetGlobalValue(Item."No.",TRUE,FALSE,FALSE,AssignTracking::SerialNo,0,FALSE);  // Create New Lot No -True, Assign Tracking as Serial No and Tracking Quantity not required.
      CreateAndReleasePurchaseOrderWithTracking(PurchaseHeader,Item."No.",LocationGreen.Code,Quantity,1);  // No. of Lines value required.
      LibraryWarehouse.CreateWhseReceiptFromPO(PurchaseHeader);
      FindWhseReceiptHeaderForPurchase(WarehouseReceiptHeader,PurchaseHeader."No.");
      PostWhseReceiptAndRegisterWarehouseActivity(
        WarehouseReceiptHeader,PurchaseHeader."No.",WarehouseActivityLine."Source Document"::"Purchase Order");

      // Exercise: Post Purchase Order.
      PostPurchaseDocument(PurchaseHeader."Document Type",PurchaseHeader."No.",FALSE,TRUE);

      // Verify: Verify Tracking line on Posted Purchase Receipt Line.
      SetGlobalValue(Item."No.",FALSE,FALSE,FALSE,AssignTracking::SerialNo,Quantity,FALSE);
      VerifyTrackingOnPostedPurchaseReceipt(PurchaseHeader."No.");

      // Create Purchase Return Order with Tracking, Post Warehouse Shipment.
      FindPurchRcptHeader(PurchRcptHeader,PurchaseHeader."No.");
      SetGlobalValue(Item."No.",FALSE,FALSE,FALSE,AssignTracking::None,0,FALSE);  // Assign Global variable for Page Handler.
      CreateAndReleasePurchaseReturnOrder(PurchaseHeader,Item."No.",LocationGreen.Code,Quantity / 2,1);  // Partial Quantity, No. of Lines value required.
      AssignTrackingOnPurchaseLine(PurchaseHeader."No.");  // Assign Tracking on Page HandlerItemTrackingPageHandler.
      LibraryWarehouse.CreateWhseShipmentFromPurchaseReturnOrder(PurchaseHeader);
      CreatePickFromWarehouseShipment(
        WarehouseShipmentHeader,PurchaseHeader."No.",WarehouseActivityLine."Source Document"::"Purchase Return Order");
      RegisterWarehouseActivityAndPostWhseShipment(
        WarehouseShipmentHeader,PurchaseHeader."No.",WarehouseActivityLine."Source Document"::"Purchase Return Order");

      // Exercise: Post Purchase Return Order.
      PostPurchaseDocument(PurchaseHeader."Document Type",PurchaseHeader."No.",FALSE,TRUE);

      // Verify: Verify Serial and Lot No in Item Ledger Entry.
      FindReturnShipmentHeader(ReturnShipmentHeader,PurchaseHeader."No.");
      VerifySerialAndLotNoOnItemLedgerEntry(
        Item."No.",ItemLedgerEntry."Document Type"::"Purchase Return Shipment",ReturnShipmentHeader."No.",
        ItemLedgerEntry."Document Type"::"Purchase Receipt",PurchRcptHeader."No.");
Member of Lib.Library - Warehouse


CreateWhseShipmentFromServiceOrder@47 Method

The procedure CreateWhseShipmentFromServiceOrder is available in codeunit 132204.

Syntax

CreateWhseShipmentFromServiceOrder@47(
    ServiceHeader@1000 : Record 5900 ServiceHeader //Input parameter of type Record
);

Parameters

ServiceHeader
Input parameter of type Record

Remarks

The relevant search keywords are: Create, Warehouse, Shipment, From, Service, Order.

For a clarification about how this function works, refer to the code listed below.

      GetSourceDocOutbound.CreateFromServiceOrderHideDialog(ServiceHeader);

Example

The below example is extracted from the test automation codeunit 136135 to show one way of using this function.

      LibraryService.ReleaseServiceDocument(ServiceHeader);
      LibraryWarehouse.CreateWhseShipmentFromServiceOrder(ServiceHeader);

      WarehouseShipmentLine.SETRANGE("Source Type",DATABASE::"Service Line");
      WarehouseShipmentLine.SETRANGE("Source Subtype",1); // 1 - ServiceLine."Document Type"::Order (option #1)
      WarehouseShipmentLine.SETRANGE("Source No.",ServiceHeader."No.");
      WarehouseShipmentLine.FINDFIRST;
      WarehouseShipmentLine.VALIDATE("Bin Code",Bin.Code);
      WarehouseShipmentLine.MODIFY(TRUE);

      WarehouseShipmentHeader.GET(WarehouseShipmentLine."No.");
Member of Lib.Library - Warehouse


CreateWhseShipmentFromSO@79 Method

The procedure CreateWhseShipmentFromSO is available in codeunit 132204.

Syntax

CreateWhseShipmentFromSO@79(
    VAR SalesHeader@1000 : Record 36 SalesHeader //Reference parameter of type Record
);

Parameters

SalesHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Warehouse, Shipment, From, Sales Order.

For a clarification about how this function works, refer to the code listed below.

      GetSourceDocOutbound.CreateFromSalesOrderHideDialog(SalesHeader);

Example

The below example is extracted from the test automation codeunit 134378 to show one way of using this function.

      // Test if Post a Sales Order with Warehouse Location and generate Posted Sales Shipment Entry.

      // Setup
      Initialize;
      LibrarySales.SetStockoutWarning(FALSE);
      LibraryERM.FindVATPostingSetup(VATPostingSetup,VATPostingSetup."VAT Calculation Type"::"Normal VAT");

      // Exercise: Create Sales Order for Warehouse Location. Using RANDOM Quantity for Sales Line, value is not important.
      LibrarySales.CreateSalesHeader(SalesHeader,SalesHeader."Document Type"::Order,CreateCustomer);
      LibrarySales.CreateSalesLine(
        SalesLine,SalesHeader,SalesLine.Type::Item,
        CreateItem(VATPostingSetup."VAT Prod. Posting Group"),LibraryRandom.RandInt(10));

      // Update Sales Line with New Warehouse Location.
      SalesLine.VALIDATE("Location Code",CreateWarehouseLocation);
      SalesLine.MODIFY(TRUE);
      PostedSaleShipmentNo := NoSeriesManagement.GetNextNo(SalesHeader."Shipping No. Series",WORKDATE,FALSE);
      LibrarySales.ReleaseSalesDocument(SalesHeader);
      LibraryWarehouse.CreateWhseShipmentFromSO(SalesHeader);

      // Post Warehouse Document as Ship.
      ShipWarehouseDocument(SalesHeader."No.",SalesLine."Line No.");

      // Verify: Verify Quantity Posted Shipment Document.
      SalesShipmentLine.SETRANGE("Document No.",PostedSaleShipmentNo);
      SalesShipmentLine.FINDFIRST;
      SalesLine.GET(SalesLine."Document Type",SalesLine."Document No.",SalesLine."Line No.");
      Assert.AreEqual(SalesLine."Quantity Shipped",SalesShipmentLine.Quantity,STRSUBSTNO(FieldErr,SalesLine.TABLECAPTION,
          SalesShipmentLine.TABLECAPTION));

      // Tear Down: Cleanup of Setup Done.
      LibrarySales.SetStockoutWarning(TRUE);
Member of Lib.Library - Warehouse


CreateWhseShipmentFromTO@99 Method

The procedure CreateWhseShipmentFromTO is available in codeunit 132204.

Syntax

CreateWhseShipmentFromTO@99(
    VAR TransferHeader@1000 : Record 5740 TransferHeader //Reference parameter of type Record
);

Parameters

TransferHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Warehouse, Shipment, From, TO.

For a clarification about how this function works, refer to the code listed below.

      GetSourceDocOutbound.CreateFromOutbndTransferOrderHideDialog(TransferHeader);

Example

The below example is extracted from the test automation codeunit 137021 to show one way of using this function.

      // Setup
      Initialize;

      // Test setup
      TestSetup;
      LFLItemSetup(Item,TRUE,'','','',0,0,0);

      // Exercise
      CreateSalesReturnOrder(SalesHeader,Item,1,CALCDATE(PlanningStartDate,CALCDATE('<+1W+1D>',WORKDATE)),LocationOne.Code);
      CreateTransferOrder(
        TransferHeader,Item."No.",LocationWhite.Code,LocationOne.Code,CALCDATE(PlanningStartDate,CALCDATE('<+1W+1D>',WORKDATE)),1);
      LibraryWarehouse.ReleaseTransferOrder(TransferHeader);
      LibraryWarehouse.CreateWhseShipmentFromTO(TransferHeader);
      SalesPlan(Item,1,CALCDATE(PlanningStartDate,CALCDATE('<+1W+1D>',WORKDATE)),LocationOne.Code,LocationOne.Code);

      // Verify planning worksheet lines - check in doc section more info on the TDS
      AssertNumberOfLinesForItem(Item,1);
      AssertPlanningLine(Item,RequisitionLine."Action Message"::Cancel,0D,
        CALCDATE(PlanningStartDate,CALCDATE('<+1W+1D>',WORKDATE)),1,0,RequisitionLine."Ref. Order Type"::Transfer,'',1);
Member of Lib.Library - Warehouse


CreateWhseWorksheetLine@14 Method

The procedure CreateWhseWorksheetLine is available in codeunit 132204.

Syntax

CreateWhseWorksheetLine@14(
    VAR WhseWorksheetLine@1004 : Record 7326 WhseWorksheetLine, //Reference parameter of type Record
    WorksheetTemplateName@1003 : Code[10] WorksheetTemplateName, //Input parameter of type Code
    Name@1002 : Code[10] Name, //Input parameter of type Code
    LocationCode@1001 : Code[10] LocationCode, //Input parameter of type Code
    WhseDocumentType@1000 : Option WhseDocumentType //Input parameter of type Option
);

Parameters

WhseWorksheetLine
Reference parameter of type Record
WorksheetTemplateName
Input parameter of type Code
Name
Input parameter of type Code
LocationCode
Input parameter of type Code
WhseDocumentType
Input parameter of type Option

Remarks

The relevant search keywords are: Create, Warehouse, Worksheet, Line.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(WhseWorksheetLine);
      WhseWorksheetLine.INIT;
      WhseWorksheetLine.VALIDATE("Worksheet Template Name",WorksheetTemplateName);
      WhseWorksheetLine.VALIDATE(Name,Name);
      WhseWorksheetLine.VALIDATE("Location Code",LocationCode);
      RecRef.GETTABLE(WhseWorksheetLine);
      WhseWorksheetLine.VALIDATE("Line No.",LibraryUtility.GetNewLineNo(RecRef,WhseWorksheetLine.FIELDNO("Line No.")));
      WhseWorksheetLine.INSERT(TRUE);
      WhseWorksheetLine.VALIDATE("Whse. Document Type",WhseDocumentType);
      WhseWorksheetLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137051 to show one way of using this function.

      CreateWhseWorksheetName(WhseWorksheetName,LocationCode);
      LibraryWarehouse.CreateWhseWorksheetLine(
        WhseWorksheetLine,WhseWorksheetName."Worksheet Template Name",WhseWorksheetName.Name,
        LocationCode,WhseWorksheetLine."Whse. Document Type"::"Internal Pick");

      WhseWorksheetLine.VALIDATE("Item No.",ItemNo);
      WhseWorksheetLine.VALIDATE("Unit of Measure Code",ItemUnitofMeasureCode);
Member of Lib.Library - Warehouse


CreateWhseWorksheetName@146 Method

The procedure CreateWhseWorksheetName is available in codeunit 132204.

Syntax

CreateWhseWorksheetName@146(
    VAR WhseWorksheetName@1006 : Record 7327 WhseWorksheetName, //Reference parameter of type Record
    WhseWorkSheetTemplateName@1004 : Code[10] WhseWorkSheetTemplateName, //Input parameter of type Code
    LocationCode@1003 : Code[10] LocationCode //Input parameter of type Code
);

Parameters

WhseWorksheetName
Reference parameter of type Record
WhseWorkSheetTemplateName
Input parameter of type Code
LocationCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Warehouse, Worksheet, Name.

For a clarification about how this function works, refer to the code listed below.

      // Create Item Journal Batch with a random Name of String length less than 10.
      WhseWorksheetName.INIT;
      WhseWorksheetName.VALIDATE("Worksheet Template Name",WhseWorkSheetTemplateName);
      WhseWorksheetName.VALIDATE(
        Name,COPYSTR(LibraryUtility.GenerateRandomCode(WhseWorksheetName.FIELDNO(Name),DATABASE::"Whse. Worksheet Name"),1,
          MAXSTRLEN(WhseWorksheetName.Name)));
      WhseWorksheetName.VALIDATE("Location Code",LocationCode);
      WhseWorksheetName.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 136148 to show one way of using this function.

      WhseWorksheetTemplate.SETRANGE(Type,WhseWorksheetTemplate.Type::Pick);
      WhseWorksheetTemplate.FINDFIRST;
      LibraryWarehouse.CreateWhseWorksheetName(WhseWorksheetName,WhseWorksheetTemplate.Name,LocationCode);
Member of Lib.Library - Warehouse


CreateZone@97 Method

The procedure CreateZone is available in codeunit 132204.

Syntax

CreateZone@97(
    VAR Zone@1000 : Record 7300 Zone, //Reference parameter of type Record
    ZoneCode@1001 : Code[10] ZoneCode, //Input parameter of type Code
    LocationCode@1004 : Code[10] LocationCode, //Input parameter of type Code
    BinTypeCode@1002 : Code[10] BinTypeCode, //Input parameter of type Code
    WhseClassCode@1003 : Code[10] WhseClassCode, //Input parameter of type Code
    SpecialEquip@1005 : Code[10] SpecialEquip, //Input parameter of type Code
    ZoneRank@1006 : Integer ZoneRank, //Input parameter of type Integer
    IsCrossDockZone@1007 : Boolean IsCrossDockZone //Input parameter of type Boolean
);

Parameters

Zone
Reference parameter of type Record
ZoneCode
Input parameter of type Code
LocationCode
Input parameter of type Code
BinTypeCode
Input parameter of type Code
WhseClassCode
Input parameter of type Code
SpecialEquip
Input parameter of type Code
ZoneRank
Input parameter of type Integer
IsCrossDockZone
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, Zone.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(Zone);
      Zone.INIT;

      IF ZoneCode = '' THEN
        Zone.VALIDATE(Code,LibraryUtility.GenerateRandomCode(Zone.FIELDNO(Code),DATABASE::Zone))
      ELSE
        Zone.VALIDATE(Code,ZoneCode);

      Zone.VALIDATE("Location Code",LocationCode);
      Zone.VALIDATE(Description,Zone.Code);
      Zone.VALIDATE("Bin Type Code",BinTypeCode);
      Zone.VALIDATE("Warehouse Class Code",WhseClassCode);
      Zone.VALIDATE("Special Equipment Code",SpecialEquip);
      Zone.VALIDATE("Zone Ranking",ZoneRank);
      Zone.VALIDATE("Cross-Dock Bin Zone",IsCrossDockZone);

      Zone.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 137033 to show one way of using this function.

      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location);
      Location."Bin Mandatory" := TRUE;
      Location.VALIDATE("Directed Put-away and Pick",TRUE);
      Location.VALIDATE("Use Cross-Docking",TRUE);
      Location.MODIFY(TRUE);

      LibraryWarehouse.CreateZone(Zone,'',Location.Code,LibraryWarehouse.SelectBinType(FALSE,FALSE,FALSE,FALSE),'','',0,FALSE);
      LibraryWarehouse.CreateNumberOfBins(Location.Code,Zone.Code,LibraryWarehouse.SelectBinType(FALSE,FALSE,FALSE,FALSE),2,FALSE);
      LibraryWarehouse.FindBin(Bin,Location.Code,Zone.Code,1);
      BinCode1 := Bin.Code;
      Location.VALIDATE("Adjustment Bin Code",Bin.Code);
      Location.MODIFY(TRUE);

      LibraryWarehouse.FindBin(Bin,Location.Code,Zone.Code,2);
      BinCode2 := Bin.Code;
Member of Lib.Library - Warehouse


DeleteEmptyWhseRegisters@117 Method

The procedure DeleteEmptyWhseRegisters is available in codeunit 132204.

Syntax

DeleteEmptyWhseRegisters@117(
      //param element not supplied
);

Remarks

The relevant search keywords are: Delete, Empty, Warehouse, Registers.

For a clarification about how this function works, refer to the code listed below.

      COMMIT;  // Commit required for batch job report.
      CLEAR(DeleteEmptyWhseRegisters);
      DeleteEmptyWhseRegisters.USEREQUESTPAGE(FALSE);
      DeleteEmptyWhseRegisters.RUN;

Example

The below example is extracted from the test automation codeunit 137407 to show one way of using this function.

      // Test and verify functionality of Delete Empty Warehouse Registers report.

      // Setup: Create Warehouse Journal Line with Item Tracking Line. Register Warehouse Journal Line. Calculate and post Warehouse Adjustment. Run Date Compress Warehouse Entries.
      Initialize;
      CreateWarehouseJournalLineWithItemTrackingLines(WarehouseJournalLine,WarehouseJournalLine."Entry Type"::"Positive Adjmt.");
      LibraryWarehouse.RegisterWhseJournalLine(
        WarehouseJournalLine."Journal Template Name",WarehouseJournalLine."Journal Batch Name",WarehouseJournalLine."Location Code",
        TRUE);
      ItemJournalBatchName := CalculateAndPostWarehouseAdjustment(WarehouseJournalLine."Item No.");
      RunDateCompressWhseEntries(WarehouseJournalLine."Item No.");

      // Exercise: Run Delete Empty Warehouse Registers.
      LibraryWarehouse.DeleteEmptyWhseRegisters;

      // Verify: Verify Empty Warehouse Registers must not exist.
      Assert.IsFalse(FindWarehouseRegister(WarehouseJournalLine."Journal Batch Name"),STRSUBSTNO(EmptyWarehouseRegisterMustNotExist));
      Assert.IsFalse(FindWarehouseRegister(ItemJournalBatchName),STRSUBSTNO(EmptyWarehouseRegisterMustNotExist));
Member of Lib.Library - Warehouse


FindBin@119 Method

The procedure FindBin is available in codeunit 132204.

Syntax

FindBin@119(
    VAR Bin@1002 : Record 7354 Bin, //Reference parameter of type Record
    LocationCode@1000 : Code[10] LocationCode, //Input parameter of type Code
    ZoneCode@1001 : Code[10] ZoneCode, //Input parameter of type Code
    BinIndex@1003 : Integer BinIndex //Input parameter of type Integer
);

Parameters

Bin
Reference parameter of type Record
LocationCode
Input parameter of type Code
ZoneCode
Input parameter of type Code
BinIndex
Input parameter of type Integer

Remarks

The relevant search keywords are: Find, Bin.

For a clarification about how this function works, refer to the code listed below.

      Bin.INIT;
      Bin.RESET;
      Bin.SETCURRENTKEY("Location Code","Zone Code",Code);
      Bin.SETRANGE("Location Code",LocationCode);
      Bin.SETRANGE("Zone Code",ZoneCode);
      Bin.FINDSET(TRUE);

      IF BinIndex > 1 THEN
        Bin.NEXT(BinIndex - 1);

Example

The below example is extracted from the test automation codeunit 136140 to show one way of using this function.

      Initialize;

      // SETUP: Create Supply for that item in the specific location and bin.
      Quantity := LibraryRandom.RandIntInRange(2,100);
      LineQuantity := Quantity - 1;

      LocationCode := WMSFullLocation;
      CreateItemAndSupply(Item,LocationCode,Quantity);

      // Find the non pickable zone and bin with quantity content.
      Zone.SETRANGE("Location Code",LocationCode);
      Zone.SETRANGE("Location Code");
      FindPickableNonPickableZone(Zone,LocationCode,FALSE,FALSE); // We find a non-pickable zone
      LibraryWarehouse.FindBin(Bin,LocationCode,Zone.Code,2);  // Find Bin for Zone for Index 2.

      BinCode := Bin.Code;

      // EXECUTE: Create Service Invoice on the Location and use a non-pickable bin.
      // VERIFY: Error is displayed when a non-pickable bin is used.
      CreateServiceDocumentWithServiceLine(ServiceHeader,ServiceHeader."Document Type"::Invoice,Item."No.",LineQuantity,LocationCode);
      FindFirstServiceLineByServiceHeader(ServiceLine,ServiceHeader);
      ASSERTERROR ServiceLine.VALIDATE("Bin Code",BinCode);
      Assert.IsTrue(STRPOS(GETLASTERRORTEXT,NonPickableBinErrorTxt) > 0,'Non Pickable error-Invoice');

      // EXECUTE: Create Service Credit memo on the Location and use a non-pickable bin.
      CLEAR(ServiceLine);
      CLEAR(ServiceHeader);
      CreateServiceDocumentWithServiceLine(ServiceHeader,
        ServiceHeader."Document Type"::"Credit Memo",Item."No.",
        LineQuantity,LocationCode);
      FindFirstServiceLineByServiceHeader(ServiceLine,ServiceHeader);
      ServiceLine.VALIDATE("Bin Code",BinCode);
      ServiceLine.MODIFY(TRUE);

      // VERIFY: Service Document can be posted
      LibraryService.PostServiceOrder(ServiceHeader,TRUE,FALSE,TRUE);
Member of Lib.Library - Warehouse


FindWhseActivityBySourceDoc@57 Method

The procedure FindWhseActivityBySourceDoc is available in codeunit 132204.

Syntax

FindWhseActivityBySourceDoc@57(
    VAR WarehouseActivityHeader@1003 : Record 5766 WarehouseActivityHeader, //Reference parameter of type Record
    SourceType@1002 : Option SourceType, //Input parameter of type Option
    SourceSubtype@1001 : Option SourceSubtype, //Input parameter of type Option
    SourceNo@1000 : Code[20] SourceNo, //Input parameter of type Code
    SourceLineNo@1005 : Integer SourceLineNo //Input parameter of type Integer
);

Parameters

WarehouseActivityHeader
Reference parameter of type Record
SourceType
Input parameter of type Option
SourceSubtype
Input parameter of type Option
SourceNo
Input parameter of type Code
SourceLineNo
Input parameter of type Integer

Return Value

Boolean

Remarks

The relevant search keywords are: Find, Warehouse, Activity, By, Source, Document.

For a clarification about how this function works, refer to the code listed below.

      IF NOT FindWhseActivityLineBySourceDoc(WarehouseActivityLine,SourceType,SourceSubtype,SourceNo,SourceLineNo) THEN
        EXIT(FALSE);

      WarehouseActivityHeader.GET(WarehouseActivityLine."Activity Type",WarehouseActivityLine."No.");
      EXIT(TRUE);

Example

The below example is extracted from the test automation codeunit 137047 to show one way of using this function.

      // [FEATURE] [Item Tracking] [Put-Away]
      // [SCENARIO 277222] Put-away created from a posted warehouse receipt inherits lot no. from unhandled tracking line of the source document, when another posted receipt withe the same lot exists

      Initialize;

      // [GIVEN] Item "I" tracked by lot number
      CreateItemWithLotWarehouseTracking(Item);
      LibraryWarehouse.CreateFullWMSLocation(Location,2);

      LotNos[1] := LibraryUtility.GenerateGUID;
      LotNos[2] := LibraryUtility.GenerateGUID;
      LotQty[1] := LibraryRandom.RandInt(10);
      LotQty[2] := LibraryRandom.RandIntInRange(10,20);

      // [GIVEN] Purchase order for 10 pcs of item "I" on a "directed put-away and pick" location.
      // [GIVEN] Assign two item tracking lines: 6 pcs with lot "L1", and 4 pcs - lot "L2", post warehouse receipt
      LibraryVariableStorage.Enqueue(2);
      LibraryVariableStorage.Enqueue(LotNos[1]);
      LibraryVariableStorage.Enqueue(LotQty[1]);
      LibraryVariableStorage.Enqueue(LotNos[2]);
      LibraryVariableStorage.Enqueue(LotQty[2]);
      CreateTrackedPurchOrderPostWhseReceipt(PurchaseHeader,PurchaseLine,Location.Code,Item."No.",LotQty[1] + LotQty[2]);
      FindPostedWhseReceiptLine(PostedWhseReceiptLine,PurchaseLine);

      // [GIVEN] Put away 6 pcs with lot "L1", do not handle lot "L2".
      SetQtyToHandleOnWhseActivityLine(
        DATABASE::"Purchase Line",PurchaseHeader."Document Type",PurchaseHeader."No.",LotNos[1],LotQty[1]);
      SetQtyToHandleOnWhseActivityLine(DATABASE::"Purchase Line",PurchaseHeader."Document Type",PurchaseHeader."No.",LotNos[2],0);
      LibraryWarehouse.FindWhseActivityBySourceDoc(
        WarehouseActivityHeader,DATABASE::"Purchase Line",PurchaseHeader."Document Type",PurchaseHeader."No.",PurchaseLine."Line No.");

      // [GIVEN] Delete the partially posted put-away document.
      LibraryWarehouse.RegisterWhseActivity(WarehouseActivityHeader);
      WarehouseActivityHeader.FIND;
      WarehouseActivityHeader.DELETE(TRUE);

      // [GIVEN] Create and put-away another purchase order for 10 pcs of item "I" with the same lot no. "L1"
      LibraryVariableStorage.Enqueue(1);
      LibraryVariableStorage.Enqueue(LotNos[1]);
      LibraryVariableStorage.Enqueue(LotQty[1]);
      CreateTrackedPurchOrderPostWhseReceipt(PurchaseHeader,PurchaseLine,Location.Code,Item."No.",LotQty[1]);

      // [WHEN] Create put-away from the posted warehouse receipt
      CreatePutAwayFromPostedWhseRcpt(WarehouseActivityLine,PostedWhseReceiptLine);

      // [THEN] Put-away line created for 4 pcs of lot "L2"
      WarehouseActivityLine.TESTFIELD("Lot No.",LotNos[2]);
      LibraryVariableStorage.AssertEmpty;
Member of Lib.Library - Warehouse


FindWhseActivityLineBySourceDoc@56 Method

The procedure FindWhseActivityLineBySourceDoc is available in codeunit 132204.

Syntax

FindWhseActivityLineBySourceDoc@56(
    VAR WarehouseActivityLine@1003 : Record 5767 WarehouseActivityLine, //Reference parameter of type Record
    SourceType@1002 : Option SourceType, //Input parameter of type Option
    SourceSubtype@1001 : Option SourceSubtype, //Input parameter of type Option
    SourceNo@1000 : Code[20] SourceNo, //Input parameter of type Code
    SourceLineNo@1005 : Integer SourceLineNo //Input parameter of type Integer
);

Parameters

WarehouseActivityLine
Reference parameter of type Record
SourceType
Input parameter of type Option
SourceSubtype
Input parameter of type Option
SourceNo
Input parameter of type Code
SourceLineNo
Input parameter of type Integer

Return Value

Boolean

Remarks

The relevant search keywords are: Find, Warehouse, Activity, Line, By, Source, Document.

For a clarification about how this function works, refer to the code listed below.

      WarehouseActivityLine.SETRANGE("Source Type",SourceType);
      WarehouseActivityLine.SETRANGE("Source Subtype",SourceSubtype);
      WarehouseActivityLine.SETRANGE("Source No.",SourceNo);
      WarehouseActivityLine.SETRANGE("Source Line No.",SourceLineNo);
      EXIT(WarehouseActivityLine.FINDFIRST);

Example

The below example is extracted from the test automation codeunit 137047 to show one way of using this function.

      WhseSourceCreateDocument.SetPostedWhseReceiptLine(PostedWhseReceiptLine,'');
      WhseSourceCreateDocument.SetHideValidationDialog(TRUE);
      WhseSourceCreateDocument.USEREQUESTPAGE(FALSE);
      WhseSourceCreateDocument.RUNMODAL;

      LibraryWarehouse.FindWhseActivityLineBySourceDoc(
        WarehouseActivityLine,PostedWhseReceiptLine."Source Type",PostedWhseReceiptLine."Source Subtype",
        PostedWhseReceiptLine."Source No.",PostedWhseReceiptLine."Source Line No.");
Member of Lib.Library - Warehouse


FindWhseReceiptNoBySourceDoc@46 Method

The procedure FindWhseReceiptNoBySourceDoc is available in codeunit 132204.

Syntax

FindWhseReceiptNoBySourceDoc@46(
    SourceType@1001 : Option SourceType, //Input parameter of type Option
    SourceSubtype@1002 : Option SourceSubtype, //Input parameter of type Option
    SourceNo@1003 : Code[20] SourceNo //Input parameter of type Code
);

Parameters

SourceType
Input parameter of type Option
SourceSubtype
Input parameter of type Option
SourceNo
Input parameter of type Code

Return Value

Code[20]

Remarks

The relevant search keywords are: Find, Warehouse, Receipt, No, By, Source, Document.

For a clarification about how this function works, refer to the code listed below.

      WITH WhseRcptLine DO BEGIN
        SETRANGE("Source Type",SourceType);
        SETRANGE("Source Subtype",SourceSubtype);
        SETRANGE("Source No.",SourceNo);
        IF FINDFIRST THEN
          EXIT("No.");

        EXIT('');
      END;

Example

The below example is extracted from the test automation codeunit 136148 to show one way of using this function.

      LibraryPurchase.CreatePurchHeader(PurchaseHeader,PurchaseHeader."Document Type"::Order,'');
      WITH ServiceLine DO
        REPEAT
          CLEAR(PurchaseLine);
          IF Type = Type::Item THEN BEGIN
            LibraryPurchase.CreatePurchaseLine(PurchaseLine,PurchaseHeader,PurchaseLine.Type::Item,"No.",Quantity);
            PurchaseLine.VALIDATE("Location Code","Location Code");
            PurchaseLine.MODIFY(TRUE);
          END;
        UNTIL NEXT <= 0;

      LibraryPurchase.ReleasePurchaseDocument(PurchaseHeader);
      LibraryWarehouse.CreateWhseReceiptFromPO(PurchaseHeader);
      WhseReceiptHeader.GET(
        LibraryWarehouse.FindWhseReceiptNoBySourceDoc(
          DATABASE::"Purchase Line",PurchaseHeader."Document Type",PurchaseHeader."No."));
      LibraryWarehouse.PostWhseReceipt(WhseReceiptHeader);
      WITH WhseActivityLine DO BEGIN
        SETRANGE("Activity Type","Activity Type"::"Put-away");
        SETRANGE("Source No.",PurchaseHeader."No.");
        FIND('-');
        Location.GET(OrangeLocation);
        REPEAT
          IF "Action Type" = "Action Type"::Place THEN BEGIN
            VALIDATE("Bin Code",Location."Default Bin Code");
            MODIFY(TRUE);
          END;
        UNTIL NEXT <= 0
      END;
      CODEUNIT.RUN(CODEUNIT::"Whse.-Act.-Register (Yes/No)",WhseActivityLine);
Member of Lib.Library - Warehouse


FindWhseShipmentNoBySourceDoc@32 Method

The procedure FindWhseShipmentNoBySourceDoc is available in codeunit 132204.

Syntax

FindWhseShipmentNoBySourceDoc@32(
    SourceType@1002 : Option SourceType, //Input parameter of type Option
    SourceSubtype@1001 : Option SourceSubtype, //Input parameter of type Option
    SourceNo@1000 : Code[20] SourceNo //Input parameter of type Code
);

Parameters

SourceType
Input parameter of type Option
SourceSubtype
Input parameter of type Option
SourceNo
Input parameter of type Code

Return Value

Code[20]

Remarks

The relevant search keywords are: Find, Warehouse, Shipment, No, By, Source, Document.

For a clarification about how this function works, refer to the code listed below.

      WITH WhseShptLine DO BEGIN
        SETRANGE("Source Type",SourceType);
        SETRANGE("Source Subtype",SourceSubtype);
        SETRANGE("Source No.",SourceNo);
        IF FINDFIRST THEN
          EXIT("No.");

        EXIT('');
      END;

Example

The below example is extracted from the test automation codeunit 136140 to show one way of using this function.

      Initialize;

      // SETUP: Create Service order on WHITE Location, release and Create warehouse shipment
      LibraryInventory.CreateItem(Item);
      CreateServiceOrderAndServiceLines(ServiceHeader,Item."No.",RANDOM(100),WMSFullLocation);
      LibraryService.ReleaseServiceDocument(ServiceHeader);
      LibraryWarehouse.CreateWhseShipmentFromServiceOrder(ServiceHeader);
      WarehouseShipmentHeaderNo :=
        LibraryWarehouse.FindWhseShipmentNoBySourceDoc(
          DATABASE::"Service Line",ServiceHeader."Document Type",ServiceHeader."No.");

      // EXECUTE: Delete and re-create Warehouse shipment on this order
      WarehouseShipmentHeader.GET(WarehouseShipmentHeaderNo);
      WarehouseShipmentHeader.DELETE(TRUE);
      CLEAR(WarehouseShipmentHeader);
      ServiceHeader.GET(ServiceHeader."Document Type",ServiceHeader."No.");
      LibraryWarehouse.CreateWhseShipmentFromServiceOrder(ServiceHeader);

      // VERIFY: new Warehouse shipments have been created
      WarehouseShipmentHeaderNo :=
        LibraryWarehouse.FindWhseShipmentNoBySourceDoc(
          DATABASE::"Service Line",ServiceHeader."Document Type",ServiceHeader."No.");
      Assert.IsTrue(
        WarehouseShipmentHeader.GET(WarehouseShipmentHeaderNo),'Displayed warehouse shipment can be located');
      GetAllServiceLinesOfTypeItem(ServiceLine,ServiceHeader);
      FindWarehouseShipmentLinesByServiceOrder(WarehouseShipmentLine,ServiceHeader,WarehouseShipmentHeader);
      Assert.AreEqual(ServiceLine.COUNT,WarehouseShipmentLine.COUNT,'Count of Lines in Whse shipment and service lines match');
      VerifyWarehouseShipmentLines(WarehouseShipmentLine,ServiceLine);
Member of Lib.Library - Warehouse


GetBinContentInternalMovement@76 Method

The procedure GetBinContentInternalMovement is available in codeunit 132204.

Syntax

GetBinContentInternalMovement@76(
    InternalMovementHeader@1001 : Record 7346 InternalMovementHeader, //Input parameter of type Record
    LocationCodeFilter@1000 : Text[30] LocationCodeFilter, //Input parameter of type Text
    ItemFilter@1002 : Text[30] ItemFilter, //Input parameter of type Text
    BinCodeFilter@1003 : Text[100] BinCodeFilter //Input parameter of type Text
);

Parameters

InternalMovementHeader
Input parameter of type Record
LocationCodeFilter
Input parameter of type Text
ItemFilter
Input parameter of type Text
BinCodeFilter
Input parameter of type Text

Remarks

The relevant search keywords are: Get, Bin, Content, Internal, Movement.

For a clarification about how this function works, refer to the code listed below.

      BinContent.INIT;
      BinContent.RESET;
      IF LocationCodeFilter <> '' THEN
        BinContent.SETRANGE("Location Code",LocationCodeFilter);
      IF ItemFilter <> '' THEN
        BinContent.SETFILTER("Item No.",ItemFilter);
      IF BinCodeFilter <> '' THEN
        BinContent.SETFILTER("Bin Code",BinCodeFilter);
      WhseGetBinContent.SETTABLEVIEW(BinContent);
      WhseGetBinContent.InitializeInternalMovement(InternalMovementHeader);
      WhseGetBinContent.USEREQUESTPAGE(FALSE);
      WhseGetBinContent.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 137030 to show one way of using this function.

      LibraryWarehouse.CreateInternalMovementHeader(InternalMovementHeader,Location.Code,ToBin.Code);
      LibraryWarehouse.GetBinContentInternalMovement(InternalMovementHeader,Location.Code,Item."No.",BinContentFilter);
Member of Lib.Library - Warehouse


GetBinContentTransferOrder@16 Method

The procedure GetBinContentTransferOrder is available in codeunit 132204.

Syntax

GetBinContentTransferOrder@16(
    VAR TransferHeader@1001 : Record 5740 TransferHeader, //Reference parameter of type Record
    LocationCodeFilter@1003 : Text[30] LocationCodeFilter, //Input parameter of type Text
    ItemFilter@1002 : Text[30] ItemFilter, //Input parameter of type Text
    BinCodeFilter@1000 : Text[100] BinCodeFilter //Input parameter of type Text
);

Parameters

TransferHeader
Reference parameter of type Record
LocationCodeFilter
Input parameter of type Text
ItemFilter
Input parameter of type Text
BinCodeFilter
Input parameter of type Text

Remarks

The relevant search keywords are: Get, Bin, Content, Transfer, Order.

For a clarification about how this function works, refer to the code listed below.

      BinContent.INIT;
      BinContent.RESET;
      IF LocationCodeFilter <> '' THEN
        BinContent.SETRANGE("Location Code",LocationCodeFilter);
      IF ItemFilter <> '' THEN
        BinContent.SETFILTER("Item No.",ItemFilter);
      IF BinCodeFilter <> '' THEN
        BinContent.SETFILTER("Bin Code",BinCodeFilter);
      WhseGetBinContent.SETTABLEVIEW(BinContent);
      WhseGetBinContent.InitializeTransferHeader(TransferHeader);
      WhseGetBinContent.USEREQUESTPAGE(FALSE);
      WhseGetBinContent.RUN;

Example

The below example is extracted from the test automation codeunit 137260 to show one way of using this function.

      // Verify Get Bin Content on Transfer Order after posting Purchase Order.

      // Setup: Create Item with Serial Specific Item Tracking and create Location with Bin, Create and Post Purchase Order, Create Transfer Order.
      Initialize;
      ItemNo := CreateSerialTrackedItem;
      CreateSilverLocation(Bin);
      LibraryWarehouse.CreateLocation(Location);
      Quantity := CreateAndPostPurchaseOrderWithBin(ItemNo,Bin.Code,Bin."Location Code",FALSE);  // Use False for Invoice.
      LibraryWarehouse.CreateTransferHeader(TransferHeader,Bin."Location Code",Location.Code,CreateTransitLocation);

      // Exercise: Get Bin Content on Transfer Order.
      LibraryWarehouse.GetBinContentTransferOrder(TransferHeader,Bin."Location Code",ItemNo,Bin.Code);

      // Verify: Verify Quantity after Get Bin Content on Transfer Order.
      VerifyQuantityOnTransferLine(TransferHeader."No.",ItemNo,Quantity);
Member of Lib.Library - Warehouse


GetInboundSourceDocuments@154 Method

The procedure GetInboundSourceDocuments is available in codeunit 132204.

Syntax

GetInboundSourceDocuments@154(
    VAR WhsePutAwayRqst@1000 : Record 7324 WhsePutAwayRqst, //Reference parameter of type Record
    WhseWorksheetName@1001 : Record 7327 WhseWorksheetName, //Input parameter of type Record
    LocationCode@1002 : Code[10] LocationCode //Input parameter of type Code
);

Parameters

WhsePutAwayRqst
Reference parameter of type Record
WhseWorksheetName
Input parameter of type Record
LocationCode
Input parameter of type Code

Remarks

The relevant search keywords are: Get, Inbound, Source, Documents.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(GetInboundSourceDocuments);
      GetInboundSourceDocuments.SetWhseWkshName(WhseWorksheetName."Worksheet Template Name",WhseWorksheetName.Name,LocationCode);
      GetInboundSourceDocuments.USEREQUESTPAGE(FALSE);
      GetInboundSourceDocuments.SETTABLEVIEW(WhsePutAwayRqst);
      GetInboundSourceDocuments.RUN;

Example

The below example is extracted from the test automation codeunit 137152 to show one way of using this function.

      LibraryWarehouse.SelectWhseWorksheetTemplate(WhseWorksheetTemplate,WhseWorksheetTemplate.Type::"Put-away");
      LibraryWarehouse.SelectWhseWorksheetName(WhseWorksheetName,WhseWorksheetTemplate.Name,LocationCode);
      WhsePutAwayRequest.SETRANGE("Completely Put Away",FALSE);
      WhsePutAwayRequest.SETRANGE("Location Code",LocationCode);
      LibraryWarehouse.GetInboundSourceDocuments(WhsePutAwayRequest,WhseWorksheetName,LocationCode);
      WhseWorksheetLine.SETRANGE("Worksheet Template Name",WhseWorksheetTemplate.Name);
      WhseWorksheetLine.SETRANGE(Name,WhseWorksheetName.Name);
      WhseWorksheetLine.SETFILTER("Item No.",ItemNo + '|' + ItemNo2);
      WhseWorksheetLine.FINDFIRST;
      IF QuantityToHandle <> 0 THEN BEGIN
        WhseWorksheetLine.VALIDATE("Qty. to Handle",QuantityToHandle);
        WhseWorksheetLine.MODIFY(TRUE);
      END;
      LibraryWarehouse.WhseSourceCreateDocument(WhseWorksheetLine,SortActivity,FALSE,FALSE,BreakbulkFilter);
Member of Lib.Library - Warehouse


GetOutboundSourceDocuments@157 Method

The procedure GetOutboundSourceDocuments is available in codeunit 132204.

Syntax

GetOutboundSourceDocuments@157(
    VAR WhsePickRequest@1004 : Record 7325 WhsePickRequest, //Reference parameter of type Record
    WhseWorksheetName@1001 : Record 7327 WhseWorksheetName, //Input parameter of type Record
    LocationCode@1000 : Code[10] LocationCode //Input parameter of type Code
);

Parameters

WhsePickRequest
Reference parameter of type Record
WhseWorksheetName
Input parameter of type Record
LocationCode
Input parameter of type Code

Remarks

The relevant search keywords are: Get, Outbound, Source, Documents.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(GetOutboundSourceDocuments);
      GetOutboundSourceDocuments.SetPickWkshName(WhseWorksheetName."Worksheet Template Name",WhseWorksheetName.Name,LocationCode);
      GetOutboundSourceDocuments.USEREQUESTPAGE(FALSE);
      GetOutboundSourceDocuments.SETTABLEVIEW(WhsePickRequest);
      GetOutboundSourceDocuments.RUN;

Example

The below example is extracted from the test automation codeunit 137150 to show one way of using this function.

      LibraryWarehouse.SelectWhseWorksheetTemplate(WhseWorksheetTemplate,WhseWorksheetTemplate.Type::Pick);
      LibraryWarehouse.SelectWhseWorksheetName(WhseWorksheetName,WhseWorksheetTemplate.Name,LocationCode);
      WhsePickRequest.SETRANGE("Location Code",LocationCode);
      LibraryWarehouse.GetOutboundSourceDocuments(WhsePickRequest,WhseWorksheetName,LocationCode);
      IF ItemNo <> '' THEN BEGIN
        WhseWorksheetLine.SETRANGE("Item No.",ItemNo);
        WhseWorksheetLine.FINDFIRST;
      END;
      LibraryWarehouse.CreatePickFromPickWorksheet(
        WhseWorksheetLine,WhseWorksheetLine."Line No.",WhseWorksheetName."Worksheet Template Name",WhseWorksheetName.Name,
        LocationCode,'',0,0,0,FALSE,FALSE,FALSE,FALSE,PerWhseDoc,FALSE,FALSE);
Member of Lib.Library - Warehouse


GetSourceDocInventoryMovement@89 Method

The procedure GetSourceDocInventoryMovement is available in codeunit 132204.

Syntax

GetSourceDocInventoryMovement@89(
    VAR WarehouseActivityHeader@1001 : Record 5766 WarehouseActivityHeader //Reference parameter of type Record
);

Parameters

WarehouseActivityHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Get, Source, Document, Inventory, Movement.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(CreateInvtPickMovement);
      CreateInvtPickMovement.SetInvtMovement(TRUE);
      CreateInvtPickMovement.RUN(WarehouseActivityHeader);

Example

The below example is extracted from the test automation codeunit 137030 to show one way of using this function.

      COMMIT; // as assert error will roll-back
      ASSERTERROR
        LibraryWarehouse.GetSourceDocInventoryMovement(WarehouseActivityHeader);
      Assert.IsTrue(STRPOS(GETLASTERRORTEXT,Message) > 0,GETLASTERRORTEXT);

      CLEARLASTERROR;
Member of Lib.Library - Warehouse


GetSourceDocInventoryPick@74 Method

The procedure GetSourceDocInventoryPick is available in codeunit 132204.

Syntax

GetSourceDocInventoryPick@74(
    WarehouseActivityHeader@1000 : Record 5766 WarehouseActivityHeader //Input parameter of type Record
);

Parameters

WarehouseActivityHeader
Input parameter of type Record

Remarks

The relevant search keywords are: Get, Source, Document, Inventory, Pick.

For a clarification about how this function works, refer to the code listed below.

      Assert.AreEqual(WarehouseActivityHeader.Type::"Invt. Pick",WarehouseActivityHeader.Type,'Only processes Inventory Pick');
      CLEAR(CreateInventoryPickMovement);
      CreateInventoryPickMovement.RUN(WarehouseActivityHeader);

Example

The below example is extracted from the test automation codeunit 137913 to show one way of using this function.

      Initialize;
      // CREATING INVENTORY PICK FROM THE INVENTORY PICK PAGE DOES NOT CREATE INVENTORY PICK
      MockAsmOrderWithComp(AsmHeader,AsmItem,CompItem,1);
      MockLocation(Location,TRUE,TRUE,FALSE,FALSE); // Require Pick location
      AddItemToInventory(CompItem,Location,Bin1,10);
      AsmLine.GET(AsmHeader."Document Type",AsmHeader."No.",10000);
      AsmLine.VALIDATE("Location Code",Location.Code);
      AsmLine.VALIDATE("Bin Code",Bin2);
      AsmLine.MODIFY(TRUE);
      LibraryAssembly.ReleaseAO(AsmHeader);

      // create empty whse. activity header for inventory pick
      CLEAR(WarehouseActivityHeader);
      WarehouseActivityHeader.Type := WarehouseActivityHeader.Type::"Invt. Pick";
      WarehouseActivityHeader.INSERT(TRUE);
      WarehouseActivityHeader.VALIDATE("Location Code",Location.Code);
      WarehouseActivityHeader.MODIFY(TRUE);
      // create inventory pick from the inventory pick page
      LibraryWarehouse.GetSourceDocInventoryPick(WarehouseActivityHeader); // throws Nothing to Handle message
      WhseActivityLine.SETRANGE("Activity Type",WarehouseActivityHeader.Type);
      WhseActivityLine.SETRANGE("No.",WarehouseActivityHeader."No.");
      Assert.AreEqual(0,WhseActivityLine.COUNT,'Count should be zero as no pick should have been created');

      // ABOVE SCENARIO USING SAME COMP BIN AS BIN CONTENT
      LibraryAssembly.ReopenAO(AsmHeader);
      AsmLine.VALIDATE("Bin Code",Bin1);
      AsmLine.MODIFY(TRUE);
      LibraryAssembly.ReleaseAO(AsmHeader);
      // create inventory pick from the inventory pick page
      LibraryWarehouse.GetSourceDocInventoryPick(WarehouseActivityHeader); // throws Nothing to Handle message
      Assert.AreEqual(0,WhseActivityLine.COUNT,'Count should be zero as no pick should have been created');
Member of Lib.Library - Warehouse


GetSourceDocInventoryPutAway@25 Method

The procedure GetSourceDocInventoryPutAway is available in codeunit 132204.

Syntax

GetSourceDocInventoryPutAway@25(
    WarehouseActivityHeader@1000 : Record 5766 WarehouseActivityHeader //Input parameter of type Record
);

Parameters

WarehouseActivityHeader
Input parameter of type Record

Remarks

The relevant search keywords are: Get, Source, Document, Inventory, Put, Away.

For a clarification about how this function works, refer to the code listed below.

      Assert.AreEqual(WarehouseActivityHeader.Type::"Invt. Put-away",WarehouseActivityHeader.Type,'Only processes Inventory Put-away');
      CLEAR(CreateInventoryPickMovement);
      CreateInventoryPickMovement.RUN(WarehouseActivityHeader);

Example

There are no examples available.
Member of Lib.Library - Warehouse


GetSourceDocumentsReceipt@7 Method

The procedure GetSourceDocumentsReceipt is available in codeunit 132204.

Syntax

GetSourceDocumentsReceipt@7(
    VAR WarehouseReceiptHeader@1002 : Record 7316 WarehouseReceiptHeader, //Reference parameter of type Record
    VAR WarehouseSourceFilter@1001 : Record 5771 WarehouseSourceFilter, //Reference parameter of type Record
    LocationCode@1000 : Code[10] LocationCode //Input parameter of type Code
);

Parameters

WarehouseReceiptHeader
Reference parameter of type Record
WarehouseSourceFilter
Reference parameter of type Record
LocationCode
Input parameter of type Code

Remarks

The relevant search keywords are: Get, Source, Documents, Receipt.

For a clarification about how this function works, refer to the code listed below.

      // Get Receipt Lines for the required Order in matching criteria.
      GetSourceDocuments.SetOneCreatedReceiptHeader(WarehouseReceiptHeader);
      WarehouseSourceFilter.SetFilters(GetSourceDocuments,LocationCode);
      GetSourceDocuments.SetSkipBlockedItem(TRUE);
      GetSourceDocuments.USEREQUESTPAGE(FALSE);
      GetSourceDocuments.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 137047 to show one way of using this function.

      CreateWarehouseReceiptHeader(WarehouseReceiptHeader,LocationCode);
      LibraryWarehouse.CreateWarehouseSourceFilter(WarehouseSourceFilter,WarehouseSourceFilter.Type::Inbound);
      UpdateSourceFilterPurchase(WarehouseSourceFilter,BuyFromVendorNo);
      UpdateSourceFilterSales(WarehouseSourceFilter,SellToCustomerNo);
      LibraryWarehouse.GetSourceDocumentsReceipt(WarehouseReceiptHeader,WarehouseSourceFilter,LocationCode);
Member of Lib.Library - Warehouse


GetSourceDocumentsShipment@4 Method

The procedure GetSourceDocumentsShipment is available in codeunit 132204.

Syntax

GetSourceDocumentsShipment@4(
    VAR WarehouseShipmentHeader@1002 : Record 7320 WarehouseShipmentHeader, //Reference parameter of type Record
    VAR WarehouseSourceFilter@1000 : Record 5771 WarehouseSourceFilter, //Reference parameter of type Record
    LocationCode@1003 : Code[10] LocationCode //Input parameter of type Code
);

Parameters

WarehouseShipmentHeader
Reference parameter of type Record
WarehouseSourceFilter
Reference parameter of type Record
LocationCode
Input parameter of type Code

Remarks

The relevant search keywords are: Get, Source, Documents, Shipment.

For a clarification about how this function works, refer to the code listed below.

      // Get Shipment Lines for the required Order in matching criteria.
      GetSourceDocuments.SetOneCreatedShptHeader(WarehouseShipmentHeader);
      WarehouseSourceFilter.SetFilters(GetSourceDocuments,LocationCode);
      GetSourceDocuments.SetSkipBlockedItem(TRUE);
      GetSourceDocuments.USEREQUESTPAGE(FALSE);
      GetSourceDocuments.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 136140 to show one way of using this function.

      Initialize;

      // SETUP: Create Service order and Sales order on WHITE Location
      LibraryInventory.CreateItem(Item);
      CreateServiceOrderAndServiceLines(ServiceHeader,Item."No.",RANDOM(100),WMSFullLocation);
      CreateAndReleaseSalesOrder(SalesHeader,Item."No.",WMSFullLocation,RANDOM(100),FALSE);

      // EXECUTE: Create Warehouse shipment on this order
      LibraryService.ReleaseServiceDocument(ServiceHeader);
      CreateWareHouseShipmentHeader(WarehouseShipmentHeader,WMSFullLocation);
      LibraryWarehouse.CreateWarehouseSourceFilter(WarehouseSourceFilter,WarehouseSourceFilter.Type::Outbound);
      WarehouseSourceFilter.VALIDATE("Service Orders",TRUE);
      WarehouseSourceFilter.VALIDATE("Sales Orders",FALSE);
      WarehouseSourceFilter.VALIDATE("Source No. Filter",ServiceHeader."No." + '|' + SalesHeader."No.");
      WarehouseSourceFilter.MODIFY(TRUE);
      LibraryWarehouse.GetSourceDocumentsShipment(WarehouseShipmentHeader,WarehouseSourceFilter,WMSFullLocation);

      // Verify: Whse shipments have been created and only service line has been pulled in
      GetWarehouseShipmentLinesByShipmentHeader(WarehouseShipmentLine,WarehouseShipmentHeader);
      GetAllServiceLinesOfTypeItem(ServiceLine,ServiceHeader);
      Assert.AreEqual(1,WarehouseShipmentLine.COUNT,'Only one line has been pulled into the warehouse shipment');
      VerifyWarehouseShipmentLines(WarehouseShipmentLine,ServiceLine);
Member of Lib.Library - Warehouse


GetWhseDocsPickWorksheet@31 Method

The procedure GetWhseDocsPickWorksheet is available in codeunit 132204.

Syntax

GetWhseDocsPickWorksheet@31(
    VAR WhseWkshLine@1000 : Record 7326 WhseWkshLine, //Reference parameter of type Record
    WhsePickRequest@1001 : Record 7325 WhsePickRequest, //Input parameter of type Record
    Name@1002 : Code[10] Name //Input parameter of type Code
);

Parameters

WhseWkshLine
Reference parameter of type Record
WhsePickRequest
Input parameter of type Record
Name
Input parameter of type Code

Return Value

Integer

Remarks

The relevant search keywords are: Get, Warehouse, Docs, Pick, Worksheet.

For a clarification about how this function works, refer to the code listed below.

      WhsePickRequest.TESTFIELD("Location Code");
      WhsePickRequest.TESTFIELD("Completely Picked",FALSE);

      WhseWkshTemplate.SETRANGE(Type,WhseWkshTemplate.Type::Pick);
      WhseWkshTemplate.FINDFIRST; // expected to be present as Distribution demo data has been called.
      IF NOT WhseWkshName.GET(WhseWkshTemplate.Name,Name,WhsePickRequest."Location Code") THEN BEGIN
        WhseWkshName.INIT;
        WhseWkshName.VALIDATE("Worksheet Template Name",WhseWkshTemplate.Name);
        WhseWkshName.VALIDATE(Name,Name);
        WhseWkshName.VALIDATE("Location Code",WhsePickRequest."Location Code");
        WhseWkshName.INSERT(TRUE);
      END;

      WhsePickRqst2 := WhsePickRequest;
      GetOutboundSourceDocuments.SetPickWkshName(
        WhseWkshTemplate.Name,WhseWkshName.Name,WhsePickRequest."Location Code");
      WhsePickRqst2.MARKEDONLY(TRUE);
      IF NOT WhsePickRqst2.FINDFIRST THEN BEGIN
        WhsePickRqst2.MARKEDONLY(FALSE);
        WhsePickRqst2.SETRECFILTER;
      END;

      GetOutboundSourceDocuments.USEREQUESTPAGE(FALSE);
      GetOutboundSourceDocuments.SETTABLEVIEW(WhsePickRqst2);
      GetOutboundSourceDocuments.RUNMODAL;

      CLEAR(WhseWkshLine);
      WhseWkshLine.SETRANGE("Worksheet Template Name",WhseWkshTemplate.Name);
      WhseWkshLine.SETRANGE(Name,WhseWkshName.Name);
      WhseWkshLine.SETRANGE("Location Code",WhsePickRequest."Location Code");
      WhseWkshLine.SETRANGE("Whse. Document No.",WhsePickRequest."Document No.");
      EXIT(WhseWkshLine.COUNT);

Example

The below example is extracted from the test automation codeunit 137065 to show one way of using this function.

      WhsePickRequest.GET(WhsePickRequest."Document Type"::Production,ProdOrderStatus,ProdOrderNo,LocationCode);
      LibraryWarehouse.GetWhseDocsPickWorksheet(WhseWorksheetLine,WhsePickRequest,LocationCode);
      WhseWorksheetLine.FINDFIRST;
Member of Lib.Library - Warehouse


GetZoneForBin@147 Method

The procedure GetZoneForBin is available in codeunit 132204.

Syntax

GetZoneForBin@147(
    LocationCode@1001 : Code[10] LocationCode, //Input parameter of type Code
    BinCode@1002 : Code[20] BinCode //Input parameter of type Code
);

Parameters

LocationCode
Input parameter of type Code
BinCode
Input parameter of type Code

Return Value

Code[10]

Remarks

The relevant search keywords are: Get, Zone, For, Bin.

For a clarification about how this function works, refer to the code listed below.

      IF Bin.GET(LocationCode,BinCode) THEN
        EXIT(Bin."Zone Code");

      EXIT('');

Example

The below example is extracted from the test automation codeunit 137150 to show one way of using this function.

      FindBin(Bin,LocationCode,Receive,PutAway,Pick);
      LibraryWarehouse.CreateNumberOfBins(
        LocationCode,LibraryWarehouse.GetZoneForBin(LocationCode,Bin.Code),
        LibraryWarehouse.SelectBinType(Receive,Ship,PutAway,Pick),NumberOfBins,IsCrossDock);
Member of Lib.Library - Warehouse


NoSeriesSetup@13 Method

The procedure NoSeriesSetup is available in codeunit 132204.

Syntax

NoSeriesSetup@13(
    VAR WarehouseSetup@1000 : Record 5769 WarehouseSetup //Reference parameter of type Record
);

Parameters

WarehouseSetup
Reference parameter of type Record

Remarks

The relevant search keywords are: No, Series, Setup.

For a clarification about how this function works, refer to the code listed below.

      WarehouseSetup.GET;
      WarehouseSetup.VALIDATE("Posted Whse. Receipt Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      WarehouseSetup.VALIDATE("Posted Whse. Shipment Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      WarehouseSetup.VALIDATE("Registered Whse. Movement Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      WarehouseSetup.VALIDATE("Registered Whse. Pick Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      WarehouseSetup.VALIDATE("Registered Whse. Put-away Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      WarehouseSetup.VALIDATE("Whse. Movement Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      WarehouseSetup.VALIDATE("Whse. Pick Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      WarehouseSetup.VALIDATE("Whse. Put-away Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      WarehouseSetup.VALIDATE("Whse. Receipt Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      WarehouseSetup.VALIDATE("Whse. Ship Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      WarehouseSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137030 to show one way of using this function.

      LibraryInventory.NoSeriesSetup(InventorySetup);
      LibraryWarehouse.NoSeriesSetup(WarehouseSetup);

      SalesSetup.GET;
      SalesSetup.VALIDATE("Order Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      SalesSetup.MODIFY(TRUE);

      PurchasesPayablesSetup.GET;
      PurchasesPayablesSetup.VALIDATE("Order Nos.",LibraryUtility.GetGlobalNoSeriesCode);
      PurchasesPayablesSetup.MODIFY(TRUE);
Member of Lib.Library - Warehouse


PostAndPrintInventoryActivity@124 Method

The procedure PostAndPrintInventoryActivity is available in codeunit 132204.

Syntax

PostAndPrintInventoryActivity@124(
    VAR WarehouseActivityHeader@1000 : Record 5766 WarehouseActivityHeader, //Reference parameter of type Record
    Invoice@1003 : Boolean Invoice, //Input parameter of type Boolean
    Print@1004 : Boolean Print //Input parameter of type Boolean
);

Parameters

WarehouseActivityHeader
Reference parameter of type Record
Invoice
Input parameter of type Boolean
Print
Input parameter of type Boolean

Remarks

The relevant search keywords are: Post, Print, Inventory, Activity.

For a clarification about how this function works, refer to the code listed below.

      WarehouseActivityLine.SETRANGE("Activity Type",WarehouseActivityHeader.Type);
      WarehouseActivityLine.SETRANGE("No.",WarehouseActivityHeader."No.");
      WarehouseActivityLine.FINDFIRST;

      WhseActivityPost.SetInvoiceSourceDoc(Invoice);
      WhseActivityPost.PrintDocument(Print);
      WhseActivityPost.RUN(WarehouseActivityLine);
      CLEAR(WhseActivityPost);

Example

The below example is extracted from the test automation codeunit 137293 to show one way of using this function.

      // [FEATURE] [Transfer Order] [Warehouse] [Put-away] [Report]
      // [SCENARIO 375628] Post and print Inbound Transfer Warehouse Activity

      // [GIVEN] Warehouse Put-away Activity Header obtained from transfer shipment
      Initialize;
      CreateItem(Item,Item."Replenishment System"::Purchase);
      CreateInitialSetupForTransferOrder(TransferLine,Item."No.",FALSE,FALSE,FALSE,TRUE);
      TransferHeader.GET(TransferLine."Document No.");
      Location.GET(TransferHeader."Transfer-to Code");
      Location.VALIDATE("Require Put-away",TRUE);
      Location.MODIFY(TRUE);
      LibraryInventory.PostTransferHeader(TransferHeader,TRUE,FALSE);
      TransferHeader.CreateInvtPutAwayPick;
      WarehouseActivityHeader.SETRANGE("Location Code",TransferHeader."Transfer-to Code");
      WarehouseActivityHeader.FINDFIRST;
      LibraryWarehouse.AutoFillQtyInventoryActivity(WarehouseActivityHeader);

      // Arguments for TransferReceiptReportDataHandler
      ReceiptFileName := FileManagement.ServerTempFileName('xlsx');
      LibraryVariableStorage.Enqueue(TransferHeader."Transfer-from Code");
      LibraryVariableStorage.Enqueue(ReceiptFileName);

      // [WHEN] Post and Print Acitivity
      LibraryWarehouse.PostAndPrintInventoryActivity(WarehouseActivityHeader,FALSE,TRUE);

      // [THEN] Report output file created
      LibraryReportValidation.SetFullFileName(ReceiptFileName);
      LibraryReportValidation.VerifyCellValueByRef('G',17,1,FindReceiptNoByLocation(TransferHeader."Transfer-from Code"));
      LibraryVariableStorage.AssertEmpty;
Member of Lib.Library - Warehouse


PostInventoryActivity@69 Method

The procedure PostInventoryActivity is available in codeunit 132204.

Syntax

PostInventoryActivity@69(
    VAR WarehouseActivityHeader@1000 : Record 5766 WarehouseActivityHeader, //Reference parameter of type Record
    Invoice@1003 : Boolean Invoice //Input parameter of type Boolean
);

Parameters

WarehouseActivityHeader
Reference parameter of type Record
Invoice
Input parameter of type Boolean

Remarks

The relevant search keywords are: Post, Inventory, Activity.

For a clarification about how this function works, refer to the code listed below.

      PostAndPrintInventoryActivity(WarehouseActivityHeader,Invoice,FALSE);

Example

The below example is extracted from the test automation codeunit 137005 to show one way of using this function.

      // [FEATURE] [Warehouse] [Pick] [Production Order]
      // This is implementation for Scenario 1, bug 40394 from "Navision Corsica" database

      Initialize;

      // Step 1 - Create item hiercarchy: BOM with hierachy: PARENT and CHILD
      // Add a new UOM to child item = KG
      CreateItemHierarchy(ProdBOMHeader,ParentItem,ChildItem,RANDOM(10));
      LibraryInventory.CreateItemUnitOfMeasure(ItemUOM,ChildItem."No.",KGConst,3);

      // Step 2 - Create location with require pick and require put-away
      CreatePickPutAwayLocation(Location);

      // Step 3 - Add 1000 PCS of child item into inventory by posting item journal into created location
      LibraryInventory.FindItemJournalTemplate(ItemJournalTemplate);
      ItemJournalBatch.SETRANGE("Journal Template Name",ItemJournalTemplate.Name);
      ItemJournalBatch.FINDFIRST;
      LibraryInventory.CreateItemJournalLine(
        ItemJournalLine,ItemJournalTemplate.Name,ItemJournalBatch.Name,ItemJournalLine."Entry Type"::"Positive Adjmt.",
        ChildItem."No.",1000);
      ItemJournalLine.VALIDATE("Location Code",Location.Code);
      ItemJournalLine.MODIFY(TRUE);
      LibraryInventory.PostItemJournalLine(ItemJournalTemplate.Name,ItemJournalBatch.Name);

      // Step 4 - Create released production order for new item and refresh it
      CreateReleasedProdOrderAndRefresh(ProductionOrder,ParentItem,Location.Code,RANDOM(10));

      // Step 5 - change the UOM to KG on the component lines
      ChangeUOMOnComponentLines(ProductionOrder,KGConst);

      // Step 6 - create the inventory pick
      WarehouseRequest.SETFILTER("Source Document",'%1|%2',
        WarehouseRequest."Source Document"::"Prod. Consumption",
        WarehouseRequest."Source Document"::"Prod. Output");
      WarehouseRequest.SETRANGE("Source No.",ProductionOrder."No.");
      LibraryWarehouse.CreateInvtPutPickMovement(
        WarehouseRequest."Source Document"::"Prod. Consumption",ProductionOrder."No.",FALSE,TRUE,FALSE);

      // Step 7 - autofill qty to handle and post pick
      Assert.IsTrue(FindAndSelInvActvOnSrcNoAndLoc(WarehouseActivityHeader,
          WarehouseActivityHeader."Source Document"::"Prod. Consumption",ProductionOrder."No.",Location.Code),
        NoPutAwayCreatedForPrdOrdConst);

      LibraryWarehouse.AutoFillQtyInventoryActivity(WarehouseActivityHeader);
      LibraryWarehouse.PostInventoryActivity(WarehouseActivityHeader,TRUE);

      // Step 8 - verify that the pick has been posted - it has been deleted
      Assert.IsFalse(FindAndSelInvActvOnSrcNoAndLoc(WarehouseActivityHeader,
          WarehouseActivityHeader."Source Document"::"Prod. Consumption",ProductionOrder."No.",Location.Code),
        PutAwayNotDeletedConst);

      // Step 9 - Verify that pick has been posted - in history
      Assert.IsTrue(
        FindAndSelPstPickOnSrcNoAndLoc(PostedInvtPickHeader,
          PostedInvtPickHeader."Source Document"::"Prod. Consumption",ProductionOrder."No.",Location.Code),
        PickNotFoundInHistoryConst);
Member of Lib.Library - Warehouse


PostTransferOrder@43 Method

The procedure PostTransferOrder is available in codeunit 132204.

Syntax

PostTransferOrder@43(
    VAR TransferHeader@1000 : Record 5740 TransferHeader, //Reference parameter of type Record
    Ship@1001 : Boolean Ship, //Input parameter of type Boolean
    Receive@1002 : Boolean Receive //Input parameter of type Boolean
);

Parameters

TransferHeader
Reference parameter of type Record
Ship
Input parameter of type Boolean
Receive
Input parameter of type Boolean

Remarks

The relevant search keywords are: Post, Transfer, Order.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(TransferOrderPostShipment);
      IF Ship THEN
        TransferOrderPostShipment.RUN(TransferHeader);
      IF Receive THEN BEGIN
        TransferOrderPostReceipt.SetHideValidationDialog(TRUE);
        TransferOrderPostReceipt.RUN(TransferHeader);
      END;

Example

The below example is extracted from the test automation codeunit 136121 to show one way of using this function.

      // Check Reservation on Service Order with Purchase Order and Transfer Order.

      // 1. Setup: Create and post Purchase Order, Transfer Order and Service Line.
      Initialize;
      CreatePurchaseOrder(PurchaseLine);
      OriginalQuantity := PurchaseLine.Quantity;  // Assign in global variable.
      ItemNo := PurchaseLine."No.";  // Assign in global variable.
      PurchaseHeader.GET(PurchaseLine."Document Type",PurchaseLine."Document No.");
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,FALSE);
      CreateTransferOrder(TransferHeader,PurchaseHeader."Location Code");
      LibraryWarehouse.PostTransferOrder(TransferHeader,TRUE,TRUE);
      LibrarySales.CreateCustomer(Customer);
      LibraryService.CreateServiceHeader(ServiceHeader,ServiceHeader."Document Type"::Order,Customer."No.");
      LibraryService.CreateServiceItemLine(ServiceItemLine,ServiceHeader,'');
      LibraryService.CreateServiceLine(ServiceLine,ServiceHeader,ServiceLine.Type::Item,ItemNo);
      UpdateServiceLine(ServiceLine,TransferHeader."Transfer-to Code",ServiceItemLine."Line No.");
      QuantityOnServiceLine := ServiceLine.Quantity;

      ReserveFromCurrentLine := TRUE;  // Assign in global variable.
      OpenServiceLinesPage(ServiceHeader."No.");
      LibraryService.PostServiceOrder(ServiceHeader,TRUE,FALSE,FALSE);
      ReserveFromCurrentLine := FALSE;  // Assign in global variable.

      // 2. Exercise:
      OpenServiceLinesPage(ServiceHeader."No.");

      // 3. Verfiy: Verify Reservation page values.
      // Verification done in 'ReservationHandler'.
Member of Lib.Library - Warehouse


PostWhseAdjustment@48 Method

The procedure PostWhseAdjustment is available in codeunit 132204.

Syntax

PostWhseAdjustment@48(
    VAR Item@1002 : Record 27 Item //Reference parameter of type Record
);

Parameters

Item
Reference parameter of type Record

Remarks

The relevant search keywords are: Post, Warehouse, Adjustment.

For a clarification about how this function works, refer to the code listed below.

      LibraryAssembly.SetupItemJournal(ItemJournalTemplate,ItemJournalBatch);
      CalculateWhseAdjustment(Item,ItemJournalBatch);
      LibraryInventory.PostItemJournalLine(ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name);

Example

The below example is extracted from the test automation codeunit 137106 to show one way of using this function.

      // [FEATURE] [Pick]
      // [SCENARIO 207772] Pick line with Quantity = 0 is not created when first available bin content is assigned to the same warehouse pick

      Initialize;

      // [GIVEN] Item "C" is an assembly component for item "P", qty. required to assembly one item "I" is 200
      // [GIVEN] Component item "C" has an additional unit of measure "BOX", base UoM is "PCS", qty. per unit of measure is 200
      CreateItems(Tracking::Untracked);
      QtyPerUoM := LibraryRandom.RandIntInRange(100,200);
      QtyToConsume := LibraryRandom.RandInt(5);
      QtyToSell := LibraryRandom.RandIntInRange(6,10);
      LibraryInventory.CreateItemUnitOfMeasureCode(ItemUnitOfMeasure,CompItem."No.",QtyPerUoM);
      LibraryManufacturing.CreateBOMComponent(
        BOMComponent,KitItem."No.",BOMComponent.Type::Item,CompItem."No.",QtyPerUoM,CompItem."Base Unit of Measure");

      // [GIVEN] Purchase and put-away 1 box of component item "C" into a bin "B2"
      FindPutAwayPickZone(Zone,LocationWMS.Code);
      LibraryAssembly.SetupWarehouseJournal(WarehouseJournalTemplate,WarehouseJournalBatch,LocationWMS.Code);
      LibraryWarehouse.FindBin(Bin,LocationWMS.Code,Zone.Code,2);
      CreateWhseJournalLine(WarehouseJournalBatch,Bin,CompItem."No.",QtyToConsume,ItemUnitOfMeasure.Code);
      // [GIVEN] Purchase and put-away 3 boxes of component item "C" into a bin "B1"
      LibraryWarehouse.FindBin(Bin,LocationWMS.Code,Zone.Code,1);
      CreateWhseJournalLine(WarehouseJournalBatch,Bin,CompItem."No.",QtyToSell,ItemUnitOfMeasure.Code);

      LibraryWarehouse.RegisterWhseJournalLine(
        WarehouseJournalBatch."Journal Template Name",WarehouseJournalBatch.Name,LocationWMS.Code,TRUE);
      LibraryWarehouse.PostWhseAdjustment(CompItem);

      // [GIVEN] Create a sales order with 2 lines
      // [GIVEN] 1st line - 1 item "P" which requires 1 box of components to assemble
      // [GIVEN] 2nd line - 2 boxes of item "C"
      LibrarySales.CreateSalesDocumentWithItem(
        SalesHeader,SalesLine,SalesHeader."Document Type"::Order,LibrarySales.CreateCustomerNo,KitItem."No.",QtyToConsume,
        LocationWMS.Code,WorkDate2);
      SalesLine.VALIDATE("Qty. to Assemble to Order",SalesLine.Quantity);
      SalesLine.MODIFY(TRUE);

      LibrarySales.CreateSalesLine(SalesLine,SalesHeader,SalesLine.Type::Item,CompItem."No.",QtyToSell);
      SalesLine.VALIDATE("Unit of Measure Code",ItemUnitOfMeasure.Code);
      SalesLine.MODIFY(TRUE);

      LibrarySales.ReleaseSalesDocument(SalesHeader);
      LibraryWarehouse.CreateWhseShipmentFromSO(SalesHeader);

      // [WHEN] Create warehouse shipment and pick from the sales order
      CreatePickFromSalesOrder(SalesHeader);

      // [THEN] Total quantity to pick for item "C" is 4 boxes
      // [THEN] There are no pick lines with Quantity = 0
      WarehouseActivityLine.SETRANGE("Item No.",CompItem."No.");
      WarehouseActivityLine.SETRANGE("Action Type",WarehouseActivityLine."Action Type"::Take);
      WarehouseActivityLine.SETRANGE("Unit of Measure Code",ItemUnitOfMeasure.Code);
      WarehouseActivityLine.SETRANGE(Quantity,0);
      Assert.RecordIsEmpty(WarehouseActivityLine);

      WarehouseActivityLine.SETRANGE(Quantity);
      WarehouseActivityLine.CALCSUMS(Quantity);
      WarehouseActivityLine.TESTFIELD(Quantity,QtyToConsume + QtyToSell);
Member of Lib.Library - Warehouse


PostWhseJournalLine@28 Method

The procedure PostWhseJournalLine is available in codeunit 132204.

Syntax

PostWhseJournalLine@28(
    JournalTemplateName@1002 : Text[30] JournalTemplateName, //Input parameter of type Text
    JournalBatchName@1001 : Text[30] JournalBatchName, //Input parameter of type Text
    Location@1003 : Text[30] Location //Input parameter of type Text
);

Parameters

JournalTemplateName
Input parameter of type Text
JournalBatchName
Input parameter of type Text
Location
Input parameter of type Text

Remarks

The relevant search keywords are: Post, Warehouse, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(WhseJnlRegisterBatch);
      WarehouseJournalLine.SETRANGE("Journal Template Name",JournalTemplateName);
      WarehouseJournalLine.SETRANGE("Journal Batch Name",JournalBatchName);
      WarehouseJournalLine.SETRANGE("Location Code",Location);
      IF WarehouseJournalLine.FINDFIRST THEN
        WhseJnlRegisterBatch.RUN(WarehouseJournalLine);

Example

The below example is extracted from the test automation codeunit 137502 to show one way of using this function.

      FindItemJournal(ItemJournalTemplate,ItemJournalBatch);
      Location.GET(LocationCode);
      IF Location."Directed Put-away and Pick" THEN BEGIN
        FindWhseJournal(WhseJournalTemplate,WhseJournalBatch,LocationCode);
        LibraryWarehouse.CreateWhseJournalLine(
          WarehouseJournalLine,WhseJournalTemplate.Name,WhseJournalBatch.Name,
          LocationCode,'',BinCode,WarehouseJournalLine."Entry Type"::"Positive Adjmt.",Item."No.",Quantity);
        LibraryWarehouse.PostWhseJournalLine(WhseJournalTemplate.Name,WhseJournalBatch.Name,Location.Code);
        LibraryWarehouse.CalculateWhseAdjustmentItemJournal(Item,WORKDATE,'');
      END ELSE BEGIN
        LibraryInventory.CreateItemJournalLine(ItemJournalLine,ItemJournalTemplate.Name,ItemJournalBatch.Name,
          ItemJournalLine."Entry Type"::"Positive Adjmt.",Item."No.",Quantity);
        ItemJournalLine.VALIDATE("Location Code",LocationCode);
        ItemJournalLine.VALIDATE("Bin Code",BinCode);
        ItemJournalLine.MODIFY(TRUE);
      END;
      LibraryInventory.PostItemJournalLine(ItemJournalTemplate.Name,ItemJournalBatch.Name);
Member of Lib.Library - Warehouse


PostWhseRcptWithConfirmMsg@8 Method

The procedure PostWhseRcptWithConfirmMsg is available in codeunit 132204.

Syntax

PostWhseRcptWithConfirmMsg@8(
    No@1000 : Code[20] No //Input parameter of type Code
);

Parameters

No
Input parameter of type Code

Remarks

The relevant search keywords are: Post, Warehouse, Rcpt, Confirm, Msg.

For a clarification about how this function works, refer to the code listed below.

      WarehouseReceiptLine.SETRANGE("No.",No);
      IF WarehouseReceiptLine.FINDFIRST THEN
        WhsePostReceiptYesNo.RUN(WarehouseReceiptLine);

Example

The below example is extracted from the test automation codeunit 137047 to show one way of using this function.

      // Setup: Create setups, Item and Customer with Dimensions.
      Initialize;
      WarehouseSetup.GET;
      UpdateWarehouseSetup(
        WarehouseSetup."Shipment Posting Policy"::"Posting errors are not processed",
        WarehouseSetup."Receipt Posting Policy"::"Posting errors are not processed");
      CreateItem(Item);
      CreateLocationSetup(Location,FALSE,TRUE,TRUE);
      UpdateItemInventory(Item."No.",Location.Code);
      CreateCustomer(Customer,Location.Code);

      // Create Sales Return Order setup. Create Warehouse Receipt using Filters to get Source document.
      CreateSalesSetup(
        SalesHeader,SalesHeader2,SalesHeader."Document Type"::"Return Order",Item."No.",Location.Code,Customer."No.");
      UseFiltersToGetSrcDocReceipt(WarehouseReceiptHeader,Customer."No.",'',Location.Code);

      // Exercise: Post Warehouse Receipt such that it generates the posting confirmation message.
      LibraryWarehouse.PostWhseRcptWithConfirmMsg(WarehouseReceiptHeader."No.");

      // Verify: Check message inside Handler and verify that correct receipt line has been posted.
      VerifyPostedReceiptLinesSales(WarehouseReceiptHeader."No.",Item."No.",SalesHeader."No.");

      // Teardown.
      UpdateWarehouseSetup(WarehouseSetup."Shipment Posting Policy",WarehouseSetup."Receipt Posting Policy");
Member of Lib.Library - Warehouse


PostWhseReceipt@112 Method

The procedure PostWhseReceipt is available in codeunit 132204.

Syntax

PostWhseReceipt@112(
    VAR WarehouseReceiptHeader@1001 : Record 7316 WarehouseReceiptHeader //Reference parameter of type Record
);

Parameters

WarehouseReceiptHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Post, Warehouse, Receipt.

For a clarification about how this function works, refer to the code listed below.

      WarehouseReceiptLine.SETRANGE("No.",WarehouseReceiptHeader."No.");
      IF WarehouseReceiptLine.FINDFIRST THEN
        WhsePostReceipt.RUN(WarehouseReceiptLine);

Example

The below example is extracted from the test automation codeunit 134327 to show one way of using this function.

      // Verify Program generates the Posted Purchase Receipt on same posting date of Warehouse Receipt Header posting date.

      // Setup: Create purchase order & create warehouse receipt for purchase order.
      Initialize;
      CreatePurchaseOrder(PurchaseHeader,PurchaseLine,CreateItem);
      ModifyLocationOnPurchaseLine(PurchaseLine);
      LibraryPurchase.ReleasePurchaseDocument(PurchaseHeader);
      LibraryWarehouse.CreateWhseReceiptFromPO(PurchaseHeader);
      ModifyPostingDateOnWarehouseReceiptHeader(WarehouseReceiptHeader,PurchaseHeader."No.",PurchaseLine."No.");

      // Exercise: Post Warehouse Document.
      LibraryWarehouse.PostWhseReceipt(WarehouseReceiptHeader);

      // Verify: Verify Purch Rcpt-Header posting date equal to Warehouse Receipt Header posting date.
      VerifyPurchRcptHeader(PurchaseHeader."No.",PurchaseHeader."Buy-from Vendor No.",WarehouseReceiptHeader."Posting Date");
Member of Lib.Library - Warehouse


PostWhseShipment@1 Method

The procedure PostWhseShipment is available in codeunit 132204.

Syntax

PostWhseShipment@1(
    WarehouseShipmentHeader@1001 : Record 7320 WarehouseShipmentHeader, //Input parameter of type Record
    Invoice@1003 : Boolean Invoice //Input parameter of type Boolean
);

Parameters

WarehouseShipmentHeader
Input parameter of type Record
Invoice
Input parameter of type Boolean

Remarks

The relevant search keywords are: Post, Warehouse, Shipment.

For a clarification about how this function works, refer to the code listed below.

      WhsePostShipment.SetPostingSettings(Invoice);
      WarehouseShipmentLine.SETRANGE("No.",WarehouseShipmentHeader."No.");
      IF WarehouseShipmentLine.FINDFIRST THEN
        WhsePostShipment.RUN(WarehouseShipmentLine);

Example

The below example is extracted from the test automation codeunit 136140 to show one way of using this function.

      Initialize;

      // SETUP: Create Service order on WHITE Location and Release Service Order, Create Whse Shpment header using Get Source Doc
      LocationCode := WMSFullLocation;
      Quantity := RANDOM(100);
      CreateItemAndSupply(Item,LocationCode,Quantity);

      CreateServiceOrderAndServiceLines(ServiceHeader,Item."No.",Quantity,LocationCode);
      LibraryService.ReleaseServiceDocument(ServiceHeader);

      CreateWareHouseShipmentHeader(WarehouseShipmentHeader,LocationCode);
      AddWarehouseShipmentLineUsingGetSourceDocument(WarehouseShipmentHeader,ServiceHeader."No.",ServiceOrderInGrid);

      // EXECUTE: Create Pick, Register Pick and post Warehouse shipment with ship option.
      LibraryWarehouse.CreatePick(WarehouseShipmentHeader);
      RegisterWarehouseActivity(ServiceHeader."No.",WarehouseActivityLine."Activity Type"::Pick);
      LibraryWarehouse.PostWhseShipment(WarehouseShipmentHeader,FALSE);

      // Verify: All service lines are present in warehouse shipment and the quantities match
      GetAllServiceLinesOfTypeItem(ServiceLine,ServiceHeader);
      Assert.AreEqual(Quantity,ServiceLine."Quantity Shipped",ServiceLine.FIELDCAPTION("Quantity Shipped"));
      Assert.AreEqual(Quantity,ServiceLine."Qty. Shipped Not Invoiced",ServiceLine.FIELDCAPTION("Qty. Shipped Not Invoiced"));
Member of Lib.Library - Warehouse


PostWhseShptWithShipInvoiceMsg@6 Method

The procedure PostWhseShptWithShipInvoiceMsg is available in codeunit 132204.

Syntax

PostWhseShptWithShipInvoiceMsg@6(
    No@1000 : Code[20] No //Input parameter of type Code
);

Parameters

No
Input parameter of type Code

Remarks

The relevant search keywords are: Post, Warehouse, Shpt, Ship, Invoice, Msg.

For a clarification about how this function works, refer to the code listed below.

      WarehouseShipmentLine.SETRANGE("No.",No);
      IF WarehouseShipmentLine.FINDFIRST THEN
        WhsePostShipShipInvoic.RUN(WarehouseShipmentLine);

Example

The below example is extracted from the test automation codeunit 137047 to show one way of using this function.

      // Setup: Create setups, Item and Customer with Dimensions.
      Initialize;
      WarehouseSetup.GET;
      UpdateWarehouseSetup(
        WarehouseSetup."Shipment Posting Policy"::"Posting errors are not processed",
        WarehouseSetup."Receipt Posting Policy"::"Posting errors are not processed");
      CreateItem(Item);
      CreateLocationSetup(Location,FALSE,TRUE,TRUE);
      UpdateItemInventory(Item."No.",Location.Code);
      CreateCustomer(Customer,Location.Code);

      // Create Sales Order Setup. Create Warehouse Shipment using Filters to get Source document.
      CreateSalesSetup(SalesHeader,SalesHeader2,SalesHeader."Document Type"::Order,Item."No.",Location.Code,Customer."No.");
      UseFiltersToGetSrcDocShipment(WarehouseShipmentHeader,Customer."No.",'',Location.Code,'');

      // Exercise: Post Warehouse Shipment such that it generates the posting confirmation message.
      LibraryWarehouse.PostWhseShptWithShipInvoiceMsg(WarehouseShipmentHeader."No.");

      // Verify: Check message inside Handler and verify that correct shipment line has been posted.
      VerifyPostedShipmentLinesSales(WarehouseShipmentHeader."No.",Item."No.",SalesHeader."No.");

      // Teardown.
      UpdateWarehouseSetup(WarehouseSetup."Shipment Posting Policy",WarehouseSetup."Receipt Posting Policy");
Member of Lib.Library - Warehouse


RegisterWhseActivity@65 Method

The procedure RegisterWhseActivity is available in codeunit 132204.

Syntax

RegisterWhseActivity@65(
    VAR WarehouseActivityHeader@1000 : Record 5766 WarehouseActivityHeader //Reference parameter of type Record
);

Parameters

WarehouseActivityHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Register, Warehouse, Activity.

For a clarification about how this function works, refer to the code listed below.

      WarehouseActivityLine.SETRANGE("Activity Type",WarehouseActivityHeader.Type);
      WarehouseActivityLine.SETRANGE("No.",WarehouseActivityHeader."No.");
      WarehouseActivityLine.FINDFIRST;
      WMSMgt.CheckBalanceQtyToHandle(WarehouseActivityLine);
      WhseActivityRegister.RUN(WarehouseActivityLine);

Example

The below example is extracted from the test automation codeunit 136140 to show one way of using this function.

      WarehouseActivityHeader.SETRANGE(Type,Type);
      WarehouseActivityHeader.SETRANGE("No.",FindWarehouseActivityNo(SourceNo,Type));
      WarehouseActivityHeader.FINDFIRST;
      IF Type = 1 THEN // Put-away
        PlaceInNonPickableZones(WarehouseActivityHeader);
      LibraryWarehouse.RegisterWhseActivity(WarehouseActivityHeader);
Member of Lib.Library - Warehouse


RegisterWhseJournalLine@108 Method

The procedure RegisterWhseJournalLine is available in codeunit 132204.

Syntax

RegisterWhseJournalLine@108(
    JournalTemplateName@1001 : Text[10] JournalTemplateName, //Input parameter of type Text
    JournalBatchName@1002 : Text[10] JournalBatchName, //Input parameter of type Text
    LocationCode@1000 : Code[10] LocationCode, //Input parameter of type Code
    UseBatchJob@1004 : Boolean UseBatchJob //Input parameter of type Boolean
);

Parameters

JournalTemplateName
Input parameter of type Text
JournalBatchName
Input parameter of type Text
LocationCode
Input parameter of type Code
UseBatchJob
Input parameter of type Boolean

Remarks

The relevant search keywords are: Register, Warehouse, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      WarehouseJournalLine.INIT;
      WarehouseJournalLine.VALIDATE("Journal Template Name",JournalTemplateName);
      WarehouseJournalLine.VALIDATE("Journal Batch Name",JournalBatchName);
      WarehouseJournalLine.VALIDATE("Location Code",LocationCode);
      // Batch job doesn't show confirmation dialog about registering journal lines and message dialog that they have been registered.
      IF UseBatchJob THEN
        CODEUNIT.RUN(CODEUNIT::"Whse. Jnl.-Register Batch",WarehouseJournalLine)
      ELSE
        CODEUNIT.RUN(CODEUNIT::"Whse. Jnl.-Register",WarehouseJournalLine);

Example

The below example is extracted from the test automation codeunit 136140 to show one way of using this function.

      LibraryWarehouse.RegisterWhseJournalLine(
        WarehouseJournalBatch."Journal Template Name",WarehouseJournalBatch.Name,LocationCode,TRUE);
      ItemJournalSetup;
      LibraryWarehouse.CalculateWhseAdjustment(Item,ItemJournalBatch);
      LibraryInventory.PostItemJournalLine(ItemJournalBatch."Journal Template Name",ItemJournalBatch.Name);
Member of Lib.Library - Warehouse


ReleaseTransferOrder@100 Method

The procedure ReleaseTransferOrder is available in codeunit 132204.

Syntax

ReleaseTransferOrder@100(
    VAR TransferHeader@1001 : Record 5740 TransferHeader //Reference parameter of type Record
);

Parameters

TransferHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Release, Transfer, Order.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(ReleaseTransferDocument);
      ReleaseTransferDocument.RUN(TransferHeader);

Example

The below example is extracted from the test automation codeunit 137021 to show one way of using this function.

      // Setup
      Initialize;

      // Test setup
      TestSetup;
      LFLItemSetup(Item,TRUE,'','','',0,0,0);

      // Exercise
      CreateSalesReturnOrder(SalesHeader,Item,1,CALCDATE(PlanningStartDate,CALCDATE('<+1W+1D>',WORKDATE)),LocationOne.Code);
      CreateTransferOrder(
        TransferHeader,Item."No.",LocationWhite.Code,LocationOne.Code,CALCDATE(PlanningStartDate,CALCDATE('<+1W+1D>',WORKDATE)),1);
      LibraryWarehouse.ReleaseTransferOrder(TransferHeader);
      LibraryWarehouse.CreateWhseShipmentFromTO(TransferHeader);
      SalesPlan(Item,1,CALCDATE(PlanningStartDate,CALCDATE('<+1W+1D>',WORKDATE)),LocationOne.Code,LocationOne.Code);

      // Verify planning worksheet lines - check in doc section more info on the TDS
      AssertNumberOfLinesForItem(Item,1);
      AssertPlanningLine(Item,RequisitionLine."Action Message"::Cancel,0D,
        CALCDATE(PlanningStartDate,CALCDATE('<+1W+1D>',WORKDATE)),1,0,RequisitionLine."Ref. Order Type"::Transfer,'',1);
Member of Lib.Library - Warehouse


ReleaseWarehouseInternalPick@21 Method

The procedure ReleaseWarehouseInternalPick is available in codeunit 132204.

Syntax

ReleaseWarehouseInternalPick@21(
    VAR WhseInternalPickHeader@1001 : Record 7333 WhseInternalPickHeader //Reference parameter of type Record
);

Parameters

WhseInternalPickHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Release, Warehouse, Internal, Pick.

For a clarification about how this function works, refer to the code listed below.

      WhseInternalPickRelease.Release(WhseInternalPickHeader);

Example

The below example is extracted from the test automation codeunit 137154 to show one way of using this function.

      CreateWarehouseInternalPickHeader(WhseInternalPickHeader,Bin);
      CreateWarehouseInternalPickLine(WhseInternalPickLine,WhseInternalPickHeader,ItemNo,VariantCode,Quantity);
      LibraryWarehouse.ReleaseWarehouseInternalPick(WhseInternalPickHeader);
      WhseInternalPickLine.SetHideValidationDialog(TRUE);
      WhseInternalPickLine.CreatePickDoc(WhseInternalPickLine,WhseInternalPickHeader);
Member of Lib.Library - Warehouse


ReleaseWarehouseInternalPutAway@26 Method

The procedure ReleaseWarehouseInternalPutAway is available in codeunit 132204.

Syntax

ReleaseWarehouseInternalPutAway@26(
    VAR WhseInternalPutAwayHeader@1000 : Record 7331 WhseInternalPutAwayHeader //Reference parameter of type Record
);

Parameters

WhseInternalPutAwayHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Release, Warehouse, Internal, Put, Away.

For a clarification about how this function works, refer to the code listed below.

      WhseIntPutAwayRelease.Release(WhseInternalPutAwayHeader);

Example

The below example is extracted from the test automation codeunit 137152 to show one way of using this function.

      CreateWhseInternalPutawayHeader(WhseInternalPutAwayHeader,Bin."Location Code",Bin."Zone Code",Bin.Code);
      LibraryWarehouse.CreateWhseInternalPutawayLine(WhseInternalPutAwayHeader,WhseInternalPutAwayLine,ItemNo,Quantity);
      WhseInternalPutAwayLine.VALIDATE("Variant Code",VariantCode);
      WhseInternalPutAwayLine.MODIFY(TRUE);
      LibraryWarehouse.ReleaseWarehouseInternalPutAway(WhseInternalPutAwayHeader);
      WhseInternalPutAwayLine.CreatePutAwayDoc(WhseInternalPutAwayLine);
Member of Lib.Library - Warehouse


ReleaseWarehouseShipment@151 Method

The procedure ReleaseWarehouseShipment is available in codeunit 132204.

Syntax

ReleaseWarehouseShipment@151(
    VAR WarehouseShipmentHeader@1001 : Record 7320 WarehouseShipmentHeader //Reference parameter of type Record
);

Parameters

WarehouseShipmentHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Release, Warehouse, Shipment.

For a clarification about how this function works, refer to the code listed below.

      WhseShipmentRelease.Release(WarehouseShipmentHeader);

Example

The below example is extracted from the test automation codeunit 137015 to show one way of using this function.

      LibrarySales.ReleaseSalesDocument(SalesHeader);
      LibraryWarehouse.CreateWhseShipmentFromSO(SalesHeader);
      WhseShipmentLine.SETRANGE("Source Document",WhseShipmentLine."Source Document"::"Sales Order");
      WhseShipmentLine.SETRANGE("Source No.",SalesHeader."No.");
      WhseShipmentLine.FINDFIRST;
      WhseShipmentHeader.GET(WhseShipmentLine."No.");
      LibraryWarehouse.ReleaseWarehouseShipment(WhseShipmentHeader);
Member of Lib.Library - Warehouse


ReopenTransferOrder@37 Method

The procedure ReopenTransferOrder is available in codeunit 132204.

Syntax

ReopenTransferOrder@37(
    VAR TransferHeader@1001 : Record 5740 TransferHeader //Reference parameter of type Record
);

Parameters

TransferHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Reopen, Transfer, Order.

For a clarification about how this function works, refer to the code listed below.

      ReleaseTransferDocument.Reopen(TransferHeader);

Example

The below example is extracted from the test automation codeunit 137038 to show one way of using this function.

      // [FEATURE] [Warehouse Request] [Warehouse Receipt]
      // [SCENARIO 381426] Warehouse Request is created for shipped not received Transfer Order when "Require Receipt" is set on destination Location. The status of the Whse. Request matches the status of the Transfer Order.
      Initialize;

      // [GIVEN] Item with inventory on Location "L1".
      // [GIVEN] Two partially shipped not received Transfer Orders "T1", "T2" from "L1" to Location "L2".
      CreateTwoPartlyShipTransferOrders(TransferHeader,TRUE);

      // [GIVEN] "T2" is re-opened.
      LibraryWarehouse.ReopenTransferOrder(TransferHeader[2]);

      // [WHEN] Turn on "Require Receipt" on "L2".
      Location.GET(TransferHeader[1]."Transfer-to Code");
      Location.VALIDATE("Require Receive",TRUE);

      // [THEN] Warehouse Request with "Released" status is created for "T1".
      WarehouseRequest.GET(
        WarehouseRequest.Type::Inbound,Location.Code,DATABASE::"Transfer Line",1,TransferHeader[1]."No.");
      WarehouseRequest.TESTFIELD("Document Status",TransferHeader[1].Status::Released);

      // [THEN] Warehouse Request with "Open" status is created for "T2".
      WarehouseRequest.GET(
        WarehouseRequest.Type::Inbound,Location.Code,DATABASE::"Transfer Line",1,TransferHeader[2]."No.");
      WarehouseRequest.TESTFIELD("Document Status",TransferHeader[2].Status::Open);
Member of Lib.Library - Warehouse


ReopenWhseShipment@83 Method

The procedure ReopenWhseShipment is available in codeunit 132204.

Syntax

ReopenWhseShipment@83(
    VAR WhseShipmentHeader@1000 : Record 7320 WhseShipmentHeader //Reference parameter of type Record
);

Parameters

WhseShipmentHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Reopen, Warehouse, Shipment.

For a clarification about how this function works, refer to the code listed below.

      WhseShipmentRelease.Reopen(WhseShipmentHeader);

Example

The below example is extracted from the test automation codeunit 137016 to show one way of using this function.

      Location.GET(LocationCode);
      CASE DocumentType OF
        DocumentType::Shipment:
          BEGIN
            CreateReserveSalesOrder(SalesHeader,SalesLine,ItemNo,LocationCode,Qty,QtyToReserve);
            LibrarySales.ReleaseSalesDocument(SalesHeader);
            LibraryWarehouse.CreateWhseShipmentFromSO(SalesHeader);
            WhseShipmentLine.SETRANGE("Source Document",WhseShipmentLine."Source Document"::"Sales Order");
            WhseShipmentLine.SETRANGE("Source No.",SalesHeader."No.");
            WhseShipmentLine.FINDFIRST;
            TempWhseShipmentLine := WhseShipmentLine;
            TempWhseShipmentLine.INSERT;
            IF WhseShipmentLine."Bin Code" = '' THEN BEGIN
              GetZoneAndBin(ZoneCode,BinCode,LocationCode,ItemNo,FALSE);
              IF BinCode <> '' THEN
                WhseShipmentLine."Bin Code" := BinCode;
            END;
            WhseShipmentLine.MODIFY(TRUE);
            WhseShipmentHeader.GET(WhseShipmentLine."No.");
            BinContent.SETRANGE("Location Code",LocationCode);
            BinContent.SETRANGE("Item No.",ItemNo);
            BinContent.SETFILTER("Bin Code",'<>%1',WhseShipmentLine."Bin Code");
            IF Location."Bin Mandatory" AND
               (BinContent.COUNT = 0)
            THEN BEGIN // Item exists in the same bin as specified on the warehouse shipment line.
              ASSERTERROR LibraryWarehouse.CreatePick(WhseShipmentHeader);
              Assert.IsTrue(STRPOS(GETLASTERRORTEXT,ErrorNothingToHandle) > 0,
                'Creating picks with same bin on Take & Place lines not allowed');
              CLEARLASTERROR;
              Bin.SETRANGE("Location Code",LocationCode);
              Bin.SETFILTER(Code,'<>%1',WhseShipmentLine."Bin Code");
              Bin.FINDFIRST;
              WhseShipmentHeader.GET(WhseShipmentLine."No.");
              LibraryWarehouse.ReopenWhseShipment(WhseShipmentHeader);
              WhseShipmentLine.VALIDATE("Bin Code",Bin.Code);
              WhseShipmentLine.MODIFY(TRUE);
            END;
            LibraryWarehouse.CreatePick(WhseShipmentHeader);
            RegisterWhseActivity(
              WhseActivityLine."Activity Type"::Pick,WhseActivityLine."Source Document"::"Sales Order",
              WhseActivityLine."Whse. Document Type"::Shipment,SalesHeader."No.",WhseShipmentHeader."No.",'','',QtyToHandle);
          END;
        DocumentType::"Int. Pick":
          BEGIN
            LibraryWarehouse.CreateWhseInternalPickHeader(WhseInternalPickHeader,LocationCode);
            GetZoneAndBin(ZoneCode,BinCode,LocationCode,'',FALSE);
            WhseInternalPickHeader."To Zone Code" := ZoneCode;
            WhseInternalPickHeader."To Bin Code" := BinCode;
            WhseInternalPickHeader.MODIFY(TRUE);
            LibraryWarehouse.CreateWhseInternalPickLine(WhseInternalPickHeader,WhseInternalPickLine,ItemNo,Qty);
            TempWhseInternalPickLine := WhseInternalPickLine;
            TempWhseInternalPickLine.INSERT;
            CreatePickFromInternalPick(WhseInternalPickHeader);
            RegisterWhseActivity(
              WhseActivityLine."Activity Type"::Pick,WhseActivityLine."Source Document"::" ",
              WhseActivityLine."Whse. Document Type"::"Internal Pick",WhseInternalPickHeader."No.",WhseInternalPickHeader."No.",
              '','',QtyToHandle);
          END;
        DocumentType::"Sales Order":
          BEGIN
            CreateReserveSalesOrder(SalesHeader,SalesLine,ItemNo,LocationCode,Qty,QtyToReserve);
            LibrarySales.ReleaseSalesDocument(SalesHeader);
            TempSalesLine := SalesLine;
            TempSalesLine.INSERT;
            CreateInvtPutPick(WhseActivityLine."Source Document"::"Sales Order",SalesHeader."No.");
            RegisterWhseActivity(
              WhseActivityLine."Activity Type"::"Invt. Pick",WhseActivityLine."Source Document"::"Sales Order",
              WhseActivityLine."Whse. Document Type"::" ",SalesHeader."No.",'','','',QtyToHandle);
          END;
        DocumentType::"Transfer Order":
          BEGIN
            CreateReserveTransferOrder(
              TransferHeader,TransferLine,ItemNo,LocationCode,Qty,QtyToReserve);
            ReleaseTransferDocument.RUN(TransferHeader);
            TempTransferLine := TransferLine;
            TempTransferLine.INSERT;
            CreateInvtPutPick(WhseActivityLine."Source Document"::"Outbound Transfer",TransferHeader."No.");
            RegisterWhseActivity(
              WhseActivityLine."Activity Type"::"Invt. Pick",WhseActivityLine."Source Document"::"Outbound Transfer",
              WhseActivityLine."Whse. Document Type"::" ",TransferHeader."No.",'','','',QtyToHandle);
          END;
        DocumentType::"Rel. Prod. Order":
          BEGIN
            CreateReserveProdOrder(ProductionOrder,LocationCode,ItemNo,Qty,QtyToReserve);
            ProdOrderComponent.SETRANGE("Prod. Order No.",ProductionOrder."No.");
            ProdOrderComponent.SETRANGE(Status,ProductionOrder.Status);
            ProdOrderComponent.SETRANGE("Item No.",ItemNo);
            ProdOrderComponent.FINDFIRST;
            TempProdOrderComponent := ProdOrderComponent;
            TempProdOrderComponent.INSERT;
            ProductionOrder.SetHideValidationDialog(TRUE);
            ProductionOrder.CreatePick(USERID,0,FALSE,FALSE,FALSE);
            IF NOT Location."Directed Put-away and Pick" THEN
              GetZoneAndBin(ZoneCode,BinCode,LocationCode,ItemNo,FALSE)
            ELSE
              BinCode := '';
            RegisterWhseActivity(
              WhseActivityLine."Activity Type"::Pick,WhseActivityLine."Source Document"::"Prod. Consumption",
              WhseActivityLine."Whse. Document Type"::Production,ProductionOrder."No.",ProductionOrder."No.",'',BinCode,QtyToHandle);
          END;
        DocumentType::"Rel. Prod. Order - Invt.":
          BEGIN
            CreateReserveProdOrder(ProductionOrder,LocationCode,ItemNo,Qty,QtyToReserve);
            ProdOrderComponent.SETRANGE("Prod. Order No.",ProductionOrder."No.");
            ProdOrderComponent.SETRANGE(Status,ProductionOrder.Status);
            ProdOrderComponent.SETRANGE("Item No.",ItemNo);
            ProdOrderComponent.FINDFIRST;
            TempProdOrderComponent := ProdOrderComponent;
            TempProdOrderComponent.INSERT;
            CreateInvtPutPick(WhseActivityLine."Source Document"::"Prod. Consumption",ProductionOrder."No.");
            RegisterWhseActivity(
              WhseActivityLine."Activity Type"::"Invt. Pick",WhseActivityLine."Source Document"::"Prod. Consumption",
              WhseActivityLine."Whse. Document Type"::" ",ProductionOrder."No.",'','','',QtyToHandle);
          END;
      END
Member of Lib.Library - Warehouse


RunDateCompressWhseEntries@27 Method

The procedure RunDateCompressWhseEntries is available in codeunit 132204.

Syntax

RunDateCompressWhseEntries@27(
    ItemNo@1002 : Code[20] ItemNo //Input parameter of type Code
);

Parameters

ItemNo
Input parameter of type Code

Remarks

The relevant search keywords are: Run, Date, Compress, Warehouse, Entries.

For a clarification about how this function works, refer to the code listed below.

      COMMIT;  // Commit required for batch job report.
      CLEAR(DateCompressWhseEntries);
      WarehouseEntry.SETRANGE("Item No.",ItemNo);
      DateCompressWhseEntries.SETTABLEVIEW(WarehouseEntry);
      DateCompressWhseEntries.RUN;

Example

The below example is extracted from the test automation codeunit 137158 to show one way of using this function.

      // Setup: Create Item with Production BOM. Create and post Purchase Order as Receive for Child Item with Lot No. Create and refresh Released Production Order. Post the Production Journal.
      Initialize;
      QuantityPer := LibraryRandom.RandInt(10);
      Quantity := Quantity + LibraryRandom.RandInt(10);  // Greater value required for Quantity.
      CreateItemWithProductionBOM(ParentItem,ChildItem,QuantityPer);
      LibraryWarehouse.CreateBin(Bin,LocationYellow.Code,LibraryUtility.GenerateGUID,'','');
      LibraryPurchase.CreateVendor(Vendor);
      LotNo :=
        CreateAndPostPurchaseOrderWithLotItemTracking(
          PurchaseHeader,Vendor."No.",ChildItem."No.",Quantity * QuantityPer,LocationYellow.Code,Bin.Code);
      CreateAndRefreshProductionOrder(ProductionOrder,ParentItem."No.",Quantity,LocationYellow.Code,Bin.Code);
      PostProductionJournal(ProductionOrder);

      // Exercise.
      LibraryVariableStorage.Enqueue(DateCompressConfirmMsg);  // Enqueue for ConfirmHandler.
      LibraryWarehouse.RunDateCompressWhseEntries(ChildItem."No.");

      // Verify.
      VerifyWarehouseEntry(
        WarehouseEntry."Entry Type"::"Positive Adjmt.",ChildItem."No.",LocationYellow.Code,Bin.Code,Quantity * QuantityPer,LotNo);  // Value required for verification.
      VerifyWarehouseEntry(
        WarehouseEntry."Entry Type"::"Negative Adjmt.",ChildItem."No.",LocationYellow.Code,Bin.Code,-Quantity * QuantityPer,LotNo);  // Value required for verification.
Member of Lib.Library - Warehouse


SelectBinType@68 Method

The procedure SelectBinType is available in codeunit 132204.

Syntax

SelectBinType@68(
    Receive@1004 : Boolean Receive, //Input parameter of type Boolean
    Ship@1003 : Boolean Ship, //Input parameter of type Boolean
    PutAway@1002 : Boolean PutAway, //Input parameter of type Boolean
    Pick@1001 : Boolean Pick //Input parameter of type Boolean
);

Parameters

Receive
Input parameter of type Boolean
Ship
Input parameter of type Boolean
PutAway
Input parameter of type Boolean
Pick
Input parameter of type Boolean

Return Value

Code[10]

Remarks

The relevant search keywords are: Select, Bin, Type.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(BinType);
      BinType.INIT;

      BinType.SETRANGE(Receive,Receive);
      BinType.SETRANGE(Ship,Ship);
      BinType.SETRANGE("Put Away",PutAway);
      BinType.SETRANGE(Pick,Pick);
      IF NOT BinType.FINDFIRST THEN
        CreateBinType(BinType,Receive,Ship,PutAway,Pick);

      EXIT(BinType.Code);

Example

The below example is extracted from the test automation codeunit 137015 to show one way of using this function.

      // [FEATURE] [Pick Worksheet]
      // [SCENARIO 204644] It should be possible to set "Qty. to Handle" in the pick worksheet when item is reserved for the line's source document, and stock is partially allocated in a non-pickable bin
      Initialize;

      LibraryInventory.CreateItem(Item);
      LibraryWarehouse.CreateFullWMSLocation(Location,1);

      // [GIVEN] Create a warehouse receipt for 20 pcs of item "I" on a location with "Directed Put-away and Pick"
      PurchaseQty := LibraryRandom.RandIntInRange(20,50);
      // [GIVEN] Register a put-away for 10 pcs of item "I"
      CreatePurchase(Item."No.",Location.Code,PurchaseQty,PurchaseQty / 2);

      WarehouseActivityLine.SETRANGE("Location Code",Location.Code);
      WarehouseActivityLine.SETRANGE("Item No.",Item."No.");
      WarehouseActivityLine.SETRANGE("Action Type",WarehouseActivityLine."Action Type"::Place);
      WarehouseActivityLine.FINDFIRST;

      // [GIVEN] Put-away remaining 10 pcs into a put-away bin (non-pickable)
      Bin.SETRANGE("Location Code",Location.Code);
      Bin.SETRANGE("Bin Type Code",LibraryWarehouse.SelectBinType(FALSE,FALSE,TRUE,FALSE));
      Bin.FINDFIRST;

      WarehouseActivityLine.VALIDATE("Zone Code",Bin."Zone Code");
      WarehouseActivityLine.VALIDATE("Bin Code",Bin.Code);
      WarehouseActivityLine.MODIFY(TRUE);
      WarehouseActivityHeader.GET(WarehouseActivityLine."Activity Type",WarehouseActivityLine."No.");
      LibraryWarehouse.RegisterWhseActivity(WarehouseActivityHeader);

      SalesQty := PurchaseQty - LibraryRandom.RandInt(10);
      // [GIVEN] Create a sales order for 15 pcs of item "I" and reserve, do not post
      CreateSales(Item."No.",Location.Code,SalesQty,TRUE,FALSE,FALSE,0);
      // [GIVEN] Create another sales order for 5 pcs of item "I", reserve, release and create a warehouse shipment "WS"
      CreateSales(Item."No.",Location.Code,PurchaseQty - SalesQty,TRUE,TRUE,FALSE,0);

      // [GIVEN] In the pick worksheet, run "Get Warehouse Documents" and choose the shipment "WS" as a source
      LibraryVariableStorage.Enqueue(Location.Code);
      GetSingleWhsePickDoc(WhseWorksheetLine,Location.Code);

      // [WHEN] In the created pick worksheet lines, set "Qty. to Handle" = 5
      WhseWorksheetLine.VALIDATE("Qty. to Handle",WhseWorksheetLine.Quantity);

      // [THEN] Quantity is validated successfully
      WhseWorksheetLine.TESTFIELD("Qty. to Handle (Base)",WhseWorksheetLine."Qty. (Base)");
Member of Lib.Library - Warehouse


SelectWhseJournalBatchName@105 Method

The procedure SelectWhseJournalBatchName is available in codeunit 132204.

Syntax

SelectWhseJournalBatchName@105(
    VAR WarehouseJournalBatch@1000 : Record 7310 WarehouseJournalBatch, //Reference parameter of type Record
    WhseJournalBatchTemplateType@1001 : Option WhseJournalBatchTemplateType, //Input parameter of type Option
    WarehouseJournalTemplateName@1002 : Code[10] WarehouseJournalTemplateName, //Input parameter of type Code
    LocationCode@1003 : Code[10] LocationCode //Input parameter of type Code
);

Parameters

WarehouseJournalBatch
Reference parameter of type Record
WhseJournalBatchTemplateType
Input parameter of type Option
WarehouseJournalTemplateName
Input parameter of type Code
LocationCode
Input parameter of type Code

Remarks

The relevant search keywords are: Select, Warehouse, Journal, Batch, Name.

For a clarification about how this function works, refer to the code listed below.

      // Find Name for Batch Name.
      WarehouseJournalBatch.SETRANGE("Template Type",WhseJournalBatchTemplateType);
      WarehouseJournalBatch.SETRANGE("Journal Template Name",WarehouseJournalTemplateName);
      WarehouseJournalBatch.SETRANGE("Location Code",LocationCode);

      // If Warehouse Journal Batch not found then create it.
      IF NOT WarehouseJournalBatch.FINDFIRST THEN
        CreateWhseJournalBatch(WarehouseJournalBatch,WarehouseJournalTemplateName,LocationCode);

Example

The below example is extracted from the test automation codeunit 136140 to show one way of using this function.

      CLEAR(WarehouseJournalTemplate);
      WarehouseJournalTemplate.INIT;
      LibraryWarehouse.SelectWhseJournalTemplateName(WarehouseJournalTemplate,WarehouseJournalTemplate.Type::Item);
      WarehouseJournalTemplate.VALIDATE("No. Series",LibraryUtility.GetGlobalNoSeriesCode);
      WarehouseJournalTemplate.MODIFY(TRUE);

      CLEAR(WarehouseJournalBatch);
      WarehouseJournalBatch.INIT;
      LibraryWarehouse.SelectWhseJournalBatchName(
        WarehouseJournalBatch,WarehouseJournalTemplate.Type,WarehouseJournalTemplate.Name,LocationCode);
      WarehouseJournalBatch.VALIDATE("No. Series",LibraryUtility.GetGlobalNoSeriesCode);
      WarehouseJournalBatch.MODIFY(TRUE);
Member of Lib.Library - Warehouse


SelectWhseJournalTemplateName@106 Method

The procedure SelectWhseJournalTemplateName is available in codeunit 132204.

Syntax

SelectWhseJournalTemplateName@106(
    VAR WarehouseJournalTemplate@1000 : Record 7309 WarehouseJournalTemplate, //Reference parameter of type Record
    WarehouseJournalTemplateType@1001 : Option WarehouseJournalTemplateType //Input parameter of type Option
);

Parameters

WarehouseJournalTemplate
Reference parameter of type Record
WarehouseJournalTemplateType
Input parameter of type Option

Remarks

The relevant search keywords are: Select, Warehouse, Journal, Template, Name.

For a clarification about how this function works, refer to the code listed below.

      // Find Item Journal Template for the given Template Type.
      WarehouseJournalTemplate.SETRANGE(Type,WarehouseJournalTemplateType);
      WarehouseJournalTemplate.FINDFIRST;

Example

The below example is extracted from the test automation codeunit 136140 to show one way of using this function.

      CLEAR(WarehouseJournalTemplate);
      WarehouseJournalTemplate.INIT;
      LibraryWarehouse.SelectWhseJournalTemplateName(WarehouseJournalTemplate,WarehouseJournalTemplate.Type::Item);
      WarehouseJournalTemplate.VALIDATE("No. Series",LibraryUtility.GetGlobalNoSeriesCode);
      WarehouseJournalTemplate.MODIFY(TRUE);

      CLEAR(WarehouseJournalBatch);
      WarehouseJournalBatch.INIT;
      LibraryWarehouse.SelectWhseJournalBatchName(
        WarehouseJournalBatch,WarehouseJournalTemplate.Type,WarehouseJournalTemplate.Name,LocationCode);
      WarehouseJournalBatch.VALIDATE("No. Series",LibraryUtility.GetGlobalNoSeriesCode);
      WarehouseJournalBatch.MODIFY(TRUE);
Member of Lib.Library - Warehouse


SelectWhseWorksheetName@143 Method

The procedure SelectWhseWorksheetName is available in codeunit 132204.

Syntax

SelectWhseWorksheetName@143(
    VAR WhseWorksheetName@1000 : Record 7327 WhseWorksheetName, //Reference parameter of type Record
    WhseWorkSheetTemplateName@1002 : Code[10] WhseWorkSheetTemplateName, //Input parameter of type Code
    LocationCode@1003 : Code[10] LocationCode //Input parameter of type Code
);

Parameters

WhseWorksheetName
Reference parameter of type Record
WhseWorkSheetTemplateName
Input parameter of type Code
LocationCode
Input parameter of type Code

Remarks

The relevant search keywords are: Select, Warehouse, Worksheet, Name.

For a clarification about how this function works, refer to the code listed below.

      // Find Name for Warehouse Worksheet Name.
      WhseWorksheetName.SETRANGE("Worksheet Template Name",WhseWorkSheetTemplateName);
      WhseWorksheetName.SETRANGE("Location Code",LocationCode);

      // If Warehouse Worksheet Name not found then create it.
      IF NOT WhseWorksheetName.FINDFIRST THEN
        CreateWhseWorksheetName(WhseWorksheetName,WhseWorkSheetTemplateName,LocationCode);

Example

The below example is extracted from the test automation codeunit 137064 to show one way of using this function.

      LibraryWarehouse.SelectWhseWorksheetTemplate(WhseWorksheetTemplate,WhseWorksheetTemplate.Type::Movement);
      LibraryWarehouse.SelectWhseWorksheetName(WhseWorksheetName,WhseWorksheetTemplate.Name,LocationCode);
      LibraryWarehouse.CalculateBinReplenishment(DummyBinContent,WhseWorksheetName,LocationCode,TRUE,TRUE,FALSE);
Member of Lib.Library - Warehouse


SelectWhseWorksheetTemplate@144 Method

The procedure SelectWhseWorksheetTemplate is available in codeunit 132204.

Syntax

SelectWhseWorksheetTemplate@144(
    VAR WhseWorksheetTemplate@1002 : Record 7328 WhseWorksheetTemplate, //Reference parameter of type Record
    WarehouseJournalTemplateType@1001 : Option WarehouseJournalTemplateType //Input parameter of type Option
);

Parameters

WhseWorksheetTemplate
Reference parameter of type Record
WarehouseJournalTemplateType
Input parameter of type Option

Remarks

The relevant search keywords are: Select, Warehouse, Worksheet, Template.

For a clarification about how this function works, refer to the code listed below.

      // Find Item Journal Template for the given Template Type.
      WhseWorksheetTemplate.SETRANGE(Type,WarehouseJournalTemplateType);
      WhseWorksheetTemplate.FINDFIRST;

Example

The below example is extracted from the test automation codeunit 137015 to show one way of using this function.

      LibraryWarehouse.SelectWhseWorksheetTemplate(WhseWorksheetTemplate,WhseWorksheetTemplate.Type::Pick);
      LibraryWarehouse.CreateWhseWorksheetName(WhseWorksheetName,WhseWorksheetTemplate.Name,LocationCode);

      GetSourceDocOutbound.GetSingleWhsePickDoc(WhseWorksheetName."Worksheet Template Name",WhseWorksheetName.Name,LocationCode);
      WhseWorksheetLine.SETRANGE("Worksheet Template Name",WhseWorksheetTemplate.Name);
      WhseWorksheetLine.SETRANGE("Location Code",LocationCode);
      WhseWorksheetLine.FINDFIRST;
Member of Lib.Library - Warehouse


SetQtyHandleInventoryMovement@91 Method

The procedure SetQtyHandleInventoryMovement is available in codeunit 132204.

Syntax

SetQtyHandleInventoryMovement@91(
    WarehouseActivityHeader@1000 : Record 5766 WarehouseActivityHeader, //Input parameter of type Record
    Qty@1002 : Decimal Qty //Input parameter of type Decimal
);

Parameters

WarehouseActivityHeader
Input parameter of type Record
Qty
Input parameter of type Decimal

Remarks

The relevant search keywords are: Set, Quantity, Handle, Inventory, Movement.

For a clarification about how this function works, refer to the code listed below.

      SetQtyToHandleWhseActivity(WarehouseActivityHeader,Qty);

Example

The below example is extracted from the test automation codeunit 137030 to show one way of using this function.

      // Test setup
      TestSetup;
      ItemSetup(Item,Item."Replenishment System"::"Prod. Order",Item."Flushing Method"::Manual);

      FindBin(FirstBinD,Location,TRUE,1);
      FindBin(SecondBinND,Location,FALSE,2);
      FindBin(ThirdBinND,Location,FALSE,2);

      // Exercise
      AddInventoryNonDirectLocation(Item,Location,FirstBinD,1);
      AddInventoryNonDirectLocation(Item,Location,SecondBinND,2);
      CreateSalesOrder(SalesHeader,SalesLine,Item,Location,SecondBinND,1,WORKDATE);
      LibrarySales.ReleaseSalesDocument(SalesHeader);
      CreateInternalMovementGetBin(InternalMovementHeader,Item,Location,ThirdBinND,SecondBinND.Code);
      LibraryWarehouse.CreateInvtMvmtFromInternalMvmt(InternalMovementHeader);

      // Verify that inventory movement is created
      GetLastActvHdrCreatedNoSource(WhseActivityHdr,Location,WhseActivityHdr.Type::"Invt. Movement");
      AssertActivityLine(WhseActivityHdr,Item,SecondBinND,WhseActivityLine."Action Type"::Take,2,0,1,MSG_INVENTORY_MOVEMENT_LINE);
      AssertActivityLine(WhseActivityHdr,Item,ThirdBinND,WhseActivityLine."Action Type"::Place,2,0,1,MSG_INVENTORY_MOVEMENT_LINE);

      // This shouldn't be created - handle message - nothing to create
      LibraryWarehouse.CreateInvtPutPickMovement(WhseActivityHdr."Source Document"::"Sales Order",SalesHeader."No.",FALSE,TRUE,FALSE);

      // Set qty to handle 1 on invt movement and register
      LibraryWarehouse.SetQtyHandleInventoryMovement(WhseActivityHdr,1);
      LibraryWarehouse.RegisterWhseActivity(WhseActivityHdr);

      // Create pick again
      SalesLine.FIND;
      SalesLine.VALIDATE("Bin Code",ThirdBinND.Code);
      SalesLine.MODIFY(TRUE);
      LibraryWarehouse.CreateInvtPutPickMovement(WhseActivityHdr."Source Document"::"Sales Order",SalesHeader."No.",FALSE,TRUE,FALSE);

      // Verify pick
      AssertActivityHdr(WhseActivityHdr,Location,WhseActivityHdr.Type::"Invt. Pick",
        WhseActivityHdr."Source Document"::"Sales Order",SalesHeader."No.",1,MSG_INVENTORY_PICK);
      AssertActivityLine(WhseActivityHdr,Item,ThirdBinND,WhseActivityLine."Action Type"::Take,1,0,1,MSG_INVENTORY_PICK_LINE);
Member of Lib.Library - Warehouse


SetQtyToHandleInternalMovement@90 Method

The procedure SetQtyToHandleInternalMovement is available in codeunit 132204.

Syntax

SetQtyToHandleInternalMovement@90(
    InternalMovementHeader@1008 : Record 7346 InternalMovementHeader, //Input parameter of type Record
    Qty@1001 : Decimal Qty //Input parameter of type Decimal
);

Parameters

InternalMovementHeader
Input parameter of type Record
Qty
Input parameter of type Decimal

Remarks

The relevant search keywords are: Set, Quantity, To, Handle, Internal, Movement.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(InternalMovementLine);
      InternalMovementLine.SETRANGE("No.",InternalMovementHeader."No.");
      InternalMovementLine.FINDSET;
      REPEAT
        InternalMovementLine.VALIDATE(Quantity,Qty);
        InternalMovementLine.MODIFY(TRUE);
      UNTIL InternalMovementLine.NEXT = 0;

Example

The below example is extracted from the test automation codeunit 137030 to show one way of using this function.

      // Test setup
      TestSetup;
      ItemSetup(Item,Item."Replenishment System"::"Prod. Order",Item."Flushing Method"::Manual);

      FindBin(FirstBin,Location,FALSE,1);
      FindBin(SecondBin,Location,FALSE,2);

      // Exercise
      AddInventoryNonDirectLocation(Item,Location,FirstBin,10);
      CreateInternalMovementGetBin(InternalMovementHeader,Item,Location,SecondBin,FirstBin.Code);

      // Assert internal movement line
      AssertInternalMovementLine(InternalMovementHeader,Item,Location,FirstBin,SecondBin,10,1);

      // set qty to handle and create movement
      LibraryWarehouse.SetQtyToHandleInternalMovement(InternalMovementHeader,5);
      LibraryWarehouse.CreateInvtMvmtFromInternalMvmt(InternalMovementHeader);

      // Verify that inventory movement is created and internal movement deleted
      AssertInternalMovementDeleted(InternalMovementHeader);
      GetLastActvHdrCreatedNoSource(WhseActivityHdr,Location,WhseActivityHdr.Type::"Invt. Movement");
      AssertActivityLine(WhseActivityHdr,Item,FirstBin,WhseActivityLine."Action Type"::Take,5,0,1,MSG_INVENTORY_MOVEMENT_LINE);
      AssertActivityLine(WhseActivityHdr,Item,SecondBin,WhseActivityLine."Action Type"::Place,5,0,1,MSG_INVENTORY_MOVEMENT_LINE);
Member of Lib.Library - Warehouse


SetQtyToHandleWhseActivity@85 Method

The procedure SetQtyToHandleWhseActivity is available in codeunit 132204.

Syntax

SetQtyToHandleWhseActivity@85(
    WhseActivityHdr@1008 : Record 5766 WhseActivityHdr, //Input parameter of type Record
    Qty@1001 : Decimal Qty //Input parameter of type Decimal
);

Parameters

WhseActivityHdr
Input parameter of type Record
Qty
Input parameter of type Decimal

Remarks

The relevant search keywords are: Set, Quantity, To, Handle, Warehouse, Activity.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(WhseActivityLine);
      WhseActivityLine.SETRANGE("Activity Type",WhseActivityHdr.Type);
      WhseActivityLine.SETRANGE("No.",WhseActivityHdr."No.");
      WhseActivityLine.FINDSET;
      REPEAT
        WhseActivityLine.VALIDATE(Quantity,Qty);
        WhseActivityLine.MODIFY(TRUE);
      UNTIL WhseActivityLine.NEXT = 0;

Example

There are no examples available.
Member of Lib.Library - Warehouse


SetRequireReceiveOnWarehouseSetup@54 Method

The procedure SetRequireReceiveOnWarehouseSetup is available in codeunit 132204.

Syntax

SetRequireReceiveOnWarehouseSetup@54(
    RequireReceive@1000 : Boolean RequireReceive //Input parameter of type Boolean
);

Parameters

RequireReceive
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, Require, Receive, On, Warehouse, Setup.

For a clarification about how this function works, refer to the code listed below.

      WarehouseSetup.GET;
      WarehouseSetup.VALIDATE("Require Receive",RequireReceive);
      WarehouseSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137154 to show one way of using this function.

      // [FEATURE] [Purchase] [Release] [Receipt] [Location]
      // [SCENARIO 222722] Cassie can create warehouse shipments from sales order having lines with blank and filled locaitons
      Initialize;

      // [GIVEN] "Require Receive" = TRUE in warehouse setup
      LibraryWarehouse.SetRequireReceiveOnWarehouseSetup(TRUE);

      // [GIVEN] Purchase order with two lines
      // [GIVEN] "Purchase Line"[1] with "Location Code" = "X" for item "A"
      // [GIVEN] "Purchase Line"[2] with blank "Location Code" for item "B"
      LibraryInventory.CreateItem(Item);
      CreatePurchaseDocument(
        PurchaseHeader,PurchaseLine,PurchaseHeader."Document Type"::Order,
        Item."No.",LocationWhite.Code,LibraryRandom.RandIntInRange(5,10));
      LibraryPurchase.CreatePurchaseLine(
        PurchaseLine,PurchaseHeader,PurchaseLine.Type::Item,Item."No.",LibraryRandom.RandIntInRange(5,10));

      // [WHEN] Release purchase order and create warehouse receipt
      LibraryPurchase.ReleasePurchaseDocument(PurchaseHeader);
      LibraryWarehouse.CreateWhseReceiptFromPO(PurchaseHeader);

      // [THEN] Warehouse requests are created for location "X" and for blank location.
      WarehouseRequest.INIT;
      WarehouseRequest.SETRANGE("Source Type",DATABASE::"Purchase Line");
      WarehouseRequest.SETRANGE("Source Subtype",PurchaseHeader."Document Type");
      WarehouseRequest.SETRANGE("Source No.",PurchaseHeader."No.");
      WarehouseRequest.SETRANGE("Document Status",PurchaseHeader.Status::Released);
      Assert.RecordCount(WarehouseRequest,2);
      WarehouseRequest.SETRANGE("Location Code",LocationWhite.Code);
      Assert.RecordCount(WarehouseRequest,1);
      WarehouseRequest.SETRANGE("Location Code",'');
      Assert.RecordCount(WarehouseRequest,1);

      // [THEN] Receipt lines are created for location "X" and for blank location.
      FindWarehouseReceiptLine(
        WarehouseReceiptLine,WarehouseReceiptLine."Source Document"::"Purchase Order",PurchaseHeader."No.");
      Assert.RecordCount(WarehouseReceiptLine,2);
      WarehouseReceiptLine.SETRANGE("Location Code",LocationWhite.Code);
      Assert.RecordCount(WarehouseReceiptLine,1);
      WarehouseReceiptLine.SETRANGE("Location Code",'');
      Assert.RecordCount(WarehouseReceiptLine,1);
Member of Lib.Library - Warehouse


SetRequireShipmentOnWarehouseSetup@53 Method

The procedure SetRequireShipmentOnWarehouseSetup is available in codeunit 132204.

Syntax

SetRequireShipmentOnWarehouseSetup@53(
    RequireShipment@1000 : Boolean RequireShipment //Input parameter of type Boolean
);

Parameters

RequireShipment
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, Require, Shipment, On, Warehouse, Setup.

For a clarification about how this function works, refer to the code listed below.

      WarehouseSetup.GET;
      WarehouseSetup.VALIDATE("Require Shipment",RequireShipment);
      WarehouseSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 137154 to show one way of using this function.

      // [FEATURE] [Sales] [Release] [Shipment] [Location]
      // [SCENARIO 222722] Cassie can create warehouse shipments from sales order having lines with blank and filled locaitons
      Initialize;

      // [GIVEN] "Require Shipment" = TRUE in warehouse setup
      LibraryWarehouse.SetRequireShipmentOnWarehouseSetup(TRUE);

      // [GIVEN] Sales order with two lines
      // [GIVEN] "Sales Line"[1] with "Location Code" = "X" for item "A"
      // [GIVEN] "Sales Line"[2] with blank "Location Code" for item "B"
      LibraryInventory.CreateItem(Item);
      CreateSalesOrder(SalesHeader,SalesLineItem,'',Item."No.",LocationWhite.Code,'');
      CreateSalesLine(SalesLineItem,SalesHeader,Item."No.",'','');

      // [WHEN] Release sales order and create warehouse shipment
      LibrarySales.ReleaseSalesDocument(SalesHeader);
      LibraryWarehouse.CreateWhseShipmentFromSO(SalesHeader);

      // [THEN] Warehouse requests are created for location "X" and for blank location.
      WarehouseRequest.INIT;
      WarehouseRequest.SETRANGE("Source Type",DATABASE::"Sales Line");
      WarehouseRequest.SETRANGE("Source Subtype",SalesHeader."Document Type");
      WarehouseRequest.SETRANGE("Source No.",SalesHeader."No.");
      WarehouseRequest.SETRANGE("Document Status",SalesHeader.Status::Released);
      Assert.RecordCount(WarehouseRequest,2);
      WarehouseRequest.SETRANGE("Location Code",LocationWhite.Code);
      Assert.RecordCount(WarehouseRequest,1);
      WarehouseRequest.SETRANGE("Location Code",'');
      Assert.RecordCount(WarehouseRequest,1);

      // [THEN] Shipment lines are created for location "X" and for blank location.
      FindWarehouseShipmentLine(
        WarehouseShipmentLine,WarehouseShipmentLine."Source Document"::"Sales Order",SalesHeader."No.");
      Assert.RecordCount(WarehouseShipmentLine,2);
      WarehouseShipmentLine.SETRANGE("Location Code",LocationWhite.Code);
      Assert.RecordCount(WarehouseShipmentLine,1);
      WarehouseShipmentLine.SETRANGE("Location Code",'');
      Assert.RecordCount(WarehouseShipmentLine,1);
Member of Lib.Library - Warehouse


WhseCalculateInventory@153 Method

The procedure WhseCalculateInventory is available in codeunit 132204.

Syntax

WhseCalculateInventory@153(
    WarehouseJournalLine@1005 : Record 7311 WarehouseJournalLine, //Input parameter of type Record
    VAR BinContent@1004 : Record 7302 BinContent, //Reference parameter of type Record
    NewRegisteringDate@1003 : Date NewRegisteringDate, //Input parameter of type Date
    WhseDocNo@1002 : Code[20] WhseDocNo, //Input parameter of type Code
    ItemsNotOnInvt@1001 : Boolean ItemsNotOnInvt //Input parameter of type Boolean
);

Parameters

WarehouseJournalLine
Input parameter of type Record
BinContent
Reference parameter of type Record
NewRegisteringDate
Input parameter of type Date
WhseDocNo
Input parameter of type Code
ItemsNotOnInvt
Input parameter of type Boolean

Remarks

The relevant search keywords are: Warehouse, Calculate, Inventory.

For a clarification about how this function works, refer to the code listed below.

      COMMIT;  // Commit is required to run the report.
      WhseCalculateInventory.SetWhseJnlLine(WarehouseJournalLine);
      WhseCalculateInventory.InitializeRequest(NewRegisteringDate,WhseDocNo,ItemsNotOnInvt);
      WhseCalculateInventory.SETTABLEVIEW(BinContent);
      WhseCalculateInventory.USEREQUESTPAGE(FALSE);
      WhseCalculateInventory.RUN;

Example

The below example is extracted from the test automation codeunit 137153 to show one way of using this function.

      CreateWarehouseJournalBatch(WarehouseJournalBatch,WarehouseJournalTemplate.Type::"Physical Inventory",LocationWhite.Code);
      WarehouseJournalLine.INIT;
      WarehouseJournalLine.VALIDATE("Journal Template Name",WarehouseJournalBatch."Journal Template Name");
      WarehouseJournalLine.VALIDATE("Journal Batch Name",WarehouseJournalBatch.Name);
      WarehouseJournalLine.VALIDATE("Location Code",LocationCode);
      IF ZoneCode <> '' THEN
        BinContent.SETRANGE("Zone Code",ZoneCode);
      IF ItemNo <> '' THEN
        BinContent.SETRANGE("Item No.",ItemNo);
      LibraryWarehouse.WhseCalculateInventory(WarehouseJournalLine,BinContent,WORKDATE,LibraryUtility.GenerateGUID,FALSE);
Member of Lib.Library - Warehouse


WhseGetBinContent@158 Method

The procedure WhseGetBinContent is available in codeunit 132204.

Syntax

WhseGetBinContent@158(
    VAR BinContent@1000 : Record 7302 BinContent, //Reference parameter of type Record
    WhseWorksheetLine@1003 : Record 7326 WhseWorksheetLine, //Input parameter of type Record
    WhseInternalPutAwayHeader@1002 : Record 7331 WhseInternalPutAwayHeader, //Input parameter of type Record
    DestinationType@1001 : Option DestinationType //Input parameter of type Option
);

Parameters

BinContent
Reference parameter of type Record
WhseWorksheetLine
Input parameter of type Record
WhseInternalPutAwayHeader
Input parameter of type Record
DestinationType
Input parameter of type Option

Remarks

The relevant search keywords are: Warehouse, Get, Bin, Content.

For a clarification about how this function works, refer to the code listed below.

      WhseGetBinContent.InitializeReport(WhseWorksheetLine,WhseInternalPutAwayHeader,DestinationType);
      WhseGetBinContent.SETTABLEVIEW(BinContent);
      WhseGetBinContent.USEREQUESTPAGE(FALSE);
      WhseGetBinContent.RUN;

Example

The below example is extracted from the test automation codeunit 137056 to show one way of using this function.

      CreateWhseWorksheetName(WhseWorksheetName,LocationCode);
      WhseWorksheetLine.INIT;
      WhseWorksheetLine.VALIDATE("Worksheet Template Name",WhseWorksheetName."Worksheet Template Name");
      WhseWorksheetLine.VALIDATE(Name,WhseWorksheetName.Name);
      WhseWorksheetLine.VALIDATE("Location Code",LocationCode);
      BinContent.SETRANGE("Location Code",LocationCode);
      BinContent.SETRANGE("Item No.",ItemNo);
      WhseInternalPutAwayHeader.INIT;
      LibraryWarehouse.WhseGetBinContent(BinContent,WhseWorksheetLine,WhseInternalPutAwayHeader,0);
Member of Lib.Library - Warehouse


WhseGetBinContentFromItemJournalLine@15 Method

The procedure WhseGetBinContentFromItemJournalLine is available in codeunit 132204.

Syntax

WhseGetBinContentFromItemJournalLine@15(
    VAR BinContent@1000 : Record 7302 BinContent, //Reference parameter of type Record
    ItemJournalLine@1001 : Record 83 ItemJournalLine //Input parameter of type Record
);

Parameters

BinContent
Reference parameter of type Record
ItemJournalLine
Input parameter of type Record

Remarks

The relevant search keywords are: Warehouse, Get, Bin, Content, From, Item, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(WhseGetBinContent);
      WhseGetBinContent.SETTABLEVIEW(BinContent);
      WhseGetBinContent.InitializeItemJournalLine(ItemJournalLine);
      WhseGetBinContent.USEREQUESTPAGE(FALSE);
      WhseGetBinContent.RUN;

Example

The below example is extracted from the test automation codeunit 137056 to show one way of using this function.

      FindBinContent(BinContent,ItemNo);
      ItemJournalLine.INIT;
      ItemJournalLine.VALIDATE("Journal Template Name",ItemJournalBatch."Journal Template Name");
      ItemJournalLine.VALIDATE("Journal Batch Name",ItemJournalBatch.Name);
      LibraryWarehouse.WhseGetBinContentFromItemJournalLine(BinContent,ItemJournalLine);
Member of Lib.Library - Warehouse


WhseSourceCreateDocument@159 Method

The procedure WhseSourceCreateDocument is available in codeunit 132204.

Syntax

WhseSourceCreateDocument@159(
    VAR WhseWorksheetLine@1005 : Record 7326 WhseWorksheetLine, //Reference parameter of type Record
    SortActivity@1004 : Option SortActivity, //Input parameter of type Option
    PrintDoc@1003 : Boolean PrintDoc, //Input parameter of type Boolean
    DoNotFillQtytoHandle@1002 : Boolean DoNotFillQtytoHandle, //Input parameter of type Boolean
    BreakbulkFilter@1001 : Boolean BreakbulkFilter //Input parameter of type Boolean
);

Parameters

WhseWorksheetLine
Reference parameter of type Record
SortActivity
Input parameter of type Option
PrintDoc
Input parameter of type Boolean
DoNotFillQtytoHandle
Input parameter of type Boolean
BreakbulkFilter
Input parameter of type Boolean

Remarks

The relevant search keywords are: Warehouse, Source, Create, Document.

For a clarification about how this function works, refer to the code listed below.

      WhseSourceCreateDocument.Initialize(USERID,SortActivity,PrintDoc,DoNotFillQtytoHandle,BreakbulkFilter);
      WhseSourceCreateDocument.USEREQUESTPAGE(FALSE);
      WhseSourceCreateDocument.SetWhseWkshLine(WhseWorksheetLine);
      WhseSourceCreateDocument.RUN;

Example

The below example is extracted from the test automation codeunit 137150 to show one way of using this function.

      WhseWorksheetLine.SETRANGE("Item No.",ItemNo);
      WhseWorksheetLine.FINDFIRST;
      IF Tracking THEN BEGIN
        LibraryVariableStorage.Enqueue(ItemTrackingModePar);
        LibraryVariableStorage.Enqueue(FALSE);
        WhseWorksheetLine.OpenItemTrackingLines;
      END;
      LibraryWarehouse.WhseSourceCreateDocument(WhseWorksheetLine,0,FALSE,FALSE,FALSE);
Member of Lib.Library - Warehouse


Library - Workflow Class

Lib.Library - Workflow

COD131101 applies to ERM,W1,All.

Methods

Name | Description
CheckEmailWasNotSent@31 | The procedure CheckEmailWasNotSent is available in codeunit 131101.
CopyWorkflow@28 | The procedure CopyWorkflow is available in codeunit 131101.
CopyWorkflowTemplate@21 | The procedure CopyWorkflowTemplate is available in codeunit 131101.
CreateDynamicRequestPageEntity@26 | The procedure CreateDynamicRequestPageEntity is available in codeunit 131101.
CreateDynamicRequestPageField@30 | The procedure CreateDynamicRequestPageField is available in codeunit 131101.
CreateEnabledWorkflow@109 | The procedure CreateEnabledWorkflow is available in codeunit 131101.
CreateEventPredecessor@66 | The procedure CreateEventPredecessor is available in codeunit 131101.
CreateNotificationSetup@27 | The procedure CreateNotificationSetup is available in codeunit 131101.
CreateNotificationTemplate@25 | The procedure CreateNotificationTemplate is available in codeunit 131101.
CreatePredecessor@39 | The procedure CreatePredecessor is available in codeunit 131101.
CreateResponsePredecessor@37 | The procedure CreateResponsePredecessor is available in codeunit 131101.
CreateTemplateWorkflow@6 | The procedure CreateTemplateWorkflow is available in codeunit 131101.
CreateWorkflow@3 | The procedure CreateWorkflow is available in codeunit 131101.
CreateWorkflowCategory@38 | The procedure CreateWorkflowCategory is available in codeunit 131101.
CreateWorkflowStepArgument@15 | The procedure CreateWorkflowStepArgument is available in codeunit 131101.
CreateWorkflowTableRelation@13 | The procedure CreateWorkflowTableRelation is available in codeunit 131101.
DeleteAllExistingWorkflows@11 | The procedure DeleteAllExistingWorkflows is available in codeunit 131101.
DeleteDynamicRequestPageFields@24 | The procedure DeleteDynamicRequestPageFields is available in codeunit 131101.
DeleteNotifications@1 | The procedure DeleteNotifications is available in codeunit 131101.
DisableAllWorkflows@29 | The procedure DisableAllWorkflows is available in codeunit 131101.
EnableWorkflow@32 | The procedure EnableWorkflow is available in codeunit 131101.
GetGeneralJournalTemplateAndBatch@2 | The procedure GetGeneralJournalTemplateAndBatch is available in codeunit 131101.
InsertApprovalArgument@44 | The procedure InsertApprovalArgument is available in codeunit 131101.
InsertEntryPointEventStep@51 | The procedure InsertEntryPointEventStep is available in codeunit 131101.
InsertEventArgument@41 | The procedure InsertEventArgument is available in codeunit 131101.
InsertEventRule@33 | The procedure InsertEventRule is available in codeunit 131101.
InsertEventStep@14 | The procedure InsertEventStep is available in codeunit 131101.
InsertMessageArgument@36 | The procedure InsertMessageArgument is available in codeunit 131101.
InsertNotificationArgument@42 | The procedure InsertNotificationArgument is available in codeunit 131101.
InsertPmtLineCreationArgument@43 | The procedure InsertPmtLineCreationArgument is available in codeunit 131101.
InsertRecChangeValueArgument@130 | The procedure InsertRecChangeValueArgument is available in codeunit 131101.
InsertResponseStep@9 | The procedure InsertResponseStep is available in codeunit 131101.
InsertSubWorkflowStep@20 | The procedure InsertSubWorkflowStep is available in codeunit 131101.
InsertTableRelation@7 | The procedure InsertTableRelation is available in codeunit 131101.
SetEventStepAsEntryPoint@16 | The procedure SetEventStepAsEntryPoint is available in codeunit 131101.
SetNextStep@34 | The procedure SetNextStep is available in codeunit 131101.
SetSequenceNo@23 | The procedure SetSequenceNo is available in codeunit 131101.
SetSubWorkflowStepAsEntryPoint@8 | The procedure SetSubWorkflowStepAsEntryPoint is available in codeunit 131101.
SetUpSMTPEmailSetup@5 | The procedure SetUpSMTPEmailSetup is available in codeunit 131101.
VerifyEmailContainsValues@17 | The procedure VerifyEmailContainsValues is available in codeunit 131101.
VerifyEmailWithMockService@4 | The procedure VerifyEmailWithMockService is available in codeunit 131101.

See Also

Lib


CheckEmailWasNotSent@31 Method

The procedure CheckEmailWasNotSent is available in codeunit 131101.

Syntax

CheckEmailWasNotSent@31(
    UserId@1000 : Code[50] UserId //Input parameter of type Code
);

Parameters

UserId
Input parameter of type Code

Remarks

The relevant search keywords are: Check, Email, Was, Not, Sent.

For a clarification about how this function works, refer to the code listed below.

      UserSetup.GET(UserId);
      FilePath := GetEmailFilePath(UserSetup."E-Mail");
      Assert.IsFalse(FileManagement.ServerFileExists(FilePath),EmailShouldNotExistErr);

Example

There are no examples available.
Member of Lib.Library - Workflow


CopyWorkflow@28 Method

The procedure CopyWorkflow is available in codeunit 131101.

Syntax

CopyWorkflow@28(
    VAR Workflow@1000 : Record 1501 Workflow, //Reference parameter of type Record
    FromWorkflowCode@1001 : Code[20] FromWorkflowCode //Input parameter of type Code
);

Parameters

Workflow
Reference parameter of type Record
FromWorkflowCode
Input parameter of type Code

Remarks

The relevant search keywords are: Copy, Workflow.

For a clarification about how this function works, refer to the code listed below.

      FromWorkflow.GET(FromWorkflowCode);

      CreateWorkflow(Workflow);

      IF Workflow.Description = '' THEN
        Workflow.Description := FromWorkflow.Description;
      Workflow.MODIFY;

      CopyWorkflowSteps(Workflow,FromWorkflowCode);
      FillNotificationUserID(Workflow);

Example

There are no examples available.
Member of Lib.Library - Workflow


CopyWorkflowTemplate@21 Method

The procedure CopyWorkflowTemplate is available in codeunit 131101.

Syntax

CopyWorkflowTemplate@21(
    VAR Workflow@1000 : Record 1501 Workflow, //Reference parameter of type Record
    FromWorkflowTemplateCode@1001 : Code[17] FromWorkflowTemplateCode //Input parameter of type Code
);

Parameters

Workflow
Reference parameter of type Record
FromWorkflowTemplateCode
Input parameter of type Code

Remarks

The relevant search keywords are: Copy, Workflow, Template.

For a clarification about how this function works, refer to the code listed below.

      FromWorkflow.GET(WorkflowSetup.GetWorkflowTemplateCode(FromWorkflowTemplateCode));

      CreateWorkflow(Workflow);

      IF Workflow.Description = '' THEN
        Workflow.Description := FromWorkflow.Description;
      Workflow.MODIFY;

      CopyWorkflowSteps(Workflow,FromWorkflow.Code);
      FillNotificationUserID(Workflow);

Example

The below example is extracted from the test automation codeunit 134170 to show one way of using this function.

      // [SCENARIO] This test that an user cannot post a Sales Invoice after it was sent for approval.
      // [GIVEN] Sales Invoice Approval Workflow that has Approver code as the approver and Direct Approver as the limit type.
      // [WHEN] Sales Invoice is sent for approval.
      // [THEN] Approval Request is created for the Approver.
      // [WHEN] The user wants to post the Sales Invoice.
      // [THEN] An error is showned to the user and the Sales Invoice is not posted.

      Initialize;

      LibraryWorkflow.CopyWorkflowTemplate(Workflow,WorkflowSetup.SalesInvoiceApprovalWorkflowCode);
      WorkflowStep.SETRANGE("Function Name",WorkflowResponseHandling.CreateApprovalRequestsCode);
      WorkflowStep.SETRANGE("Workflow Code",Workflow.Code);
      IF WorkflowStep.FINDFIRST THEN BEGIN
        WorkflowStepArgument.GET(WorkflowStep.Argument);
        WorkflowStepArgument."Approver Limit Type" := WorkflowStepArgument."Approver Limit Type"::"Direct Approver";
        WorkflowStepArgument.MODIFY(TRUE);
      END;

      LibraryWorkflow.EnableWorkflow(Workflow);

      // Setup - Create 2 usersetups
      LibraryDocumentApprovals.CreateOrFindUserSetup(CurrentUserSetup,USERID);
      LibraryDocumentApprovals.CreateMockupUserSetup(ApproverUserSetup);

      // Setup - Direct approver
      LibraryDocumentApprovals.SetApprover(CurrentUserSetup,ApproverUserSetup);

      // Setup - Create Sales invoice
      CreateSalesInvWithLine(SalesHeader,LibraryRandom.RandInt(5000));

      // Setup - Update Salesperson Code
      SetSalesDocSalespersonCode(SalesHeader,ApproverUserSetup."Salespers./Purch. Code");

      // Excercise - Open Sales invoice card and sent it for approval
      SendSalesInvoiceForApproval(SalesHeader);

      // Verify - Sales invoice status is set to Pending Approval
      VerifySalesInvIsPendingApproval(SalesHeader);

      // Verify - Approval requests and their data
      LibraryDocumentApprovals.GetApprovalEntries(ApprovalEntry,SalesHeader.RECORDID);
      Assert.AreEqual(1,ApprovalEntry.COUNT,UnexpectedNoOfApprovalEntriesErr);

      VerifyApprovalEntryIsOpen(ApprovalEntry);
      VerifyApprovalEntrySenderID(ApprovalEntry,CurrentUserSetup."User ID");
      VerifyApprovalEntryApproverID(ApprovalEntry,ApproverUserSetup."User ID");

      // Exercise - Try to post the Sales Document
      COMMIT;
      ASSERTERROR PostSalesInvoice(SalesHeader);

      // Verify - Sales Document cannot be posted
      Assert.ExpectedError(STRSUBSTNO(PostRestrictionErr,FORMAT(SalesHeader.RECORDID,0,1)));
Member of Lib.Library - Workflow


CreateDynamicRequestPageEntity@26 Method

The procedure CreateDynamicRequestPageEntity is available in codeunit 131101.

Syntax

CreateDynamicRequestPageEntity@26(
    Name@1003 : Code[20] Name, //Input parameter of type Code
    TableID@1001 : Integer TableID, //Input parameter of type Integer
    RelatedTableID@1002 : Integer RelatedTableID //Input parameter of type Integer
);

Parameters

Name
Input parameter of type Code
TableID
Input parameter of type Integer
RelatedTableID
Input parameter of type Integer

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Dynamic, Request, Page, Entity.

For a clarification about how this function works, refer to the code listed below.

      DynamicRequestPageEntity.INIT;
      DynamicRequestPageEntity.VALIDATE(Name,Name);
      DynamicRequestPageEntity.VALIDATE("Table ID",TableID);
      DynamicRequestPageEntity.VALIDATE("Related Table ID",RelatedTableID);
      DynamicRequestPageEntity.INSERT(TRUE);
      EXIT(DynamicRequestPageEntity.Name);

Example

There are no examples available.
Member of Lib.Library - Workflow


CreateDynamicRequestPageField@30 Method

The procedure CreateDynamicRequestPageField is available in codeunit 131101.

Syntax

CreateDynamicRequestPageField@30(
    TableID@1001 : Integer TableID, //Input parameter of type Integer
    FieldID@1002 : Integer FieldID //Input parameter of type Integer
);

Parameters

TableID
Input parameter of type Integer
FieldID
Input parameter of type Integer

Remarks

The relevant search keywords are: Create, Dynamic, Request, Page, Field.

For a clarification about how this function works, refer to the code listed below.

      DynamicRequestPageField.INIT;
      DynamicRequestPageField.VALIDATE("Table ID",TableID);
      DynamicRequestPageField.VALIDATE("Field ID",FieldID);
      DynamicRequestPageField.INSERT(TRUE);

Example

There are no examples available.
Member of Lib.Library - Workflow


CreateEnabledWorkflow@109 Method

The procedure CreateEnabledWorkflow is available in codeunit 131101.

Syntax

CreateEnabledWorkflow@109(
    VAR Workflow@1000 : Record 1501 Workflow, //Reference parameter of type Record
    WorkflowCode@1001 : Code[17] WorkflowCode //Input parameter of type Code
);

Parameters

Workflow
Reference parameter of type Record
WorkflowCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Enabled, Workflow.

For a clarification about how this function works, refer to the code listed below.

      CopyWorkflow(Workflow,WorkflowSetup.GetWorkflowTemplateCode(WorkflowCode));
      EnableWorkflow(Workflow);

Example

The below example is extracted from the test automation codeunit 134170 to show one way of using this function.

      // [SCENARIO] The user cannot release a Sales invoice when the approval workflow is enabled and the Sales invoice is not approved.
      // [GIVEN] There is a Sales invoice that is not approved.
      // [GIVEN] The approval workflow for puchase invoices is enabled.
      // [WHEN] The user wants to Release the Sales invoice.
      // [THEN] The user will get an error that he cannot release a Sales invoice that is not approved.

      // Setup
      Initialize;

      LibraryWorkflow.CreateEnabledWorkflow(Workflow,WorkflowSetup.SalesInvoiceApprovalWorkflowCode);

      LibrarySales.CreateSalesInvoice(SalesHeader);

      // Exercise
      SalesInvoice.OPENVIEW;
      SalesInvoice.GOTORECORD(SalesHeader);
      ASSERTERROR SalesInvoice.Release.INVOKE;

      // Verify
      Assert.ExpectedError(DocCannotBeReleasedErr);
Member of Lib.Library - Workflow


CreateEventPredecessor@66 Method

The procedure CreateEventPredecessor is available in codeunit 131101.

Syntax

CreateEventPredecessor@66(
    FunctionName@1001 : Code[128] FunctionName, //Input parameter of type Code
    PredecessorFunctionName@1002 : Code[128] PredecessorFunctionName //Input parameter of type Code
);

Parameters

FunctionName
Input parameter of type Code
PredecessorFunctionName
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Event, Predecessor.

For a clarification about how this function works, refer to the code listed below.

      CreatePredecessor(WFEventResponseCombination.Type::"Event",FunctionName,
        WFEventResponseCombination."Predecessor Type"::"Event",PredecessorFunctionName);

Example

There are no examples available.
Member of Lib.Library - Workflow


CreateNotificationSetup@27 Method

The procedure CreateNotificationSetup is available in codeunit 131101.

Syntax

CreateNotificationSetup@27(
    VAR NotificationSetup@1000 : Record 1512 NotificationSetup, //Reference parameter of type Record
    UserID@1004 : Code[50] UserID, //Input parameter of type Code
    NotificationType@1005 : Option NotificationType, //Input parameter of type Option
    NotificationTemplateCode@1006 : Code[20] NotificationTemplateCode, //Input parameter of type Code
    NonAggregatedNotifications@1007 : Boolean NonAggregatedNotifications //Input parameter of type Boolean
);

Parameters

NotificationSetup
Reference parameter of type Record
UserID
Input parameter of type Code
NotificationType
Input parameter of type Option
NotificationTemplateCode
Input parameter of type Code
NonAggregatedNotifications
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, Notification, Setup.

For a clarification about how this function works, refer to the code listed below.

      NotificationSetup.INIT;
      NotificationSetup."User ID" := UserID;
      NotificationSetup."Notification Type" := NotificationType;
      NotificationSetup."Notification Template Code" := NotificationTemplateCode;
      NotificationSetup."Non-Aggregated Notifications" := NonAggregatedNotifications;
      NotificationSetup.INSERT(TRUE);

Example

There are no examples available.
Member of Lib.Library - Workflow


CreateNotificationTemplate@25 Method

The procedure CreateNotificationTemplate is available in codeunit 131101.

Syntax

CreateNotificationTemplate@25(
    VAR NotificationTemplate@1000 : Record 1510 NotificationTemplate, //Reference parameter of type Record
    Method@1002 : Option Method, //Input parameter of type Option
    Type@1001 : Option Type //Input parameter of type Option
);

Parameters

NotificationTemplate
Reference parameter of type Record
Method
Input parameter of type Option
Type
Input parameter of type Option

Return Value

Text

Remarks

The relevant search keywords are: Create, Notification, Template.

For a clarification about how this function works, refer to the code listed below.

      NotificationTemplate.INIT;
      NotificationTemplate.Code := LibraryUtility.GenerateGUID;
      NotificationTemplate."Notification Body".CREATEOUTSTREAM(OutStream,TEXTENCODING::Windows);
      OutStream.WRITETEXT(NotificationTemplateTxt);
      NotificationTemplate."Notification Method" := Method;
      NotificationTemplate.Type := Type;
      NotificationTemplate.INSERT(TRUE);

      EXIT(NotificationTemplateTxt);

Example

There are no examples available.
Member of Lib.Library - Workflow


CreatePredecessor@39 Method

The procedure CreatePredecessor is available in codeunit 131101.

Syntax

CreatePredecessor@39(
    Type@1004 : Option Type, //Input parameter of type Option
    FunctionName@1001 : Code[128] FunctionName, //Input parameter of type Code
    PredecessorType@1003 : Option PredecessorType, //Input parameter of type Option
    PredecessorFunctionName@1002 : Code[128] PredecessorFunctionName //Input parameter of type Code
);

Parameters

Type
Input parameter of type Option
FunctionName
Input parameter of type Code
PredecessorType
Input parameter of type Option
PredecessorFunctionName
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Predecessor.

For a clarification about how this function works, refer to the code listed below.

      WFEventResponseCombination.INIT;
      WFEventResponseCombination.Type := Type;
      WFEventResponseCombination."Function Name" := FunctionName;
      WFEventResponseCombination."Predecessor Type" := PredecessorType;
      WFEventResponseCombination."Predecessor Function Name" := PredecessorFunctionName;
      IF WFEventResponseCombination.INSERT THEN;

Example

There are no examples available.
Member of Lib.Library - Workflow


CreateResponsePredecessor@37 Method

The procedure CreateResponsePredecessor is available in codeunit 131101.

Syntax

CreateResponsePredecessor@37(
    FunctionName@1001 : Code[128] FunctionName, //Input parameter of type Code
    PredecessorFunctionName@1002 : Code[128] PredecessorFunctionName //Input parameter of type Code
);

Parameters

FunctionName
Input parameter of type Code
PredecessorFunctionName
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Response, Predecessor.

For a clarification about how this function works, refer to the code listed below.

      CreatePredecessor(WFEventResponseCombination.Type::Response,FunctionName,
        WFEventResponseCombination."Predecessor Type"::"Event",PredecessorFunctionName);

Example

There are no examples available.
Member of Lib.Library - Workflow


CreateTemplateWorkflow@6 Method

The procedure CreateTemplateWorkflow is available in codeunit 131101.

Syntax

CreateTemplateWorkflow@6(
    VAR Workflow@1000 : Record 1501 Workflow //Reference parameter of type Record
);

Parameters

Workflow
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Template, Workflow.

For a clarification about how this function works, refer to the code listed below.

      CreateWorkflow(Workflow);
      Workflow.VALIDATE(Template,TRUE);
      Workflow.MODIFY;

Example

The below example is extracted from the test automation codeunit 134340 to show one way of using this function.

      // Setup
      Initialize;
      LibraryWorkflow.CreateTemplateWorkflow(Workflow);

      // Exercise
      TempWorkflowBuffer.InitBufferForTemplates(TempWorkflowBuffer);

      // Verify
      TempWorkflowBuffer.GET(Workflow.Category,'');
      TempWorkflowBuffer.GET(Workflow.Category,Workflow.Code);
Member of Lib.Library - Workflow


CreateWorkflow@3 Method

The procedure CreateWorkflow is available in codeunit 131101.

Syntax

CreateWorkflow@3(
    VAR Workflow@1000 : Record 1501 Workflow //Reference parameter of type Record
);

Parameters

Workflow
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Workflow.

For a clarification about how this function works, refer to the code listed below.

      Workflow.INIT;
      Workflow.Code := GenerateRandomWorkflowCode;
      Workflow.Description := DELCHR(LibraryUtility.GenerateRandomText(MAXSTRLEN(Workflow.Description)),'=','''()&|<>'); // remove invalid filter chars
      Workflow.Category := CreateWorkflowCategory;
      Workflow.Template := FALSE;
      Workflow.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 134187 to show one way of using this function.

      // [SCENARIO 381194] "Workflow Instance" query when there are no instances

      // [GIVEN] Workflow templates reinitiated
      LibraryWorkflow.DeleteAllExistingWorkflows;
      WorkflowSetup.InitWorkflow;

      // [GIVEN] Workflow = "X" without steps and instances
      LibraryWorkflow.CreateWorkflow(Workflow);

      // [WHEN] Look at Workflow = "X" in "Workflow Instance" query
      WorkflowInstance.SETRANGE(Code,Workflow.Code);
      WorkflowInstance.OPEN;

      // [THEN] Query is empty
      Assert.IsFalse(WorkflowInstance.READ,'');
Member of Lib.Library - Workflow


CreateWorkflowCategory@38 Method

The procedure CreateWorkflowCategory is available in codeunit 131101.

Syntax

CreateWorkflowCategory@38(
      //param element not supplied
);

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Workflow, Category.

For a clarification about how this function works, refer to the code listed below.

      WorkflowCategory.Code := LibraryUtility.GenerateRandomCode(WorkflowCategory.FIELDNO(Code),DATABASE::"Workflow Category");
      WorkflowCategory.Description :=
        DELCHR(LibraryUtility.GenerateRandomText(MAXSTRLEN(WorkflowCategory.Description)),'=','''()&|<>');
      WorkflowCategory.INSERT;
      EXIT(WorkflowCategory.Code);

Example

There are no examples available.
Member of Lib.Library - Workflow


CreateWorkflowStepArgument@15 Method

The procedure CreateWorkflowStepArgument is available in codeunit 131101.

Syntax

CreateWorkflowStepArgument@15(
    VAR WorkflowStepArgument@1000 : Record 1523 WorkflowStepArgument, //Reference parameter of type Record
    Type@1001 : Option Type, //Input parameter of type Option
    UserID@1004 : Code[50] UserID, //Input parameter of type Code
    TemplateName@1002 : Code[10] TemplateName, //Input parameter of type Code
    BatchName@1003 : Code[10] BatchName, //Input parameter of type Code
    ApproverType@1006 : Option ApproverType, //Input parameter of type Option
    InformUser@1005 : Boolean InformUser //Input parameter of type Boolean
);

Parameters

WorkflowStepArgument
Reference parameter of type Record
Type
Input parameter of type Option
UserID
Input parameter of type Code
TemplateName
Input parameter of type Code
BatchName
Input parameter of type Code
ApproverType
Input parameter of type Option
InformUser
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, Workflow, Step, Argument.

For a clarification about how this function works, refer to the code listed below.

      WorkflowStepArgument.INIT;
      WorkflowStepArgument.Type := Type;
      WorkflowStepArgument."General Journal Template Name" := TemplateName;
      WorkflowStepArgument."General Journal Batch Name" := BatchName;
      WorkflowStepArgument."Notification User ID" := UserID;
      WorkflowStepArgument."Approver Type" := ApproverType;
      WorkflowStepArgument."Approver Limit Type" := WorkflowStepArgument."Approver Limit Type"::"Approver Chain";
      WorkflowStepArgument."Show Confirmation Message" := InformUser;
      WorkflowStepArgument.INSERT(TRUE);

Example

There are no examples available.
Member of Lib.Library - Workflow


CreateWorkflowTableRelation@13 Method

The procedure CreateWorkflowTableRelation is available in codeunit 131101.

Syntax

CreateWorkflowTableRelation@13(
    VAR WorkflowTableRelation@1000 : Record 1505 WorkflowTableRelation, //Reference parameter of type Record
    TableId@1001 : Integer TableId, //Input parameter of type Integer
    FieldId@1002 : Integer FieldId, //Input parameter of type Integer
    RelatedTableId@1003 : Integer RelatedTableId, //Input parameter of type Integer
    RelatedFieldId@1004 : Integer RelatedFieldId //Input parameter of type Integer
);

Parameters

WorkflowTableRelation
Reference parameter of type Record
TableId
Input parameter of type Integer
FieldId
Input parameter of type Integer
RelatedTableId
Input parameter of type Integer
RelatedFieldId
Input parameter of type Integer

Remarks

The relevant search keywords are: Create, Workflow, Table, Relation.

For a clarification about how this function works, refer to the code listed below.

      WorkflowTableRelation.INIT;
      WorkflowTableRelation."Table ID" := TableId;
      WorkflowTableRelation."Field ID" := FieldId;
      WorkflowTableRelation."Related Table ID" := RelatedTableId;
      WorkflowTableRelation."Related Field ID" := RelatedFieldId;
      IF WorkflowTableRelation.INSERT(TRUE) THEN;

Example

There are no examples available.
Member of Lib.Library - Workflow


DeleteAllExistingWorkflows@11 Method

The procedure DeleteAllExistingWorkflows is available in codeunit 131101.

Syntax

DeleteAllExistingWorkflows@11(
      //param element not supplied
);

Remarks

The relevant search keywords are: Delete, All, Existing, Workflows.

For a clarification about how this function works, refer to the code listed below.

      WorkflowRecordChange.DELETEALL;
      WorkflowRecordChangeArchive.DELETEALL;

      WorkflowTableRelationValue.DELETEALL;

      WorkflowStepArgument.DELETEALL;
      WorkflowStepArgumentArchive.DELETEALL;

      WorkflowRule.DELETEALL;
      WorkflowStepInstanceArchive.DELETEALL;

      WorkflowStepInstance.DELETEALL;
      WorkflowStep.DELETEALL;

      Workflow.DELETEALL;

Example

The below example is extracted from the test automation codeunit 134175 to show one way of using this function.

      // [FEATURE] [Sales] [Approvals]
      // [SCENARIO 379202] Test Workflow Table Relations for Sales Order
      // [WHEN] Init Workflow Setup
      LibraryWorkflow.DeleteAllExistingWorkflows;
      WorkflowSetup.InitWorkflow;

      // [THEN] Workflow Table Relations for Sales Order exist
      WorkflowTableRelation.GET(
        DATABASE::"Sales Header",SalesHeader.FIELDNO("Document Type"),
        DATABASE::"Sales Line",SalesLine.FIELDNO("Document Type"));
      WorkflowTableRelation.GET(
        DATABASE::"Sales Header",SalesHeader.FIELDNO("No."),
        DATABASE::"Sales Line",SalesLine.FIELDNO("Document No."));
Member of Lib.Library - Workflow


DeleteDynamicRequestPageFields@24 Method

The procedure DeleteDynamicRequestPageFields is available in codeunit 131101.

Syntax

DeleteDynamicRequestPageFields@24(
    TableID@1001 : Integer TableID //Input parameter of type Integer
);

Parameters

TableID
Input parameter of type Integer

Remarks

The relevant search keywords are: Delete, Dynamic, Request, Page, Fields.

For a clarification about how this function works, refer to the code listed below.

      DynamicRequestPageField.SETRANGE("Table ID",TableID);
      DynamicRequestPageField.DELETEALL(TRUE);

Example

There are no examples available.
Member of Lib.Library - Workflow


DeleteNotifications@1 Method

The procedure DeleteNotifications is available in codeunit 131101.

Syntax

DeleteNotifications@1(
      //param element not supplied
);

Remarks

The relevant search keywords are: Delete, Notifications.

For a clarification about how this function works, refer to the code listed below.

      NotificationTemplate.DELETEALL;
      NotificationEntry.DELETEALL;

Example

There are no examples available.
Member of Lib.Library - Workflow


DisableAllWorkflows@29 Method

The procedure DisableAllWorkflows is available in codeunit 131101.

Syntax

DisableAllWorkflows@29(
      //param element not supplied
);

Remarks

The relevant search keywords are: Disable, All, Workflows.

For a clarification about how this function works, refer to the code listed below.

      Workflow.SETRANGE(Template,FALSE);
      Workflow.MODIFYALL(Enabled,FALSE,TRUE);

Example

The below example is extracted from the test automation codeunit 134170 to show one way of using this function.

      LibraryVariableStorage.Clear;
      UserSetup.DELETEALL;
      LibraryERMCountryData.UpdateGeneralPostingSetup;
      LibraryERMCountryData.CreateVATData;
      LibraryWorkflow.DisableAllWorkflows;
      COMMIT;
Member of Lib.Library - Workflow


EnableWorkflow@32 Method

The procedure EnableWorkflow is available in codeunit 131101.

Syntax

EnableWorkflow@32(
    VAR Workflow@1000 : Record 1501 Workflow //Reference parameter of type Record
);

Parameters

Workflow
Reference parameter of type Record

Remarks

The relevant search keywords are: Enable, Workflow.

For a clarification about how this function works, refer to the code listed below.

      Workflow.VALIDATE(Enabled,TRUE);
      Workflow.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134170 to show one way of using this function.

      // [SCENARIO] This test that an user cannot post a Sales Invoice after it was sent for approval.
      // [GIVEN] Sales Invoice Approval Workflow that has Approver code as the approver and Direct Approver as the limit type.
      // [WHEN] Sales Invoice is sent for approval.
      // [THEN] Approval Request is created for the Approver.
      // [WHEN] The user wants to post the Sales Invoice.
      // [THEN] An error is showned to the user and the Sales Invoice is not posted.

      Initialize;

      LibraryWorkflow.CopyWorkflowTemplate(Workflow,WorkflowSetup.SalesInvoiceApprovalWorkflowCode);
      WorkflowStep.SETRANGE("Function Name",WorkflowResponseHandling.CreateApprovalRequestsCode);
      WorkflowStep.SETRANGE("Workflow Code",Workflow.Code);
      IF WorkflowStep.FINDFIRST THEN BEGIN
        WorkflowStepArgument.GET(WorkflowStep.Argument);
        WorkflowStepArgument."Approver Limit Type" := WorkflowStepArgument."Approver Limit Type"::"Direct Approver";
        WorkflowStepArgument.MODIFY(TRUE);
      END;

      LibraryWorkflow.EnableWorkflow(Workflow);

      // Setup - Create 2 usersetups
      LibraryDocumentApprovals.CreateOrFindUserSetup(CurrentUserSetup,USERID);
      LibraryDocumentApprovals.CreateMockupUserSetup(ApproverUserSetup);

      // Setup - Direct approver
      LibraryDocumentApprovals.SetApprover(CurrentUserSetup,ApproverUserSetup);

      // Setup - Create Sales invoice
      CreateSalesInvWithLine(SalesHeader,LibraryRandom.RandInt(5000));

      // Setup - Update Salesperson Code
      SetSalesDocSalespersonCode(SalesHeader,ApproverUserSetup."Salespers./Purch. Code");

      // Excercise - Open Sales invoice card and sent it for approval
      SendSalesInvoiceForApproval(SalesHeader);

      // Verify - Sales invoice status is set to Pending Approval
      VerifySalesInvIsPendingApproval(SalesHeader);

      // Verify - Approval requests and their data
      LibraryDocumentApprovals.GetApprovalEntries(ApprovalEntry,SalesHeader.RECORDID);
      Assert.AreEqual(1,ApprovalEntry.COUNT,UnexpectedNoOfApprovalEntriesErr);

      VerifyApprovalEntryIsOpen(ApprovalEntry);
      VerifyApprovalEntrySenderID(ApprovalEntry,CurrentUserSetup."User ID");
      VerifyApprovalEntryApproverID(ApprovalEntry,ApproverUserSetup."User ID");

      // Exercise - Try to post the Sales Document
      COMMIT;
      ASSERTERROR PostSalesInvoice(SalesHeader);

      // Verify - Sales Document cannot be posted
      Assert.ExpectedError(STRSUBSTNO(PostRestrictionErr,FORMAT(SalesHeader.RECORDID,0,1)));
Member of Lib.Library - Workflow


GetGeneralJournalTemplateAndBatch@2 Method

The procedure GetGeneralJournalTemplateAndBatch is available in codeunit 131101.

Syntax

GetGeneralJournalTemplateAndBatch@2(
    VAR GeneralJnlTemplateCode@1002 : Code[10] GeneralJnlTemplateCode, //Reference parameter of type Code
    VAR GeneralJnlBatchCode@1003 : Code[10] GeneralJnlBatchCode //Reference parameter of type Code
);

Parameters

GeneralJnlTemplateCode
Reference parameter of type Code
GeneralJnlBatchCode
Reference parameter of type Code

Remarks

The relevant search keywords are: Get, General, Journal, Template, Batch.

For a clarification about how this function works, refer to the code listed below.

      GenJournalTemplate.SETRANGE(Type,GenJournalTemplate.Type::Payments);
      GenJournalTemplate.FINDFIRST;

      GeneralJnlTemplateCode := GenJournalTemplate.Name;

      LibraryERM.CreateGenJournalBatch(GenJournalBatch,GeneralJnlTemplateCode);

      GeneralJnlBatchCode := GenJournalBatch.Name;

Example

There are no examples available.
Member of Lib.Library - Workflow


InsertApprovalArgument@44 Method

The procedure InsertApprovalArgument is available in codeunit 131101.

Syntax

InsertApprovalArgument@44(
    WorkflowStepID@1000 : Integer WorkflowStepID, //Input parameter of type Integer
    ApproverType@1009 : Option ApproverType, //Input parameter of type Option
    ApproverLimitType@1010 : Option ApproverLimitType, //Input parameter of type Option
    WorkflowUserGroupCode@1003 : Text[20] WorkflowUserGroupCode, //Input parameter of type Text
    InformUser@1002 : Boolean InformUser //Input parameter of type Boolean
);

Parameters

WorkflowStepID
Input parameter of type Integer
ApproverType
Input parameter of type Option
ApproverLimitType
Input parameter of type Option
WorkflowUserGroupCode
Input parameter of type Text
InformUser
Input parameter of type Boolean

Remarks

The relevant search keywords are: Insert, Approval, Argument.

For a clarification about how this function works, refer to the code listed below.

      InsertStepArgument(WorkflowStepArgument,WorkflowStepID);

      WorkflowStepArgument."Approver Type" := ApproverType;
      WorkflowStepArgument."Approver Limit Type" := ApproverLimitType;
      WorkflowStepArgument."Workflow User Group Code" := WorkflowUserGroupCode;
      WorkflowStepArgument."Show Confirmation Message" := InformUser;
      WorkflowStepArgument.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - Workflow


InsertEntryPointEventStep@51 Method

The procedure InsertEntryPointEventStep is available in codeunit 131101.

Syntax

InsertEntryPointEventStep@51(
    Workflow@1000 : Record 1501 Workflow, //Input parameter of type Record
    ActivityName@1001 : Code[128] ActivityName //Input parameter of type Code
);

Parameters

Workflow
Input parameter of type Record
ActivityName
Input parameter of type Code

Return Value

Integer

Remarks

The relevant search keywords are: Insert, Entry, Point, Event, Step.

For a clarification about how this function works, refer to the code listed below.

      InsertStep(WorkflowStep,Workflow.Code,WorkflowStep.Type::"Event",ActivityName);
      WorkflowStep.VALIDATE("Entry Point",TRUE);
      WorkflowStep.MODIFY(TRUE);
      EXIT(WorkflowStep.ID);

Example

There are no examples available.
Member of Lib.Library - Workflow


InsertEventArgument@41 Method

The procedure InsertEventArgument is available in codeunit 131101.

Syntax

InsertEventArgument@41(
    WorkflowStepID@1000 : Integer WorkflowStepID, //Input parameter of type Integer
    EventConditions@1008 : Text EventConditions //Input parameter of type Text
);

Parameters

WorkflowStepID
Input parameter of type Integer
EventConditions
Input parameter of type Text

Remarks

The relevant search keywords are: Insert, Event, Argument.

For a clarification about how this function works, refer to the code listed below.

      IF EventConditions = '' THEN
        ERROR(InvalidEventCondErr);

      WorkflowStepArgument.Type := WorkflowStepArgument.Type::"Event";
      WorkflowStepArgument.INSERT(TRUE);
      WorkflowStepArgument.SetEventFilters(EventConditions);

      WorkflowStep.SETRANGE(ID,WorkflowStepID);
      WorkflowStep.FINDFIRST;
      WorkflowStep.VALIDATE(Argument,WorkflowStepArgument.ID);
      WorkflowStep.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - Workflow


InsertEventRule@33 Method

The procedure InsertEventRule is available in codeunit 131101.

Syntax

InsertEventRule@33(
    WorkflowStepId@1000 : Integer WorkflowStepId, //Input parameter of type Integer
    FieldNo@1003 : Integer FieldNo, //Input parameter of type Integer
    Operator@1008 : Option Operator //Input parameter of type Option
);

Parameters

WorkflowStepId
Input parameter of type Integer
FieldNo
Input parameter of type Integer
Operator
Input parameter of type Option

Remarks

The relevant search keywords are: Insert, Event, Rule.

For a clarification about how this function works, refer to the code listed below.

      WorkflowStep.SETRANGE(ID,WorkflowStepId);
      WorkflowStep.FINDFIRST;

      WorkflowRule.INIT;
      WorkflowRule."Workflow Code" := WorkflowStep."Workflow Code";
      WorkflowRule."Workflow Step ID" := WorkflowStep.ID;
      WorkflowRule.Operator := Operator;

      IF WorkflowEvent.GET(WorkflowStep."Function Name") THEN
        WorkflowRule."Table ID" := WorkflowEvent."Table ID";
      WorkflowRule."Field No." := FieldNo;
      WorkflowRule.INSERT(TRUE);

Example

There are no examples available.
Member of Lib.Library - Workflow


InsertEventStep@14 Method

The procedure InsertEventStep is available in codeunit 131101.

Syntax

InsertEventStep@14(
    Workflow@1000 : Record 1501 Workflow, //Input parameter of type Record
    ActivityName@1001 : Code[128] ActivityName, //Input parameter of type Code
    PreviousStepID@1002 : Integer PreviousStepID //Input parameter of type Integer
);

Parameters

Workflow
Input parameter of type Record
ActivityName
Input parameter of type Code
PreviousStepID
Input parameter of type Integer

Return Value

Integer

Remarks

The relevant search keywords are: Insert, Event, Step.

For a clarification about how this function works, refer to the code listed below.

      InsertStep(WorkflowStep,Workflow.Code,WorkflowStep.Type::"Event",ActivityName);
      WorkflowStep."Sequence No." := GetNextSequenceNo(Workflow,PreviousStepID);
      WorkflowStep.VALIDATE("Previous Workflow Step ID",PreviousStepID);
      WorkflowStep.MODIFY(TRUE);
      EXIT(WorkflowStep.ID);

Example

There are no examples available.
Member of Lib.Library - Workflow


InsertMessageArgument@36 Method

The procedure InsertMessageArgument is available in codeunit 131101.

Syntax

InsertMessageArgument@36(
    WorkflowStepID@1000 : Integer WorkflowStepID, //Input parameter of type Integer
    Msg@1003 : Text[250] Msg //Input parameter of type Text
);

Parameters

WorkflowStepID
Input parameter of type Integer
Msg
Input parameter of type Text

Remarks

The relevant search keywords are: Insert, Message, Argument.

For a clarification about how this function works, refer to the code listed below.

      InsertStepArgument(WorkflowStepArgument,WorkflowStepID);

      WorkflowStepArgument.Message := Msg;
      WorkflowStepArgument.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - Workflow


InsertNotificationArgument@42 Method

The procedure InsertNotificationArgument is available in codeunit 131101.

Syntax

InsertNotificationArgument@42(
    WorkflowStepID@1000 : Integer WorkflowStepID, //Input parameter of type Integer
    NotifUserID@1004 : Code[50] NotifUserID, //Input parameter of type Code
    LinkTargetPage@1007 : Integer LinkTargetPage, //Input parameter of type Integer
    CustomLink@1003 : Text[250] CustomLink //Input parameter of type Text
);

Parameters

WorkflowStepID
Input parameter of type Integer
NotifUserID
Input parameter of type Code
LinkTargetPage
Input parameter of type Integer
CustomLink
Input parameter of type Text

Remarks

The relevant search keywords are: Insert, Notification, Argument.

For a clarification about how this function works, refer to the code listed below.

      InsertStepArgument(WorkflowStepArgument,WorkflowStepID);

      WorkflowStepArgument."Notification User ID" := NotifUserID;
      WorkflowStepArgument."Link Target Page" := LinkTargetPage;
      WorkflowStepArgument."Custom Link" := CustomLink;
      WorkflowStepArgument.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134179 to show one way of using this function.

      LibraryWorkflow.CopyWorkflowTemplate(Workflow,WorkflowSetup.PurchaseInvoiceWorkflowCode);

      WorkflowStep.SETRANGE("Workflow Code",Workflow.Code);
      WorkflowStep.SETRANGE(Type,WorkflowStep.Type::Response);

      WorkflowStep.SETRANGE("Function Name",WorkflowResponseHandling.PostDocumentAsyncCode);
      WorkflowStep.FINDFIRST;

      WorkflowStep.VALIDATE("Function Name",WorkflowResponseHandling.PostDocumentCode);
      WorkflowStep.MODIFY(TRUE);

      WorkflowStep.SETRANGE("Function Name",WorkflowResponseHandling.CreatePmtLineForPostedPurchaseDocAsyncCode);
      WorkflowStep.FINDFIRST;
      WorkflowStep.VALIDATE("Function Name",WorkflowResponseHandling.CreatePmtLineForPostedPurchaseDocCode);
      WorkflowStep.MODIFY(TRUE);

      LibraryPurchase.SelectPmtJnlBatch(GenJournalBatch);
      LibraryWorkflow.InsertPmtLineCreationArgument(WorkflowStep.ID,GenJournalBatch."Journal Template Name",GenJournalBatch.Name);

      WorkflowStep.SETRANGE("Function Name",WorkflowResponseHandling.CreateNotificationEntryCode);
      WorkflowStep.FINDFIRST;

      NotificationManagement.CreateDefaultNotificationTemplate(NotificationTemplate,NotificationTemplate.Type::"New Record");
      LibraryWorkflow.InsertNotificationArgument(WorkflowStep.ID,USERID,0,'');

      LibraryWorkflow.EnableWorkflow(Workflow);
Member of Lib.Library - Workflow


InsertPmtLineCreationArgument@43 Method

The procedure InsertPmtLineCreationArgument is available in codeunit 131101.

Syntax

InsertPmtLineCreationArgument@43(
    WorkflowStepID@1004 : Integer WorkflowStepID, //Input parameter of type Integer
    GenJnlTemplateName@1002 : Code[10] GenJnlTemplateName, //Input parameter of type Code
    GenJnlBatchName@1003 : Code[10] GenJnlBatchName //Input parameter of type Code
);

Parameters

WorkflowStepID
Input parameter of type Integer
GenJnlTemplateName
Input parameter of type Code
GenJnlBatchName
Input parameter of type Code

Remarks

The relevant search keywords are: Insert, Payment, Line, Creation, Argument.

For a clarification about how this function works, refer to the code listed below.

      InsertStepArgument(WorkflowStepArgument,WorkflowStepID);

      WorkflowStepArgument."General Journal Template Name" := GenJnlTemplateName;
      WorkflowStepArgument."General Journal Batch Name" := GenJnlBatchName;
      WorkflowStepArgument.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 134179 to show one way of using this function.

      LibraryWorkflow.CopyWorkflowTemplate(Workflow,WorkflowSetup.PurchaseInvoiceWorkflowCode);

      WorkflowStep.SETRANGE("Workflow Code",Workflow.Code);
      WorkflowStep.SETRANGE(Type,WorkflowStep.Type::Response);

      WorkflowStep.SETRANGE("Function Name",WorkflowResponseHandling.PostDocumentAsyncCode);
      WorkflowStep.FINDFIRST;

      WorkflowStep.VALIDATE("Function Name",WorkflowResponseHandling.PostDocumentCode);
      WorkflowStep.MODIFY(TRUE);

      WorkflowStep.SETRANGE("Function Name",WorkflowResponseHandling.CreatePmtLineForPostedPurchaseDocAsyncCode);
      WorkflowStep.FINDFIRST;
      WorkflowStep.VALIDATE("Function Name",WorkflowResponseHandling.CreatePmtLineForPostedPurchaseDocCode);
      WorkflowStep.MODIFY(TRUE);

      LibraryPurchase.SelectPmtJnlBatch(GenJournalBatch);
      LibraryWorkflow.InsertPmtLineCreationArgument(WorkflowStep.ID,GenJournalBatch."Journal Template Name",GenJournalBatch.Name);

      WorkflowStep.SETRANGE("Function Name",WorkflowResponseHandling.CreateNotificationEntryCode);
      WorkflowStep.FINDFIRST;

      NotificationManagement.CreateDefaultNotificationTemplate(NotificationTemplate,NotificationTemplate.Type::"New Record");
      LibraryWorkflow.InsertNotificationArgument(WorkflowStep.ID,USERID,0,'');

      LibraryWorkflow.EnableWorkflow(Workflow);
Member of Lib.Library - Workflow


InsertRecChangeValueArgument@130 Method

The procedure InsertRecChangeValueArgument is available in codeunit 131101.

Syntax

InsertRecChangeValueArgument@130(
    WorkflowStepID@1000 : Integer WorkflowStepID, //Input parameter of type Integer
    TableNo@1002 : Integer TableNo, //Input parameter of type Integer
    FieldNo@1003 : Integer FieldNo //Input parameter of type Integer
);

Parameters

WorkflowStepID
Input parameter of type Integer
TableNo
Input parameter of type Integer
FieldNo
Input parameter of type Integer

Remarks

The relevant search keywords are: Insert, Rec, Change, Value, Argument.

For a clarification about how this function works, refer to the code listed below.

      InsertStepArgument(WorkflowStepArgument,WorkflowStepID);

      WorkflowStepArgument."Table No." := TableNo;
      WorkflowStepArgument."Field No." := FieldNo;
      WorkflowStepArgument.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - Workflow


InsertResponseStep@9 Method

The procedure InsertResponseStep is available in codeunit 131101.

Syntax

InsertResponseStep@9(
    Workflow@1001 : Record 1501 Workflow, //Input parameter of type Record
    ActivityName@1000 : Code[128] ActivityName, //Input parameter of type Code
    PreviousStepID@1002 : Integer PreviousStepID //Input parameter of type Integer
);

Parameters

Workflow
Input parameter of type Record
ActivityName
Input parameter of type Code
PreviousStepID
Input parameter of type Integer

Return Value

Integer

Remarks

The relevant search keywords are: Insert, Response, Step.

For a clarification about how this function works, refer to the code listed below.

      InsertStep(WorkflowStep,Workflow.Code,WorkflowStep.Type::Response,ActivityName);
      WorkflowStep."Sequence No." := GetNextSequenceNo(Workflow,PreviousStepID);
      WorkflowStep.VALIDATE("Previous Workflow Step ID",PreviousStepID);
      WorkflowStep.MODIFY(TRUE);
      EXIT(WorkflowStep.ID);

Example

There are no examples available.
Member of Lib.Library - Workflow


InsertSubWorkflowStep@20 Method

The procedure InsertSubWorkflowStep is available in codeunit 131101.

Syntax

InsertSubWorkflowStep@20(
    Workflow@1001 : Record 1501 Workflow, //Input parameter of type Record
    WorkflowCode@1000 : Code[20] WorkflowCode, //Input parameter of type Code
    PreviousStepID@1002 : Integer PreviousStepID //Input parameter of type Integer
);

Parameters

Workflow
Input parameter of type Record
WorkflowCode
Input parameter of type Code
PreviousStepID
Input parameter of type Integer

Return Value

Integer

Remarks

The relevant search keywords are: Insert, Sub, Workflow, Step.

For a clarification about how this function works, refer to the code listed below.

      InsertStep(WorkflowStep,Workflow.Code,WorkflowStep.Type::"Sub-Workflow",WorkflowCode);
      WorkflowStep."Sequence No." := GetNextSequenceNo(Workflow,PreviousStepID);
      WorkflowStep.VALIDATE("Previous Workflow Step ID",PreviousStepID);
      WorkflowStep.MODIFY(TRUE);
      EXIT(WorkflowStep.ID);

Example

There are no examples available.
Member of Lib.Library - Workflow


InsertTableRelation@7 Method

The procedure InsertTableRelation is available in codeunit 131101.

Syntax

InsertTableRelation@7(
    TableId@1000 : Integer TableId, //Input parameter of type Integer
    FieldId@1001 : Integer FieldId, //Input parameter of type Integer
    RelatedTableId@1002 : Integer RelatedTableId, //Input parameter of type Integer
    RelatedFieldId@1003 : Integer RelatedFieldId //Input parameter of type Integer
);

Parameters

TableId
Input parameter of type Integer
FieldId
Input parameter of type Integer
RelatedTableId
Input parameter of type Integer
RelatedFieldId
Input parameter of type Integer

Remarks

The relevant search keywords are: Insert, Table, Relation.

For a clarification about how this function works, refer to the code listed below.

      WorkflowTableRelation.INIT;
      WorkflowTableRelation."Table ID" := TableId;
      WorkflowTableRelation."Field ID" := FieldId;
      WorkflowTableRelation."Related Table ID" := RelatedTableId;
      WorkflowTableRelation."Related Field ID" := RelatedFieldId;
      WorkflowTableRelation.INSERT;

Example

There are no examples available.
Member of Lib.Library - Workflow


SetEventStepAsEntryPoint@16 Method

The procedure SetEventStepAsEntryPoint is available in codeunit 131101.

Syntax

SetEventStepAsEntryPoint@16(
    Workflow@1003 : Record 1501 Workflow, //Input parameter of type Record
    WorkflowStepID@1001 : Integer WorkflowStepID //Input parameter of type Integer
);

Parameters

Workflow
Input parameter of type Record
WorkflowStepID
Input parameter of type Integer

Remarks

The relevant search keywords are: Set, Event, Step, As, Entry, Point.

For a clarification about how this function works, refer to the code listed below.

      WorkflowStep.GET(Workflow.Code,WorkflowStepID);
      WorkflowStep.TESTFIELD(Type,WorkflowStep.Type::"Event");
      WorkflowStep.VALIDATE("Entry Point",TRUE);
      WorkflowStep.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - Workflow


SetNextStep@34 Method

The procedure SetNextStep is available in codeunit 131101.

Syntax

SetNextStep@34(
    Workflow@1003 : Record 1501 Workflow, //Input parameter of type Record
    WorkflowStepID@1001 : Integer WorkflowStepID, //Input parameter of type Integer
    NextStepID@1000 : Integer NextStepID //Input parameter of type Integer
);

Parameters

Workflow
Input parameter of type Record
WorkflowStepID
Input parameter of type Integer
NextStepID
Input parameter of type Integer

Remarks

The relevant search keywords are: Set, Next, Step.

For a clarification about how this function works, refer to the code listed below.

      WorkflowStep.GET(Workflow.Code,WorkflowStepID);
      WorkflowStep.VALIDATE("Next Workflow Step ID",NextStepID);
      WorkflowStep.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - Workflow


SetSequenceNo@23 Method

The procedure SetSequenceNo is available in codeunit 131101.

Syntax

SetSequenceNo@23(
    Workflow@1003 : Record 1501 Workflow, //Input parameter of type Record
    WorkflowStepID@1001 : Integer WorkflowStepID, //Input parameter of type Integer
    SequenceNo@1000 : Integer SequenceNo //Input parameter of type Integer
);

Parameters

Workflow
Input parameter of type Record
WorkflowStepID
Input parameter of type Integer
SequenceNo
Input parameter of type Integer

Remarks

The relevant search keywords are: Set, Sequence, No.

For a clarification about how this function works, refer to the code listed below.

      WorkflowStep.GET(Workflow.Code,WorkflowStepID);
      WorkflowStep.VALIDATE("Sequence No.",SequenceNo);
      WorkflowStep.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - Workflow


SetSubWorkflowStepAsEntryPoint@8 Method

The procedure SetSubWorkflowStepAsEntryPoint is available in codeunit 131101.

Syntax

SetSubWorkflowStepAsEntryPoint@8(
    Workflow@1003 : Record 1501 Workflow, //Input parameter of type Record
    WorkflowStepID@1001 : Integer WorkflowStepID //Input parameter of type Integer
);

Parameters

Workflow
Input parameter of type Record
WorkflowStepID
Input parameter of type Integer

Remarks

The relevant search keywords are: Set, Sub, Workflow, Step, As, Entry, Point.

For a clarification about how this function works, refer to the code listed below.

      WorkflowStep.GET(Workflow.Code,WorkflowStepID);
      WorkflowStep.TESTFIELD(Type,WorkflowStep.Type::"Sub-Workflow");
      WorkflowStep.VALIDATE("Entry Point",TRUE);
      WorkflowStep.MODIFY(TRUE);

Example

There are no examples available.
Member of Lib.Library - Workflow


SetUpSMTPEmailSetup@5 Method

The procedure SetUpSMTPEmailSetup is available in codeunit 131101.

Syntax

SetUpSMTPEmailSetup@5(
      //param element not supplied
);

Remarks

The relevant search keywords are: Set, Up, SMTP, Email, Setup.

For a clarification about how this function works, refer to the code listed below.

      SMTPMailSetup.DELETEALL;

      SMTPMailSetup.INIT;
      SMTPMailSetup."SMTP Server" := 'localhost';
      SMTPMailSetup."SMTP Server Port" := 8081;
      SMTPMailSetup."User ID" := 'TestUser';
      SMTPMailSetup.Password := 'TestPassword';
      SMTPMailSetup.Authentication := SMTPMailSetup.Authentication::Basic;
      SMTPMailSetup.INSERT;

Example

There are no examples available.
Member of Lib.Library - Workflow


VerifyEmailContainsValues@17 Method

The procedure VerifyEmailContainsValues is available in codeunit 131101.

Syntax

VerifyEmailContainsValues@17(
    ExpectedValues@1000 : ARRAY [5] OF Text ExpectedValues, //Input Array parameter of type Text
    UserCode@1007 : Code[50] UserCode //Input parameter of type Code
);

Parameters

ExpectedValues
Input Array parameter of type Text
UserCode
Input parameter of type Code

Remarks

The relevant search keywords are: Verify, Email, Contains, Values.

For a clarification about how this function works, refer to the code listed below.

      SentNotificationEntry.SETRANGE("Recipient User ID",UserCode);

      Retries := 0;
      WHILE (NOT SentNotificationEntry.FINDFIRST) AND (Retries < 120) DO BEGIN
        SLEEP(1000);
        Retries += 1;
      END;

      IF Retries = 120 THEN
        ERROR(TimeoutErr);

      UserSetup.GET(UserCode);

      FilePath := GetEmailFilePath(UserSetup."E-Mail");
      IF FileManagement.ServerFileExists(FilePath) THEN BEGIN
        FOR index := 1 TO ARRAYLEN(ExpectedValues) DO
          IF ExpectedValues[index] <> '' THEN
            Assert.IsTrue(LibraryTextFileValidation.DoesFileContainValue(FilePath,ExpectedValues[index]),
              'The value was not found in the file');
        FileManagement.DeleteServerFile(FilePath);
      END ELSE
        Assert.Fail('File not found at:' + FilePath);

Example

There are no examples available.
Member of Lib.Library - Workflow


VerifyEmailWithMockService@4 Method

The procedure VerifyEmailWithMockService is available in codeunit 131101.

Syntax

VerifyEmailWithMockService@4(
    UserId@1003 : Code[50] UserId, //Input parameter of type Code
    NotificationBodyText@1004 : Text NotificationBodyText //Input parameter of type Text
);

Parameters

UserId
Input parameter of type Code
NotificationBodyText
Input parameter of type Text

Remarks

The relevant search keywords are: Verify, Email, Mock, Service.

For a clarification about how this function works, refer to the code listed below.

      SentNotificationEntry.SETRANGE("Recipient User ID",UserId);

      Retries := 0;
      WHILE (NOT SentNotificationEntry.FINDFIRST) AND (Retries < 120) DO BEGIN
        SLEEP(1000);
        Retries += 1;
      END;

      IF Retries = 120 THEN
        ERROR(TimeoutErr);

      UserSetup.GET(UserId);

      VerifyEmailFile(NotificationBodyText,UserSetup."E-Mail");

Example

There are no examples available.
Member of Lib.Library - Workflow


Library - XML Read Class

Lib.Library - XML Read

COD131335 applies to ERM,W1,All.

Methods

Name | Description
GetAttributeFromElement@7 | The procedure GetAttributeFromElement is available in codeunit 131335.
GetAttributeValueInSubtree@14 | The procedure GetAttributeValueInSubtree is available in codeunit 131335.
GetElementValue@2 | The procedure GetElementValue is available in codeunit 131335.
GetFirstElementValueFromNode@9 | The procedure GetFirstElementValueFromNode is available in codeunit 131335.
GetNodeByElementName@8 | The procedure GetNodeByElementName is available in codeunit 131335.
GetNodeListByElementName@6 | The procedure GetNodeListByElementName is available in codeunit 131335.
GetNodesCount@22 | The procedure GetNodesCount is available in codeunit 131335.
GetNodeValueAtIndex@21 | The procedure GetNodeValueAtIndex is available in codeunit 131335.
GetNodeValueInSubtree@15 | The procedure GetNodeValueInSubtree is available in codeunit 131335.
Initialize@1 | The procedure Initialize is available in codeunit 131335.
LocateNodeInSubtree@17 | The procedure LocateNodeInSubtree is available in codeunit 131335.
VerifyAttributeAbsence@37 | The procedure VerifyAttributeAbsence is available in codeunit 131335.
VerifyAttributeAbsenceInSubtree@25 | The procedure VerifyAttributeAbsenceInSubtree is available in codeunit 131335.
VerifyAttributeValue@4 | The procedure VerifyAttributeValue is available in codeunit 131335.
VerifyAttributeValueInSubtree@19 | The procedure VerifyAttributeValueInSubtree is available in codeunit 131335.
VerifyElementAbsenceInSubtree@23 | The procedure VerifyElementAbsenceInSubtree is available in codeunit 131335.
VerifyNodeAbsence@26 | The procedure VerifyNodeAbsence is available in codeunit 131335.
VerifyNodeAbsenceInSubtree@24 | The procedure VerifyNodeAbsenceInSubtree is available in codeunit 131335.
VerifyNodeValue@3 | The procedure VerifyNodeValue is available in codeunit 131335.
VerifyNodeValueInSubtree@18 | The procedure VerifyNodeValueInSubtree is available in codeunit 131335.
VerifyXMLDeclaration@5 | The procedure VerifyXMLDeclaration is available in codeunit 131335.

See Also

Lib


GetAttributeFromElement@7 Method

The procedure GetAttributeFromElement is available in codeunit 131335.

Syntax

GetAttributeFromElement@7(
    ElementName@1002 : Text ElementName, //Input parameter of type Text
    AttributeName@1001 : Text AttributeName, //Input parameter of type Text
    VAR Attribute@1000 : DotNet "'System.Xml Attribute, //Reference parameter of type DotNet
     Version=2.0.0.0  //param element not supplied
     Culture=neutral  //param element not supplied
     PublicKeyToken=b77a5c561934e089'.System.Xml.XmlAttribute"  //param element not supplied
);

Parameters

ElementName
Input parameter of type Text
AttributeName
Input parameter of type Text
Attribute
Reference parameter of type DotNet

Remarks

The relevant search keywords are: Get, Attribute, From, Element.

For a clarification about how this function works, refer to the code listed below.

      GetNodeByElementName(ElementName,Node);
      Attribute := Node.Attributes.GetNamedItem(AttributeName);

Example

There are no examples available.
Member of Lib.Library - XML Read


GetAttributeValueInSubtree@14 Method

The procedure GetAttributeValueInSubtree is available in codeunit 131335.

Syntax

GetAttributeValueInSubtree@14(
    RootNodeName@1002 : Text RootNodeName, //Input parameter of type Text
    NodeName@1001 : Text NodeName, //Input parameter of type Text
    AttributeName@1000 : Text AttributeName //Input parameter of type Text
);

Parameters

RootNodeName
Input parameter of type Text
NodeName
Input parameter of type Text
AttributeName
Input parameter of type Text

Return Value

Text

Remarks

The relevant search keywords are: Get, Attribute, Value, In, Subtree.

For a clarification about how this function works, refer to the code listed below.

      LocateNodeInSubtree(Node,RootNodeName,NodeName,'',NodeMatchCriteria::FindByName);

      AttributeCollection := Node.Attributes;
      IF ISNULL(AttributeCollection) THEN
        Assert.Fail(STRSUBSTNO(NodeHasNoAttributesErr,NodeName,RootNodeName));

      Attribute := AttributeCollection.ItemOf(AttributeName);
      IF ISNULL(Attribute) THEN
        Assert.Fail(STRSUBSTNO(AttributeNotFoundErr,NodeName,RootNodeName,AttributeName));

      EXIT(Attribute.Value);

Example

There are no examples available.
Member of Lib.Library - XML Read


GetElementValue@2 Method

The procedure GetElementValue is available in codeunit 131335.

Syntax

GetElementValue@2(
    ElementName@1000 : Text ElementName //Input parameter of type Text
);

Parameters

ElementName
Input parameter of type Text

Return Value

Text[1024]

Remarks

The relevant search keywords are: Get, Element, Value.

For a clarification about how this function works, refer to the code listed below.

      GetNodeByElementName(ElementName,XMLNode);
      EXIT(COPYSTR(XMLNode.InnerText,1,1024));

Example

There are no examples available.
Member of Lib.Library - XML Read


GetFirstElementValueFromNode@9 Method

The procedure GetFirstElementValueFromNode is available in codeunit 131335.

Syntax

GetFirstElementValueFromNode@9(
    ElementName@1002 : Text ElementName, //Input parameter of type Text
    NodeName@1001 : Text NodeName //Input parameter of type Text
);

Parameters

ElementName
Input parameter of type Text
NodeName
Input parameter of type Text

Return Value

Text

Remarks

The relevant search keywords are: Get, First, Element, Value, From, Node.

For a clarification about how this function works, refer to the code listed below.

      GetNodeListByElementName(NodeName,NodeList);
      Msg := COPYSTR(STRSUBSTNO(CountErr,NodeName),1,MAXSTRLEN(Msg));
      Assert.AreNotEqual(0,NodeList.Count,Msg);
      Node := NodeList.Item(0).SelectSingleNode(ElementName);

      EXIT(Node.InnerText);

Example

There are no examples available.
Member of Lib.Library - XML Read


GetNodeByElementName@8 Method

The procedure GetNodeByElementName is available in codeunit 131335.

Syntax

GetNodeByElementName@8(
    ElementName@1001 : Text ElementName, //Input parameter of type Text
    VAR Node@1000 : DotNet "'System.Xml Node, //Reference parameter of type DotNet
     Version=2.0.0.0  //param element not supplied
     Culture=neutral  //param element not supplied
     PublicKeyToken=b77a5c561934e089'.System.Xml.XmlNode"  //param element not supplied
);

Parameters

ElementName
Input parameter of type Text
Node
Reference parameter of type DotNet

Remarks

The relevant search keywords are: Get, Node, By, Element, Name.

For a clarification about how this function works, refer to the code listed below.

      GetNodeListByElementName(ElementName,NodeList);
      Node := NodeList.Item(0);

Example

There are no examples available.
Member of Lib.Library - XML Read


GetNodeListByElementName@6 Method

The procedure GetNodeListByElementName is available in codeunit 131335.

Syntax

GetNodeListByElementName@6(
    ElementName@1001 : Text ElementName, //Input parameter of type Text
    VAR NodeList@1000 : DotNet "'System.Xml NodeList, //Reference parameter of type DotNet
     Version=2.0.0.0  //param element not supplied
     Culture=neutral  //param element not supplied
     PublicKeyToken=b77a5c561934e089'.System.Xml.XmlNodeList"  //param element not supplied
);

Parameters

ElementName
Input parameter of type Text
NodeList
Reference parameter of type DotNet

Return Value

Integer

Remarks

The relevant search keywords are: Get, Node, List, By, Element, Name.

For a clarification about how this function works, refer to the code listed below.

      NodeList := XMLDocOut.GetElementsByTagName(ElementName);
      IF NodeList.Count = 0 THEN
        ERROR(MissingElementErr,ElementName);
      EXIT(NodeList.Count);

Example

There are no examples available.
Member of Lib.Library - XML Read


GetNodesCount@22 Method

The procedure GetNodesCount is available in codeunit 131335.

Syntax

GetNodesCount@22(
    NodeName@1000 : Text NodeName //Input parameter of type Text
);

Parameters

NodeName
Input parameter of type Text

Return Value

Integer

Remarks

The relevant search keywords are: Get, Nodes, Count.

For a clarification about how this function works, refer to the code listed below.

      EXIT(GetNodeListByElementName(NodeName,NodeList));

Example

There are no examples available.
Member of Lib.Library - XML Read


GetNodeValueAtIndex@21 Method

The procedure GetNodeValueAtIndex is available in codeunit 131335.

Syntax

GetNodeValueAtIndex@21(
    NodeName@1000 : Text NodeName, //Input parameter of type Text
    Index@1003 : Integer Index //Input parameter of type Integer
);

Parameters

NodeName
Input parameter of type Text
Index
Input parameter of type Integer

Return Value

Text[1024]

Remarks

The relevant search keywords are: Get, Node, Value, At, Index.

For a clarification about how this function works, refer to the code listed below.

      NodesCount := GetNodeListByElementName(NodeName,NodeList);
      IF (Index < 0) OR (Index >= NodesCount) THEN
        ERROR(STRSUBSTNO(NodeIndexOutOfBoundsErr,NodeName,Index,NodesCount));
      XMLNode := NodeList.Item(Index);
      EXIT(COPYSTR(XMLNode.InnerText,1,1024));

Example

There are no examples available.
Member of Lib.Library - XML Read


GetNodeValueInSubtree@15 Method

The procedure GetNodeValueInSubtree is available in codeunit 131335.

Syntax

GetNodeValueInSubtree@15(
    RootNodeName@1001 : Text RootNodeName, //Input parameter of type Text
    NodeName@1000 : Text NodeName //Input parameter of type Text
);

Parameters

RootNodeName
Input parameter of type Text
NodeName
Input parameter of type Text

Return Value

Text

Remarks

The relevant search keywords are: Get, Node, Value, In, Subtree.

For a clarification about how this function works, refer to the code listed below.

      LocateNodeInSubtree(Node,RootNodeName,NodeName,'',NodeMatchCriteria::FindByName);
      EXIT(Node.InnerText);

Example

There are no examples available.
Member of Lib.Library - XML Read


Initialize@1 Method

The procedure Initialize is available in codeunit 131335.

Syntax

Initialize@1(
    FullFilePath@1000 : Text FullFilePath //Input parameter of type Text
);

Parameters

FullFilePath
Input parameter of type Text

Remarks

The relevant search keywords are: Initialize.

For a clarification about how this function works, refer to the code listed below.

      CLEAR(XMLDocOut);
      XMLDocOut := XMLDocOut.XmlDocument;
      // TFS 379960 - We keep XmlDocument.Load, because the library intended to be ran on client
      XMLDocOut.Load(FullFilePath);

Example

The below example is extracted from the test automation codeunit 134406 to show one way of using this function.

      Initialize;

      // Setup
      PostedDocNo := PostWorkdateSalesInvoiceSEPADirectDebit(Customer,WORKDATE - 30,WORKDATE + 30,Customer."Partner Type"::Company);
      CreateSEPABankAccount(BankAccount);

      // Execute
      RunCreateDirectDebitCollectionReport(
        WORKDATE - 5,WORKDATE + 5,Customer."Partner Type"::Company,BankAccount."No.",FALSE,FALSE);
      DirectDebitCollectionEntry.SETFILTER("Applies-to Entry Document No.",'<>%1',PostedDocNo);
      DirectDebitCollectionEntry.DELETEALL(TRUE);
      DirectDebitCollectionEntry.SETRANGE("Applies-to Entry Document No.",PostedDocNo);
      DirectDebitCollectionEntry.FINDFIRST;
      DirectDebitCollectionEntry2.SETRANGE("Direct Debit Collection No.",DirectDebitCollectionEntry."Direct Debit Collection No.");
      ExportToServerTempFile(DirectDebitCollectionEntry2);

      // Verify
      LibraryXMLRead.Initialize(ServerFileName);
      LibraryXMLRead.VerifyNodeValueInSubtree('PmtTpInf','LclInstrm','B2B');
      LibraryXMLRead.VerifyNodeValue('ChrgBr','SLEV');
      // PmtTpInf/InstrPrty removed due to BUG: 267559
      LibraryXMLRead.VerifyElementAbsenceInSubtree('PmtTpInf','InstrPrty');
      LibraryXMLRead.VerifyNodeValueInSubtree('MndtRltdInf','MndtId',DirectDebitCollectionEntry."Mandate ID");
      LibraryXMLRead.VerifyNodeValueInSubtree('DrctDbtTxInf','InstdAmt',DirectDebitCollectionEntry."Transfer Amount");
      LibraryXMLRead.VerifyAttributeValueInSubtree('DrctDbtTxInf','InstdAmt','Ccy','EUR');
      LibraryXMLRead.VerifyNodeValueInSubtree('CdtrAcct','IBAN',BankAccount.IBAN);
      LibraryXMLRead.VerifyNodeValueInSubtree('FinInstnId','BIC',BankAccount."SWIFT Code");
Member of Lib.Library - XML Read


LocateNodeInSubtree@17 Method

The procedure LocateNodeInSubtree is available in codeunit 131335.

Syntax

LocateNodeInSubtree@17(
    VAR Node@1004 : DotNet "'System.Xml Node, //Reference parameter of type DotNet
     Version=4.0.0.0 RootNodeName, //Input parameter of type Text
     Culture=neutral NodeName, //Input parameter of type Text
     PublicKeyToken=b77a5c561934e089'.System.Xml.XmlNode" ExpectedNodeValue, //Input parameter of type Variant
    RootNodeName@1003 : Text MatchCriteria, //Input parameter of type Option
    NodeName@1002 : Text  //param element not supplied
    ExpectedNodeValue@1001 : Variant  //param element not supplied
    MatchCriteria@1000 : Option  //param element not supplied
);

Parameters

Node
Reference parameter of type DotNet
RootNodeName
Input parameter of type Text
NodeName
Input parameter of type Text
ExpectedNodeValue
Input parameter of type Variant
MatchCriteria
Input parameter of type Option

Remarks

The relevant search keywords are: Locate, Node, In, Subtree.

For a clarification about how this function works, refer to the code listed below.

      // If multiple nodes with the same name exist in the subtree, only the first one encountered will be verified.
      IF (MatchCriteria = NodeMatchCriteria::FindByNameAndValue) AND Equal(ExpectedNodeValue,'') THEN
        ERROR(IncorrectUseOfFunctionErr);
      IF NOT (MatchCriteria IN [NodeMatchCriteria::FindByName,NodeMatchCriteria::FindByNameAndValue]) THEN
        ERROR(IncorrectUseOfFunctionErr);

      NodeCount := GetNodeListByElementName(NodeName,NodeList);

      IF NodeCount < 1 THEN
        Assert.Fail(STRSUBSTNO(MissingNodeErr,NodeName));

      Index := 0;
      Found := FALSE;
      REPEAT
        Node := NodeList.Item(Index);
        IF HasIndirectParent(Node,RootNodeName) AND
           ((MatchCriteria = NodeMatchCriteria::FindByName) OR Equal(ExpectedNodeValue,Node.InnerText))
        THEN
          Found := TRUE
        ELSE
          Index += 1;
      UNTIL (Found OR (Index = NodeCount));

      IF NOT Found THEN
        IF MatchCriteria = NodeMatchCriteria::FindByName THEN
          Assert.Fail(STRSUBSTNO(NotFoundAnyInSubtreeErr,NodeName,RootNodeName))
        ELSE
          Assert.Fail(STRSUBSTNO(NotFoundInSubtreeErr,NodeName,ExpectedNodeValue,RootNodeName));

Example

There are no examples available.
Member of Lib.Library - XML Read


VerifyAttributeAbsence@37 Method

The procedure VerifyAttributeAbsence is available in codeunit 131335.

Syntax

VerifyAttributeAbsence@37(
    ElementName@1004 : Text ElementName, //Input parameter of type Text
    AttributeName@1005 : Text AttributeName //Input parameter of type Text
);

Parameters

ElementName
Input parameter of type Text
AttributeName
Input parameter of type Text

Remarks

The relevant search keywords are: Verify, Attribute, Absence.

For a clarification about how this function works, refer to the code listed below.

      GetAttributeFromElement(ElementName,AttributeName,Attribute);
      Assert.IsTrue(ISNULL(Attribute),STRSUBSTNO(AttributeExistsErr,AttributeName));

Example

There are no examples available.
Member of Lib.Library - XML Read


VerifyAttributeAbsenceInSubtree@25 Method

The procedure VerifyAttributeAbsenceInSubtree is available in codeunit 131335.

Syntax

VerifyAttributeAbsenceInSubtree@25(
    RootNodeName@1000 : Text RootNodeName, //Input parameter of type Text
    NodeName@1001 : Text NodeName, //Input parameter of type Text
    AttributeName@1002 : Text AttributeName //Input parameter of type Text
);

Parameters

RootNodeName
Input parameter of type Text
NodeName
Input parameter of type Text
AttributeName
Input parameter of type Text

Remarks

The relevant search keywords are: Verify, Attribute, Absence, In, Subtree.

For a clarification about how this function works, refer to the code listed below.

      ASSERTERROR GetAttributeValueInSubtree(RootNodeName,NodeName,AttributeName);
      Assert.ExpectedErrorCode('Dialog');
      Assert.ExpectedError(STRSUBSTNO(AttributeNotFoundErr,NodeName,RootNodeName,AttributeName));

Example

There are no examples available.
Member of Lib.Library - XML Read


VerifyAttributeValue@4 Method

The procedure VerifyAttributeValue is available in codeunit 131335.

Syntax

VerifyAttributeValue@4(
    ElementName@1002 : Text ElementName, //Input parameter of type Text
    AttributeName@1001 : Text AttributeName, //Input parameter of type Text
    Expected@1000 : Variant Expected //Input parameter of type Variant
);

Parameters

ElementName
Input parameter of type Text
AttributeName
Input parameter of type Text
Expected
Input parameter of type Variant

Remarks

The relevant search keywords are: Verify, Attribute, Value.

For a clarification about how this function works, refer to the code listed below.

      GetAttributeFromElement(ElementName,AttributeName,Attribute);
      Assert.AreEqual(FORMAT(Expected,0,9),Attribute.Value,
        STRSUBSTNO(AttributeValueErr,AttributeName));

Example

There are no examples available.
Member of Lib.Library - XML Read


VerifyAttributeValueInSubtree@19 Method

The procedure VerifyAttributeValueInSubtree is available in codeunit 131335.

Syntax

VerifyAttributeValueInSubtree@19(
    RootNodeName@1003 : Text RootNodeName, //Input parameter of type Text
    NodeName@1002 : Text NodeName, //Input parameter of type Text
    AttributeName@1001 : Text AttributeName, //Input parameter of type Text
    ExpectedAttributeValue@1000 : Text ExpectedAttributeValue //Input parameter of type Text
);

Parameters

RootNodeName
Input parameter of type Text
NodeName
Input parameter of type Text
AttributeName
Input parameter of type Text
ExpectedAttributeValue
Input parameter of type Text

Remarks

The relevant search keywords are: Verify, Attribute, Value, In, Subtree.

For a clarification about how this function works, refer to the code listed below.

      ActualAttributeValue := GetAttributeValueInSubtree(RootNodeName,NodeName,AttributeName);
      Assert.AreEqual(
        ExpectedAttributeValue,ActualAttributeValue,
        STRSUBSTNO(AttributeNodeValueErr,AttributeName,NodeName,RootNodeName));

Example

The below example is extracted from the test automation codeunit 134406 to show one way of using this function.

      Initialize;

      // Setup
      PostedDocNo := PostWorkdateSalesInvoiceSEPADirectDebit(Customer,WORKDATE - 30,WORKDATE + 30,Customer."Partner Type"::Company);
      CreateSEPABankAccount(BankAccount);

      // Execute
      RunCreateDirectDebitCollectionReport(
        WORKDATE - 5,WORKDATE + 5,Customer."Partner Type"::Company,BankAccount."No.",FALSE,FALSE);
      DirectDebitCollectionEntry.SETFILTER("Applies-to Entry Document No.",'<>%1',PostedDocNo);
      DirectDebitCollectionEntry.DELETEALL(TRUE);
      DirectDebitCollectionEntry.SETRANGE("Applies-to Entry Document No.",PostedDocNo);
      DirectDebitCollectionEntry.FINDFIRST;
      DirectDebitCollectionEntry2.SETRANGE("Direct Debit Collection No.",DirectDebitCollectionEntry."Direct Debit Collection No.");
      ExportToServerTempFile(DirectDebitCollectionEntry2);

      // Verify
      LibraryXMLRead.Initialize(ServerFileName);
      LibraryXMLRead.VerifyNodeValueInSubtree('PmtTpInf','LclInstrm','B2B');
      LibraryXMLRead.VerifyNodeValue('ChrgBr','SLEV');
      // PmtTpInf/InstrPrty removed due to BUG: 267559
      LibraryXMLRead.VerifyElementAbsenceInSubtree('PmtTpInf','InstrPrty');
      LibraryXMLRead.VerifyNodeValueInSubtree('MndtRltdInf','MndtId',DirectDebitCollectionEntry."Mandate ID");
      LibraryXMLRead.VerifyNodeValueInSubtree('DrctDbtTxInf','InstdAmt',DirectDebitCollectionEntry."Transfer Amount");
      LibraryXMLRead.VerifyAttributeValueInSubtree('DrctDbtTxInf','InstdAmt','Ccy','EUR');
      LibraryXMLRead.VerifyNodeValueInSubtree('CdtrAcct','IBAN',BankAccount.IBAN);
      LibraryXMLRead.VerifyNodeValueInSubtree('FinInstnId','BIC',BankAccount."SWIFT Code");
Member of Lib.Library - XML Read


VerifyElementAbsenceInSubtree@23 Method

The procedure VerifyElementAbsenceInSubtree is available in codeunit 131335.

Syntax

VerifyElementAbsenceInSubtree@23(
    RootNodeName@1001 : Text RootNodeName, //Input parameter of type Text
    NodeName@1000 : Text NodeName //Input parameter of type Text
);

Parameters

RootNodeName
Input parameter of type Text
NodeName
Input parameter of type Text

Remarks

The relevant search keywords are: Verify, Element, Absence, In, Subtree.

For a clarification about how this function works, refer to the code listed below.

      ASSERTERROR LocateNodeInSubtree(Node,RootNodeName,NodeName,'',NodeMatchCriteria::FindByName);
      Assert.ExpectedErrorCode('Dialog');
      Assert.ExpectedError(STRSUBSTNO(MissingElementErr,NodeName));

Example

The below example is extracted from the test automation codeunit 134406 to show one way of using this function.

      Initialize;

      // Setup
      PostedDocNo := PostWorkdateSalesInvoiceSEPADirectDebit(Customer,WORKDATE - 30,WORKDATE + 30,Customer."Partner Type"::Company);
      CreateSEPABankAccount(BankAccount);

      // Execute
      RunCreateDirectDebitCollectionReport(
        WORKDATE - 5,WORKDATE + 5,Customer."Partner Type"::Company,BankAccount."No.",FALSE,FALSE);
      DirectDebitCollectionEntry.SETFILTER("Applies-to Entry Document No.",'<>%1',PostedDocNo);
      DirectDebitCollectionEntry.DELETEALL(TRUE);
      DirectDebitCollectionEntry.SETRANGE("Applies-to Entry Document No.",PostedDocNo);
      DirectDebitCollectionEntry.FINDFIRST;
      DirectDebitCollectionEntry2.SETRANGE("Direct Debit Collection No.",DirectDebitCollectionEntry."Direct Debit Collection No.");
      ExportToServerTempFile(DirectDebitCollectionEntry2);

      // Verify
      LibraryXMLRead.Initialize(ServerFileName);
      LibraryXMLRead.VerifyNodeValueInSubtree('PmtTpInf','LclInstrm','B2B');
      LibraryXMLRead.VerifyNodeValue('ChrgBr','SLEV');
      // PmtTpInf/InstrPrty removed due to BUG: 267559
      LibraryXMLRead.VerifyElementAbsenceInSubtree('PmtTpInf','InstrPrty');
      LibraryXMLRead.VerifyNodeValueInSubtree('MndtRltdInf','MndtId',DirectDebitCollectionEntry."Mandate ID");
      LibraryXMLRead.VerifyNodeValueInSubtree('DrctDbtTxInf','InstdAmt',DirectDebitCollectionEntry."Transfer Amount");
      LibraryXMLRead.VerifyAttributeValueInSubtree('DrctDbtTxInf','InstdAmt','Ccy','EUR');
      LibraryXMLRead.VerifyNodeValueInSubtree('CdtrAcct','IBAN',BankAccount.IBAN);
      LibraryXMLRead.VerifyNodeValueInSubtree('FinInstnId','BIC',BankAccount."SWIFT Code");
Member of Lib.Library - XML Read


VerifyNodeAbsence@26 Method

The procedure VerifyNodeAbsence is available in codeunit 131335.

Syntax

VerifyNodeAbsence@26(
    NodeName@1000 : Text NodeName //Input parameter of type Text
);

Parameters

NodeName
Input parameter of type Text

Remarks

The relevant search keywords are: Verify, Node, Absence.

For a clarification about how this function works, refer to the code listed below.

      ASSERTERROR GetNodeByElementName(NodeName,XMLNode);
      Assert.ExpectedErrorCode('Dialog');
      Assert.ExpectedError(STRSUBSTNO(MissingElementErr,NodeName));

Example

There are no examples available.
Member of Lib.Library - XML Read


VerifyNodeAbsenceInSubtree@24 Method

The procedure VerifyNodeAbsenceInSubtree is available in codeunit 131335.

Syntax

VerifyNodeAbsenceInSubtree@24(
    RootNodeName@1001 : Text RootNodeName, //Input parameter of type Text
    NodeName@1000 : Text NodeName //Input parameter of type Text
);

Parameters

RootNodeName
Input parameter of type Text
NodeName
Input parameter of type Text

Remarks

The relevant search keywords are: Verify, Node, Absence, In, Subtree.

For a clarification about how this function works, refer to the code listed below.

      ASSERTERROR LocateNodeInSubtree(Node,RootNodeName,NodeName,'',NodeMatchCriteria::FindByName);
      Assert.ExpectedErrorCode('Dialog');
      Assert.ExpectedError(STRSUBSTNO(NotFoundAnyInSubtreeErr,NodeName,RootNodeName));

Example

There are no examples available.
Member of Lib.Library - XML Read


VerifyNodeValue@3 Method

The procedure VerifyNodeValue is available in codeunit 131335.

Syntax

VerifyNodeValue@3(
    ElementName@1001 : Text ElementName, //Input parameter of type Text
    Expected@1000 : Variant Expected //Input parameter of type Variant
);

Parameters

ElementName
Input parameter of type Text
Expected
Input parameter of type Variant

Remarks

The relevant search keywords are: Verify, Node, Value.

For a clarification about how this function works, refer to the code listed below.

      GetNodeByElementName(ElementName,XMLNode);
      Assert.AreEqual(FORMAT(Expected,0,9),XMLNode.InnerText,
        STRSUBSTNO(ElementValueErr,ElementName));

Example

The below example is extracted from the test automation codeunit 134406 to show one way of using this function.

      Initialize;

      // Setup
      PostedDocNo := PostWorkdateSalesInvoiceSEPADirectDebit(Customer,WORKDATE - 30,WORKDATE + 30,Customer."Partner Type"::Company);
      CreateSEPABankAccount(BankAccount);

      // Execute
      RunCreateDirectDebitCollectionReport(
        WORKDATE - 5,WORKDATE + 5,Customer."Partner Type"::Company,BankAccount."No.",FALSE,FALSE);
      DirectDebitCollectionEntry.SETFILTER("Applies-to Entry Document No.",'<>%1',PostedDocNo);
      DirectDebitCollectionEntry.DELETEALL(TRUE);
      DirectDebitCollectionEntry.SETRANGE("Applies-to Entry Document No.",PostedDocNo);
      DirectDebitCollectionEntry.FINDFIRST;
      DirectDebitCollectionEntry2.SETRANGE("Direct Debit Collection No.",DirectDebitCollectionEntry."Direct Debit Collection No.");
      ExportToServerTempFile(DirectDebitCollectionEntry2);

      // Verify
      LibraryXMLRead.Initialize(ServerFileName);
      LibraryXMLRead.VerifyNodeValueInSubtree('PmtTpInf','LclInstrm','B2B');
      LibraryXMLRead.VerifyNodeValue('ChrgBr','SLEV');
      // PmtTpInf/InstrPrty removed due to BUG: 267559
      LibraryXMLRead.VerifyElementAbsenceInSubtree('PmtTpInf','InstrPrty');
      LibraryXMLRead.VerifyNodeValueInSubtree('MndtRltdInf','MndtId',DirectDebitCollectionEntry."Mandate ID");
      LibraryXMLRead.VerifyNodeValueInSubtree('DrctDbtTxInf','InstdAmt',DirectDebitCollectionEntry."Transfer Amount");
      LibraryXMLRead.VerifyAttributeValueInSubtree('DrctDbtTxInf','InstdAmt','Ccy','EUR');
      LibraryXMLRead.VerifyNodeValueInSubtree('CdtrAcct','IBAN',BankAccount.IBAN);
      LibraryXMLRead.VerifyNodeValueInSubtree('FinInstnId','BIC',BankAccount."SWIFT Code");
Member of Lib.Library - XML Read


VerifyNodeValueInSubtree@18 Method

The procedure VerifyNodeValueInSubtree is available in codeunit 131335.

Syntax

VerifyNodeValueInSubtree@18(
    RootNodeName@1002 : Text RootNodeName, //Input parameter of type Text
    NodeName@1001 : Text NodeName, //Input parameter of type Text
    ExpectedNodeValue@1000 : Variant ExpectedNodeValue //Input parameter of type Variant
);

Parameters

RootNodeName
Input parameter of type Text
NodeName
Input parameter of type Text
ExpectedNodeValue
Input parameter of type Variant

Remarks

The relevant search keywords are: Verify, Node, Value, In, Subtree.

For a clarification about how this function works, refer to the code listed below.

      LocateNodeInSubtree(Node,RootNodeName,NodeName,ExpectedNodeValue,NodeMatchCriteria::FindByNameAndValue);

Example

The below example is extracted from the test automation codeunit 134406 to show one way of using this function.

      Initialize;

      // Setup
      PostedDocNo := PostWorkdateSalesInvoiceSEPADirectDebit(Customer,WORKDATE - 30,WORKDATE + 30,Customer."Partner Type"::Company);
      CreateSEPABankAccount(BankAccount);

      // Execute
      RunCreateDirectDebitCollectionReport(
        WORKDATE - 5,WORKDATE + 5,Customer."Partner Type"::Company,BankAccount."No.",FALSE,FALSE);
      DirectDebitCollectionEntry.SETFILTER("Applies-to Entry Document No.",'<>%1',PostedDocNo);
      DirectDebitCollectionEntry.DELETEALL(TRUE);
      DirectDebitCollectionEntry.SETRANGE("Applies-to Entry Document No.",PostedDocNo);
      DirectDebitCollectionEntry.FINDFIRST;
      DirectDebitCollectionEntry2.SETRANGE("Direct Debit Collection No.",DirectDebitCollectionEntry."Direct Debit Collection No.");
      ExportToServerTempFile(DirectDebitCollectionEntry2);

      // Verify
      LibraryXMLRead.Initialize(ServerFileName);
      LibraryXMLRead.VerifyNodeValueInSubtree('PmtTpInf','LclInstrm','B2B');
      LibraryXMLRead.VerifyNodeValue('ChrgBr','SLEV');
      // PmtTpInf/InstrPrty removed due to BUG: 267559
      LibraryXMLRead.VerifyElementAbsenceInSubtree('PmtTpInf','InstrPrty');
      LibraryXMLRead.VerifyNodeValueInSubtree('MndtRltdInf','MndtId',DirectDebitCollectionEntry."Mandate ID");
      LibraryXMLRead.VerifyNodeValueInSubtree('DrctDbtTxInf','InstdAmt',DirectDebitCollectionEntry."Transfer Amount");
      LibraryXMLRead.VerifyAttributeValueInSubtree('DrctDbtTxInf','InstdAmt','Ccy','EUR');
      LibraryXMLRead.VerifyNodeValueInSubtree('CdtrAcct','IBAN',BankAccount.IBAN);
      LibraryXMLRead.VerifyNodeValueInSubtree('FinInstnId','BIC',BankAccount."SWIFT Code");
Member of Lib.Library - XML Read


VerifyXMLDeclaration@5 Method

The procedure VerifyXMLDeclaration is available in codeunit 131335.

Syntax

VerifyXMLDeclaration@5(
    Version@1002 : Text Version, //Input parameter of type Text
    Encoding@1001 : Text Encoding, //Input parameter of type Text
    Standalone@1000 : Text Standalone //Input parameter of type Text
);

Parameters

Version
Input parameter of type Text
Encoding
Input parameter of type Text
Standalone
Input parameter of type Text

Remarks

The relevant search keywords are: Verify, XML, Declaration.

For a clarification about how this function works, refer to the code listed below.

      XMLDeclaration := XMLDocOut.FirstChild;
      Assert.AreEqual(Version,XMLDeclaration.Version,DeclarationVersionErr);
      Assert.AreEqual(Encoding,XMLDeclaration.Encoding,DeclarationEncodingErr);
      Assert.AreEqual(Standalone,XMLDeclaration.Standalone,DeclarationStandaloneErr);

Example

There are no examples available.
Member of Lib.Library - XML Read


Library - XPath XML Reader Class

Lib.Library - XPath XML Reader

COD131337 applies to ERM,W1,All.

Methods

Name | Description
AddAdditionalNamespace@41 | The procedure AddAdditionalNamespace is available in codeunit 131337.
CompareTextWithInteger@14 | The procedure CompareTextWithInteger is available in codeunit 131337.
GetAttributeFromElement@8 | The procedure GetAttributeFromElement is available in codeunit 131337.
GetAttributeValueFromNode@46 | The procedure GetAttributeValueFromNode is available in codeunit 131337.
GetElementInCurrNode@11 | The procedure GetElementInCurrNode is available in codeunit 131337.
GetElementValue@2 | The procedure GetElementValue is available in codeunit 131337.
GetElementValueInCurrNode@12 | The procedure GetElementValueInCurrNode is available in codeunit 131337.
GetNodeByElementName@10 | The procedure GetNodeByElementName is available in codeunit 131337.
GetNodeByXPath@9 | The procedure GetNodeByXPath is available in codeunit 131337.
GetNodeList@22 | The procedure GetNodeList is available in codeunit 131337.
GetNodeListByElementName@7 | The procedure GetNodeListByElementName is available in codeunit 131337.
GetNodeListInCurrNode@26 | The procedure GetNodeListInCurrNode is available in codeunit 131337.
Initialize@1 | The procedure Initialize is available in codeunit 131337.
InitializeWithBlob@13 | The procedure InitializeWithBlob is available in codeunit 131337.
InitializeWithPrefix@40 | The procedure InitializeWithPrefix is available in codeunit 131337.
InitializeWithText@20 | The procedure InitializeWithText is available in codeunit 131337.
SetDefaultNamespaceUsage@21 | The procedure SetDefaultNamespaceUsage is available in codeunit 131337.
VerifyAttributeAbsence@5 | The procedure VerifyAttributeAbsence is available in codeunit 131337.
VerifyAttributeAbsenceFromNode@18 | The procedure VerifyAttributeAbsenceFromNode is available in codeunit 131337.
VerifyAttributeFromNode@17 | The procedure VerifyAttributeFromNode is available in codeunit 131337.
VerifyAttributeValue@6 | The procedure VerifyAttributeValue is available in codeunit 131337.
VerifyNodeAbsence@3 | The procedure VerifyNodeAbsence is available in codeunit 131337.
VerifyNodeCountByXPath@23 | The procedure VerifyNodeCountByXPath is available in codeunit 131337.
VerifyNodeCountWithValueByXPath@15 | The procedure VerifyNodeCountWithValueByXPath is available in codeunit 131337.
VerifyNodeValue@4 | The procedure VerifyNodeValue is available in codeunit 131337.
VerifyNodeValueByXPath@16 | The procedure VerifyNodeValueByXPath is available in codeunit 131337.
VerifyNodeValueByXPathWithIndex@19 | The procedure VerifyNodeValueByXPathWithIndex is available in codeunit 131337.
VerifyOptionalAttributeFromNode@33 | The procedure VerifyOptionalAttributeFromNode is available in codeunit 131337.

See Also

Lib


AddAdditionalNamespace@41 Method

The procedure AddAdditionalNamespace is available in codeunit 131337.

Syntax

AddAdditionalNamespace@41(
    Prefix@1000 : Text Prefix, //Input parameter of type Text
    Namespace@1001 : Text Namespace //Input parameter of type Text
);

Parameters

Prefix
Input parameter of type Text
Namespace
Input parameter of type Text

Remarks

The relevant search keywords are: Add, Additional, Namespace.

For a clarification about how this function works, refer to the code listed below.

      XMLNsMgr.AddNamespace(Prefix,Namespace);

Example

There are no examples available.
Member of Lib.Library - XPath XML Reader


CompareTextWithInteger@14 Method

The procedure CompareTextWithInteger is available in codeunit 131337.

Syntax

CompareTextWithInteger@14(
    TextValue@1000 : Text TextValue, //Input parameter of type Text
    ExpectedValue@1001 : Integer ExpectedValue //Input parameter of type Integer
);

Parameters

TextValue
Input parameter of type Text
ExpectedValue
Input parameter of type Integer

Remarks

The relevant search keywords are: Compare, Text, Integer.

For a clarification about how this function works, refer to the code listed below.

      IF EVALUATE(Value,TextValue) THEN
        IF Value = ExpectedValue THEN
          EXIT;

      ERROR(UnexpectedValueErr,ExpectedValue,TextValue);

Example

There are no examples available.
Member of Lib.Library - XPath XML Reader


GetAttributeFromElement@8 Method

The procedure GetAttributeFromElement is available in codeunit 131337.

Syntax

GetAttributeFromElement@8(
    ElementName@1000 : Text ElementName, //Input parameter of type Text
    AttributeName@1001 : Text AttributeName, //Input parameter of type Text
    VAR Attribute@1002 : DotNet "'System.Xml Attribute, //Reference parameter of type DotNet
     Version=4.0.0.0  //param element not supplied
     Culture=neutral  //param element not supplied
     PublicKeyToken=b77a5c561934e089'.System.Xml.XmlAttribute"  //param element not supplied
);

Parameters

ElementName
Input parameter of type Text
AttributeName
Input parameter of type Text
Attribute
Reference parameter of type DotNet

Remarks

The relevant search keywords are: Get, Attribute, From, Element.

For a clarification about how this function works, refer to the code listed below.

      GetNodeByElementName(ElementName,Node);
      IF Node.Attributes.Count = 0 THEN
        Assert.Fail('Attribute is missing! ' + ElementName);
      Attribute := Node.Attributes.GetNamedItem(AttributeName);

Example

There are no examples available.
Member of Lib.Library - XPath XML Reader


GetAttributeValueFromNode@46 Method

The procedure GetAttributeValueFromNode is available in codeunit 131337.

Syntax

GetAttributeValueFromNode@46(
    Node@1001 : DotNet "'System.Xml Node, //Input parameter of type DotNet
     Version=4.0.0.0 AttributeName, //Input parameter of type Text
     Culture=neutral  //param element not supplied
     PublicKeyToken=b77a5c561934e089'.System.Xml.XmlNode"  //param element not supplied
    AttributeName@1000 : Text  //param element not supplied
);

Parameters

Node
Input parameter of type DotNet
AttributeName
Input parameter of type Text

Return Value

Text

Remarks

The relevant search keywords are: Get, Attribute, Value, From, Node.

For a clarification about how this function works, refer to the code listed below.

      Attribute := Node.Attributes.GetNamedItem(AttributeName);
      Assert.IsFalse(ISNULL(Attribute),STRSUBSTNO(MissingAttributeErr,AttributeName,Node.Name));
      Actual := Attribute.Value;
      EXIT(Actual);

Example

There are no examples available.
Member of Lib.Library - XPath XML Reader


GetElementInCurrNode@11 Method

The procedure GetElementInCurrNode is available in codeunit 131337.

Syntax

GetElementInCurrNode@11(
    CurrNode@1000 : DotNet "'System.Xml CurrNode, //Input parameter of type DotNet
     Version=4.0.0.0 ElementName, //Input parameter of type Text
     Culture=neutral ElementNode, //Reference parameter of type DotNet
     PublicKeyToken=b77a5c561934e089'.System.Xml.XmlNode"  //param element not supplied
    ElementName@1001 : Text  //param element not supplied
    VAR ElementNode@1002 : DotNet "'System.Xml  //param element not supplied
     Version=4.0.0.0  //param element not supplied
     Culture=neutral  //param element not supplied
     PublicKeyToken=b77a5c561934e089'.System.Xml.XmlNode"  //param element not supplied
);

Parameters

CurrNode
Input parameter of type DotNet
ElementName
Input parameter of type Text
ElementNode
Reference parameter of type DotNet

Remarks

The relevant search keywords are: Get, Element, In, Currency, Node.

For a clarification about how this function works, refer to the code listed below.

      ElementNode := CurrNode.SelectSingleNode(ElementName,XMLNsMgr);

Example

There are no examples available.
Member of Lib.Library - XPath XML Reader


GetElementValue@2 Method

The procedure GetElementValue is available in codeunit 131337.

Syntax

GetElementValue@2(
    ElementName@1000 : Text ElementName //Input parameter of type Text
);

Parameters

ElementName
Input parameter of type Text

Return Value

Text

Remarks

The relevant search keywords are: Get, Element, Value.

For a clarification about how this function works, refer to the code listed below.

      GetNodeByElementName(ElementName,XMLNode);
      EXIT(XMLNode.Value);

Example

There are no examples available.
Member of Lib.Library - XPath XML Reader


GetElementValueInCurrNode@12 Method

The procedure GetElementValueInCurrNode is available in codeunit 131337.

Syntax

GetElementValueInCurrNode@12(
    CurrNode@1000 : DotNet "'System.Xml CurrNode, //Input parameter of type DotNet
     Version=4.0.0.0 ElementName, //Input parameter of type Text
     Culture=neutral  //param element not supplied
     PublicKeyToken=b77a5c561934e089'.System.Xml.XmlNode"  //param element not supplied
    ElementName@1001 : Text  //param element not supplied
);

Parameters

CurrNode
Input parameter of type DotNet
ElementName
Input parameter of type Text

Return Value

Text

Remarks

The relevant search keywords are: Get, Element, Value, In, Currency, Node.

For a clarification about how this function works, refer to the code listed below.

      GetElementInCurrNode(CurrNode,ElementName,Node);
      EXIT(Node.InnerText);

Example

There are no examples available.
Member of Lib.Library - XPath XML Reader


GetNodeByElementName@10 Method

The procedure GetNodeByElementName is available in codeunit 131337.

Syntax

GetNodeByElementName@10(
    ElementName@1000 : Text ElementName, //Input parameter of type Text
    VAR Node@1001 : DotNet "'System.Xml Node, //Reference parameter of type DotNet
     Version=4.0.0.0  //param element not supplied
     Culture=neutral  //param element not supplied
     PublicKeyToken=b77a5c561934e089'.System.Xml.XmlNode"  //param element not supplied
);

Parameters

ElementName
Input parameter of type Text
Node
Reference parameter of type DotNet

Remarks

The relevant search keywords are: Get, Node, By, Element, Name.

For a clarification about how this function works, refer to the code listed below.

      GetNodeListByElementName(ElementName,NodeList);
      Node := NodeList.Item(0);

Example

There are no examples available.
Member of Lib.Library - XPath XML Reader


GetNodeByXPath@9 Method

The procedure GetNodeByXPath is available in codeunit 131337.

Syntax

GetNodeByXPath@9(
    xPath@1000 : Text xPath, //Input parameter of type Text
    VAR Node@1001 : DotNet "'System.Xml Node, //Reference parameter of type DotNet
     Version=4.0.0.0  //param element not supplied
     Culture=neutral  //param element not supplied
     PublicKeyToken=b77a5c561934e089'.System.Xml.XmlNode"  //param element not supplied
);

Parameters

xPath
Input parameter of type Text
Node
Reference parameter of type DotNet

Remarks

The relevant search keywords are: Get, Node, By, X, Path.

For a clarification about how this function works, refer to the code listed below.

      GetNodeList(xPath,NodeList);
      Assert.AreNotEqual(0,NodeList.Count,STRSUBSTNO(NodeNotFoundErr,xPath));
      Node := NodeList.Item(0);

Example

There are no examples available.
Member of Lib.Library - XPath XML Reader


GetNodeList@22 Method

The procedure GetNodeList is available in codeunit 131337.

Syntax

GetNodeList@22(
    xPath@1000 : Text xPath, //Input parameter of type Text
    VAR nodeList@1001 : DotNet "'System.Xml nodeList, //Reference parameter of type DotNet
     Version=4.0.0.0  //param element not supplied
     Culture=neutral  //param element not supplied
     PublicKeyToken=b77a5c561934e089'.System.Xml.XmlNodeList"  //param element not supplied
);

Parameters

xPath
Input parameter of type Text
nodeList
Reference parameter of type DotNet

Remarks

The relevant search keywords are: Get, Node, List.

For a clarification about how this function works, refer to the code listed below.

      IF SkipDefaultNamespace THEN
        nodeList := XMLDocOut.DocumentElement.SelectNodes(xPath,XMLNsMgr)
      ELSE
        nodeList := XMLDocOut.DocumentElement.SelectNodes(Replace(xPath,'/','/ns:'),XMLNsMgr);

Example

The below example is extracted from the test automation codeunit 134403 to show one way of using this function.

      // [SCENARIO 109389] Message to recipient is stored in the exported file
      Init;
      RequiredMessageLength := 140;

      // [GIVEN] A Payment Journal Line
      // [GIVEN] bal. bank account using the SEPA CT export format
      CreateGenJnlLine(GenJnlLine);

      // [GIVEN] 140 characters in "Message to recipient"
      GenJnlLine.VALIDATE("Message to Recipient",LibraryUtility.GenerateRandomXMLText(RequiredMessageLength));
      GenJnlLine.MODIFY(TRUE);
      Assert.AreEqual(RequiredMessageLength,STRLEN(GenJnlLine."Message to Recipient"),InvalidLengthErr);

      // [WHEN] The Payment Journal Line is exported
      GenJnlLine.SETRANGE("Document No.",GenJnlLine."Document No.");
      GenJnlLine.SETRANGE("Document Type",GenJnlLine."Document Type");
      TempBlob.INIT;
      TempBlob.Blob.CREATEOUTSTREAM(OutStr);
      XMLPORT.EXPORT(BankAccount.GetPaymentExportXMLPortID,OutStr,GenJnlLine);

      // [THEN] The exported file contains an ustrd tag with all 140 characters
      LibraryXPathXMLReader.InitializeWithBlob(TempBlob,NamespaceTxt);
      LibraryXPathXMLReader.GetNodeList('//Ustrd',NodeList);

      ContainsReqCharacters := FALSE;
      FOR i := 1 TO NodeList.Count DO
        IF GenJnlLine."Message to Recipient" = NodeList.Item(i - 1).InnerText THEN
          ContainsReqCharacters := TRUE;

      Assert.IsTrue(ContainsReqCharacters,MessageToRecipientNotFoundErr);
Member of Lib.Library - XPath XML Reader


GetNodeListByElementName@7 Method

The procedure GetNodeListByElementName is available in codeunit 131337.

Syntax

GetNodeListByElementName@7(
    ElementName@1000 : Text ElementName, //Input parameter of type Text
    VAR NodeList@1001 : DotNet "'System.Xml NodeList, //Reference parameter of type DotNet
     Version=4.0.0.0  //param element not supplied
     Culture=neutral  //param element not supplied
     PublicKeyToken=b77a5c561934e089'.System.Xml.XmlNodeList"  //param element not supplied
);

Parameters

ElementName
Input parameter of type Text
NodeList
Reference parameter of type DotNet

Return Value

Integer

Remarks

The relevant search keywords are: Get, Node, List, By, Element, Name.

For a clarification about how this function works, refer to the code listed below.

      GetNodeList(ElementName,NodeList);
      IF NodeList.Count = 0 THEN
        Assert.Fail('Element is missing! ' + ElementName);
      EXIT(NodeList.Count);

Example

There are no examples available.
Member of Lib.Library - XPath XML Reader


GetNodeListInCurrNode@26 Method

The procedure GetNodeListInCurrNode is available in codeunit 131337.

Syntax

GetNodeListInCurrNode@26(
    CurrNode@1000 : DotNet "'System.Xml CurrNode, //Input parameter of type DotNet
     Version=4.0.0.0 xPath, //Input parameter of type Text
     Culture=neutral nodeList, //Reference parameter of type DotNet
     PublicKeyToken=b77a5c561934e089'.System.Xml.XmlNode"  //param element not supplied
    xPath@1001 : Text  //param element not supplied
    VAR nodeList@1002 : DotNet "'System.Xml  //param element not supplied
     Version=4.0.0.0  //param element not supplied
     Culture=neutral  //param element not supplied
     PublicKeyToken=b77a5c561934e089'.System.Xml.XmlNodeList"  //param element not supplied
);

Parameters

CurrNode
Input parameter of type DotNet
xPath
Input parameter of type Text
nodeList
Reference parameter of type DotNet

Remarks

The relevant search keywords are: Get, Node, List, In, Currency, Node.

For a clarification about how this function works, refer to the code listed below.

      IF SkipDefaultNamespace THEN
        nodeList := CurrNode.SelectNodes(xPath,XMLNsMgr)
      ELSE
        nodeList := CurrNode.SelectNodes(Replace(xPath,'/','/ns:'),XMLNsMgr);

Example

There are no examples available.
Member of Lib.Library - XPath XML Reader


Initialize@1 Method

The procedure Initialize is available in codeunit 131337.

Syntax

Initialize@1(
    FullFilePath@1000 : Text FullFilePath, //Input parameter of type Text
    NameSpace@1001 : Text NameSpace //Input parameter of type Text
);

Parameters

FullFilePath
Input parameter of type Text
NameSpace
Input parameter of type Text

Remarks

The relevant search keywords are: Initialize.

For a clarification about how this function works, refer to the code listed below.

      XMLDOMManagement.LoadXMLDocumentFromFile(FullFilePath,XMLDocOut);

      XMLNsMgr := XMLNsMgr.XmlNamespaceManager(XMLDocOut.NameTable);
      XMLNsMgr.AddNamespace('ns',NameSpace);

Example

The below example is extracted from the test automation codeunit 134412 to show one way of using this function.

      DataExch.SETRANGE("Data Exch. Def Code",DataExchDef.Code);
      DataExch.FINDLAST;
      DataExch.CALCFIELDS("File Content");

      LibraryXPathXMLReader.Initialize(DataExch."File Name",BankDataConvServMgt.GetNamespace);

      GenJournalLine.FINDSET;
      REPEAT
        LineNo += 1;
        BankAccount.GET(GenJournalLine."Bal. Account No.");
        PaymentMethod.GET(GenJournalLine."Payment Method Code");

        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex('/paymentExportBank/amcpaymentreq/banktransjournal/bankagreementlevel1',
          BankAccount."Creditor No.",0);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex('/paymentExportBank/amcpaymentreq/banktransjournal/bankagreementlevel2',
          BankAccount."Transit No.",0);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex('/paymentExportBank/amcpaymentreq/banktransjournal/journalname',
          GenJournalLine."Journal Template Name",0);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex('/paymentExportBank/amcpaymentreq/banktransjournal/journalnumber',
          GenJournalLine."Journal Batch Name",0);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex('/paymentExportBank/bank',
          BankAccount."Bank Name - Data Conversion",0);

        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/bankaccountident/bankaccount',
          BankAccount.GetBankAccountNo,LineNo - 1);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/bankaccountident/intregno',
          BankAccount."Bank Clearing Code",LineNo - 1);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/bankaccountident/intregnotype',
          BankAccount."Bank Clearing Standard",LineNo - 1);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/bankaccountident/swiftcode',
          BankAccount."SWIFT Code",LineNo - 1);

        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/bankaccountident/bankaccountaddress/address1',
          BankAccount.Address,LineNo - 1);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/bankaccountident/bankaccountaddress/city',
          BankAccount.City,LineNo - 1);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/bankaccountident/bankaccountaddress/name',
          BankAccount.Name,LineNo - 1);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/bankaccountident/bankaccountaddress/countryiso',
          BankAccount."Country/Region Code",LineNo - 1);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/bankaccountident/bankaccountaddress/zipcode',
          BankAccount."Post Code",LineNo - 1);

        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/bankaccountcurrency',
          GeneralLedgerSetup.GetCurrencyCode(BankAccount."Currency Code"),LineNo - 1);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/countryoforigin',
          BankAccount."Country/Region Code",0);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/messagetoownbank',
          GenJournalLine."Document No.",LineNo - 1);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/ownreference',
          GenJournalLine."Document No.",LineNo - 1);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/banktransthem/shortadvice',
          GenJournalLine."Applies-to Ext. Doc. No.",LineNo - 1);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/banktransthem/customerid',
          GenJournalLine."Account No.",LineNo - 1);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/banktransthem/costs',
          'Shared',LineNo - 1);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/banktransthem/paymenttype',
          PaymentMethod."Bank Data Conversion Pmt. Type",LineNo - 1);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/banktransthem/reference',
          GenJournalLine."Payment Reference",LineNo - 1);

        Amount := GenJournalLine.Amount; // to avoid DecimalPaces property affects the FORMAT
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/banktransthem/amountdetails/payamount',
          FORMAT(Amount,0,9),LineNo - 1);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/banktransthem/amountdetails/paycurrency',
          GeneralLedgerSetup.GetCurrencyCode(GenJournalLine."Currency Code"),LineNo - 1);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/banktransthem/amountdetails/paydate',
          FORMAT(CREATEDATETIME(GenJournalLine."Posting Date",010000T),0,9),LineNo - 1);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/banktransthem/messagestructure',
          'manual',LineNo - 1);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/ownaddressinfo',
          'frombank',LineNo - 1);

        CASE GenJournalLine."Account Type" OF
          GenJournalLine."Account Type"::Vendor:
            VerifyVendorDetails(GenJournalLine,LineNo);
          GenJournalLine."Account Type"::Customer:
            VerifyCustomerDetails(GenJournalLine,LineNo);
        END;

      UNTIL GenJournalLine.NEXT = 0;
Member of Lib.Library - XPath XML Reader


InitializeWithBlob@13 Method

The procedure InitializeWithBlob is available in codeunit 131337.

Syntax

InitializeWithBlob@13(
    TempBlob@1000 : Record 99008535 TempBlob, //Input parameter of type Record
    NameSpace@1001 : Text NameSpace //Input parameter of type Text
);

Parameters

TempBlob
Input parameter of type Record
NameSpace
Input parameter of type Text

Remarks

The relevant search keywords are: Initialize, Blob.

For a clarification about how this function works, refer to the code listed below.

      TempBlob.Blob.CREATEINSTREAM(InStream);
      XMLDOMManagement.LoadXMLDocumentFromInStream(InStream,XMLDocOut);

      XMLNsMgr := XMLNsMgr.XmlNamespaceManager(XMLDocOut.NameTable);
      XMLNsMgr.AddNamespace('ns',NameSpace);

Example

The below example is extracted from the test automation codeunit 134403 to show one way of using this function.

      // [SCENARIO 109389] Message to recipient is stored in the exported file
      Init;
      RequiredMessageLength := 140;

      // [GIVEN] A Payment Journal Line
      // [GIVEN] bal. bank account using the SEPA CT export format
      CreateGenJnlLine(GenJnlLine);

      // [GIVEN] 140 characters in "Message to recipient"
      GenJnlLine.VALIDATE("Message to Recipient",LibraryUtility.GenerateRandomXMLText(RequiredMessageLength));
      GenJnlLine.MODIFY(TRUE);
      Assert.AreEqual(RequiredMessageLength,STRLEN(GenJnlLine."Message to Recipient"),InvalidLengthErr);

      // [WHEN] The Payment Journal Line is exported
      GenJnlLine.SETRANGE("Document No.",GenJnlLine."Document No.");
      GenJnlLine.SETRANGE("Document Type",GenJnlLine."Document Type");
      TempBlob.INIT;
      TempBlob.Blob.CREATEOUTSTREAM(OutStr);
      XMLPORT.EXPORT(BankAccount.GetPaymentExportXMLPortID,OutStr,GenJnlLine);

      // [THEN] The exported file contains an ustrd tag with all 140 characters
      LibraryXPathXMLReader.InitializeWithBlob(TempBlob,NamespaceTxt);
      LibraryXPathXMLReader.GetNodeList('//Ustrd',NodeList);

      ContainsReqCharacters := FALSE;
      FOR i := 1 TO NodeList.Count DO
        IF GenJnlLine."Message to Recipient" = NodeList.Item(i - 1).InnerText THEN
          ContainsReqCharacters := TRUE;

      Assert.IsTrue(ContainsReqCharacters,MessageToRecipientNotFoundErr);
Member of Lib.Library - XPath XML Reader


InitializeWithPrefix@40 Method

The procedure InitializeWithPrefix is available in codeunit 131337.

Syntax

InitializeWithPrefix@40(
    FullFilePath@1000 : Text FullFilePath, //Input parameter of type Text
    Prefix@1001 : Text Prefix, //Input parameter of type Text
    NameSpace@1002 : Text NameSpace //Input parameter of type Text
);

Parameters

FullFilePath
Input parameter of type Text
Prefix
Input parameter of type Text
NameSpace
Input parameter of type Text

Remarks

The relevant search keywords are: Initialize, Prefix.

For a clarification about how this function works, refer to the code listed below.

      XMLDOMManagement.LoadXMLDocumentFromFile(FullFilePath,XMLDocOut);

      XMLNsMgr := XMLNsMgr.XmlNamespaceManager(XMLDocOut.NameTable);
      XMLNsMgr.AddNamespace(Prefix,NameSpace);

Example

There are no examples available.
Member of Lib.Library - XPath XML Reader


InitializeWithText@20 Method

The procedure InitializeWithText is available in codeunit 131337.

Syntax

InitializeWithText@20(
    Content@1000 : Text Content, //Input parameter of type Text
    NameSpace@1001 : Text NameSpace //Input parameter of type Text
);

Parameters

Content
Input parameter of type Text
NameSpace
Input parameter of type Text

Remarks

The relevant search keywords are: Initialize, Text.

For a clarification about how this function works, refer to the code listed below.

      XMLDOMManagement.LoadXMLNodeFromText(Content,XmlDocumentNode);
      XMLDocOut := XmlDocumentNode.OwnerDocument;

      XMLNsMgr := XMLNsMgr.XmlNamespaceManager(XMLDocOut.NameTable);
      XMLNsMgr.AddNamespace('ns',NameSpace);

Example

There are no examples available.
Member of Lib.Library - XPath XML Reader


SetDefaultNamespaceUsage@21 Method

The procedure SetDefaultNamespaceUsage is available in codeunit 131337.

Syntax

SetDefaultNamespaceUsage@21(
    UseDefaultNamespace@1000 : Boolean UseDefaultNamespace //Input parameter of type Boolean
);

Parameters

UseDefaultNamespace
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, Default, Namespace, Usage.

For a clarification about how this function works, refer to the code listed below.

      SkipDefaultNamespace := NOT UseDefaultNamespace;

Example

The below example is extracted from the test automation codeunit 134761 to show one way of using this function.

      LibraryXPathXMLReader.SetDefaultNamespaceUsage(TRUE);
      LibraryXPathXMLReader.Initialize(OutputPath,'');
      XMLPath :=
        '//ReportDataSet/DataItems/DataItem/DataItems/DataItem/DataItems/DataItem[2]/DataItems/DataItem/Columns/Column';
      LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(XMLPath,FORMAT(VerifyAmount),ColumnNo);
Member of Lib.Library - XPath XML Reader


VerifyAttributeAbsence@5 Method

The procedure VerifyAttributeAbsence is available in codeunit 131337.

Syntax

VerifyAttributeAbsence@5(
    ElementName@1000 : Text ElementName, //Input parameter of type Text
    AttributeName@1001 : Text AttributeName //Input parameter of type Text
);

Parameters

ElementName
Input parameter of type Text
AttributeName
Input parameter of type Text

Remarks

The relevant search keywords are: Verify, Attribute, Absence.

For a clarification about how this function works, refer to the code listed below.

      ASSERTERROR GetAttributeFromElement(ElementName,AttributeName,Attribute);
      Assert.ExpectedError('Attribute is missing!');

Example

There are no examples available.
Member of Lib.Library - XPath XML Reader


VerifyAttributeAbsenceFromNode@18 Method

The procedure VerifyAttributeAbsenceFromNode is available in codeunit 131337.

Syntax

VerifyAttributeAbsenceFromNode@18(
    Node@1000 : DotNet "'System.Xml Node, //Input parameter of type DotNet
     Version=4.0.0.0 AttributeName, //Input parameter of type Text
     Culture=neutral  //param element not supplied
     PublicKeyToken=b77a5c561934e089'.System.Xml.XmlNode"  //param element not supplied
    AttributeName@1001 : Text  //param element not supplied
);

Parameters

Node
Input parameter of type DotNet
AttributeName
Input parameter of type Text

Remarks

The relevant search keywords are: Verify, Attribute, Absence, From, Node.

For a clarification about how this function works, refer to the code listed below.

      Attribute := Node.Attributes.GetNamedItem(AttributeName);
      Assert.IsTrue(ISNULL(Attribute),STRSUBSTNO(UnexpectedAttributeErr,AttributeName,Node.Name));

Example

There are no examples available.
Member of Lib.Library - XPath XML Reader


VerifyAttributeFromNode@17 Method

The procedure VerifyAttributeFromNode is available in codeunit 131337.

Syntax

VerifyAttributeFromNode@17(
    Node@1000 : DotNet "'System.Xml Node, //Input parameter of type DotNet
     Version=4.0.0.0 AttributeName, //Input parameter of type Text
     Culture=neutral AttributeExpectedValue, //Input parameter of type Text
     PublicKeyToken=b77a5c561934e089'.System.Xml.XmlNode"  //param element not supplied
    AttributeName@1001 : Text  //param element not supplied
    AttributeExpectedValue@1002 : Text  //param element not supplied
);

Parameters

Node
Input parameter of type DotNet
AttributeName
Input parameter of type Text
AttributeExpectedValue
Input parameter of type Text

Remarks

The relevant search keywords are: Verify, Attribute, From, Node.

For a clarification about how this function works, refer to the code listed below.

      Actual := GetAttributeValueFromNode(Node,AttributeName);
      Assert.AreEqual(AttributeExpectedValue,Actual,STRSUBSTNO(UnexpectedAttributeValueErr,AttributeName));

Example

There are no examples available.
Member of Lib.Library - XPath XML Reader


VerifyAttributeValue@6 Method

The procedure VerifyAttributeValue is available in codeunit 131337.

Syntax

VerifyAttributeValue@6(
    ElementName@1000 : Text ElementName, //Input parameter of type Text
    AttributeName@1001 : Text AttributeName, //Input parameter of type Text
    Expected@1002 : Text Expected //Input parameter of type Text
);

Parameters

ElementName
Input parameter of type Text
AttributeName
Input parameter of type Text
Expected
Input parameter of type Text

Remarks

The relevant search keywords are: Verify, Attribute, Value.

For a clarification about how this function works, refer to the code listed below.

      GetAttributeFromElement(ElementName,AttributeName,Attribute);
      Actual := Attribute.Value;
      Assert.AreEqual(Expected,Actual,
        STRSUBSTNO('Unexpected value in xml file for Attribute <%1>',AttributeName));

Example

There are no examples available.
Member of Lib.Library - XPath XML Reader


VerifyNodeAbsence@3 Method

The procedure VerifyNodeAbsence is available in codeunit 131337.

Syntax

VerifyNodeAbsence@3(
    ElementName@1000 : Text ElementName //Input parameter of type Text
);

Parameters

ElementName
Input parameter of type Text

Remarks

The relevant search keywords are: Verify, Node, Absence.

For a clarification about how this function works, refer to the code listed below.

      ASSERTERROR GetNodeByElementName(ElementName,Node);
      Assert.ExpectedError('Element is missing!');

Example

There are no examples available.
Member of Lib.Library - XPath XML Reader


VerifyNodeCountByXPath@23 Method

The procedure VerifyNodeCountByXPath is available in codeunit 131337.

Syntax

VerifyNodeCountByXPath@23(
    xPath@1000 : Text xPath, //Input parameter of type Text
    NodeCount@1001 : Integer NodeCount //Input parameter of type Integer
);

Parameters

xPath
Input parameter of type Text
NodeCount
Input parameter of type Integer

Remarks

The relevant search keywords are: Verify, Node, Count, By, X, Path.

For a clarification about how this function works, refer to the code listed below.

      GetNodeList(xPath,NodeList);
      Assert.AreEqual(NodeCount,NodeList.Count,STRSUBSTNO(NodeCountErr,xPath));

Example

There are no examples available.
Member of Lib.Library - XPath XML Reader


VerifyNodeCountWithValueByXPath@15 Method

The procedure VerifyNodeCountWithValueByXPath is available in codeunit 131337.

Syntax

VerifyNodeCountWithValueByXPath@15(
    xPath@1000 : Text xPath, //Input parameter of type Text
    Value@1001 : Text Value, //Input parameter of type Text
    NodeCount@1002 : Integer NodeCount //Input parameter of type Integer
);

Parameters

xPath
Input parameter of type Text
Value
Input parameter of type Text
NodeCount
Input parameter of type Integer

Remarks

The relevant search keywords are: Verify, Node, Count, Value, By, X, Path.

For a clarification about how this function works, refer to the code listed below.

      GetNodeList(xPath,NodeList);
      ActualNodeCount := 0;
      FOR i := 0 TO NodeList.Count - 1 DO
        IF NodeList.Item(i).InnerText = Value THEN
          ActualNodeCount += 1;
      Assert.AreEqual(NodeCount,ActualNodeCount,STRSUBSTNO(NodeCountWithValueErr,Value,xPath));

Example

There are no examples available.
Member of Lib.Library - XPath XML Reader


VerifyNodeValue@4 Method

The procedure VerifyNodeValue is available in codeunit 131337.

Syntax

VerifyNodeValue@4(
    ElementName@1000 : Text ElementName, //Input parameter of type Text
    Expected@1001 : Text Expected //Input parameter of type Text
);

Parameters

ElementName
Input parameter of type Text
Expected
Input parameter of type Text

Remarks

The relevant search keywords are: Verify, Node, Value.

For a clarification about how this function works, refer to the code listed below.

      GetNodeByElementName(ElementName,XMLNode);
      Actual := XMLNode.InnerText;
      Assert.AreEqual(Expected,Actual,
        STRSUBSTNO('Unexpected value in xml file for element <%1>',ElementName));

Example

There are no examples available.
Member of Lib.Library - XPath XML Reader


VerifyNodeValueByXPath@16 Method

The procedure VerifyNodeValueByXPath is available in codeunit 131337.

Syntax

VerifyNodeValueByXPath@16(
    xPath@1000 : Text xPath, //Input parameter of type Text
    NodeValue@1001 : Text NodeValue //Input parameter of type Text
);

Parameters

xPath
Input parameter of type Text
NodeValue
Input parameter of type Text

Remarks

The relevant search keywords are: Verify, Node, Value, By, X, Path.

For a clarification about how this function works, refer to the code listed below.

      VerifyNodeValueByXPathWithIndex(xPath,NodeValue,0);

Example

There are no examples available.
Member of Lib.Library - XPath XML Reader


VerifyNodeValueByXPathWithIndex@19 Method

The procedure VerifyNodeValueByXPathWithIndex is available in codeunit 131337.

Syntax

VerifyNodeValueByXPathWithIndex@19(
    xPath@1000 : Text xPath, //Input parameter of type Text
    NodeValue@1001 : Text NodeValue, //Input parameter of type Text
    Index@1006 : Integer Index //Input parameter of type Integer
);

Parameters

xPath
Input parameter of type Text
NodeValue
Input parameter of type Text
Index
Input parameter of type Integer

Remarks

The relevant search keywords are: Verify, Node, Value, By, X, Path, Index.

For a clarification about how this function works, refer to the code listed below.

      GetNodeList(xPath,NodeList);
      NodeCount := NodeList.Count;
      Assert.AreNotEqual(0,NodeCount,STRSUBSTNO(NodeNotFoundErr,xPath));
      Node := NodeList.Item(Index);
      ActualNodeValue := Node.InnerText;
      Assert.AreEqual(NodeValue,ActualNodeValue,STRSUBSTNO(UnexpectedNodeValueErr,xPath,NodeValue,ActualNodeValue));

Example

The below example is extracted from the test automation codeunit 134412 to show one way of using this function.

      DataExch.SETRANGE("Data Exch. Def Code",DataExchDef.Code);
      DataExch.FINDLAST;
      DataExch.CALCFIELDS("File Content");

      LibraryXPathXMLReader.Initialize(DataExch."File Name",BankDataConvServMgt.GetNamespace);

      GenJournalLine.FINDSET;
      REPEAT
        LineNo += 1;
        BankAccount.GET(GenJournalLine."Bal. Account No.");
        PaymentMethod.GET(GenJournalLine."Payment Method Code");

        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex('/paymentExportBank/amcpaymentreq/banktransjournal/bankagreementlevel1',
          BankAccount."Creditor No.",0);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex('/paymentExportBank/amcpaymentreq/banktransjournal/bankagreementlevel2',
          BankAccount."Transit No.",0);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex('/paymentExportBank/amcpaymentreq/banktransjournal/journalname',
          GenJournalLine."Journal Template Name",0);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex('/paymentExportBank/amcpaymentreq/banktransjournal/journalnumber',
          GenJournalLine."Journal Batch Name",0);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex('/paymentExportBank/bank',
          BankAccount."Bank Name - Data Conversion",0);

        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/bankaccountident/bankaccount',
          BankAccount.GetBankAccountNo,LineNo - 1);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/bankaccountident/intregno',
          BankAccount."Bank Clearing Code",LineNo - 1);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/bankaccountident/intregnotype',
          BankAccount."Bank Clearing Standard",LineNo - 1);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/bankaccountident/swiftcode',
          BankAccount."SWIFT Code",LineNo - 1);

        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/bankaccountident/bankaccountaddress/address1',
          BankAccount.Address,LineNo - 1);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/bankaccountident/bankaccountaddress/city',
          BankAccount.City,LineNo - 1);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/bankaccountident/bankaccountaddress/name',
          BankAccount.Name,LineNo - 1);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/bankaccountident/bankaccountaddress/countryiso',
          BankAccount."Country/Region Code",LineNo - 1);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/bankaccountident/bankaccountaddress/zipcode',
          BankAccount."Post Code",LineNo - 1);

        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/bankaccountcurrency',
          GeneralLedgerSetup.GetCurrencyCode(BankAccount."Currency Code"),LineNo - 1);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/countryoforigin',
          BankAccount."Country/Region Code",0);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/messagetoownbank',
          GenJournalLine."Document No.",LineNo - 1);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/ownreference',
          GenJournalLine."Document No.",LineNo - 1);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/banktransthem/shortadvice',
          GenJournalLine."Applies-to Ext. Doc. No.",LineNo - 1);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/banktransthem/customerid',
          GenJournalLine."Account No.",LineNo - 1);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/banktransthem/costs',
          'Shared',LineNo - 1);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/banktransthem/paymenttype',
          PaymentMethod."Bank Data Conversion Pmt. Type",LineNo - 1);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/banktransthem/reference',
          GenJournalLine."Payment Reference",LineNo - 1);

        Amount := GenJournalLine.Amount; // to avoid DecimalPaces property affects the FORMAT
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/banktransthem/amountdetails/payamount',
          FORMAT(Amount,0,9),LineNo - 1);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/banktransthem/amountdetails/paycurrency',
          GeneralLedgerSetup.GetCurrencyCode(GenJournalLine."Currency Code"),LineNo - 1);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/banktransthem/amountdetails/paydate',
          FORMAT(CREATEDATETIME(GenJournalLine."Posting Date",010000T),0,9),LineNo - 1);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/banktransthem/messagestructure',
          'manual',LineNo - 1);
        LibraryXPathXMLReader.VerifyNodeValueByXPathWithIndex(
          '/paymentExportBank/amcpaymentreq/banktransjournal/banktransus/ownaddressinfo',
          'frombank',LineNo - 1);

        CASE GenJournalLine."Account Type" OF
          GenJournalLine."Account Type"::Vendor:
            VerifyVendorDetails(GenJournalLine,LineNo);
          GenJournalLine."Account Type"::Customer:
            VerifyCustomerDetails(GenJournalLine,LineNo);
        END;

      UNTIL GenJournalLine.NEXT = 0;
Member of Lib.Library - XPath XML Reader


VerifyOptionalAttributeFromNode@33 Method

The procedure VerifyOptionalAttributeFromNode is available in codeunit 131337.

Syntax

VerifyOptionalAttributeFromNode@33(
    Node@1000 : DotNet "'System.Xml Node, //Input parameter of type DotNet
     Version=4.0.0.0 AttributeName, //Input parameter of type Text
     Culture=neutral AttributeExpectedValue, //Input parameter of type Text
     PublicKeyToken=b77a5c561934e089'.System.Xml.XmlNode"  //param element not supplied
    AttributeName@1001 : Text  //param element not supplied
    AttributeExpectedValue@1002 : Text  //param element not supplied
);

Parameters

Node
Input parameter of type DotNet
AttributeName
Input parameter of type Text
AttributeExpectedValue
Input parameter of type Text

Remarks

The relevant search keywords are: Verify, Optional, Attribute, From, Node.

For a clarification about how this function works, refer to the code listed below.

      IF EVALUATE(AttributeValueDecimal,AttributeExpectedValue) THEN
        IsNumber := TRUE;

      IF (IsNumber AND (AttributeValueDecimal = 0)) OR (AttributeExpectedValue = '') THEN
        VerifyAttributeAbsenceFromNode(Node,AttributeName)
      ELSE BEGIN
        AttributeActualValue := GetAttributeValueFromNode(Node,AttributeName);
        Assert.AreEqual(AttributeExpectedValue,AttributeActualValue,STRSUBSTNO(UnexpectedAttributeValueErr,AttributeName));
      END;

Example

There are no examples available.
Member of Lib.Library - XPath XML Reader


Library UT Utility Class

Lib.Library UT Utility

COD131008 applies to UT,RES,ERM,SCM,W1,All.

Methods

Name | Description
Clear@1 | The procedure Clear is available in codeunit 131008.
GetNewCode@1001 | The procedure GetNewCode is available in codeunit 131008.
GetNewCode10@1003 | The procedure GetNewCode10 is available in codeunit 131008.

See Also

Lib


Clear@1 Method

The procedure Clear is available in codeunit 131008.

Syntax

Clear@1(
      //param element not supplied
);

Remarks

The relevant search keywords are: Clear.

For a clarification about how this function works, refer to the code listed below.

      Str := '';
      Str2 := '';

Example

The below example is extracted from the test automation codeunit 134922 to show one way of using this function.

      ItemBudgetName.DELETEALL;
      ItemNo := LibraryInventory.CreateItem(Item);
      LibraryVariableStorage.Clear;
      LibraryVariableStorage.Enqueue(ItemNo);
      CreateItemBudgetName(ItemBudgetName,ItemNo,BudgetAmounts[1],AnalysisArea);
      CreateItemBudgetName(ItemBudgetName,ItemNo,BudgetAmounts[2],AnalysisArea);
Member of Lib.Library UT Utility


GetNewCode@1001 Method

The procedure GetNewCode is available in codeunit 131008.

Syntax

GetNewCode@1001(
      //param element not supplied
);

Return Value

Code[20]

Remarks

The relevant search keywords are: Get, New, Code.

For a clarification about how this function works, refer to the code listed below.

      IF Str = '' THEN
        Str := 'XX000';
      Str := INCSTR(Str);
      EXIT(FORMAT(TIME) + Str);

Example

The below example is extracted from the test automation codeunit 134987 to show one way of using this function.

      // [FEATURE] [Report] [Vendor Pre-Payment Journal] [Customer]
      // [SCENARIO 359950.1] Payment Journal - Pre-Check Report shows payment discount correctly when printing invoice and credit memo.
      Initialize;

      CustomerNo := LibrarySales.CreateCustomerNo;
      AppliesToID := LibraryUTUtility.GetNewCode;
      // [GIVEN] Invoice with amount X and payment discount P less then X
      CreateCustLedgerEntryWithSpecificAmountAndAppliesToID(
        CustLedgerEntry,CustLedgerEntry."Document Type"::Invoice,CustomerNo,LibraryRandom.RandDec(100,2),AppliesToID);
      PmtDiscPossible := ROUND(CustLedgerEntry."Amount (LCY)" / LibraryRandom.RandIntInRange(3,5));
      UpdateCustLedgEntryWithPmtDisc(CustLedgerEntry,PmtDiscPossible);

      // [GIVEN] Credit memo with amount Y less then X
      // [GIVEN] Payment with amount Z less then (X - Y - P)
      CalcEntriesAmount(EntryAmount,CustLedgerEntry."Amount (LCY)",CustLedgerEntry."Remaining Pmt. Disc. Possible");
      CreateCustLedgerEntryWithSpecificAmountAndAppliesToID(
        CustLedgerEntry,CustLedgerEntry."Document Type"::"Credit Memo",
        CustomerNo,EntryAmount[EntryType::"Credit Memo"],AppliesToID);
      CreateGenJournalLineWithAppliesToID(
        GenJournalLine,GenJournalLine."Account Type"::Customer,CustomerNo,EntryAmount[EntryType::Payment],AppliesToID);

      // [WHEN] Run Payment PreCheck report on both invoice with pmt. discount and credit memo
      RunVendorPrePaymentJournal(GenJournalLine);

      // [THEN] Payment discount P is not show in report as separate amount (unapplied amount) but include to invoice amount
      VerifyInvAndPmtDiscInPreCheckReport(
        AmountToApplyDiscTolSalesTxt,-(EntryAmount[EntryType::Invoice] - PmtDiscPossible),PmtDiscPossible);
Member of Lib.Library UT Utility


GetNewCode10@1003 Method

The procedure GetNewCode10 is available in codeunit 131008.

Syntax

GetNewCode10@1003(
      //param element not supplied
);

Return Value

Code[10]

Remarks

The relevant search keywords are: Get, New, Code10.

For a clarification about how this function works, refer to the code listed below.

      IF Str2 = '' THEN
        Str2 := 'X000';
      Str2 := INCSTR(Str2);
      EXIT(COPYSTR(FORMAT(TIME,0,'<Standard Format,2>'),1,6) + Str2);

Example

The below example is extracted from the test automation codeunit 134922 to show one way of using this function.

      // [FEATURE] [UT] [Analysis View]
      // [SCENARIO 206551] Related Item Analysis View Budg. Entry should be deleted when Item Budget Entry is deleted
      Initialize;

      ItemBudgetName."Analysis Area" := ItemBudgetName."Analysis Area"::Sales;
      ItemBudgetName.Name := LibraryUTUtility.GetNewCode10;
      ItemBudgetName.INSERT;

      ItemBudgetEntry."Entry No." := LibraryUtility.GetNewRecNo(ItemBudgetEntry,ItemBudgetEntry.FIELDNO("Entry No."));
      ItemBudgetEntry."Analysis Area" := ItemBudgetName."Analysis Area";
      ItemBudgetEntry."Budget Name" := ItemBudgetName.Name;
      ItemBudgetEntry.INSERT;

      ItemAnalysisViewBudgEntry.INIT;
      ItemAnalysisViewBudgEntry."Analysis Area" := ItemBudgetEntry."Analysis Area";
      ItemAnalysisViewBudgEntry."Budget Name" := ItemBudgetName.Name;
      ItemAnalysisViewBudgEntry."Entry No." := ItemBudgetEntry."Entry No.";
      ItemAnalysisViewBudgEntry.INSERT;

      ItemBudgetEntry.DELETE(TRUE);

      ItemAnalysisViewBudgEntry.SETRANGE("Entry No.",ItemBudgetEntry."Entry No.");
      Assert.RecordIsEmpty(ItemAnalysisViewBudgEntry);
Member of Lib.Library UT Utility


Miscellaneous Namespace

Miscellaneous

Classes

Class Description
Library - Tables UT

COD131923 applies to ERM,W1,All.
Library - TDS

COD143000 applies to ERM,IN.
Library - Service Tax

COD143001 applies to ERM,IN.
Service Tax FCY Helper

COD143002 applies to ERM,IN.
Service Tax As Excise Helper

COD143003 applies to ERM,IN.
Service Tax Verify

COD143004 applies to ERM,IN.
Service Tax With TDS Helper

COD143005 applies to ERM,IN.
Reverse Service Tax Helper

COD143006 applies to ERM,IN.
Service Tax Report Helper

COD143007 applies to ERM,IN.


Library - Service Tax Class

Miscellaneous.Library - Service Tax

COD143001 applies to ERM,IN.

Methods

Name | Description
CreateGLAccountWithPrefix@14 | The procedure CreateGLAccountWithPrefix is available in codeunit 143001.
CreateServiceEntityType@1500005 | The procedure CreateServiceEntityType is available in codeunit 143001.
CreateServiceTaxGroup@1500003 | The procedure CreateServiceTaxGroup is available in codeunit 143001.
CreateServiceTaxRegistrationNo@1500006 | The procedure CreateServiceTaxRegistrationNo is available in codeunit 143001.
CreateServiceTaxReturnPeriod@1500000 | The procedure CreateServiceTaxReturnPeriod is available in codeunit 143001.
CreateServiceTaxSetup@1500009 | The procedure CreateServiceTaxSetup is available in codeunit 143001.
CreateServiceTaxStructure@1500002 | The procedure CreateServiceTaxStructure is available in codeunit 143001.
CreateSrvTaxReverseChargeSetup@1500004 | The procedure CreateSrvTaxReverseChargeSetup is available in codeunit 143001.
GetDateWithinIncomeTaxAcPeriod@11 | The procedure GetDateWithinIncomeTaxAcPeriod is available in codeunit 143001.
GetDateWithinSrvTaxPeriod@1500011 | The procedure GetDateWithinSrvTaxPeriod is available in codeunit 143001.
GetDeltaDateWithinSrvTaxPeriod@1500010 | The procedure GetDeltaDateWithinSrvTaxPeriod is available in codeunit 143001.
GetSrvTaxReturnPeriodEndDate@1500008 | The procedure GetSrvTaxReturnPeriodEndDate is available in codeunit 143001.
GetSrvTaxReturnPeriodStartDate@1500007 | The procedure GetSrvTaxReturnPeriodStartDate is available in codeunit 143001.
PayServiceTax@1500001 | The procedure PayServiceTax is available in codeunit 143001.
SetServiceTaxRounding@1500013 | The procedure SetServiceTaxRounding is available in codeunit 143001.
SetServiceTaxRoundingOne@1500014 | The procedure SetServiceTaxRoundingOne is available in codeunit 143001.
SetValuesForPaymentUseCreditAvailable@1500017 | The procedure SetValuesForPaymentUseCreditAvailable is available in codeunit 143001.

See Also

Miscellaneous


CreateGLAccountWithPrefix@14 Method

The procedure CreateGLAccountWithPrefix is available in codeunit 143001.

Syntax

CreateGLAccountWithPrefix@14(
    VAR GLAccount@1000 : Record 15 GLAccount, //Reference parameter of type Record
    Prefix@1500000 : Text[10] Prefix //Input parameter of type Text
);

Parameters

GLAccount
Reference parameter of type Record
Prefix
Input parameter of type Text

Remarks

The relevant search keywords are: Create, General Ledger, Account, Prefix.

For a clarification about how this function works, refer to the code listed below.

      GLAccount.INIT;
      RandomCode := LibraryUtility.GenerateRandomCode(GLAccount.FIELDNO("No."),DATABASE::"G/L Account");
      GLAccount.VALIDATE("No.",STRSUBSTNO('%1%2',Prefix,RandomCode));
      GLAccount.VALIDATE(Name,GLAccount."No.");
      GLAccount.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 144042 to show one way of using this function.

      ServiceTaxSetup.FindOnDate(ServiceTaxGroupCode,DocumentDate);
      LibraryServiceTax.CreateGLAccountWithPrefix(GLAccount,ServTaxRecDistAccountErr);
      ServiceTaxSetup.VALIDATE("S.T. Receivable Account (Dist)",GLAccount."No.");
      LibraryServiceTax.CreateGLAccountWithPrefix(GLAccount,ServTaxRecInterimDistAccountErr);
      ServiceTaxSetup.VALIDATE("Receivable Acc. Interim (Dist)",GLAccount."No.");
      ServiceTaxSetup.MODIFY(TRUE);
Member of Miscellaneous.Library - Service Tax


CreateServiceEntityType@1500005 Method

The procedure CreateServiceEntityType is available in codeunit 143001.

Syntax

CreateServiceEntityType@1500005(
    VAR ServiceEntityType@1500000 : Record 16460 ServiceEntityType //Reference parameter of type Record
);

Parameters

ServiceEntityType
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Service, Entity, Type.

For a clarification about how this function works, refer to the code listed below.

      ServiceEntityType.INIT;
      ServiceEntityType.VALIDATE(
        Code,LibraryUtility.GenerateRandomCode(ServiceEntityType.FIELDNO(Code),DATABASE::"Service Entity Type"));
      ServiceEntityType.VALIDATE(Description,ServiceEntityType.Code);
      ServiceEntityType.INSERT(TRUE);

Example

There are no examples available.
Member of Miscellaneous.Library - Service Tax


CreateServiceTaxGroup@1500003 Method

The procedure CreateServiceTaxGroup is available in codeunit 143001.

Syntax

CreateServiceTaxGroup@1500003(
    VAR ServiceTaxGroup@1500000 : Record 16471 ServiceTaxGroup //Reference parameter of type Record
);

Parameters

ServiceTaxGroup
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Service, Tax, Group.

For a clarification about how this function works, refer to the code listed below.

      ServiceTaxGroup.INIT;
      ServiceTaxGroup.VALIDATE(Code,LibraryUtility.GenerateRandomCode(ServiceTaxGroup.FIELDNO(Code),DATABASE::"Service Tax Groups"));
      ServiceTaxGroup.VALIDATE(Description,ServiceTaxGroup.Code);
      ServiceTaxGroup.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 144014 to show one way of using this function.

      IF IsInitialized THEN
        EXIT;
      LibraryServiceTax.CreateServiceTaxRegistrationNo(ServiceTaxRegistrationNos);
      LibraryServiceTax.CreateServiceTaxGroup(ServiceTaxGroups);
      LibraryServiceTax.CreateServiceTaxSetup(ServiceTaxGroups.Code,WORKDATE - 1);
      CreateTaxSetupAndStateAndLocations;
      GeneralLedgerSetup.GET;
      ServiceTaxSetup.GET(ServiceTaxGroups.Code,WORKDATE - 1);
      IsInitialized := TRUE;
      COMMIT;
Member of Miscellaneous.Library - Service Tax


CreateServiceTaxRegistrationNo@1500006 Method

The procedure CreateServiceTaxRegistrationNo is available in codeunit 143001.

Syntax

CreateServiceTaxRegistrationNo@1500006(
    VAR ServiceTaxRegistrationNo@1500000 : Record 16475 ServiceTaxRegistrationNo //Reference parameter of type Record
);

Parameters

ServiceTaxRegistrationNo
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Service, Tax, Registration, No.

For a clarification about how this function works, refer to the code listed below.

      CreateServiceEntityType(ServiceEntityType);

      ServiceTaxRegistrationNo.INIT;
      ServiceTaxRegistrationNo.VALIDATE(Code,
        LibraryUtility.GenerateRandomCode(ServiceTaxRegistrationNo.FIELDNO(Code),DATABASE::"Service Tax Registration Nos."));
      ServiceTaxRegistrationNo.VALIDATE(Description,ServiceTaxRegistrationNo.Code);
      ServiceTaxRegistrationNo.VALIDATE("Service Entity Type",ServiceEntityType.Code);
      ServiceTaxRegistrationNo.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 144014 to show one way of using this function.

      IF IsInitialized THEN
        EXIT;
      LibraryServiceTax.CreateServiceTaxRegistrationNo(ServiceTaxRegistrationNos);
      LibraryServiceTax.CreateServiceTaxGroup(ServiceTaxGroups);
      LibraryServiceTax.CreateServiceTaxSetup(ServiceTaxGroups.Code,WORKDATE - 1);
      CreateTaxSetupAndStateAndLocations;
      GeneralLedgerSetup.GET;
      ServiceTaxSetup.GET(ServiceTaxGroups.Code,WORKDATE - 1);
      IsInitialized := TRUE;
      COMMIT;
Member of Miscellaneous.Library - Service Tax


CreateServiceTaxReturnPeriod@1500000 Method

The procedure CreateServiceTaxReturnPeriod is available in codeunit 143001.

Syntax

CreateServiceTaxReturnPeriod@1500000(
      //param element not supplied
);

Remarks

The relevant search keywords are: Create, Service, Tax, Return, Period.

For a clarification about how this function works, refer to the code listed below.

      IF ServiceTaxReturnPeriod.FINDLAST THEN
        NewYear := ServiceTaxReturnPeriod.Year + 1
      ELSE
        NewYear := DATE2DMY(WORKDATE,3);

      WITH ServiceTaxReturnPeriod DO BEGIN
        INIT;
        VALIDATE(Year,NewYear);
        VALIDATE("Return Period","Return Period"::"Apr-Sep");
        VALIDATE("Return Filing Due Date",DMY2DATE(31,12,Year));
        INSERT(TRUE);
        CreatePeriodDueDates(Year,"Return Period")
      END;

Example

The below example is extracted from the test automation codeunit 144030 to show one way of using this function.

      LibraryRandom.SetSeed(1);

      IF isInitialized THEN
        EXIT;

      LibraryServiceTax.CreateServiceTaxReturnPeriod;
      ReverseServiceTaxHelper.SetupCompanyInfo;
      COMMIT;

      isInitialized := TRUE;
Member of Miscellaneous.Library - Service Tax


CreateServiceTaxSetup@1500009 Method

The procedure CreateServiceTaxSetup is available in codeunit 143001.

Syntax

CreateServiceTaxSetup@1500009(
    ServiceTaxGroupCode@1500000 : Code[20] ServiceTaxGroupCode, //Input parameter of type Code
    FromDate@1500002 : Date FromDate //Input parameter of type Date
);

Parameters

ServiceTaxGroupCode
Input parameter of type Code
FromDate
Input parameter of type Date

Remarks

The relevant search keywords are: Create, Service, Tax, Setup.

For a clarification about how this function works, refer to the code listed below.

      ServiceTaxSetup.INIT;
      ServiceTaxSetup.VALIDATE(Code,ServiceTaxGroupCode);
      ServiceTaxSetup.VALIDATE("From Date",FromDate);
      ServiceTaxSetup.VALIDATE("Service Tax %",LibraryRandom.RandIntInRange(5,20));
      ServiceTaxSetup.VALIDATE("SB Cess%",LibraryRandom.RandIntInRange(5,20));
      ServiceTaxSetup.VALIDATE("KK Cess%",LibraryRandom.RandIntInRange(5,20));
      ServiceTaxSetup.INSERT(TRUE);

      CreateGLAccountWithPrefix(GLAccount,ServTaxReceivablesAccount);
      ServiceTaxSetup.VALIDATE("Service Tax Receivable Account",GLAccount."No.");
      CreateGLAccountWithPrefix(GLAccount,ServTaxPayablesAccount);
      ServiceTaxSetup.VALIDATE("Service Tax Payable Account",GLAccount."No.");
      CreateGLAccountWithPrefix(GLAccount,ServTaxRecInterimAccount);
      ServiceTaxSetup.VALIDATE("Receivables Account (Interim)",GLAccount."No.");
      CreateGLAccountWithPrefix(GLAccount,ServTaxPayInterimAccount);
      ServiceTaxSetup.VALIDATE("Payables Account (Interim)",GLAccount."No.");
      CreateGLAccountWithPrefix(GLAccount,ServTaxExpensesAccount);
      ServiceTaxSetup.VALIDATE("Service Tax Expenses Account",GLAccount."No.");
      CreateGLAccountWithPrefix(GLAccount,SBCExpensesAccount);
      ServiceTaxSetup.VALIDATE("SB Cess Expense Account",GLAccount."No.");
      CreateGLAccountWithPrefix(GLAccount,SBCPayablesAccount);
      ServiceTaxSetup.VALIDATE("SB Cess Payable Account",GLAccount."No.");
      CreateGLAccountWithPrefix(GLAccount,SBCInterimAccount);
      ServiceTaxSetup.VALIDATE("SB Cess Acc.(Interim)",GLAccount."No.");
      CreateGLAccountWithPrefix(GLAccount,SBCPayInterimAccount);
      ServiceTaxSetup.VALIDATE("SB Cess Payable Acc.(Interim)",GLAccount."No.");
      CreateGLAccountWithPrefix(GLAccount,KKCReceivablesAccount);
      ServiceTaxSetup.VALIDATE("KK Cess Receivable Account",GLAccount."No.");
      CreateGLAccountWithPrefix(GLAccount,KKCPayablesAccount);
      ServiceTaxSetup.VALIDATE("KK Cess Payable Account",GLAccount."No.");
      CreateGLAccountWithPrefix(GLAccount,KKCRecInterimAccount);
      ServiceTaxSetup.VALIDATE("KK Cess Rec. Acc. (Interim)",GLAccount."No.");
      CreateGLAccountWithPrefix(GLAccount,KKCPayInterimAccount);
      ServiceTaxSetup.VALIDATE("KK Cess Payable Acc. (Interim)",GLAccount."No.");
      CreateGLAccountWithPrefix(GLAccount,KKCExpensesAccount);
      ServiceTaxSetup.VALIDATE("KK Cess Expense Account",GLAccount."No.");
      ServiceTaxSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 144014 to show one way of using this function.

      IF IsInitialized THEN
        EXIT;
      LibraryServiceTax.CreateServiceTaxRegistrationNo(ServiceTaxRegistrationNos);
      LibraryServiceTax.CreateServiceTaxGroup(ServiceTaxGroups);
      LibraryServiceTax.CreateServiceTaxSetup(ServiceTaxGroups.Code,WORKDATE - 1);
      CreateTaxSetupAndStateAndLocations;
      GeneralLedgerSetup.GET;
      ServiceTaxSetup.GET(ServiceTaxGroups.Code,WORKDATE - 1);
      IsInitialized := TRUE;
      COMMIT;
Member of Miscellaneous.Library - Service Tax


CreateServiceTaxStructure@1500002 Method

The procedure CreateServiceTaxStructure is available in codeunit 143001.

Syntax

CreateServiceTaxStructure@1500002(
    VAR StructureHeader@1500000 : Record 13792 StructureHeader //Reference parameter of type Record
);

Parameters

StructureHeader
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Service, Tax, Structure.

For a clarification about how this function works, refer to the code listed below.

      StructureHeader.INIT;
      StructureHeader.VALIDATE(Code,LibraryUtility.GenerateRandomCode(StructureHeader.FIELDNO(Code),DATABASE::"Structure Header"));
      StructureHeader.VALIDATE(Description,StructureHeader.Code);
      StructureHeader.INSERT(TRUE);

      StructureLines.INIT;
      StructureLines.VALIDATE(Code,StructureHeader.Code);
      StructureLines.VALIDATE(Type,StructureLines.Type::"Service Tax");
      StructureLines.VALIDATE("Header/Line",StructureLines."Header/Line"::Line);
      StructureLines.VALIDATE("Include Base",TRUE);
      StructureLines.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 144015 to show one way of using this function.

      LibraryServiceTax.CreateServiceTaxStructure(StructureHeader);
      LibraryServiceTax.CreateServiceTaxGroup(ServiceTaxGroups);
      LibraryServiceTax.CreateServiceTaxSetup(ServiceTaxGroups.Code,WORKDATE);
      LibraryServiceTax.CreateServiceTaxRegistrationNo(ServiceTaxRegistrationNos);
Member of Miscellaneous.Library - Service Tax


CreateSrvTaxReverseChargeSetup@1500004 Method

The procedure CreateSrvTaxReverseChargeSetup is available in codeunit 143001.

Syntax

CreateSrvTaxReverseChargeSetup@1500004(
    SrvTaxGroupCode@1500000 : Code[10] SrvTaxGroupCode, //Input parameter of type Code
    FromEntityType@1500001 : Code[10] FromEntityType, //Input parameter of type Code
    ToEntityType@1500002 : Code[10] ToEntityType, //Input parameter of type Code
    ServiceTaxType@1500003 : Option ServiceTaxType, //Input parameter of type Option
    ReverseChargePercentage@1500005 : Integer ReverseChargePercentage //Input parameter of type Integer
);

Parameters

SrvTaxGroupCode
Input parameter of type Code
FromEntityType
Input parameter of type Code
ToEntityType
Input parameter of type Code
ServiceTaxType
Input parameter of type Option
ReverseChargePercentage
Input parameter of type Integer

Remarks

The relevant search keywords are: Create, Srv, Tax, Reverse, Charge, Setup.

For a clarification about how this function works, refer to the code listed below.

      IF STReverseChargeSetup.GET(SrvTaxGroupCode,FromEntityType,ToEntityType) THEN
        EXIT;
      STReverseChargeSetup.INIT;
      STReverseChargeSetup.VALIDATE("Service Tax Group",SrvTaxGroupCode);
      STReverseChargeSetup.VALIDATE("From Service Entity Type",FromEntityType);
      STReverseChargeSetup.VALIDATE("To Service Entity Type",ToEntityType);
      STReverseChargeSetup.VALIDATE("Reverse Charge Tax Type",ServiceTaxType);
      STReverseChargeSetup.VALIDATE("Reverse Charge %",ReverseChargePercentage);
      STReverseChargeSetup.INSERT(TRUE);

Example

There are no examples available.
Member of Miscellaneous.Library - Service Tax


GetDateWithinIncomeTaxAcPeriod@11 Method

The procedure GetDateWithinIncomeTaxAcPeriod is available in codeunit 143001.

Syntax

GetDateWithinIncomeTaxAcPeriod@11(
    IncomeTaxAccPeriod@1500000 : Record 13724 IncomeTaxAccPeriod //Input parameter of type Record
);

Parameters

IncomeTaxAccPeriod
Input parameter of type Record

Return Value

Date

Remarks

The relevant search keywords are: Get, Datein, Income, Tax, Ac, Period.

For a clarification about how this function works, refer to the code listed below.

      EXIT(GetDateWithin(IncomeTaxAccPeriod."Starting Date",IncomeTaxAccPeriod."Ending Date"))

Example

There are no examples available.
Member of Miscellaneous.Library - Service Tax


GetDateWithinSrvTaxPeriod@1500011 Method

The procedure GetDateWithinSrvTaxPeriod is available in codeunit 143001.

Syntax

GetDateWithinSrvTaxPeriod@1500011(
    ServiceTaxReturnPeriod@1500000 : Record 16588 ServiceTaxReturnPeriod //Input parameter of type Record
);

Parameters

ServiceTaxReturnPeriod
Input parameter of type Record

Return Value

Date

Remarks

The relevant search keywords are: Get, Datein, Srv, Tax, Period.

For a clarification about how this function works, refer to the code listed below.

      EXIT(GetDateWithin(GetSrvTaxReturnPeriodStartDate(ServiceTaxReturnPeriod),GetSrvTaxReturnPeriodEndDate(ServiceTaxReturnPeriod)))

Example

There are no examples available.
Member of Miscellaneous.Library - Service Tax


GetDeltaDateWithinSrvTaxPeriod@1500010 Method

The procedure GetDeltaDateWithinSrvTaxPeriod is available in codeunit 143001.

Syntax

GetDeltaDateWithinSrvTaxPeriod@1500010(
    ServiceTaxReturnPeriod@1500000 : Record 16588 ServiceTaxReturnPeriod, //Input parameter of type Record
    StartDate@1500001 : Date StartDate //Input parameter of type Date
);

Parameters

ServiceTaxReturnPeriod
Input parameter of type Record
StartDate
Input parameter of type Date

Return Value

Date

Remarks

The relevant search keywords are: Get, Delta, Datein, Srv, Tax, Period.

For a clarification about how this function works, refer to the code listed below.

      EXIT(GetDateWithin(StartDate,GetSrvTaxReturnPeriodEndDate(ServiceTaxReturnPeriod)))

Example

There are no examples available.
Member of Miscellaneous.Library - Service Tax


GetSrvTaxReturnPeriodEndDate@1500008 Method

The procedure GetSrvTaxReturnPeriodEndDate is available in codeunit 143001.

Syntax

GetSrvTaxReturnPeriodEndDate@1500008(
    ServiceTaxReturnPeriod@1500001 : Record 16588 ServiceTaxReturnPeriod //Input parameter of type Record
);

Parameters

ServiceTaxReturnPeriod
Input parameter of type Record

Return Value

Date

Remarks

The relevant search keywords are: Get, Srv, Tax, Return, Period, End, Date.

For a clarification about how this function works, refer to the code listed below.

      CASE ServiceTaxReturnPeriod."Return Period" OF
        ServiceTaxReturnPeriod."Return Period"::"Apr-Sep":
          EndDate := DMY2DATE(30,9,ServiceTaxReturnPeriod.Year);
        ServiceTaxReturnPeriod."Return Period"::"Oct-Mar":
          EndDate := DMY2DATE(31,3,ServiceTaxReturnPeriod.Year);
      END;

Example

The below example is extracted from the test automation codeunit 144041 to show one way of using this function.

      // Step 1: for each eligible entry, a new record is inserted in ServiceTaxBuffer table
      ServiceTaxReturnPeriod.FINDLAST;
      PostingDate := LibraryServiceTax.GetSrvTaxReturnPeriodEndDate(ServiceTaxReturnPeriod);
      DateFilter :=
        FORMAT(LibraryServiceTax.GetSrvTaxReturnPeriodStartDate(ServiceTaxReturnPeriod)) + '..' + FORMAT(PostingDate);
      DocNo := LibraryUtility.GenerateRandomCode(ServiceTaxEntryDetail.FIELDNO("Document No."),DATABASE::"Service Tax Entry Details");

      ServiceTaxPaymentBuffer.DELETEALL;
      ServiceTaxMgt.CreateServiceTaxBufferForGroup(DocNo,PostingDate,ServiceTaxRegNo,DateFilter,ReverseCharge,ServiceTaxGroupCode);
      ServiceTaxPaymentBuffer.SETRANGE("Service Tax Group Code",ServiceTaxGroupCode);
      ServiceTaxPaymentBuffer.FINDFIRST;
      ServiceTaxPaymentBuffer."Account Type" := ServiceTaxPaymentBuffer."Account Type"::"G/L Account";
      LibraryERM.CreateGLAccount(GLAccount);
      ServiceTaxPaymentBuffer."Account No." := GLAccount."No.";
      ServiceTaxPaymentBuffer.VALIDATE("Payment Amount",ServiceTaxPaymentBuffer."Payment Liability");
      ServiceTaxPaymentBuffer.VALIDATE("Payment Amount (eCess)",ServiceTaxPaymentBuffer."Payment Liability (eCess)");
      ServiceTaxPaymentBuffer.VALIDATE("Payment Amount (SHECess)",ServiceTaxPaymentBuffer."Payment Liability (SHECess)");
      ServiceTaxPaymentBuffer.VALIDATE("Payment Amount (KKC)",ServiceTaxPaymentBuffer."Payment Liability (KKC)");
      ServiceTaxPaymentBuffer.VALIDATE("Payment Amount (SBC)",ServiceTaxPaymentBuffer."Payment Liability (SBC)");

      ServiceTaxPaymentBuffer.MODIFY(TRUE);
Member of Miscellaneous.Library - Service Tax


GetSrvTaxReturnPeriodStartDate@1500007 Method

The procedure GetSrvTaxReturnPeriodStartDate is available in codeunit 143001.

Syntax

GetSrvTaxReturnPeriodStartDate@1500007(
    ServiceTaxReturnPeriod@1500000 : Record 16588 ServiceTaxReturnPeriod //Input parameter of type Record
);

Parameters

ServiceTaxReturnPeriod
Input parameter of type Record

Return Value

Date

Remarks

The relevant search keywords are: Get, Srv, Tax, Return, Period, Start, Date.

For a clarification about how this function works, refer to the code listed below.

      CASE ServiceTaxReturnPeriod."Return Period" OF
        ServiceTaxReturnPeriod."Return Period"::"Apr-Sep":
          StartDate := DMY2DATE(1,4,ServiceTaxReturnPeriod.Year);
        ServiceTaxReturnPeriod."Return Period"::"Oct-Mar":
          StartDate := DMY2DATE(1,10,ServiceTaxReturnPeriod.Year);
      END;

Example

The below example is extracted from the test automation codeunit 144041 to show one way of using this function.

      // Step 1: for each eligible entry, a new record is inserted in ServiceTaxBuffer table
      ServiceTaxReturnPeriod.FINDLAST;
      PostingDate := LibraryServiceTax.GetSrvTaxReturnPeriodEndDate(ServiceTaxReturnPeriod);
      DateFilter :=
        FORMAT(LibraryServiceTax.GetSrvTaxReturnPeriodStartDate(ServiceTaxReturnPeriod)) + '..' + FORMAT(PostingDate);
      DocNo := LibraryUtility.GenerateRandomCode(ServiceTaxEntryDetail.FIELDNO("Document No."),DATABASE::"Service Tax Entry Details");

      ServiceTaxPaymentBuffer.DELETEALL;
      ServiceTaxMgt.CreateServiceTaxBufferForGroup(DocNo,PostingDate,ServiceTaxRegNo,DateFilter,ReverseCharge,ServiceTaxGroupCode);
      ServiceTaxPaymentBuffer.SETRANGE("Service Tax Group Code",ServiceTaxGroupCode);
      ServiceTaxPaymentBuffer.FINDFIRST;
      ServiceTaxPaymentBuffer."Account Type" := ServiceTaxPaymentBuffer."Account Type"::"G/L Account";
      LibraryERM.CreateGLAccount(GLAccount);
      ServiceTaxPaymentBuffer."Account No." := GLAccount."No.";
      ServiceTaxPaymentBuffer.VALIDATE("Payment Amount",ServiceTaxPaymentBuffer."Payment Liability");
      ServiceTaxPaymentBuffer.VALIDATE("Payment Amount (eCess)",ServiceTaxPaymentBuffer."Payment Liability (eCess)");
      ServiceTaxPaymentBuffer.VALIDATE("Payment Amount (SHECess)",ServiceTaxPaymentBuffer."Payment Liability (SHECess)");
      ServiceTaxPaymentBuffer.VALIDATE("Payment Amount (KKC)",ServiceTaxPaymentBuffer."Payment Liability (KKC)");
      ServiceTaxPaymentBuffer.VALIDATE("Payment Amount (SBC)",ServiceTaxPaymentBuffer."Payment Liability (SBC)");

      ServiceTaxPaymentBuffer.MODIFY(TRUE);
Member of Miscellaneous.Library - Service Tax


PayServiceTax@1500001 Method

The procedure PayServiceTax is available in codeunit 143001.

Syntax

PayServiceTax@1500001(
    ServiceTaxRegNo@1500000 : Code[20] ServiceTaxRegNo, //Input parameter of type Code
    ServiceTaxGroupCode@1500007 : Code[20] ServiceTaxGroupCode, //Input parameter of type Code
    ReverseCharge@1500001 : Boolean ReverseCharge //Input parameter of type Boolean
);

Parameters

ServiceTaxRegNo
Input parameter of type Code
ServiceTaxGroupCode
Input parameter of type Code
ReverseCharge
Input parameter of type Boolean

Return Value

Code[20]

Remarks

The relevant search keywords are: Pay, Service, Tax.

For a clarification about how this function works, refer to the code listed below.

      ServiceTaxReturnPeriod.FINDLAST;
      PostingDate := GetSrvTaxReturnPeriodEndDate(ServiceTaxReturnPeriod);
      DateFilter :=
        FORMAT(GetSrvTaxReturnPeriodStartDate(ServiceTaxReturnPeriod)) + '..' +
        FORMAT(PostingDate);
      DocNo := LibraryUtility.GenerateRandomCode(ServiceTaxEntryDetail.FIELDNO("Document No."),DATABASE::"Service Tax Entry Details");

      ServiceTaxPayment.OPENEDIT;
      ServiceTaxPayment.ReverseChargeTrans.SETVALUE(ReverseCharge);
      ServiceTaxPayment.ServiceTaxRegistrationNo.SETVALUE(ServiceTaxRegNo);
      ServiceTaxPayment.DateFilter.SETVALUE(DateFilter);
      ServiceTaxPayment.DocumentNo.SETVALUE(DocNo);
      ServiceTaxPayment.PostingDate.SETVALUE(PostingDate);
      ServiceTaxPayment.ApplyBtn.INVOKE;

      EXIT(DocNo);

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      Initialize;

      PostedPurchPaymentDocNo :=
        PostRevChargeInvAndApplyPmt(
          ServiceTaxRegNo,ServiceTaxGroup,ServiceTaxSetup,PurchaseHeader,PurchaseLine,
          PurchaseHeader."Document Type"::Invoice,PurchaseHeader."Service Type (Rev. Chrg.)"::Inward,
          ReverseChargeTypeOption::Standard);
      ReverseServiceTaxHelper.PayServiceTax(ServiceTaxRegNo.Code,ServiceTaxGroup.Code,TRUE);

      PostedSalesInvoiceDocNo :=
        ReverseServiceTaxHelper.UseCreditToPayForSalesDoc(PostedPurchPaymentDocNo,ServiceTaxEntryDetails);

      VerifySalesCreditClosed(ServiceTaxEntryDetails."Base Amount",PostedPurchPaymentDocNo,PostedSalesInvoiceDocNo);
Member of Miscellaneous.Library - Service Tax


SetServiceTaxRounding@1500013 Method

The procedure SetServiceTaxRounding is available in codeunit 143001.

Syntax

SetServiceTaxRounding@1500013(
      //param element not supplied
);

Remarks

The relevant search keywords are: Set, Service, Tax, Rounding.

For a clarification about how this function works, refer to the code listed below.

      GLSetup.GET;
      GLSetup.VALIDATE("Service Tax Rounding Precision",0.01);
      GLSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      InitializeReportTest;
      PmtGenJournalLine.PoT := FALSE;
      LibraryServiceTax.SetServiceTaxRounding;
      PostedDocNo :=
        ApplyBiggerDocToAdvPmt(
          PmtGenJournalLine,PurchaseHeader."Document Type"::Invoice,ReverseChargeType::Standard,
          GLAccountNo,InvoiceBaseAmount,InvoiceTaxAmount,PaymentBaseAmount,PaymentTaxAmount);

      RemainingAmt := PaymentBaseAmount * 2;
      PmtDocNo :=
        ReverseServiceTaxHelper.PostPayment(
          PmtGenJournalLine."Account No.",RemainingAmt,PmtGenJournalLine."Posting Date",PmtGenJournalLine."Document Type"::Payment);
      ReverseServiceTaxHelper.ApplyAndPostVendorEntry(
        PurchaseHeader."Document Type"::Invoice,PostedDocNo,PmtGenJournalLine."Document Type"::Payment,PmtDocNo);
      ReverseServiceTaxHelper.PayServiceTax(
        PmtGenJournalLine."Service Tax Registration No.",PmtGenJournalLine."Service Tax Group Code",TRUE);

      COMMIT;
      ServiceTaxReportHelper.RunReportInputServiceDetails(PmtGenJournalLine);

      ServiceTaxSetup.FindOnDate(PmtGenJournalLine."Service Tax Group Code",PmtGenJournalLine."Posting Date");
      ServiceTaxReportHelper.VerifyInputServiceDetails(
        PaymentBaseAmount,RemainingAmt,PmtGenJournalLine."Document No.",PostedDocNo,ServiceTaxSetup);
Member of Miscellaneous.Library - Service Tax


SetServiceTaxRoundingOne@1500014 Method

The procedure SetServiceTaxRoundingOne is available in codeunit 143001.

Syntax

SetServiceTaxRoundingOne@1500014(
      //param element not supplied
);

Remarks

The relevant search keywords are: Set, Service, Tax, Rounding, One.

For a clarification about how this function works, refer to the code listed below.

      GLSetup.GET;
      GLSetup.VALIDATE("Service Tax Rounding Precision",1);
      GLSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      // Setup
      LastTransactionNo := Initialize;
      LibraryServiceTax.SetServiceTaxRounding;
      // Exercise
      PostAdvancePaymentPoTFCY(GenJournalLine,IncludeServTax);

      // Restore
      ServiceTaxFCYHelper.SetNonResidentPmtOnTDSGroup(GenJournalLine,FALSE);

      // Verify
      ServiceTaxFCYHelper.VerifyServiceTaxAdvPmtBalances(GenJournalLine,LastTransactionNo,FALSE);
      GenJournalLine.Amount := ServiceTaxFCYHelper.ConvertFCYAmountToLCY(GenJournalLine);
      ServiceTaxTDSHelper.VerifyTDSPostingAdvPmt(GenJournalLine,IncludeServTax);
      LibraryServiceTax.SetServiceTaxRoundingOne;
Member of Miscellaneous.Library - Service Tax


SetValuesForPaymentUseCreditAvailable@1500017 Method

The procedure SetValuesForPaymentUseCreditAvailable is available in codeunit 143001.

Syntax

SetValuesForPaymentUseCreditAvailable@1500017(
    PayServiceTax@1500000 : TestPage 16477 PayServiceTax //Input parameter of type TestPage
);

Parameters

PayServiceTax
Input parameter of type TestPage

Remarks

The relevant search keywords are: Set, Values, For, Payment, Use, Credit, Available.

For a clarification about how this function works, refer to the code listed below.

      WITH PayServiceTax DO BEGIN
        FILTER.SETFILTER("Payment Liability",'<>0');
        LAST;
        PayServiceTaxComponent("Payment Liability".ASDECIMAL,"Credit Available".ASDECIMAL,CreditAvailed,PaymentAmt);
        "Credit Availed".SETVALUE(CreditAvailed);
        "Payment Amount".SETVALUE(PaymentAmt);
        TotalPayment += PaymentAmt;
        PayServiceTaxComponent("Payment Liability (eCess)".ASDECIMAL,"Credit Available (eCess)".ASDECIMAL,CreditAvailed,PaymentAmt);
        "Credit Availed (eCess)".SETVALUE(CreditAvailed);
        "Payment Amount (eCess)".SETVALUE(PaymentAmt);
        TotalPayment += PaymentAmt;
        PayServiceTaxComponent("Payment Liability (SHECess)".ASDECIMAL,"Credit Available (SHECess)".ASDECIMAL,CreditAvailed,PaymentAmt);
        "Credit Availed (SHECess)".SETVALUE(CreditAvailed);
        "Payment Amount (SHECess)".SETVALUE(PaymentAmt);
        TotalPayment += PaymentAmt;
        PayServiceTaxComponent("Payment Liability (KKC)".ASDECIMAL,"Credit Available (KKC)".ASDECIMAL,CreditAvailed,PaymentAmt);
        "Credit Availed (KKC)".SETVALUE(CreditAvailed);
        "Payment Amount (KKC)".SETVALUE(PaymentAmt);
        TotalPayment += PaymentAmt;
        SBCAmt := "Payment Liability (SBC)".ASDECIMAL;
        "Payment Amount (SBC)".SETVALUE(SBCAmt);
        TotalPayment += SBCAmt;
        IF TotalPayment <> 0 THEN BEGIN
          "Account Type".SETVALUE(ServiceTaxPaymentBuffer."Account Type"::"G/L Account");
          LibraryERM.CreateGLAccount(GLAccount);
          "Account No.".SETVALUE(GLAccount."No.");
        END;
        Post.INVOKE;
      END;

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      LibraryServiceTax.SetValuesForPaymentUseCreditAvailable(PayServiceTax);
Member of Miscellaneous.Library - Service Tax


Library - Tables UT Class

Miscellaneous.Library - Tables UT

COD131923 applies to ERM,W1,All.

Methods

Name | Description
CompareFieldTypeAndLength@1 | The procedure CompareFieldTypeAndLength is available in codeunit 131923.

See Also

Miscellaneous


CompareFieldTypeAndLength@1 Method

The procedure CompareFieldTypeAndLength is available in codeunit 131923.

Syntax

CompareFieldTypeAndLength@1(
    Table1@1003 : Variant Table1, //Input parameter of type Variant
    Field1@1001 : Integer Field1, //Input parameter of type Integer
    Table2@1002 : Variant Table2, //Input parameter of type Variant
    Field2@1000 : Integer Field2 //Input parameter of type Integer
);

Parameters

Table1
Input parameter of type Variant
Field1
Input parameter of type Integer
Table2
Input parameter of type Variant
Field2
Input parameter of type Integer

Remarks

The relevant search keywords are: Compare, Field, Type, Length.

For a clarification about how this function works, refer to the code listed below.

      RecordRef1.GETTABLE(Table1);
      RecordRef2.GETTABLE(Table2);
      FieldRef1 := RecordRef1.FIELD(Field1);
      FieldRef2 := RecordRef2.FIELD(Field2);
      Assert.IsTrue(FieldRef1.TYPE = FieldRef2.TYPE,'Fields Type mismatch');
      Assert.AreEqual(FieldRef1.LENGTH,FieldRef2.LENGTH,'Fields Length mismatch');

Example

The below example is extracted from the test automation codeunit 134600 to show one way of using this function.

      // [FEATURE] [UT]
      // [SCENARIO 252058] Length of "Custom Report Layout"."Description" shoud be equal to length of "Custom Report Selection"."Custom Report Description"

      LibraryTablesUT.CompareFieldTypeAndLength(
        CustomReportLayout,CustomReportLayout.FIELDNO(Description),
        CustomReportSelection,CustomReportSelection.FIELDNO("Custom Report Description"));
Member of Miscellaneous.Library - Tables UT


Library - TDS Class

Miscellaneous.Library - TDS

COD143000 applies to ERM,IN.

Methods

Name | Description
CalcExpectedTDSAmounts@1500015 | The procedure CalcExpectedTDSAmounts is available in codeunit 143000.
CalcTDSAmountsFromBase@1500087 | The procedure CalcTDSAmountsFromBase is available in codeunit 143000.
CreateAndUpdateTDSAccNo@1500040 | The procedure CreateAndUpdateTDSAccNo is available in codeunit 143000.
CreateAssesseeandNODNOCSetup@1500013 | The procedure CreateAssesseeandNODNOCSetup is available in codeunit 143000.
CreateAssesseeCode@1170000008 | The procedure CreateAssesseeCode is available in codeunit 143000.
CreateConcessionalCode@1500021 | The procedure CreateConcessionalCode is available in codeunit 143000.
CreateDeductorCategory@1500011 | The procedure CreateDeductorCategory is available in codeunit 143000.
CreateDeductoryCodeAndUpdateOnCompanyInformation@1500053 | The procedure CreateDeductoryCodeAndUpdateOnCompanyInformation is available in codeunit 143000.
CreateForeignVendorWithPANAPPLIED@1500037 | The procedure CreateForeignVendorWithPANAPPLIED is available in codeunit 143000.
CreateIncomeTaxAccPeriod@1500006 | The procedure CreateIncomeTaxAccPeriod is available in codeunit 143000.
CreateIncomeTaxPeriod@1500004 | The procedure CreateIncomeTaxPeriod is available in codeunit 143000.
CreateIncomeTaxPeriodQuarters@1500003 | The procedure CreateIncomeTaxPeriodQuarters is available in codeunit 143000.
CreateNatureOfRemittance@1170000000 | The procedure CreateNatureOfRemittance is available in codeunit 143000.
CreateNODNOCHeader@1500000 | The procedure CreateNODNOCHeader is available in codeunit 143000.
CreateNODNOCLines@1500001 | The procedure CreateNODNOCLines is available in codeunit 143000.
CreateNODNOCSetupforTDS@1500012 | The procedure CreateNODNOCSetupforTDS is available in codeunit 143000.
CreateParty@1170000001 | The procedure CreateParty is available in codeunit 143000.
CreateTANNo@1500005 | The procedure CreateTANNo is available in codeunit 143000.
CreateTaxJournalBatchTDSAdj@1500421 | The procedure CreateTaxJournalBatchTDSAdj is available in codeunit 143000.
CreateTaxJournalTemplateTDSAdj@1500420 | The procedure CreateTaxJournalTemplateTDSAdj is available in codeunit 143000.
CreateTDSNatureDeduction@1500008 | The procedure CreateTDSNatureDeduction is available in codeunit 143000.
CreateTDSNatureDeductionAndTDSSetup@10 | The procedure CreateTDSNatureDeductionAndTDSSetup is available in codeunit 143000.
CreateTDSSetup@1500010 | The procedure CreateTDSSetup is available in codeunit 143000.
CreateTDSSetupWithCountry@1500016 | The procedure CreateTDSSetupWithCountry is available in codeunit 143000.
CreateTDSTCSFiscalYear@1500007 | The procedure CreateTDSTCSFiscalYear is available in codeunit 143000.
CreateVendorWithPostingSetup@1500023 | The procedure CreateVendorWithPostingSetup is available in codeunit 143000.
Form26QForm27QReportFieldsValidation@1500017 | The procedure Form26QForm27QReportFieldsValidation is available in codeunit 143000.
GetFormNo@1500031 | The procedure GetFormNo is available in codeunit 143000.
GetPostedTDSAmount@1500018 | The procedure GetPostedTDSAmount is available in codeunit 143000.
PayTDS@1500034 | The procedure PayTDS is available in codeunit 143000.
RoundTCSAmount@1500257 | The procedure RoundTCSAmount is available in codeunit 143000.
RoundTDS@1500030 | The procedure RoundTDS is available in codeunit 143000.
RunUpdateChallanRegister@1500217 | The procedure RunUpdateChallanRegister is available in codeunit 143000.
SetInclServTaxOptionInGenJnl@1500014 | The procedure SetInclServTaxOptionInGenJnl is available in codeunit 143000.
SetInclServTaxOptionInStruct@1500009 | The procedure SetInclServTaxOptionInStruct is available in codeunit 143000.
UpdateChallanDetails@1500038 | The procedure UpdateChallanDetails is available in codeunit 143000.
UpdateNODNOCLines@1500046 | The procedure UpdateNODNOCLines is available in codeunit 143000.
UpdateTDSNilChallanInGeneralLedgerSetup@1500434 | The procedure UpdateTDSNilChallanInGeneralLedgerSetup is available in codeunit 143000.

See Also

Miscellaneous


CalcExpectedTDSAmounts@1500015 Method

The procedure CalcExpectedTDSAmounts is available in codeunit 143000.

Syntax

CalcExpectedTDSAmounts@1500015(
    VAR ExpectedTDSAmtPurchaseLine@1500000 : Record 39 ExpectedTDSAmtPurchaseLine, //Reference parameter of type Record
    PurchaseLine@1500003 : Record 39 PurchaseLine, //Input parameter of type Record
    TDSSetup@1500002 : Record 13728 TDSSetup //Input parameter of type Record
);

Parameters

ExpectedTDSAmtPurchaseLine
Reference parameter of type Record
PurchaseLine
Input parameter of type Record
TDSSetup
Input parameter of type Record

Remarks

The relevant search keywords are: Calc, Expected, TDS, Amounts.

For a clarification about how this function works, refer to the code listed below.

      WITH ExpectedTDSAmtPurchaseLine DO BEGIN
        "TDS %" := TDSSetup."TDS %";
        "Surcharge %" := TDSSetup."Surcharge %";
        "eCESS % on TDS" := TDSSetup."eCESS %";
        "SHE Cess % On TDS" := TDSSetup."SHE Cess %";
        "TDS Base Amount" := PurchaseLine.Amount;
        "TDS Amount" := RoundTDS((TDSSetup."TDS %" / 100 * "TDS Base Amount"));
        "Surcharge Amount" := RoundTDS((TDSSetup."Surcharge %" / 100 * "TDS Amount"));
        "eCESS on TDS Amount" := RoundTDS((TDSSetup."eCESS %" / 100 * ("TDS Amount" + "Surcharge Amount")));
        "SHE Cess on TDS Amount" := RoundTDS((TDSSetup."SHE Cess %" / 100 * ("TDS Amount" + "Surcharge Amount")));
        "Total TDS Including SHE CESS" :=
          RoundTDS("TDS Amount" + "eCESS on TDS Amount" + "SHE Cess on TDS Amount" + "Surcharge Amount");
      END;

Example

The below example is extracted from the test automation codeunit 144060 to show one way of using this function.

      // [SCENARIO 64543] Calculating TDS related amount successfully in the following forms in case of setting different rates for same NOD with different effective dates
      // [FEATURE] [Purchase Order]

      // [GIVEN] Created NODNOC ,TDS Nature of deduction,Assesse Code & TDS Setup For Purchase Order
      InitializeSetup(NodNocHeader,TdsNatureOfDeduction,TDSSetup,WORKDATE,TRUE,TRUE,TRUE);// ThresholdOverlook=TRUE,SurchargeOverlook=TRUE,MonthlyCertificate=TRUE

      // [WHEN] Create Purchase order With Line Item Type Including TDS and calculated expected & actual tds in purchase lines
      CreatePurchaseDocWithTDS(
        PurchaseHeader,PurchaseLine,NodNocHeader."No.",PurchaseLine.Type::Item,TdsNatureOfDeduction.Code,WORKDATE);
      PurchaseLine.CalculateTDS(PurchaseHeader);
      LibraryTDS.CalcExpectedTDSAmounts(ExpectedTDSAmountsPurchaseLine,PurchaseLine,TDSSetup);

      // [THEN] TDS Amounts calculated in Purchase Lines  using tds setup
      VerifyTDSAmountsPurchaseDoc(ExpectedTDSAmountsPurchaseLine,PurchaseLine,FALSE);
Member of Miscellaneous.Library - TDS


CalcTDSAmountsFromBase@1500087 Method

The procedure CalcTDSAmountsFromBase is available in codeunit 143000.

Syntax

CalcTDSAmountsFromBase@1500087(
    VAR ExpectedTDSAmounts@1500001 : Record 13729 ExpectedTDSAmounts, //Reference parameter of type Record
    TDSsetup@1500004 : Record 13728 TDSsetup, //Input parameter of type Record
    TaxBaseAmount@1500003 : Decimal TaxBaseAmount //Input parameter of type Decimal
);

Parameters

ExpectedTDSAmounts
Reference parameter of type Record
TDSsetup
Input parameter of type Record
TaxBaseAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Calc, TDS, Amounts, From, Base.

For a clarification about how this function works, refer to the code listed below.

      WITH ExpectedTDSAmounts DO BEGIN
        "TDS Base Amount" := TaxBaseAmount;
        "TDS Amount" := RoundTDS(TDSsetup."TDS %" / 100 * "TDS Base Amount");
        "Surcharge Amount" := RoundTDS(TDSsetup."Surcharge %" / 100 * "TDS Amount");
        "eCESS Amount" := RoundTDS(TDSsetup."eCESS %" / 100 * ("TDS Amount" + "Surcharge Amount"));
        "SHE Cess Amount" := RoundTDS(TDSsetup."SHE Cess %" / 100 * ("TDS Amount" + "Surcharge Amount"));
        "Total TDS Including SHE CESS" := "TDS Amount" + "eCESS Amount" + "SHE Cess Amount" + "Surcharge Amount";
      END;

Example

The below example is extracted from the test automation codeunit 144056 to show one way of using this function.

      //[SCENARIO 164267] Posting of General journal with TDS & Foreign currency after executing additional Currency report .
      //[FEATURE] [General Journal]

      // [GIVEN] Create Setup for NODNOC,Assessee Setup and Vendor with Country &foreign currency For General Journals
      Initialize;
      CreateIncomeTaxAccountingPeriod;
      CreateDeductoryCodeAndUpdateOnCompanyInformation;
      LibraryERM.CreateCountryRegion(CountryRegion);
      LibraryPurchase.CreateVendor(Vendor);
      Vendor.VALIDATE("Currency Code",LibraryERM.CreateCurrencyWithRandomExchRates);
      Vendor.VALIDATE("Country/Region Code",CountryRegion.Code);
      Vendor.VALIDATE("P.A.N. No.",LibraryUtility.GenerateRandomCode(Vendor.FIELDNO("P.A.N. No."),DATABASE::Vendor));
      Vendor.MODIFY(TRUE);
      LibraryTDS.CreateAssesseeandNODNOCSetup(NODNOCHeader,TDSNatureDeduction,TDSSetup,
        CountryRegion.Code,Vendor."No.",NODNOCHeader.Type::Vendor,WORKDATE);
      Amount := LibraryRandom.RandDec(1000,2);

      //[WHEN] Create General Journals With Foreign Currency and Creating Balance account along with this line
      LibraryERM.CreateGenJournalTemplate(GenJournalTemplate);
      LibraryERM.CreateGenJournalBatch(GenJournalBatch,GenJournalTemplate.Name);
      LibraryERM.CreateGeneralJnlLineWithBalAcc(
        GenJournalLine,GenJournalTemplate.Name,GenJournalBatch.Name,GenJournalLine."Document Type"::Payment,
        GenJournalLine."Account Type"::Vendor,Vendor."No.",GenJournalLine."Bal. Account Type"::"Bank Account",
        LibraryERM.CreateBankAccountNo,Amount);
      GenJournalLine.VALIDATE("Party Type",GenJournalLine."Party Type"::Vendor);
      GenJournalLine.VALIDATE("Party Code",Vendor."No.");
      GenJournalLine.VALIDATE("TDS Nature of Deduction",TDSNatureDeduction.Code);
      GenJournalLine.MODIFY(TRUE);
      LibraryTDS.CalcTDSAmountsFromBase(ExpectedTDSEntry,TDSSetup,GenJournalLine."Amount (LCY)");
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      //[THEN] G/l entries and TDS Entries are created,which are calculated using tds setup defined
      VerifyGLEntryCount(GenJournalLine."Document No.",3);
      VerifyGLEntry(GenJournalLine."Document Type"::Payment,GenJournalLine."Document No.",GenJournalLine."Amount (LCY)");
      ServiceTaxWithTDSHelper.VerifyTDSEntry(
        ExpectedTDSEntry,GenJournalLine."Document No.",GenJournalLine."Document Type"::Payment,FALSE);
Member of Miscellaneous.Library - TDS


CreateAndUpdateTDSAccNo@1500040 Method

The procedure CreateAndUpdateTDSAccNo is available in codeunit 143000.

Syntax

CreateAndUpdateTDSAccNo@1500040(
    TDSSetup@1500000 : Record 13728 TDSSetup //Input parameter of type Record
);

Parameters

TDSSetup
Input parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Update, TDS, Account, No.

For a clarification about how this function works, refer to the code listed below.

      TDSAccount := LibraryERM.CreateGLAccountNo;
      TDSGroup.SETRANGE("TDS Group",TDSSetup."TDS Group");
      TDSGroup.FINDFIRST;
      TDSGroup.VALIDATE("TDS Account",TDSAccount);
      TDSGroup.MODIFY;
      EXIT(TDSAccount);

Example

The below example is extracted from the test automation codeunit 144062 to show one way of using this function.

      // [SCENARIO 163890] Program generates correct TDS report Form 26Q when TDS entries are adjusted using the TDS Adjustment Journal
      // [FEATURE] [eTDS TRANSACTION]

      // [GIVEN] Created TDS Setup
      Initialize;
      CreateIncomeTaxAccountingPeriod;
      LibraryTDS.UpdateTDSNilChallanInGeneralLedgerSetup;
      TDSAccNo := LibraryTDS.CreateAndUpdateTDSAccNo(TDSSetup);

      // [WHEN] Create and Post payment against Gen. Jnl. Line using PAY TDS, Create and Post TDS Adjustment Journal,SUpdate TDS Register, Generate Form 26Q and eTDS
      CreateJournalDocs(GenJournalLine,NodNocHeader."No.",-LibraryRandom.RandDec(1000,2),TdsNatureOfDeduction.Code,
        GenJournalLine."Bal. Account Type"::"G/L Account",GenJournalTemplate."Sub Type"::"Bank Payment Voucher",
        GenJournalTemplate.Type::General,GenJournalLine."Document Type"::Invoice);
      LibraryERM.PostGeneralJnlLine(GenJournalLine);
      CreateAndPostTDSAdjustmentJournal(GenJournalLine."Document No.",NodNocHeader."No.",TaxJournalBatch.Name);
      CreateBankPaymentLineForPayTDS(
        GenJnlLinePaymnt,GenJournalTemplate."Sub Type"::"Bank Payment Voucher",GenJnlLinePaymnt."Document Type"::Payment,
        TDSAccNo,GenJournalLine."T.A.N. No.");
      GeneralJournalTemplateName := GenJnlLinePaymnt."Journal Template Name";
      GetBankPaymentVoucherAmountAfterPayTDS(GenJnlLinePaymnt."Journal Batch Name");
      LibraryERM.PostGeneralJnlLine(GenJnlLinePaymnt);
      LibraryTDS.UpdateChallanDetails(
        GenJournalLine."Document No.",GenJnlLinePaymnt."Document No.",IncomeTaxAccountingPeriod."Starting Date");
      IncomeTaxAccPeriod.FINDLAST;
      LibraryVariableStorage.Enqueue(IncomeTaxAccPeriod."Financial Year for eTDS/TCS");
      GenerateForm26Q27Q(TRUE);
      GenerateETDS(TRUE,IncomeTaxAccPeriod."Financial Year for eTDS/TCS");

      // [THEN] File for Generate eTDS has been created
      VerifyValuesOnBatchHeader(FormNo::"26Q",CompanyInformation."T.A.N. No.");
Member of Miscellaneous.Library - TDS


CreateAssesseeandNODNOCSetup@1500013 Method

The procedure CreateAssesseeandNODNOCSetup is available in codeunit 143000.

Syntax

CreateAssesseeandNODNOCSetup@1500013(
    VAR NODNOCHeader@1500000 : Record 13786 NODNOCHeader, //Reference parameter of type Record
    VAR TDSNatureofDeduction@1500001 : Record 13726 TDSNatureofDeduction, //Reference parameter of type Record
    VAR TDSSetup@1500007 : Record 13728 TDSSetup, //Reference parameter of type Record
    CountryCode@1500004 : Code[10] CountryCode, //Input parameter of type Code
    VendorNo@1500005 : Code[20] VendorNo, //Input parameter of type Code
    Type@1500006 : Option Type, //Input parameter of type Option
    EffectiveDate@1500008 : Date EffectiveDate //Input parameter of type Date
);

Parameters

NODNOCHeader
Reference parameter of type Record
TDSNatureofDeduction
Reference parameter of type Record
TDSSetup
Reference parameter of type Record
CountryCode
Input parameter of type Code
VendorNo
Input parameter of type Code
Type
Input parameter of type Option
EffectiveDate
Input parameter of type Date

Remarks

The relevant search keywords are: Create, Assesseeand, NODNOC, Setup.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.CreateAssesseeCode(AssesseeCode);
      IF CountryCode <> '' THEN
        CreateTDSNatureDeductionAndTDSSetup(TDSNatureofDeduction,TDSSetup,
          TDSNatureofDeduction."TDS Group"::"Payable to Non Residents",AssesseeCode.Code,CountryCode,EffectiveDate)
      ELSE
        CreateTDSNatureDeductionAndTDSSetup(TDSNatureofDeduction,TDSSetup,
          TDSNatureofDeduction."TDS Group"::Contractor,AssesseeCode.Code,CountryCode,EffectiveDate);
      CreateNODNOCSetupforTDS(NODNOCHeader,Type,VendorNo,AssesseeCode.Code,TDSNatureofDeduction.Code);

Example

The below example is extracted from the test automation codeunit 144013 to show one way of using this function.

      LibrarySetupStorage.Restore;
      IF isInitialized THEN
        EXIT;
      GeneralLedgerSetup.GET;
      CompanyInformation.GET;
      LibraryTDS.CreateDeductoryCodeAndUpdateOnCompanyInformation(CompanyInformation);
      LibraryTDS.UpdateTDSNilChallanInGeneralLedgerSetup;
      LibraryTDS.CreateIncomeTaxAccPeriod(IncomeTaxAccountingPeriod);
      LibraryTDS.CreateIncomeTaxPeriod(IncomeTaxPeriodSetup,IncomeTaxAccountingPeriod."No.",1);
      LibraryTDS.CreateAssesseeandNODNOCSetup(
        NodNocHeader,TDSNatureOfDeduction,TDSSetup,'',ServiceTaxWithTDSHelper.CreateVendorWithPANNo,NodNocHeader.Type::Vendor,
        IncomeTaxAccountingPeriod."Starting Date");
      isInitialized := TRUE;
      COMMIT;
      LibrarySetupStorage.Save(DATABASE::"Company Information");
Member of Miscellaneous.Library - TDS


CreateAssesseeCode@1170000008 Method

The procedure CreateAssesseeCode is available in codeunit 143000.

Syntax

CreateAssesseeCode@1170000008(
      //param element not supplied
);

Return Value

Code[10]

Remarks

The relevant search keywords are: Create, Assessee, Code.

For a clarification about how this function works, refer to the code listed below.

      WITH AssesseeCode DO BEGIN
        INIT;
        VALIDATE(Code,LibraryUtility.GenerateRandomCode(FIELDNO(Code),DATABASE::"Assessee Code"));
        VALIDATE(Description,Code);
        INSERT(TRUE);
        EXIT(Code);
      END;

Example

The below example is extracted from the test automation codeunit 144020 to show one way of using this function.

      // Create Setup, Post General Journal Lines and Verify Posted Entries.
      Initialize;
      CreateIncomeTaxAccountingPeriod;
      CreateDeductoryCodeAndUpdateOnCompanyInformation;
      Amount := LibraryRandom.RandDec(1000,2); // For Random Value.
      LibraryERM.CreateAssesseeCode(AssesseeCode); // Generate Assessee Code.
      CreateTDSNatureDeductionAndTDSSetup(TDSNatureDeduction,TDSSetup,TDSNatureDeduction."TDS Group"::Contractor,AssesseeCode.Code);
      CreateTDSNatureDeductionAndTDSSetup(TDSNatureDeduction2,TDSSetup,TDSNatureDeduction2."TDS Group"::Others,AssesseeCode.Code);
      CreateNODNOCSetup(
        NODNOCHeader,NODNOCHeader.Type::Vendor,CreateVendor,AssesseeCode.Code,TDSNatureDeduction.Code,TDSNatureDeduction2.Code);

      // Exercise: Create & Post Bank Payment Voucher.
      DocumentNo := CreateAndPostBankPaymentVoucher(Amount,NODNOCHeader."No.",TDSNatureDeduction.Code,TDSNatureDeduction2.Code);

      // Verify: Verify Credit Amount On GL Entry.
      VerifyGLEntry(DocumentType::Payment,DocumentNo,Amount);
Member of Miscellaneous.Library - TDS


CreateConcessionalCode@1500021 Method

The procedure CreateConcessionalCode is available in codeunit 143000.

Syntax

CreateConcessionalCode@1500021(
    VAR ConCode@1500002 : Record 13718 ConCode //Reference parameter of type Record
);

Parameters

ConCode
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Concessional, Code.

For a clarification about how this function works, refer to the code listed below.

      ConCode.INIT;
      ConCode.VALIDATE(
        Code,
        COPYSTR(
          LibraryUtility.GenerateRandomCode(ConCode.FIELDNO(Code),DATABASE::"Concessional Codes"),
          1,LibraryUtility.GetFieldLength(DATABASE::"Concessional Codes",ConCode.FIELDNO(Code))));
      ConCode.VALIDATE(Description,ConCode.Code);
      ConCode.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 144051 to show one way of using this function.

      // [SCENARIO 163825] Check if the program is calculating TCS amount with defined Concessional codes
      // [FEATURE] [Sales Order]

      // [GIVEN] Created NODNOC ,TCS Nature of Collection,Assesse Code & TCS Setup For Sales Order & Sales Return order
      Initialize;
      LibraryTDS.CreateConcessionalCode(ConcessionalCodes);
      InitializeSalesSetup(NodNocHeader,TcsNatureOfCollection,TCSSetup,ConcessionalCodes.Code);
      Amount := LibraryRandom.RandDec(5000,2);

      // [WHEN] Create Sales Order with ConcessionalCode and Calculated TCS Entries.
      CreateSalesDocWithTCS(SalesHeader,SalesLine,NodNocHeader,TcsNatureOfCollection.Code,SalesHeader."Document Type"::Order,Amount);
      CalcExpectedTCSAmounts(ExpectedTCSEntry,TCSSetup,SalesLine.Amount);
      SalesLine.CalculateTCS(SalesHeader);
      DocumentNo := LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

      // [THEN] Created GL Entries and TCS Entries and Verified.
      VerifyTCSEntry(ExpectedTCSEntry,DocumentNo,ExpectedTCSEntry."Document Type"::Invoice);
Member of Miscellaneous.Library - TDS


CreateDeductorCategory@1500011 Method

The procedure CreateDeductorCategory is available in codeunit 143000.

Syntax

CreateDeductorCategory@1500011(
    VAR DeductorCategory@1500002 : Record 16498 DeductorCategory //Reference parameter of type Record
);

Parameters

DeductorCategory
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Deductor, Category.

For a clarification about how this function works, refer to the code listed below.

      WITH DeductorCategory DO BEGIN
        INIT;
        VALIDATE(Code,LibraryUtility.GenerateRandomCode(FIELDNO(Code),DATABASE::"Deductor Category"));
        INSERT(TRUE);
      END;

Example

The below example is extracted from the test automation codeunit 144012 to show one way of using this function.

      LibraryERM.CreateDeductorCategory(DeductorCategory);
      CompanyInformation.VALIDATE("Deductor Category",DeductorCategory.Code);
      CompanyInformation.MODIFY(TRUE);
Member of Miscellaneous.Library - TDS


CreateDeductoryCodeAndUpdateOnCompanyInformation@1500053 Method

The procedure CreateDeductoryCodeAndUpdateOnCompanyInformation is available in codeunit 143000.

Syntax

CreateDeductoryCodeAndUpdateOnCompanyInformation@1500053(
    VAR CompanyInformation@1500000 : Record 79 CompanyInformation //Reference parameter of type Record
);

Parameters

CompanyInformation
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Deductory, Code, Update, On, Company, Information.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.CreateDeductorCategory(DeductorCategory);
      CompanyInformation.GET;
      CompanyInformation.VALIDATE("Deductor Category",DeductorCategory.Code);
      CompanyInformation.VALIDATE("T.A.N. No.",CreateTANNo);
      CompanyInformation.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 144013 to show one way of using this function.

      LibrarySetupStorage.Restore;
      IF isInitialized THEN
        EXIT;
      GeneralLedgerSetup.GET;
      CompanyInformation.GET;
      LibraryTDS.CreateDeductoryCodeAndUpdateOnCompanyInformation(CompanyInformation);
      LibraryTDS.UpdateTDSNilChallanInGeneralLedgerSetup;
      LibraryTDS.CreateIncomeTaxAccPeriod(IncomeTaxAccountingPeriod);
      LibraryTDS.CreateIncomeTaxPeriod(IncomeTaxPeriodSetup,IncomeTaxAccountingPeriod."No.",1);
      LibraryTDS.CreateAssesseeandNODNOCSetup(
        NodNocHeader,TDSNatureOfDeduction,TDSSetup,'',ServiceTaxWithTDSHelper.CreateVendorWithPANNo,NodNocHeader.Type::Vendor,
        IncomeTaxAccountingPeriod."Starting Date");
      isInitialized := TRUE;
      COMMIT;
      LibrarySetupStorage.Save(DATABASE::"Company Information");
Member of Miscellaneous.Library - TDS


CreateForeignVendorWithPANAPPLIED@1500037 Method

The procedure CreateForeignVendorWithPANAPPLIED is available in codeunit 143000.

Syntax

CreateForeignVendorWithPANAPPLIED@1500037(
    VAR Vendor@1500000 : Record 23 Vendor, //Reference parameter of type Record
    CurrencyCode@1500001 : Code[10] CurrencyCode, //Input parameter of type Code
    CountryCode@1500002 : Code[10] CountryCode //Input parameter of type Code
);

Parameters

Vendor
Reference parameter of type Record
CurrencyCode
Input parameter of type Code
CountryCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Foreign, Vendor, PANAPPLIED.

For a clarification about how this function works, refer to the code listed below.

      LibraryPurchase.CreateVendor(Vendor);
      Vendor.VALIDATE("P.A.N. Status",Vendor."P.A.N. Status"::PANAPPLIED);
      Vendor.VALIDATE("P.A.N. Reference No.",
        LibraryUtility.GenerateRandomCode(Vendor.FIELDNO("P.A.N. Reference No."),DATABASE::Vendor));
      Vendor.VALIDATE("Currency Code",CurrencyCode);
      Vendor.VALIDATE("Country/Region Code",CountryCode);
      Vendor.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 144062 to show one way of using this function.

      // [SCENARIO 164335] Validate whether transactions are marked with Concessional Code in Form 26Q where deduction is made with higher rate for non-availability of PAN
      // [FEATURE] [TDS TRANSACTION]

      // [GIVEN] Created TDS Setup with Concessional Code
      Initialize;
      LibraryTDS.UpdateTDSNilChallanInGeneralLedgerSetup;
      LibraryERM.CreateAssesseeCode(AssesseeCode);
      LibraryTDS.CreateConcessionalCode(ConcessionalCodes);
      LibraryTDS.CreateForeignVendorWithPANAPPLIED(Vendor,'','');
      CreateTDSNatureDeductionAndTDSSetup(TdsNatureOfDeduction1,TDSSetup1,TDSSetup1."TDS Group"::Contractor,
        AssesseeCode.Code,ConcessionalCodes.Code,'');
      CreateNODNOCSetup(NodNocHeader1,Vendor."No.",AssesseeCode.Code,ConcessionalCodes.Code,TdsNatureOfDeduction1.Code,TRUE,TRUE,TRUE);

      // [WHEN] Create and Post payment against Gen. Jnl. Line using PAY TDS, Update TDs Register, Generate Form 26Q and eTDS
      PostedDocNo := CreateAndPostMultipleGenJnlLinWithPaymentByPayTDS(GenJnlLinePayment,TDSSetup1,NodNocHeader1."No.",'');
      LibraryTDS.UpdateChallanDetails(PostedDocNo,GenJnlLinePayment."Document No.",IncomeTaxAccountingPeriod."Starting Date");
      LibraryVariableStorage.Enqueue(IncomeTaxAccountingPeriod."Financial Year for eTDS/TCS");
      GenerateForm26Q27Q(TRUE);
      GenerateETDS(TRUE,IncomeTaxAccountingPeriod."Financial Year for eTDS/TCS");

      // [THEN] Form 26Q has been generated with Concessional Code
      LibraryReportDataset.LoadDataSetFile;
      LibraryReportDataset.AssertElementWithValueExists('Form_26Q_27Q_Entry__Concessional_Code_',ConcessionalCodes.Code);
Member of Miscellaneous.Library - TDS


CreateIncomeTaxAccPeriod@1500006 Method

The procedure CreateIncomeTaxAccPeriod is available in codeunit 143000.

Syntax

CreateIncomeTaxAccPeriod@1500006(
    VAR IncomeTaxAccountingPeriod@1500000 : Record 13724 IncomeTaxAccountingPeriod //Reference parameter of type Record
);

Parameters

IncomeTaxAccountingPeriod
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Income, Tax, Account, Period.

For a clarification about how this function works, refer to the code listed below.

      IF IncomeTaxAccountingPeriod.FINDLAST THEN
        StartingDate := CALCDATE('<1D>',IncomeTaxAccountingPeriod."Ending Date")
      ELSE
        StartingDate := WORKDATE;

      CreateTDSTCSFiscalYear(IncomeTaxAccountingPeriod,StartingDate);

Example

The below example is extracted from the test automation codeunit 144013 to show one way of using this function.

      LibrarySetupStorage.Restore;
      IF isInitialized THEN
        EXIT;
      GeneralLedgerSetup.GET;
      CompanyInformation.GET;
      LibraryTDS.CreateDeductoryCodeAndUpdateOnCompanyInformation(CompanyInformation);
      LibraryTDS.UpdateTDSNilChallanInGeneralLedgerSetup;
      LibraryTDS.CreateIncomeTaxAccPeriod(IncomeTaxAccountingPeriod);
      LibraryTDS.CreateIncomeTaxPeriod(IncomeTaxPeriodSetup,IncomeTaxAccountingPeriod."No.",1);
      LibraryTDS.CreateAssesseeandNODNOCSetup(
        NodNocHeader,TDSNatureOfDeduction,TDSSetup,'',ServiceTaxWithTDSHelper.CreateVendorWithPANNo,NodNocHeader.Type::Vendor,
        IncomeTaxAccountingPeriod."Starting Date");
      isInitialized := TRUE;
      COMMIT;
      LibrarySetupStorage.Save(DATABASE::"Company Information");
Member of Miscellaneous.Library - TDS


CreateIncomeTaxPeriod@1500004 Method

The procedure CreateIncomeTaxPeriod is available in codeunit 143000.

Syntax

CreateIncomeTaxPeriod@1500004(
    VAR IncomeTaxPeriodSetup@1500000 : Record 16501 IncomeTaxPeriodSetup, //Reference parameter of type Record
    IncomeTaxAccountingPeriodNo@1500001 : Integer IncomeTaxAccountingPeriodNo, //Input parameter of type Integer
    QuarterNo@1500002 : Integer QuarterNo //Input parameter of type Integer
);

Parameters

IncomeTaxPeriodSetup
Reference parameter of type Record
IncomeTaxAccountingPeriodNo
Input parameter of type Integer
QuarterNo
Input parameter of type Integer

Remarks

The relevant search keywords are: Create, Income, Tax, Period.

For a clarification about how this function works, refer to the code listed below.

      IncomeTaxAccPeriod.GET(IncomeTaxAccountingPeriodNo);
      StartingDate := GetQuarterStartingDate(IncomeTaxAccPeriod."Starting Date",QuarterNo);

      WITH IncomeTaxPeriodSetup DO BEGIN
        INIT;
        VALIDATE("No.",IncomeTaxAccPeriod."No.");
        VALIDATE(Quarter,QuarterNo);
        VALIDATE("Starting Date",StartingDate);
        VALIDATE("Ending Date",CALCDATE('<CQ>',StartingDate));
        INSERT(TRUE);
      END;

Example

The below example is extracted from the test automation codeunit 144013 to show one way of using this function.

      LibrarySetupStorage.Restore;
      IF isInitialized THEN
        EXIT;
      GeneralLedgerSetup.GET;
      CompanyInformation.GET;
      LibraryTDS.CreateDeductoryCodeAndUpdateOnCompanyInformation(CompanyInformation);
      LibraryTDS.UpdateTDSNilChallanInGeneralLedgerSetup;
      LibraryTDS.CreateIncomeTaxAccPeriod(IncomeTaxAccountingPeriod);
      LibraryTDS.CreateIncomeTaxPeriod(IncomeTaxPeriodSetup,IncomeTaxAccountingPeriod."No.",1);
      LibraryTDS.CreateAssesseeandNODNOCSetup(
        NodNocHeader,TDSNatureOfDeduction,TDSSetup,'',ServiceTaxWithTDSHelper.CreateVendorWithPANNo,NodNocHeader.Type::Vendor,
        IncomeTaxAccountingPeriod."Starting Date");
      isInitialized := TRUE;
      COMMIT;
      LibrarySetupStorage.Save(DATABASE::"Company Information");
Member of Miscellaneous.Library - TDS


CreateIncomeTaxPeriodQuarters@1500003 Method

The procedure CreateIncomeTaxPeriodQuarters is available in codeunit 143000.

Syntax

CreateIncomeTaxPeriodQuarters@1500003(
    IncomeTaxAccountingPeriodNo@1500001 : Integer IncomeTaxAccountingPeriodNo //Input parameter of type Integer
);

Parameters

IncomeTaxAccountingPeriodNo
Input parameter of type Integer

Remarks

The relevant search keywords are: Create, Income, Tax, Period, Quarters.

For a clarification about how this function works, refer to the code listed below.

      FOR Quarter := IncomeTaxPeriodSetup.Quarter::Q1 TO IncomeTaxPeriodSetup.Quarter::Q4 DO
        CreateIncomeTaxPeriod(IncomeTaxPeriodSetup,IncomeTaxAccountingPeriodNo,Quarter);

Example

The below example is extracted from the test automation codeunit 144053 to show one way of using this function.

      Initialize;
      LibraryTDS.UpdateTDSNilChallanInGeneralLedgerSetup;
      LibraryTDS.CreateIncomeTaxAccPeriod(IncomeTaxAccountingPeriod);
      LibraryTDS.CreateIncomeTaxPeriodQuarters(IncomeTaxAccountingPeriod."No.");
Member of Miscellaneous.Library - TDS


CreateNatureOfRemittance@1170000000 Method

The procedure CreateNatureOfRemittance is available in codeunit 143000.

Syntax

CreateNatureOfRemittance@1170000000(
    VAR NatureOfRemittance@1170000000 : Record 13783 NatureOfRemittance //Reference parameter of type Record
);

Parameters

NatureOfRemittance
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Nature, Of, Remittance.

For a clarification about how this function works, refer to the code listed below.

      NatureOfRemittance.INIT;
      NatureOfRemittance.VALIDATE(Code,
        LibraryUtility.GenerateRandomCode(NatureOfRemittance.FIELDNO(Code),DATABASE::"TDS Nature of Remittance"));
      NatureOfRemittance.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 144047 to show one way of using this function.

      IF TDSNatureOfDeductionGroup = TDSNatureOfDeduction."TDS Group"::"Payable to Non Residents" THEN BEGIN
        LibraryTDS.CreateNatureOfRemittance(NatureOfRemittance);
        NatureOfRemittanceCode := NatureOfRemittance.Code;
        ActApplicable := TDSSetup."Act Applicable"::IT;
        CountryRegionCode := FindCountryRegionCode;
      END;
      WITH TDSSetup DO BEGIN
        LibraryTDS.CreateTDSSetup(TDSSetup,TDSNatureDeductionCode,AssesseeCode,EffectiveDate,'A',NatureOfRemittanceCode,ActApplicable,CountryRegionCode);
        VALIDATE("TDS %",TDSPercentage);
        VALIDATE("Non PAN TDS %",TDSPercentage);
        VALIDATE("Surcharge %",LibraryRandom.RandInt(5));
        VALIDATE("eCESS %",LibraryRandom.RandInt(5));
        VALIDATE("SHE Cess %",LibraryRandom.RandInt(5));
        MODIFY(TRUE);
      END;
Member of Miscellaneous.Library - TDS


CreateNODNOCHeader@1500000 Method

The procedure CreateNODNOCHeader is available in codeunit 143000.

Syntax

CreateNODNOCHeader@1500000(
    VAR NODNOCHeader@1500000 : Record 13786 NODNOCHeader, //Reference parameter of type Record
    HeaderType@1500001 : Option HeaderType, //Input parameter of type Option
    No@1500002 : Code[20] No, //Input parameter of type Code
    AssesseeCode@1500003 : Code[10] AssesseeCode //Input parameter of type Code
);

Parameters

NODNOCHeader
Reference parameter of type Record
HeaderType
Input parameter of type Option
No
Input parameter of type Code
AssesseeCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, NODNOC, Header.

For a clarification about how this function works, refer to the code listed below.

      WITH NODNOCHeader DO BEGIN
        INIT;
        VALIDATE(Type,HeaderType);
        VALIDATE("No.",No);
        VALIDATE("Assesse Code",AssesseeCode);
        INSERT(TRUE);
      END;

Example

The below example is extracted from the test automation codeunit 144020 to show one way of using this function.

      LibraryERM.CreateNODNOCHeader(NODNOCHeader,Type,No);
      NODNOCHeader.VALIDATE("Assesse Code",AssesseeCode);
      NODNOCHeader.MODIFY(TRUE);
      LibraryERM.CreateNODNOCLines(NODNOCLines,NODNOCHeader,CodeContractor);
      IF CodeOthers <> '' THEN
        LibraryERM.CreateNODNOCLines(NODNOCLines,NODNOCHeader,CodeOthers);
      UpdateNODNOCLines(NODNOCLines,NODNOCHeader.Type::Vendor);
Member of Miscellaneous.Library - TDS


CreateNODNOCLines@1500001 Method

The procedure CreateNODNOCLines is available in codeunit 143000.

Syntax

CreateNODNOCLines@1500001(
    VAR NODNOCLines@1500000 : Record 13785 NODNOCLines, //Reference parameter of type Record
    NODNOCHeader@1500001 : Record 13786 NODNOCHeader, //Input parameter of type Record
    NODNOC@1500002 : Code[10] NODNOC, //Input parameter of type Code
    ThresholdOverlook@1500003 : Boolean ThresholdOverlook, //Input parameter of type Boolean
    NatureOfRemittance@1170000000 : Code[10] NatureOfRemittance, //Input parameter of type Code
    ActApplicable@1170000001 : Option ActApplicable //Input parameter of type Option
);

Parameters

NODNOCLines
Reference parameter of type Record
NODNOCHeader
Input parameter of type Record
NODNOC
Input parameter of type Code
ThresholdOverlook
Input parameter of type Boolean
NatureOfRemittance
Input parameter of type Code
ActApplicable
Input parameter of type Option

Remarks

The relevant search keywords are: Create, NODNOC, Lines.

For a clarification about how this function works, refer to the code listed below.

      WITH NODNOCLines DO BEGIN
        INIT;
        VALIDATE(Type,NODNOCHeader.Type);
        VALIDATE("No.",NODNOCHeader."No.");
        VALIDATE("NOD/NOC",NODNOC);
        VALIDATE("Threshold Overlook",ThresholdOverlook);
        IF NatureOfRemittance <> '' THEN
          VALIDATE("Nature of Remittance",NatureOfRemittance);
        IF ActApplicable <> ActApplicable::" " THEN
          VALIDATE("Act Applicable",ActApplicable);
        INSERT(TRUE);
      END;

Example

The below example is extracted from the test automation codeunit 144020 to show one way of using this function.

      LibraryERM.CreateNODNOCHeader(NODNOCHeader,Type,No);
      NODNOCHeader.VALIDATE("Assesse Code",AssesseeCode);
      NODNOCHeader.MODIFY(TRUE);
      LibraryERM.CreateNODNOCLines(NODNOCLines,NODNOCHeader,CodeContractor);
      IF CodeOthers <> '' THEN
        LibraryERM.CreateNODNOCLines(NODNOCLines,NODNOCHeader,CodeOthers);
      UpdateNODNOCLines(NODNOCLines,NODNOCHeader.Type::Vendor);
Member of Miscellaneous.Library - TDS


CreateNODNOCSetupforTDS@1500012 Method

The procedure CreateNODNOCSetupforTDS is available in codeunit 143000.

Syntax

CreateNODNOCSetupforTDS@1500012(
    VAR NODNOCHeader@1040 : Record 13786 NODNOCHeader, //Reference parameter of type Record
    Type@1041 : Option Type, //Input parameter of type Option
    No@1042 : Code[20] No, //Input parameter of type Code
    AssesseeCode@1043 : Code[10] AssesseeCode, //Input parameter of type Code
    CodeContractor@1044 : Code[10] CodeContractor //Input parameter of type Code
);

Parameters

NODNOCHeader
Reference parameter of type Record
Type
Input parameter of type Option
No
Input parameter of type Code
AssesseeCode
Input parameter of type Code
CodeContractor
Input parameter of type Code

Remarks

The relevant search keywords are: Create, NODNOC, Setupfor, TDS.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.CreateNODNOCHeader(NODNOCHeader,Type,No);
      NODNOCHeader.VALIDATE("Assesse Code",AssesseeCode);
      NODNOCHeader.MODIFY(TRUE);
      LibraryERM.CreateNODNOCLines(NODNOCLines,NODNOCHeader,CodeContractor);
      UpdateNODNOCLines(NODNOCLines,Type,TRUE,TRUE,FALSE);

Example

The below example is extracted from the test automation codeunit 144025 to show one way of using this function.

      // [SCENARIO 164277] Created Setup, Posted Purchase Order with Work Tax and TDS Threshold Amount with PANAPPLIED for Vendor.
      // [FEATURE] [TDS][Purchase Order]
      Initialize;

      // [GIVEN] Created Setup for NOD/NOC, Assessee Code,TDS Setup with TDS Threshold Amount and Non-PAN Vendor.
      CreateIncomeTaxAccountingPeriod;
      Amount := LibraryRandom.RandDec(10000,2);
      LibraryERM.CreateAssesseeCode(AssesseeCode);
      LibraryTDS.CreateTDSNatureDeductionAndTDSSetup(
        TdsNatureOfDeduction,TDSSetup,TdsNatureOfDeduction."TDS Group"::Others,AssesseeCode.Code,'',WORKDATE);
      LibraryTDS.CreateNODNOCSetupforTDS(
        NodNocHeader,NodNocHeader.Type::Vendor,CreateVendorWithLocation('',TRUE),AssesseeCode.Code,TdsNatureOfDeduction.Code);
      UpdateNODNOCLines(NodNocHeader,FALSE,FALSE,TRUE);
      UpdateThresholdLimit(TDSGroup,TdsNatureOfDeduction."TDS Group");

      // [WHEN] Create & Post Purchase Invoice
      CreatePurchaseOrder(
        PurchaseHeader,PurchaseLine,PurchaseHeader."Document Type"::Order,NodNocHeader."No.",'',TdsNatureOfDeduction.Code,Amount);
      PurchaseLine.CalculateTDS(PurchaseHeader);
      CalcTDSAmountsFromBase(ExpectedTDSEntry,TDSSetup,PurchaseLine.Amount,FALSE,TRUE);
      VerifyPurchaseOrderStatistics(ExpectedTDSEntry,PurchaseLine);
      DocumentNo := LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

      // [THEN] 3 GL Entries are created and posted to TDS Account.
      VerifyGLEntryCount(DocumentNo,3);
      VerifyGLEntryWithTDSAccount(DocumentNo,TDSGroup."TDS Account",-ExpectedTDSEntry."Work Tax Amount");
Member of Miscellaneous.Library - TDS


CreateParty@1170000001 Method

The procedure CreateParty is available in codeunit 143000.

Syntax

CreateParty@1170000001(
    VAR Party@1170000000 : Record 13730 Party //Reference parameter of type Record
);

Parameters

Party
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Party.

For a clarification about how this function works, refer to the code listed below.

      Party.INIT;
      Party.VALIDATE(Code,
        LibraryUtility.GenerateRandomCode(Party.FIELDNO(Code),DATABASE::Party));
      Party.VALIDATE("P.A.N. No.",LibraryUtility.GenerateRandomCode(Party.FIELDNO("P.A.N. No."),DATABASE::Party));
      Party.INSERT(TRUE);

Example

The below example is extracted from the test automation codeunit 144048 to show one way of using this function.

      LibraryTDS.CreateParty(Party);
      Party.VALIDATE("P.A.N. No.",'ACFPH4256A');  // Valid P.A.N. No.
      Party.MODIFY(TRUE);
      EXIT(Party.Code);
Member of Miscellaneous.Library - TDS


CreateTANNo@1500005 Method

The procedure CreateTANNo is available in codeunit 143000.

Syntax

CreateTANNo@1500005(
      //param element not supplied
);

Return Value

Code[10]

Remarks

The relevant search keywords are: Create, TAN, No.

For a clarification about how this function works, refer to the code listed below.

      WITH TANNos DO BEGIN
        INIT;
        VALIDATE(Code,LibraryUtility.GenerateRandomCode(FIELDNO(Code),DATABASE::"T.A.N. Nos."));
        VALIDATE(Description,Code);
        INSERT(TRUE);
        EXIT(Code);
      END;

Example

The below example is extracted from the test automation codeunit 144053 to show one way of using this function.

      CompanyInformation.GET;
      FinancialYear := FinancialYearValue;
      ReportFrequency := Quarter;
      CASE FieldNumber OF
        1:
          TANNo := LibraryTDS.CreateTANNo;
        2:
          TANNo := CompanyInformation."T.A.N. No.";
      END;
Member of Miscellaneous.Library - TDS


CreateTaxJournalBatchTDSAdj@1500421 Method

The procedure CreateTaxJournalBatchTDSAdj is available in codeunit 143000.

Syntax

CreateTaxJournalBatchTDSAdj@1500421(
    VAR TaxJournalBatch@1500220 : Record 16586 TaxJournalBatch, //Reference parameter of type Record
    JournalTemplateName@1500221 : Code[10] JournalTemplateName //Input parameter of type Code
);

Parameters

TaxJournalBatch
Reference parameter of type Record
JournalTemplateName
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Tax, Journal, Batch, TDS, Adj.

For a clarification about how this function works, refer to the code listed below.

      WITH TaxJournalBatch DO BEGIN
        INIT;
        VALIDATE("Journal Template Name",JournalTemplateName);
        VALIDATE(
          Name,COPYSTR(
            LibraryUtility.GenerateRandomCode(FIELDNO(Name),DATABASE::"Tax Journal Batch"),1,
            LibraryUtility.GetFieldLength(DATABASE::"Tax Journal Batch",FIELDNO(Name))));
        VALIDATE(Description,Name);
        INSERT(TRUE);
        VALIDATE("No. Series",CreateNoseries);
        MODIFY(TRUE);
      END;

Example

The below example is extracted from the test automation codeunit 144001 to show one way of using this function.

      LibraryTDS.CreateTaxJournalTemplateTDSAdj(TaxJournalTemplate);
      TaxJournalTemplate.VALIDATE(Type,TaxJournalTemplate.Type::Excise);
      TaxJournalTemplate.MODIFY(TRUE);
      TaxJnlTemplateName := TaxJournalTemplate.Name;
      LibraryTDS.CreateTaxJournalBatchTDSAdj(TaxJournalBatch,TaxJournalTemplate.Name);
      EXIT(TaxJournalBatch.Name);
Member of Miscellaneous.Library - TDS


CreateTaxJournalTemplateTDSAdj@1500420 Method

The procedure CreateTaxJournalTemplateTDSAdj is available in codeunit 143000.

Syntax

CreateTaxJournalTemplateTDSAdj@1500420(
    VAR TaxJournalTemplate@1500222 : Record 16585 TaxJournalTemplate //Reference parameter of type Record
);

Parameters

TaxJournalTemplate
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Tax, Journal, Template, TDS, Adj.

For a clarification about how this function works, refer to the code listed below.

      WITH TaxJournalTemplate DO BEGIN
        INIT;
        VALIDATE(
          Name,COPYSTR(
            LibraryUtility.GenerateRandomCode(FIELDNO(Name),DATABASE::"Tax Journal Template"),1,
            LibraryUtility.GetFieldLength(DATABASE::"Tax Journal Template",FIELDNO(Name))));
        VALIDATE(Description,Name);
        INSERT(TRUE);
        VALIDATE(Type,Type::"TDS Adjustments");
        MODIFY(TRUE);
      END;

Example

The below example is extracted from the test automation codeunit 144001 to show one way of using this function.

      LibraryTDS.CreateTaxJournalTemplateTDSAdj(TaxJournalTemplate);
      TaxJournalTemplate.VALIDATE(Type,TaxJournalTemplate.Type::Excise);
      TaxJournalTemplate.MODIFY(TRUE);
      TaxJnlTemplateName := TaxJournalTemplate.Name;
      LibraryTDS.CreateTaxJournalBatchTDSAdj(TaxJournalBatch,TaxJournalTemplate.Name);
      EXIT(TaxJournalBatch.Name);
Member of Miscellaneous.Library - TDS


CreateTDSNatureDeduction@1500008 Method

The procedure CreateTDSNatureDeduction is available in codeunit 143000.

Syntax

CreateTDSNatureDeduction@1500008(
    TDSGroup@1500001 : Option TDSGroup //Input parameter of type Option
);

Parameters

TDSGroup
Input parameter of type Option

Return Value

Code[10]

Remarks

The relevant search keywords are: Create, TDS, Nature, Deduction.

For a clarification about how this function works, refer to the code listed below.

      WITH TDSNatureDeduction DO BEGIN
        INIT;
        VALIDATE(Code,
          COPYSTR(
            LibraryUtility.GenerateRandomCode(FIELDNO(Code),DATABASE::"TDS Nature of Deduction"),
            1,LibraryUtility.GetFieldLength(DATABASE::"TDS Nature of Deduction",FIELDNO(Code))));
        VALIDATE(Description,Code);
        VALIDATE(Category,Category::C);
        VALIDATE("TDS Group",TDSGroup);
        INSERT(TRUE);
        EXIT(Code);
      END;

Example

The below example is extracted from the test automation codeunit 144020 to show one way of using this function.

      LibraryERM.CreateTDSNatureDeduction(TDSNatureDeduction);
      TDSNatureDeduction.VALIDATE("TDS Group",TDSGroup);
      TDSNatureDeduction.MODIFY(TRUE);
      CreateTDSSetUp(TDSSetup,TDSNatureDeduction.Code,AssesseeCode);
Member of Miscellaneous.Library - TDS


CreateTDSNatureDeductionAndTDSSetup@10 Method

The procedure CreateTDSNatureDeductionAndTDSSetup is available in codeunit 143000.

Syntax

CreateTDSNatureDeductionAndTDSSetup@10(
    VAR TDSNatureDeduction@1055 : Record 13726 TDSNatureDeduction, //Reference parameter of type Record
    VAR TDSSetup@1500002 : Record 13728 TDSSetup, //Reference parameter of type Record
    TDSGroup@1056 : Option TDSGroup, //Input parameter of type Option
    AssesseeCode@1057 : Code[10] AssesseeCode, //Input parameter of type Code
    CountryCode@1500000 : Code[10] CountryCode, //Input parameter of type Code
    EffectiveDate@1500001 : Date EffectiveDate //Input parameter of type Date
);

Parameters

TDSNatureDeduction
Reference parameter of type Record
TDSSetup
Reference parameter of type Record
TDSGroup
Input parameter of type Option
AssesseeCode
Input parameter of type Code
CountryCode
Input parameter of type Code
EffectiveDate
Input parameter of type Date

Remarks

The relevant search keywords are: Create, TDS, Nature, Deduction, TDS, Setup.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.CreateTDSNatureDeduction(TDSNatureDeduction);
      TDSNatureDeduction.VALIDATE("TDS Group",TDSGroup);
      TDSNatureDeduction.MODIFY(TRUE);
      CreateTDSSetupWithCountry(TDSSetup,TDSNatureDeduction.Code,AssesseeCode,CountryCode,EffectiveDate);

Example

The below example is extracted from the test automation codeunit 144025 to show one way of using this function.

      // [SCENARIO 164277] Created Setup, Posted Purchase Order with Work Tax and TDS Threshold Amount with PANAPPLIED for Vendor.
      // [FEATURE] [TDS][Purchase Order]
      Initialize;

      // [GIVEN] Created Setup for NOD/NOC, Assessee Code,TDS Setup with TDS Threshold Amount and Non-PAN Vendor.
      CreateIncomeTaxAccountingPeriod;
      Amount := LibraryRandom.RandDec(10000,2);
      LibraryERM.CreateAssesseeCode(AssesseeCode);
      LibraryTDS.CreateTDSNatureDeductionAndTDSSetup(
        TdsNatureOfDeduction,TDSSetup,TdsNatureOfDeduction."TDS Group"::Others,AssesseeCode.Code,'',WORKDATE);
      LibraryTDS.CreateNODNOCSetupforTDS(
        NodNocHeader,NodNocHeader.Type::Vendor,CreateVendorWithLocation('',TRUE),AssesseeCode.Code,TdsNatureOfDeduction.Code);
      UpdateNODNOCLines(NodNocHeader,FALSE,FALSE,TRUE);
      UpdateThresholdLimit(TDSGroup,TdsNatureOfDeduction."TDS Group");

      // [WHEN] Create & Post Purchase Invoice
      CreatePurchaseOrder(
        PurchaseHeader,PurchaseLine,PurchaseHeader."Document Type"::Order,NodNocHeader."No.",'',TdsNatureOfDeduction.Code,Amount);
      PurchaseLine.CalculateTDS(PurchaseHeader);
      CalcTDSAmountsFromBase(ExpectedTDSEntry,TDSSetup,PurchaseLine.Amount,FALSE,TRUE);
      VerifyPurchaseOrderStatistics(ExpectedTDSEntry,PurchaseLine);
      DocumentNo := LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

      // [THEN] 3 GL Entries are created and posted to TDS Account.
      VerifyGLEntryCount(DocumentNo,3);
      VerifyGLEntryWithTDSAccount(DocumentNo,TDSGroup."TDS Account",-ExpectedTDSEntry."Work Tax Amount");
Member of Miscellaneous.Library - TDS


CreateTDSSetup@1500010 Method

The procedure CreateTDSSetup is available in codeunit 143000.

Syntax

CreateTDSSetup@1500010(
    VAR TDSSetup@1500000 : Record 13728 TDSSetup, //Reference parameter of type Record
    TDSNatureDeduction@1500001 : Code[10] TDSNatureDeduction, //Input parameter of type Code
    AssesseeCode@1500002 : Code[10] AssesseeCode, //Input parameter of type Code
    EffectiveDate@1500003 : Date EffectiveDate, //Input parameter of type Date
    ConcessionalCode@1500004 : Code[10] ConcessionalCode, //Input parameter of type Code
    NatureOfRemittance@1170000000 : Code[10] NatureOfRemittance, //Input parameter of type Code
    ActApplicable@1170000001 : Option ActApplicable, //Input parameter of type Option
    CountryCode@1170000002 : Code[10] CountryCode //Input parameter of type Code
);

Parameters

TDSSetup
Reference parameter of type Record
TDSNatureDeduction
Input parameter of type Code
AssesseeCode
Input parameter of type Code
EffectiveDate
Input parameter of type Date
ConcessionalCode
Input parameter of type Code
NatureOfRemittance
Input parameter of type Code
ActApplicable
Input parameter of type Option
CountryCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, TDS, Setup.

For a clarification about how this function works, refer to the code listed below.

      WITH TDSSetup DO BEGIN
        INIT;
        VALIDATE("TDS Nature of Deduction",TDSNatureDeduction);
        VALIDATE("Assessee Code",AssesseeCode);
        VALIDATE("Effective Date",EffectiveDate);
        VALIDATE("Concessional Code",ConcessionalCode);
        VALIDATE("Nature of Remittance",NatureOfRemittance);
        VALIDATE("Act Applicable",ActApplicable);
        VALIDATE("Country Code",CountryCode);
        INSERT(TRUE);
      END;

Example

The below example is extracted from the test automation codeunit 144020 to show one way of using this function.

      LibraryERM.CreateTDSNatureDeduction(TDSNatureDeduction);
      TDSNatureDeduction.VALIDATE("TDS Group",TDSGroup);
      TDSNatureDeduction.MODIFY(TRUE);
      IF TDSNatureDeduction."TDS Group" = TDSNatureDeduction."TDS Group"::"Payable to Non Residents" THEN BEGIN
        LibraryTDS.CreateTDSSetup(TDSSetup,TDSNatureDeduction.Code,AssesseeCode,TODAY,'','',0,CountryCode);
        TDSSetup.VALIDATE("TDS %",LibraryRandom.RandInt(5));
        TDSSetup.VALIDATE("Non PAN TDS %",LibraryRandom.RandInt(5));
        TDSSetup.VALIDATE("Surcharge %",LibraryRandom.RandInt(5));
        TDSSetup.VALIDATE("eCESS %",LibraryRandom.RandInt(5));
        TDSSetup.MODIFY(TRUE);
      END;
Member of Miscellaneous.Library - TDS


CreateTDSSetupWithCountry@1500016 Method

The procedure CreateTDSSetupWithCountry is available in codeunit 143000.

Syntax

CreateTDSSetupWithCountry@1500016(
    VAR TDSSetup@1500002 : Record 13728 TDSSetup, //Reference parameter of type Record
    TDSNatureDeductionCode@1500001 : Code[10] TDSNatureDeductionCode, //Input parameter of type Code
    AssesseeCode@1500000 : Code[10] AssesseeCode, //Input parameter of type Code
    CountryCode@1500003 : Code[10] CountryCode, //Input parameter of type Code
    EffectiveDate@1500004 : Date EffectiveDate //Input parameter of type Date
);

Parameters

TDSSetup
Reference parameter of type Record
TDSNatureDeductionCode
Input parameter of type Code
AssesseeCode
Input parameter of type Code
CountryCode
Input parameter of type Code
EffectiveDate
Input parameter of type Date

Remarks

The relevant search keywords are: Create, TDS, Setup, Country.

For a clarification about how this function works, refer to the code listed below.

      CreateTDSSetup(TDSSetup,TDSNatureDeductionCode,AssesseeCode,EffectiveDate,'','',TDSSetup."Act Applicable",CountryCode);
      TDSSetup.VALIDATE("TDS %",LibraryRandom.RandInt(5));
      TDSSetup.VALIDATE("Non PAN TDS %",LibraryRandom.RandInt(5));
      TDSSetup.VALIDATE("Surcharge %",LibraryRandom.RandInt(5));
      TDSSetup.VALIDATE("eCESS %",LibraryRandom.RandInt(5));
      TDSSetup.VALIDATE("SHE Cess %",LibraryRandom.RandInt(5));
      TDSSetup.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 144052 to show one way of using this function.

      LibraryERM.CreateTDSNatureDeduction(TDSNatureDeduction);
      TDSNatureDeduction.VALIDATE("TDS Group",TDSGroup);
      TDSNatureDeduction.MODIFY(TRUE);
      LibraryTDS.CreateTDSSetupWithCountry(TDSSetup,TDSNatureDeduction.Code,AssesseeCode,CountryCode,EffectiveDate);
Member of Miscellaneous.Library - TDS


CreateTDSTCSFiscalYear@1500007 Method

The procedure CreateTDSTCSFiscalYear is available in codeunit 143000.

Syntax

CreateTDSTCSFiscalYear@1500007(
    VAR IncomeTaxAccountingPeriod@1500000 : Record 13724 IncomeTaxAccountingPeriod, //Reference parameter of type Record
    StartingDate@1500001 : Date StartingDate //Input parameter of type Date
);

Parameters

IncomeTaxAccountingPeriod
Reference parameter of type Record
StartingDate
Input parameter of type Date

Remarks

The relevant search keywords are: Create, TDSTCS, Fiscal, Year.

For a clarification about how this function works, refer to the code listed below.

      CreateTDSTCSFiscalYear.InitializeRequest(StartingDate,CALCDATE('<1Y-1D>',StartingDate));
      CreateTDSTCSFiscalYear.USEREQUESTPAGE(FALSE);
      CreateTDSTCSFiscalYear.RUN;

      IncomeTaxAccountingPeriod.SETRANGE("Starting Date",StartingDate);
      IncomeTaxAccountingPeriod.FINDLAST;

Example

There are no examples available.
Member of Miscellaneous.Library - TDS


CreateVendorWithPostingSetup@1500023 Method

The procedure CreateVendorWithPostingSetup is available in codeunit 143000.

Syntax

CreateVendorWithPostingSetup@1500023(
      //param element not supplied
);

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Vendor, Posting, Setup.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.CreateGenBusPostingGroup(GenBusPostingGroup);
      LibraryERM.CreateGenProdPostingGroup(GenProductPostingGroup);
      LibraryERM.CreateGeneralPostingSetup(GeneralPostingSetup,GenBusPostingGroup.Code,GenProductPostingGroup.Code);
      LibraryPurchase.CreateVendor(Vendor);
      Vendor.VALIDATE("Gen. Bus. Posting Group",GeneralPostingSetup."Gen. Bus. Posting Group");
      Vendor.VALIDATE("P.A.N. No.",LibraryUtility.GenerateRandomCode(Vendor.FIELDNO("P.A.N. No."),DATABASE::Vendor));
      Vendor.MODIFY(TRUE);
      EXIT(Vendor."No.");

Example

There are no examples available.
Member of Miscellaneous.Library - TDS


Form26QForm27QReportFieldsValidation@1500017 Method

The procedure Form26QForm27QReportFieldsValidation is available in codeunit 143000.

Syntax

Form26QForm27QReportFieldsValidation@1500017(
      //param element not supplied
);

Remarks

The relevant search keywords are: Form26Q, Form27Q, Report, Fields, Validation.

For a clarification about how this function works, refer to the code listed below.

      CompanyInfo.GET;
      WITH CompanyInfo DO BEGIN
        VALIDATE("Phone No.",PhoneNoTxt);
        VALIDATE("E-Mail",EmailTxt);
        VALIDATE("Location Code",LocationTxt);
        VALIDATE(Address,AddressTxt);
        MODIFY(TRUE);
        Location.GET("Location Code");
        Location.VALIDATE("T.A.N. No.","T.A.N. No.");
        Location.MODIFY(TRUE);
        COMMIT;
      END;

Example

The below example is extracted from the test automation codeunit 144047 to show one way of using this function.

      ConcessionalCode := SetupTDSNatureWithNODNOC(
        NODNOCHeader,TDSNatureOfDeduction,TDSNatureOfDeduction2,CurrencyCode,
        TRUE,Transporter,LibraryRandom.RandInt(5),0,TDSNatureOfDeductionTDSGroup,NODNOCLines,NODNOCLines2);
      PostedDocumentNo := PostPurchaseDocWithAndWithoutTDSAmount(
        NODNOCHeader."No.",Amount,Amount2,TDSNatureOfDeduction.Code,TDSNatureOfDeduction2.Code,NODNOCLines,NODNOCLines2);
      UpdateChallanDetailsAfterTDSPayment(PostedDocumentNo,TDSNatureOfDeduction."TDS Group");
      RunGenerateCertificateNos(NODNOCHeader."No.",TDSNatureOfDeduction."TDS Group",IncomeTaxAccountingPeriod."Starting Date");
      EnqueueValuesInFormReqPageHandlers(IncomeTaxAccountingPeriod."Financial Year for eTDS/TCS");
      PANNo := LibraryUtility.GenerateRandomCode(Vendor.FIELDNO("P.A.N. No."),DATABASE::Vendor);
      LibraryTDS.Form26QForm27QReportFieldsValidation;
      REPORT.RUN(ReportID);
Member of Miscellaneous.Library - TDS


GetFormNo@1500031 Method

The procedure GetFormNo is available in codeunit 143000.

Syntax

GetFormNo@1500031(
    Resident@1500000 : Boolean Resident //Input parameter of type Boolean
);

Parameters

Resident
Input parameter of type Boolean

Return Value

Integer

Remarks

The relevant search keywords are: Get, Form, No.

For a clarification about how this function works, refer to the code listed below.

      IF Resident THEN
        EXIT(BatchHeader."Form No."::"26Q");
      EXIT(BatchHeader."Form No."::"27Q");

Example

The below example is extracted from the test automation codeunit 144053 to show one way of using this function.

      LibraryVariableStorage.Enqueue(CompanyInformation."T.A.N. No.");
      LibraryVariableStorage.Enqueue(FinancialYearForeTDSTCS);
      FileName := FileManagement.ServerTempFileName('.txt');
      LibraryVariableStorage.Enqueue(FileName);
      GenerateeTDS.OPENEDIT;
      GenerateeTDS.FormNo.SETVALUE(LibraryTDS.GetFormNo(Resident));
      GenerateeTDS.eTDS.INVOKE;
Member of Miscellaneous.Library - TDS


GetPostedTDSAmount@1500018 Method

The procedure GetPostedTDSAmount is available in codeunit 143000.

Syntax

GetPostedTDSAmount@1500018(
    DocumentNo@1500001 : Code[20] DocumentNo, //Input parameter of type Code
    TDSAccountNo@1500000 : Code[20] TDSAccountNo //Input parameter of type Code
);

Parameters

DocumentNo
Input parameter of type Code
TDSAccountNo
Input parameter of type Code

Return Value

Decimal

Remarks

The relevant search keywords are: Get, Posted, TDS, Amount.

For a clarification about how this function works, refer to the code listed below.

      TDSEntry.SETRANGE("Pay TDS Document No.",DocumentNo);
      TDSEntry.SETRANGE("Account No.",TDSAccountNo);
      TDSEntry.SETRANGE("TDS Paid",FALSE);
      IF TDSEntry.FINDSET THEN
        REPEAT
          Amount := Amount + TDSEntry."Bal. TDS Including SHE CESS";
        UNTIL TDSEntry.NEXT = 0;
      EXIT(Amount);

Example

The below example is extracted from the test automation codeunit 144076 to show one way of using this function.

      LibraryERM.CreateGenJournalTemplate(GenJournalTemplate);
      GenJournalTemplate.VALIDATE(Type,GenJournalTemplate.Type::Payments);
      GenJournalTemplate.MODIFY(TRUE);
      LibraryERM.CreateGenJournalBatch(GenJournalBatch,GenJournalTemplate.Name);
      WITH GenJournalLine DO BEGIN
        LibraryERM.CreateGeneralJnlLineWithBalAcc(
          GenJournalLine,GenJournalTemplate.Name,GenJournalBatch.Name,"Document Type"::Payment,
          "Account Type"::"G/L Account",TDSAccount,"Bal. Account Type"::"Bank Account",
          LibraryERM.CreateBankAccountNo,0);
        VALIDATE("Posting Date",IncomeTaxAccountingPeriod."Starting Date");
        VALIDATE("T.A.N. No.",CompanyInformation."T.A.N. No.");
        MODIFY(TRUE);
        LibraryTDS.PayTDS(GenJournalLine);
      END;
      Amount := LibraryTDS.GetPostedTDSAmount(GenJournalLine."Document No.",TDSAccount);
Member of Miscellaneous.Library - TDS


PayTDS@1500034 Method

The procedure PayTDS is available in codeunit 143000.

Syntax

PayTDS@1500034(
    VAR GenJournalLine@1500000 : Record 81 GenJournalLine //Reference parameter of type Record
);

Parameters

GenJournalLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Pay, TDS.

For a clarification about how this function works, refer to the code listed below.

      WITH GenJournalLine DO BEGIN
        TESTFIELD("Document No.");
        TESTFIELD("Account No.");
        TESTFIELD("T.A.N. No.");
        "Pay TDS" := TRUE;
        MODIFY;
        TDSEntry.RESET;
        TDSEntry.SETRANGE("Account No.","Account No.");
        TDSEntry.SETRANGE("T.A.N. No.","T.A.N. No.");
        TDSEntry.SETFILTER("Total TDS Including SHE CESS",'<>%1',0);
        TDSEntry.SETRANGE("TDS Paid",FALSE);
        TDSEntry.SETRANGE(Reversed,FALSE);
        IF TDSEntry.FINDFIRST THEN BEGIN
          PayTDS1.SetBatch("Journal Batch Name","Journal Template Name","Line No.");
          PayTDS1.PayTDS(TDSEntry)
        END;
      END;

Example

The below example is extracted from the test automation codeunit 144013 to show one way of using this function.

      CreateGeneralJournalBatch(GenJournalBatch,TemplateType,TemplateSubtype);
      LibraryERM.CreateGeneralJnlLine(GenJournalLine,GenJournalBatch."Journal Template Name",GenJournalBatch.Name,
        GenJournalLine."Document Type"::Payment,GenJournalLine."Account Type"::"G/L Account",
        GetTDSAccount(TDSNatureOfDeduction."TDS Group"),LibraryRandom.RandIntInRange(5000,6000));
      GenJournalLine.VALIDATE("Posting Date",IncomeTaxAccountingPeriod."Starting Date");
      GenJournalLine.VALIDATE("T.A.N. No.",CompanyInformation."T.A.N. No.");
      GenJournalLine.VALIDATE("Bal. Account Type",GenJournalLine."Bal. Account Type"::"Bank Account");
      GenJournalLine.VALIDATE("Bal. Account No.",LibraryERM.CreateBankAccountNo);
      GenJournalLine.MODIFY(TRUE);
      LibraryTDS.PayTDS(GenJournalLine);
      TDSEntry.SETRANGE("Document No.",JournalDocNo);
      TDSEntry.FINDSET;
      REPEAT
        PayTDSAmount += TDSEntry."Total TDS Including SHE CESS";
      UNTIL TDSEntry.NEXT = 0;
      GenJournalLine1.SETRANGE("Document No.",GenJournalLine."Document No.");
      GenJournalLine1.FINDFIRST;
      Assert.AreEqual(PayTDSAmount,GenJournalLine1.Amount,AmountErr);
      LibraryERM.PostGeneralJnlLine(GenJournalLine1);
      EXIT(GenJournalLine1."Document No.");
Member of Miscellaneous.Library - TDS


RoundTCSAmount@1500257 Method

The procedure RoundTCSAmount is available in codeunit 143000.

Syntax

RoundTCSAmount@1500257(
    TCSAmount@1500000 : Decimal TCSAmount //Input parameter of type Decimal
);

Parameters

TCSAmount
Input parameter of type Decimal

Return Value

Decimal

Remarks

The relevant search keywords are: Round, TCS, Amount.

For a clarification about how this function works, refer to the code listed below.

      GLSetup.GET;
      WITH GLSetup DO BEGIN
        CASE "TCS Rounding Type" OF
          "TCS Rounding Type"::Nearest:
            TCSRoundingDirection := '=';
          "TCS Rounding Type"::Up:
            TCSRoundingDirection := '>';
          "TCS Rounding Type"::Down:
            TCSRoundingDirection := '<';
        END;

        IF "TCS Rounding Precision" <> 0 THEN
          TCSRoundingPrecision := "TCS Rounding Precision"
        ELSE
          TCSRoundingPrecision := 1;

        EXIT(ROUND(TCSAmount,TCSRoundingPrecision,TCSRoundingDirection));
      END;

Example

The below example is extracted from the test automation codeunit 144012 to show one way of using this function.

      SalesLine.SETRANGE("Document No.",SalesHeader."No.");
      SalesLine.FINDSET;
      REPEAT
        ExpectedTCSAmount += SalesLine."TDS/TCS Base Amount" * TCSSetup."TCS %" / 100;
      UNTIL SalesLine.NEXT = 0;
      ExpectedTCSAmount += ExpectedTCSAmount * TCSSetup."Surcharge %" / 100;
      ExpectedTCSAmount += ExpectedTCSAmount * TCSSetup."eCESS %" / 100 + ExpectedTCSAmount * TCSSetup."SHE Cess %" / 100;
      ExpectedTCSAmount := LibraryTDS.RoundTCSAmount(ExpectedTCSAmount);
      SalesOrderStatistics.OPENVIEW;
      SalesOrderStatistics.GOTORECORD(SalesHeader);
      ActualAmount := SalesOrderStatistics.Control1500015.ASDECIMAL;
      Assert.AreNearlyEqual(ExpectedTCSAmount,ActualAmount,GeneralLedgerSetup."TCS Rounding Precision",STRSUBSTNO(AmountErr));
Member of Miscellaneous.Library - TDS


RoundTDS@1500030 Method

The procedure RoundTDS is available in codeunit 143000.

Syntax

RoundTDS@1500030(
    Amount@1500000 : Decimal Amount //Input parameter of type Decimal
);

Parameters

Amount
Input parameter of type Decimal

Return Value

Decimal

Remarks

The relevant search keywords are: Round, TDS.

For a clarification about how this function works, refer to the code listed below.

      GLSetup.GET;
      EXIT(ROUND(Amount,GLSetup."TDS Rounding Precision"));

Example

The below example is extracted from the test automation codeunit 144020 to show one way of using this function.

      WITH ExpectedTDSEntry DO BEGIN
        "TDS Base Amount" := TaxBaseAmount;
        IF HasPAN THEN
          "TDS Amount" := LibraryTDS.RoundTDS(TDSSetup."TDS %" / 100 * "TDS Base Amount")
        ELSE
          "TDS Amount" := LibraryTDS.RoundTDS(TDSSetup."Non PAN TDS %" / 100 * "TDS Base Amount");
        "Surcharge Amount" := LibraryTDS.RoundTDS(TDSSetup."Surcharge %" / 100 * "TDS Amount");
        "eCESS Amount" := LibraryTDS.RoundTDS(TDSSetup."eCESS %" / 100 * ("TDS Amount" + "Surcharge Amount"));
        "SHE Cess Amount" := LibraryTDS.RoundTDS(TDSSetup."SHE Cess %" / 100 * ("TDS Amount" + "Surcharge Amount"));
        "Total TDS Including SHE CESS" := "TDS Amount" + "eCESS Amount" + "SHE Cess Amount" + "Surcharge Amount";
      END;
Member of Miscellaneous.Library - TDS


RunUpdateChallanRegister@1500217 Method

The procedure RunUpdateChallanRegister is available in codeunit 143000.

Syntax

RunUpdateChallanRegister@1500217(
    ChallanNo@1501000 : Code[20] ChallanNo, //Input parameter of type Code
    UpdatedTDSAmount@1500001 : Decimal UpdatedTDSAmount //Input parameter of type Decimal
);

Parameters

ChallanNo
Input parameter of type Code
UpdatedTDSAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Run, Update, Challan, Register.

For a clarification about how this function works, refer to the code listed below.

      ChallanRegister.SETRANGE("Challan No.",ChallanNo);
      ChallanRegister.FINDFIRST;
      COMMIT;
      UpdateChallanRegister.SETTABLEVIEW(ChallanRegister);
      UpdateChallanRegister.UpdateChallan(UpdatedTDSAmount,UpdatedTDSAmount,UpdatedTDSAmount,ChallanRegister."Entry No.");
      UpdateChallanRegister.USEREQUESTPAGE(FALSE);
      UpdateChallanRegister.RUNMODAL;

Example

The below example is extracted from the test automation codeunit 144013 to show one way of using this function.

      // [SCENARIO 164365] Generation of e-TDS (26Q) in file format
      // [FEATURE] [eTDS Transactions]

      // [GIVEN] Created TDS Setup
      Initialize;

      // [WHEN] Pay TDS and Generate Form 26Q and Generate E-TDS 26Q
      CreateJournalForTDSPaymentWithBalAcc(
        GenJournalLine,GenJournalTemplate.Type::General,GenJournalTemplate."Sub Type"::"Bank Payment Voucher");
      PayDocNo := PayTDSBank(GenJournalLine."Document No.");
      ChallanNo := LibraryTDS.UpdateChallanDetails(GenJournalLine."Document No.",PayDocNo,IncomeTaxAccountingPeriod."Starting Date");
      LibraryTDS.RunUpdateChallanRegister(ChallanNo,
        LibraryRandom.RandIntInRange(10000,20000));
      UpdateCompanyEmailandLocation;
      COMMIT;
      REPORT.RUN(REPORT::"Form 26Q");
      FileName := TEMPORARYPATH + LibraryUtility.GenerateGUID + '.txt';
      LibraryVariableStorage.Enqueue(FileName);
      COMMIT;
      BatchHeader.SETRANGE("Form No.",FormNo);
      REPORT.RUN(REPORT::"Generate e-TDS",TRUE,FALSE,BatchHeader);

      // [THEN] Verify Generated Values
      VerifyValuesOnBatchHeader(FormNo::"26Q",CompanyInformation."T.A.N. No.");
Member of Miscellaneous.Library - TDS


SetInclServTaxOptionInGenJnl@1500014 Method

The procedure SetInclServTaxOptionInGenJnl is available in codeunit 143000.

Syntax

SetInclServTaxOptionInGenJnl@1500014(
    VAR GenJournalLine@1500001 : Record 81 GenJournalLine, //Reference parameter of type Record
    Value@1500000 : Boolean Value //Input parameter of type Boolean
);

Parameters

GenJournalLine
Reference parameter of type Record
Value
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, Incl, Serv, Tax, Option, In, General, Journal.

For a clarification about how this function works, refer to the code listed below.

      GenJournalLine.VALIDATE("Include Serv. Tax in TDS Base",Value);
      GenJournalLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;

      // Setup
      ServiceTaxTDSHelper.CreateAdvPmtPoT(GenJournalLine);
      LibraryTDS.SetInclServTaxOptionInGenJnl(GenJournalLine,TRUE);
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // Exercise
      ServiceTaxTDSHelper.ApplyAndPostInvoiceDoc(GenJournalLine);

      // Verify
      ServiceTaxTDSHelper.VerifyTDSPostingAppliedInvoice(GenJournalLine,TRUE);
Member of Miscellaneous.Library - TDS


SetInclServTaxOptionInStruct@1500009 Method

The procedure SetInclServTaxOptionInStruct is available in codeunit 143000.

Syntax

SetInclServTaxOptionInStruct@1500009(
    Structure@1500001 : Code[10] Structure, //Input parameter of type Code
    Value@1500000 : Boolean Value //Input parameter of type Boolean
);

Parameters

Structure
Input parameter of type Code
Value
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, Incl, Serv, Tax, Option, In, Struct.

For a clarification about how this function works, refer to the code listed below.

      StructureDetails.SETFILTER(Code,Structure);
      StructureDetails.MODIFYALL("Include in TDS Base",Value);

Example

There are no examples available.
Member of Miscellaneous.Library - TDS


UpdateChallanDetails@1500038 Method

The procedure UpdateChallanDetails is available in codeunit 143000.

Syntax

UpdateChallanDetails@1500038(
    DocNo@1500005 : Code[20] DocNo, //Input parameter of type Code
    PaymentDocNo@1500000 : Code[20] PaymentDocNo, //Input parameter of type Code
    ChallanDate@1500001 : Date ChallanDate //Input parameter of type Date
);

Parameters

DocNo
Input parameter of type Code
PaymentDocNo
Input parameter of type Code
ChallanDate
Input parameter of type Date

Return Value

Code[5]

Remarks

The relevant search keywords are: Update, Challan, Details.

For a clarification about how this function works, refer to the code listed below.

      WITH TDSEntry DO BEGIN
        SETFILTER("Document No.",DocNo);
        FINDFIRST;
        ChallanNo := FORMAT(LibraryRandom.RandInt(1000));
        UpdateChallanDetails.InitializeRequest(PaymentDocNo,ChallanNo,ChallanDate,
          LibraryUtility.GenerateGUID,COPYSTR(LibraryUtility.GenerateGUID,1,7),LibraryUtility.GenerateGUID,
          ChallanDate,1);
        UpdateChallanDetails.USEREQUESTPAGE(FALSE);
        UpdateChallanDetails.RUN;
      END;
      EXIT(ChallanNo);

Example

The below example is extracted from the test automation codeunit 144013 to show one way of using this function.

      // [SCENARIO 164365] Generation of e-TDS (26Q) in file format
      // [FEATURE] [eTDS Transactions]

      // [GIVEN] Created TDS Setup
      Initialize;

      // [WHEN] Pay TDS and Generate Form 26Q and Generate E-TDS 26Q
      CreateJournalForTDSPaymentWithBalAcc(
        GenJournalLine,GenJournalTemplate.Type::General,GenJournalTemplate."Sub Type"::"Bank Payment Voucher");
      PayDocNo := PayTDSBank(GenJournalLine."Document No.");
      ChallanNo := LibraryTDS.UpdateChallanDetails(GenJournalLine."Document No.",PayDocNo,IncomeTaxAccountingPeriod."Starting Date");
      LibraryTDS.RunUpdateChallanRegister(ChallanNo,
        LibraryRandom.RandIntInRange(10000,20000));
      UpdateCompanyEmailandLocation;
      COMMIT;
      REPORT.RUN(REPORT::"Form 26Q");
      FileName := TEMPORARYPATH + LibraryUtility.GenerateGUID + '.txt';
      LibraryVariableStorage.Enqueue(FileName);
      COMMIT;
      BatchHeader.SETRANGE("Form No.",FormNo);
      REPORT.RUN(REPORT::"Generate e-TDS",TRUE,FALSE,BatchHeader);

      // [THEN] Verify Generated Values
      VerifyValuesOnBatchHeader(FormNo::"26Q",CompanyInformation."T.A.N. No.");
Member of Miscellaneous.Library - TDS


UpdateNODNOCLines@1500046 Method

The procedure UpdateNODNOCLines is available in codeunit 143000.

Syntax

UpdateNODNOCLines@1500046(
    VAR NODNOCLines@1500004 : Record 13785 NODNOCLines, //Reference parameter of type Record
    Type@1500003 : Option Type, //Input parameter of type Option
    ThresholdOverlook@1500002 : Boolean ThresholdOverlook, //Input parameter of type Boolean
    SurchargeOverlook@1500001 : Boolean SurchargeOverlook, //Input parameter of type Boolean
    MonthlyCertificate@1500000 : Boolean MonthlyCertificate //Input parameter of type Boolean
);

Parameters

NODNOCLines
Reference parameter of type Record
Type
Input parameter of type Option
ThresholdOverlook
Input parameter of type Boolean
SurchargeOverlook
Input parameter of type Boolean
MonthlyCertificate
Input parameter of type Boolean

Remarks

The relevant search keywords are: Update, NODNOC, Lines.

For a clarification about how this function works, refer to the code listed below.

      NODNOCLines.SETRANGE("No.",NODNOCLines."No.");
      NODNOCLines.SETRANGE(Type,Type);
      NODNOCLines.FINDSET;
      NODNOCLines.MODIFYALL("Monthly Certificate",MonthlyCertificate);
      NODNOCLines.MODIFYALL("Threshold Overlook",ThresholdOverlook);
      NODNOCLines.MODIFYALL("Surcharge Overlook",SurchargeOverlook);

Example

The below example is extracted from the test automation codeunit 144025 to show one way of using this function.

      NodNocLines.SETRANGE(Type,NodNocHeader.Type);
      NodNocLines.SETRANGE("No.",NodNocHeader."No.");
      NodNocLines.FINDFIRST;
      LibraryTDS.UpdateNODNOCLines(NodNocLines,NodNocHeader.Type::Vendor,ThresholdOverlook,SurchargeOverlook,MonthlyCertificate);
Member of Miscellaneous.Library - TDS


UpdateTDSNilChallanInGeneralLedgerSetup@1500434 Method

The procedure UpdateTDSNilChallanInGeneralLedgerSetup is available in codeunit 143000.

Syntax

UpdateTDSNilChallanInGeneralLedgerSetup@1500434(
      //param element not supplied
);

Remarks

The relevant search keywords are: Update, TDS, Nil, Challan, In, General, Ledger, Setup.

For a clarification about how this function works, refer to the code listed below.

      WITH GeneralLedgerSetup DO BEGIN
        GET;
        VALIDATE("TDS Nil Challan Nos.",LibraryERM.CreateNoSeriesCode);
        VALIDATE("Nil Pay TDS Document Nos.","TDS Nil Challan Nos.");
        MODIFY(TRUE);
      END;

Example

The below example is extracted from the test automation codeunit 144013 to show one way of using this function.

      LibrarySetupStorage.Restore;
      IF isInitialized THEN
        EXIT;
      GeneralLedgerSetup.GET;
      CompanyInformation.GET;
      LibraryTDS.CreateDeductoryCodeAndUpdateOnCompanyInformation(CompanyInformation);
      LibraryTDS.UpdateTDSNilChallanInGeneralLedgerSetup;
      LibraryTDS.CreateIncomeTaxAccPeriod(IncomeTaxAccountingPeriod);
      LibraryTDS.CreateIncomeTaxPeriod(IncomeTaxPeriodSetup,IncomeTaxAccountingPeriod."No.",1);
      LibraryTDS.CreateAssesseeandNODNOCSetup(
        NodNocHeader,TDSNatureOfDeduction,TDSSetup,'',ServiceTaxWithTDSHelper.CreateVendorWithPANNo,NodNocHeader.Type::Vendor,
        IncomeTaxAccountingPeriod."Starting Date");
      isInitialized := TRUE;
      COMMIT;
      LibrarySetupStorage.Save(DATABASE::"Company Information");
Member of Miscellaneous.Library - TDS


Reverse Service Tax Helper Class

Miscellaneous.Reverse Service Tax Helper

COD143006 applies to ERM,IN.

Methods

Name | Description
AlterServiceTaxGrpInJnlLine@1500067 | The procedure AlterServiceTaxGrpInJnlLine is available in codeunit 143006.
AlterServiceTaxRegNoInJnlLine@1500064 | The procedure AlterServiceTaxRegNoInJnlLine is available in codeunit 143006.
ApplyAndPostVendorEntry@1500055 | The procedure ApplyAndPostVendorEntry is available in codeunit 143006.
CalcDocPoTTotalTaxAmount@1500007 | The procedure CalcDocPoTTotalTaxAmount is available in codeunit 143006.
CalcGenJournalLineServTaxBase@1500024 | The procedure CalcGenJournalLineServTaxBase is available in codeunit 143006.
CalcRemFullTaxAmountOnDocs@1500023 | The procedure CalcRemFullTaxAmountOnDocs is available in codeunit 143006.
CalcSBCandKKCAmounts@1500111 | The procedure CalcSBCandKKCAmounts is available in codeunit 143006.
CalcServTaxAmounts@1500092 | The procedure CalcServTaxAmounts is available in codeunit 143006.
CalcServTaxBaseAmountBackward@1500014 | The procedure CalcServTaxBaseAmountBackward is available in codeunit 143006.
CalcServTaxBaseAmountBackwardNonKKC@1500107 | The procedure CalcServTaxBaseAmountBackwardNonKKC is available in codeunit 143006.
CalcServTaxBaseAmountBackwardWithKKC@1500113 | The procedure CalcServTaxBaseAmountBackwardWithKKC is available in codeunit 143006.
CalcSplitAmounts@1500018 | The procedure CalcSplitAmounts is available in codeunit 143006.
CalcSplitAmountsKKC@1500115 | The procedure CalcSplitAmountsKKC is available in codeunit 143006.
CalculateECess@1500026 | The procedure CalculateECess is available in codeunit 143006.
CalculateKKCAmount@1500106 | The procedure CalculateKKCAmount is available in codeunit 143006.
CalculateKKCess@1500083 | The procedure CalculateKKCess is available in codeunit 143006.
CalculatePayment@1500056 | The procedure CalculatePayment is available in codeunit 143006.
CalculatePoTSBCandKKCAmount@1500108 | The procedure CalculatePoTSBCandKKCAmount is available in codeunit 143006.
CalculatePoTTotalTaxAmount@1500062 | The procedure CalculatePoTTotalTaxAmount is available in codeunit 143006.
CalculatePoTTotalTaxAmountKKC@1500087 | The procedure CalculatePoTTotalTaxAmountKKC is available in codeunit 143006.
CalculateSBC@1500085 | The procedure CalculateSBC is available in codeunit 143006.
CalculateServTax@1500020 | The procedure CalculateServTax is available in codeunit 143006.
CalculateServTaxAmount@1500051 | The procedure CalculateServTaxAmount is available in codeunit 143006.
CalculateServTaxBase@1500057 | The procedure CalculateServTaxBase is available in codeunit 143006.
CalculateServTaxSBCAmount@1500105 | The procedure CalculateServTaxSBCAmount is available in codeunit 143006.
CalculateServTaxTotal@1500033 | The procedure CalculateServTaxTotal is available in codeunit 143006.
CalculateSHECess@1500027 | The procedure CalculateSHECess is available in codeunit 143006.
ConvertDocToJnlLine@1500075 | The procedure ConvertDocToJnlLine is available in codeunit 143006.
CreateAdvancePayment@1500031 | The procedure CreateAdvancePayment is available in codeunit 143006.
CreateAndPostAdvancePayment@1500030 | The procedure CreateAndPostAdvancePayment is available in codeunit 143006.
CreateCustomer@1500079 | The procedure CreateCustomer is available in codeunit 143006.
CreateDocAndApplyAdvPayment@1500032 | The procedure CreateDocAndApplyAdvPayment is available in codeunit 143006.
CreateGenJnllBatchWithBalAcc@1500010 | The procedure CreateGenJnllBatchWithBalAcc is available in codeunit 143006.
CreateGenJournalBatch@1500003 | The procedure CreateGenJournalBatch is available in codeunit 143006.
CreateGLAccount@1 | The procedure CreateGLAccount is available in codeunit 143006.
CreateGLAccountForSales@1500086 | The procedure CreateGLAccountForSales is available in codeunit 143006.
CreateJnlLineWithServiceTax@1170000002 | The procedure CreateJnlLineWithServiceTax is available in codeunit 143006.
CreateJnlLineWithSTNoSetup@1500045 | The procedure CreateJnlLineWithSTNoSetup is available in codeunit 143006.
CreateJournalLine@1500011 | The procedure CreateJournalLine is available in codeunit 143006.
CreateLocation@2 | The procedure CreateLocation is available in codeunit 143006.
CreateNewServGrpForRevChPLine@1500070 | The procedure CreateNewServGrpForRevChPLine is available in codeunit 143006.
CreateNewSRegNoForRevChPLine@1500069 | The procedure CreateNewSRegNoForRevChPLine is available in codeunit 143006.
CreatePayment@1500151 | The procedure CreatePayment is available in codeunit 143006.
CreatePaymentWithOnlineAppl@1500063 | The procedure CreatePaymentWithOnlineAppl is available in codeunit 143006.
CreatePurchaseDoc@1500038 | The procedure CreatePurchaseDoc is available in codeunit 143006.
CreatePurchaseDocForAdvPayment@1500048 | The procedure CreatePurchaseDocForAdvPayment is available in codeunit 143006.
CreatePurchaseDocForVendor@1500036 | The procedure CreatePurchaseDocForVendor is available in codeunit 143006.
CreatePurchaseDocFromGenJnl@1500071 | The procedure CreatePurchaseDocFromGenJnl is available in codeunit 143006.
CreatePurchaseHeader@1500035 | The procedure CreatePurchaseHeader is available in codeunit 143006.
CreatePurchaseHeaderByVendor@1500041 | The procedure CreatePurchaseHeaderByVendor is available in codeunit 143006.
CreatePurchaseLine@5 | The procedure CreatePurchaseLine is available in codeunit 143006.
CreatePurchaseLineWithAmount@1500043 | The procedure CreatePurchaseLineWithAmount is available in codeunit 143006.
CreateSalesDocFromGenJnl@1500093 | The procedure CreateSalesDocFromGenJnl is available in codeunit 143006.
CreateSalesJnlLineNormalPmt@1500061 | The procedure CreateSalesJnlLineNormalPmt is available in codeunit 143006.
CreateSalesJnlLineWithServTax@1500058 | The procedure CreateSalesJnlLineWithServTax is available in codeunit 143006.
CreateServiceTaxGroupAndSetup@1500099 | The procedure CreateServiceTaxGroupAndSetup is available in codeunit 143006.
CreateServiceTaxGroupSetup@1500017 | The procedure CreateServiceTaxGroupSetup is available in codeunit 143006.
CreateServiceTaxSetup@1500059 | The procedure CreateServiceTaxSetup is available in codeunit 143006.
CreateServTaxRegNo@1500019 | The procedure CreateServTaxRegNo is available in codeunit 143006.
CreateSplitDocJnlLine@1500074 | The procedure CreateSplitDocJnlLine is available in codeunit 143006.
CreateSTRevChrgSetupFromJnl@1500004 | The procedure CreateSTRevChrgSetupFromJnl is available in codeunit 143006.
CreateSTRevChrgSetupFromPurch@1500016 | The procedure CreateSTRevChrgSetupFromPurch is available in codeunit 143006.
CreateVendor@8 | The procedure CreateVendor is available in codeunit 143006.
FillExpectedAmntsFullPurchFlow@1500040 | The procedure FillExpectedAmntsFullPurchFlow is available in codeunit 143006.
FillExpectedAmntsRevChrgAppln@1500039 | The procedure FillExpectedAmntsRevChrgAppln is available in codeunit 143006.
FillExpectedAmntsSTEntry@1500037 | The procedure FillExpectedAmntsSTEntry is available in codeunit 143006.
FindCurrencyCode@1500068 | The procedure FindCurrencyCode is available in codeunit 143006.
FindPmtMethodWithBalAcc@1500029 | The procedure FindPmtMethodWithBalAcc is available in codeunit 143006.
GetAmountSignInJournalLine@1500005 | The procedure GetAmountSignInJournalLine is available in codeunit 143006.
GetApplyingDocType@1500012 | The procedure GetApplyingDocType is available in codeunit 143006.
GetBankAccGLPostingAcc@1500065 | The procedure GetBankAccGLPostingAcc is available in codeunit 143006.
GetBaseAmountFromAdvPayment@1500047 | The procedure GetBaseAmountFromAdvPayment is available in codeunit 143006.
GetBaseAmountFromAdvPaymentNonKKC@1500104 | The procedure GetBaseAmountFromAdvPaymentNonKKC is available in codeunit 143006.
GetBaseAmountFromGenJnlLine@1500049 | The procedure GetBaseAmountFromGenJnlLine is available in codeunit 143006.
GetBaseAmountFromGenJnlLineNonKKC@1500114 | The procedure GetBaseAmountFromGenJnlLineNonKKC is available in codeunit 143006.
GetBaseAmountFromGenJnlLineWithKKC@1500112 | The procedure GetBaseAmountFromGenJnlLineWithKKC is available in codeunit 143006.
GetBaseAndTaxAmountFromAdvPmt@1500995 | The procedure GetBaseAndTaxAmountFromAdvPmt is available in codeunit 143006.
GetBaseAndTaxAmountFromAdvPmtNonKKC@1500098 | The procedure GetBaseAndTaxAmountFromAdvPmtNonKKC is available in codeunit 143006.
GetKKCAndSBCmountFromAdvPmt@1500109 | The procedure GetKKCAndSBCmountFromAdvPmt is available in codeunit 143006.
GetKKCExpenseAcc@1500096 | The procedure GetKKCExpenseAcc is available in codeunit 143006.
GetKKCInterimPayAcc@1500094 | The procedure GetKKCInterimPayAcc is available in codeunit 143006.
GetKKCInterimRecAcc@1500090 | The procedure GetKKCInterimRecAcc is available in codeunit 143006.
GetKKCPayAcc@1500077 | The procedure GetKKCPayAcc is available in codeunit 143006.
GetKKCRecAcc@1500073 | The procedure GetKKCRecAcc is available in codeunit 143006.
GetLastTransactionNo@1500008 | The procedure GetLastTransactionNo is available in codeunit 143006.
GetPostingDocType@1500076 | The procedure GetPostingDocType is available in codeunit 143006.
GetPurchInvAmountFactor@1500097 | The procedure GetPurchInvAmountFactor is available in codeunit 143006.
GetRemainingAmount@1500157 | The procedure GetRemainingAmount is available in codeunit 143006.
GetRevChrgPercent@1500091 | The procedure GetRevChrgPercent is available in codeunit 143006.
GetReverseChargeServType@1500066 | The procedure GetReverseChargeServType is available in codeunit 143006.
GetServiceTaxEntryDetail@1500084 | The procedure GetServiceTaxEntryDetail is available in codeunit 143006.
GetServiceTaxReturnPeriod@1500015 | The procedure GetServiceTaxReturnPeriod is available in codeunit 143006.
GetServTaxExpenseAcc@1170000004 | The procedure GetServTaxExpenseAcc is available in codeunit 143006.
GetServTaxInterimPayAcc@1500009 | The procedure GetServTaxInterimPayAcc is available in codeunit 143006.
GetServTaxInterimRecAcc@1500002 | The procedure GetServTaxInterimRecAcc is available in codeunit 143006.
GetServTaxPayAcc@1500006 | The procedure GetServTaxPayAcc is available in codeunit 143006.
GetServTaxRecAcc@1500013 | The procedure GetServTaxRecAcc is available in codeunit 143006.
GetServTaxRoundingPrecision@1500044 | The procedure GetServTaxRoundingPrecision is available in codeunit 143006.
GetServTaxSBCExpenseAcc@1500082 | The procedure GetServTaxSBCExpenseAcc is available in codeunit 143006.
GetServTaxSBCInterimPayAcc@1500081 | The procedure GetServTaxSBCInterimPayAcc is available in codeunit 143006.
GetServTaxSBCInterimRecAcc@1500080 | The procedure GetServTaxSBCInterimRecAcc is available in codeunit 143006.
GetServTaxSBCPayAcc@1500178 | The procedure GetServTaxSBCPayAcc is available in codeunit 143006.
GetServTaxSBCRecAcc@1500179 | The procedure GetServTaxSBCRecAcc is available in codeunit 143006.
GetServTaxType@1500095 | The procedure GetServTaxType is available in codeunit 143006.
GetVendorPostingAccount@1500054 | The procedure GetVendorPostingAccount is available in codeunit 143006.
InvokeForwardStaxCalculation@1500072 | The procedure InvokeForwardStaxCalculation is available in codeunit 143006.
PayServiceTax@1500000 | The procedure PayServiceTax is available in codeunit 143006.
PostEqualAmountSalesDoc@1500088 | The procedure PostEqualAmountSalesDoc is available in codeunit 143006.
PostPayment@1500042 | The procedure PostPayment is available in codeunit 143006.
PostPurchaseDoc@1500001 | The procedure PostPurchaseDoc is available in codeunit 143006.
PostPurchaseDocForVendor@1500100 | The procedure PostPurchaseDocForVendor is available in codeunit 143006.
PostPurchaseDocForVendWithAmt@1500102 | The procedure PostPurchaseDocForVendWithAmt is available in codeunit 143006.
PostPurchaseDocWOServTax@1500103 | The procedure PostPurchaseDocWOServTax is available in codeunit 143006.
PostPurchDocFromGenJnl@1500101 | The procedure PostPurchDocFromGenJnl is available in codeunit 143006.
RandomAmountForSalesDocType@1500060 | The procedure RandomAmountForSalesDocType is available in codeunit 143006.
ReverseDocument@1500052 | The procedure ReverseDocument is available in codeunit 143006.
RoundAmount@1500022 | The procedure RoundAmount is available in codeunit 143006.
RoundServTax@1500021 | The procedure RoundServTax is available in codeunit 143006.
RunGenJnlPostLine@52 | The procedure RunGenJnlPostLine is available in codeunit 143006.
SetupCompanyInfo@13 | The procedure SetupCompanyInfo is available in codeunit 143006.
UnapplyTwice@1500053 | The procedure UnapplyTwice is available in codeunit 143006.
UnapplyVendorLedgerEntry@21 | The procedure UnapplyVendorLedgerEntry is available in codeunit 143006.
UseCreditToPayForSalesDoc@1500050 | The procedure UseCreditToPayForSalesDoc is available in codeunit 143006.

See Also

Miscellaneous


AlterServiceTaxGrpInJnlLine@1500067 Method

The procedure AlterServiceTaxGrpInJnlLine is available in codeunit 143006.

Syntax

AlterServiceTaxGrpInJnlLine@1500067(
    VAR GenJournalLine@1500000 : Record 81 GenJournalLine //Reference parameter of type Record
);

Parameters

GenJournalLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Alter, Service, Tax, Grp, In, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      CreateServiceTaxGroupSetup(ServiceTaxGroup);
      GenJournalLine."Service Tax Group Code" := ServiceTaxGroup.Code;
      CreateSTRevChrgSetupFromJnl(GenJournalLine,ReverseChargeTypeOption::Standard,100);

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      Initialize;

      // Post Advance Payment
      ReverseServiceTaxHelper.CreateAndPostAdvancePayment(GenJournalLine,FALSE,
        ReverseServiceTaxHelper.GetReverseChargeServType(ReverseChargeType::Standard),ReverseChargeType::Standard,100);

      // Create a purchase document with different Service Tax Group Code
      ReverseServiceTaxHelper.AlterServiceTaxGrpInJnlLine(GenJournalLine);

      // Try to apply and post
      ReverseServiceTaxHelper.CreateDocAndApplyAdvPayment(PurchaseHeader,PurchaseLine,GenJournalLine,
        PurchaseDocumentType::Invoice,ReverseChargeType::Standard,100,FALSE,GenJournalLine.Amount);
      ASSERTERROR ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);
      Assert.ExpectedError(ServiceTaxGroupCodeErr);
Member of Miscellaneous.Reverse Service Tax Helper


AlterServiceTaxRegNoInJnlLine@1500064 Method

The procedure AlterServiceTaxRegNoInJnlLine is available in codeunit 143006.

Syntax

AlterServiceTaxRegNoInJnlLine@1500064(
    VAR GenJournalLine@1500000 : Record 81 GenJournalLine //Reference parameter of type Record
);

Parameters

GenJournalLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Alter, Service, Tax, Reg, No, In, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      LibraryServiceTax.CreateServiceTaxRegistrationNo(ServiceTaxRegistrationNos);
      GenJournalLine."Service Tax Registration No." := ServiceTaxRegistrationNos.Code;
      CreateSTRevChrgSetupFromJnl(GenJournalLine,ReverseChargeTypeOption::Standard,100);

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      Initialize;

      // Post Advance Payment
      ReverseServiceTaxHelper.CreateAndPostAdvancePayment(GenJournalLine,FALSE,
        ReverseServiceTaxHelper.GetReverseChargeServType(ReverseChargeType::Standard),ReverseChargeType::Standard,100);

      // Create a purchase document with different Service Tax Registration No.
      ReverseServiceTaxHelper.AlterServiceTaxRegNoInJnlLine(GenJournalLine);

      // Try to apply and post
      ReverseServiceTaxHelper.CreateDocAndApplyAdvPayment(PurchaseHeader,PurchaseLine,GenJournalLine,
        PurchaseDocumentType::Invoice,ReverseChargeType::Standard,100,FALSE,GenJournalLine.Amount);
      ASSERTERROR ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);
      Assert.ExpectedError(ServiceTaxRegNoErr);
Member of Miscellaneous.Reverse Service Tax Helper


ApplyAndPostVendorEntry@1500055 Method

The procedure ApplyAndPostVendorEntry is available in codeunit 143006.

Syntax

ApplyAndPostVendorEntry@1500055(
    DocumentType@1500002 : Option DocumentType, //Input parameter of type Option
    PostedDocNo@1500000 : Code[20] PostedDocNo, //Input parameter of type Code
    AppliedDocumentType@1500005 : Option AppliedDocumentType, //Input parameter of type Option
    AppliedDocNo@1500004 : Code[20] AppliedDocNo //Input parameter of type Code
);

Parameters

DocumentType
Input parameter of type Option
PostedDocNo
Input parameter of type Code
AppliedDocumentType
Input parameter of type Option
AppliedDocNo
Input parameter of type Code

Remarks

The relevant search keywords are: Apply, Post, Vendor, Entry.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.FindVendorLedgerEntry(VendorLedgerEntry,DocumentType,PostedDocNo);
      VendorLedgerEntry.CALCFIELDS("Remaining Amount");
      LibraryERM.SetApplyVendorEntry(VendorLedgerEntry,VendorLedgerEntry."Remaining Amount");

      LibraryERM.FindVendorLedgerEntry(AppliedVendorLedgerEntry,AppliedDocumentType,AppliedDocNo);
      LibraryERM.SetAppliestoIdVendor(AppliedVendorLedgerEntry);

      LibraryERM.PostVendLedgerApplication(VendorLedgerEntry);

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      Initialize;
      ReverseServiceTaxHelper.SetupCompanyInfo;

      PoT := TRUE;
      ReverseServiceTaxHelper.CreateAdvancePayment(AdvPmtGenJnlLine,AdvPmtGenJnlLine."Document Type"::Payment,PoT,0,0,0);

      PostPurchDocEqualToAdvPmt(AdvPmtGenJnlLine,ReverseChargeType::" ",PoT,PurchaseDocumentType::Invoice,InvoiceGenJnlLine);
      ReverseServiceTaxHelper.UseCreditToPayForSalesDoc(InvoiceGenJnlLine."Document No.",ServiceTaxEntryDetails);

      LibraryERM.PostGeneralJnlLine(AdvPmtGenJnlLine);

      ASSERTERROR
        ReverseServiceTaxHelper.ApplyAndPostVendorEntry(
          InvoiceGenJnlLine."Document Type"::Invoice,InvoiceGenJnlLine."Document No.",
          AdvPmtGenJnlLine."Document Type"::Payment,AdvPmtGenJnlLine."Document No.");

      Assert.ExpectedError(STRSUBSTNO(ApplyToPoTUsedCreditErr,InvoiceGenJnlLine."Document No."));
Member of Miscellaneous.Reverse Service Tax Helper


CalcDocPoTTotalTaxAmount@1500007 Method

The procedure CalcDocPoTTotalTaxAmount is available in codeunit 143006.

Syntax

CalcDocPoTTotalTaxAmount@1500007(
    BaseAmount@1500003 : Decimal BaseAmount, //Input parameter of type Decimal
    PoTFactor@1500004 : Decimal PoTFactor, //Input parameter of type Decimal
    ServiceTaxSetup@1500005 : Record 16472 ServiceTaxSetup //Input parameter of type Record
);

Parameters

BaseAmount
Input parameter of type Decimal
PoTFactor
Input parameter of type Decimal
ServiceTaxSetup
Input parameter of type Record

Return Value

Decimal

Remarks

The relevant search keywords are: Calc, Document, Po, T, Total, Tax, Amount.

For a clarification about how this function works, refer to the code listed below.

      ServTaxAmount := ROUND(BaseAmount * ServiceTaxSetup."Service Tax %" / 100);
      ECessAmount := ROUND(ServTaxAmount * ServiceTaxSetup."eCess %" / 100);
      SHECessAmount := ROUND(ServTaxAmount * ServiceTaxSetup."SHE Cess %" / 100);
      EXIT(ROUND((ServTaxAmount + ECessAmount + SHECessAmount) * PoTFactor));

Example

There are no examples available.
Member of Miscellaneous.Reverse Service Tax Helper


CalcGenJournalLineServTaxBase@1500024 Method

The procedure CalcGenJournalLineServTaxBase is available in codeunit 143006.

Syntax

CalcGenJournalLineServTaxBase@1500024(
    Base@1500000 : Decimal Base, //Input parameter of type Decimal
    DocumentType@1500002 : Option DocumentType //Input parameter of type Option
);

Parameters

Base
Input parameter of type Decimal
DocumentType
Input parameter of type Option

Return Value

Decimal

Remarks

The relevant search keywords are: Calc, General, Journal, Line, Serv, Tax, Base.

For a clarification about how this function works, refer to the code listed below.

      Sign := 1;
      IF (DocumentType = GenJournalLine."Document Type"::Refund) OR
         (DocumentType = GenJournalLine."Document Type"::"Credit Memo")
      THEN
        Sign := -1;
      EXIT(Sign * Base);

Example

There are no examples available.
Member of Miscellaneous.Reverse Service Tax Helper


CalcRemFullTaxAmountOnDocs@1500023 Method

The procedure CalcRemFullTaxAmountOnDocs is available in codeunit 143006.

Syntax

CalcRemFullTaxAmountOnDocs@1500023(
    PmtDocumentNo@1500002 : Code[20] PmtDocumentNo, //Input parameter of type Code
    InvDocumentNo@1500000 : Code[20] InvDocumentNo //Input parameter of type Code
);

Parameters

PmtDocumentNo
Input parameter of type Code
InvDocumentNo
Input parameter of type Code

Return Value

Decimal

Remarks

The relevant search keywords are: Calc, Rem, Full, Tax, Amount, On, Docs.

For a clarification about how this function works, refer to the code listed below.

      PmtTaxAmount := CalcFullTaxAmountOnDoc(PmtDocumentNo,FALSE);
      InvTaxAmount := CalcFullTaxAmountOnDoc(InvDocumentNo,FALSE);
      ReversedTaxAmount := CalcFullTaxAmountOnDoc(InvDocumentNo,TRUE);
      IF PmtTaxAmount > InvTaxAmount THEN
        TotalTaxAmount := PmtTaxAmount
      ELSE
        TotalTaxAmount := InvTaxAmount;
      RemainingServiceTaxAmount := TotalTaxAmount + ReversedTaxAmount;

Example

The below example is extracted from the test automation codeunit 144039 to show one way of using this function.

      AdvPmtAndInvPayAdvPmtRCToGov(
        PostedAdvancePaymentDocNo,PostedPurchInvoiceDocNo,ServiceTaxSetup,InvAmountIs,GetReverseChargeType(PoT),PoT);
      RemainingServiceTaxAmount :=
        ReverseServiceTaxHelper.CalcRemFullTaxAmountOnDocs(PostedAdvancePaymentDocNo,PostedPurchInvoiceDocNo);

      PostSalesInvAndTakeCredit(PostedAdvancePaymentDocNo);
Member of Miscellaneous.Reverse Service Tax Helper


CalcSBCandKKCAmounts@1500111 Method

The procedure CalcSBCandKKCAmounts is available in codeunit 143006.

Syntax

CalcSBCandKKCAmounts@1500111(
    GenJournalLine@1500000 : Record 81 GenJournalLine, //Input parameter of type Record
    BaseAmount@1500002 : Decimal BaseAmount, //Input parameter of type Decimal
    VAR PoTAmount@1500003 : Decimal PoTAmount, //Reference parameter of type Decimal
    ServiceTaxSetup@1500005 : Record 16472 ServiceTaxSetup //Input parameter of type Record
);

Parameters

GenJournalLine
Input parameter of type Record
BaseAmount
Input parameter of type Decimal
PoTAmount
Reference parameter of type Decimal
ServiceTaxSetup
Input parameter of type Record

Remarks

The relevant search keywords are: Calc, SB, Cand, KKC, Amounts.

For a clarification about how this function works, refer to the code listed below.

      BaseAmount := GetBaseAmountFromGenJnlLineWithKKC(GenJournalLine);

      PoTPart := (100 - GetRevChrgPercent(GenJournalLine)) / 100;
      PoTAmount := CalculatePoTTotalTaxAmount(BaseAmount,PoTPart,ServiceTaxSetup);

Example

There are no examples available.
Member of Miscellaneous.Reverse Service Tax Helper


CalcServTaxAmounts@1500092 Method

The procedure CalcServTaxAmounts is available in codeunit 143006.

Syntax

CalcServTaxAmounts@1500092(
    GenJournalLine@1500000 : Record 81 GenJournalLine, //Input parameter of type Record
    VAR BaseAmount@1500002 : Decimal BaseAmount, //Reference parameter of type Decimal
    VAR PoTAmount@1500003 : Decimal PoTAmount, //Reference parameter of type Decimal
    ServiceTaxSetup@1500005 : Record 16472 ServiceTaxSetup //Input parameter of type Record
);

Parameters

GenJournalLine
Input parameter of type Record
BaseAmount
Reference parameter of type Decimal
PoTAmount
Reference parameter of type Decimal
ServiceTaxSetup
Input parameter of type Record

Remarks

The relevant search keywords are: Calc, Serv, Tax, Amounts.

For a clarification about how this function works, refer to the code listed below.

      IF BaseAmount = 0 THEN
        BaseAmount := GetBaseAmountFromGenJnlLine(GenJournalLine);

      PoTPart := (100 - GetRevChrgPercent(GenJournalLine)) / 100;
      PoTAmount := CalculatePoTTotalTaxAmount(BaseAmount,PoTPart,ServiceTaxSetup);

Example

There are no examples available.
Member of Miscellaneous.Reverse Service Tax Helper


CalcServTaxBaseAmountBackward@1500014 Method

The procedure CalcServTaxBaseAmountBackward is available in codeunit 143006.

Syntax

CalcServTaxBaseAmountBackward@1500014(
    Amount@1500000 : Decimal Amount, //Input parameter of type Decimal
    ServiceTaxSetup@1500001 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    RevChrgPercentage@1500002 : Integer RevChrgPercentage //Input parameter of type Integer
);

Parameters

Amount
Input parameter of type Decimal
ServiceTaxSetup
Input parameter of type Record
RevChrgPercentage
Input parameter of type Integer

Return Value

Decimal

Remarks

The relevant search keywords are: Calc, Serv, Tax, Base, Amount, Backward.

For a clarification about how this function works, refer to the code listed below.

      IF RevChrgPercentage = 100 THEN
        RevChrgPercentage := 0; // if not split case, the calculation should not be affected by Percentage

      // Given the amount and the service tax setup, calculate the base amount and round it
      WITH ServiceTaxSetup DO BEGIN
        TotalPercent := "Service Tax %" + "SB Cess%" + "KK Cess%";
        BaseAmount :=
          RoundAmount(
            Amount / (1 + (TotalPercent * (1 - RevChrgPercentage / 100) * (1 - "Abatement %" / 100) / 100)));
        AdjustServTaxBaseAmount(BaseAmount,Amount,ServiceTaxSetup,RevChrgPercentage);
      END;

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      ServiceTaxSetup.FindOnDate(PurchaseLine."Service Tax Group",PurchaseHeader."Posting Date");

      IF RevChargeType = ReverseChargeTypeOption::" " THEN
        BaseAmount := ReverseServiceTaxHelper.CalcServTaxBaseAmountBackward(BaseAmount,ServiceTaxSetup,0);

      InvoiceTaxAmount := ReverseServiceTaxHelper.CalculateServTaxAmount(ServiceTaxSetup,BaseAmount,DocumentType);

      FirstPaymentTaxAmount := ReverseServiceTaxHelper.RoundServTax(PartialPaymentFactor * InvoiceTaxAmount);
      SecondPaymentTaxAmount := ReverseServiceTaxHelper.RoundServTax((1 - PartialPaymentFactor) * InvoiceTaxAmount);

      SBCAmount :=
        ReverseServiceTaxHelper.CalculateServTaxSBCAmount(ServiceTaxSetup,BaseAmount,DocumentType);
      KKCAmount :=
        ReverseServiceTaxHelper.CalculateKKCAmount(ServiceTaxSetup,BaseAmount,DocumentType);

      FirstPaymentSBCAmount := ReverseServiceTaxHelper.RoundServTax(PartialPaymentFactor * SBCAmount);
      FirstPaymentKKCAmount := ReverseServiceTaxHelper.RoundServTax(PartialPaymentFactor * KKCAmount);
      SecondPaymentSBCAmount := ReverseServiceTaxHelper.RoundServTax((1 - PartialPaymentFactor) * SBCAmount);
      SecondPaymentKKCAmount := ReverseServiceTaxHelper.RoundServTax((1 - PartialPaymentFactor) * KKCAmount);

      ServiceTaxVerify.CountOfUnappliedEntries(ApplyTransactionNo);

      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDoc,TRUE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedRemainingPayment,TRUE);

      ServiceTaxVerify.UnappPmtRemainSTEntryDetBal(FirstPaymentTaxAmount,SecondPaymentTaxAmount,LastTransactionNo,RevChargeType,PoT);
      ServiceTaxVerify.UnappPmtRemainSTSBCKKCEntryDetBal(FirstPaymentSBCAmount,SecondPaymentSBCAmount,
        FirstPaymentKKCAmount,SecondPaymentKKCAmount,
        LastTransactionNo,RevChargeType,PoT);

      IF RevChargeType = ReverseChargeTypeOption::" " THEN
        ServiceTaxVerify.VendorLedgerEntryRemAmt(
          PostedPurchaseDoc,-((1 - PartialPaymentFactor) * (BaseAmount + InvoiceTaxAmount + SBCAmount + KKCAmount)))
      ELSE
        ServiceTaxVerify.VendorLedgerEntryRemAmt(PostedPurchaseDoc,-((1 - PartialPaymentFactor) * BaseAmount));

      ServiceTaxVerify.PostedPmtAndInvGLBalPartial(
        ServiceTaxSetup,RevChargeType,PoT,InvoiceTaxAmount,FirstPaymentTaxAmount);
      ServiceTaxVerify.PostedSBCKKCPmtAndInvGLBalPartial(
        ServiceTaxSetup,RevChargeType,PoT,SBCAmount,FirstPaymentSBCAmount,KKCAmount,FirstPaymentKKCAmount);
Member of Miscellaneous.Reverse Service Tax Helper


CalcServTaxBaseAmountBackwardNonKKC@1500107 Method

The procedure CalcServTaxBaseAmountBackwardNonKKC is available in codeunit 143006.

Syntax

CalcServTaxBaseAmountBackwardNonKKC@1500107(
    Amount@1500000 : Decimal Amount, //Input parameter of type Decimal
    ServiceTaxSetup@1500001 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    RevChrgPercentage@1500002 : Integer RevChrgPercentage //Input parameter of type Integer
);

Parameters

Amount
Input parameter of type Decimal
ServiceTaxSetup
Input parameter of type Record
RevChrgPercentage
Input parameter of type Integer

Return Value

Decimal

Remarks

The relevant search keywords are: Calc, Serv, Tax, Base, Amount, Backward, Non, KKC.

For a clarification about how this function works, refer to the code listed below.

      IF RevChrgPercentage = 100 THEN
        RevChrgPercentage := 0; // if not split case, the calculation should not be affected by Percentage

      // Given the amount and the service tax setup, calculate the base amount and round it
      WITH ServiceTaxSetup DO
        BaseAmount :=
          RoundAmount(
            Amount / (1 + ("Service Tax %" * (1 - RevChrgPercentage / 100) * (1 - "Abatement %" / 100) / 100)));

Example

There are no examples available.
Member of Miscellaneous.Reverse Service Tax Helper


CalcServTaxBaseAmountBackwardWithKKC@1500113 Method

The procedure CalcServTaxBaseAmountBackwardWithKKC is available in codeunit 143006.

Syntax

CalcServTaxBaseAmountBackwardWithKKC@1500113(
    Amount@1500000 : Decimal Amount, //Input parameter of type Decimal
    ServiceTaxSetup@1500001 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    RevChrgPercentage@1500002 : Integer RevChrgPercentage //Input parameter of type Integer
);

Parameters

Amount
Input parameter of type Decimal
ServiceTaxSetup
Input parameter of type Record
RevChrgPercentage
Input parameter of type Integer

Return Value

Decimal

Remarks

The relevant search keywords are: Calc, Serv, Tax, Base, Amount, Backward, KKC.

For a clarification about how this function works, refer to the code listed below.

      IF RevChrgPercentage = 100 THEN
        RevChrgPercentage := 0; // if not split case, the calculation should not be affected by Percentage

      // Given the amount and the service tax setup, calculate the base amount and round it
      WITH ServiceTaxSetup DO BEGIN
        TotalPercent := "Service Tax %" + "SB Cess%" + "KK Cess%";
        BaseAmount :=
          RoundAmount(
            Amount / (1 + (TotalPercent * (1 - RevChrgPercentage / 100) * (1 - "Abatement %" / 100) / 100)));
      END;

Example

The below example is extracted from the test automation codeunit 144014 to show one way of using this function.

      DummyGLEntry.SETRANGE("Document No.",GenJournalLine."Document No.");
      Assert.RecordCount(DummyGLEntry,8);
      VerifyGLEntry(LibrarySales.GetCustomerAccount(GenJournalLine."Account No."),GenJournalLine."Document No.",
        GenJournalLine.Amount / GenJournalLine."Currency Factor");
      VerifyGLEntryAdditionalCurrencyAmount(LibrarySales.GetCustomerAccount(GenJournalLine."Account No."),
        GenJournalLine."Document No.",GenJournalLine.Amount);
      VerifyGLEntry(ReverseServiceTaxHelper.GetBankAccGLPostingAcc(GenJournalLine."Bal. Account No."),
        GenJournalLine."Document No.",-GenJournalLine.Amount / GenJournalLine."Currency Factor");
      VerifyGLEntryAdditionalCurrencyAmount(ReverseServiceTaxHelper.GetBankAccGLPostingAcc(GenJournalLine."Bal. Account No."),
        GenJournalLine."Document No.",-GenJournalLine.Amount);
      ServTaxBaseAmount := ReverseServiceTaxHelper.CalcServTaxBaseAmountBackwardWithKKC(GenJournalLine.Amount,ServiceTaxSetup,0);
      VerifyGLEntry(ServiceTaxSetup."Service Tax Payable Account",GenJournalLine."Document No.",
        ReverseServiceTaxHelper.CalculateServTax(ServTaxBaseAmount,ServiceTaxSetup) / GenJournalLine."Currency Factor");
      VerifyGLEntryAdditionalCurrencyAmount(ServiceTaxSetup."Service Tax Payable Account",GenJournalLine."Document No.",
        ReverseServiceTaxHelper.CalculateServTax(ServTaxBaseAmount,ServiceTaxSetup));
      VerifyGLEntry(ServiceTaxSetup."Payables Account (Interim)",GenJournalLine."Document No.",-
        ReverseServiceTaxHelper.CalculateServTax(ServTaxBaseAmount,ServiceTaxSetup) / GenJournalLine."Currency Factor");
      VerifyGLEntryAdditionalCurrencyAmount(ServiceTaxSetup."Payables Account (Interim)",GenJournalLine."Document No.",-
        ReverseServiceTaxHelper.CalculateServTax(ServTaxBaseAmount,ServiceTaxSetup));
Member of Miscellaneous.Reverse Service Tax Helper


CalcSplitAmounts@1500018 Method

The procedure CalcSplitAmounts is available in codeunit 143006.

Syntax

CalcSplitAmounts@1500018(
    GenJournalLine@1500000 : Record 81 GenJournalLine, //Input parameter of type Record
    VAR BaseAmount@1500007 : Decimal BaseAmount, //Reference parameter of type Decimal
    VAR PoTAmount@1500003 : Decimal PoTAmount, //Reference parameter of type Decimal
    VAR RevChrgAmount@1500006 : Decimal RevChrgAmount, //Reference parameter of type Decimal
    VAR Percentage@1500008 : Integer Percentage, //Reference parameter of type Integer
    ServiceTaxSetup@1500005 : Record 16472 ServiceTaxSetup //Input parameter of type Record
);

Parameters

GenJournalLine
Input parameter of type Record
BaseAmount
Reference parameter of type Decimal
PoTAmount
Reference parameter of type Decimal
RevChrgAmount
Reference parameter of type Decimal
Percentage
Reference parameter of type Integer
ServiceTaxSetup
Input parameter of type Record

Remarks

The relevant search keywords are: Calc, Split, Amounts.

For a clarification about how this function works, refer to the code listed below.

      Percentage := GetRevChrgPercent(GenJournalLine);
      BaseAmount := GetBaseAmountFromGenJnlLine(GenJournalLine);
      TotalTaxAmount := CalculateServTaxTotal(BaseAmount,ServiceTaxSetup);
      PoTAmount := CalculatePoTTotalTaxAmount(BaseAmount,(100 - Percentage) / 100,ServiceTaxSetup);
      RevChrgAmount := TotalTaxAmount - PoTAmount;

Example

The below example is extracted from the test automation codeunit 144034 to show one way of using this function.

      Initialize;
      ReverseServiceTaxHelper.SetupCompanyInfo;

      // Setup
      Percentage := LibraryRandom.RandIntInRange(10,90);
      ReverseServiceTaxHelper.CreatePurchaseDocFromGenJnl(GenJournalLine,GenJournalLine."Document Type"::Invoice,
        ServiceTypeRevChrg,ReverseChargeTypeOption::Standard,TRUE,Percentage);
      PostedDocNo := GenJournalLine."Document No.";
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      PartialFactor := GetPartialFactor;
      PaymentDocNo := ReverseServiceTaxHelper.PostPayment(GenJournalLine."Account No.",
          PartialFactor * ReverseServiceTaxHelper.CalculatePayment(GenJournalLine."Document Type"::Invoice,ABS(GenJournalLine.Amount),
            ServiceTaxSetup,Percentage),GenJournalLine."Posting Date",GenJournalLine."Document Type"::Payment);

      ReverseServiceTaxHelper.ApplyAndPostVendorEntry(GenJournalLine."Document Type"::Invoice,PostedDocNo,
        GenJournalLine."Document Type"::Payment,PaymentDocNo);

      // Exercise and Verify
      PaymentToGovDocNo :=
        ReverseServiceTaxHelper.PayServiceTax(
          GenJournalLine."Service Tax Registration No.",GenJournalLine."Service Tax Group Code",TRUE);

      // Verify
      ReverseServiceTaxHelper.CalcSplitAmounts(GenJournalLine,BaseAmount,PoTAmount,RevChrgAmount,Percentage,ServiceTaxSetup);
      PoTSBCandKKCAmount :=
        ReverseServiceTaxHelper.CalculatePoTSBCandKKCAmount(BaseAmount,(100 - Percentage) / 100,ServiceTaxSetup);
      ServiceTaxVerify.GLEntriesForSTPmtEntriesForAmt(
        (RevChrgAmount + PoTSBCandKKCAmount) * PartialFactor,ServiceTaxSetup,PaymentToGovDocNo,ServiceTypeRevChrg);

      // Real Service Tax Part - because the Real Service Tax Detail entry is created when posting the invoice for the whole amount
      // so partial factor is 1.
      ServiceTaxVerify.STDetailsAfterPayRCToGovSplit(GenJournalLine."Document No.",BaseAmount,Percentage,
        FALSE,ServiceTaxSetup,1,ServiceTypeRevChrg);
      // Rev charge Service Tax Part
      ServiceTaxVerify.STDetailsAfterPayRCToGovSplit(PaymentDocNo,BaseAmount,Percentage,
        TRUE,ServiceTaxSetup,PartialFactor,ServiceTypeRevChrg);
Member of Miscellaneous.Reverse Service Tax Helper


CalcSplitAmountsKKC@1500115 Method

The procedure CalcSplitAmountsKKC is available in codeunit 143006.

Syntax

CalcSplitAmountsKKC@1500115(
    GenJournalLine@1500000 : Record 81 GenJournalLine, //Input parameter of type Record
    VAR BaseAmount@1500007 : Decimal BaseAmount, //Reference parameter of type Decimal
    VAR PoTAmount@1500003 : Decimal PoTAmount, //Reference parameter of type Decimal
    VAR RevChrgAmount@1500006 : Decimal RevChrgAmount, //Reference parameter of type Decimal
    VAR Percentage@1500008 : Integer Percentage, //Reference parameter of type Integer
    ServiceTaxSetup@1500005 : Record 16472 ServiceTaxSetup //Input parameter of type Record
);

Parameters

GenJournalLine
Input parameter of type Record
BaseAmount
Reference parameter of type Decimal
PoTAmount
Reference parameter of type Decimal
RevChrgAmount
Reference parameter of type Decimal
Percentage
Reference parameter of type Integer
ServiceTaxSetup
Input parameter of type Record

Remarks

The relevant search keywords are: Calc, Split, Amounts, KKC.

For a clarification about how this function works, refer to the code listed below.

      Percentage := GetRevChrgPercent(GenJournalLine);
      BaseAmount := GetBaseAmountFromGenJnlLineWithKKC(GenJournalLine);
      TotalTaxAmount := CalculateServTaxTotal(BaseAmount,ServiceTaxSetup);
      PoTAmount := CalculatePoTTotalTaxAmountKKC(BaseAmount,(100 - Percentage) / 100,ServiceTaxSetup);
      RevChrgAmount := TotalTaxAmount - PoTAmount;

Example

The below example is extracted from the test automation codeunit 144040 to show one way of using this function.

      ServiceTaxSetup.FindOnDate(AdvPmtGenJournalLine."Service Tax Group Code",
        AdvPmtGenJournalLine."Posting Date");
      ReverseServiceTaxHelper.CalcSplitAmountsKKC(AdvPmtGenJournalLine,BaseAmount[1],PoTAmount[1],RevChrgAmount[1],
        Percentage,ServiceTaxSetup);
      ReverseServiceTaxHelper.CalcSplitAmountsKKC(InvGenJournalLine,BaseAmount[2],PoTAmount[2],RevChrgAmount[2],
        Percentage,ServiceTaxSetup);
      ApplnRatio := (BaseAmount[1] + PoTAmount[1]) / (BaseAmount[2] + PoTAmount[2]);
      IF BaseAmount[1] > BaseAmount[2] THEN BEGIN
        ServiceTaxVerify.STPayInterimAccBalance(ServiceTaxSetup,0);
        ServiceTaxVerify.STRecInterimAccBalance(ServiceTaxSetup,RevChrgAmount[1] - PoTAmount[1] + PoTAmount[2]);
        ServiceTaxVerify.STPayAccBalance(ServiceTaxSetup,-RevChrgAmount[1]);
        ServiceTaxVerify.STRecAccBalance(ServiceTaxSetup,PoTAmount[1]);
        VerifySTEntriesAdvPmt(LastTransactionNo,AdvPmtGenJournalLine,BaseAmount[1],FALSE);
      END ELSE BEGIN
        ServiceTaxVerify.STPayInterimAccBalance(
          ServiceTaxSetup,ReverseServiceTaxHelper.RoundServTax((-RevChrgAmount[2] ) * (1 - ApplnRatio)));
        ServiceTaxVerify.STRecInterimAccBalance(
          ServiceTaxSetup,ReverseServiceTaxHelper.RoundServTax(RevChrgAmount[2] * (1 - ApplnRatio) + RevChrgAmount[1]));
        ServiceTaxVerify.STPayAccBalance(ServiceTaxSetup,-RevChrgAmount[1]);
        ServiceTaxVerify.STRecAccBalance(
          ServiceTaxSetup,ReverseServiceTaxHelper.RoundServTax(PoTAmount[2] * (1 - ApplnRatio) + PoTAmount[1]));
        VerifySTEntriesInvoicePartAppl(LastTransactionNo,InvGenJournalLine,BaseAmount[1],BaseAmount[2],FALSE);
      END;
Member of Miscellaneous.Reverse Service Tax Helper


CalculateECess@1500026 Method

The procedure CalculateECess is available in codeunit 143006.

Syntax

CalculateECess@1500026(
    Base@1500000 : Decimal Base, //Input parameter of type Decimal
    ServiceTaxSetup@1500001 : Record 16472 ServiceTaxSetup //Input parameter of type Record
);

Parameters

Base
Input parameter of type Decimal
ServiceTaxSetup
Input parameter of type Record

Return Value

Decimal

Remarks

The relevant search keywords are: Calculate, E, Cess.

For a clarification about how this function works, refer to the code listed below.

      ServiceTax := CalculateServTax(Base,ServiceTaxSetup);
      EXIT(RoundServTax(ServiceTax * ServiceTaxSetup."eCess %" / 100));

Example

The below example is extracted from the test automation codeunit 144038 to show one way of using this function.

      BaseAmount := CalculateFullBaseAmount(GenJournalLine,ServTaxSetup);
      ECessAmount := ReverseServiceTaxHelper.CalculateECess(BaseAmount,ServTaxSetup);
      SHECessAmount := ReverseServiceTaxHelper.CalculateSHECess(BaseAmount,ServTaxSetup);
Member of Miscellaneous.Reverse Service Tax Helper


CalculateKKCAmount@1500106 Method

The procedure CalculateKKCAmount is available in codeunit 143006.

Syntax

CalculateKKCAmount@1500106(
    ServiceTaxSetup@1500001 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    Amount@1500000 : Decimal Amount, //Input parameter of type Decimal
    DocumentType@1500002 : Option DocumentType //Input parameter of type Option
);

Parameters

ServiceTaxSetup
Input parameter of type Record
Amount
Input parameter of type Decimal
DocumentType
Input parameter of type Option

Return Value

Decimal

Remarks

The relevant search keywords are: Calculate, KKC, Amount.

For a clarification about how this function works, refer to the code listed below.

      ServiceTaxBase := CalculateServTaxBase(Amount,DocumentType);
      EXIT(CalculateKKCess(ServiceTaxBase,ServiceTaxSetup));

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      ServiceTaxSetup.FindOnDate(PurchaseLine."Service Tax Group",PurchaseHeader."Posting Date");

      IF RevChargeType = ReverseChargeTypeOption::" " THEN
        BaseAmount := ReverseServiceTaxHelper.CalcServTaxBaseAmountBackward(BaseAmount,ServiceTaxSetup,0);

      InvoiceTaxAmount := ReverseServiceTaxHelper.CalculateServTaxAmount(ServiceTaxSetup,BaseAmount,DocumentType);

      FirstPaymentTaxAmount := ReverseServiceTaxHelper.RoundServTax(PartialPaymentFactor * InvoiceTaxAmount);
      SecondPaymentTaxAmount := ReverseServiceTaxHelper.RoundServTax((1 - PartialPaymentFactor) * InvoiceTaxAmount);

      SBCAmount :=
        ReverseServiceTaxHelper.CalculateServTaxSBCAmount(ServiceTaxSetup,BaseAmount,DocumentType);
      KKCAmount :=
        ReverseServiceTaxHelper.CalculateKKCAmount(ServiceTaxSetup,BaseAmount,DocumentType);

      FirstPaymentSBCAmount := ReverseServiceTaxHelper.RoundServTax(PartialPaymentFactor * SBCAmount);
      FirstPaymentKKCAmount := ReverseServiceTaxHelper.RoundServTax(PartialPaymentFactor * KKCAmount);
      SecondPaymentSBCAmount := ReverseServiceTaxHelper.RoundServTax((1 - PartialPaymentFactor) * SBCAmount);
      SecondPaymentKKCAmount := ReverseServiceTaxHelper.RoundServTax((1 - PartialPaymentFactor) * KKCAmount);

      ServiceTaxVerify.CountOfUnappliedEntries(ApplyTransactionNo);

      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDoc,TRUE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedRemainingPayment,TRUE);

      ServiceTaxVerify.UnappPmtRemainSTEntryDetBal(FirstPaymentTaxAmount,SecondPaymentTaxAmount,LastTransactionNo,RevChargeType,PoT);
      ServiceTaxVerify.UnappPmtRemainSTSBCKKCEntryDetBal(FirstPaymentSBCAmount,SecondPaymentSBCAmount,
        FirstPaymentKKCAmount,SecondPaymentKKCAmount,
        LastTransactionNo,RevChargeType,PoT);

      IF RevChargeType = ReverseChargeTypeOption::" " THEN
        ServiceTaxVerify.VendorLedgerEntryRemAmt(
          PostedPurchaseDoc,-((1 - PartialPaymentFactor) * (BaseAmount + InvoiceTaxAmount + SBCAmount + KKCAmount)))
      ELSE
        ServiceTaxVerify.VendorLedgerEntryRemAmt(PostedPurchaseDoc,-((1 - PartialPaymentFactor) * BaseAmount));

      ServiceTaxVerify.PostedPmtAndInvGLBalPartial(
        ServiceTaxSetup,RevChargeType,PoT,InvoiceTaxAmount,FirstPaymentTaxAmount);
      ServiceTaxVerify.PostedSBCKKCPmtAndInvGLBalPartial(
        ServiceTaxSetup,RevChargeType,PoT,SBCAmount,FirstPaymentSBCAmount,KKCAmount,FirstPaymentKKCAmount);
Member of Miscellaneous.Reverse Service Tax Helper


CalculateKKCess@1500083 Method

The procedure CalculateKKCess is available in codeunit 143006.

Syntax

CalculateKKCess@1500083(
    Base@1500000 : Decimal Base, //Input parameter of type Decimal
    ServiceTaxSetup@1500001 : Record 16472 ServiceTaxSetup //Input parameter of type Record
);

Parameters

Base
Input parameter of type Decimal
ServiceTaxSetup
Input parameter of type Record

Return Value

Decimal

Remarks

The relevant search keywords are: Calculate, KK, Cess.

For a clarification about how this function works, refer to the code listed below.

      EXIT(RoundServTax(Base * ServiceTaxSetup."KK Cess%" / 100));

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      Initialize;

      // Exercise
      PostPmtAppliedToInvPoT(DocumentType,PoT,PurchaseLine,PostedPurchaseDocNo,PostedPaymentDocNo,ServiceTaxSetup);

      // Verify
      BaseAmount := ReverseServiceTaxHelper.CalculateServTaxBase(PurchaseLine."Line Amount",DocumentType);
      Amount := ReverseServiceTaxHelper.CalculateServTaxTotal(BaseAmount,ServiceTaxSetup);
      KKCAmount := ReverseServiceTaxHelper.CalculateKKCess(BaseAmount,ServiceTaxSetup);
      SBCAmount := ReverseServiceTaxHelper.CalculateSBC(BaseAmount,ServiceTaxSetup);
      RevChargeCreditClosed := TRUE;
      RealCreditClosed := FALSE;

      IF PoT THEN
        ServiceTaxVerify.ServiceTaxEntries(PostedPurchaseDocNo,BaseAmount,ServiceTaxSetup,RevChargeCreditClosed,RealCreditClosed)
      ELSE BEGIN
        ServiceTaxVerify.ServTaxEntry(PostedPurchaseDocNo,BaseAmount,ServiceTaxSetup);
        ServiceTaxVerify.ServTaxEntryDetails(PostedPaymentDocNo,BaseAmount,ServiceTaxSetup,RevChargeCreditClosed,RealCreditClosed);
      END;

      ServiceTaxVerify.ServTaxGLAccountsBalance(ServiceTaxSetup,Amount,0,0,0);
      ServiceTaxVerify.KKCGLAccountsBalance(ServiceTaxSetup,KKCAmount,0,0,0);
      ServiceTaxVerify.SBCGLAccountsBalance(ServiceTaxSetup,SBCAmount,0,0,0);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDocNo,FALSE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPaymentDocNo,FALSE);
Member of Miscellaneous.Reverse Service Tax Helper


CalculatePayment@1500056 Method

The procedure CalculatePayment is available in codeunit 143006.

Syntax

CalculatePayment@1500056(
    DocumentType@1500001 : Option DocumentType, //Input parameter of type Option
    LineAmount@1500005 : Decimal LineAmount, //Input parameter of type Decimal
    ServiceTaxSetup@1500002 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    RevChrgPercentage@1500000 : Integer RevChrgPercentage //Input parameter of type Integer
);

Parameters

DocumentType
Input parameter of type Option
LineAmount
Input parameter of type Decimal
ServiceTaxSetup
Input parameter of type Record
RevChrgPercentage
Input parameter of type Integer

Return Value

Decimal

Remarks

The relevant search keywords are: Calculate, Payment.

For a clarification about how this function works, refer to the code listed below.

      Sign := 1;
      IF (DocumentType = PurchaseLine."Document Type"::"Credit Memo") OR
         (DocumentType = PurchaseLine."Document Type"::"Return Order")
      THEN
        Sign := -1;
      EXIT(Sign * (LineAmount + ABS(CalculatePoTTotalTaxAmount(LineAmount,(100 - RevChrgPercentage) / 100,ServiceTaxSetup))));

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      Initialize;

      // Setup:
      ReverseServiceTaxHelper.CreatePurchaseDoc(PurchaseHeader,PurchaseLine,DocumentType,ReverseChargeTypeOption::Standard,100,FALSE);

      // Exercise
      ServiceTaxSetup.FindOnDate(PurchaseLine."Service Tax Group",PurchaseHeader."Posting Date");
      PostedPurchaseDoc := ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);

      PostedPayment := PostAndApplyPayment(PurchaseHeader."Pay-to Vendor No.",
          ReverseServiceTaxHelper.CalculatePayment(PurchaseLine."Document Type",PurchaseLine."Line Amount",ServiceTaxSetup,100),
          PurchaseHeader."Posting Date",ReverseServiceTaxHelper.GetPostingDocType(PurchaseHeader."Document Type"),PostedPurchaseDoc,
          ReverseServiceTaxHelper.GetApplyingDocType(PurchaseHeader."Document Type"));

      // Verify
      BaseAmount := ReverseServiceTaxHelper.CalculateServTaxBase(PurchaseLine."Line Amount",DocumentType);
      Amount := ReverseServiceTaxHelper.CalculateServTaxTotal(BaseAmount,ServiceTaxSetup);
      KKCAmount := ReverseServiceTaxHelper.CalculateKKCess(BaseAmount,ServiceTaxSetup);
      SBCAmount := ReverseServiceTaxHelper.CalculateSBC(BaseAmount,ServiceTaxSetup);

      ServiceTaxVerify.ServTaxGLAccountsBalance(ServiceTaxSetup,0,Amount,-Amount,0);
      ServiceTaxVerify.KKCGLAccountsBalance(ServiceTaxSetup,0,KKCAmount,-KKCAmount,0);
      ServiceTaxVerify.SBCGLAccountsBalance(ServiceTaxSetup,SBCAmount,0,-SBCAmount,0);

      RevChargeCreditClosed := FALSE;
      RealCreditClosed := TRUE;
      ServiceTaxVerify.ServTaxEntryDetails(
        PostedPayment,BaseAmount,ServiceTaxSetup,RevChargeCreditClosed,RealCreditClosed);

      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDoc,FALSE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPayment,FALSE);
Member of Miscellaneous.Reverse Service Tax Helper


CalculatePoTSBCandKKCAmount@1500108 Method

The procedure CalculatePoTSBCandKKCAmount is available in codeunit 143006.

Syntax

CalculatePoTSBCandKKCAmount@1500108(
    BaseAmount@1500003 : Decimal BaseAmount, //Input parameter of type Decimal
    PoTFactor@1500004 : Decimal PoTFactor, //Input parameter of type Decimal
    ServiceTaxSetup@1500005 : Record 16472 ServiceTaxSetup //Input parameter of type Record
);

Parameters

BaseAmount
Input parameter of type Decimal
PoTFactor
Input parameter of type Decimal
ServiceTaxSetup
Input parameter of type Record

Return Value

Decimal

Remarks

The relevant search keywords are: Calculate, Po, TSB, Cand, KKC, Amount.

For a clarification about how this function works, refer to the code listed below.

      PoTSBCAmount := CalculateSBC(BaseAmount,ServiceTaxSetup);
      PoTKKCessAmount := CalculateKKCess(BaseAmount,ServiceTaxSetup);
      EXIT(RoundServTax(PoTSBCAmount * PoTFactor) + RoundServTax(PoTKKCessAmount * PoTFactor));

Example

The below example is extracted from the test automation codeunit 144034 to show one way of using this function.

      Initialize;
      ReverseServiceTaxHelper.SetupCompanyInfo;

      // Setup
      Percentage := LibraryRandom.RandIntInRange(10,90);
      ReverseServiceTaxHelper.CreatePurchaseDocFromGenJnl(GenJournalLine,GenJournalLine."Document Type"::Invoice,
        ServiceTypeRevChrg,ReverseChargeTypeOption::Standard,TRUE,Percentage);
      PostedDocNo := GenJournalLine."Document No.";
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      PartialFactor := GetPartialFactor;
      PaymentDocNo := ReverseServiceTaxHelper.PostPayment(GenJournalLine."Account No.",
          PartialFactor * ReverseServiceTaxHelper.CalculatePayment(GenJournalLine."Document Type"::Invoice,ABS(GenJournalLine.Amount),
            ServiceTaxSetup,Percentage),GenJournalLine."Posting Date",GenJournalLine."Document Type"::Payment);

      ReverseServiceTaxHelper.ApplyAndPostVendorEntry(GenJournalLine."Document Type"::Invoice,PostedDocNo,
        GenJournalLine."Document Type"::Payment,PaymentDocNo);

      // Exercise and Verify
      PaymentToGovDocNo :=
        ReverseServiceTaxHelper.PayServiceTax(
          GenJournalLine."Service Tax Registration No.",GenJournalLine."Service Tax Group Code",TRUE);

      // Verify
      ReverseServiceTaxHelper.CalcSplitAmounts(GenJournalLine,BaseAmount,PoTAmount,RevChrgAmount,Percentage,ServiceTaxSetup);
      PoTSBCandKKCAmount :=
        ReverseServiceTaxHelper.CalculatePoTSBCandKKCAmount(BaseAmount,(100 - Percentage) / 100,ServiceTaxSetup);
      ServiceTaxVerify.GLEntriesForSTPmtEntriesForAmt(
        (RevChrgAmount + PoTSBCandKKCAmount) * PartialFactor,ServiceTaxSetup,PaymentToGovDocNo,ServiceTypeRevChrg);

      // Real Service Tax Part - because the Real Service Tax Detail entry is created when posting the invoice for the whole amount
      // so partial factor is 1.
      ServiceTaxVerify.STDetailsAfterPayRCToGovSplit(GenJournalLine."Document No.",BaseAmount,Percentage,
        FALSE,ServiceTaxSetup,1,ServiceTypeRevChrg);
      // Rev charge Service Tax Part
      ServiceTaxVerify.STDetailsAfterPayRCToGovSplit(PaymentDocNo,BaseAmount,Percentage,
        TRUE,ServiceTaxSetup,PartialFactor,ServiceTypeRevChrg);
Member of Miscellaneous.Reverse Service Tax Helper


CalculatePoTTotalTaxAmount@1500062 Method

The procedure CalculatePoTTotalTaxAmount is available in codeunit 143006.

Syntax

CalculatePoTTotalTaxAmount@1500062(
    BaseAmount@1500003 : Decimal BaseAmount, //Input parameter of type Decimal
    PoTFactor@1500004 : Decimal PoTFactor, //Input parameter of type Decimal
    ServiceTaxSetup@1500005 : Record 16472 ServiceTaxSetup //Input parameter of type Record
);

Parameters

BaseAmount
Input parameter of type Decimal
PoTFactor
Input parameter of type Decimal
ServiceTaxSetup
Input parameter of type Record

Return Value

Decimal

Remarks

The relevant search keywords are: Calculate, Po, T, Total, Tax, Amount.

For a clarification about how this function works, refer to the code listed below.

      ServTaxAmount := CalculateServTax(BaseAmount,ServiceTaxSetup);
      ECessAmount := CalculateECess(BaseAmount,ServiceTaxSetup);
      SHECessAmount := CalculateSHECess(BaseAmount,ServiceTaxSetup);
      SBCAmount := CalculateSBC(BaseAmount,ServiceTaxSetup);
      KKCessAmount := CalculateKKCess(BaseAmount,ServiceTaxSetup);
      EXIT(RoundServTax(ServTaxAmount * PoTFactor) + RoundServTax(ECessAmount * PoTFactor) + RoundServTax(SHECessAmount * PoTFactor) +
        RoundServTax(SBCAmount * PoTFactor) + RoundServTax(KKCessAmount * PoTFactor));

Example

There are no examples available.
Member of Miscellaneous.Reverse Service Tax Helper


CalculatePoTTotalTaxAmountKKC@1500087 Method

The procedure CalculatePoTTotalTaxAmountKKC is available in codeunit 143006.

Syntax

CalculatePoTTotalTaxAmountKKC@1500087(
    BaseAmount@1500003 : Decimal BaseAmount, //Input parameter of type Decimal
    PoTFactor@1500004 : Decimal PoTFactor, //Input parameter of type Decimal
    ServiceTaxSetup@1500005 : Record 16472 ServiceTaxSetup //Input parameter of type Record
);

Parameters

BaseAmount
Input parameter of type Decimal
PoTFactor
Input parameter of type Decimal
ServiceTaxSetup
Input parameter of type Record

Return Value

Decimal

Remarks

The relevant search keywords are: Calculate, Po, T, Total, Tax, Amount, KKC.

For a clarification about how this function works, refer to the code listed below.

      ServTaxAmount := CalculateServTax(BaseAmount,ServiceTaxSetup);
      ECessAmount := CalculateECess(BaseAmount,ServiceTaxSetup);
      SHECessAmount := CalculateSHECess(BaseAmount,ServiceTaxSetup);
      EXIT(RoundServTax(ServTaxAmount * PoTFactor) + RoundServTax(ECessAmount * PoTFactor) + RoundServTax(SHECessAmount * PoTFactor));

Example

There are no examples available.
Member of Miscellaneous.Reverse Service Tax Helper


CalculateSBC@1500085 Method

The procedure CalculateSBC is available in codeunit 143006.

Syntax

CalculateSBC@1500085(
    Base@1500000 : Decimal Base, //Input parameter of type Decimal
    ServiceTaxSetup@1500001 : Record 16472 ServiceTaxSetup //Input parameter of type Record
);

Parameters

Base
Input parameter of type Decimal
ServiceTaxSetup
Input parameter of type Record

Return Value

Decimal

Remarks

The relevant search keywords are: Calculate, SBC.

For a clarification about how this function works, refer to the code listed below.

      EXIT(RoundServTax(Base * ServiceTaxSetup."SB Cess%" / 100));

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      Initialize;

      // Exercise
      PostPmtAppliedToInvPoT(DocumentType,PoT,PurchaseLine,PostedPurchaseDocNo,PostedPaymentDocNo,ServiceTaxSetup);

      // Verify
      BaseAmount := ReverseServiceTaxHelper.CalculateServTaxBase(PurchaseLine."Line Amount",DocumentType);
      Amount := ReverseServiceTaxHelper.CalculateServTaxTotal(BaseAmount,ServiceTaxSetup);
      KKCAmount := ReverseServiceTaxHelper.CalculateKKCess(BaseAmount,ServiceTaxSetup);
      SBCAmount := ReverseServiceTaxHelper.CalculateSBC(BaseAmount,ServiceTaxSetup);
      RevChargeCreditClosed := TRUE;
      RealCreditClosed := FALSE;

      IF PoT THEN
        ServiceTaxVerify.ServiceTaxEntries(PostedPurchaseDocNo,BaseAmount,ServiceTaxSetup,RevChargeCreditClosed,RealCreditClosed)
      ELSE BEGIN
        ServiceTaxVerify.ServTaxEntry(PostedPurchaseDocNo,BaseAmount,ServiceTaxSetup);
        ServiceTaxVerify.ServTaxEntryDetails(PostedPaymentDocNo,BaseAmount,ServiceTaxSetup,RevChargeCreditClosed,RealCreditClosed);
      END;

      ServiceTaxVerify.ServTaxGLAccountsBalance(ServiceTaxSetup,Amount,0,0,0);
      ServiceTaxVerify.KKCGLAccountsBalance(ServiceTaxSetup,KKCAmount,0,0,0);
      ServiceTaxVerify.SBCGLAccountsBalance(ServiceTaxSetup,SBCAmount,0,0,0);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDocNo,FALSE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPaymentDocNo,FALSE);
Member of Miscellaneous.Reverse Service Tax Helper


CalculateServTax@1500020 Method

The procedure CalculateServTax is available in codeunit 143006.

Syntax

CalculateServTax@1500020(
    Base@1500000 : Decimal Base, //Input parameter of type Decimal
    ServiceTaxSetup@1500001 : Record 16472 ServiceTaxSetup //Input parameter of type Record
);

Parameters

Base
Input parameter of type Decimal
ServiceTaxSetup
Input parameter of type Record

Return Value

Decimal

Remarks

The relevant search keywords are: Calculate, Serv, Tax.

For a clarification about how this function works, refer to the code listed below.

      EXIT(RoundServTax(Base * ServiceTaxSetup."Service Tax %" / 100));

Example

The below example is extracted from the test automation codeunit 144014 to show one way of using this function.

      DummyGLEntry.SETRANGE("Document No.",GenJournalLine."Document No.");
      Assert.RecordCount(DummyGLEntry,8);
      VerifyGLEntry(LibrarySales.GetCustomerAccount(GenJournalLine."Account No."),GenJournalLine."Document No.",
        GenJournalLine.Amount / GenJournalLine."Currency Factor");
      VerifyGLEntryAdditionalCurrencyAmount(LibrarySales.GetCustomerAccount(GenJournalLine."Account No."),
        GenJournalLine."Document No.",GenJournalLine.Amount);
      VerifyGLEntry(ReverseServiceTaxHelper.GetBankAccGLPostingAcc(GenJournalLine."Bal. Account No."),
        GenJournalLine."Document No.",-GenJournalLine.Amount / GenJournalLine."Currency Factor");
      VerifyGLEntryAdditionalCurrencyAmount(ReverseServiceTaxHelper.GetBankAccGLPostingAcc(GenJournalLine."Bal. Account No."),
        GenJournalLine."Document No.",-GenJournalLine.Amount);
      ServTaxBaseAmount := ReverseServiceTaxHelper.CalcServTaxBaseAmountBackwardWithKKC(GenJournalLine.Amount,ServiceTaxSetup,0);
      VerifyGLEntry(ServiceTaxSetup."Service Tax Payable Account",GenJournalLine."Document No.",
        ReverseServiceTaxHelper.CalculateServTax(ServTaxBaseAmount,ServiceTaxSetup) / GenJournalLine."Currency Factor");
      VerifyGLEntryAdditionalCurrencyAmount(ServiceTaxSetup."Service Tax Payable Account",GenJournalLine."Document No.",
        ReverseServiceTaxHelper.CalculateServTax(ServTaxBaseAmount,ServiceTaxSetup));
      VerifyGLEntry(ServiceTaxSetup."Payables Account (Interim)",GenJournalLine."Document No.",-
        ReverseServiceTaxHelper.CalculateServTax(ServTaxBaseAmount,ServiceTaxSetup) / GenJournalLine."Currency Factor");
      VerifyGLEntryAdditionalCurrencyAmount(ServiceTaxSetup."Payables Account (Interim)",GenJournalLine."Document No.",-
        ReverseServiceTaxHelper.CalculateServTax(ServTaxBaseAmount,ServiceTaxSetup));
Member of Miscellaneous.Reverse Service Tax Helper


CalculateServTaxAmount@1500051 Method

The procedure CalculateServTaxAmount is available in codeunit 143006.

Syntax

CalculateServTaxAmount@1500051(
    ServiceTaxSetup@1500001 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    Amount@1500000 : Decimal Amount, //Input parameter of type Decimal
    DocumentType@1500002 : Option DocumentType //Input parameter of type Option
);

Parameters

ServiceTaxSetup
Input parameter of type Record
Amount
Input parameter of type Decimal
DocumentType
Input parameter of type Option

Return Value

Decimal

Remarks

The relevant search keywords are: Calculate, Serv, Tax, Amount.

For a clarification about how this function works, refer to the code listed below.

      ServiceTaxBase := CalculateServTaxBase(Amount,DocumentType);
      EXIT(CalculateServTaxTotal(ServiceTaxBase,ServiceTaxSetup));

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      ServiceTaxSetup.FindOnDate(PurchaseLine."Service Tax Group",PurchaseHeader."Posting Date");

      IF RevChargeType = ReverseChargeTypeOption::" " THEN
        BaseAmount := ReverseServiceTaxHelper.CalcServTaxBaseAmountBackward(BaseAmount,ServiceTaxSetup,0);

      InvoiceTaxAmount := ReverseServiceTaxHelper.CalculateServTaxAmount(ServiceTaxSetup,BaseAmount,DocumentType);

      FirstPaymentTaxAmount := ReverseServiceTaxHelper.RoundServTax(PartialPaymentFactor * InvoiceTaxAmount);
      SecondPaymentTaxAmount := ReverseServiceTaxHelper.RoundServTax((1 - PartialPaymentFactor) * InvoiceTaxAmount);

      SBCAmount :=
        ReverseServiceTaxHelper.CalculateServTaxSBCAmount(ServiceTaxSetup,BaseAmount,DocumentType);
      KKCAmount :=
        ReverseServiceTaxHelper.CalculateKKCAmount(ServiceTaxSetup,BaseAmount,DocumentType);

      FirstPaymentSBCAmount := ReverseServiceTaxHelper.RoundServTax(PartialPaymentFactor * SBCAmount);
      FirstPaymentKKCAmount := ReverseServiceTaxHelper.RoundServTax(PartialPaymentFactor * KKCAmount);
      SecondPaymentSBCAmount := ReverseServiceTaxHelper.RoundServTax((1 - PartialPaymentFactor) * SBCAmount);
      SecondPaymentKKCAmount := ReverseServiceTaxHelper.RoundServTax((1 - PartialPaymentFactor) * KKCAmount);

      ServiceTaxVerify.CountOfUnappliedEntries(ApplyTransactionNo);

      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDoc,TRUE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedRemainingPayment,TRUE);

      ServiceTaxVerify.UnappPmtRemainSTEntryDetBal(FirstPaymentTaxAmount,SecondPaymentTaxAmount,LastTransactionNo,RevChargeType,PoT);
      ServiceTaxVerify.UnappPmtRemainSTSBCKKCEntryDetBal(FirstPaymentSBCAmount,SecondPaymentSBCAmount,
        FirstPaymentKKCAmount,SecondPaymentKKCAmount,
        LastTransactionNo,RevChargeType,PoT);

      IF RevChargeType = ReverseChargeTypeOption::" " THEN
        ServiceTaxVerify.VendorLedgerEntryRemAmt(
          PostedPurchaseDoc,-((1 - PartialPaymentFactor) * (BaseAmount + InvoiceTaxAmount + SBCAmount + KKCAmount)))
      ELSE
        ServiceTaxVerify.VendorLedgerEntryRemAmt(PostedPurchaseDoc,-((1 - PartialPaymentFactor) * BaseAmount));

      ServiceTaxVerify.PostedPmtAndInvGLBalPartial(
        ServiceTaxSetup,RevChargeType,PoT,InvoiceTaxAmount,FirstPaymentTaxAmount);
      ServiceTaxVerify.PostedSBCKKCPmtAndInvGLBalPartial(
        ServiceTaxSetup,RevChargeType,PoT,SBCAmount,FirstPaymentSBCAmount,KKCAmount,FirstPaymentKKCAmount);
Member of Miscellaneous.Reverse Service Tax Helper


CalculateServTaxBase@1500057 Method

The procedure CalculateServTaxBase is available in codeunit 143006.

Syntax

CalculateServTaxBase@1500057(
    Base@1500000 : Decimal Base, //Input parameter of type Decimal
    DocumentType@1500002 : Option DocumentType //Input parameter of type Option
);

Parameters

Base
Input parameter of type Decimal
DocumentType
Input parameter of type Option

Return Value

Decimal

Remarks

The relevant search keywords are: Calculate, Serv, Tax, Base.

For a clarification about how this function works, refer to the code listed below.

      Sign := 1;
      IF (DocumentType = PurchaseHeader."Document Type"::"Credit Memo") OR
         (DocumentType = PurchaseHeader."Document Type"::"Return Order")
      THEN
        Sign := -1;
      EXIT(Sign * Base);

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      LastTransactionNo := Initialize;

      // Setup:
      PoT := ReverseChargeType = ReverseChargeTypeOption::" ";
      ReverseServiceTaxHelper.CreatePurchaseDoc(
        PurchaseHeader,PurchaseLine,PurchaseHeader."Document Type"::Invoice,ReverseChargeType,100,PoT);

      // Exercise
      PostedDocNo1 := ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);
      PostedDocNo2 := PostAndApplyCrMemo(PurchaseHeader,PostedDocNo1,InvAmountIs);

      // Verify
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedDocNo1,InvAmountIs = InvoiceAmountIs::Greater);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedDocNo2,InvAmountIs = InvoiceAmountIs::Smaller);

      ServiceTaxSetup.FindOnDate(PurchaseLine."Service Tax Group",PurchaseHeader."Posting Date");
      InvoiceBaseAmount := ReverseServiceTaxHelper.CalculateServTaxBase(PurchaseLine."Line Amount",PurchaseHeader."Document Type");
      InvoiceTaxAmount := ReverseServiceTaxHelper.CalculateServTaxTotal(InvoiceBaseAmount,ServiceTaxSetup);
      CrMemoBaseAmount := -InvoiceBaseAmount / ReverseServiceTaxHelper.GetPurchInvAmountFactor(InvAmountIs);
      CrMemoTaxAmount := ReverseServiceTaxHelper.CalculateServTaxTotal(CrMemoBaseAmount,ServiceTaxSetup);

      ServiceTaxVerify.ServTaxEntry(PostedDocNo1,InvoiceBaseAmount,ServiceTaxSetup);
      ServiceTaxVerify.ServTaxEntry(PostedDocNo2,CrMemoBaseAmount,ServiceTaxSetup);

      ServiceTaxVerify.PostedPurchDocGLBalance(ServiceTaxSetup,ReverseChargeType,PoT,InvoiceTaxAmount + CrMemoTaxAmount);

      IF ReverseChargeType = ReverseChargeTypeOption::" " THEN
        IF PoT THEN BEGIN
          ServiceTaxVerify.STEntryDetailsRemainingCredit(LastTransactionNo,InvoiceTaxAmount + CrMemoTaxAmount);
          ServiceTaxVerify.ServTaxEntriesArePaid(ReverseServiceTaxHelper.GetLastTransactionNo);
        END ELSE
          ServiceTaxVerify.STEntryDetailsRemainingCredit(LastTransactionNo,0)
      ELSE
        ServiceTaxVerify.STEntryDetailsRemRevChrgCredit(LastTransactionNo,0);

      IF InvAmountIs = InvoiceAmountIs::Greater THEN
        SmallerDocumentNo := PostedDocNo2
      ELSE
        SmallerDocumentNo := PostedDocNo1;
      ServiceTaxVerify.DocHasClosedRemCredit(SmallerDocumentNo);
Member of Miscellaneous.Reverse Service Tax Helper


CalculateServTaxSBCAmount@1500105 Method

The procedure CalculateServTaxSBCAmount is available in codeunit 143006.

Syntax

CalculateServTaxSBCAmount@1500105(
    ServiceTaxSetup@1500001 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    Amount@1500000 : Decimal Amount, //Input parameter of type Decimal
    DocumentType@1500002 : Option DocumentType //Input parameter of type Option
);

Parameters

ServiceTaxSetup
Input parameter of type Record
Amount
Input parameter of type Decimal
DocumentType
Input parameter of type Option

Return Value

Decimal

Remarks

The relevant search keywords are: Calculate, Serv, Tax, SBC, Amount.

For a clarification about how this function works, refer to the code listed below.

      ServiceTaxBase := CalculateServTaxBase(Amount,DocumentType);
      EXIT(CalculateSBC(ServiceTaxBase,ServiceTaxSetup));

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      ServiceTaxSetup.FindOnDate(PurchaseLine."Service Tax Group",PurchaseHeader."Posting Date");

      IF RevChargeType = ReverseChargeTypeOption::" " THEN
        BaseAmount := ReverseServiceTaxHelper.CalcServTaxBaseAmountBackward(BaseAmount,ServiceTaxSetup,0);

      InvoiceTaxAmount := ReverseServiceTaxHelper.CalculateServTaxAmount(ServiceTaxSetup,BaseAmount,DocumentType);

      FirstPaymentTaxAmount := ReverseServiceTaxHelper.RoundServTax(PartialPaymentFactor * InvoiceTaxAmount);
      SecondPaymentTaxAmount := ReverseServiceTaxHelper.RoundServTax((1 - PartialPaymentFactor) * InvoiceTaxAmount);

      SBCAmount :=
        ReverseServiceTaxHelper.CalculateServTaxSBCAmount(ServiceTaxSetup,BaseAmount,DocumentType);
      KKCAmount :=
        ReverseServiceTaxHelper.CalculateKKCAmount(ServiceTaxSetup,BaseAmount,DocumentType);

      FirstPaymentSBCAmount := ReverseServiceTaxHelper.RoundServTax(PartialPaymentFactor * SBCAmount);
      FirstPaymentKKCAmount := ReverseServiceTaxHelper.RoundServTax(PartialPaymentFactor * KKCAmount);
      SecondPaymentSBCAmount := ReverseServiceTaxHelper.RoundServTax((1 - PartialPaymentFactor) * SBCAmount);
      SecondPaymentKKCAmount := ReverseServiceTaxHelper.RoundServTax((1 - PartialPaymentFactor) * KKCAmount);

      ServiceTaxVerify.CountOfUnappliedEntries(ApplyTransactionNo);

      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDoc,TRUE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedRemainingPayment,TRUE);

      ServiceTaxVerify.UnappPmtRemainSTEntryDetBal(FirstPaymentTaxAmount,SecondPaymentTaxAmount,LastTransactionNo,RevChargeType,PoT);
      ServiceTaxVerify.UnappPmtRemainSTSBCKKCEntryDetBal(FirstPaymentSBCAmount,SecondPaymentSBCAmount,
        FirstPaymentKKCAmount,SecondPaymentKKCAmount,
        LastTransactionNo,RevChargeType,PoT);

      IF RevChargeType = ReverseChargeTypeOption::" " THEN
        ServiceTaxVerify.VendorLedgerEntryRemAmt(
          PostedPurchaseDoc,-((1 - PartialPaymentFactor) * (BaseAmount + InvoiceTaxAmount + SBCAmount + KKCAmount)))
      ELSE
        ServiceTaxVerify.VendorLedgerEntryRemAmt(PostedPurchaseDoc,-((1 - PartialPaymentFactor) * BaseAmount));

      ServiceTaxVerify.PostedPmtAndInvGLBalPartial(
        ServiceTaxSetup,RevChargeType,PoT,InvoiceTaxAmount,FirstPaymentTaxAmount);
      ServiceTaxVerify.PostedSBCKKCPmtAndInvGLBalPartial(
        ServiceTaxSetup,RevChargeType,PoT,SBCAmount,FirstPaymentSBCAmount,KKCAmount,FirstPaymentKKCAmount);
Member of Miscellaneous.Reverse Service Tax Helper


CalculateServTaxTotal@1500033 Method

The procedure CalculateServTaxTotal is available in codeunit 143006.

Syntax

CalculateServTaxTotal@1500033(
    Base@1500000 : Decimal Base, //Input parameter of type Decimal
    ServiceTaxSetup@1500001 : Record 16472 ServiceTaxSetup //Input parameter of type Record
);

Parameters

Base
Input parameter of type Decimal
ServiceTaxSetup
Input parameter of type Record

Return Value

Decimal

Remarks

The relevant search keywords are: Calculate, Serv, Tax, Total.

For a clarification about how this function works, refer to the code listed below.

      ServiceTax := CalculateServTax(Base,ServiceTaxSetup);
      ECess := CalculateECess(Base,ServiceTaxSetup);
      SHECess := CalculateSHECess(Base,ServiceTaxSetup);
      EXIT(ServiceTax + ECess + SHECess);

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      LastTransactionNo := Initialize;

      // Setup:
      PoT := ReverseChargeType = ReverseChargeTypeOption::" ";
      ReverseServiceTaxHelper.CreatePurchaseDoc(
        PurchaseHeader,PurchaseLine,PurchaseHeader."Document Type"::Invoice,ReverseChargeType,100,PoT);

      // Exercise
      PostedDocNo1 := ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);
      PostedDocNo2 := PostAndApplyCrMemo(PurchaseHeader,PostedDocNo1,InvAmountIs);

      // Verify
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedDocNo1,InvAmountIs = InvoiceAmountIs::Greater);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedDocNo2,InvAmountIs = InvoiceAmountIs::Smaller);

      ServiceTaxSetup.FindOnDate(PurchaseLine."Service Tax Group",PurchaseHeader."Posting Date");
      InvoiceBaseAmount := ReverseServiceTaxHelper.CalculateServTaxBase(PurchaseLine."Line Amount",PurchaseHeader."Document Type");
      InvoiceTaxAmount := ReverseServiceTaxHelper.CalculateServTaxTotal(InvoiceBaseAmount,ServiceTaxSetup);
      CrMemoBaseAmount := -InvoiceBaseAmount / ReverseServiceTaxHelper.GetPurchInvAmountFactor(InvAmountIs);
      CrMemoTaxAmount := ReverseServiceTaxHelper.CalculateServTaxTotal(CrMemoBaseAmount,ServiceTaxSetup);

      ServiceTaxVerify.ServTaxEntry(PostedDocNo1,InvoiceBaseAmount,ServiceTaxSetup);
      ServiceTaxVerify.ServTaxEntry(PostedDocNo2,CrMemoBaseAmount,ServiceTaxSetup);

      ServiceTaxVerify.PostedPurchDocGLBalance(ServiceTaxSetup,ReverseChargeType,PoT,InvoiceTaxAmount + CrMemoTaxAmount);

      IF ReverseChargeType = ReverseChargeTypeOption::" " THEN
        IF PoT THEN BEGIN
          ServiceTaxVerify.STEntryDetailsRemainingCredit(LastTransactionNo,InvoiceTaxAmount + CrMemoTaxAmount);
          ServiceTaxVerify.ServTaxEntriesArePaid(ReverseServiceTaxHelper.GetLastTransactionNo);
        END ELSE
          ServiceTaxVerify.STEntryDetailsRemainingCredit(LastTransactionNo,0)
      ELSE
        ServiceTaxVerify.STEntryDetailsRemRevChrgCredit(LastTransactionNo,0);

      IF InvAmountIs = InvoiceAmountIs::Greater THEN
        SmallerDocumentNo := PostedDocNo2
      ELSE
        SmallerDocumentNo := PostedDocNo1;
      ServiceTaxVerify.DocHasClosedRemCredit(SmallerDocumentNo);
Member of Miscellaneous.Reverse Service Tax Helper


CalculateSHECess@1500027 Method

The procedure CalculateSHECess is available in codeunit 143006.

Syntax

CalculateSHECess@1500027(
    Base@1500000 : Decimal Base, //Input parameter of type Decimal
    ServiceTaxSetup@1500001 : Record 16472 ServiceTaxSetup //Input parameter of type Record
);

Parameters

Base
Input parameter of type Decimal
ServiceTaxSetup
Input parameter of type Record

Return Value

Decimal

Remarks

The relevant search keywords are: Calculate, SHE, Cess.

For a clarification about how this function works, refer to the code listed below.

      ServiceTax := CalculateServTax(Base,ServiceTaxSetup);
      EXIT(RoundServTax(ServiceTax * ServiceTaxSetup."SHE Cess %" / 100));

Example

The below example is extracted from the test automation codeunit 144038 to show one way of using this function.

      BaseAmount := CalculateFullBaseAmount(GenJournalLine,ServTaxSetup);
      ECessAmount := ReverseServiceTaxHelper.CalculateECess(BaseAmount,ServTaxSetup);
      SHECessAmount := ReverseServiceTaxHelper.CalculateSHECess(BaseAmount,ServTaxSetup);
Member of Miscellaneous.Reverse Service Tax Helper


ConvertDocToJnlLine@1500075 Method

The procedure ConvertDocToJnlLine is available in codeunit 143006.

Syntax

ConvertDocToJnlLine@1500075(
    PurchaseHeader@1500000 : Record 38 PurchaseHeader, //Input parameter of type Record
    PurchaseLine@1500002 : Record 39 PurchaseLine, //Input parameter of type Record
    PostedDocNo@1500003 : Code[20] PostedDocNo, //Input parameter of type Code
    VAR GenJnlLine@1500001 : Record 81 GenJnlLine //Reference parameter of type Record
);

Parameters

PurchaseHeader
Input parameter of type Record
PurchaseLine
Input parameter of type Record
PostedDocNo
Input parameter of type Code
GenJnlLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Convert, Document, To, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      WITH GenJnlLine DO BEGIN
        INIT;
        "Document Type" := GetPostingDocType(PurchaseHeader."Document Type");
        "Document No." := PostedDocNo;
        "Posting Date" := PurchaseHeader."Posting Date";
        "Account Type" := "Account Type"::Vendor;
        "Account No." := PurchaseHeader."Pay-to Vendor No.";
        Amount := PurchaseLine."Line Amount";
        "Bal. Account No." := PurchaseLine."No.";
        "Service Tax Group Code" := PurchaseLine."Service Tax Group";
        "Service Tax Registration No." := PurchaseLine."Service Tax Registration No.";
        "Service Type (Rev. Chrg.)" := PurchaseHeader."Service Type (Rev. Chrg.)";
        PoT := PurchaseHeader.PoT;
        "Service Tax Type" := "Service Tax Type"::Purchase;
      END;

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      Initialize;

      ReverseServiceTaxHelper.CreatePurchaseDoc(
        PurchaseHeader,PurchaseLine,PurchaseHeader."Document Type"::Invoice,ReverseChargeTypeOption::" ",0,TRUE);
      PostedPurchInvoiceDocNo := ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);

      PostedSalesInvoiceDocNo :=
        ReverseServiceTaxHelper.UseCreditToPayForSalesDoc(PostedPurchInvoiceDocNo,ServiceTaxEntryDetails);

      COMMIT;
      ReverseServiceTaxHelper.ConvertDocToJnlLine(PurchaseHeader,PurchaseLine,PostedPurchInvoiceDocNo,GenJournalLine);
      ServiceTaxReportHelper.RunReportServiceTaxCreditRegister(GenJournalLine,TRUE);

      ServiceTaxReportHelper.VerifyServTaxCreditRegisterTakenAsSalesCredit(PostedSalesInvoiceDocNo,ServiceTaxEntryDetails.FullTaxAmount);
Member of Miscellaneous.Reverse Service Tax Helper


CreateAdvancePayment@1500031 Method

The procedure CreateAdvancePayment is available in codeunit 143006.

Syntax

CreateAdvancePayment@1500031(
    VAR GenJournalLine@1500006 : Record 81 GenJournalLine, //Reference parameter of type Record
    DocumentType@1500002 : Option DocumentType, //Input parameter of type Option
    PoT@1500007 : Boolean PoT, //Input parameter of type Boolean
    RevChargeServiceType@1500017 : Option RevChargeServiceType, //Input parameter of type Option
    RevChargeType@1500018 : Option RevChargeType, //Input parameter of type Option
    ReverseChargePercentage@1500003 : Integer ReverseChargePercentage //Input parameter of type Integer
);

Parameters

GenJournalLine
Reference parameter of type Record
DocumentType
Input parameter of type Option
PoT
Input parameter of type Boolean
RevChargeServiceType
Input parameter of type Option
RevChargeType
Input parameter of type Option
ReverseChargePercentage
Input parameter of type Integer

Remarks

The relevant search keywords are: Create, Advance, Payment.

For a clarification about how this function works, refer to the code listed below.

      CreateGenJournalBatch(GenJournalBatch);
      CreateJnlLineWithServiceTax(GenJournalLine,GenJournalBatch,DocumentType,
        RevChargeServiceType,RevChargeType,ReverseChargePercentage);
      GenJournalLine.VALIDATE(PoT,PoT);
      GenJournalLine.VALIDATE("Serv. Tax on Advance Payment",TRUE);
      GenJournalLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 144030 to show one way of using this function.

      Initialize;

      ReverseServiceTaxHelper.CreateAdvancePayment(GenJournalLine,GenJournalLine."Document Type"::Payment,FALSE,
        GenJournalLine."Service Type (Rev. Chrg.)"::" ",ServiceTaxType::Standard,100);

      // Exercise & Verify:
      ASSERTERROR LibraryERM.PostGeneralJnlLine(GenJournalLine);
      VerifyExpectedErrorMessage(
        STRSUBSTNO(BlankOptionFieldErr,GenJournalLine.FIELDCAPTION("Service Type (Rev. Chrg.)"),GenJournalLine.TABLENAME))
Member of Miscellaneous.Reverse Service Tax Helper


CreateAndPostAdvancePayment@1500030 Method

The procedure CreateAndPostAdvancePayment is available in codeunit 143006.

Syntax

CreateAndPostAdvancePayment@1500030(
    VAR GenJournalLine@1500006 : Record 81 GenJournalLine, //Reference parameter of type Record
    PoT@1500007 : Boolean PoT, //Input parameter of type Boolean
    RevChargeServiceType@1500017 : Option RevChargeServiceType, //Input parameter of type Option
    RevChargeType@1500018 : Option RevChargeType, //Input parameter of type Option
    ReverseChargePercentage@1500001 : Integer ReverseChargePercentage //Input parameter of type Integer
);

Parameters

GenJournalLine
Reference parameter of type Record
PoT
Input parameter of type Boolean
RevChargeServiceType
Input parameter of type Option
RevChargeType
Input parameter of type Option
ReverseChargePercentage
Input parameter of type Integer

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Post, Advance, Payment.

For a clarification about how this function works, refer to the code listed below.

      IF GenJournalLine."Document Type" = GenJournalLine."Document Type"::" " THEN
        DocumentType := GenJournalLine."Document Type"::Payment
      ELSE
        DocumentType := GenJournalLine."Document Type";
      CreateAdvancePayment(GenJournalLine,DocumentType,PoT,RevChargeServiceType,RevChargeType,ReverseChargePercentage);
      LibraryERM.PostGeneralJnlLine(GenJournalLine);
      EXIT(GenJournalLine."Document No.")

Example

The below example is extracted from the test automation codeunit 144030 to show one way of using this function.

      Initialize;

      ReverseServiceTaxHelper.CreateAndPostAdvancePayment(
        GenJournalLine,
        PoT,
        GenJournalLine."Service Type (Rev. Chrg.)"::" ",
        ServiceTaxType::" ",0);

      ReverseServiceTaxHelper.CreateDocAndApplyAdvPayment(
        PurchaseHeader,
        PurchaseLine,
        GenJournalLine,
        GenJournalLine."Document Type"::Invoice,
        ServiceTaxType::" ",0,
        PoT,
        GenJournalLine.Amount);

      PurchaseHeader.VALIDATE(Structure,'');
      PurchaseHeader.VALIDATE(PoT,PoT); // Because PoT is reset when changing Structure
      PurchaseHeader.MODIFY(TRUE);

      ASSERTERROR ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);
      // Renew the record, to avoid the error: "Another user has modified the record [..]"
      PurchaseHeader.GET(PurchaseHeader."Document Type",PurchaseHeader."No.");
      PurchaseHeader.DELETE;
      Assert.ExpectedError(ApplyToNotServTaxDocErr);
Member of Miscellaneous.Reverse Service Tax Helper


CreateCustomer@1500079 Method

The procedure CreateCustomer is available in codeunit 143006.

Syntax

CreateCustomer@1500079(
      //param element not supplied
);

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Customer.

For a clarification about how this function works, refer to the code listed below.

      LibrarySales.CreateCustomer(Customer);
      LibraryERM.FindGeneralPostingSetup(GeneralPostingSetup);
      Customer.VALIDATE("Gen. Bus. Posting Group",GeneralPostingSetup."Gen. Bus. Posting Group");
      Customer.MODIFY(TRUE);
      EXIT(Customer."No.");

Example

The below example is extracted from the test automation codeunit 144001 to show one way of using this function.

      LibrarySales.CreateCustomer(Customer);
      WITH Customer DO BEGIN
        VALIDATE("Tax Liable",TaxLiable);
        VALIDATE("Excise Bus. Posting Group",ExciseBusPostingGroup);
        VALIDATE("State Code",StateCode);
        MODIFY(TRUE);
        EXIT("No.");
      END;
Member of Miscellaneous.Reverse Service Tax Helper


CreateDocAndApplyAdvPayment@1500032 Method

The procedure CreateDocAndApplyAdvPayment is available in codeunit 143006.

Syntax

CreateDocAndApplyAdvPayment@1500032(
    VAR PurchaseHeader@1500000 : Record 38 PurchaseHeader, //Reference parameter of type Record
    VAR PurchaseLine@1500011 : Record 39 PurchaseLine, //Reference parameter of type Record
    GenJournalLine@1500001 : Record 81 GenJournalLine, //Input parameter of type Record
    DocumentType@1500002 : Option DocumentType, //Input parameter of type Option
    ReverseChargeType@1500006 : Option ReverseChargeType, //Input parameter of type Option
    ReverseChargePercentage@1500003 : Integer ReverseChargePercentage, //Input parameter of type Integer
    PoT@1500009 : Boolean PoT, //Input parameter of type Boolean
    Amount@1500007 : Decimal Amount //Input parameter of type Decimal
);

Parameters

PurchaseHeader
Reference parameter of type Record
PurchaseLine
Reference parameter of type Record
GenJournalLine
Input parameter of type Record
DocumentType
Input parameter of type Option
ReverseChargeType
Input parameter of type Option
ReverseChargePercentage
Input parameter of type Integer
PoT
Input parameter of type Boolean
Amount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Document, Apply, Adv, Payment.

For a clarification about how this function works, refer to the code listed below.

      CreatePurchaseDocForAdvPayment(PurchaseHeader,PurchaseLine,GenJournalLine,
        DocumentType,ReverseChargeType,ReverseChargePercentage,PoT,Amount);

      ApplyAdvancePaymentOnline(PurchaseHeader,GenJournalLine."Document No.");

Example

The below example is extracted from the test automation codeunit 144030 to show one way of using this function.

      Initialize;

      ReverseServiceTaxHelper.CreateAndPostAdvancePayment(
        GenJournalLine,
        PoT,
        GenJournalLine."Service Type (Rev. Chrg.)"::" ",
        ServiceTaxType::" ",0);

      ReverseServiceTaxHelper.CreateDocAndApplyAdvPayment(
        PurchaseHeader,
        PurchaseLine,
        GenJournalLine,
        GenJournalLine."Document Type"::Invoice,
        ServiceTaxType::" ",0,
        PoT,
        GenJournalLine.Amount);

      PurchaseHeader.VALIDATE(Structure,'');
      PurchaseHeader.VALIDATE(PoT,PoT); // Because PoT is reset when changing Structure
      PurchaseHeader.MODIFY(TRUE);

      ASSERTERROR ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);
      // Renew the record, to avoid the error: "Another user has modified the record [..]"
      PurchaseHeader.GET(PurchaseHeader."Document Type",PurchaseHeader."No.");
      PurchaseHeader.DELETE;
      Assert.ExpectedError(ApplyToNotServTaxDocErr);
Member of Miscellaneous.Reverse Service Tax Helper


CreateGenJnllBatchWithBalAcc@1500010 Method

The procedure CreateGenJnllBatchWithBalAcc is available in codeunit 143006.

Syntax

CreateGenJnllBatchWithBalAcc@1500010(
    VAR GenJournalBatch@1500000 : Record 232 GenJournalBatch //Reference parameter of type Record
);

Parameters

GenJournalBatch
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, General, Jnll, Batch, Bal, Account.

For a clarification about how this function works, refer to the code listed below.

      CreateGenJournalBatch(GenJournalBatch);
      GenJournalBatch.VALIDATE("Bal. Account Type",GenJournalBatch."Bal. Account Type"::"G/L Account");
      LibraryERM.CreateGLAccount(GLAccount);
      GenJournalBatch.VALIDATE("Bal. Account No.",GLAccount."No.");
      GenJournalBatch.MODIFY(TRUE);

Example

There are no examples available.
Member of Miscellaneous.Reverse Service Tax Helper


CreateGenJournalBatch@1500003 Method

The procedure CreateGenJournalBatch is available in codeunit 143006.

Syntax

CreateGenJournalBatch@1500003(
    VAR GenJournalBatch@1500000 : Record 232 GenJournalBatch //Reference parameter of type Record
);

Parameters

GenJournalBatch
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, General, Journal, Batch.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.CreateGenJournalTemplate(GenJournalTemplate);
      LibraryERM.CreateGenJournalBatch(GenJournalBatch,GenJournalTemplate.Name);

Example

The below example is extracted from the test automation codeunit 144014 to show one way of using this function.

      LibraryERM.CreateGenJournalTemplate(GenJournalTemplate);
      GenJournalTemplate.VALIDATE(Type,TemplateType);
      GenJournalTemplate.VALIDATE("Sub Type",TemplateSubtype);
      GenJournalTemplate.MODIFY(TRUE);
      LibraryERM.CreateGenJournalBatch(GenJournalBatch,GenJournalTemplate.Name);
Member of Miscellaneous.Reverse Service Tax Helper


CreateGLAccount@1 Method

The procedure CreateGLAccount is available in codeunit 143006.

Syntax

CreateGLAccount@1(
    ServiceTaxGroupCode@1500000 : Code[20] ServiceTaxGroupCode //Input parameter of type Code
);

Parameters

ServiceTaxGroupCode
Input parameter of type Code

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, General Ledger, Account.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.FindGeneralPostingSetup(GeneralPostingSetup);
      LibraryERM.CreateGLAccount(GLAccount);
      GLAccount.VALIDATE("Income/Balance",GLAccount."Income/Balance"::"Balance Sheet");
      GLAccount.VALIDATE("Direct Posting",TRUE);
      GLAccount.VALIDATE("Gen. Posting Type",GLAccount."Gen. Posting Type"::Purchase); // important for Service Tax Calculation
      GLAccount.VALIDATE("Gen. Prod. Posting Group",GeneralPostingSetup."Gen. Prod. Posting Group");
      GLAccount.VALIDATE("Service Tax Group Code",ServiceTaxGroupCode);
      GLAccount.MODIFY(TRUE);
      EXIT(GLAccount."No.");

Example

The below example is extracted from the test automation codeunit 144001 to show one way of using this function.

      WITH ExcisePostingSetup DO BEGIN
        LibraryERM.CreateExcisePostingSetup(
          ExcisePostingSetup,"BED Calculation Type"::"Excise %",ExciseAmount,FALSE);
        // Will include BCD Amount only to BED Amount.
        // BED Amount is a part of Excise.
        "Cenvat Cr. Receivable(Trading)" := ServiceTaxAsExciseHelper.CreateGLAccount;
        "Cenvat Cr. Receivable Account" := ServiceTaxAsExciseHelper.CreateGLAccount;
        "Cenvat Transfered(Trading)" := ServiceTaxAsExciseHelper.CreateGLAccount;
        "eCess %" := LibraryRandom.RandInt(10);
        "eCess Calculation Formula" := 'BED AMOUNT';
        "SHE Cess %" := LibraryRandom.RandInt(10);
        "SHE Cess Calculation Formula" := 'BED AMOUNT';
        "Setoff available" := TRUE;
        MODIFY(TRUE);
      END;
Member of Miscellaneous.Reverse Service Tax Helper


CreateGLAccountForSales@1500086 Method

The procedure CreateGLAccountForSales is available in codeunit 143006.

Syntax

CreateGLAccountForSales@1500086(
    ServiceTaxGroupCode@1500002 : Code[10] ServiceTaxGroupCode //Input parameter of type Code
);

Parameters

ServiceTaxGroupCode
Input parameter of type Code

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, General Ledger, Account, For, Sales.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.FindGeneralPostingSetup(GeneralPostingSetup);
      LibraryERM.CreateGLAccount(GLAccount);
      GLAccount.VALIDATE("Income/Balance",GLAccount."Income/Balance"::"Balance Sheet");
      GLAccount.VALIDATE("Direct Posting",TRUE);
      GLAccount.VALIDATE("Gen. Posting Type",GLAccount."Gen. Posting Type"::Sale);
      GLAccount.VALIDATE("Gen. Prod. Posting Group",GeneralPostingSetup."Gen. Prod. Posting Group");
      GLAccount.VALIDATE("Service Tax Group Code",ServiceTaxGroupCode);
      GLAccount.MODIFY(TRUE);
      EXIT(GLAccount."No.");

Example

There are no examples available.
Member of Miscellaneous.Reverse Service Tax Helper


CreateJnlLineWithServiceTax@1170000002 Method

The procedure CreateJnlLineWithServiceTax is available in codeunit 143006.

Syntax

CreateJnlLineWithServiceTax@1170000002(
    VAR GenJournalLine@1170000001 : Record 81 GenJournalLine, //Reference parameter of type Record
    GenJournalBatch@1500000 : Record 232 GenJournalBatch, //Input parameter of type Record
    DocumentType@1500002 : Option DocumentType, //Input parameter of type Option
    RevChargeServiceType@1500008 : Option RevChargeServiceType, //Input parameter of type Option
    RevChargeType@1500006 : Option RevChargeType, //Input parameter of type Option
    ReverseChargePercentage@1500007 : Integer ReverseChargePercentage //Input parameter of type Integer
);

Parameters

GenJournalLine
Reference parameter of type Record
GenJournalBatch
Input parameter of type Record
DocumentType
Input parameter of type Option
RevChargeServiceType
Input parameter of type Option
RevChargeType
Input parameter of type Option
ReverseChargePercentage
Input parameter of type Integer

Remarks

The relevant search keywords are: Create, Journal, Line, Service, Tax.

For a clarification about how this function works, refer to the code listed below.

      IF GenJournalLine.Amount = 0 THEN
        Amount := GetAmountSignInJournalLine(DocumentType) * LibraryRandom.RandInt(200000)
      ELSE
        Amount := GetAmountSignInJournalLine(DocumentType) * GenJournalLine.Amount;

      CompanyInfo.GET;
      ServiceTaxRegNo.GET(CompanyInfo."Service Tax Registration No.");
      CreateServiceTaxGroupSetup(ServiceTaxGroup);
      GetServiceTaxReturnPeriod(ServiceTaxReturnPeriod);
      CreateJnlLineWithSTNoSetup(GenJournalLine,GenJournalBatch,DocumentType,RevChargeServiceType,CreateVendor,Amount,
        LibraryServiceTax.GetDateWithinSrvTaxPeriod(ServiceTaxReturnPeriod),ServiceTaxRegNo.Code,ServiceTaxGroup.Code);
      CreateSTRevChrgSetupFromJnl(GenJournalLine,RevChargeType,ReverseChargePercentage);

Example

The below example is extracted from the test automation codeunit 144030 to show one way of using this function.

      ReverseServiceTaxHelper.CreateGenJournalBatch(GenJournalBatch);
      ReverseServiceTaxHelper.CreateJnlLineWithServiceTax(GenJournalLine,GenJournalBatch,
        DocumentType,ReverseChargeServiceType,ReverseChargeType,100);
Member of Miscellaneous.Reverse Service Tax Helper


CreateJnlLineWithSTNoSetup@1500045 Method

The procedure CreateJnlLineWithSTNoSetup is available in codeunit 143006.

Syntax

CreateJnlLineWithSTNoSetup@1500045(
    VAR GenJournalLine@1170000001 : Record 81 GenJournalLine, //Reference parameter of type Record
    GenJournalBatch@1500000 : Record 232 GenJournalBatch, //Input parameter of type Record
    DocumentType@1500002 : Option DocumentType, //Input parameter of type Option
    RevChargeServiceType@1500008 : Option RevChargeServiceType, //Input parameter of type Option
    VendorNo@1500007 : Code[20] VendorNo, //Input parameter of type Code
    Amount@1500003 : Decimal Amount, //Input parameter of type Decimal
    PostingDate@1500005 : Date PostingDate, //Input parameter of type Date
    ServiceTaxRegNo@1500001 : Code[20] ServiceTaxRegNo, //Input parameter of type Code
    ServiceTaxGroup@1500004 : Code[20] ServiceTaxGroup //Input parameter of type Code
);

Parameters

GenJournalLine
Reference parameter of type Record
GenJournalBatch
Input parameter of type Record
DocumentType
Input parameter of type Option
RevChargeServiceType
Input parameter of type Option
VendorNo
Input parameter of type Code
Amount
Input parameter of type Decimal
PostingDate
Input parameter of type Date
ServiceTaxRegNo
Input parameter of type Code
ServiceTaxGroup
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Journal, Line, ST, No, Setup.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.CreateGeneralJnlLine(GenJournalLine,GenJournalBatch."Journal Template Name",GenJournalBatch.Name,
        DocumentType,GenJournalLine."Account Type"::Vendor,VendorNo,Amount);
      WITH GenJournalLine DO BEGIN
        IF DocumentType IN ["Document Type"::Payment,"Document Type"::Refund] THEN BEGIN
          VALIDATE("Bal. Account Type","Bal. Account Type"::"Bank Account");
          LibraryERM.FindBankAccount(BankAccount);
          VALIDATE("Bal. Account No.",BankAccount."No.");
          VALIDATE("Service Tax Group Code",ServiceTaxGroup);
        END ELSE BEGIN
          VALIDATE("Bal. Account Type","Bal. Account Type"::"G/L Account");
          VALIDATE("Bal. Account No.",CreateGLAccount(ServiceTaxGroup));
        END;
        VALIDATE("Service Tax Registration No.",ServiceTaxRegNo);
        VALIDATE("Posting Date",PostingDate);
        VALIDATE("Document No.",LibraryUtility.GenerateRandomCode(FIELDNO("Document No."),DATABASE::"Gen. Journal Line"));
        VALIDATE("External Document No.","Document No.");
        VALIDATE("Consignment Note No.","Document No.");
        VALIDATE("Service Type (Rev. Chrg.)",RevChargeServiceType);
        MODIFY(TRUE);
      END;

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      ReverseServiceTaxHelper.CreateGenJournalBatch(GenJournalBatch);
      WITH GenJournalLine1 DO BEGIN
        ReverseServiceTaxHelper.CreateJnlLineWithSTNoSetup(GenJournalLine2,GenJournalBatch,DocumentType,
          "Service Type (Rev. Chrg.)","Account No.",-BaseAmount,"Posting Date","Service Tax Registration No.",
          "Service Tax Group Code");
        GenJournalLine2.VALIDATE(PoT,PoT);
        GenJournalLine2.VALIDATE("Applies-to Doc. Type","Document Type");
        GenJournalLine2.VALIDATE("Applies-to Doc. No.","Document No.");
        GenJournalLine2.VALIDATE("Serv. Tax on Advance Payment",ServTaxOnAdvPayment);
      END;
      GenJournalLine2.MODIFY(TRUE);
      LibraryERM.PostGeneralJnlLine(GenJournalLine2);
Member of Miscellaneous.Reverse Service Tax Helper


CreateJournalLine@1500011 Method

The procedure CreateJournalLine is available in codeunit 143006.

Syntax

CreateJournalLine@1500011(
    VAR GenJournalLine@1170000001 : Record 81 GenJournalLine, //Reference parameter of type Record
    GenJournalBatch@1500000 : Record 232 GenJournalBatch, //Input parameter of type Record
    DocumentType@1500001 : Option DocumentType, //Input parameter of type Option
    AccountType@1500002 : Option AccountType, //Input parameter of type Option
    AccountNo@1500003 : Code[20] AccountNo, //Input parameter of type Code
    Amount@1500006 : Decimal Amount, //Input parameter of type Decimal
    PostingDate@1170000003 : Date PostingDate //Input parameter of type Date
);

Parameters

GenJournalLine
Reference parameter of type Record
GenJournalBatch
Input parameter of type Record
DocumentType
Input parameter of type Option
AccountType
Input parameter of type Option
AccountNo
Input parameter of type Code
Amount
Input parameter of type Decimal
PostingDate
Input parameter of type Date

Remarks

The relevant search keywords are: Create, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.CreateGeneralJnlLine(GenJournalLine,GenJournalBatch."Journal Template Name",GenJournalBatch.Name,
        DocumentType,AccountType,AccountNo,Amount);
      GenJournalLine.VALIDATE("Posting Date",PostingDate);
      GenJournalLine.VALIDATE("Document No.",
        LibraryUtility.GenerateRandomCode(GenJournalLine.FIELDNO("Document No."),DATABASE::"Gen. Journal Line"));
      GenJournalLine.MODIFY(TRUE);

Example

There are no examples available.
Member of Miscellaneous.Reverse Service Tax Helper


CreateLocation@2 Method

The procedure CreateLocation is available in codeunit 143006.

Syntax

CreateLocation@2(
    VAR Location@1500000 : Record 14 Location //Reference parameter of type Record
);

Parameters

Location
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Location.

For a clarification about how this function works, refer to the code listed below.

      LibraryServiceTax.CreateServiceTaxRegistrationNo(ServiceTaxRegNo);

      LibraryWarehouse.CreateLocation(Location);
      Location.VALIDATE("Input Service Distributor",FALSE);
      Location.VALIDATE("Service Tax Registration No.",ServiceTaxRegNo.Code);
      Location.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 144014 to show one way of using this function.

      LibraryERM.CreateTaxArea(TaxArea);
      LibraryERM.CreateTaxJurisdiction(TaxJurisdiction);
      LibraryERM.CreateTaxGroup(TaxGroup);
      LibraryWarehouse.CreateLocation(Location);
      LibraryERM.CreateState(State);
      Location.VALIDATE("State Code",State.Code);
      Location.MODIFY;
      LibraryERM.CreateState(State);
      TaxJurisdiction.VALIDATE("State Code",Location."State Code");
      TaxJurisdiction.VALIDATE("Tax Type",TaxJurisdiction."Tax Type"::CST);
      TaxJurisdiction.MODIFY(TRUE);
      ServiceTaxAsExciseHelper.CreateTaxAreaLocations(Location.Code,State.Code,TaxArea.Code,TaxAreaLocationsType::Customer);
      LibraryERM.CreateTaxAreaLine(TaxAreaLine,TaxArea.Code,TaxJurisdiction.Code);
      TaxAreaLine.VALIDATE("Include Tax Base",TRUE);
      TaxAreaLine.MODIFY;
      LibraryERM.CreateTaxDetail(TaxDetail,TaxJurisdiction.Code,TaxGroup.Code,TaxDetail."Tax Type"::"Sales Tax",WORKDATE);
      TaxDetail.VALIDATE("Tax Below Maximum",LibraryRandom.RandDecInRange(10,15,2));
      TaxDetail.MODIFY(TRUE);
Member of Miscellaneous.Reverse Service Tax Helper


CreateNewServGrpForRevChPLine@1500070 Method

The procedure CreateNewServGrpForRevChPLine is available in codeunit 143006.

Syntax

CreateNewServGrpForRevChPLine@1500070(
    PurchaseLine@1500000 : Record 39 PurchaseLine, //Input parameter of type Record
    VAR ServiceTaxGroup@1500002 : Record 16471 ServiceTaxGroup //Reference parameter of type Record
);

Parameters

PurchaseLine
Input parameter of type Record
ServiceTaxGroup
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, New, Serv, Grp, For, Rev, Ch, P, Line.

For a clarification about how this function works, refer to the code listed below.

      CreateServiceTaxGroupSetup(ServiceTaxGroup);
      PurchaseLine."Service Tax Group" := ServiceTaxGroup.Code;
      CreateSTRevChrgSetupFromPurch(PurchaseLine,ReverseChargeTypeOption::Standard,100);

Example

The below example is extracted from the test automation codeunit 144033 to show one way of using this function.

      Initialize;
      ServiceTypeReverseCharge := PurchaseHeader."Service Type (Rev. Chrg.)"::Inward;

      // Post Invoice
      ReverseServiceTaxHelper.CreateServiceTaxGroupSetup(ServiceTaxGroup);
      VendorNo := ReverseServiceTaxHelper.CreateVendor;
      ServRegNo := ReverseServiceTaxHelper.CreateServTaxRegNo;
      Amount := 10000;
      PostedInvoiceNo := ReverseServiceTaxHelper.PostPurchaseDocForVendWithAmt(
          PurchaseHeader,PurchaseLine,VendorNo,PurchaseHeader."Document Type"::Invoice,
          ServiceTypeReverseCharge,ServiceTaxType::Standard,FALSE,ServRegNo,ServiceTaxGroup.Code,Amount);

      // Post Cr. Memo with different service tax group
      ReverseServiceTaxHelper.CreateNewServGrpForRevChPLine(PurchaseLine,ServiceTaxGroup);
      PostedCrMNo := ReverseServiceTaxHelper.PostPurchaseDocForVendWithAmt(
          PurchaseHeaderCrM,PurchaseLineCrM,VendorNo,
          PurchaseHeaderCrM."Document Type"::"Credit Memo",ServiceTypeReverseCharge,
          ServiceTaxType::Standard,FALSE,ServRegNo,ServiceTaxGroup.Code,Amount);

      // Try to apply
      ASSERTERROR ReverseServiceTaxHelper.ApplyAndPostVendorEntry(VendorLedgerEntry."Document Type"::Invoice,PostedInvoiceNo,
          VendorLedgerEntry."Document Type"::"Credit Memo",PostedCrMNo);
      Assert.ExpectedError(ServiceTaxGroupCodeErr);
Member of Miscellaneous.Reverse Service Tax Helper


CreateNewSRegNoForRevChPLine@1500069 Method

The procedure CreateNewSRegNoForRevChPLine is available in codeunit 143006.

Syntax

CreateNewSRegNoForRevChPLine@1500069(
    PurchaseLine@1500000 : Record 39 PurchaseLine, //Input parameter of type Record
    VAR ServiceTaxRegistrationNos@1500002 : Record 16475 ServiceTaxRegistrationNos //Reference parameter of type Record
);

Parameters

PurchaseLine
Input parameter of type Record
ServiceTaxRegistrationNos
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, New, S, Reg, No, For, Rev, Ch, P, Line.

For a clarification about how this function works, refer to the code listed below.

      LibraryServiceTax.CreateServiceTaxRegistrationNo(ServiceTaxRegistrationNos);
      PurchaseLine."Service Tax Registration No." := ServiceTaxRegistrationNos.Code;
      CreateSTRevChrgSetupFromPurch(PurchaseLine,ReverseChargeTypeOption::Standard,100);

Example

The below example is extracted from the test automation codeunit 144033 to show one way of using this function.

      Initialize;
      ServiceTypeReverseCharge := PurchaseHeader."Service Type (Rev. Chrg.)"::Inward;

      // Post Invoice
      ReverseServiceTaxHelper.CreateServiceTaxGroupSetup(ServiceTaxGroup);
      VendorNo := ReverseServiceTaxHelper.CreateVendor;
      ServRegNo := ReverseServiceTaxHelper.CreateServTaxRegNo;
      Amount := 10000;
      PostedInvoiceNo := ReverseServiceTaxHelper.PostPurchaseDocForVendWithAmt(
          PurchaseHeader,PurchaseLine,VendorNo,PurchaseHeader."Document Type"::Invoice,
          ServiceTypeReverseCharge,ServiceTaxType::Standard,FALSE,ServRegNo,ServiceTaxGroup.Code,Amount);

      // Post Cr. Memo with different service tax registration no.
      ReverseServiceTaxHelper.CreateNewSRegNoForRevChPLine(PurchaseLine,ServiceTaxRegistrationNos);
      PostedCrMNo := ReverseServiceTaxHelper.PostPurchaseDocForVendWithAmt(
          PurchaseHeaderCrM,PurchaseLineCrM,VendorNo,
          PurchaseHeaderCrM."Document Type"::"Credit Memo",ServiceTypeReverseCharge,
          ServiceTaxType::Standard,FALSE,ServiceTaxRegistrationNos.Code,ServiceTaxGroup.Code,Amount);

      // Try to apply
      ASSERTERROR ReverseServiceTaxHelper.ApplyAndPostVendorEntry(VendorLedgerEntry."Document Type"::Invoice,PostedInvoiceNo,
          VendorLedgerEntry."Document Type"::"Credit Memo",PostedCrMNo);
      Assert.ExpectedError(ServiceTaxRegNoErr);
Member of Miscellaneous.Reverse Service Tax Helper


CreatePayment@1500151 Method

The procedure CreatePayment is available in codeunit 143006.

Syntax

CreatePayment@1500151(
    VAR GenJournalLine@1500006 : Record 81 GenJournalLine, //Reference parameter of type Record
    VendorNo@1500003 : Code[20] VendorNo, //Input parameter of type Code
    Amount@1500002 : Decimal Amount, //Input parameter of type Decimal
    PostingDate@1500001 : Date PostingDate, //Input parameter of type Date
    DocumentType@1500000 : Option DocumentType //Input parameter of type Option
);

Parameters

GenJournalLine
Reference parameter of type Record
VendorNo
Input parameter of type Code
Amount
Input parameter of type Decimal
PostingDate
Input parameter of type Date
DocumentType
Input parameter of type Option

Remarks

The relevant search keywords are: Create, Payment.

For a clarification about how this function works, refer to the code listed below.

      CreateGenJnllBatchWithBalAcc(GenJournalBatch);
      CreateJournalLine(
        GenJournalLine,GenJournalBatch,DocumentType,GenJournalLine."Account Type"::Vendor,
        VendorNo,Amount,PostingDate);

Example

The below example is extracted from the test automation codeunit 144030 to show one way of using this function.

      ReverseServiceTaxHelper.CreatePayment(GenJournalLine,ReverseServiceTaxHelper.CreateVendor,
        ReverseServiceTaxHelper.GetAmountSignInJournalLine(DocumentType) * LibraryRandom.RandDec(10000,2),
        WORKDATE,DocumentType);
Member of Miscellaneous.Reverse Service Tax Helper


CreatePaymentWithOnlineAppl@1500063 Method

The procedure CreatePaymentWithOnlineAppl is available in codeunit 143006.

Syntax

CreatePaymentWithOnlineAppl@1500063(
    VAR GenJournalLine@1500006 : Record 81 GenJournalLine, //Reference parameter of type Record
    DocumentType@1500002 : Option DocumentType, //Input parameter of type Option
    Amount@1500000 : Decimal Amount //Input parameter of type Decimal
);

Parameters

GenJournalLine
Reference parameter of type Record
DocumentType
Input parameter of type Option
Amount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Payment, Online, Appl.

For a clarification about how this function works, refer to the code listed below.

      ApplyToDocumentType := GenJournalLine."Document Type";
      ApplyToDocumentNo := GenJournalLine."Document No.";
      LibraryERM.FindBankAccount(BankAccount);
      CreateGenJnllBatchWithBalAcc(GenJournalBatch);
      CurrencyCode := GenJournalLine."Currency Code";
      PostingDate := GenJournalLine."Posting Date";
      LibraryERM.CreateGeneralJnlLine(
        GenJournalLine,GenJournalBatch."Journal Template Name",GenJournalBatch.Name,
        DocumentType,GenJournalLine."Account Type",GenJournalLine."Account No.",Amount);
      GenJournalLine.VALIDATE("Document No.",
        LibraryUtility.GenerateRandomCode(GenJournalLine.FIELDNO("Document No."),DATABASE::"Gen. Journal Line"));
      GenJournalLine.VALIDATE("Posting Date",PostingDate);
      GenJournalLine.VALIDATE("Bal. Account Type",GenJournalLine."Bal. Account Type"::"Bank Account");
      GenJournalLine.VALIDATE("Bal. Account No.",BankAccount."No.");
      GenJournalLine.VALIDATE("Currency Code",CurrencyCode);
      GenJournalLine.VALIDATE("Applies-to Doc. Type",ApplyToDocumentType);
      GenJournalLine.VALIDATE("Applies-to Doc. No.",ApplyToDocumentNo);
      GenJournalLine.MODIFY;

Example

The below example is extracted from the test automation codeunit 144034 to show one way of using this function.

      ReverseServiceTaxHelper.CreatePaymentWithOnlineAppl(
        GenJournalLine,ReverseServiceTaxHelper.GetApplyingDocType(GenJournalLine."Document Type"),PaymentAmount);
      LibraryERM.PostGeneralJnlLine(GenJournalLine);
      EXIT(GenJournalLine."Document No.");
Member of Miscellaneous.Reverse Service Tax Helper


CreatePurchaseDoc@1500038 Method

The procedure CreatePurchaseDoc is available in codeunit 143006.

Syntax

CreatePurchaseDoc@1500038(
    VAR PurchaseHeader@1500000 : Record 38 PurchaseHeader, //Reference parameter of type Record
    VAR PurchaseLine@1500004 : Record 39 PurchaseLine, //Reference parameter of type Record
    DocumentType@1500001 : Option DocumentType, //Input parameter of type Option
    ReverseChargeType@1500002 : Option ReverseChargeType, //Input parameter of type Option
    ReverseChargePercentage@1500006 : Integer ReverseChargePercentage, //Input parameter of type Integer
    PoT@1500003 : Boolean PoT //Input parameter of type Boolean
);

Parameters

PurchaseHeader
Reference parameter of type Record
PurchaseLine
Reference parameter of type Record
DocumentType
Input parameter of type Option
ReverseChargeType
Input parameter of type Option
ReverseChargePercentage
Input parameter of type Integer
PoT
Input parameter of type Boolean

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Purchase, Document.

For a clarification about how this function works, refer to the code listed below.

      EXIT(CreatePurchaseDocForVendor(PurchaseHeader,PurchaseLine,CreateVendor,DocumentType,
          ReverseChargeType,ReverseChargePercentage,PoT))

Example

The below example is extracted from the test automation codeunit 144030 to show one way of using this function.

      Initialize;

      // Post Purchase Invoice
      ReverseServiceTaxHelper.CreatePurchaseDoc(PurchaseHeader,PurchaseLine,DocumentType,ReverseChargeType,
        LibraryRandom.RandInt(99),FALSE);
      ASSERTERROR ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);
      Assert.ExpectedError(STRSUBSTNO(SplitRevChargeAndPOTError,PurchaseHeader.FIELDCAPTION(PoT)));
Member of Miscellaneous.Reverse Service Tax Helper


CreatePurchaseDocForAdvPayment@1500048 Method

The procedure CreatePurchaseDocForAdvPayment is available in codeunit 143006.

Syntax

CreatePurchaseDocForAdvPayment@1500048(
    VAR PurchaseHeader@1500006 : Record 38 PurchaseHeader, //Reference parameter of type Record
    VAR PurchaseLine@1500005 : Record 39 PurchaseLine, //Reference parameter of type Record
    GenJournalLine@1500004 : Record 81 GenJournalLine, //Input parameter of type Record
    DocumentType@1500003 : Option DocumentType, //Input parameter of type Option
    ReverseChargeType@1500002 : Option ReverseChargeType, //Input parameter of type Option
    ReverseChargePercentage@1500007 : Integer ReverseChargePercentage, //Input parameter of type Integer
    PoT@1500001 : Boolean PoT, //Input parameter of type Boolean
    Amount@1500000 : Decimal Amount //Input parameter of type Decimal
);

Parameters

PurchaseHeader
Reference parameter of type Record
PurchaseLine
Reference parameter of type Record
GenJournalLine
Input parameter of type Record
DocumentType
Input parameter of type Option
ReverseChargeType
Input parameter of type Option
ReverseChargePercentage
Input parameter of type Integer
PoT
Input parameter of type Boolean
Amount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Purchase, Document, For, Adv, Payment.

For a clarification about how this function works, refer to the code listed below.

      CreatePurchaseHeaderByVendor(PurchaseHeader,DocumentType,GenJournalLine."Service Type (Rev. Chrg.)",
        PoT,GenJournalLine."Account No.");
      PurchaseHeader.VALIDATE("Posting Date",GenJournalLine."Posting Date");
      PurchaseHeader.VALIDATE("Currency Code",GenJournalLine."Currency Code");
      PurchaseHeader.MODIFY(TRUE);
      CreatePurchaseLineWithAmount(PurchaseLine,PurchaseHeader,GenJournalLine."Service Tax Group Code",
        GenJournalLine."Service Tax Registration No.",ReverseChargeType,ReverseChargePercentage,Amount);
      PurchaseLine.VALIDATE("Posting Group",GenJournalLine."Posting Group");
      PurchaseLine.MODIFY;

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      // Post a purchase document, based on the advance payment
      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      ReverseServiceTaxHelper.GetBaseAndTaxAmountFromAdvPmt(
        BaseAmount,TaxAmount,ServiceTaxSetup,GenJournalLine.Amount,TypeOfReverseCharge,100);

      ReverseServiceTaxHelper.CreatePurchaseDocForAdvPayment(
        PurchaseHeader,PurchaseLine,GenJournalLine,DocumentType,TypeOfReverseCharge,100,PoT,BaseAmount);

      // Exercise: Post the purchase document
      PostedPurchaseDocumentNo := ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);

      // values for verification
      ReverseServiceTaxHelper.ConvertDocToJnlLine(PurchaseHeader,PurchaseLine,PostedPurchaseDocumentNo,PurchaseGenJnlLine);
      PurchaseGenJnlLine."Service Tax Base Amount (LCY)" := BaseAmount;
      PurchaseGenJnlLine."Service Tax Amount" := TaxAmount;
Member of Miscellaneous.Reverse Service Tax Helper


CreatePurchaseDocForVendor@1500036 Method

The procedure CreatePurchaseDocForVendor is available in codeunit 143006.

Syntax

CreatePurchaseDocForVendor@1500036(
    VAR PurchaseHeader@1500004 : Record 38 PurchaseHeader, //Reference parameter of type Record
    VAR PurchaseLine@1500003 : Record 39 PurchaseLine, //Reference parameter of type Record
    VendorNo@1500005 : Code[20] VendorNo, //Input parameter of type Code
    DocumentType@1500002 : Option DocumentType, //Input parameter of type Option
    ReverseChargeType@1500001 : Option ReverseChargeType, //Input parameter of type Option
    ReverseChargePercentage@1500007 : Integer ReverseChargePercentage, //Input parameter of type Integer
    PoT@1500000 : Boolean PoT //Input parameter of type Boolean
);

Parameters

PurchaseHeader
Reference parameter of type Record
PurchaseLine
Reference parameter of type Record
VendorNo
Input parameter of type Code
DocumentType
Input parameter of type Option
ReverseChargeType
Input parameter of type Option
ReverseChargePercentage
Input parameter of type Integer
PoT
Input parameter of type Boolean

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Purchase, Document, For, Vendor.

For a clarification about how this function works, refer to the code listed below.

      CreateServiceTaxGroupSetup(ServiceTaxGroup);
      CreatePurchaseHeaderByVendor(PurchaseHeader,DocumentType,GetReverseChargeServType(ReverseChargeType),PoT,VendorNo);
      CreatePurchaseLine(PurchaseLine,PurchaseHeader,ServiceTaxGroup.Code,CreateServTaxRegNo,
        ReverseChargeType,ReverseChargePercentage);
      EXIT(ServiceTaxGroup.Code);

Example

There are no examples available.
Member of Miscellaneous.Reverse Service Tax Helper


CreatePurchaseDocFromGenJnl@1500071 Method

The procedure CreatePurchaseDocFromGenJnl is available in codeunit 143006.

Syntax

CreatePurchaseDocFromGenJnl@1500071(
    VAR GenJournalLine@1500000 : Record 81 GenJournalLine, //Reference parameter of type Record
    DocumentType@1500001 : Option DocumentType, //Input parameter of type Option
    ServiceTypeRevChrg@1500002 : Option ServiceTypeRevChrg, //Input parameter of type Option
    ReverseChargeType@1500006 : Option ReverseChargeType, //Input parameter of type Option
    PoT@1500004 : Boolean PoT, //Input parameter of type Boolean
    Percentage@1500005 : Integer Percentage //Input parameter of type Integer
);

Parameters

GenJournalLine
Reference parameter of type Record
DocumentType
Input parameter of type Option
ServiceTypeRevChrg
Input parameter of type Option
ReverseChargeType
Input parameter of type Option
PoT
Input parameter of type Boolean
Percentage
Input parameter of type Integer

Remarks

The relevant search keywords are: Create, Purchase, Document, From, General, Journal.

For a clarification about how this function works, refer to the code listed below.

      CreateGenJournalBatch(GenJournalBatch);
      CreateJnlLineWithServiceTax(GenJournalLine,GenJournalBatch,DocumentType,
        ServiceTypeRevChrg,ReverseChargeType,Percentage);
      GenJournalLine.VALIDATE(PoT,PoT);
      GenJournalLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      ReverseServiceTaxHelper.CreatePurchaseDocFromGenJnl(
        GenJournalLine,DocumentType,GetServiceTypeRevChrg(ReverseChargeType),ReverseChargeType,PoT,GetRevChargePct(ReverseChargeType));

      LibraryERM.PostGeneralJnlLine(GenJournalLine);
      EXIT(GenJournalLine."Document No.");
Member of Miscellaneous.Reverse Service Tax Helper


CreatePurchaseHeader@1500035 Method

The procedure CreatePurchaseHeader is available in codeunit 143006.

Syntax

CreatePurchaseHeader@1500035(
    VAR PurchaseHeader@1500000 : Record 38 PurchaseHeader, //Reference parameter of type Record
    DocumentType@1500004 : Option DocumentType, //Input parameter of type Option
    ReverseChargeServiceType@1500001 : Option ReverseChargeServiceType, //Input parameter of type Option
    PoT@1500005 : Boolean PoT //Input parameter of type Boolean
);

Parameters

PurchaseHeader
Reference parameter of type Record
DocumentType
Input parameter of type Option
ReverseChargeServiceType
Input parameter of type Option
PoT
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, Purchase, Header.

For a clarification about how this function works, refer to the code listed below.

      CreatePurchaseHeaderByVendor(PurchaseHeader,DocumentType,ReverseChargeServiceType,PoT,CreateVendor)

Example

The below example is extracted from the test automation codeunit 144030 to show one way of using this function.

      ReverseServiceTaxHelper.CreatePurchaseHeader(PurchaseHeader,PurchaseHeader."Document Type"::Invoice,
        PurchaseHeader."Service Type (Rev. Chrg.)"::Inward,FALSE);

      ReverseServiceTaxHelper.CreatePurchaseLine(PurchaseLine,PurchaseHeader,ServiceTaxGroup1,ServiceTaxRegNo1,ReverseChargeType1,100);
      ReverseServiceTaxHelper.CreatePurchaseLine(PurchaseLine,PurchaseHeader,ServiceTaxGroup2,ServiceTaxRegNo2,ReverseChargeType2,100);
Member of Miscellaneous.Reverse Service Tax Helper


CreatePurchaseHeaderByVendor@1500041 Method

The procedure CreatePurchaseHeaderByVendor is available in codeunit 143006.

Syntax

CreatePurchaseHeaderByVendor@1500041(
    VAR PurchaseHeader@1500000 : Record 38 PurchaseHeader, //Reference parameter of type Record
    DocumentType@1500004 : Option DocumentType, //Input parameter of type Option
    ReverseChargeServiceType@1500001 : Option ReverseChargeServiceType, //Input parameter of type Option
    PoT@1500005 : Boolean PoT, //Input parameter of type Boolean
    VendorNo@1500006 : Code[20] VendorNo //Input parameter of type Code
);

Parameters

PurchaseHeader
Reference parameter of type Record
DocumentType
Input parameter of type Option
ReverseChargeServiceType
Input parameter of type Option
PoT
Input parameter of type Boolean
VendorNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Purchase, Header, By, Vendor.

For a clarification about how this function works, refer to the code listed below.

      GetServiceTaxReturnPeriod(ServiceTaxReturnPeriod);
      LibraryServiceTax.CreateServiceTaxStructure(StructureHeader);

      CurrencyCode := PurchaseHeader."Currency Code";
      LibraryPurchase.CreatePurchHeader(PurchaseHeader,DocumentType,VendorNo);
      PurchaseHeader.VALIDATE("Posting Date",LibraryServiceTax.GetDateWithinSrvTaxPeriod(ServiceTaxReturnPeriod));
      PurchaseHeader.VALIDATE("Currency Code",CurrencyCode);
      PurchaseHeader.VALIDATE("Vendor Invoice No.",PurchaseHeader."No.");
      PurchaseHeader.VALIDATE("Vendor Cr. Memo No.",PurchaseHeader."No.");
      PurchaseHeader.VALIDATE("Consignment Note No.",PurchaseHeader."No.");
      PurchaseHeader.VALIDATE(Structure,StructureHeader.Code);
      PurchaseHeader.VALIDATE("Service Type (Rev. Chrg.)",ReverseChargeServiceType);
      PurchaseHeader.VALIDATE("Location Code",'');
      PurchaseHeader.VALIDATE(PoT,PoT);
      PurchaseHeader.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 144034 to show one way of using this function.

      ReverseServiceTaxHelper.CreatePurchaseHeaderByVendor(CrMemoPurchaseHeader,
        CrMemoPurchaseHeader."Document Type"::"Credit Memo",
        ReverseChargeTypeOption::Standard,TRUE,InvoiceGenJournalLine."Account No.");

      ReverseServiceTaxHelper.CreatePurchaseLineWithAmount(CrMemoPurchaseLine,CrMemoPurchaseHeader,
        InvoiceGenJournalLine."Service Tax Group Code",
        InvoiceGenJournalLine."Service Tax Registration No.",
        ReverseChargeTypeOption::Standard,
        GetRevChrgPercent(InvoiceGenJournalLine),ABS(Amount));

      CrMemoPurchaseHeader.VALIDATE("Applies-to Doc. Type",InvoiceGenJournalLine."Document Type");
      CrMemoPurchaseHeader.VALIDATE("Applies-to Doc. No.",InvoiceGenJournalLine."Document No.");
      CrMemoPurchaseHeader.MODIFY;

      EXIT(ReverseServiceTaxHelper.PostPurchaseDoc(CrMemoPurchaseHeader));
Member of Miscellaneous.Reverse Service Tax Helper


CreatePurchaseLine@5 Method

The procedure CreatePurchaseLine is available in codeunit 143006.

Syntax

CreatePurchaseLine@5(
    VAR PurchaseLine@1500001 : Record 39 PurchaseLine, //Reference parameter of type Record
    PurchaseHeader@1500000 : Record 38 PurchaseHeader, //Input parameter of type Record
    ServiceTaxGroupCode@1500003 : Code[20] ServiceTaxGroupCode, //Input parameter of type Code
    ServiceTaxRegNo@1500005 : Code[20] ServiceTaxRegNo, //Input parameter of type Code
    RevChargeType@1500002 : Option RevChargeType, //Input parameter of type Option
    ReverseChargePercentage@1500006 : Integer ReverseChargePercentage //Input parameter of type Integer
);

Parameters

PurchaseLine
Reference parameter of type Record
PurchaseHeader
Input parameter of type Record
ServiceTaxGroupCode
Input parameter of type Code
ServiceTaxRegNo
Input parameter of type Code
RevChargeType
Input parameter of type Option
ReverseChargePercentage
Input parameter of type Integer

Remarks

The relevant search keywords are: Create, Purchase, Line.

For a clarification about how this function works, refer to the code listed below.

      CreatePurchaseLineWithAmount(
        PurchaseLine,PurchaseHeader,ServiceTaxGroupCode,ServiceTaxRegNo,RevChargeType,ReverseChargePercentage,
        LibraryRandom.RandInt(20000));

Example

The below example is extracted from the test automation codeunit 144001 to show one way of using this function.

      CreateStructureCVDEnabled(StructureHeader);
      LocationCode :=
        LibraryLocation.CreateTradingLocation(
          ServiceTaxAsExciseHelper.CreateECCNoAndSeries(ExciseNoSeries.Type::RG23D,LibraryERM.CreateNoSeriesCode));
      ItemNo := CreateItemWithoutTaxGroup(ExcisePostingSetup."Excise Prod. Posting Group",FALSE);

      LibraryPurchase.CreatePurchHeader(
        PurchaseHeader,
        DocumentType,
        CreateVendorForeign(
          ExcisePostingSetup."Excise Bus. Posting Group",
          CurrencyFactor,
          LocationCode));
      PurchaseHeader.VALIDATE(Structure,StructureHeader.Code);
      PurchaseHeader.MODIFY(TRUE);

      LibraryPurchase.CreatePurchaseLine(
        PurchaseLine,
        PurchaseHeader,
        PurchaseLine.Type::Item,
        ItemNo,
        LibraryRandom.RandDecInRange(1000,2000,2));

      PurchaseLine.VALIDATE("Direct Unit Cost",LibraryRandom.RandDecInRange(10,20,2));
      PurchaseLine.VALIDATE("BCD Amount",BCDAmount);
      PurchaseLine.MODIFY(TRUE);

      CalculatePurchaseLines(PurchaseHeader);
      // Create Inventory Posting Setup for new item
      ServiceTaxAsExciseHelper.CreateInventoryPostingSetup(PurchaseLine."No.",LocationCode);
Member of Miscellaneous.Reverse Service Tax Helper


CreatePurchaseLineWithAmount@1500043 Method

The procedure CreatePurchaseLineWithAmount is available in codeunit 143006.

Syntax

CreatePurchaseLineWithAmount@1500043(
    VAR PurchaseLine@1500001 : Record 39 PurchaseLine, //Reference parameter of type Record
    PurchaseHeader@1500000 : Record 38 PurchaseHeader, //Input parameter of type Record
    ServiceTaxGroupCode@1500003 : Code[20] ServiceTaxGroupCode, //Input parameter of type Code
    ServiceTaxRegNo@1500005 : Code[20] ServiceTaxRegNo, //Input parameter of type Code
    RevChargeType@1500002 : Option RevChargeType, //Input parameter of type Option
    ReverseChargePercentage@1500007 : Integer ReverseChargePercentage, //Input parameter of type Integer
    Amount@1500006 : Decimal Amount //Input parameter of type Decimal
);

Parameters

PurchaseLine
Reference parameter of type Record
PurchaseHeader
Input parameter of type Record
ServiceTaxGroupCode
Input parameter of type Code
ServiceTaxRegNo
Input parameter of type Code
RevChargeType
Input parameter of type Option
ReverseChargePercentage
Input parameter of type Integer
Amount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Create, Purchase, Line, Amount.

For a clarification about how this function works, refer to the code listed below.

      LibraryPurchase.CreatePurchaseLine(PurchaseLine,PurchaseHeader,
        PurchaseLine.Type::"G/L Account",CreateGLAccount(ServiceTaxGroupCode),1);
      PurchaseLine.VALIDATE("Service Tax Registration No.",ServiceTaxRegNo);
      PurchaseLine.VALIDATE("Direct Unit Cost",Amount);
      PurchaseLine.MODIFY(TRUE);

      CreateSTRevChrgSetupFromPurch(PurchaseLine,RevChargeType,ReverseChargePercentage);

Example

The below example is extracted from the test automation codeunit 144034 to show one way of using this function.

      ReverseServiceTaxHelper.CreatePurchaseHeaderByVendor(CrMemoPurchaseHeader,
        CrMemoPurchaseHeader."Document Type"::"Credit Memo",
        ReverseChargeTypeOption::Standard,TRUE,InvoiceGenJournalLine."Account No.");

      ReverseServiceTaxHelper.CreatePurchaseLineWithAmount(CrMemoPurchaseLine,CrMemoPurchaseHeader,
        InvoiceGenJournalLine."Service Tax Group Code",
        InvoiceGenJournalLine."Service Tax Registration No.",
        ReverseChargeTypeOption::Standard,
        GetRevChrgPercent(InvoiceGenJournalLine),ABS(Amount));

      CrMemoPurchaseHeader.VALIDATE("Applies-to Doc. Type",InvoiceGenJournalLine."Document Type");
      CrMemoPurchaseHeader.VALIDATE("Applies-to Doc. No.",InvoiceGenJournalLine."Document No.");
      CrMemoPurchaseHeader.MODIFY;

      EXIT(ReverseServiceTaxHelper.PostPurchaseDoc(CrMemoPurchaseHeader));
Member of Miscellaneous.Reverse Service Tax Helper


CreateSalesDocFromGenJnl@1500093 Method

The procedure CreateSalesDocFromGenJnl is available in codeunit 143006.

Syntax

CreateSalesDocFromGenJnl@1500093(
    VAR GenJournalLine@1500004 : Record 81 GenJournalLine, //Reference parameter of type Record
    DocumentType@1500003 : Option DocumentType, //Input parameter of type Option
    Amount@1500006 : Decimal Amount, //Input parameter of type Decimal
    PostingDate@1500007 : Date PostingDate, //Input parameter of type Date
    ServiceTaxGroupCode@1500008 : Code[20] ServiceTaxGroupCode, //Input parameter of type Code
    ServiceTaxRegistrationNo@1500009 : Code[20] ServiceTaxRegistrationNo //Input parameter of type Code
);

Parameters

GenJournalLine
Reference parameter of type Record
DocumentType
Input parameter of type Option
Amount
Input parameter of type Decimal
PostingDate
Input parameter of type Date
ServiceTaxGroupCode
Input parameter of type Code
ServiceTaxRegistrationNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Sales, Document, From, General, Journal.

For a clarification about how this function works, refer to the code listed below.

      CreateGenJournalBatch(GenJournalBatch);
      CreateSalesJnlLineWithST(
        GenJournalLine,GenJournalBatch,DocumentType,Amount,PostingDate,ServiceTaxGroupCode,ServiceTaxRegistrationNo);

Example

The below example is extracted from the test automation codeunit 144041 to show one way of using this function.

      IF GenJournalLine."Account No." = '' THEN
        CreateJnlLineWithServiceTax(GenJournalLine,ReverseServiceTaxHelper.GetApplyingDocType(DocumentType));
      ReverseServiceTaxHelper.CreateSalesDocFromGenJnl(
        GenJournalLine,DocumentType,-GenJournalLine."Service Tax Base Amount (LCY)",GenJournalLine."Posting Date",
        GenJournalLine."Service Tax Group Code",GenJournalLine."Service Tax Registration No.");
Member of Miscellaneous.Reverse Service Tax Helper


CreateSalesJnlLineNormalPmt@1500061 Method

The procedure CreateSalesJnlLineNormalPmt is available in codeunit 143006.

Syntax

CreateSalesJnlLineNormalPmt@1500061(
    VAR GenJournalLine@1170000001 : Record 81 GenJournalLine, //Reference parameter of type Record
    DocumentType@1500002 : Option DocumentType, //Input parameter of type Option
    CustomerNo@1500007 : Code[20] CustomerNo, //Input parameter of type Code
    Amount@1500003 : Decimal Amount, //Input parameter of type Decimal
    PostingDate@1500005 : Date PostingDate //Input parameter of type Date
);

Parameters

GenJournalLine
Reference parameter of type Record
DocumentType
Input parameter of type Option
CustomerNo
Input parameter of type Code
Amount
Input parameter of type Decimal
PostingDate
Input parameter of type Date

Remarks

The relevant search keywords are: Create, Sales, Journal, Line, Normal, Payment.

For a clarification about how this function works, refer to the code listed below.

      CreateGenJournalBatch(GenJournalBatch);
      LibraryERM.CreateGeneralJnlLine(
        GenJournalLine,GenJournalBatch."Journal Template Name",GenJournalBatch.Name,
        DocumentType,GenJournalLine."Account Type"::Customer,CustomerNo,Amount);
      WITH GenJournalLine DO BEGIN
        VALIDATE("Bal. Account Type","Bal. Account Type"::"Bank Account");
        LibraryERM.FindBankAccount(BankAccount);
        VALIDATE("Bal. Account No.",BankAccount."No.");
        VALIDATE("Posting Date",PostingDate);
        VALIDATE("Document No.",LibraryUtility.GenerateRandomCode(FIELDNO("Document No."),DATABASE::"Gen. Journal Line"));
        VALIDATE("External Document No.","Document No.");
      END;

Example

The below example is extracted from the test automation codeunit 144041 to show one way of using this function.

      ReverseServiceTaxHelper.CreateServiceTaxSetup(ServiceTaxSetup,ServiceTaxRegNoCode);
      BaseAmount := ReverseServiceTaxHelper.RandomAmountForSalesDocType(DocumentType);
      IF DocumentType IN [GenJournalLine."Document Type"::Payment,GenJournalLine."Document Type"::Refund] THEN
        LineAmount := BaseAmount + ReverseServiceTaxHelper.CalculateServTaxTotal(BaseAmount,ServiceTaxSetup)
      ELSE
        LineAmount := BaseAmount;
      PoT := GenJournalLine.PoT;
      ReverseServiceTaxHelper.CreateSalesJnlLineNormalPmt(
        GenJournalLine,DocumentType,ReverseServiceTaxHelper.CreateCustomer,
        LineAmount,ServiceTaxSetup."From Date");
      GenJournalLine.VALIDATE("Posting Date",ServiceTaxSetup."From Date");
      GenJournalLine.VALIDATE("Service Tax Group Code",ServiceTaxSetup.Code);
      GenJournalLine.VALIDATE("Service Tax Registration No.",ServiceTaxRegNoCode);
      IF DocumentType IN [GenJournalLine."Document Type"::Payment,GenJournalLine."Document Type"::Refund] THEN
        GenJournalLine.VALIDATE("Serv. Tax on Advance Payment",TRUE);
      ReverseServiceTaxHelper.InvokeForwardStaxCalculation(GenJournalLine);
      GenJournalLine.VALIDATE(PoT,PoT);
Member of Miscellaneous.Reverse Service Tax Helper


CreateSalesJnlLineWithServTax@1500058 Method

The procedure CreateSalesJnlLineWithServTax is available in codeunit 143006.

Syntax

CreateSalesJnlLineWithServTax@1500058(
    VAR GenJournalLine@1170000001 : Record 81 GenJournalLine, //Reference parameter of type Record
    DocumentType@1500002 : Option DocumentType //Input parameter of type Option
);

Parameters

GenJournalLine
Reference parameter of type Record
DocumentType
Input parameter of type Option

Remarks

The relevant search keywords are: Create, Sales, Journal, Line, Serv, Tax.

For a clarification about how this function works, refer to the code listed below.

      CreateServiceTaxSetup(ServiceTaxSetup,ServiceTaxRegNoCode);
      BaseAmount := RandomAmountForSalesDocType(DocumentType);
      IF DocumentType IN [GenJournalLine."Document Type"::Payment,GenJournalLine."Document Type"::Refund] THEN
        LineAmount := BaseAmount + CalculateServTaxTotal(BaseAmount,ServiceTaxSetup)
      ELSE
        LineAmount := BaseAmount;
      PoT := GenJournalLine.PoT;
      CreateSalesJnlLineNormalPmt(
        GenJournalLine,DocumentType,CreateCustomer,LineAmount,ServiceTaxSetup."From Date");
      GenJournalLine.VALIDATE("Posting Date",ServiceTaxSetup."From Date");
      GenJournalLine.VALIDATE("Service Tax Group Code",ServiceTaxSetup.Code);
      GenJournalLine.VALIDATE("Service Tax Registration No.",ServiceTaxRegNoCode);
      IF DocumentType IN [GenJournalLine."Document Type"::Payment,GenJournalLine."Document Type"::Refund] THEN
        GenJournalLine.VALIDATE("Serv. Tax on Advance Payment",TRUE);
      GenJournalLine.VALIDATE("Service Tax Base Amount (LCY)",BaseAmount);
      GenJournalLine.VALIDATE(PoT,PoT);

Example

The below example is extracted from the test automation codeunit 144045 to show one way of using this function.

      Initialize;
      WITH GenJournalLine DO BEGIN
        ReverseServiceTaxHelper.CreateSalesJnlLineWithServTax(GenJournalLine,"Document Type"::"Credit Memo");
        VALIDATE("Service Tax Base Amount (LCY)",0);
        Assert.AreEqual(0,"Service Tax Base Amount (LCY)",'Service Tax Base Amount (LCY) should be zero');
        Assert.AreEqual(0,"Amount (LCY)",'Amount (LCY) should be zero');
        Assert.AreEqual(0,Amount,'Amount should be zero');
      END;
Member of Miscellaneous.Reverse Service Tax Helper


CreateServiceTaxGroupAndSetup@1500099 Method

The procedure CreateServiceTaxGroupAndSetup is available in codeunit 143006.

Syntax

CreateServiceTaxGroupAndSetup@1500099(
    VAR ServiceTaxGroup@1500001 : Record 16471 ServiceTaxGroup, //Reference parameter of type Record
    VAR ServiceTaxSetup@1500002 : Record 16472 ServiceTaxSetup //Reference parameter of type Record
);

Parameters

ServiceTaxGroup
Reference parameter of type Record
ServiceTaxSetup
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Service, Tax, Group, Setup.

For a clarification about how this function works, refer to the code listed below.

      GetServiceTaxReturnPeriod(ServiceTaxReturnPeriod);
      LibraryServiceTax.CreateServiceTaxGroup(ServiceTaxGroup);

      FromDate := LibraryServiceTax.GetSrvTaxReturnPeriodStartDate(ServiceTaxReturnPeriod);
      LibraryServiceTax.CreateServiceTaxSetup(ServiceTaxGroup.Code,FromDate);
      ServiceTaxSetup.FindOnDate(ServiceTaxGroup.Code,FromDate);

Example

The below example is extracted from the test automation codeunit 144038 to show one way of using this function.

      ReverseServiceTaxHelper.CreateServiceTaxGroupAndSetup(ServiceTaxGroup,ServiceTaxSetup);
      ServiceTaxSetup.VALIDATE("Abatement %",LibraryRandom.RandDecInRange(10,90,2));
      ServiceTaxSetup.MODIFY(TRUE);

      ReverseServiceTaxHelper.CreatePurchaseHeaderByVendor(
        PurchaseHeader,DocumentType,
        ReverseServiceTaxHelper.GetReverseChargeServType(ReverseChargeType),PoT,
        ReverseServiceTaxHelper.CreateVendor);
      ReverseServiceTaxHelper.CreatePurchaseLine(
        PurchaseLine,PurchaseHeader,ServiceTaxGroup.Code,
        ReverseServiceTaxHelper.CreateServTaxRegNo,ReverseChargeType,ReverseChargePercentage);
      EXIT(ServiceTaxGroup.Code);
Member of Miscellaneous.Reverse Service Tax Helper


CreateServiceTaxGroupSetup@1500017 Method

The procedure CreateServiceTaxGroupSetup is available in codeunit 143006.

Syntax

CreateServiceTaxGroupSetup@1500017(
    VAR ServiceTaxGroup@1500001 : Record 16471 ServiceTaxGroup //Reference parameter of type Record
);

Parameters

ServiceTaxGroup
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Service, Tax, Group, Setup.

For a clarification about how this function works, refer to the code listed below.

      GetServiceTaxReturnPeriod(ServiceTaxReturnPeriod);
      LibraryServiceTax.CreateServiceTaxGroup(ServiceTaxGroup);
      LibraryServiceTax.CreateServiceTaxSetup(
        ServiceTaxGroup.Code,
        LibraryServiceTax.GetSrvTaxReturnPeriodStartDate(ServiceTaxReturnPeriod));

Example

The below example is extracted from the test automation codeunit 144030 to show one way of using this function.

      ReverseServiceTaxHelper.CreateServiceTaxGroupSetup(ServiceTaxGroup1);
      ReverseServiceTaxHelper.CreateServiceTaxGroupSetup(ServiceTaxGroup2);
      LibraryServiceTax.CreateServiceTaxRegistrationNo(ServiceTaxRegNo);

      CreateInvoiceWithMixedLines(PurchaseHeader,ReverseChargeType,ReverseChargeType,
        ServiceTaxGroup1.Code,ServiceTaxGroup2.Code,ServiceTaxRegNo.Code,ServiceTaxRegNo.Code);
Member of Miscellaneous.Reverse Service Tax Helper


CreateServiceTaxSetup@1500059 Method

The procedure CreateServiceTaxSetup is available in codeunit 143006.

Syntax

CreateServiceTaxSetup@1500059(
    VAR ServiceTaxSetup@1500000 : Record 16472 ServiceTaxSetup, //Reference parameter of type Record
    VAR ServiceTaxRegNoCode@1500001 : Code[20] ServiceTaxRegNoCode //Reference parameter of type Code
);

Parameters

ServiceTaxSetup
Reference parameter of type Record
ServiceTaxRegNoCode
Reference parameter of type Code

Remarks

The relevant search keywords are: Create, Service, Tax, Setup.

For a clarification about how this function works, refer to the code listed below.

      LibraryServiceTax.CreateServiceTaxRegistrationNo(ServiceTaxRegNo);
      ServiceTaxRegNoCode := ServiceTaxRegNo.Code;
      CreateServiceTaxGroupSetup(ServiceTaxGroup);
      ServiceTaxSetup.SETRANGE(Code,ServiceTaxGroup.Code);
      ServiceTaxSetup.FINDFIRST;

Example

The below example is extracted from the test automation codeunit 144014 to show one way of using this function.

      IF IsInitialized THEN
        EXIT;
      LibraryServiceTax.CreateServiceTaxRegistrationNo(ServiceTaxRegistrationNos);
      LibraryServiceTax.CreateServiceTaxGroup(ServiceTaxGroups);
      LibraryServiceTax.CreateServiceTaxSetup(ServiceTaxGroups.Code,WORKDATE - 1);
      CreateTaxSetupAndStateAndLocations;
      GeneralLedgerSetup.GET;
      ServiceTaxSetup.GET(ServiceTaxGroups.Code,WORKDATE - 1);
      IsInitialized := TRUE;
      COMMIT;
Member of Miscellaneous.Reverse Service Tax Helper


CreateServTaxRegNo@1500019 Method

The procedure CreateServTaxRegNo is available in codeunit 143006.

Syntax

CreateServTaxRegNo@1500019(
      //param element not supplied
);

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Serv, Tax, Reg, No.

For a clarification about how this function works, refer to the code listed below.

      LibraryServiceTax.CreateServiceTaxRegistrationNo(ServTaxRegNo);
      EXIT(ServTaxRegNo.Code);

Example

The below example is extracted from the test automation codeunit 144033 to show one way of using this function.

      Initialize;
      ServiceTypeReverseCharge := PurchaseHeader."Service Type (Rev. Chrg.)"::Inward;

      // Post Invoice
      ReverseServiceTaxHelper.CreateServiceTaxGroupSetup(ServiceTaxGroup);
      VendorNo := ReverseServiceTaxHelper.CreateVendor;
      ServRegNo := ReverseServiceTaxHelper.CreateServTaxRegNo;
      Amount := 10000;
      PostedInvoiceNo := ReverseServiceTaxHelper.PostPurchaseDocForVendWithAmt(
          PurchaseHeader,PurchaseLine,VendorNo,PurchaseHeader."Document Type"::Invoice,
          ServiceTypeReverseCharge,ServiceTaxType::Standard,FALSE,ServRegNo,ServiceTaxGroup.Code,Amount);

      // Post Cr. Memo with different service tax group
      ReverseServiceTaxHelper.CreateNewServGrpForRevChPLine(PurchaseLine,ServiceTaxGroup);
      PostedCrMNo := ReverseServiceTaxHelper.PostPurchaseDocForVendWithAmt(
          PurchaseHeaderCrM,PurchaseLineCrM,VendorNo,
          PurchaseHeaderCrM."Document Type"::"Credit Memo",ServiceTypeReverseCharge,
          ServiceTaxType::Standard,FALSE,ServRegNo,ServiceTaxGroup.Code,Amount);

      // Try to apply
      ASSERTERROR ReverseServiceTaxHelper.ApplyAndPostVendorEntry(VendorLedgerEntry."Document Type"::Invoice,PostedInvoiceNo,
          VendorLedgerEntry."Document Type"::"Credit Memo",PostedCrMNo);
      Assert.ExpectedError(ServiceTaxGroupCodeErr);
Member of Miscellaneous.Reverse Service Tax Helper


CreateSplitDocJnlLine@1500074 Method

The procedure CreateSplitDocJnlLine is available in codeunit 143006.

Syntax

CreateSplitDocJnlLine@1500074(
    VAR GenJournalLine@1500000 : Record 81 GenJournalLine, //Reference parameter of type Record
    DocumentType@1500001 : Option DocumentType //Input parameter of type Option
);

Parameters

GenJournalLine
Reference parameter of type Record
DocumentType
Input parameter of type Option

Remarks

The relevant search keywords are: Create, Split, Document, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      Percentage := LibraryRandom.RandIntInRange(10,90);
      CreatePurchaseDocFromGenJnl(
        GenJournalLine,DocumentType,GenJournalLine."Service Type (Rev. Chrg.)"::Inward,
        ReverseChargeTypeOption::Standard,TRUE,Percentage);

Example

The below example is extracted from the test automation codeunit 144034 to show one way of using this function.

      Initialize;

      // Setup
      ReverseServiceTaxHelper.CreateSplitDocJnlLine(GenJournalLine,GenJournalLine."Document Type"::Invoice);
      GenJournalLine."Applies-to ID" := GenJournalLine."Document No.";
      GenJournalLine.MODIFY;

      InvoiceAmount := CalculatePaymentAmount(GenJournalLine);

      // 1st Payment
      PartialFactor := GetPartialFactor;
      AppliedDocAmount := ROUND(InvoiceAmount * PartialFactor);
      AppliedDocNo[1] := PostPaymentWithAmount(GenJournalLine,AppliedDocAmount);

      // 2nd Payment
      AppliedDocAmount := InvoiceAmount - AppliedDocAmount;
      IF DocumentType = GenJournalLine."Document Type"::Payment THEN
        AppliedDocNo[2] := PostPaymentWithAmount(GenJournalLine,AppliedDocAmount)
      ELSE
        AppliedDocNo[2] := PostCrMemoForInvoice(GenJournalLine,AppliedDocAmount);

      SetAppliesToID(AppliedDocNo,GenJournalLine);

      // Exercise & Verify
      ASSERTERROR LibraryERM.PostGeneralJnlLine(GenJournalLine);
      Assert.ExpectedError(MultipleAppErr);
Member of Miscellaneous.Reverse Service Tax Helper


CreateSTRevChrgSetupFromJnl@1500004 Method

The procedure CreateSTRevChrgSetupFromJnl is available in codeunit 143006.

Syntax

CreateSTRevChrgSetupFromJnl@1500004(
    GenJournalLine@1500001 : Record 81 GenJournalLine, //Input parameter of type Record
    RevChargeType@1500002 : Option RevChargeType, //Input parameter of type Option
    ReverseChargePercentage@1500004 : Integer ReverseChargePercentage //Input parameter of type Integer
);

Parameters

GenJournalLine
Input parameter of type Record
RevChargeType
Input parameter of type Option
ReverseChargePercentage
Input parameter of type Integer

Remarks

The relevant search keywords are: Create, ST, Rev, Chrg, Setup, From, Journal.

For a clarification about how this function works, refer to the code listed below.

      IF RevChargeType = ReverseChargeTypeOption::" " THEN
        EXIT;

      Vendor.GET(GenJournalLine."Account No.");
      LibraryServiceTax.CreateSrvTaxReverseChargeSetup(
        GenJournalLine."Service Tax Group Code",
        Vendor."Service Entity Type",
        ServiceTaxRegNo.GetServiceEntityType(GenJournalLine."Service Tax Registration No."),
        ConvertSTReverseCharge(RevChargeType),ReverseChargePercentage);

Example

The below example is extracted from the test automation codeunit 144033 to show one way of using this function.

      DocumentType := GenJournalLine."Document Type"::"Credit Memo";
      ReverseServiceTaxHelper.CreateGenJournalBatch(GenJournalBatch);
      ReverseServiceTaxHelper.CreateJnlLineWithSTNoSetup(GenJournalLine,GenJournalBatch,DocumentType,
        GenJournalLine."Service Type (Rev. Chrg.)",GenJournalLine."Account No.",-GenJournalLine."Amount (LCY)",
        GenJournalLine."Posting Date",GenJournalLine."Service Tax Registration No.",
        GenJournalLine."Service Tax Group Code");
      ReverseServiceTaxHelper.CreateSTRevChrgSetupFromJnl(GenJournalLine,GenJournalLine."Service Type (Rev. Chrg.)",100);
      GenJournalLine.VALIDATE(PoT,FALSE);
      GenJournalLine.VALIDATE("Applies-to Doc. Type",AppliesToDocType);
      GenJournalLine.VALIDATE("Applies-to Doc. No.",AppliesToDocNo);
      GenJournalLine.MODIFY(TRUE);
      LibraryERM.PostGeneralJnlLine(GenJournalLine);
Member of Miscellaneous.Reverse Service Tax Helper


CreateSTRevChrgSetupFromPurch@1500016 Method

The procedure CreateSTRevChrgSetupFromPurch is available in codeunit 143006.

Syntax

CreateSTRevChrgSetupFromPurch@1500016(
    PurchaseLine@1500000 : Record 39 PurchaseLine, //Input parameter of type Record
    RevChargeType@1500001 : Option RevChargeType, //Input parameter of type Option
    ReverseChargePercentage@1500004 : Integer ReverseChargePercentage //Input parameter of type Integer
);

Parameters

PurchaseLine
Input parameter of type Record
RevChargeType
Input parameter of type Option
ReverseChargePercentage
Input parameter of type Integer

Remarks

The relevant search keywords are: Create, ST, Rev, Chrg, Setup, From, Purchase.

For a clarification about how this function works, refer to the code listed below.

      IF RevChargeType = ReverseChargeTypeOption::" " THEN
        EXIT;

      Vendor.GET(PurchaseLine."Buy-from Vendor No.");
      LibraryServiceTax.CreateSrvTaxReverseChargeSetup(
        PurchaseLine."Service Tax Group",
        Vendor."Service Entity Type",
        ServiceTaxRegNo.GetServiceEntityType(PurchaseLine."Service Tax Registration No."),
        ConvertSTReverseCharge(RevChargeType),ReverseChargePercentage);

Example

There are no examples available.
Member of Miscellaneous.Reverse Service Tax Helper


CreateVendor@8 Method

The procedure CreateVendor is available in codeunit 143006.

Syntax

CreateVendor@8(
      //param element not supplied
);

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Vendor.

For a clarification about how this function works, refer to the code listed below.

      LibraryServiceTax.CreateServiceEntityType(ServiceEntityType);
      LibraryERM.FindGeneralPostingSetup(GeneralPostingSetup);
      CreateLocation(Location);

      LibraryPurchase.CreateVendor(Vendor);
      Vendor.VALIDATE("Gen. Bus. Posting Group",GeneralPostingSetup."Gen. Bus. Posting Group");
      Vendor.VALIDATE("Service Entity Type",ServiceEntityType.Code);
      Vendor.VALIDATE("Location Code",Location.Code);
      Vendor.MODIFY(TRUE);
      EXIT(Vendor."No.");

Example

The below example is extracted from the test automation codeunit 144001 to show one way of using this function.

      WITH Vendor DO BEGIN
        LibraryPurchase.CreateVendor(Vendor);
        VALIDATE("Excise Bus. Posting Group",ExciseBusPostingGroup);
        VALIDATE("Gen. Bus. Posting Group",GenBusPostingGroup);
        MODIFY(TRUE);
        EXIT("No.");
      END;
Member of Miscellaneous.Reverse Service Tax Helper


FillExpectedAmntsFullPurchFlow@1500040 Method

The procedure FillExpectedAmntsFullPurchFlow is available in codeunit 143006.

Syntax

FillExpectedAmntsFullPurchFlow@1500040(
    VAR ExpectedServTaxEntryDetails@1500000 : Record 16474 ExpectedServTaxEntryDetails, //Reference parameter of type Record
    ExpectedServTaxEntry@1500001 : Record 16473 ExpectedServTaxEntry //Input parameter of type Record
);

Parameters

ExpectedServTaxEntryDetails
Reference parameter of type Record
ExpectedServTaxEntry
Input parameter of type Record

Remarks

The relevant search keywords are: Fill, Expected, Amnts, Full, Purchase, Flow.

For a clarification about how this function works, refer to the code listed below.

      WITH ExpectedServTaxEntryDetails DO BEGIN
        "Service Tax Amount" := ExpectedServTaxEntry."Service Tax Amount";
        "Service Tax eCess Amount" := ExpectedServTaxEntry."eCess Amount";
        "Service Tax SHE Cess Amount" := ExpectedServTaxEntry."SHE Cess Amount";
        "Service Tax SBC Amount" := ExpectedServTaxEntry."Service Tax SBC Amount";
        "KK Cess Amount" := ExpectedServTaxEntry."KK Cess Amount";
        "Remaining Credit" := ExpectedServTaxEntry."Service Tax Amount";
        "Remaining Credit (eCess)" := ExpectedServTaxEntry."eCess Amount";
        "Remaining Credit (SHECess)" := ExpectedServTaxEntry."SHE Cess Amount";
        "Remaining Credit (KK Cess)" := ExpectedServTaxEntry."KK Cess Amount";
        "Rev. Chrg. Remaining Credit" := 0;
        "Rev. Chrg. Rem. Credit (eCESS)" := 0;
        "Rev. Chrg. Rem. Cr. (SHECess)" := 0;
        "Rev. Chrg. Rem. Credit (KKC)" := 0;
      END;

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      ReverseServiceTaxHelper.FillExpectedAmntsSTEntry(PmtGenJnlLine,PmtBaseAmount + InvBaseAmount,ExpectedServTaxEntry);
      ServiceTaxVerify.STEntryBalances(LastTransactionNo,ExpectedServTaxEntry);

      IF PmtBaseAmount < InvBaseAmount THEN
        ReverseServiceTaxHelper.FillExpectedAmntsSTEntry(PmtGenJnlLine,PmtBaseAmount,ExpectedServTaxEntry)
      ELSE
        ReverseServiceTaxHelper.FillExpectedAmntsSTEntry(PmtGenJnlLine,InvBaseAmount,ExpectedServTaxEntry);

      ReverseServiceTaxHelper.FillExpectedAmntsFullPurchFlow(ExpectedServTaxEntryDetails,ExpectedServTaxEntry);
      ServiceTaxVerify.STEntryDtlsBalancesAndStatuses(LastTransactionNo,ExpectedServTaxEntryDetails);
Member of Miscellaneous.Reverse Service Tax Helper


FillExpectedAmntsRevChrgAppln@1500039 Method

The procedure FillExpectedAmntsRevChrgAppln is available in codeunit 143006.

Syntax

FillExpectedAmntsRevChrgAppln@1500039(
    VAR ExpectedServTaxEntryDetails@1500000 : Record 16474 ExpectedServTaxEntryDetails, //Reference parameter of type Record
    ExpectedServTaxEntry@1500001 : Record 16473 ExpectedServTaxEntry //Input parameter of type Record
);

Parameters

ExpectedServTaxEntryDetails
Reference parameter of type Record
ExpectedServTaxEntry
Input parameter of type Record

Remarks

The relevant search keywords are: Fill, Expected, Amnts, Rev, Chrg, Application.

For a clarification about how this function works, refer to the code listed below.

      WITH ExpectedServTaxEntryDetails DO BEGIN
        "Service Tax Amount" := ExpectedServTaxEntry."Service Tax Amount";
        "Service Tax eCess Amount" := ExpectedServTaxEntry."eCess Amount";
        "Service Tax SHE Cess Amount" := ExpectedServTaxEntry."SHE Cess Amount";
        "Service Tax SBC Amount" := ExpectedServTaxEntry."Service Tax SBC Amount";
        "KK Cess Amount" := ExpectedServTaxEntry."KK Cess Amount";
        "Remaining Credit" := 0;
        "Remaining Credit (eCess)" := 0;
        "Remaining Credit (SHECess)" := 0;
        "Remaining Credit (KK Cess)" := 0;
        "Rev. Chrg. Remaining Credit" := ExpectedServTaxEntry."Service Tax Amount";
        "Rev. Chrg. Rem. Credit (eCESS)" := ExpectedServTaxEntry."eCess Amount";
        "Rev. Chrg. Rem. Cr. (SHECess)" := ExpectedServTaxEntry."SHE Cess Amount";
        "Rev. Chrg. Rem. Credit (KKC)" := ExpectedServTaxEntry."KK Cess Amount";
      END;

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      IF PmtBaseAmount > InvBaseAmount THEN
        BaseAmount := PmtBaseAmount
      ELSE
        BaseAmount := InvBaseAmount;

      ReverseServiceTaxHelper.FillExpectedAmntsSTEntry(PmtGenJnlLine,BaseAmount,ExpectedServTaxEntry);

      ServiceTaxVerify.STEntryBalances(LastTransactionNo,ExpectedServTaxEntry);

      IF PmtBaseAmount < InvBaseAmount THEN
        ReverseServiceTaxHelper.FillExpectedAmntsSTEntry(PmtGenJnlLine,PmtBaseAmount,ExpectedServTaxEntry);

      ReverseServiceTaxHelper.FillExpectedAmntsRevChrgAppln(ExpectedServTaxEntryDetails,ExpectedServTaxEntry);

      ServiceTaxVerify.STEntryDtlsBalancesAndStatuses(LastTransactionNo,ExpectedServTaxEntryDetails);
Member of Miscellaneous.Reverse Service Tax Helper


FillExpectedAmntsSTEntry@1500037 Method

The procedure FillExpectedAmntsSTEntry is available in codeunit 143006.

Syntax

FillExpectedAmntsSTEntry@1500037(
    GenJnlLine@1500004 : Record 81 GenJnlLine, //Input parameter of type Record
    BaseAmount@1500010 : Decimal BaseAmount, //Input parameter of type Decimal
    VAR ServTaxEntry@1500009 : Record 16473 ServTaxEntry //Reference parameter of type Record
);

Parameters

GenJnlLine
Input parameter of type Record
BaseAmount
Input parameter of type Decimal
ServTaxEntry
Reference parameter of type Record

Remarks

The relevant search keywords are: Fill, Expected, Amnts, ST, Entry.

For a clarification about how this function works, refer to the code listed below.

      Percentage := GetRevChrgPercent(GenJnlLine);
      ServTaxSetup.FindOnDate(GenJnlLine."Service Tax Group Code",GenJnlLine."Posting Date");

      ServTaxEntry."Service Tax Base Amount" := BaseAmount;
      ServTaxEntry."Service Tax Amount" := CalculateServTax(BaseAmount,ServTaxSetup);
      ServTaxEntry."eCess Amount" := CalculateECess(BaseAmount,ServTaxSetup);
      ServTaxEntry."SHE Cess Amount" := CalculateSHECess(BaseAmount,ServTaxSetup);
      ServTaxEntry."Service Tax SBC Amount" := CalculateSBC(BaseAmount,ServTaxSetup);
      ServTaxEntry."KK Cess Amount" := CalculateKKCess(BaseAmount,ServTaxSetup);
      ServTaxEntry."Reverse Charge" := Percentage = 100;

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      ReverseServiceTaxHelper.FillExpectedAmntsSTEntry(PmtGenJnlLine,PmtBaseAmount + InvBaseAmount,ExpectedServTaxEntry);
      ServiceTaxVerify.STEntryBalances(LastTransactionNo,ExpectedServTaxEntry);

      IF PmtBaseAmount < InvBaseAmount THEN
        ReverseServiceTaxHelper.FillExpectedAmntsSTEntry(PmtGenJnlLine,PmtBaseAmount,ExpectedServTaxEntry)
      ELSE
        ReverseServiceTaxHelper.FillExpectedAmntsSTEntry(PmtGenJnlLine,InvBaseAmount,ExpectedServTaxEntry);

      ReverseServiceTaxHelper.FillExpectedAmntsFullPurchFlow(ExpectedServTaxEntryDetails,ExpectedServTaxEntry);
      ServiceTaxVerify.STEntryDtlsBalancesAndStatuses(LastTransactionNo,ExpectedServTaxEntryDetails);
Member of Miscellaneous.Reverse Service Tax Helper


FindCurrencyCode@1500068 Method

The procedure FindCurrencyCode is available in codeunit 143006.

Syntax

FindCurrencyCode@1500068(
      //param element not supplied
);

Return Value

Code[10]

Remarks

The relevant search keywords are: Find, Currency, Code.

For a clarification about how this function works, refer to the code listed below.

      Currency.SETRANGE("Invoice Rounding Precision",0.01);
      LibraryERM.FindCurrency(Currency);
      EXIT(Currency.Code);

Example

The below example is extracted from the test automation codeunit 144034 to show one way of using this function.

      Initialize;

      PurchaseHeader."Currency Code" := ReverseServiceTaxHelper.FindCurrencyCode;
      CreateDocument(PurchaseHeader,PurchaseLine,DocumentType);

      ASSERTERROR ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);

      Assert.ExpectedError(
        STRSUBSTNO(BlockedPostOfSplitDocInFCYErr,PurchaseLine."Service Tax Group"));
Member of Miscellaneous.Reverse Service Tax Helper


FindPmtMethodWithBalAcc@1500029 Method

The procedure FindPmtMethodWithBalAcc is available in codeunit 143006.

Syntax

FindPmtMethodWithBalAcc@1500029(
      //param element not supplied
);

Return Value

Code[10]

Remarks

The relevant search keywords are: Find, Payment, Method, Bal, Account.

For a clarification about how this function works, refer to the code listed below.

      PaymentMethod.SETFILTER("Bal. Account No.",'<>%1','');
      PaymentMethod.FINDFIRST;
      EXIT(PaymentMethod.Code);

Example

There are no examples available.
Member of Miscellaneous.Reverse Service Tax Helper


GetAmountSignInJournalLine@1500005 Method

The procedure GetAmountSignInJournalLine is available in codeunit 143006.

Syntax

GetAmountSignInJournalLine@1500005(
    DocumentType@1500000 : Option DocumentType //Input parameter of type Option
);

Parameters

DocumentType
Input parameter of type Option

Return Value

Integer

Remarks

The relevant search keywords are: Get, Amount, Sign, In, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      CASE DocumentType OF
        GenJournalLine."Document Type"::"Credit Memo",
        GenJournalLine."Document Type"::Payment:
          EXIT(1);
        GenJournalLine."Document Type"::"Finance Charge Memo",
        GenJournalLine."Document Type"::Reminder,
        GenJournalLine."Document Type"::Refund,
        GenJournalLine."Document Type"::Invoice:
          EXIT(-1);
        ELSE
          ERROR(STRSUBSTNO(InvalidDocumentTypeErr,DocumentType))
      END

Example

The below example is extracted from the test automation codeunit 144030 to show one way of using this function.

      ReverseServiceTaxHelper.CreatePayment(GenJournalLine,ReverseServiceTaxHelper.CreateVendor,
        ReverseServiceTaxHelper.GetAmountSignInJournalLine(DocumentType) * LibraryRandom.RandDec(10000,2),
        WORKDATE,DocumentType);
Member of Miscellaneous.Reverse Service Tax Helper


GetApplyingDocType@1500012 Method

The procedure GetApplyingDocType is available in codeunit 143006.

Syntax

GetApplyingDocType@1500012(
    DocumentType@1500000 : Option DocumentType //Input parameter of type Option
);

Parameters

DocumentType
Input parameter of type Option

Return Value

Integer

Remarks

The relevant search keywords are: Get, Applying, Document, Type.

For a clarification about how this function works, refer to the code listed below.

      IF (DocumentType = PurchaseHeader."Document Type"::Order) OR (DocumentType = PurchaseHeader."Document Type"::Invoice) THEN
        EXIT(GenJournalLine."Document Type"::Payment);
      EXIT(GenJournalLine."Document Type"::Refund);

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      Initialize;

      PostedPurchaseDocNo := PostPurchDocFromJnl(GenJournalLine,DocumentType,ReverseChargeType,PoT);

      PaymentAmount := -ServiceTaxVerify.CalcVendLedgEntryRemAmount(PostedPurchaseDocNo);
      PostedPaymentDocNo :=
        PostAndApplyPayment(
          GenJournalLine."Account No.",PaymentAmount,GenJournalLine."Posting Date",
          GenJournalLine."Document Type",PostedPurchaseDocNo,
          ReverseServiceTaxHelper.GetApplyingDocType(GenJournalLine."Document Type"));

      // values for further verification
      GenJournalLine."Applies-to Doc. No." := PostedPaymentDocNo;
      GenJournalLine."Document No." := PostedPurchaseDocNo;
      GenJournalLine."Service Tax Base Amount (LCY)" := -GenJournalLine.Amount;
Member of Miscellaneous.Reverse Service Tax Helper


GetBankAccGLPostingAcc@1500065 Method

The procedure GetBankAccGLPostingAcc is available in codeunit 143006.

Syntax

GetBankAccGLPostingAcc@1500065(
    BankAccountCode@1500002 : Code[20] BankAccountCode //Input parameter of type Code
);

Parameters

BankAccountCode
Input parameter of type Code

Return Value

Code[20]

Remarks

The relevant search keywords are: Get, Bank, Accountount, General Ledger, Posting, Accountount.

For a clarification about how this function works, refer to the code listed below.

      BankAccount.GET(BankAccountCode);
      BankAccPostingGroup.GET(BankAccount."Bank Acc. Posting Group");
      EXIT(BankAccPostingGroup."G/L Bank Account No.");

Example

The below example is extracted from the test automation codeunit 144014 to show one way of using this function.

      DummyGLEntry.SETRANGE("Document No.",GenJournalLine."Document No.");
      Assert.RecordCount(DummyGLEntry,8);
      VerifyGLEntry(LibrarySales.GetCustomerAccount(GenJournalLine."Account No."),GenJournalLine."Document No.",
        GenJournalLine.Amount / GenJournalLine."Currency Factor");
      VerifyGLEntryAdditionalCurrencyAmount(LibrarySales.GetCustomerAccount(GenJournalLine."Account No."),
        GenJournalLine."Document No.",GenJournalLine.Amount);
      VerifyGLEntry(ReverseServiceTaxHelper.GetBankAccGLPostingAcc(GenJournalLine."Bal. Account No."),
        GenJournalLine."Document No.",-GenJournalLine.Amount / GenJournalLine."Currency Factor");
      VerifyGLEntryAdditionalCurrencyAmount(ReverseServiceTaxHelper.GetBankAccGLPostingAcc(GenJournalLine."Bal. Account No."),
        GenJournalLine."Document No.",-GenJournalLine.Amount);
      ServTaxBaseAmount := ReverseServiceTaxHelper.CalcServTaxBaseAmountBackwardWithKKC(GenJournalLine.Amount,ServiceTaxSetup,0);
      VerifyGLEntry(ServiceTaxSetup."Service Tax Payable Account",GenJournalLine."Document No.",
        ReverseServiceTaxHelper.CalculateServTax(ServTaxBaseAmount,ServiceTaxSetup) / GenJournalLine."Currency Factor");
      VerifyGLEntryAdditionalCurrencyAmount(ServiceTaxSetup."Service Tax Payable Account",GenJournalLine."Document No.",
        ReverseServiceTaxHelper.CalculateServTax(ServTaxBaseAmount,ServiceTaxSetup));
      VerifyGLEntry(ServiceTaxSetup."Payables Account (Interim)",GenJournalLine."Document No.",-
        ReverseServiceTaxHelper.CalculateServTax(ServTaxBaseAmount,ServiceTaxSetup) / GenJournalLine."Currency Factor");
      VerifyGLEntryAdditionalCurrencyAmount(ServiceTaxSetup."Payables Account (Interim)",GenJournalLine."Document No.",-
        ReverseServiceTaxHelper.CalculateServTax(ServTaxBaseAmount,ServiceTaxSetup));
Member of Miscellaneous.Reverse Service Tax Helper


GetBaseAmountFromAdvPayment@1500047 Method

The procedure GetBaseAmountFromAdvPayment is available in codeunit 143006.

Syntax

GetBaseAmountFromAdvPayment@1500047(
    Amount@1500000 : Decimal Amount, //Input parameter of type Decimal
    RevChrgPercentage@1500003 : Integer RevChrgPercentage, //Input parameter of type Integer
    ReverseChargeType@1500001 : Option ReverseChargeType, //Input parameter of type Option
    ServiceTaxSetup@1500002 : Record 16472 ServiceTaxSetup //Input parameter of type Record
);

Parameters

Amount
Input parameter of type Decimal
RevChrgPercentage
Input parameter of type Integer
ReverseChargeType
Input parameter of type Option
ServiceTaxSetup
Input parameter of type Record

Return Value

Decimal

Remarks

The relevant search keywords are: Get, Base, Amount, From, Adv, Payment.

For a clarification about how this function works, refer to the code listed below.

      IF ReverseChargeType = ReverseChargeTypeOption::" " THEN
        EXIT(CalcServTaxBaseAmountBackward(Amount,ServiceTaxSetup,RevChrgPercentage));
      EXIT(Amount)

Example

The below example is extracted from the test automation codeunit 144038 to show one way of using this function.

      IF GenJournalLine."Document Type" IN [GenJournalLine."Document Type"::Invoice,
                                            GenJournalLine."Document Type"::"Credit Memo"]
      THEN
        BaseAmount := ReverseServiceTaxHelper.CalculateServTaxBase(ABS(GenJournalLine.Amount),GenJournalLine."Document Type")
      ELSE
        BaseAmount := ReverseServiceTaxHelper.GetBaseAmountFromAdvPayment(
            GenJournalLine.Amount,ReverseServiceTaxHelper.GetRevChrgPercent(GenJournalLine),
            ReverseServiceTaxHelper.GetServTaxType(
              GenJournalLine."Service Tax Group Code",GenJournalLine."Account No.",GenJournalLine."Service Tax Registration No."),
            ServiceTaxSetup);
Member of Miscellaneous.Reverse Service Tax Helper


GetBaseAmountFromAdvPaymentNonKKC@1500104 Method

The procedure GetBaseAmountFromAdvPaymentNonKKC is available in codeunit 143006.

Syntax

GetBaseAmountFromAdvPaymentNonKKC@1500104(
    Amount@1500000 : Decimal Amount, //Input parameter of type Decimal
    RevChrgPercentage@1500003 : Integer RevChrgPercentage, //Input parameter of type Integer
    ReverseChargeType@1500001 : Option ReverseChargeType, //Input parameter of type Option
    ServiceTaxSetup@1500002 : Record 16472 ServiceTaxSetup //Input parameter of type Record
);

Parameters

Amount
Input parameter of type Decimal
RevChrgPercentage
Input parameter of type Integer
ReverseChargeType
Input parameter of type Option
ServiceTaxSetup
Input parameter of type Record

Return Value

Decimal

Remarks

The relevant search keywords are: Get, Base, Amount, From, Adv, Payment, Non, KKC.

For a clarification about how this function works, refer to the code listed below.

      IF ReverseChargeType = ReverseChargeTypeOption::" " THEN
        EXIT(CalcServTaxBaseAmountBackwardNonKKC(Amount,ServiceTaxSetup,RevChrgPercentage));
      EXIT(Amount)

Example

There are no examples available.
Member of Miscellaneous.Reverse Service Tax Helper


GetBaseAmountFromGenJnlLine@1500049 Method

The procedure GetBaseAmountFromGenJnlLine is available in codeunit 143006.

Syntax

GetBaseAmountFromGenJnlLine@1500049(
    GenJournalLine@1500000 : Record 81 GenJournalLine //Input parameter of type Record
);

Parameters

GenJournalLine
Input parameter of type Record

Return Value

Decimal

Remarks

The relevant search keywords are: Get, Base, Amount, From, General, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      Percentage := GetRevChrgPercent(GenJournalLine);
      IF GenJournalLine."Currency Code" = '' THEN
        AmountLCY := GenJournalLine.Amount
      ELSE
        AmountLCY := GenJournalLine."Amount (LCY)";

      IF GenJournalLine."Document Type" IN [GenJournalLine."Document Type"::Invoice,
                                            GenJournalLine."Document Type"::"Credit Memo"]
      THEN
        EXIT(CalculateServTaxBase(ABS(AmountLCY),GenJournalLine."Document Type"));

      IF (Percentage >= 1) AND (Percentage <= 99) THEN
        ServiceTaxType := ReverseChargeTypeOption::" "
      ELSE
        ServiceTaxType := GetServTaxType(
            GenJournalLine."Service Tax Group Code",GenJournalLine."Account No.",GenJournalLine."Service Tax Registration No.");
      EXIT(GetBaseAmountFromAdvPayment(AmountLCY,Percentage,ServiceTaxType,ServiceTaxSetup));

Example

The below example is extracted from the test automation codeunit 144040 to show one way of using this function.

      LastTransactionNo := Initialize;
      PartialFactor := 1 + GetPartialFactor;
      AdvPmtGenJournalLine.Amount := LibraryRandom.RandDec(10000,2);

      PostAdvPmt(AdvPmtGenJournalLine);
      PostAdvPmtWithSameSetup(AdvPmtGenJournalLine,AdvPmtGenJournalLine2,PartialFactor);
      PostPartialInvoice(AdvPmtGenJournalLine,InvGenJournalLine,PartialFactor);
      ApplyOffline(AdvPmtGenJournalLine,InvGenJournalLine);
      ApplyOffline(AdvPmtGenJournalLine2,InvGenJournalLine);

      ReverseServiceTaxHelper.UnapplyTwice(InvGenJournalLine."Document No.");

      VerifyUnapply(InvGenJournalLine,ReverseServiceTaxHelper.GetBaseAmountFromGenJnlLine(AdvPmtGenJournalLine),
        ReverseServiceTaxHelper.GetBaseAmountFromGenJnlLine(AdvPmtGenJournalLine2),1,LastTransactionNo);
Member of Miscellaneous.Reverse Service Tax Helper


GetBaseAmountFromGenJnlLineNonKKC@1500114 Method

The procedure GetBaseAmountFromGenJnlLineNonKKC is available in codeunit 143006.

Syntax

GetBaseAmountFromGenJnlLineNonKKC@1500114(
    GenJournalLine@1500000 : Record 81 GenJournalLine //Input parameter of type Record
);

Parameters

GenJournalLine
Input parameter of type Record

Return Value

Decimal

Remarks

The relevant search keywords are: Get, Base, Amount, From, General, Journal, Line, Non, KKC.

For a clarification about how this function works, refer to the code listed below.

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      Percentage := GetRevChrgPercent(GenJournalLine);
      IF GenJournalLine."Currency Code" = '' THEN
        AmountLCY := GenJournalLine.Amount
      ELSE
        AmountLCY := GenJournalLine."Amount (LCY)";

      IF GenJournalLine."Document Type" IN [GenJournalLine."Document Type"::Invoice,
                                            GenJournalLine."Document Type"::"Credit Memo"]
      THEN
        EXIT(CalculateServTaxBase(ABS(AmountLCY),GenJournalLine."Document Type"));

      IF (Percentage >= 1) AND (Percentage <= 99) THEN
        ServiceTaxType := ReverseChargeTypeOption::" "
      ELSE
        ServiceTaxType := GetServTaxType(
            GenJournalLine."Service Tax Group Code",GenJournalLine."Account No.",GenJournalLine."Service Tax Registration No.");
      IF ServiceTaxType = ReverseChargeTypeOption::" " THEN
        EXIT(CalcServTaxBaseAmountBackwardNonKKC(AmountLCY,ServiceTaxSetup,Percentage));
      EXIT(AmountLCY)

Example

There are no examples available.
Member of Miscellaneous.Reverse Service Tax Helper


GetBaseAmountFromGenJnlLineWithKKC@1500112 Method

The procedure GetBaseAmountFromGenJnlLineWithKKC is available in codeunit 143006.

Syntax

GetBaseAmountFromGenJnlLineWithKKC@1500112(
    GenJournalLine@1500000 : Record 81 GenJournalLine //Input parameter of type Record
);

Parameters

GenJournalLine
Input parameter of type Record

Return Value

Decimal

Remarks

The relevant search keywords are: Get, Base, Amount, From, General, Journal, Line, KKC.

For a clarification about how this function works, refer to the code listed below.

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      Percentage := GetRevChrgPercent(GenJournalLine);
      IF GenJournalLine."Currency Code" = '' THEN
        AmountLCY := GenJournalLine.Amount
      ELSE
        AmountLCY := GenJournalLine."Amount (LCY)";

      IF GenJournalLine."Document Type" IN [GenJournalLine."Document Type"::Invoice,
                                            GenJournalLine."Document Type"::"Credit Memo"]
      THEN
        EXIT(CalculateServTaxBase(ABS(AmountLCY),GenJournalLine."Document Type"));

      IF (Percentage >= 1) AND (Percentage <= 99) THEN
        ServiceTaxType := ReverseChargeTypeOption::" "
      ELSE
        ServiceTaxType := GetServTaxType(
            GenJournalLine."Service Tax Group Code",GenJournalLine."Account No.",GenJournalLine."Service Tax Registration No.");
      IF ServiceTaxType = ReverseChargeTypeOption::" " THEN
        EXIT(CalcServTaxBaseAmountBackwardWithKKC(AmountLCY,ServiceTaxSetup,Percentage));
      EXIT(AmountLCY)

Example

There are no examples available.
Member of Miscellaneous.Reverse Service Tax Helper


GetBaseAndTaxAmountFromAdvPmt@1500995 Method

The procedure GetBaseAndTaxAmountFromAdvPmt is available in codeunit 143006.

Syntax

GetBaseAndTaxAmountFromAdvPmt@1500995(
    VAR BaseAmount@1500002 : Decimal BaseAmount, //Reference parameter of type Decimal
    VAR TaxAmount@1500003 : Decimal TaxAmount, //Reference parameter of type Decimal
    ServiceTaxSetup@1500004 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    Amount@1500000 : Decimal Amount, //Input parameter of type Decimal
    RevChargeType@1500005 : Option RevChargeType, //Input parameter of type Option
    RevChrgPercentage@1500001 : Integer RevChrgPercentage //Input parameter of type Integer
);

Parameters

BaseAmount
Reference parameter of type Decimal
TaxAmount
Reference parameter of type Decimal
ServiceTaxSetup
Input parameter of type Record
Amount
Input parameter of type Decimal
RevChargeType
Input parameter of type Option
RevChrgPercentage
Input parameter of type Integer

Remarks

The relevant search keywords are: Get, Base, Tax, Amount, From, Adv, Payment.

For a clarification about how this function works, refer to the code listed below.

      BaseAmount := GetBaseAmountFromAdvPayment(Amount,RevChrgPercentage,RevChargeType,ServiceTaxSetup);
      TaxAmount := CalculateServTaxTotal(BaseAmount,ServiceTaxSetup);

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      Initialize;

      ReverseServiceTaxHelper.CreateAdvancePayment(GenJournalLine,GenJournalLine."Document Type"::Payment,
        FALSE,SrvTypeRevChrg,ReverseChargeTypeParam,100);
      PostedAdvancePaymentDocNo := GenJournalLine."Document No.";
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      ReverseServiceTaxHelper.CreateDocAndApplyAdvPayment(PurchaseHeader,PurchaseLine,GenJournalLine,DocumentType,
        ReverseChargeTypeParam,100,FALSE,GenJournalLine.Amount);
      PostedPurchInvoiceDocNo := ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      ReverseServiceTaxHelper.GetBaseAndTaxAmountFromAdvPmt(
        BaseAmount,TaxAmount,ServiceTaxSetup,GenJournalLine.Amount,ReverseChargeTypeParam,100);

      PostedPayRCToGovDocNo := ReverseServiceTaxHelper.PayServiceTax(GenJournalLine."Service Tax Registration No.",
          GenJournalLine."Service Tax Group Code",TRUE);
Member of Miscellaneous.Reverse Service Tax Helper


GetBaseAndTaxAmountFromAdvPmtNonKKC@1500098 Method

The procedure GetBaseAndTaxAmountFromAdvPmtNonKKC is available in codeunit 143006.

Syntax

GetBaseAndTaxAmountFromAdvPmtNonKKC@1500098(
    VAR BaseAmount@1500002 : Decimal BaseAmount, //Reference parameter of type Decimal
    VAR TaxAmount@1500003 : Decimal TaxAmount, //Reference parameter of type Decimal
    VAR SBCAmount@1500006 : Decimal SBCAmount, //Reference parameter of type Decimal
    VAR KKCAmount@1500007 : Decimal KKCAmount, //Reference parameter of type Decimal
    ServiceTaxSetup@1500004 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    Amount@1500000 : Decimal Amount, //Input parameter of type Decimal
    RevChargeType@1500005 : Option RevChargeType, //Input parameter of type Option
    RevChrgPercentage@1500001 : Integer RevChrgPercentage //Input parameter of type Integer
);

Parameters

BaseAmount
Reference parameter of type Decimal
TaxAmount
Reference parameter of type Decimal
SBCAmount
Reference parameter of type Decimal
KKCAmount
Reference parameter of type Decimal
ServiceTaxSetup
Input parameter of type Record
Amount
Input parameter of type Decimal
RevChargeType
Input parameter of type Option
RevChrgPercentage
Input parameter of type Integer

Remarks

The relevant search keywords are: Get, Base, Tax, Amount, From, Adv, Payment, Non, KKC.

For a clarification about how this function works, refer to the code listed below.

      BaseAmount := GetBaseAmountFromAdvPaymentNonKKC(Amount,RevChrgPercentage,RevChargeType,ServiceTaxSetup);
      TaxAmount := CalculateServTaxTotal(BaseAmount,ServiceTaxSetup);
      SBCAmount := CalculateSBC(BaseAmount,ServiceTaxSetup);
      KKCAmount := CalculateKKCess(BaseAmount,ServiceTaxSetup);

Example

There are no examples available.
Member of Miscellaneous.Reverse Service Tax Helper


GetKKCAndSBCmountFromAdvPmt@1500109 Method

The procedure GetKKCAndSBCmountFromAdvPmt is available in codeunit 143006.

Syntax

GetKKCAndSBCmountFromAdvPmt@1500109(
    BaseAmount@1500002 : Decimal BaseAmount, //Input parameter of type Decimal
    VAR SBCAmount@1500007 : Decimal SBCAmount, //Reference parameter of type Decimal
    VAR KKCAmount@1500006 : Decimal KKCAmount, //Reference parameter of type Decimal
    ServiceTaxSetup@1500004 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    Amount@1500000 : Decimal Amount, //Input parameter of type Decimal
    RevChargeType@1500005 : Option RevChargeType, //Input parameter of type Option
    RevChrgPercentage@1500001 : Integer RevChrgPercentage //Input parameter of type Integer
);

Parameters

BaseAmount
Input parameter of type Decimal
SBCAmount
Reference parameter of type Decimal
KKCAmount
Reference parameter of type Decimal
ServiceTaxSetup
Input parameter of type Record
Amount
Input parameter of type Decimal
RevChargeType
Input parameter of type Option
RevChrgPercentage
Input parameter of type Integer

Remarks

The relevant search keywords are: Get, KKC, SB, Cmount, From, Adv, Payment.

For a clarification about how this function works, refer to the code listed below.

      BaseAmount := GetBaseAmountFromAdvPayment(Amount,RevChrgPercentage,RevChargeType,ServiceTaxSetup);
      SBCAmount := CalculateSBC(BaseAmount,ServiceTaxSetup);
      KKCAmount := CalculateKKCess(BaseAmount,ServiceTaxSetup);

Example

There are no examples available.
Member of Miscellaneous.Reverse Service Tax Helper


GetKKCExpenseAcc@1500096 Method

The procedure GetKKCExpenseAcc is available in codeunit 143006.

Syntax

GetKKCExpenseAcc@1500096(
    ServiceTaxSetup@1500000 : Record 16472 ServiceTaxSetup //Input parameter of type Record
);

Parameters

ServiceTaxSetup
Input parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Get, KKC, Expense, Account.

For a clarification about how this function works, refer to the code listed below.

      EXIT(ServiceTaxSetup."KK Cess Expense Account");

Example

There are no examples available.
Member of Miscellaneous.Reverse Service Tax Helper


GetKKCInterimPayAcc@1500094 Method

The procedure GetKKCInterimPayAcc is available in codeunit 143006.

Syntax

GetKKCInterimPayAcc@1500094(
    ServiceTaxSetup@1500000 : Record 16472 ServiceTaxSetup //Input parameter of type Record
);

Parameters

ServiceTaxSetup
Input parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Get, KKC, Interim, Pay, Account.

For a clarification about how this function works, refer to the code listed below.

      EXIT(ServiceTaxSetup."KK Cess Payable Acc. (Interim)");

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      Initialize;

      // Setup:
      ReverseServiceTaxHelper.CreatePurchaseDoc(PurchaseHeader,PurchaseLine,DocumentType,ReverseChargeTypeOption::Standard,100,FALSE);
      PartialPaymentFactor := LibraryRandom.RandDec(1,1);

      // Exercise
      PostedPurchaseDoc := ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);
      ServiceTaxSetup.FindOnDate(PurchaseLine."Service Tax Group",PurchaseHeader."Posting Date");

      PaymentAmount :=
        ReverseServiceTaxHelper.CalculatePayment(PurchaseLine."Document Type",PurchaseLine."Line Amount",ServiceTaxSetup,100);

      PostedPartialPayment := PostAndApplyPmt(PurchaseHeader,PartialPaymentFactor * PaymentAmount,PostedPurchaseDoc);
      PostedRemainingPayment := PostAndApplyPmt(PurchaseHeader,(1 - PartialPaymentFactor) * PaymentAmount,PostedPurchaseDoc);

      // Verify
      AccountNo := ReverseServiceTaxHelper.GetServTaxInterimRecAcc(ServiceTaxSetup);
      BaseAmount := ReverseServiceTaxHelper.CalculateServTaxBase(PurchaseLine."Line Amount",DocumentType);
      Amount := ReverseServiceTaxHelper.CalculateServTaxTotal(BaseAmount,ServiceTaxSetup);
      KKCAmount := ReverseServiceTaxHelper.CalculateKKCess(BaseAmount,ServiceTaxSetup);
      SBCAmount := ReverseServiceTaxHelper.CalculateSBC(BaseAmount,ServiceTaxSetup);

      ServiceTaxVerify.GLBalanceRevCharge(ServiceTaxSetup,Amount);
      ServiceTaxVerify.GLSBCBalanceRevCharge(ServiceTaxSetup,SBCAmount);
      ServiceTaxVerify.GLKKCBalanceRevCharge(ServiceTaxSetup,KKCAmount);

      AccountNo := ReverseServiceTaxHelper.GetServTaxInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,PartialPaymentFactor * Amount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(1 - PartialPaymentFactor) * Amount);
      AccountNo := ReverseServiceTaxHelper.GetServTaxSBCInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,PartialPaymentFactor * SBCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(1 - PartialPaymentFactor) * SBCAmount);
      AccountNo := ReverseServiceTaxHelper.GetKKCInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,PartialPaymentFactor * KKCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(1 - PartialPaymentFactor) * KKCAmount);

      AccountNo := ReverseServiceTaxHelper.GetServTaxPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,-PartialPaymentFactor * Amount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(PartialPaymentFactor - 1) * Amount);
      AccountNo := ReverseServiceTaxHelper.GetServTaxSBCPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,-PartialPaymentFactor * SBCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(PartialPaymentFactor - 1) * SBCAmount);
      AccountNo := ReverseServiceTaxHelper.GetKKCPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,-PartialPaymentFactor * KKCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(PartialPaymentFactor - 1) * KKCAmount);
      RevChargeCreditClosed := FALSE;
      RealCreditClosed := TRUE;
      ServiceTaxVerify.STEntryDetailsPartialPay(PostedPartialPayment,BaseAmount,ServiceTaxSetup,PartialPaymentFactor,0,FALSE,
        RevChargeCreditClosed,RealCreditClosed);
      ServiceTaxVerify.STEntryDetailsPartialPay(PostedRemainingPayment,BaseAmount,ServiceTaxSetup,1 - PartialPaymentFactor,0,FALSE,
        RevChargeCreditClosed,RealCreditClosed);

      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDoc,FALSE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPartialPayment,FALSE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedRemainingPayment,FALSE);
Member of Miscellaneous.Reverse Service Tax Helper


GetKKCInterimRecAcc@1500090 Method

The procedure GetKKCInterimRecAcc is available in codeunit 143006.

Syntax

GetKKCInterimRecAcc@1500090(
    ServiceTaxSetup@1500000 : Record 16472 ServiceTaxSetup //Input parameter of type Record
);

Parameters

ServiceTaxSetup
Input parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Get, KKC, Interim, Rec, Account.

For a clarification about how this function works, refer to the code listed below.

      EXIT(ServiceTaxSetup."KK Cess Rec. Acc. (Interim)");

Example

The below example is extracted from the test automation codeunit 144038 to show one way of using this function.

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      ServTaxAmount := CalculateTaxWithAbatement(GenJournalLine,ServiceTaxSetup);
      CalculateSBCKKCWithAbatement(GenJournalLine,ServiceTaxSetup,SBCAmount,KKCAmount);

      ServiceTaxVerify.AccountBalance(ReverseServiceTaxHelper.GetServTaxInterimRecAcc(ServiceTaxSetup),-ServTaxAmount);
      ServiceTaxVerify.AccountBalance(ReverseServiceTaxHelper.GetServTaxRecAcc(ServiceTaxSetup),ServTaxAmount);
      ServiceTaxVerify.AccountBalance(ReverseServiceTaxHelper.GetServTaxSBCExpenseAcc(ServiceTaxSetup),SBCAmount);
      ServiceTaxVerify.AccountBalance(ReverseServiceTaxHelper.GetServTaxSBCRecAcc(ServiceTaxSetup),SBCAmount);
      ServiceTaxVerify.AccountBalance(ReverseServiceTaxHelper.GetKKCInterimRecAcc(ServiceTaxSetup),-KKCAmount);
      ServiceTaxVerify.AccountBalance(ReverseServiceTaxHelper.GetKKCRecAcc(ServiceTaxSetup),KKCAmount);

      VerifySTEntryAbatement(GenJournalLine,ServiceTaxSetup);
      VerifySTEntryDetailAbatement(GenJournalLine,ServiceTaxSetup);
Member of Miscellaneous.Reverse Service Tax Helper


GetKKCPayAcc@1500077 Method

The procedure GetKKCPayAcc is available in codeunit 143006.

Syntax

GetKKCPayAcc@1500077(
    ServiceTaxSetup@1500000 : Record 16472 ServiceTaxSetup //Input parameter of type Record
);

Parameters

ServiceTaxSetup
Input parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Get, KKC, Pay, Account.

For a clarification about how this function works, refer to the code listed below.

      EXIT(ServiceTaxSetup."KK Cess Payable Account");

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      Initialize;

      // Setup:
      ReverseServiceTaxHelper.CreatePurchaseDoc(PurchaseHeader,PurchaseLine,DocumentType,ReverseChargeTypeOption::Standard,100,FALSE);
      PartialPaymentFactor := LibraryRandom.RandDec(1,1);

      // Exercise
      PostedPurchaseDoc := ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);
      ServiceTaxSetup.FindOnDate(PurchaseLine."Service Tax Group",PurchaseHeader."Posting Date");

      PaymentAmount :=
        ReverseServiceTaxHelper.CalculatePayment(PurchaseLine."Document Type",PurchaseLine."Line Amount",ServiceTaxSetup,100);

      PostedPartialPayment := PostAndApplyPmt(PurchaseHeader,PartialPaymentFactor * PaymentAmount,PostedPurchaseDoc);
      PostedRemainingPayment := PostAndApplyPmt(PurchaseHeader,(1 - PartialPaymentFactor) * PaymentAmount,PostedPurchaseDoc);

      // Verify
      AccountNo := ReverseServiceTaxHelper.GetServTaxInterimRecAcc(ServiceTaxSetup);
      BaseAmount := ReverseServiceTaxHelper.CalculateServTaxBase(PurchaseLine."Line Amount",DocumentType);
      Amount := ReverseServiceTaxHelper.CalculateServTaxTotal(BaseAmount,ServiceTaxSetup);
      KKCAmount := ReverseServiceTaxHelper.CalculateKKCess(BaseAmount,ServiceTaxSetup);
      SBCAmount := ReverseServiceTaxHelper.CalculateSBC(BaseAmount,ServiceTaxSetup);

      ServiceTaxVerify.GLBalanceRevCharge(ServiceTaxSetup,Amount);
      ServiceTaxVerify.GLSBCBalanceRevCharge(ServiceTaxSetup,SBCAmount);
      ServiceTaxVerify.GLKKCBalanceRevCharge(ServiceTaxSetup,KKCAmount);

      AccountNo := ReverseServiceTaxHelper.GetServTaxInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,PartialPaymentFactor * Amount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(1 - PartialPaymentFactor) * Amount);
      AccountNo := ReverseServiceTaxHelper.GetServTaxSBCInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,PartialPaymentFactor * SBCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(1 - PartialPaymentFactor) * SBCAmount);
      AccountNo := ReverseServiceTaxHelper.GetKKCInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,PartialPaymentFactor * KKCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(1 - PartialPaymentFactor) * KKCAmount);

      AccountNo := ReverseServiceTaxHelper.GetServTaxPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,-PartialPaymentFactor * Amount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(PartialPaymentFactor - 1) * Amount);
      AccountNo := ReverseServiceTaxHelper.GetServTaxSBCPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,-PartialPaymentFactor * SBCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(PartialPaymentFactor - 1) * SBCAmount);
      AccountNo := ReverseServiceTaxHelper.GetKKCPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,-PartialPaymentFactor * KKCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(PartialPaymentFactor - 1) * KKCAmount);
      RevChargeCreditClosed := FALSE;
      RealCreditClosed := TRUE;
      ServiceTaxVerify.STEntryDetailsPartialPay(PostedPartialPayment,BaseAmount,ServiceTaxSetup,PartialPaymentFactor,0,FALSE,
        RevChargeCreditClosed,RealCreditClosed);
      ServiceTaxVerify.STEntryDetailsPartialPay(PostedRemainingPayment,BaseAmount,ServiceTaxSetup,1 - PartialPaymentFactor,0,FALSE,
        RevChargeCreditClosed,RealCreditClosed);

      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDoc,FALSE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPartialPayment,FALSE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedRemainingPayment,FALSE);
Member of Miscellaneous.Reverse Service Tax Helper


GetKKCRecAcc@1500073 Method

The procedure GetKKCRecAcc is available in codeunit 143006.

Syntax

GetKKCRecAcc@1500073(
    ServiceTaxSetup@1500000 : Record 16472 ServiceTaxSetup //Input parameter of type Record
);

Parameters

ServiceTaxSetup
Input parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Get, KKC, Rec, Account.

For a clarification about how this function works, refer to the code listed below.

      EXIT(ServiceTaxSetup."KK Cess Receivable Account");

Example

The below example is extracted from the test automation codeunit 144038 to show one way of using this function.

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      ServTaxAmount := CalculateTaxWithAbatement(GenJournalLine,ServiceTaxSetup);
      CalculateSBCKKCWithAbatement(GenJournalLine,ServiceTaxSetup,SBCAmount,KKCAmount);
      ServiceTaxVerify.AccountBalance(ReverseServiceTaxHelper.GetServTaxRecAcc(ServiceTaxSetup),ServTaxAmount);
      ServiceTaxVerify.AccountBalance(ReverseServiceTaxHelper.GetServTaxSBCRecAcc(ServiceTaxSetup),SBCAmount);
      ServiceTaxVerify.AccountBalance(ReverseServiceTaxHelper.GetKKCRecAcc(ServiceTaxSetup),KKCAmount);
      VerifySTEntryAbatement(GenJournalLine,ServiceTaxSetup);
      VerifySTEntryDetailAbatement(GenJournalLine,ServiceTaxSetup);
Member of Miscellaneous.Reverse Service Tax Helper


GetLastTransactionNo@1500008 Method

The procedure GetLastTransactionNo is available in codeunit 143006.

Syntax

GetLastTransactionNo@1500008(
      //param element not supplied
);

Return Value

Integer

Remarks

The relevant search keywords are: Get, Last, Transaction, No.

For a clarification about how this function works, refer to the code listed below.

      GLEntry.FINDLAST;
      EXIT(GLEntry."Transaction No.");

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      LastTransactionNo := Initialize;
      ValidateTaxTypeParameters(PoT,RevChargeType);

      // Setup
      ReverseServiceTaxHelper.CreatePurchaseDoc(PurchaseHeader,PurchaseLine,DocumentType,
        RevChargeType,100,PoT);

      PostedPurchaseDocNo := ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);

      ServiceTaxSetup.FindOnDate(PurchaseLine."Service Tax Group",PurchaseHeader."Posting Date");
      PaymentAmount := -ServiceTaxVerify.CalcVendLedgEntryRemAmount(PostedPurchaseDocNo);
      PostedPaymentDocNo := PostAndApplyPmt(PurchaseHeader,PaymentAmount,PostedPurchaseDocNo);
      ApplyTransactionNo := ReverseServiceTaxHelper.GetLastTransactionNo;

      // Exercise
      ReverseServiceTaxHelper.UnapplyVendorLedgerEntry(PostedPaymentDocNo);

      // Verify
      VerifyUnapply(
        PurchaseHeader,PurchaseLine,PaymentAmount,ApplyTransactionNo,LastTransactionNo,
        DocumentType,RevChargeType,PostedPurchaseDocNo,PostedPaymentDocNo,PoT);
Member of Miscellaneous.Reverse Service Tax Helper


GetPostingDocType@1500076 Method

The procedure GetPostingDocType is available in codeunit 143006.

Syntax

GetPostingDocType@1500076(
    DocumentType@1500000 : Option DocumentType //Input parameter of type Option
);

Parameters

DocumentType
Input parameter of type Option

Return Value

Integer

Remarks

The relevant search keywords are: Get, Posting, Document, Type.

For a clarification about how this function works, refer to the code listed below.

      CASE DocumentType OF
        PurchHeader."Document Type"::Order,PurchHeader."Document Type"::Invoice:
          EXIT(GenJnlLine."Document Type"::Invoice);
        PurchHeader."Document Type"::"Return Order",PurchHeader."Document Type"::"Credit Memo":
          EXIT(GenJnlLine."Document Type"::"Credit Memo");
      END;

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      Initialize;

      // Setup:
      ReverseServiceTaxHelper.CreatePurchaseDoc(PurchaseHeader,PurchaseLine,DocumentType,ReverseChargeTypeOption::Standard,100,FALSE);

      // Exercise
      ServiceTaxSetup.FindOnDate(PurchaseLine."Service Tax Group",PurchaseHeader."Posting Date");
      PostedPurchaseDoc := ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);

      PostedPayment := PostAndApplyPayment(PurchaseHeader."Pay-to Vendor No.",
          ReverseServiceTaxHelper.CalculatePayment(PurchaseLine."Document Type",PurchaseLine."Line Amount",ServiceTaxSetup,100),
          PurchaseHeader."Posting Date",ReverseServiceTaxHelper.GetPostingDocType(PurchaseHeader."Document Type"),PostedPurchaseDoc,
          ReverseServiceTaxHelper.GetApplyingDocType(PurchaseHeader."Document Type"));

      // Verify
      BaseAmount := ReverseServiceTaxHelper.CalculateServTaxBase(PurchaseLine."Line Amount",DocumentType);
      Amount := ReverseServiceTaxHelper.CalculateServTaxTotal(BaseAmount,ServiceTaxSetup);
      KKCAmount := ReverseServiceTaxHelper.CalculateKKCess(BaseAmount,ServiceTaxSetup);
      SBCAmount := ReverseServiceTaxHelper.CalculateSBC(BaseAmount,ServiceTaxSetup);

      ServiceTaxVerify.ServTaxGLAccountsBalance(ServiceTaxSetup,0,Amount,-Amount,0);
      ServiceTaxVerify.KKCGLAccountsBalance(ServiceTaxSetup,0,KKCAmount,-KKCAmount,0);
      ServiceTaxVerify.SBCGLAccountsBalance(ServiceTaxSetup,SBCAmount,0,-SBCAmount,0);

      RevChargeCreditClosed := FALSE;
      RealCreditClosed := TRUE;
      ServiceTaxVerify.ServTaxEntryDetails(
        PostedPayment,BaseAmount,ServiceTaxSetup,RevChargeCreditClosed,RealCreditClosed);

      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDoc,FALSE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPayment,FALSE);
Member of Miscellaneous.Reverse Service Tax Helper


GetPurchInvAmountFactor@1500097 Method

The procedure GetPurchInvAmountFactor is available in codeunit 143006.

Syntax

GetPurchInvAmountFactor@1500097(
    AmountRelation@1500000 : Option AmountRelation //Input parameter of type Option
);

Parameters

AmountRelation
Input parameter of type Option

Return Value

Decimal

Remarks

The relevant search keywords are: Get, Purchase, Invoice, Amount, Factor.

For a clarification about how this function works, refer to the code listed below.

      CASE AmountRelation OF
        PurchInvAmountVsAppliedDocAmt::InvoiceAmountEqual:
          PurchInvAmtFactorToAdvPmtAmt := 1;
        PurchInvAmountVsAppliedDocAmt::InvoiceAmountGreater:
          PurchInvAmtFactorToAdvPmtAmt := 1.5;
        PurchInvAmountVsAppliedDocAmt::InvoiceAmountSmaller:
          PurchInvAmtFactorToAdvPmtAmt := 0.75;
      END;
      EXIT(PurchInvAmtFactorToAdvPmtAmt);

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      LastTransactionNo := Initialize;

      // Setup:
      PoT := ReverseChargeType = ReverseChargeTypeOption::" ";
      ReverseServiceTaxHelper.CreatePurchaseDoc(
        PurchaseHeader,PurchaseLine,PurchaseHeader."Document Type"::Invoice,ReverseChargeType,100,PoT);

      // Exercise
      PostedDocNo1 := ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);
      PostedDocNo2 := PostAndApplyCrMemo(PurchaseHeader,PostedDocNo1,InvAmountIs);

      // Verify
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedDocNo1,InvAmountIs = InvoiceAmountIs::Greater);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedDocNo2,InvAmountIs = InvoiceAmountIs::Smaller);

      ServiceTaxSetup.FindOnDate(PurchaseLine."Service Tax Group",PurchaseHeader."Posting Date");
      InvoiceBaseAmount := ReverseServiceTaxHelper.CalculateServTaxBase(PurchaseLine."Line Amount",PurchaseHeader."Document Type");
      InvoiceTaxAmount := ReverseServiceTaxHelper.CalculateServTaxTotal(InvoiceBaseAmount,ServiceTaxSetup);
      CrMemoBaseAmount := -InvoiceBaseAmount / ReverseServiceTaxHelper.GetPurchInvAmountFactor(InvAmountIs);
      CrMemoTaxAmount := ReverseServiceTaxHelper.CalculateServTaxTotal(CrMemoBaseAmount,ServiceTaxSetup);

      ServiceTaxVerify.ServTaxEntry(PostedDocNo1,InvoiceBaseAmount,ServiceTaxSetup);
      ServiceTaxVerify.ServTaxEntry(PostedDocNo2,CrMemoBaseAmount,ServiceTaxSetup);

      ServiceTaxVerify.PostedPurchDocGLBalance(ServiceTaxSetup,ReverseChargeType,PoT,InvoiceTaxAmount + CrMemoTaxAmount);

      IF ReverseChargeType = ReverseChargeTypeOption::" " THEN
        IF PoT THEN BEGIN
          ServiceTaxVerify.STEntryDetailsRemainingCredit(LastTransactionNo,InvoiceTaxAmount + CrMemoTaxAmount);
          ServiceTaxVerify.ServTaxEntriesArePaid(ReverseServiceTaxHelper.GetLastTransactionNo);
        END ELSE
          ServiceTaxVerify.STEntryDetailsRemainingCredit(LastTransactionNo,0)
      ELSE
        ServiceTaxVerify.STEntryDetailsRemRevChrgCredit(LastTransactionNo,0);

      IF InvAmountIs = InvoiceAmountIs::Greater THEN
        SmallerDocumentNo := PostedDocNo2
      ELSE
        SmallerDocumentNo := PostedDocNo1;
      ServiceTaxVerify.DocHasClosedRemCredit(SmallerDocumentNo);
Member of Miscellaneous.Reverse Service Tax Helper


GetRemainingAmount@1500157 Method

The procedure GetRemainingAmount is available in codeunit 143006.

Syntax

GetRemainingAmount@1500157(
    DocumentType@1500001 : Option DocumentType, //Input parameter of type Option
    PostedDocNo@1500000 : Code[20] PostedDocNo //Input parameter of type Code
);

Parameters

DocumentType
Input parameter of type Option
PostedDocNo
Input parameter of type Code

Return Value

Decimal

Remarks

The relevant search keywords are: Get, Remaining, Amount.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.FindVendorLedgerEntry(VendorLedgerEntry,DocumentType,PostedDocNo);
      VendorLedgerEntry.CALCFIELDS("Remaining Amount");
      EXIT(VendorLedgerEntry."Remaining Amount");

Example

The below example is extracted from the test automation codeunit 144033 to show one way of using this function.

      PaymentDocNo := ReverseServiceTaxHelper.PostPayment(
        InvGenJournalLine."Account No.",-ReverseServiceTaxHelper.GetRemainingAmount(InvGenJournalLine."Document Type",
        InvGenJournalLine."Document No."),InvGenJournalLine."Posting Date",InvGenJournalLine."Document Type"::Payment);
      ReverseServiceTaxHelper.ApplyAndPostVendorEntry(
        InvGenJournalLine."Document Type",InvGenJournalLine."Document No.",InvGenJournalLine."Document Type"::Payment,PaymentDocNo);
Member of Miscellaneous.Reverse Service Tax Helper


GetRevChrgPercent@1500091 Method

The procedure GetRevChrgPercent is available in codeunit 143006.

Syntax

GetRevChrgPercent@1500091(
    GenJournalLine@1500000 : Record 81 GenJournalLine //Input parameter of type Record
);

Parameters

GenJournalLine
Input parameter of type Record

Return Value

Integer

Remarks

The relevant search keywords are: Get, Rev, Chrg, Percent.

For a clarification about how this function works, refer to the code listed below.

      IF GenJournalLine.TryGetSrvTaxReverseChargeSetup(STReverseChargeSetup) THEN
        EXIT(STReverseChargeSetup."Reverse Charge %");
      EXIT(0);

Example

The below example is extracted from the test automation codeunit 144038 to show one way of using this function.

      IF GenJournalLine."Document Type" IN [GenJournalLine."Document Type"::Invoice,
                                            GenJournalLine."Document Type"::"Credit Memo"]
      THEN
        BaseAmount := ReverseServiceTaxHelper.CalculateServTaxBase(ABS(GenJournalLine.Amount),GenJournalLine."Document Type")
      ELSE
        BaseAmount := ReverseServiceTaxHelper.GetBaseAmountFromAdvPayment(
            GenJournalLine.Amount,ReverseServiceTaxHelper.GetRevChrgPercent(GenJournalLine),
            ReverseServiceTaxHelper.GetServTaxType(
              GenJournalLine."Service Tax Group Code",GenJournalLine."Account No.",GenJournalLine."Service Tax Registration No."),
            ServiceTaxSetup);
Member of Miscellaneous.Reverse Service Tax Helper


GetReverseChargeServType@1500066 Method

The procedure GetReverseChargeServType is available in codeunit 143006.

Syntax

GetReverseChargeServType@1500066(
    ReverseChargeType@1500000 : Option ReverseChargeType //Input parameter of type Option
);

Parameters

ReverseChargeType
Input parameter of type Option

Return Value

Integer

Remarks

The relevant search keywords are: Get, Reverse, Charge, Serv, Type.

For a clarification about how this function works, refer to the code listed below.

      IF ReverseChargeType = ReverseChargeTypeOption::" " THEN
        EXIT(PurchaseHeader."Service Type (Rev. Chrg.)"::" ");
      EXIT(PurchaseHeader."Service Type (Rev. Chrg.)"::Inward);

Example

The below example is extracted from the test automation codeunit 144030 to show one way of using this function.

      Initialize;

      ServiceType := ReverseServiceTaxHelper.GetReverseChargeServType(ServiceTaxType);

      // Create and post Advance Payment
      ReverseServiceTaxHelper.CreateAndPostAdvancePayment(GenJournalLine,PaymentPoT,ServiceType,ServiceTaxType,100);

      // Create a purchase invoice having the same amount
      ReverseServiceTaxHelper.CreateDocAndApplyAdvPayment(PurchaseHeader,PurchaseLine,
        GenJournalLine,GenJournalLine."Document Type"::Invoice,ServiceTaxType,100,InvoicePoT,GenJournalLine.Amount);

      // When posting, throw an error message because the PoT on the purchase doesn't match the PoT on the invoice
      ASSERTERROR ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);
      IF ServiceTaxType <> ServiceTaxType::" " THEN
        Assert.ExpectedError(
          STRSUBSTNO(ReverseChargeWithPoTErr,GenJournalLine."Service Tax Group Code",GenJournalLine.FIELDCAPTION(PoT)))
      ELSE
        Assert.ExpectedError(PotMismatchErr);
Member of Miscellaneous.Reverse Service Tax Helper


GetServiceTaxEntryDetail@1500084 Method

The procedure GetServiceTaxEntryDetail is available in codeunit 143006.

Syntax

GetServiceTaxEntryDetail@1500084(
    VAR ServiceTaxEntryDetails@1500001 : Record 16474 ServiceTaxEntryDetails, //Reference parameter of type Record
    DocumentNo@1500000 : Code[20] DocumentNo //Input parameter of type Code
);

Parameters

ServiceTaxEntryDetails
Reference parameter of type Record
DocumentNo
Input parameter of type Code

Remarks

The relevant search keywords are: Get, Service, Tax, Entry, Detail.

For a clarification about how this function works, refer to the code listed below.

      ServiceTaxEntryDetails.SETRANGE("Document No.",DocumentNo);
      ServiceTaxEntryDetails.SETRANGE("Corrective Application Entry",FALSE);
      IF NOT ServiceTaxEntryDetails.FINDLAST THEN BEGIN
        ServiceTaxEntry.SETRANGE("Document No.");
        ServiceTaxEntry.FINDLAST;
        ServiceTaxEntryDetails.RESET;
        ServiceTaxEntryDetails.SETRANGE("Service Tax Entry No.",ServiceTaxEntry."Entry No.");
        ServiceTaxEntryDetails.SETRANGE("Corrective Application Entry",FALSE);
        IF ServiceTaxEntryDetails.FINDLAST THEN;
      END;

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      // Post Sales Document and take credit
      ReverseServiceTaxHelper.GetServiceTaxEntryDetail(ServiceTaxEntryDetails,PostedAdvancePaymentDocNo);
      PostedSalesInvoiceDocNo := ReverseServiceTaxHelper.PostEqualAmountSalesDoc(ServiceTaxEntryDetails);
      LibraryServiceTax.PayServiceTax(ServiceTaxEntryDetails."Service Tax Registration No.",
        ServiceTaxEntryDetails."Service Tax Group Code",FALSE);
Member of Miscellaneous.Reverse Service Tax Helper


GetServiceTaxReturnPeriod@1500015 Method

The procedure GetServiceTaxReturnPeriod is available in codeunit 143006.

Syntax

GetServiceTaxReturnPeriod@1500015(
    VAR ServiceTaxReturnPeriod@1500000 : Record 16588 ServiceTaxReturnPeriod //Reference parameter of type Record
);

Parameters

ServiceTaxReturnPeriod
Reference parameter of type Record

Remarks

The relevant search keywords are: Get, Service, Tax, Return, Period.

For a clarification about how this function works, refer to the code listed below.

      ServiceTaxReturnPeriod.FINDLAST;

Example

There are no examples available.
Member of Miscellaneous.Reverse Service Tax Helper


GetServTaxExpenseAcc@1170000004 Method

The procedure GetServTaxExpenseAcc is available in codeunit 143006.

Syntax

GetServTaxExpenseAcc@1170000004(
    ServiceTaxSetup@1500000 : Record 16472 ServiceTaxSetup //Input parameter of type Record
);

Parameters

ServiceTaxSetup
Input parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Get, Serv, Tax, Expense, Account.

For a clarification about how this function works, refer to the code listed below.

      EXIT(ServiceTaxSetup."Service Tax Expenses Account");

Example

There are no examples available.
Member of Miscellaneous.Reverse Service Tax Helper


GetServTaxInterimPayAcc@1500009 Method

The procedure GetServTaxInterimPayAcc is available in codeunit 143006.

Syntax

GetServTaxInterimPayAcc@1500009(
    ServiceTaxSetup@1500000 : Record 16472 ServiceTaxSetup //Input parameter of type Record
);

Parameters

ServiceTaxSetup
Input parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Get, Serv, Tax, Interim, Pay, Account.

For a clarification about how this function works, refer to the code listed below.

      EXIT(ServiceTaxSetup."Payables Account (Interim)");

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      Initialize;

      // Setup:
      ReverseServiceTaxHelper.CreatePurchaseDoc(PurchaseHeader,PurchaseLine,DocumentType,ReverseChargeTypeOption::Standard,100,FALSE);
      PartialPaymentFactor := LibraryRandom.RandDec(1,1);

      // Exercise
      PostedPurchaseDoc := ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);
      ServiceTaxSetup.FindOnDate(PurchaseLine."Service Tax Group",PurchaseHeader."Posting Date");

      PaymentAmount :=
        ReverseServiceTaxHelper.CalculatePayment(PurchaseLine."Document Type",PurchaseLine."Line Amount",ServiceTaxSetup,100);

      PostedPartialPayment := PostAndApplyPmt(PurchaseHeader,PartialPaymentFactor * PaymentAmount,PostedPurchaseDoc);
      PostedRemainingPayment := PostAndApplyPmt(PurchaseHeader,(1 - PartialPaymentFactor) * PaymentAmount,PostedPurchaseDoc);

      // Verify
      AccountNo := ReverseServiceTaxHelper.GetServTaxInterimRecAcc(ServiceTaxSetup);
      BaseAmount := ReverseServiceTaxHelper.CalculateServTaxBase(PurchaseLine."Line Amount",DocumentType);
      Amount := ReverseServiceTaxHelper.CalculateServTaxTotal(BaseAmount,ServiceTaxSetup);
      KKCAmount := ReverseServiceTaxHelper.CalculateKKCess(BaseAmount,ServiceTaxSetup);
      SBCAmount := ReverseServiceTaxHelper.CalculateSBC(BaseAmount,ServiceTaxSetup);

      ServiceTaxVerify.GLBalanceRevCharge(ServiceTaxSetup,Amount);
      ServiceTaxVerify.GLSBCBalanceRevCharge(ServiceTaxSetup,SBCAmount);
      ServiceTaxVerify.GLKKCBalanceRevCharge(ServiceTaxSetup,KKCAmount);

      AccountNo := ReverseServiceTaxHelper.GetServTaxInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,PartialPaymentFactor * Amount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(1 - PartialPaymentFactor) * Amount);
      AccountNo := ReverseServiceTaxHelper.GetServTaxSBCInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,PartialPaymentFactor * SBCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(1 - PartialPaymentFactor) * SBCAmount);
      AccountNo := ReverseServiceTaxHelper.GetKKCInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,PartialPaymentFactor * KKCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(1 - PartialPaymentFactor) * KKCAmount);

      AccountNo := ReverseServiceTaxHelper.GetServTaxPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,-PartialPaymentFactor * Amount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(PartialPaymentFactor - 1) * Amount);
      AccountNo := ReverseServiceTaxHelper.GetServTaxSBCPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,-PartialPaymentFactor * SBCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(PartialPaymentFactor - 1) * SBCAmount);
      AccountNo := ReverseServiceTaxHelper.GetKKCPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,-PartialPaymentFactor * KKCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(PartialPaymentFactor - 1) * KKCAmount);
      RevChargeCreditClosed := FALSE;
      RealCreditClosed := TRUE;
      ServiceTaxVerify.STEntryDetailsPartialPay(PostedPartialPayment,BaseAmount,ServiceTaxSetup,PartialPaymentFactor,0,FALSE,
        RevChargeCreditClosed,RealCreditClosed);
      ServiceTaxVerify.STEntryDetailsPartialPay(PostedRemainingPayment,BaseAmount,ServiceTaxSetup,1 - PartialPaymentFactor,0,FALSE,
        RevChargeCreditClosed,RealCreditClosed);

      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDoc,FALSE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPartialPayment,FALSE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedRemainingPayment,FALSE);
Member of Miscellaneous.Reverse Service Tax Helper


GetServTaxInterimRecAcc@1500002 Method

The procedure GetServTaxInterimRecAcc is available in codeunit 143006.

Syntax

GetServTaxInterimRecAcc@1500002(
    ServiceTaxSetup@1500000 : Record 16472 ServiceTaxSetup //Input parameter of type Record
);

Parameters

ServiceTaxSetup
Input parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Get, Serv, Tax, Interim, Rec, Account.

For a clarification about how this function works, refer to the code listed below.

      EXIT(ServiceTaxSetup."Receivables Account (Interim)");

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      Initialize;

      // Setup:
      ReverseServiceTaxHelper.CreatePurchaseDoc(PurchaseHeader,PurchaseLine,DocumentType,ReverseChargeTypeOption::Standard,100,FALSE);
      PartialPaymentFactor := LibraryRandom.RandDec(1,1);

      // Exercise
      PostedPurchaseDoc := ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);
      ServiceTaxSetup.FindOnDate(PurchaseLine."Service Tax Group",PurchaseHeader."Posting Date");

      PaymentAmount :=
        ReverseServiceTaxHelper.CalculatePayment(PurchaseLine."Document Type",PurchaseLine."Line Amount",ServiceTaxSetup,100);

      PostedPartialPayment := PostAndApplyPmt(PurchaseHeader,PartialPaymentFactor * PaymentAmount,PostedPurchaseDoc);
      PostedRemainingPayment := PostAndApplyPmt(PurchaseHeader,(1 - PartialPaymentFactor) * PaymentAmount,PostedPurchaseDoc);

      // Verify
      AccountNo := ReverseServiceTaxHelper.GetServTaxInterimRecAcc(ServiceTaxSetup);
      BaseAmount := ReverseServiceTaxHelper.CalculateServTaxBase(PurchaseLine."Line Amount",DocumentType);
      Amount := ReverseServiceTaxHelper.CalculateServTaxTotal(BaseAmount,ServiceTaxSetup);
      KKCAmount := ReverseServiceTaxHelper.CalculateKKCess(BaseAmount,ServiceTaxSetup);
      SBCAmount := ReverseServiceTaxHelper.CalculateSBC(BaseAmount,ServiceTaxSetup);

      ServiceTaxVerify.GLBalanceRevCharge(ServiceTaxSetup,Amount);
      ServiceTaxVerify.GLSBCBalanceRevCharge(ServiceTaxSetup,SBCAmount);
      ServiceTaxVerify.GLKKCBalanceRevCharge(ServiceTaxSetup,KKCAmount);

      AccountNo := ReverseServiceTaxHelper.GetServTaxInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,PartialPaymentFactor * Amount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(1 - PartialPaymentFactor) * Amount);
      AccountNo := ReverseServiceTaxHelper.GetServTaxSBCInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,PartialPaymentFactor * SBCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(1 - PartialPaymentFactor) * SBCAmount);
      AccountNo := ReverseServiceTaxHelper.GetKKCInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,PartialPaymentFactor * KKCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(1 - PartialPaymentFactor) * KKCAmount);

      AccountNo := ReverseServiceTaxHelper.GetServTaxPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,-PartialPaymentFactor * Amount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(PartialPaymentFactor - 1) * Amount);
      AccountNo := ReverseServiceTaxHelper.GetServTaxSBCPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,-PartialPaymentFactor * SBCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(PartialPaymentFactor - 1) * SBCAmount);
      AccountNo := ReverseServiceTaxHelper.GetKKCPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,-PartialPaymentFactor * KKCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(PartialPaymentFactor - 1) * KKCAmount);
      RevChargeCreditClosed := FALSE;
      RealCreditClosed := TRUE;
      ServiceTaxVerify.STEntryDetailsPartialPay(PostedPartialPayment,BaseAmount,ServiceTaxSetup,PartialPaymentFactor,0,FALSE,
        RevChargeCreditClosed,RealCreditClosed);
      ServiceTaxVerify.STEntryDetailsPartialPay(PostedRemainingPayment,BaseAmount,ServiceTaxSetup,1 - PartialPaymentFactor,0,FALSE,
        RevChargeCreditClosed,RealCreditClosed);

      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDoc,FALSE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPartialPayment,FALSE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedRemainingPayment,FALSE);
Member of Miscellaneous.Reverse Service Tax Helper


GetServTaxPayAcc@1500006 Method

The procedure GetServTaxPayAcc is available in codeunit 143006.

Syntax

GetServTaxPayAcc@1500006(
    ServiceTaxSetup@1500000 : Record 16472 ServiceTaxSetup //Input parameter of type Record
);

Parameters

ServiceTaxSetup
Input parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Get, Serv, Tax, Pay, Account.

For a clarification about how this function works, refer to the code listed below.

      EXIT(ServiceTaxSetup."Service Tax Payable Account");

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      Initialize;

      // Setup:
      ReverseServiceTaxHelper.CreatePurchaseDoc(PurchaseHeader,PurchaseLine,DocumentType,ReverseChargeTypeOption::Standard,100,FALSE);
      PartialPaymentFactor := LibraryRandom.RandDec(1,1);

      // Exercise
      PostedPurchaseDoc := ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);
      ServiceTaxSetup.FindOnDate(PurchaseLine."Service Tax Group",PurchaseHeader."Posting Date");

      PaymentAmount :=
        ReverseServiceTaxHelper.CalculatePayment(PurchaseLine."Document Type",PurchaseLine."Line Amount",ServiceTaxSetup,100);

      PostedPartialPayment := PostAndApplyPmt(PurchaseHeader,PartialPaymentFactor * PaymentAmount,PostedPurchaseDoc);
      PostedRemainingPayment := PostAndApplyPmt(PurchaseHeader,(1 - PartialPaymentFactor) * PaymentAmount,PostedPurchaseDoc);

      // Verify
      AccountNo := ReverseServiceTaxHelper.GetServTaxInterimRecAcc(ServiceTaxSetup);
      BaseAmount := ReverseServiceTaxHelper.CalculateServTaxBase(PurchaseLine."Line Amount",DocumentType);
      Amount := ReverseServiceTaxHelper.CalculateServTaxTotal(BaseAmount,ServiceTaxSetup);
      KKCAmount := ReverseServiceTaxHelper.CalculateKKCess(BaseAmount,ServiceTaxSetup);
      SBCAmount := ReverseServiceTaxHelper.CalculateSBC(BaseAmount,ServiceTaxSetup);

      ServiceTaxVerify.GLBalanceRevCharge(ServiceTaxSetup,Amount);
      ServiceTaxVerify.GLSBCBalanceRevCharge(ServiceTaxSetup,SBCAmount);
      ServiceTaxVerify.GLKKCBalanceRevCharge(ServiceTaxSetup,KKCAmount);

      AccountNo := ReverseServiceTaxHelper.GetServTaxInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,PartialPaymentFactor * Amount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(1 - PartialPaymentFactor) * Amount);
      AccountNo := ReverseServiceTaxHelper.GetServTaxSBCInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,PartialPaymentFactor * SBCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(1 - PartialPaymentFactor) * SBCAmount);
      AccountNo := ReverseServiceTaxHelper.GetKKCInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,PartialPaymentFactor * KKCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(1 - PartialPaymentFactor) * KKCAmount);

      AccountNo := ReverseServiceTaxHelper.GetServTaxPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,-PartialPaymentFactor * Amount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(PartialPaymentFactor - 1) * Amount);
      AccountNo := ReverseServiceTaxHelper.GetServTaxSBCPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,-PartialPaymentFactor * SBCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(PartialPaymentFactor - 1) * SBCAmount);
      AccountNo := ReverseServiceTaxHelper.GetKKCPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,-PartialPaymentFactor * KKCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(PartialPaymentFactor - 1) * KKCAmount);
      RevChargeCreditClosed := FALSE;
      RealCreditClosed := TRUE;
      ServiceTaxVerify.STEntryDetailsPartialPay(PostedPartialPayment,BaseAmount,ServiceTaxSetup,PartialPaymentFactor,0,FALSE,
        RevChargeCreditClosed,RealCreditClosed);
      ServiceTaxVerify.STEntryDetailsPartialPay(PostedRemainingPayment,BaseAmount,ServiceTaxSetup,1 - PartialPaymentFactor,0,FALSE,
        RevChargeCreditClosed,RealCreditClosed);

      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDoc,FALSE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPartialPayment,FALSE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedRemainingPayment,FALSE);
Member of Miscellaneous.Reverse Service Tax Helper


GetServTaxRecAcc@1500013 Method

The procedure GetServTaxRecAcc is available in codeunit 143006.

Syntax

GetServTaxRecAcc@1500013(
    ServiceTaxSetup@1500000 : Record 16472 ServiceTaxSetup //Input parameter of type Record
);

Parameters

ServiceTaxSetup
Input parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Get, Serv, Tax, Rec, Account.

For a clarification about how this function works, refer to the code listed below.

      EXIT(ServiceTaxSetup."Service Tax Receivable Account");

Example

The below example is extracted from the test automation codeunit 144034 to show one way of using this function.

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      ReverseServiceTaxHelper.CalcSplitAmounts(GenJournalLine,BaseAmount,PoTAmount,RevChrgAmount,Percentage,ServiceTaxSetup);

      PoTSBCandKKCAmount := ReverseServiceTaxHelper.CalculatePoTSBCandKKCAmount(BaseAmount,(100 - Percentage) / 100,ServiceTaxSetup);

      AccountNo := ReverseServiceTaxHelper.GetServTaxRecAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(GenJournalLine."Document No.",AccountNo,PoTAmount - PoTSBCandKKCAmount);
      ServiceTaxVerify.STEntryDetailsOnDocNoSplit(GenJournalLine."Document No.",BaseAmount,Percentage,FALSE,ServiceTaxSetup,1);

      AccountNo := ReverseServiceTaxHelper.GetServTaxInterimRecAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(GenJournalLine."Document No.",AccountNo,RevChrgAmount + PoTSBCandKKCAmount);
      AccountNo := ReverseServiceTaxHelper.GetServTaxInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(GenJournalLine."Document No.",AccountNo,-RevChrgAmount - PoTSBCandKKCAmount);

      ServiceTaxVerify.PoTServTaxEntry(GenJournalLine."Document No.",BaseAmount,Percentage,FALSE,ServiceTaxSetup);
      ServiceTaxVerify.RevChrgServTaxEntry(GenJournalLine."Document No.",BaseAmount,Percentage,TRUE,ServiceTaxSetup);

      ServiceTaxVerify.GLEntry(GenJournalLine."Document No.",
        ReverseServiceTaxHelper.GetVendorPostingAccount(GenJournalLine."Account No."),-(BaseAmount + PoTAmount));
      ServiceTaxVerify.GLEntry(GenJournalLine."Document No.",GenJournalLine."Bal. Account No.",BaseAmount);

      ServiceTaxVerify.GLEntriesCount(ReverseServiceTaxHelper.GetPostingDocType(GenJournalLine."Document Type"),GenJournalLine.
        "Document No.",10);
Member of Miscellaneous.Reverse Service Tax Helper


GetServTaxRoundingPrecision@1500044 Method

The procedure GetServTaxRoundingPrecision is available in codeunit 143006.

Syntax

GetServTaxRoundingPrecision@1500044(
      //param element not supplied
);

Return Value

Decimal

Remarks

The relevant search keywords are: Get, Serv, Tax, Rounding, Precision.

For a clarification about how this function works, refer to the code listed below.

      GLSetup.GET;
      EXIT(GLSetup."Service Tax Rounding Precision");

Example

There are no examples available.
Member of Miscellaneous.Reverse Service Tax Helper


GetServTaxSBCExpenseAcc@1500082 Method

The procedure GetServTaxSBCExpenseAcc is available in codeunit 143006.

Syntax

GetServTaxSBCExpenseAcc@1500082(
    ServiceTaxSetup@1500000 : Record 16472 ServiceTaxSetup //Input parameter of type Record
);

Parameters

ServiceTaxSetup
Input parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Get, Serv, Tax, SBC, Expense, Account.

For a clarification about how this function works, refer to the code listed below.

      EXIT(ServiceTaxSetup."SB Cess Expense Account");

Example

The below example is extracted from the test automation codeunit 144038 to show one way of using this function.

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      ServTaxAmount := CalculateTaxWithAbatement(GenJournalLine,ServiceTaxSetup);
      CalculateSBCKKCWithAbatement(GenJournalLine,ServiceTaxSetup,SBCAmount,KKCAmount);

      ServiceTaxVerify.AccountBalance(ReverseServiceTaxHelper.GetServTaxInterimRecAcc(ServiceTaxSetup),-ServTaxAmount);
      ServiceTaxVerify.AccountBalance(ReverseServiceTaxHelper.GetServTaxRecAcc(ServiceTaxSetup),ServTaxAmount);
      ServiceTaxVerify.AccountBalance(ReverseServiceTaxHelper.GetServTaxSBCExpenseAcc(ServiceTaxSetup),SBCAmount);
      ServiceTaxVerify.AccountBalance(ReverseServiceTaxHelper.GetServTaxSBCRecAcc(ServiceTaxSetup),SBCAmount);
      ServiceTaxVerify.AccountBalance(ReverseServiceTaxHelper.GetKKCInterimRecAcc(ServiceTaxSetup),-KKCAmount);
      ServiceTaxVerify.AccountBalance(ReverseServiceTaxHelper.GetKKCRecAcc(ServiceTaxSetup),KKCAmount);

      VerifySTEntryAbatement(GenJournalLine,ServiceTaxSetup);
      VerifySTEntryDetailAbatement(GenJournalLine,ServiceTaxSetup);
Member of Miscellaneous.Reverse Service Tax Helper


GetServTaxSBCInterimPayAcc@1500081 Method

The procedure GetServTaxSBCInterimPayAcc is available in codeunit 143006.

Syntax

GetServTaxSBCInterimPayAcc@1500081(
    ServiceTaxSetup@1500000 : Record 16472 ServiceTaxSetup //Input parameter of type Record
);

Parameters

ServiceTaxSetup
Input parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Get, Serv, Tax, SBC, Interim, Pay, Account.

For a clarification about how this function works, refer to the code listed below.

      EXIT(ServiceTaxSetup."SB Cess Payable Acc.(Interim)");

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      Initialize;

      // Setup:
      ReverseServiceTaxHelper.CreatePurchaseDoc(PurchaseHeader,PurchaseLine,DocumentType,ReverseChargeTypeOption::Standard,100,FALSE);
      PartialPaymentFactor := LibraryRandom.RandDec(1,1);

      // Exercise
      PostedPurchaseDoc := ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);
      ServiceTaxSetup.FindOnDate(PurchaseLine."Service Tax Group",PurchaseHeader."Posting Date");

      PaymentAmount :=
        ReverseServiceTaxHelper.CalculatePayment(PurchaseLine."Document Type",PurchaseLine."Line Amount",ServiceTaxSetup,100);

      PostedPartialPayment := PostAndApplyPmt(PurchaseHeader,PartialPaymentFactor * PaymentAmount,PostedPurchaseDoc);
      PostedRemainingPayment := PostAndApplyPmt(PurchaseHeader,(1 - PartialPaymentFactor) * PaymentAmount,PostedPurchaseDoc);

      // Verify
      AccountNo := ReverseServiceTaxHelper.GetServTaxInterimRecAcc(ServiceTaxSetup);
      BaseAmount := ReverseServiceTaxHelper.CalculateServTaxBase(PurchaseLine."Line Amount",DocumentType);
      Amount := ReverseServiceTaxHelper.CalculateServTaxTotal(BaseAmount,ServiceTaxSetup);
      KKCAmount := ReverseServiceTaxHelper.CalculateKKCess(BaseAmount,ServiceTaxSetup);
      SBCAmount := ReverseServiceTaxHelper.CalculateSBC(BaseAmount,ServiceTaxSetup);

      ServiceTaxVerify.GLBalanceRevCharge(ServiceTaxSetup,Amount);
      ServiceTaxVerify.GLSBCBalanceRevCharge(ServiceTaxSetup,SBCAmount);
      ServiceTaxVerify.GLKKCBalanceRevCharge(ServiceTaxSetup,KKCAmount);

      AccountNo := ReverseServiceTaxHelper.GetServTaxInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,PartialPaymentFactor * Amount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(1 - PartialPaymentFactor) * Amount);
      AccountNo := ReverseServiceTaxHelper.GetServTaxSBCInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,PartialPaymentFactor * SBCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(1 - PartialPaymentFactor) * SBCAmount);
      AccountNo := ReverseServiceTaxHelper.GetKKCInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,PartialPaymentFactor * KKCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(1 - PartialPaymentFactor) * KKCAmount);

      AccountNo := ReverseServiceTaxHelper.GetServTaxPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,-PartialPaymentFactor * Amount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(PartialPaymentFactor - 1) * Amount);
      AccountNo := ReverseServiceTaxHelper.GetServTaxSBCPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,-PartialPaymentFactor * SBCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(PartialPaymentFactor - 1) * SBCAmount);
      AccountNo := ReverseServiceTaxHelper.GetKKCPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,-PartialPaymentFactor * KKCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(PartialPaymentFactor - 1) * KKCAmount);
      RevChargeCreditClosed := FALSE;
      RealCreditClosed := TRUE;
      ServiceTaxVerify.STEntryDetailsPartialPay(PostedPartialPayment,BaseAmount,ServiceTaxSetup,PartialPaymentFactor,0,FALSE,
        RevChargeCreditClosed,RealCreditClosed);
      ServiceTaxVerify.STEntryDetailsPartialPay(PostedRemainingPayment,BaseAmount,ServiceTaxSetup,1 - PartialPaymentFactor,0,FALSE,
        RevChargeCreditClosed,RealCreditClosed);

      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDoc,FALSE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPartialPayment,FALSE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedRemainingPayment,FALSE);
Member of Miscellaneous.Reverse Service Tax Helper


GetServTaxSBCInterimRecAcc@1500080 Method

The procedure GetServTaxSBCInterimRecAcc is available in codeunit 143006.

Syntax

GetServTaxSBCInterimRecAcc@1500080(
    ServiceTaxSetup@1500000 : Record 16472 ServiceTaxSetup //Input parameter of type Record
);

Parameters

ServiceTaxSetup
Input parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Get, Serv, Tax, SBC, Interim, Rec, Account.

For a clarification about how this function works, refer to the code listed below.

      EXIT(ServiceTaxSetup."SB Cess Acc.(Interim)");

Example

The below example is extracted from the test automation codeunit 144038 to show one way of using this function.

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      IF Abatement THEN BEGIN
        ServTaxAmount := CalculateTaxWithAbatement(GenJournalLine,ServiceTaxSetup);
        CalculateSBCKKCWithAbatement(GenJournalLine,ServiceTaxSetup,SBCAmount,KKCAmount);
      END ELSE BEGIN
        ServTaxAmount := ReverseServiceTaxHelper.CalculateServTaxTotal(GenJournalLine.Amount,ServiceTaxSetup);
        SBCAmount := ReverseServiceTaxHelper.CalculateSBC(GenJournalLine.Amount,ServiceTaxSetup);
        KKCAmount := ReverseServiceTaxHelper.CalculateKKCess(GenJournalLine.Amount,ServiceTaxSetup);
      END;
      ServiceTaxVerify.AccountBalance(ReverseServiceTaxHelper.GetServTaxInterimRecAcc(ServiceTaxSetup),ServTaxAmount);
      ServiceTaxVerify.AccountBalance(ReverseServiceTaxHelper.GetServTaxPayAcc(ServiceTaxSetup),-ServTaxAmount);
      ServiceTaxVerify.AccountBalance(ReverseServiceTaxHelper.GetKKCInterimRecAcc(ServiceTaxSetup),KKCAmount);
      ServiceTaxVerify.AccountBalance(ReverseServiceTaxHelper.GetKKCPayAcc(ServiceTaxSetup),-KKCAmount);
      ServiceTaxVerify.AccountBalance(ReverseServiceTaxHelper.GetServTaxSBCInterimRecAcc(ServiceTaxSetup),SBCAmount);
      ServiceTaxVerify.AccountBalance(ReverseServiceTaxHelper.GetServTaxSBCPayAcc(ServiceTaxSetup),-SBCAmount);
      IF Abatement THEN BEGIN
        VerifySTEntryAbatement(GenJournalLine,ServiceTaxSetup);
        VerifySTEntryDetailAbatement(GenJournalLine,ServiceTaxSetup);
      END ELSE BEGIN
        VerifySTEntry(GenJournalLine,ServiceTaxSetup);
        VerifySTEntryDetail(GenJournalLine,ServiceTaxSetup);
      END;
Member of Miscellaneous.Reverse Service Tax Helper


GetServTaxSBCPayAcc@1500178 Method

The procedure GetServTaxSBCPayAcc is available in codeunit 143006.

Syntax

GetServTaxSBCPayAcc@1500178(
    ServiceTaxSetup@1500000 : Record 16472 ServiceTaxSetup //Input parameter of type Record
);

Parameters

ServiceTaxSetup
Input parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Get, Serv, Tax, SBC, Pay, Account.

For a clarification about how this function works, refer to the code listed below.

      EXIT(ServiceTaxSetup."SB Cess Payable Account");

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      Initialize;

      // Setup:
      ReverseServiceTaxHelper.CreatePurchaseDoc(PurchaseHeader,PurchaseLine,DocumentType,ReverseChargeTypeOption::Standard,100,FALSE);
      PartialPaymentFactor := LibraryRandom.RandDec(1,1);

      // Exercise
      PostedPurchaseDoc := ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);
      ServiceTaxSetup.FindOnDate(PurchaseLine."Service Tax Group",PurchaseHeader."Posting Date");

      PaymentAmount :=
        ReverseServiceTaxHelper.CalculatePayment(PurchaseLine."Document Type",PurchaseLine."Line Amount",ServiceTaxSetup,100);

      PostedPartialPayment := PostAndApplyPmt(PurchaseHeader,PartialPaymentFactor * PaymentAmount,PostedPurchaseDoc);
      PostedRemainingPayment := PostAndApplyPmt(PurchaseHeader,(1 - PartialPaymentFactor) * PaymentAmount,PostedPurchaseDoc);

      // Verify
      AccountNo := ReverseServiceTaxHelper.GetServTaxInterimRecAcc(ServiceTaxSetup);
      BaseAmount := ReverseServiceTaxHelper.CalculateServTaxBase(PurchaseLine."Line Amount",DocumentType);
      Amount := ReverseServiceTaxHelper.CalculateServTaxTotal(BaseAmount,ServiceTaxSetup);
      KKCAmount := ReverseServiceTaxHelper.CalculateKKCess(BaseAmount,ServiceTaxSetup);
      SBCAmount := ReverseServiceTaxHelper.CalculateSBC(BaseAmount,ServiceTaxSetup);

      ServiceTaxVerify.GLBalanceRevCharge(ServiceTaxSetup,Amount);
      ServiceTaxVerify.GLSBCBalanceRevCharge(ServiceTaxSetup,SBCAmount);
      ServiceTaxVerify.GLKKCBalanceRevCharge(ServiceTaxSetup,KKCAmount);

      AccountNo := ReverseServiceTaxHelper.GetServTaxInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,PartialPaymentFactor * Amount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(1 - PartialPaymentFactor) * Amount);
      AccountNo := ReverseServiceTaxHelper.GetServTaxSBCInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,PartialPaymentFactor * SBCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(1 - PartialPaymentFactor) * SBCAmount);
      AccountNo := ReverseServiceTaxHelper.GetKKCInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,PartialPaymentFactor * KKCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(1 - PartialPaymentFactor) * KKCAmount);

      AccountNo := ReverseServiceTaxHelper.GetServTaxPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,-PartialPaymentFactor * Amount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(PartialPaymentFactor - 1) * Amount);
      AccountNo := ReverseServiceTaxHelper.GetServTaxSBCPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,-PartialPaymentFactor * SBCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(PartialPaymentFactor - 1) * SBCAmount);
      AccountNo := ReverseServiceTaxHelper.GetKKCPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,-PartialPaymentFactor * KKCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(PartialPaymentFactor - 1) * KKCAmount);
      RevChargeCreditClosed := FALSE;
      RealCreditClosed := TRUE;
      ServiceTaxVerify.STEntryDetailsPartialPay(PostedPartialPayment,BaseAmount,ServiceTaxSetup,PartialPaymentFactor,0,FALSE,
        RevChargeCreditClosed,RealCreditClosed);
      ServiceTaxVerify.STEntryDetailsPartialPay(PostedRemainingPayment,BaseAmount,ServiceTaxSetup,1 - PartialPaymentFactor,0,FALSE,
        RevChargeCreditClosed,RealCreditClosed);

      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDoc,FALSE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPartialPayment,FALSE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedRemainingPayment,FALSE);
Member of Miscellaneous.Reverse Service Tax Helper


GetServTaxSBCRecAcc@1500179 Method

The procedure GetServTaxSBCRecAcc is available in codeunit 143006.

Syntax

GetServTaxSBCRecAcc@1500179(
    ServiceTaxSetup@1500000 : Record 16472 ServiceTaxSetup //Input parameter of type Record
);

Parameters

ServiceTaxSetup
Input parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Get, Serv, Tax, SBC, Rec, Account.

For a clarification about how this function works, refer to the code listed below.

      EXIT(ServiceTaxSetup."SB Cess Expense Account");

Example

The below example is extracted from the test automation codeunit 144038 to show one way of using this function.

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      ServTaxAmount := CalculateTaxWithAbatement(GenJournalLine,ServiceTaxSetup);
      CalculateSBCKKCWithAbatement(GenJournalLine,ServiceTaxSetup,SBCAmount,KKCAmount);
      ServiceTaxVerify.AccountBalance(ReverseServiceTaxHelper.GetServTaxRecAcc(ServiceTaxSetup),ServTaxAmount);
      ServiceTaxVerify.AccountBalance(ReverseServiceTaxHelper.GetServTaxSBCRecAcc(ServiceTaxSetup),SBCAmount);
      ServiceTaxVerify.AccountBalance(ReverseServiceTaxHelper.GetKKCRecAcc(ServiceTaxSetup),KKCAmount);
      VerifySTEntryAbatement(GenJournalLine,ServiceTaxSetup);
      VerifySTEntryDetailAbatement(GenJournalLine,ServiceTaxSetup);
Member of Miscellaneous.Reverse Service Tax Helper


GetServTaxType@1500095 Method

The procedure GetServTaxType is available in codeunit 143006.

Syntax

GetServTaxType@1500095(
    ServTaxGroup@1500000 : Code[10] ServTaxGroup, //Input parameter of type Code
    VendorNo@1500001 : Code[20] VendorNo, //Input parameter of type Code
    ServTaxRegNo@1500002 : Code[20] ServTaxRegNo //Input parameter of type Code
);

Parameters

ServTaxGroup
Input parameter of type Code
VendorNo
Input parameter of type Code
ServTaxRegNo
Input parameter of type Code

Return Value

Integer

Remarks

The relevant search keywords are: Get, Serv, Tax, Type.

For a clarification about how this function works, refer to the code listed below.

      Vendor.GET(VendorNo);
      SrvTaxRegNo.GET(ServTaxRegNo);
      IF SrvTaxReverseChrgSetup.GET(ServTaxGroup,Vendor."Service Entity Type",SrvTaxRegNo."Service Entity Type") THEN
        EXIT(ReverseChargeTypeOption::Standard);
      EXIT(ReverseChargeTypeOption::" ");

Example

The below example is extracted from the test automation codeunit 144038 to show one way of using this function.

      IF GenJournalLine."Document Type" IN [GenJournalLine."Document Type"::Invoice,
                                            GenJournalLine."Document Type"::"Credit Memo"]
      THEN
        BaseAmount := ReverseServiceTaxHelper.CalculateServTaxBase(ABS(GenJournalLine.Amount),GenJournalLine."Document Type")
      ELSE
        BaseAmount := ReverseServiceTaxHelper.GetBaseAmountFromAdvPayment(
            GenJournalLine.Amount,ReverseServiceTaxHelper.GetRevChrgPercent(GenJournalLine),
            ReverseServiceTaxHelper.GetServTaxType(
              GenJournalLine."Service Tax Group Code",GenJournalLine."Account No.",GenJournalLine."Service Tax Registration No."),
            ServiceTaxSetup);
Member of Miscellaneous.Reverse Service Tax Helper


GetVendorPostingAccount@1500054 Method

The procedure GetVendorPostingAccount is available in codeunit 143006.

Syntax

GetVendorPostingAccount@1500054(
    VendorNo@1500000 : Code[20] VendorNo //Input parameter of type Code
);

Parameters

VendorNo
Input parameter of type Code

Return Value

Code[20]

Remarks

The relevant search keywords are: Get, Vendor, Posting, Account.

For a clarification about how this function works, refer to the code listed below.

      Vendor.GET(VendorNo);
      VendorPostingGroup.GET(Vendor."Vendor Posting Group");
      EXIT(VendorPostingGroup."Payables Account");

Example

The below example is extracted from the test automation codeunit 144034 to show one way of using this function.

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      ReverseServiceTaxHelper.CalcSplitAmounts(GenJournalLine,BaseAmount,PoTAmount,RevChrgAmount,Percentage,ServiceTaxSetup);

      PoTSBCandKKCAmount := ReverseServiceTaxHelper.CalculatePoTSBCandKKCAmount(BaseAmount,(100 - Percentage) / 100,ServiceTaxSetup);

      AccountNo := ReverseServiceTaxHelper.GetServTaxRecAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(GenJournalLine."Document No.",AccountNo,PoTAmount - PoTSBCandKKCAmount);
      ServiceTaxVerify.STEntryDetailsOnDocNoSplit(GenJournalLine."Document No.",BaseAmount,Percentage,FALSE,ServiceTaxSetup,1);

      AccountNo := ReverseServiceTaxHelper.GetServTaxInterimRecAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(GenJournalLine."Document No.",AccountNo,RevChrgAmount + PoTSBCandKKCAmount);
      AccountNo := ReverseServiceTaxHelper.GetServTaxInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(GenJournalLine."Document No.",AccountNo,-RevChrgAmount - PoTSBCandKKCAmount);

      ServiceTaxVerify.PoTServTaxEntry(GenJournalLine."Document No.",BaseAmount,Percentage,FALSE,ServiceTaxSetup);
      ServiceTaxVerify.RevChrgServTaxEntry(GenJournalLine."Document No.",BaseAmount,Percentage,TRUE,ServiceTaxSetup);

      ServiceTaxVerify.GLEntry(GenJournalLine."Document No.",
        ReverseServiceTaxHelper.GetVendorPostingAccount(GenJournalLine."Account No."),-(BaseAmount + PoTAmount));
      ServiceTaxVerify.GLEntry(GenJournalLine."Document No.",GenJournalLine."Bal. Account No.",BaseAmount);

      ServiceTaxVerify.GLEntriesCount(ReverseServiceTaxHelper.GetPostingDocType(GenJournalLine."Document Type"),GenJournalLine.
        "Document No.",10);
Member of Miscellaneous.Reverse Service Tax Helper


InvokeForwardStaxCalculation@1500072 Method

The procedure InvokeForwardStaxCalculation is available in codeunit 143006.

Syntax

InvokeForwardStaxCalculation@1500072(
    VAR GenJournalLine@1500000 : Record 81 GenJournalLine //Reference parameter of type Record
);

Parameters

GenJournalLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Invoke, Forward, Stax, Calculation.

For a clarification about how this function works, refer to the code listed below.

      ServiceTaxBaseAmountLCY := GenJournalLine."Service Tax Base Amount (LCY)";
      GenJournalLine.VALIDATE("Service Tax Base Amount (LCY)",0);
      GenJournalLine.MODIFY(TRUE);
      GenJournalLine.VALIDATE("Service Tax Base Amount (LCY)",ServiceTaxBaseAmountLCY);
      GenJournalLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      ReverseServiceTaxHelper.CreateAdvancePayment(
        GenJournalLine,GenJournalLine."Document Type"::Payment,PoT,
        ReverseServiceTaxHelper.GetReverseChargeServType(TypeOfReverseCharge),
        TypeOfReverseCharge,100);

      // When setting the Service Tax Base Amount (instead of setting the amount), the posting should work the same way.
      ReverseServiceTaxHelper.InvokeForwardStaxCalculation(GenJournalLine);

      LibraryERM.PostGeneralJnlLine(GenJournalLine);
Member of Miscellaneous.Reverse Service Tax Helper


PayServiceTax@1500000 Method

The procedure PayServiceTax is available in codeunit 143006.

Syntax

PayServiceTax@1500000(
    ServiceTaxRegNo@1500000 : Code[20] ServiceTaxRegNo, //Input parameter of type Code
    ServiceTaxGroupCode@1500003 : Code[20] ServiceTaxGroupCode, //Input parameter of type Code
    ReverseCharge@1500001 : Boolean ReverseCharge //Input parameter of type Boolean
);

Parameters

ServiceTaxRegNo
Input parameter of type Code
ServiceTaxGroupCode
Input parameter of type Code
ReverseCharge
Input parameter of type Boolean

Return Value

Code[20]

Remarks

The relevant search keywords are: Pay, Service, Tax.

For a clarification about how this function works, refer to the code listed below.

      EXIT(LibraryServiceTax.PayServiceTax(ServiceTaxRegNo,ServiceTaxGroupCode,ReverseCharge))

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      Initialize;

      PostedPurchPaymentDocNo :=
        PostRevChargeInvAndApplyPmt(
          ServiceTaxRegNo,ServiceTaxGroup,ServiceTaxSetup,PurchaseHeader,PurchaseLine,
          PurchaseHeader."Document Type"::Invoice,PurchaseHeader."Service Type (Rev. Chrg.)"::Inward,
          ReverseChargeTypeOption::Standard);
      ReverseServiceTaxHelper.PayServiceTax(ServiceTaxRegNo.Code,ServiceTaxGroup.Code,TRUE);

      PostedSalesInvoiceDocNo :=
        ReverseServiceTaxHelper.UseCreditToPayForSalesDoc(PostedPurchPaymentDocNo,ServiceTaxEntryDetails);

      VerifySalesCreditClosed(ServiceTaxEntryDetails."Base Amount",PostedPurchPaymentDocNo,PostedSalesInvoiceDocNo);
Member of Miscellaneous.Reverse Service Tax Helper


PostEqualAmountSalesDoc@1500088 Method

The procedure PostEqualAmountSalesDoc is available in codeunit 143006.

Syntax

PostEqualAmountSalesDoc@1500088(
    ServiceTaxEntryDetails@1500000 : Record 16474 ServiceTaxEntryDetails //Input parameter of type Record
);

Parameters

ServiceTaxEntryDetails
Input parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Post, Equal, Amount, Sales, Document.

For a clarification about how this function works, refer to the code listed below.

      GenJournalLine.PoT := TRUE;
      CreateSalesDocFromGenJnl(GenJournalLine,GenJournalLine."Document Type"::Invoice,
        ServiceTaxEntryDetails."Base Amount",ServiceTaxEntryDetails."Posting Date",
        ServiceTaxEntryDetails."Service Tax Group Code",ServiceTaxEntryDetails."Service Tax Registration No.");

      PostedDocNo := GenJournalLine."Document No.";
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      // Post Sales Document and take credit
      ReverseServiceTaxHelper.GetServiceTaxEntryDetail(ServiceTaxEntryDetails,PostedAdvancePaymentDocNo);
      PostedSalesInvoiceDocNo := ReverseServiceTaxHelper.PostEqualAmountSalesDoc(ServiceTaxEntryDetails);
      LibraryServiceTax.PayServiceTax(ServiceTaxEntryDetails."Service Tax Registration No.",
        ServiceTaxEntryDetails."Service Tax Group Code",FALSE);
Member of Miscellaneous.Reverse Service Tax Helper


PostPayment@1500042 Method

The procedure PostPayment is available in codeunit 143006.

Syntax

PostPayment@1500042(
    VendorNo@1500003 : Code[20] VendorNo, //Input parameter of type Code
    Amount@1500002 : Decimal Amount, //Input parameter of type Decimal
    PostingDate@1500001 : Date PostingDate, //Input parameter of type Date
    DocumentType@1500000 : Option DocumentType //Input parameter of type Option
);

Parameters

VendorNo
Input parameter of type Code
Amount
Input parameter of type Decimal
PostingDate
Input parameter of type Date
DocumentType
Input parameter of type Option

Return Value

Code[20]

Remarks

The relevant search keywords are: Post, Payment.

For a clarification about how this function works, refer to the code listed below.

      CreatePayment(GenJournalLine,VendorNo,Amount,PostingDate,DocumentType);
      LibraryERM.PostGeneralJnlLine(GenJournalLine);
      EXIT(GenJournalLine."Document No.")

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      InitializeReportTest;
      PmtGenJournalLine.PoT := FALSE;
      LibraryServiceTax.SetServiceTaxRounding;
      PostedDocNo :=
        ApplyBiggerDocToAdvPmt(
          PmtGenJournalLine,PurchaseHeader."Document Type"::Invoice,ReverseChargeType::Standard,
          GLAccountNo,InvoiceBaseAmount,InvoiceTaxAmount,PaymentBaseAmount,PaymentTaxAmount);

      RemainingAmt := PaymentBaseAmount * 2;
      PmtDocNo :=
        ReverseServiceTaxHelper.PostPayment(
          PmtGenJournalLine."Account No.",RemainingAmt,PmtGenJournalLine."Posting Date",PmtGenJournalLine."Document Type"::Payment);
      ReverseServiceTaxHelper.ApplyAndPostVendorEntry(
        PurchaseHeader."Document Type"::Invoice,PostedDocNo,PmtGenJournalLine."Document Type"::Payment,PmtDocNo);
      ReverseServiceTaxHelper.PayServiceTax(
        PmtGenJournalLine."Service Tax Registration No.",PmtGenJournalLine."Service Tax Group Code",TRUE);

      COMMIT;
      ServiceTaxReportHelper.RunReportInputServiceDetails(PmtGenJournalLine);

      ServiceTaxSetup.FindOnDate(PmtGenJournalLine."Service Tax Group Code",PmtGenJournalLine."Posting Date");
      ServiceTaxReportHelper.VerifyInputServiceDetails(
        PaymentBaseAmount,RemainingAmt,PmtGenJournalLine."Document No.",PostedDocNo,ServiceTaxSetup);
Member of Miscellaneous.Reverse Service Tax Helper


PostPurchaseDoc@1500001 Method

The procedure PostPurchaseDoc is available in codeunit 143006.

Syntax

PostPurchaseDoc@1500001(
    PurchaseHeader@1500000 : Record 38 PurchaseHeader //Input parameter of type Record
);

Parameters

PurchaseHeader
Input parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Post, Purchase, Document.

For a clarification about how this function works, refer to the code listed below.

      PostedDocNo := NoSeriesManagement.GetNextNo(PurchaseHeader."Posting No. Series",WORKDATE,FALSE);
      PurchaseHeader.VALIDATE(Ship,TRUE);
      PurchaseHeader.MODIFY(TRUE);
      LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE);

Example

The below example is extracted from the test automation codeunit 144030 to show one way of using this function.

      Initialize;

      ReverseServiceTaxHelper.CreateAndPostAdvancePayment(
        GenJournalLine,
        PoT,
        GenJournalLine."Service Type (Rev. Chrg.)"::" ",
        ServiceTaxType::" ",0);

      ReverseServiceTaxHelper.CreateDocAndApplyAdvPayment(
        PurchaseHeader,
        PurchaseLine,
        GenJournalLine,
        GenJournalLine."Document Type"::Invoice,
        ServiceTaxType::" ",0,
        PoT,
        GenJournalLine.Amount);

      PurchaseHeader.VALIDATE(Structure,'');
      PurchaseHeader.VALIDATE(PoT,PoT); // Because PoT is reset when changing Structure
      PurchaseHeader.MODIFY(TRUE);

      ASSERTERROR ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);
      // Renew the record, to avoid the error: "Another user has modified the record [..]"
      PurchaseHeader.GET(PurchaseHeader."Document Type",PurchaseHeader."No.");
      PurchaseHeader.DELETE;
      Assert.ExpectedError(ApplyToNotServTaxDocErr);
Member of Miscellaneous.Reverse Service Tax Helper


PostPurchaseDocForVendor@1500100 Method

The procedure PostPurchaseDocForVendor is available in codeunit 143006.

Syntax

PostPurchaseDocForVendor@1500100(
    VAR PurchaseHeader@1500004 : Record 38 PurchaseHeader, //Reference parameter of type Record
    VAR PurchaseLine@1500003 : Record 39 PurchaseLine, //Reference parameter of type Record
    VendorNo@1500005 : Code[20] VendorNo, //Input parameter of type Code
    DocumentType@1500002 : Option DocumentType, //Input parameter of type Option
    ReverseChargeType@1500001 : Option ReverseChargeType, //Input parameter of type Option
    PoT@1500000 : Boolean PoT //Input parameter of type Boolean
);

Parameters

PurchaseHeader
Reference parameter of type Record
PurchaseLine
Reference parameter of type Record
VendorNo
Input parameter of type Code
DocumentType
Input parameter of type Option
ReverseChargeType
Input parameter of type Option
PoT
Input parameter of type Boolean

Return Value

Code[20]

Remarks

The relevant search keywords are: Post, Purchase, Document, For, Vendor.

For a clarification about how this function works, refer to the code listed below.

      CreatePurchaseDocForVendor(PurchaseHeader,PurchaseLine,VendorNo,DocumentType,ReverseChargeType,100,PoT);
      EXIT(PostPurchaseDoc(PurchaseHeader))

Example

The below example is extracted from the test automation codeunit 144033 to show one way of using this function.

      // Acceptance Test 7 an invoice with service tax applied on credit memo wo service tax Error is expected
      Initialize;

      VendorNo := ReverseServiceTaxHelper.CreateVendor;
      PostedInvoiceNo := ReverseServiceTaxHelper.PostPurchaseDocForVendor(
          PurchaseHeader,PurchaseLine,VendorNo,PurchaseHeader."Document Type"::Invoice,ServiceTaxType::Standard,FALSE);
      PostedCrMNo := ReverseServiceTaxHelper.PostPurchaseDocWOServTax(PurchaseHeader."Document Type"::"Credit Memo",VendorNo);

      ASSERTERROR ReverseServiceTaxHelper.ApplyAndPostVendorEntry(PurchaseHeader."Document Type"::Invoice,PostedInvoiceNo,
          VendorLedgerEntry."Document Type"::"Credit Memo",PostedCrMNo);

      Assert.ExpectedError(ServiceTaxApplicationErr);
Member of Miscellaneous.Reverse Service Tax Helper


PostPurchaseDocForVendWithAmt@1500102 Method

The procedure PostPurchaseDocForVendWithAmt is available in codeunit 143006.

Syntax

PostPurchaseDocForVendWithAmt@1500102(
    VAR PurchaseHeader@1500004 : Record 38 PurchaseHeader, //Reference parameter of type Record
    VAR PurchaseLine@1500003 : Record 39 PurchaseLine, //Reference parameter of type Record
    VendorNo@1500005 : Code[20] VendorNo, //Input parameter of type Code
    DocumentType@1500002 : Option DocumentType, //Input parameter of type Option
    ServiceTypeReverseCharge@1500009 : Option ServiceTypeReverseCharge, //Input parameter of type Option
    ReverseChargeType@1500001 : Option ReverseChargeType, //Input parameter of type Option
    PoT@1500000 : Boolean PoT, //Input parameter of type Boolean
    ServRegNo@1500008 : Code[20] ServRegNo, //Input parameter of type Code
    ServiceTaxGroupCode@1500007 : Code[20] ServiceTaxGroupCode, //Input parameter of type Code
    Amount@1500006 : Decimal Amount //Input parameter of type Decimal
);

Parameters

PurchaseHeader
Reference parameter of type Record
PurchaseLine
Reference parameter of type Record
VendorNo
Input parameter of type Code
DocumentType
Input parameter of type Option
ServiceTypeReverseCharge
Input parameter of type Option
ReverseChargeType
Input parameter of type Option
PoT
Input parameter of type Boolean
ServRegNo
Input parameter of type Code
ServiceTaxGroupCode
Input parameter of type Code
Amount
Input parameter of type Decimal

Return Value

Code[20]

Remarks

The relevant search keywords are: Post, Purchase, Document, For, Vendor, Amt.

For a clarification about how this function works, refer to the code listed below.

      CreatePurchaseHeaderByVendor(PurchaseHeader,DocumentType,ServiceTypeReverseCharge,PoT,VendorNo);
      CreatePurchaseLineWithAmount(PurchaseLine,PurchaseHeader,ServiceTaxGroupCode,ServRegNo,ReverseChargeType,100,Amount);
      EXIT(PostPurchaseDoc(PurchaseHeader))

Example

The below example is extracted from the test automation codeunit 144033 to show one way of using this function.

      Initialize;

      DocumentType := PurchaseHeader."Document Type"::Invoice;
      ReverseChargeType := ServiceTaxType::Standard;
      ServiceTypeReverseCharge := PurchaseHeader."Service Type (Rev. Chrg.)"::Inward;
      PoT := FALSE;
      // Post an Invoice with Amount greater than Credit Memo. Apply Credit Memo to the Invoice.
      ApplyDocOnCrMemoCoverAmount(DocumentType,ServiceTypeReverseCharge,ReverseChargeType,PoT,
        InvoiceAmountIs::Greater,InvGenJournalLine,CRMemoGenJournalLine);
      ServiceTaxSetup.FindOnDate(InvGenJournalLine."Service Tax Group Code",InvGenJournalLine."Posting Date");

      // Post Second Credit Memo
      RemainingBaseAmount := InvGenJournalLine.Amount - ABS(CRMemoGenJournalLine.Amount);
      PostedSecondCreditMemoNo :=
        ReverseServiceTaxHelper.PostPurchaseDocForVendWithAmt(
          PurchaseHeaderCrM,PurchaseLineCrM,InvGenJournalLine."Account No.",
          PurchaseHeaderCrM."Document Type"::"Credit Memo",ServiceTypeReverseCharge,ReverseChargeType,PoT,
          InvGenJournalLine."Service Tax Registration No.",InvGenJournalLine."Service Tax Group Code",RemainingBaseAmount);
      ApplyCreditMemoToInvoice(InvGenJournalLine."Document No.",PostedSecondCreditMemoNo);

      // Verify
      ServiceTaxVerify.ServTaxEntry(PostedSecondCreditMemoNo,-RemainingBaseAmount,ServiceTaxSetup);

      ServiceTaxVerify.PostedPurchDocGLBalance(ServiceTaxSetup,ReverseChargeType,PoT,0);
      ServiceTaxVerify.ServTaxEntriesArePaid(ReverseServiceTaxHelper.GetLastTransactionNo);
      ServiceTaxVerify.DocHasClosedRemCredit(PostedSecondCreditMemoNo);
      ServiceTaxVerify.DocHasClosedRemCredit(InvGenJournalLine."Document No.");

      ServiceTaxVerify.VendorLedgerEntryOpen(InvGenJournalLine."Document No.",FALSE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedSecondCreditMemoNo,FALSE);
Member of Miscellaneous.Reverse Service Tax Helper


PostPurchaseDocWOServTax@1500103 Method

The procedure PostPurchaseDocWOServTax is available in codeunit 143006.

Syntax

PostPurchaseDocWOServTax@1500103(
    DocumentType@1500000 : Option DocumentType, //Input parameter of type Option
    VendorNo@1500001 : Code[20] VendorNo //Input parameter of type Code
);

Parameters

DocumentType
Input parameter of type Option
VendorNo
Input parameter of type Code

Return Value

Code[20]

Remarks

The relevant search keywords are: Post, Purchase, Document, WO, Serv, Tax.

For a clarification about how this function works, refer to the code listed below.

      LibraryPurchase.CreatePurchHeader(PurchaseHeader,DocumentType,VendorNo);
      PurchaseHeader.VALIDATE("Vendor Invoice No.",PurchaseHeader."No.");
      PurchaseHeader.VALIDATE("Vendor Cr. Memo No.",PurchaseHeader."No.");
      PurchaseHeader.MODIFY(TRUE);

      LibraryPurchase.CreatePurchaseLine(PurchaseLine,PurchaseHeader,
        PurchaseLine.Type::"G/L Account",CreateGLAccount(''),1);
      PurchaseLine.VALIDATE("Direct Unit Cost",LibraryRandom.RandDec(1000,2));
      PurchaseLine.MODIFY(TRUE);

      EXIT(PostPurchaseDoc(PurchaseHeader))

Example

The below example is extracted from the test automation codeunit 144033 to show one way of using this function.

      // Acceptance Test 7 an invoice with service tax applied on credit memo wo service tax Error is expected
      Initialize;

      VendorNo := ReverseServiceTaxHelper.CreateVendor;
      PostedInvoiceNo := ReverseServiceTaxHelper.PostPurchaseDocForVendor(
          PurchaseHeader,PurchaseLine,VendorNo,PurchaseHeader."Document Type"::Invoice,ServiceTaxType::Standard,FALSE);
      PostedCrMNo := ReverseServiceTaxHelper.PostPurchaseDocWOServTax(PurchaseHeader."Document Type"::"Credit Memo",VendorNo);

      ASSERTERROR ReverseServiceTaxHelper.ApplyAndPostVendorEntry(PurchaseHeader."Document Type"::Invoice,PostedInvoiceNo,
          VendorLedgerEntry."Document Type"::"Credit Memo",PostedCrMNo);

      Assert.ExpectedError(ServiceTaxApplicationErr);
Member of Miscellaneous.Reverse Service Tax Helper


PostPurchDocFromGenJnl@1500101 Method

The procedure PostPurchDocFromGenJnl is available in codeunit 143006.

Syntax

PostPurchDocFromGenJnl@1500101(
    VAR GenJournalLine@1500000 : Record 81 GenJournalLine, //Reference parameter of type Record
    ReverseChargeType@1500002 : Option ReverseChargeType, //Input parameter of type Option
    DocumentType@1500003 : Option DocumentType, //Input parameter of type Option
    PoT@1500004 : Boolean PoT //Input parameter of type Boolean
);

Parameters

GenJournalLine
Reference parameter of type Record
ReverseChargeType
Input parameter of type Option
DocumentType
Input parameter of type Option
PoT
Input parameter of type Boolean

Return Value

Code[20]

Remarks

The relevant search keywords are: Post, Purchase, Document, From, General, Journal.

For a clarification about how this function works, refer to the code listed below.

      CreatePurchaseDocFromGenJnl(GenJournalLine,DocumentType,GetReverseChargeServType(ReverseChargeType),ReverseChargeType,PoT,100);
      LibraryERM.PostGeneralJnlLine(GenJournalLine);
      EXIT(GenJournalLine."Document No.")

Example

The below example is extracted from the test automation codeunit 144033 to show one way of using this function.

      Initialize;
      PostedInvoiceNo := ReverseServiceTaxHelper.PostPurchDocFromGenJnl(
          GenJournalLine,ServiceTaxType::Standard,GenJournalLine."Document Type"::Invoice,FALSE);

      ReverseServiceTaxHelper.AlterServiceTaxGrpInJnlLine(GenJournalLine);
      ASSERTERROR PostAndOnlineApplyCrMJnl(GenJournalLine,GenJournalLine."Document Type",PostedInvoiceNo);

      Assert.ExpectedError(ServiceTaxGroupCodeErr);
Member of Miscellaneous.Reverse Service Tax Helper


RandomAmountForSalesDocType@1500060 Method

The procedure RandomAmountForSalesDocType is available in codeunit 143006.

Syntax

RandomAmountForSalesDocType@1500060(
    DocumentType@1500000 : Option DocumentType //Input parameter of type Option
);

Parameters

DocumentType
Input parameter of type Option

Return Value

Decimal

Remarks

The relevant search keywords are: Random, Amount, For, Sales, Document, Type.

For a clarification about how this function works, refer to the code listed below.

      EXIT(-GetAmountSignInJournalLine(DocumentType) * LibraryRandom.RandInt(100000));

Example

The below example is extracted from the test automation codeunit 144041 to show one way of using this function.

      ReverseServiceTaxHelper.CreateServiceTaxSetup(ServiceTaxSetup,ServiceTaxRegNoCode);
      BaseAmount := ReverseServiceTaxHelper.RandomAmountForSalesDocType(DocumentType);
      IF DocumentType IN [GenJournalLine."Document Type"::Payment,GenJournalLine."Document Type"::Refund] THEN
        LineAmount := BaseAmount + ReverseServiceTaxHelper.CalculateServTaxTotal(BaseAmount,ServiceTaxSetup)
      ELSE
        LineAmount := BaseAmount;
      PoT := GenJournalLine.PoT;
      ReverseServiceTaxHelper.CreateSalesJnlLineNormalPmt(
        GenJournalLine,DocumentType,ReverseServiceTaxHelper.CreateCustomer,
        LineAmount,ServiceTaxSetup."From Date");
      GenJournalLine.VALIDATE("Posting Date",ServiceTaxSetup."From Date");
      GenJournalLine.VALIDATE("Service Tax Group Code",ServiceTaxSetup.Code);
      GenJournalLine.VALIDATE("Service Tax Registration No.",ServiceTaxRegNoCode);
      IF DocumentType IN [GenJournalLine."Document Type"::Payment,GenJournalLine."Document Type"::Refund] THEN
        GenJournalLine.VALIDATE("Serv. Tax on Advance Payment",TRUE);
      ReverseServiceTaxHelper.InvokeForwardStaxCalculation(GenJournalLine);
      GenJournalLine.VALIDATE(PoT,PoT);
Member of Miscellaneous.Reverse Service Tax Helper


ReverseDocument@1500052 Method

The procedure ReverseDocument is available in codeunit 143006.

Syntax

ReverseDocument@1500052(
    DocumentNo@1500000 : Code[20] DocumentNo //Input parameter of type Code
);

Parameters

DocumentNo
Input parameter of type Code

Remarks

The relevant search keywords are: Reverse, Document.

For a clarification about how this function works, refer to the code listed below.

      VendLedgEntry.SETRANGE("Document No.",DocumentNo);
      VendLedgEntry.FINDLAST;
      ReversalEntry.SetReverseFilter(VendLedgEntry."Transaction No.",ReversalEntry."Reversal Type"::Transaction);
      // Form179
      TempReversalEntry.INIT;
      TempReversalEntry."Reversal Type" := TempReversalEntry."Reversal Type"::Transaction;
      TempReversalEntry."Transaction No." := VendLedgEntry."Transaction No.";
      TempReversalEntry.INSERT;
      // Form179.Post()
      ReversalEntry.CheckEntries;
      GenJnlPostReverse.Reverse(ReversalEntry,TempReversalEntry);

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      Initialize;

      PostPurchDocFromJnl(GenJournalLine,GenJournalLine."Document Type"::Invoice,ReverseChargeTypeOption::" ",TRUE);

      ReverseServiceTaxHelper.UseCreditToPayForSalesDoc(GenJournalLine."Document No.",ServiceTaxEntryDetails);

      ASSERTERROR ReverseServiceTaxHelper.ReverseDocument(GenJournalLine."Document No.");
      Assert.ExpectedError(STRSUBSTNO(ReversePaidTaxErr,GenJournalLine."Document Type",GenJournalLine."Document No."));
Member of Miscellaneous.Reverse Service Tax Helper


RoundAmount@1500022 Method

The procedure RoundAmount is available in codeunit 143006.

Syntax

RoundAmount@1500022(
    Amount@1500000 : Decimal Amount //Input parameter of type Decimal
);

Parameters

Amount
Input parameter of type Decimal

Return Value

Decimal

Remarks

The relevant search keywords are: Round, Amount.

For a clarification about how this function works, refer to the code listed below.

      GLSetup.GET;
      EXIT(ROUND(Amount,GLSetup."Amount Rounding Precision"));

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      ReverseServiceTaxHelper.GetBaseAndTaxAmountFromAdvPmt(
        PaymentBaseAmount,PaymentTaxAmount,ServiceTaxSetup,GenJournalLine.Amount,RevChargeType,100);

      // calculate tax and base amount for invoice
      ReverseServiceTaxHelper.GetBaseAndTaxAmountFromAdvPmt(InvoiceBaseAmount,InvoiceTaxAmount,
        ServiceTaxSetup,ReverseServiceTaxHelper.RoundAmount(PaymentBaseAmount / 3),RevChargeType,100);

      // create invoice and apply payment
      ReverseServiceTaxHelper.CreateDocAndApplyAdvPayment(PurchaseHeader,PurchaseLine,GenJournalLine,
        DocumentType,RevChargeType,100,PoT,InvoiceBaseAmount);

      // Exercise
      EXIT(ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader));
Member of Miscellaneous.Reverse Service Tax Helper


RoundServTax@1500021 Method

The procedure RoundServTax is available in codeunit 143006.

Syntax

RoundServTax@1500021(
    Amount@1500000 : Decimal Amount //Input parameter of type Decimal
);

Parameters

Amount
Input parameter of type Decimal

Return Value

Decimal

Remarks

The relevant search keywords are: Round, Serv, Tax.

For a clarification about how this function works, refer to the code listed below.

      GLSetup.GET;
      EXIT(ROUND(Amount,GLSetup."Service Tax Rounding Precision"));

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      ServiceTaxSetup.FindOnDate(PurchaseLine."Service Tax Group",PurchaseHeader."Posting Date");

      IF RevChargeType = ReverseChargeTypeOption::" " THEN
        BaseAmount := ReverseServiceTaxHelper.CalcServTaxBaseAmountBackward(BaseAmount,ServiceTaxSetup,0);

      InvoiceTaxAmount := ReverseServiceTaxHelper.CalculateServTaxAmount(ServiceTaxSetup,BaseAmount,DocumentType);

      FirstPaymentTaxAmount := ReverseServiceTaxHelper.RoundServTax(PartialPaymentFactor * InvoiceTaxAmount);
      SecondPaymentTaxAmount := ReverseServiceTaxHelper.RoundServTax((1 - PartialPaymentFactor) * InvoiceTaxAmount);

      SBCAmount :=
        ReverseServiceTaxHelper.CalculateServTaxSBCAmount(ServiceTaxSetup,BaseAmount,DocumentType);
      KKCAmount :=
        ReverseServiceTaxHelper.CalculateKKCAmount(ServiceTaxSetup,BaseAmount,DocumentType);

      FirstPaymentSBCAmount := ReverseServiceTaxHelper.RoundServTax(PartialPaymentFactor * SBCAmount);
      FirstPaymentKKCAmount := ReverseServiceTaxHelper.RoundServTax(PartialPaymentFactor * KKCAmount);
      SecondPaymentSBCAmount := ReverseServiceTaxHelper.RoundServTax((1 - PartialPaymentFactor) * SBCAmount);
      SecondPaymentKKCAmount := ReverseServiceTaxHelper.RoundServTax((1 - PartialPaymentFactor) * KKCAmount);

      ServiceTaxVerify.CountOfUnappliedEntries(ApplyTransactionNo);

      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDoc,TRUE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedRemainingPayment,TRUE);

      ServiceTaxVerify.UnappPmtRemainSTEntryDetBal(FirstPaymentTaxAmount,SecondPaymentTaxAmount,LastTransactionNo,RevChargeType,PoT);
      ServiceTaxVerify.UnappPmtRemainSTSBCKKCEntryDetBal(FirstPaymentSBCAmount,SecondPaymentSBCAmount,
        FirstPaymentKKCAmount,SecondPaymentKKCAmount,
        LastTransactionNo,RevChargeType,PoT);

      IF RevChargeType = ReverseChargeTypeOption::" " THEN
        ServiceTaxVerify.VendorLedgerEntryRemAmt(
          PostedPurchaseDoc,-((1 - PartialPaymentFactor) * (BaseAmount + InvoiceTaxAmount + SBCAmount + KKCAmount)))
      ELSE
        ServiceTaxVerify.VendorLedgerEntryRemAmt(PostedPurchaseDoc,-((1 - PartialPaymentFactor) * BaseAmount));

      ServiceTaxVerify.PostedPmtAndInvGLBalPartial(
        ServiceTaxSetup,RevChargeType,PoT,InvoiceTaxAmount,FirstPaymentTaxAmount);
      ServiceTaxVerify.PostedSBCKKCPmtAndInvGLBalPartial(
        ServiceTaxSetup,RevChargeType,PoT,SBCAmount,FirstPaymentSBCAmount,KKCAmount,FirstPaymentKKCAmount);
Member of Miscellaneous.Reverse Service Tax Helper


RunGenJnlPostLine@52 Method

The procedure RunGenJnlPostLine is available in codeunit 143006.

Syntax

RunGenJnlPostLine@52(
    VAR GenJnlLine@1000 : Record 81 GenJnlLine //Reference parameter of type Record
);

Parameters

GenJnlLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Run, General, Journal, Post, Line.

For a clarification about how this function works, refer to the code listed below.

      GenJnlPostLine.RunWithCheck(GenJnlLine);

Example

The below example is extracted from the test automation codeunit 144030 to show one way of using this function.

      // Setup
      CreateGeneralJournal(GenJournalLine,GenJournalLine."Document Type"::Payment);

      // Exercise
      GenJournalLine.VALIDATE("E.C.C. No.",CreateECCNo);
      GenJournalLine.MODIFY(TRUE);

      // Setting an "E.C.C. No." trigers to pay the Excise Tax from the PLA account. Excise Tax payment is out scope of verification here,
      // so the alternate verification is to post a payment without Errors when only E.C.C. No. is selected.
      ReverseServiceTaxHelper.RunGenJnlPostLine(GenJournalLine);
Member of Miscellaneous.Reverse Service Tax Helper


SetupCompanyInfo@13 Method

The procedure SetupCompanyInfo is available in codeunit 143006.

Syntax

SetupCompanyInfo@13(
      //param element not supplied
);

Remarks

The relevant search keywords are: Setup, Company, Info.

For a clarification about how this function works, refer to the code listed below.

      LibraryServiceTax.CreateServiceTaxRegistrationNo(ServiceTaxRegNo);

      CompanyInfo.GET;
      CompanyInfo.VALIDATE("Service Tax Registration No.",ServiceTaxRegNo.Code);
      CompanyInfo.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 144030 to show one way of using this function.

      LibraryRandom.SetSeed(1);

      IF isInitialized THEN
        EXIT;

      LibraryServiceTax.CreateServiceTaxReturnPeriod;
      ReverseServiceTaxHelper.SetupCompanyInfo;
      COMMIT;

      isInitialized := TRUE;
Member of Miscellaneous.Reverse Service Tax Helper


UnapplyTwice@1500053 Method

The procedure UnapplyTwice is available in codeunit 143006.

Syntax

UnapplyTwice@1500053(
    DocumentNo@1500000 : Code[20] DocumentNo //Input parameter of type Code
);

Parameters

DocumentNo
Input parameter of type Code

Remarks

The relevant search keywords are: Unapply, Twice.

For a clarification about how this function works, refer to the code listed below.

      UnapplyVendorLedgerEntry(DocumentNo);
      UnapplyVendorLedgerEntry(DocumentNo);

Example

The below example is extracted from the test automation codeunit 144034 to show one way of using this function.

      LastTransactionNo := Initialize;

      // Setup
      PostDocJnlLine(GenJournalLine,GenJournalLine."Document Type"::Invoice);
      CalculatePartialAmounts(GenJournalLine,RemainingPayment,CrMemoBaseAmount);

      OffApplyPostPayment(GenJournalLine,RemainingPayment);

      OffApplyPostCrMemoForInvoice(GenJournalLine,CrMemoBaseAmount);

      // Excercise
      ReverseServiceTaxHelper.UnapplyTwice(GenJournalLine."Document No.");

      // Verify
      VerifyUnapplyInvCrMemo(GenJournalLine,CrMemoBaseAmount,LastTransactionNo);
Member of Miscellaneous.Reverse Service Tax Helper


UnapplyVendorLedgerEntry@21 Method

The procedure UnapplyVendorLedgerEntry is available in codeunit 143006.

Syntax

UnapplyVendorLedgerEntry@21(
    DocumentNo@1500000 : Code[20] DocumentNo //Input parameter of type Code
);

Parameters

DocumentNo
Input parameter of type Code

Remarks

The relevant search keywords are: Unapply, Vendor, Ledger, Entry.

For a clarification about how this function works, refer to the code listed below.

      VendorLedgerEntry.SETRANGE("Document No.",DocumentNo);
      VendorLedgerEntry.FINDLAST;

      WITH DetailedVendorLedgEntry DO BEGIN
        SETRANGE("Vendor Ledger Entry No.",VendorLedgerEntry."Entry No.");
        SETRANGE("Entry Type","Entry Type"::Application);
        SETRANGE(Unapplied,FALSE);
        FINDLAST;
        DetailedVendorLedgEntryBuf.COPY(DetailedVendorLedgEntry);
        DetailedVendorLedgEntryBuf.INSERT;
        VendEntryApplyPostedEntries.PostUnApplyVendor(DetailedVendorLedgEntry,"Document No.","Posting Date");
      END;

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      Initialize;

      PostedPurchPaymentDocNo :=
        PostRevChargeInvAndApplyPmt(
          ServiceTaxRegNo,ServiceTaxGroup,ServiceTaxSetup,PurchaseHeader,PurchaseLine,
          PurchaseHeader."Document Type"::Invoice,PurchaseHeader."Service Type (Rev. Chrg.)"::Inward,
          ReverseChargeTypeOption::Standard);
      ReverseServiceTaxHelper.PayServiceTax(ServiceTaxRegNo.Code,ServiceTaxGroup.Code,TRUE);

      ASSERTERROR ReverseServiceTaxHelper.UnapplyVendorLedgerEntry(PostedPurchPaymentDocNo);
      Assert.ExpectedError(UnapplyOfUsedCreditErr);
Member of Miscellaneous.Reverse Service Tax Helper


UseCreditToPayForSalesDoc@1500050 Method

The procedure UseCreditToPayForSalesDoc is available in codeunit 143006.

Syntax

UseCreditToPayForSalesDoc@1500050(
    PostedDocNo@1500000 : Code[20] PostedDocNo, //Input parameter of type Code
    VAR ServiceTaxEntryDetails@1500001 : Record 16474 ServiceTaxEntryDetails //Reference parameter of type Record
);

Parameters

PostedDocNo
Input parameter of type Code
ServiceTaxEntryDetails
Reference parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Use, Credit, To, Pay, For, Sales, Document.

For a clarification about how this function works, refer to the code listed below.

      GetServiceTaxEntryDetail(ServiceTaxEntryDetails,PostedDocNo);
      PostedSalesInvoiceDocNo := PostEqualAmountSalesDoc(ServiceTaxEntryDetails);
      LibraryServiceTax.PayServiceTax(ServiceTaxEntryDetails."Service Tax Registration No.",ServiceTaxEntryDetails."Service Tax Group Code",FALSE);
      EXIT(PostedSalesInvoiceDocNo);

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      Initialize;

      PostPurchDocFromJnl(GenJournalLine,GenJournalLine."Document Type"::Invoice,ReverseChargeTypeOption::" ",TRUE);

      ReverseServiceTaxHelper.UseCreditToPayForSalesDoc(GenJournalLine."Document No.",ServiceTaxEntryDetails);

      ASSERTERROR ReverseServiceTaxHelper.ReverseDocument(GenJournalLine."Document No.");
      Assert.ExpectedError(STRSUBSTNO(ReversePaidTaxErr,GenJournalLine."Document Type",GenJournalLine."Document No."));
Member of Miscellaneous.Reverse Service Tax Helper


Service Tax As Excise Helper Class

Miscellaneous.Service Tax As Excise Helper

COD143003 applies to ERM,IN.

Methods

Name | Description
CreateECCNoAndSeries@1500007 | The procedure CreateECCNoAndSeries is available in codeunit 143003.
CreateExciseSetupWithItemVendorAndLocation@1500032 | The procedure CreateExciseSetupWithItemVendorAndLocation is available in codeunit 143003.
CreateGLAccount@1500011 | The procedure CreateGLAccount is available in codeunit 143003.
CreateInventoryPostingSetup@1500136 | The procedure CreateInventoryPostingSetup is available in codeunit 143003.
CreateItemWithTaxGroup@1500010 | The procedure CreateItemWithTaxGroup is available in codeunit 143003.
CreateLocationWithState@1500042 | The procedure CreateLocationWithState is available in codeunit 143003.
CreateLocationWithStateAndTINNo@1500012 | The procedure CreateLocationWithStateAndTINNo is available in codeunit 143003.
CreatePLAAccAndUpdateGLSetup@1500033 | The procedure CreatePLAAccAndUpdateGLSetup is available in codeunit 143003.
CreateStateWithCForm@1500014 | The procedure CreateStateWithCForm is available in codeunit 143003.
CreateStructure@1500008 | The procedure CreateStructure is available in codeunit 143003.
CreateStructureExciseSalesTax@1500031 | The procedure CreateStructureExciseSalesTax is available in codeunit 143003.
CreateTaxAreaLine@1500019 | The procedure CreateTaxAreaLine is available in codeunit 143003.
CreateTaxAreaLocations@1500056 | The procedure CreateTaxAreaLocations is available in codeunit 143003.
CreateTaxDetail@1500021 | The procedure CreateTaxDetail is available in codeunit 143003.
CreateTaxGroup@1500022 | The procedure CreateTaxGroup is available in codeunit 143003.
CreateTaxJurisdiction@1500023 | The procedure CreateTaxJurisdiction is available in codeunit 143003.
CreateVendorWithTaxLiable@1500024 | The procedure CreateVendorWithTaxLiable is available in codeunit 143003.
FindStateFormCode@1500020 | The procedure FindStateFormCode is available in codeunit 143003.
OpenPurchaseOrderStatistics@1500028 | The procedure OpenPurchaseOrderStatistics is available in codeunit 143003.
OpenSalesOrderStatistics@1500029 | The procedure OpenSalesOrderStatistics is available in codeunit 143003.
PostExcisePayment@1500025 | The procedure PostExcisePayment is available in codeunit 143003.
PostSalesInvoiceDirectExcise@1500050 | The procedure PostSalesInvoiceDirectExcise is available in codeunit 143003.
PostSalesInvoiceWithExcise@1500129 | The procedure PostSalesInvoiceWithExcise is available in codeunit 143003.
RoundExciseAmount@1500016 | The procedure RoundExciseAmount is available in codeunit 143003.
SetGlobalECCNo@1500000 | The procedure SetGlobalECCNo is available in codeunit 143003.
SetNewGlobalECCNo@1500030 | The procedure SetNewGlobalECCNo is available in codeunit 143003.
SetServiceTaxAsExciseCredit@1500092 | The procedure SetServiceTaxAsExciseCredit is available in codeunit 143003.
SetupItemLocationAndTaxes@1500017 | The procedure SetupItemLocationAndTaxes is available in codeunit 143003.
SetupSalesTax@1500013 | The procedure SetupSalesTax is available in codeunit 143003.
UpdateStateAccounts@1500015 | The procedure UpdateStateAccounts is available in codeunit 143003.
VerifyExcisePaidByServiceTax@1500003 | The procedure VerifyExcisePaidByServiceTax is available in codeunit 143003.

See Also

Miscellaneous


CreateECCNoAndSeries@1500007 Method

The procedure CreateECCNoAndSeries is available in codeunit 143003.

Syntax

CreateECCNoAndSeries@1500007(
    ExciseNoSeriesType@1500002 : Option ExciseNoSeriesType, //Input parameter of type Option
    NoSeriesCode@1500003 : Code[10] NoSeriesCode //Input parameter of type Code
);

Parameters

ExciseNoSeriesType
Input parameter of type Option
NoSeriesCode
Input parameter of type Code

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, ECC, No, Series.

For a clarification about how this function works, refer to the code listed below.

      WITH ECCNosRec DO BEGIN
        INIT;
        VALIDATE(Code,LibraryUtility.GenerateRandomCode(FIELDNO(Code),DATABASE::"E.C.C. Nos."));
        VALIDATE(Description,Code);
        VALIDATE("Type of Unit","Type of Unit"::" ");
        INSERT(TRUE)
      END;
      WITH ExciseNoSeries DO BEGIN
        INIT;
        VALIDATE(Type,ExciseNoSeriesType);
        VALIDATE("E.C.C. No.",ECCNosRec.Code);
        VALIDATE(Description,ECCNosRec.Code);
        VALIDATE("No. Series",NoSeriesCode);
        INSERT(TRUE);
      END;
      EXIT(ECCNosRec.Code);

Example

The below example is extracted from the test automation codeunit 144001 to show one way of using this function.

      CreateStructureCVDEnabled(StructureHeader);
      LocationCode :=
        LibraryLocation.CreateTradingLocation(
          ServiceTaxAsExciseHelper.CreateECCNoAndSeries(ExciseNoSeries.Type::RG23D,LibraryERM.CreateNoSeriesCode));
      ItemNo := CreateItemWithoutTaxGroup(ExcisePostingSetup."Excise Prod. Posting Group",FALSE);

      LibraryPurchase.CreatePurchHeader(
        PurchaseHeader,
        DocumentType,
        CreateVendorForeign(
          ExcisePostingSetup."Excise Bus. Posting Group",
          CurrencyFactor,
          LocationCode));
      PurchaseHeader.VALIDATE(Structure,StructureHeader.Code);
      PurchaseHeader.MODIFY(TRUE);

      LibraryPurchase.CreatePurchaseLine(
        PurchaseLine,
        PurchaseHeader,
        PurchaseLine.Type::Item,
        ItemNo,
        LibraryRandom.RandDecInRange(1000,2000,2));

      PurchaseLine.VALIDATE("Direct Unit Cost",LibraryRandom.RandDecInRange(10,20,2));
      PurchaseLine.VALIDATE("BCD Amount",BCDAmount);
      PurchaseLine.MODIFY(TRUE);

      CalculatePurchaseLines(PurchaseHeader);
      // Create Inventory Posting Setup for new item
      ServiceTaxAsExciseHelper.CreateInventoryPostingSetup(PurchaseLine."No.",LocationCode);
Member of Miscellaneous.Service Tax As Excise Helper


CreateExciseSetupWithItemVendorAndLocation@1500032 Method

The procedure CreateExciseSetupWithItemVendorAndLocation is available in codeunit 143003.

Syntax

CreateExciseSetupWithItemVendorAndLocation@1500032(
    VAR Vendor@1500000 : Record 23 Vendor, //Reference parameter of type Record
    VAR Location@1500002 : Record 14 Location //Reference parameter of type Record
);

Parameters

Vendor
Reference parameter of type Record
Location
Reference parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Excise, Setup, Item, Vendor, Location.

For a clarification about how this function works, refer to the code listed below.

      CreateAndUpdateAccountWithExciseSetup(ExcisePostingSetup);
      ItemCode := CreateItemWithTaxGroupAndExcise(Item,ExcisePostingSetup."Excise Prod. Posting Group");
      LibraryPurchase.CreateVendor(Vendor);
      Vendor.VALIDATE("Excise Bus. Posting Group",ExcisePostingSetup."Excise Bus. Posting Group");
      Vendor.MODIFY(TRUE);
      CreateLocationWithState(Location,ExcisePostingSetup."Excise Bus. Posting Group");
      Location.VALIDATE("E.C.C. No.",CreateECCNoAndSeries(0,LibraryERM.CreateNoSeriesCode));
      Location.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 144001 to show one way of using this function.

      // [SCENARIO BUG 167069]  Excise - PLA Amounts Should be reverse from Posted PLA Entires
      // [FEATURE] [PLA Transaction]

      // [GIVEN] Created Excise Setup with Vendor Item and Location & Structure
      Initialize;
      ItemCode := ServiceTaxAsExciseHelper.CreateExciseSetupWithItemVendorAndLocation(Vendor,Location);
      StructureCode := ServiceTaxAsExciseHelper.CreateStructure(Type::Excise);

      // [WHEN] Create and Post Purchase Order & Tax journal
      CreateAndPostPurchaseOrderWithStructure(Vendor."No.",ItemCode,StructureCode);
      CreateAndPostTaxJournal(Location."E.C.C. No.");

      // [WHEN] Reverse PLA Entry
      ReversalEntry.SetHideDialog(TRUE);
      ReversalEntry.ReverseTransaction(ReverseServiceTaxHelper.GetLastTransactionNo);

      // [THEN] PLA Entry has been reversed
      VerifyReversedPLAEntry;
Member of Miscellaneous.Service Tax As Excise Helper


CreateGLAccount@1500011 Method

The procedure CreateGLAccount is available in codeunit 143003.

Syntax

CreateGLAccount@1500011(
      //param element not supplied
);

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, General Ledger, Account.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.CreateGLAccount(GLAccount);
      EXIT(GLAccount."No.");

Example

The below example is extracted from the test automation codeunit 144001 to show one way of using this function.

      WITH ExcisePostingSetup DO BEGIN
        LibraryERM.CreateExcisePostingSetup(
          ExcisePostingSetup,"BED Calculation Type"::"Excise %",ExciseAmount,FALSE);
        // Will include BCD Amount only to BED Amount.
        // BED Amount is a part of Excise.
        "Cenvat Cr. Receivable(Trading)" := ServiceTaxAsExciseHelper.CreateGLAccount;
        "Cenvat Cr. Receivable Account" := ServiceTaxAsExciseHelper.CreateGLAccount;
        "Cenvat Transfered(Trading)" := ServiceTaxAsExciseHelper.CreateGLAccount;
        "eCess %" := LibraryRandom.RandInt(10);
        "eCess Calculation Formula" := 'BED AMOUNT';
        "SHE Cess %" := LibraryRandom.RandInt(10);
        "SHE Cess Calculation Formula" := 'BED AMOUNT';
        "Setoff available" := TRUE;
        MODIFY(TRUE);
      END;
Member of Miscellaneous.Service Tax As Excise Helper


CreateInventoryPostingSetup@1500136 Method

The procedure CreateInventoryPostingSetup is available in codeunit 143003.

Syntax

CreateInventoryPostingSetup@1500136(
    ItemNo@1500000 : Code[20] ItemNo, //Input parameter of type Code
    LocationCode@1500001 : Code[10] LocationCode //Input parameter of type Code
);

Parameters

ItemNo
Input parameter of type Code
LocationCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Inventory, Posting, Setup.

For a clarification about how this function works, refer to the code listed below.

      Item.GET(ItemNo);
      LibraryAssembly.CreateInvtPostingSetup(
        InventoryPostingSetup,
        LocationCode,
        Item."Inventory Posting Group",
        CreateGLAccount,
        CreateGLAccount,
        CreateGLAccount,
        CreateGLAccount,
        CreateGLAccount,
        CreateGLAccount);

Example

The below example is extracted from the test automation codeunit 144001 to show one way of using this function.

      CreateStructureCVDEnabled(StructureHeader);
      LocationCode :=
        LibraryLocation.CreateTradingLocation(
          ServiceTaxAsExciseHelper.CreateECCNoAndSeries(ExciseNoSeries.Type::RG23D,LibraryERM.CreateNoSeriesCode));
      ItemNo := CreateItemWithoutTaxGroup(ExcisePostingSetup."Excise Prod. Posting Group",FALSE);

      LibraryPurchase.CreatePurchHeader(
        PurchaseHeader,
        DocumentType,
        CreateVendorForeign(
          ExcisePostingSetup."Excise Bus. Posting Group",
          CurrencyFactor,
          LocationCode));
      PurchaseHeader.VALIDATE(Structure,StructureHeader.Code);
      PurchaseHeader.MODIFY(TRUE);

      LibraryPurchase.CreatePurchaseLine(
        PurchaseLine,
        PurchaseHeader,
        PurchaseLine.Type::Item,
        ItemNo,
        LibraryRandom.RandDecInRange(1000,2000,2));

      PurchaseLine.VALIDATE("Direct Unit Cost",LibraryRandom.RandDecInRange(10,20,2));
      PurchaseLine.VALIDATE("BCD Amount",BCDAmount);
      PurchaseLine.MODIFY(TRUE);

      CalculatePurchaseLines(PurchaseHeader);
      // Create Inventory Posting Setup for new item
      ServiceTaxAsExciseHelper.CreateInventoryPostingSetup(PurchaseLine."No.",LocationCode);
Member of Miscellaneous.Service Tax As Excise Helper


CreateItemWithTaxGroup@1500010 Method

The procedure CreateItemWithTaxGroup is available in codeunit 143003.

Syntax

CreateItemWithTaxGroup@1500010(
      //param element not supplied
);

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Item, Tax, Group.

For a clarification about how this function works, refer to the code listed below.

      LibraryInventory.CreateItem(Item);
      Item.VALIDATE("Tax Group Code",CreateTaxGroup(TRUE));
      Item.MODIFY(TRUE);
      EXIT(Item."No.");

Example

There are no examples available.
Member of Miscellaneous.Service Tax As Excise Helper


CreateLocationWithState@1500042 Method

The procedure CreateLocationWithState is available in codeunit 143003.

Syntax

CreateLocationWithState@1500042(
    VAR Location@1500000 : Record 14 Location, //Reference parameter of type Record
    ExciseBusPostingGroup@1500003 : Code[10] ExciseBusPostingGroup //Input parameter of type Code
);

Parameters

Location
Reference parameter of type Record
ExciseBusPostingGroup
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Location, State.

For a clarification about how this function works, refer to the code listed below.

      CreateLocationWithStateAndTINNo(Location);
      ECCNo := CreateECCNoAndSeries(ExciseNoSeries.Type::RG23D,LibraryERM.CreateNoSeriesCode);

      WITH Location DO BEGIN
        UpdateStateAccounts("State Code");
        VALIDATE("Trading Location",TRUE);
        VALIDATE("E.C.C. No.",ECCNo);
        VALIDATE("Excise Bus. Posting Group",ExciseBusPostingGroup);
        MODIFY(TRUE);
      END;

Example

The below example is extracted from the test automation codeunit 137061 to show one way of using this function.

      // Verify that the location code has changed on the Sales line.
      // Setup:
      Initialize;

      // Create item with Order Tracking.
      CreateItemWithTracking(Item);

      // Create two Customers with different default location codes.
      LibraryExciseHelper.CreateLocationWithState(Location,Item."Excise Prod. Posting Group");
      CreateCustomerWithLocation(Customer,Location.Code);

      LibraryExciseHelper.CreateLocationWithState(Location2,Item."Excise Prod. Posting Group");
      CreateCustomerWithLocation(Customer2,Location2.Code);
      LibrarySales.CreateSalesHeader(SalesHeader,SalesHeader."Document Type"::Order,Customer."No.");

      // Exercise: Create sales Line.
      LibrarySales.CreateSalesLine(
        SalesLine,SalesHeader,SalesLine.Type::Item,Item."No.",LibraryRandom.RandDec(10,2));

      // Change the Sell-to Customer No.
      SalesHeader.VALIDATE("Sell-to Customer No.",Customer2."No.");
      SalesHeader.MODIFY(TRUE);

      // Verify: verify that the location code has changed on the Sales line.
      SalesLine.GET(SalesLine."Document Type",SalesLine."Document No.",SalesLine."Line No.");
      Assert.AreEqual(Location2.Code,SalesLine."Location Code",ChangedOnSalesLine);

      // Verify that the location code has also changed in the Reservation Entry for the tracking entries.
      ReservationEntry.SETRANGE("Item No.",Item."No.");
      ReservationEntry.FINDSET;
      REPEAT
        Assert.AreEqual(
          Location2.Code,ReservationEntry."Location Code",ChangedOnReservationEntry);
      UNTIL ReservationEntry.NEXT = 0;
Member of Miscellaneous.Service Tax As Excise Helper


CreateLocationWithStateAndTINNo@1500012 Method

The procedure CreateLocationWithStateAndTINNo is available in codeunit 143003.

Syntax

CreateLocationWithStateAndTINNo@1500012(
    VAR Location@1500000 : Record 14 Location //Reference parameter of type Record
);

Parameters

Location
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Location, State, TIN, No.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.CreateState(State);
      LibraryERM.CreateTINNo(T_I_N_Nos);
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location);
      Location.VALIDATE("T.I.N. No.",T_I_N_Nos.Code);
      Location.VALIDATE("State Code",State.Code);
      Location.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 144022 to show one way of using this function.

      // Test the functionality of Posting Sales Order with multiple Item Charge and Foreign Currency.

      // Setup: Crete State, TIN, Location, Item, Currency and Exchange Rate. Create Tax Details and Structure. Create Sales Order.
      Initialize;
      Quantity := LibraryRandom.RandInt(5);
      ServiceTaxAsExciseHelper.CreateLocationWithStateAndTINNo(Location);
      CreateCurrencyAndExchangeRate(Currency);
      LibraryVariableStorage.Enqueue(AddReportingCurrencyConfirmMeaasge);  // Enqueue for Confirm Handler.
      UpdateGeneralLedgerSetup(OldCurrencyCode,OldInvRoundingPrecisionLCY,Currency.Code,LibraryRandom.RandDec(5,2));
      CreateSalesOrder(SalesHeader,Location.Code,Currency.Code,Quantity);

      // Exercise: Post Sales Order.
      LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);  // Post Sales Order as Ship and Invoice.

      // Verify: Posted Sales Invoice.
      VerifyPostedSalesInvoice(SalesHeader."No.",Location.Code,Quantity);

      // TearDown.
      LibraryVariableStorage.Enqueue(DeleteAddReportingCurrency);  // Enqueue for Confirm Handler.
      RestoreGeneralLedgerSetup(OldCurrencyCode,OldInvRoundingPrecisionLCY);
Member of Miscellaneous.Service Tax As Excise Helper


CreatePLAAccAndUpdateGLSetup@1500033 Method

The procedure CreatePLAAccAndUpdateGLSetup is available in codeunit 143003.

Syntax

CreatePLAAccAndUpdateGLSetup@1500033(
      //param element not supplied
);

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, PLA, Account, Update, General Ledger, Setup.

For a clarification about how this function works, refer to the code listed below.

      GeneralLedgerSetup.GET;
      GeneralLedgerSetup.VALIDATE("PLA Account",LibraryERM.CreateGLAccountNo);
      GeneralLedgerSetup.MODIFY(TRUE);
      EXIT(GeneralLedgerSetup."PLA Account");

Example

There are no examples available.
Member of Miscellaneous.Service Tax As Excise Helper


CreateStateWithCForm@1500014 Method

The procedure CreateStateWithCForm is available in codeunit 143003.

Syntax

CreateStateWithCForm@1500014(
    VAR State@1500001 : Record 13762 State //Reference parameter of type Record
);

Parameters

State
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, State, C, Form.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.CreateState(State);
      UpdateStateAccounts(State.Code);
      CreateStateForms(State.Code,TRUE,FALSE);

Example

The below example is extracted from the test automation codeunit 144082 to show one way of using this function.

      ServiceTaxAsExciseHelper.CreateStateWithCForm(State);
      State.VALIDATE("Tax Account (Sales)",LibraryERM.CreateGLAccountNo);
      State.MODIFY(TRUE);
      WITH Customer DO BEGIN
        GET(CustomerNo);
        VALIDATE("State Code",State.Code);
        VALIDATE("Tax Liable",TRUE);
        VALIDATE("Location Code",Location.Code);
        MODIFY(TRUE);
      END;
      LibraryWarehouse.CreateLocationWithInventoryPostingSetup(Location);
      Location.VALIDATE("State Code",State.Code);
      Location.MODIFY(TRUE);
Member of Miscellaneous.Service Tax As Excise Helper


CreateStructure@1500008 Method

The procedure CreateStructure is available in codeunit 143003.

Syntax

CreateStructure@1500008(
    Type@1500001 : Option Type //Input parameter of type Option
);

Parameters

Type
Input parameter of type Option

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Structure.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.CreateStructureHeader(StructureHeader);
      LibraryERM.CreateStructureDetails(StructureDetails,StructureHeader.Code,1,Type,'','');  // Value 1 for Calculation Order Field.
      WITH StructureDetails DO BEGIN
        VALIDATE("Include Base",TRUE);
        VALIDATE("Include Line Discount",TRUE);
        VALIDATE("Include Invoice Discount",TRUE);
        MODIFY(TRUE);
      END;
      EXIT(StructureHeader.Code);

Example

The below example is extracted from the test automation codeunit 144001 to show one way of using this function.

      // [SCENARIO BUG 167069]  Excise - PLA Amounts Should be reverse from Posted PLA Entires
      // [FEATURE] [PLA Transaction]

      // [GIVEN] Created Excise Setup with Vendor Item and Location & Structure
      Initialize;
      ItemCode := ServiceTaxAsExciseHelper.CreateExciseSetupWithItemVendorAndLocation(Vendor,Location);
      StructureCode := ServiceTaxAsExciseHelper.CreateStructure(Type::Excise);

      // [WHEN] Create and Post Purchase Order & Tax journal
      CreateAndPostPurchaseOrderWithStructure(Vendor."No.",ItemCode,StructureCode);
      CreateAndPostTaxJournal(Location."E.C.C. No.");

      // [WHEN] Reverse PLA Entry
      ReversalEntry.SetHideDialog(TRUE);
      ReversalEntry.ReverseTransaction(ReverseServiceTaxHelper.GetLastTransactionNo);

      // [THEN] PLA Entry has been reversed
      VerifyReversedPLAEntry;
Member of Miscellaneous.Service Tax As Excise Helper


CreateStructureExciseSalesTax@1500031 Method

The procedure CreateStructureExciseSalesTax is available in codeunit 143003.

Syntax

CreateStructureExciseSalesTax@1500031(
    SalesTaxBaseFormula@1500001 : Text[80] SalesTaxBaseFormula //Input parameter of type Text
);

Parameters

SalesTaxBaseFormula
Input parameter of type Text

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Structure, Excise, Sales, Tax.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.CreateStructureHeader(StructureHeader);
      WITH StructureDetails DO BEGIN
        LibraryERM.CreateStructureDetails(StructureDetails,StructureHeader.Code,1,Type::Excise,'','');
        VALIDATE("Include Base",TRUE);
        MODIFY(TRUE);
        LibraryERM.CreateStructureDetails(StructureDetails,StructureHeader.Code,1,Type::"Sales Tax",'','');
        VALIDATE("Include Base",TRUE);
        VALIDATE("Base Formula",SalesTaxBaseFormula);
        MODIFY(TRUE);
        EXIT(Code);
      END;

Example

There are no examples available.
Member of Miscellaneous.Service Tax As Excise Helper


CreateTaxAreaLine@1500019 Method

The procedure CreateTaxAreaLine is available in codeunit 143003.

Syntax

CreateTaxAreaLine@1500019(
    TaxArea@1500000 : Code[20] TaxArea, //Input parameter of type Code
    TaxJurisdiction@1500001 : Code[10] TaxJurisdiction //Input parameter of type Code
);

Parameters

TaxArea
Input parameter of type Code
TaxJurisdiction
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Tax, Area, Line.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.CreateTaxAreaLine(TaxAreaLine,TaxArea,TaxJurisdiction);
      TaxAreaLine.VALIDATE("Calculation Order",GetNextCalcOrdTaxAreaLine(TaxArea));
      TaxAreaLine.VALIDATE("Include Tax Base",TRUE);
      TaxAreaLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 144014 to show one way of using this function.

      LibraryERM.CreateTaxArea(TaxArea);
      LibraryERM.CreateTaxJurisdiction(TaxJurisdiction);
      LibraryERM.CreateTaxGroup(TaxGroup);
      LibraryWarehouse.CreateLocation(Location);
      LibraryERM.CreateState(State);
      Location.VALIDATE("State Code",State.Code);
      Location.MODIFY;
      LibraryERM.CreateState(State);
      TaxJurisdiction.VALIDATE("State Code",Location."State Code");
      TaxJurisdiction.VALIDATE("Tax Type",TaxJurisdiction."Tax Type"::CST);
      TaxJurisdiction.MODIFY(TRUE);
      ServiceTaxAsExciseHelper.CreateTaxAreaLocations(Location.Code,State.Code,TaxArea.Code,TaxAreaLocationsType::Customer);
      LibraryERM.CreateTaxAreaLine(TaxAreaLine,TaxArea.Code,TaxJurisdiction.Code);
      TaxAreaLine.VALIDATE("Include Tax Base",TRUE);
      TaxAreaLine.MODIFY;
      LibraryERM.CreateTaxDetail(TaxDetail,TaxJurisdiction.Code,TaxGroup.Code,TaxDetail."Tax Type"::"Sales Tax",WORKDATE);
      TaxDetail.VALIDATE("Tax Below Maximum",LibraryRandom.RandDecInRange(10,15,2));
      TaxDetail.MODIFY(TRUE);
Member of Miscellaneous.Service Tax As Excise Helper


CreateTaxAreaLocations@1500056 Method

The procedure CreateTaxAreaLocations is available in codeunit 143003.

Syntax

CreateTaxAreaLocations@1500056(
    LocationCode@1500000 : Code[20] LocationCode, //Input parameter of type Code
    StateCode@1500001 : Code[10] StateCode, //Input parameter of type Code
    TaxAreaCode@1500002 : Code[20] TaxAreaCode, //Input parameter of type Code
    TaxAreaLocationsType@1500006 : Option TaxAreaLocationsType //Input parameter of type Option
);

Parameters

LocationCode
Input parameter of type Code
StateCode
Input parameter of type Code
TaxAreaCode
Input parameter of type Code
TaxAreaLocationsType
Input parameter of type Option

Remarks

The relevant search keywords are: Create, Tax, Area, Locations.

For a clarification about how this function works, refer to the code listed below.

      WITH TaxAreaLocations DO BEGIN
        INIT;
        VALIDATE(Type,TaxAreaLocationsType);
        VALIDATE("Dispatch / Receiving Location",LocationCode);
        VALIDATE("Customer / Vendor Location",StateCode);
        VALIDATE("VAT Applicable",TRUE);
        VALIDATE("Tax Area Code",TaxAreaCode);
        INSERT;
      END;

Example

The below example is extracted from the test automation codeunit 144014 to show one way of using this function.

      LibraryERM.CreateTaxArea(TaxArea);
      LibraryERM.CreateTaxJurisdiction(TaxJurisdiction);
      LibraryERM.CreateTaxGroup(TaxGroup);
      LibraryWarehouse.CreateLocation(Location);
      LibraryERM.CreateState(State);
      Location.VALIDATE("State Code",State.Code);
      Location.MODIFY;
      LibraryERM.CreateState(State);
      TaxJurisdiction.VALIDATE("State Code",Location."State Code");
      TaxJurisdiction.VALIDATE("Tax Type",TaxJurisdiction."Tax Type"::CST);
      TaxJurisdiction.MODIFY(TRUE);
      ServiceTaxAsExciseHelper.CreateTaxAreaLocations(Location.Code,State.Code,TaxArea.Code,TaxAreaLocationsType::Customer);
      LibraryERM.CreateTaxAreaLine(TaxAreaLine,TaxArea.Code,TaxJurisdiction.Code);
      TaxAreaLine.VALIDATE("Include Tax Base",TRUE);
      TaxAreaLine.MODIFY;
      LibraryERM.CreateTaxDetail(TaxDetail,TaxJurisdiction.Code,TaxGroup.Code,TaxDetail."Tax Type"::"Sales Tax",WORKDATE);
      TaxDetail.VALIDATE("Tax Below Maximum",LibraryRandom.RandDecInRange(10,15,2));
      TaxDetail.MODIFY(TRUE);
Member of Miscellaneous.Service Tax As Excise Helper


CreateTaxDetail@1500021 Method

The procedure CreateTaxDetail is available in codeunit 143003.

Syntax

CreateTaxDetail@1500021(
    VAR TaxDetail@1500000 : Record 322 TaxDetail, //Reference parameter of type Record
    TaxJurisdictionCode@1500001 : Code[10] TaxJurisdictionCode, //Input parameter of type Code
    TaxGroupCode@1500002 : Code[10] TaxGroupCode, //Input parameter of type Code
    TaxType@1500003 : Option TaxType, //Input parameter of type Option
    EffectiveDate@1500004 : Date EffectiveDate, //Input parameter of type Date
    TaxBelowMax@1500005 : Decimal TaxBelowMax, //Input parameter of type Decimal
    FormCode@1500006 : Code[10] FormCode //Input parameter of type Code
);

Parameters

TaxDetail
Reference parameter of type Record
TaxJurisdictionCode
Input parameter of type Code
TaxGroupCode
Input parameter of type Code
TaxType
Input parameter of type Option
EffectiveDate
Input parameter of type Date
TaxBelowMax
Input parameter of type Decimal
FormCode
Input parameter of type Code

Remarks

The relevant search keywords are: Create, Tax, Detail.

For a clarification about how this function works, refer to the code listed below.

      WITH TaxDetail DO BEGIN
        INIT;
        VALIDATE("Tax Jurisdiction Code",TaxJurisdictionCode);
        VALIDATE("Tax Group Code",TaxGroupCode);
        VALIDATE("Tax Type",TaxType);
        VALIDATE("Effective Date",EffectiveDate);
        VALIDATE("Form Code",FormCode);
        VALIDATE("Tax Below Maximum",TaxBelowMax);
        INSERT(TRUE);
      END;

Example

The below example is extracted from the test automation codeunit 144014 to show one way of using this function.

      LibraryERM.CreateTaxArea(TaxArea);
      LibraryERM.CreateTaxJurisdiction(TaxJurisdiction);
      LibraryERM.CreateTaxGroup(TaxGroup);
      LibraryWarehouse.CreateLocation(Location);
      LibraryERM.CreateState(State);
      Location.VALIDATE("State Code",State.Code);
      Location.MODIFY;
      LibraryERM.CreateState(State);
      TaxJurisdiction.VALIDATE("State Code",Location."State Code");
      TaxJurisdiction.VALIDATE("Tax Type",TaxJurisdiction."Tax Type"::CST);
      TaxJurisdiction.MODIFY(TRUE);
      ServiceTaxAsExciseHelper.CreateTaxAreaLocations(Location.Code,State.Code,TaxArea.Code,TaxAreaLocationsType::Customer);
      LibraryERM.CreateTaxAreaLine(TaxAreaLine,TaxArea.Code,TaxJurisdiction.Code);
      TaxAreaLine.VALIDATE("Include Tax Base",TRUE);
      TaxAreaLine.MODIFY;
      LibraryERM.CreateTaxDetail(TaxDetail,TaxJurisdiction.Code,TaxGroup.Code,TaxDetail."Tax Type"::"Sales Tax",WORKDATE);
      TaxDetail.VALIDATE("Tax Below Maximum",LibraryRandom.RandDecInRange(10,15,2));
      TaxDetail.MODIFY(TRUE);
Member of Miscellaneous.Service Tax As Excise Helper


CreateTaxGroup@1500022 Method

The procedure CreateTaxGroup is available in codeunit 143003.

Syntax

CreateTaxGroup@1500022(
    Applicable@1500001 : Boolean Applicable //Input parameter of type Boolean
);

Parameters

Applicable
Input parameter of type Boolean

Return Value

Code[10]

Remarks

The relevant search keywords are: Create, Tax, Group.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.CreateTaxGroup(TaxGroup);
      TaxGroup.VALIDATE("VAT Applicable",Applicable);
      TaxGroup.MODIFY(TRUE);
      EXIT(TaxGroup.Code);

Example

The below example is extracted from the test automation codeunit 144014 to show one way of using this function.

      LibraryERM.CreateTaxArea(TaxArea);
      LibraryERM.CreateTaxJurisdiction(TaxJurisdiction);
      LibraryERM.CreateTaxGroup(TaxGroup);
      LibraryWarehouse.CreateLocation(Location);
      LibraryERM.CreateState(State);
      Location.VALIDATE("State Code",State.Code);
      Location.MODIFY;
      LibraryERM.CreateState(State);
      TaxJurisdiction.VALIDATE("State Code",Location."State Code");
      TaxJurisdiction.VALIDATE("Tax Type",TaxJurisdiction."Tax Type"::CST);
      TaxJurisdiction.MODIFY(TRUE);
      ServiceTaxAsExciseHelper.CreateTaxAreaLocations(Location.Code,State.Code,TaxArea.Code,TaxAreaLocationsType::Customer);
      LibraryERM.CreateTaxAreaLine(TaxAreaLine,TaxArea.Code,TaxJurisdiction.Code);
      TaxAreaLine.VALIDATE("Include Tax Base",TRUE);
      TaxAreaLine.MODIFY;
      LibraryERM.CreateTaxDetail(TaxDetail,TaxJurisdiction.Code,TaxGroup.Code,TaxDetail."Tax Type"::"Sales Tax",WORKDATE);
      TaxDetail.VALIDATE("Tax Below Maximum",LibraryRandom.RandDecInRange(10,15,2));
      TaxDetail.MODIFY(TRUE);
Member of Miscellaneous.Service Tax As Excise Helper


CreateTaxJurisdiction@1500023 Method

The procedure CreateTaxJurisdiction is available in codeunit 143003.

Syntax

CreateTaxJurisdiction@1500023(
    VAR TaxJurisdiction@1500000 : Record 320 TaxJurisdiction, //Reference parameter of type Record
    TaxType@1500001 : Option TaxType //Input parameter of type Option
);

Parameters

TaxJurisdiction
Reference parameter of type Record
TaxType
Input parameter of type Option

Remarks

The relevant search keywords are: Create, Tax, Jurisdiction.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.CreateTaxJurisdiction(TaxJurisdiction);
      WITH TaxJurisdiction DO BEGIN
        VALIDATE("Tax Account (Sales)",CreateGLAccount);
        VALIDATE("Tax Account (Purchases)",CreateGLAccount);
        VALIDATE("Tax Type",TaxType);
        MODIFY(TRUE);
      END;

Example

The below example is extracted from the test automation codeunit 144014 to show one way of using this function.

      LibraryERM.CreateTaxArea(TaxArea);
      LibraryERM.CreateTaxJurisdiction(TaxJurisdiction);
      LibraryERM.CreateTaxGroup(TaxGroup);
      LibraryWarehouse.CreateLocation(Location);
      LibraryERM.CreateState(State);
      Location.VALIDATE("State Code",State.Code);
      Location.MODIFY;
      LibraryERM.CreateState(State);
      TaxJurisdiction.VALIDATE("State Code",Location."State Code");
      TaxJurisdiction.VALIDATE("Tax Type",TaxJurisdiction."Tax Type"::CST);
      TaxJurisdiction.MODIFY(TRUE);
      ServiceTaxAsExciseHelper.CreateTaxAreaLocations(Location.Code,State.Code,TaxArea.Code,TaxAreaLocationsType::Customer);
      LibraryERM.CreateTaxAreaLine(TaxAreaLine,TaxArea.Code,TaxJurisdiction.Code);
      TaxAreaLine.VALIDATE("Include Tax Base",TRUE);
      TaxAreaLine.MODIFY;
      LibraryERM.CreateTaxDetail(TaxDetail,TaxJurisdiction.Code,TaxGroup.Code,TaxDetail."Tax Type"::"Sales Tax",WORKDATE);
      TaxDetail.VALIDATE("Tax Below Maximum",LibraryRandom.RandDecInRange(10,15,2));
      TaxDetail.MODIFY(TRUE);
Member of Miscellaneous.Service Tax As Excise Helper


CreateVendorWithTaxLiable@1500024 Method

The procedure CreateVendorWithTaxLiable is available in codeunit 143003.

Syntax

CreateVendorWithTaxLiable@1500024(
    VAR Vendor@1500000 : Record 23 Vendor, //Reference parameter of type Record
    CurrencyCode@1500001 : Code[10] CurrencyCode, //Input parameter of type Code
    TaxLiable@1500002 : Boolean TaxLiable //Input parameter of type Boolean
);

Parameters

Vendor
Reference parameter of type Record
CurrencyCode
Input parameter of type Code
TaxLiable
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, Vendor, Tax, Liable.

For a clarification about how this function works, refer to the code listed below.

      LibraryPurchase.CreateVendor(Vendor);
      LibraryERM.CreateTaxArea(TaxArea);
      WITH Vendor DO BEGIN
        VALIDATE("Tax Area Code",TaxArea.Code);
        VALIDATE("Tax Liable",TaxLiable);
        VALIDATE("Currency Code",CurrencyCode);
        MODIFY(TRUE);
      END;

Example

The below example is extracted from the test automation codeunit 144022 to show one way of using this function.

      ServiceTaxAsExciseHelper.CreateVendorWithTaxLiable(Vendor,CurrencyCode,TRUE);
      CreatePurchaseHeaderForCreditMemo(PurchaseHeader,CurrencyCode,Vendor."No.");
      CreatePurchaseLineWithTax(PurchaseHeader,Vendor."Tax Area Code");
      EXIT(LibraryPurchase.PostPurchaseDocument(PurchaseHeader,TRUE,TRUE));
Member of Miscellaneous.Service Tax As Excise Helper


FindStateFormCode@1500020 Method

The procedure FindStateFormCode is available in codeunit 143003.

Syntax

FindStateFormCode@1500020(
    StateCode@1500001 : Code[10] StateCode //Input parameter of type Code
);

Parameters

StateCode
Input parameter of type Code

Return Value

Code[10]

Remarks

The relevant search keywords are: Find, State, Form, Code.

For a clarification about how this function works, refer to the code listed below.

      WITH StateForms DO BEGIN
        SETRANGE(State,StateCode);
        FINDFIRST;
        EXIT("Form Code");
      END;

Example

The below example is extracted from the test automation codeunit 144001 to show one way of using this function.

      CreateCustomer(Customer,TRUE,ExciseBusPostingGroup,StateCode);

      WITH SalesHeader DO BEGIN
        LibrarySales.CreateSalesHeader(SalesHeader,"Document Type"::Order,Customer."No.");
        VALIDATE(Structure,ServiceTaxAsExciseHelper.CreateStructure(StructureDetails.Type::Excise));
        VALIDATE("Location Code",PurchaseLine."Location Code");
        VALIDATE("Form Code",ServiceTaxAsExciseHelper.FindStateFormCode(State));
        MODIFY(TRUE);
      END;

      WITH SalesLine DO BEGIN
        LibrarySales.CreateSalesLine(SalesLine,SalesHeader,Type::Item,PurchaseLine."No.",PurchaseLine.Quantity);
        VALIDATE("Unit Price",PurchaseLine."Direct Unit Cost" * Factor);
        VALIDATE("Qty. to Ship",PurchaseLine."Quantity Received" / Factor);
        MODIFY(TRUE);

        DocumentNo := LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);
        GET("Document Type","Document No.","Line No.");
        FindSalesInvoiceLine(SalesInvoiceLine,DocumentNo);
      END;
Member of Miscellaneous.Service Tax As Excise Helper


OpenPurchaseOrderStatistics@1500028 Method

The procedure OpenPurchaseOrderStatistics is available in codeunit 143003.

Syntax

OpenPurchaseOrderStatistics@1500028(
    PurchaseLine@1500001 : Record 39 PurchaseLine //Input parameter of type Record
);

Parameters

PurchaseLine
Input parameter of type Record

Remarks

The relevant search keywords are: Open, Purchase, Order, Statistics.

For a clarification about how this function works, refer to the code listed below.

      PurchasesPayablesSetup.GET;
      WITH PurchaseLine DO BEGIN
        PurchaseHeader.GET("Document Type","Document No.");
        IF PurchasesPayablesSetup."Calc. Inv. Discount" THEN BEGIN
          PurchaseHeader.CalcInvDiscForHeader;
          COMMIT;
        END;

        IF PurchaseHeader.Structure <> '' THEN BEGIN
          CalculateStructures(PurchaseHeader);
          AdjustStructureAmounts(PurchaseHeader);
          UpdatePurchLines(PurchaseHeader);
        END;
        CalculateTDS(PurchaseHeader);

        COMMIT;
        PAGE.RUNMODAL(PAGE::"Purchase Order Statistics",PurchaseHeader);
      END;

Example

The below example is extracted from the test automation codeunit 144001 to show one way of using this function.

      WITH PurchaseLine DO
        LibraryVariableStorage.Enqueue(
          ServiceTaxAsExciseHelper.RoundExciseAmount(
            CalcExciseAmount("Direct Unit Cost","Qty. to Receive",ExcisePostingSetup,1)));

      ServiceTaxAsExciseHelper.OpenPurchaseOrderStatistics(PurchaseLine);
Member of Miscellaneous.Service Tax As Excise Helper


OpenSalesOrderStatistics@1500029 Method

The procedure OpenSalesOrderStatistics is available in codeunit 143003.

Syntax

OpenSalesOrderStatistics@1500029(
    VAR SalesLine@1500000 : Record 37 SalesLine //Reference parameter of type Record
);

Parameters

SalesLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Open, Sales, Order, Statistics.

For a clarification about how this function works, refer to the code listed below.

      SalesReceivablesSetup.GET;
      WITH SalesLine DO BEGIN
        SalesHeader.GET("Document Type","Document No.");
        SalesHeader.CALCFIELDS("Price Inclusive of Taxes");
        IF SalesReceivablesSetup."Calc. Inv. Discount" AND (NOT SalesHeader."Price Inclusive of Taxes") THEN BEGIN
          SalesHeader.CalcInvDiscForHeader;
          COMMIT
        END;
        IF SalesHeader."Price Inclusive of Taxes" THEN BEGIN
          InitStrOrdDetail(SalesHeader);
          GetSalesPriceExclusiveTaxes(SalesHeader);
          UpdateSalesLinesPIT(SalesHeader);
          COMMIT;
        END;

        IF SalesHeader.Structure <> '' THEN BEGIN
          CalculateStructures(SalesHeader);
          AdjustStructureAmounts(SalesHeader);
          UpdateSalesLines(SalesHeader);
        END;
        CalculateTCS(SalesHeader);

        COMMIT;
        PAGE.RUNMODAL(PAGE::"Sales Order Statistics",SalesHeader);
      END;

Example

The below example is extracted from the test automation codeunit 144001 to show one way of using this function.

      ExciseAmount := CalcExciseAmount(SalesLine."Unit Price",PurchInvLine.Quantity,ExcisePostingSetup,1);
      LibraryVariableStorage.Enqueue(ServiceTaxAsExciseHelper.RoundExciseAmount(ExciseAmount));
      LibraryVariableStorage.Enqueue(
        CalcTaxAmount(SalesLine."Unit Price" * PurchInvLine.Quantity,ExciseAmount,TaxPercent));
      ServiceTaxAsExciseHelper.OpenSalesOrderStatistics(SalesLine);
Member of Miscellaneous.Service Tax As Excise Helper


PostExcisePayment@1500025 Method

The procedure PostExcisePayment is available in codeunit 143003.

Syntax

PostExcisePayment@1500025(
    PostedSalesInvoiceDocNo@1500001 : Code[20] PostedSalesInvoiceDocNo, //Input parameter of type Code
    ServiceTaxEntryDetails@1500000 : Record 16474 ServiceTaxEntryDetails //Input parameter of type Record
);

Parameters

PostedSalesInvoiceDocNo
Input parameter of type Code
ServiceTaxEntryDetails
Input parameter of type Record

Remarks

The relevant search keywords are: Post, Excise, Payment.

For a clarification about how this function works, refer to the code listed below.

      FindExciseEntry(ExciseEntry,PostedSalesInvoiceDocNo);
      CreateExcisePayment(ExciseEntry,ServiceTaxEntryDetails,GenJournalLine);
      // Form 13701 Pay Excise."Apply Entries".OnPush
      ExciseEntry."Modvat Claimed Doc No." := GenJournalLine."Document No.";
      ExciseEntry.MODIFY;

      LibraryERM.PostGeneralJnlLine(GenJournalLine);

Example

The below example is extracted from the test automation codeunit 144043 to show one way of using this function.

      LastTransactionNo := Initialize;
      OldECCNo := ServiceTaxAsExciseHelper.SetNewGlobalECCNo;

      ApplyInvToAdvPmt(ServiceTaxEntryDetails,TRUE);
      ServiceTaxAsExciseHelper.SetServiceTaxAsExciseCredit(ServiceTaxEntryDetails);
      PostedSalesInvoiceDocNo :=
        ServiceTaxAsExciseHelper.PostSalesInvoiceWithExcise(
          ServiceTaxEntryDetails."Posting Date",ServiceTaxEntryDetails."Base Amount" DIV 3);

      ServiceTaxAsExciseHelper.PostExcisePayment(PostedSalesInvoiceDocNo,ServiceTaxEntryDetails);

      // Verify
      ServiceTaxAsExciseHelper.VerifyExcisePaidByServiceTax(ServiceTaxEntryDetails,LastTransactionNo);

      // TearDown
      ServiceTaxAsExciseHelper.SetGlobalECCNo(OldECCNo);
Member of Miscellaneous.Service Tax As Excise Helper


PostSalesInvoiceDirectExcise@1500050 Method

The procedure PostSalesInvoiceDirectExcise is available in codeunit 143003.

Syntax

PostSalesInvoiceDirectExcise@1500050(
    PostingDate@1500004 : Date PostingDate, //Input parameter of type Date
    BaseAmount@1500003 : Decimal BaseAmount, //Input parameter of type Decimal
    ServiceTaxGroupCode@1500000 : Code[20] ServiceTaxGroupCode //Input parameter of type Code
);

Parameters

PostingDate
Input parameter of type Date
BaseAmount
Input parameter of type Decimal
ServiceTaxGroupCode
Input parameter of type Code

Return Value

Code[20]

Remarks

The relevant search keywords are: Post, Sales, Invoice, Direct, Excise.

For a clarification about how this function works, refer to the code listed below.

      CreateSalesDocWithExcise(SalesHeader,SalesLine,PostingDate);
      SalesLine.VALIDATE("Unit Price",BaseAmount);
      SalesLine.VALIDATE("Direct Debit To PLA / RG",TRUE);
      SalesLine.MODIFY(TRUE);

      CreateExcisePaymentForDoc(SalesHeader,SalesLine,ServiceTaxGroupCode);

      PostedDocNo := NoSeriesManagement.GetNextNo(SalesHeader."Posting No. Series",PostingDate,FALSE);
      LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

Example

The below example is extracted from the test automation codeunit 144043 to show one way of using this function.

      LastTransactionNo := Initialize;
      OldECCNo := ServiceTaxAsExciseHelper.SetNewGlobalECCNo;

      ApplyInvToAdvPmt(ServiceTaxEntryDetails,TRUE);
      ServiceTaxAsExciseHelper.SetServiceTaxAsExciseCredit(ServiceTaxEntryDetails);

      ServiceTaxAsExciseHelper.PostSalesInvoiceDirectExcise(
        ServiceTaxEntryDetails."Posting Date",ServiceTaxEntryDetails."Base Amount" DIV 3,
        ServiceTaxEntryDetails."Service Tax Group Code");

      // Verify
      ServiceTaxAsExciseHelper.VerifyExcisePaidByServiceTax(ServiceTaxEntryDetails,LastTransactionNo);

      // TearDown
      ServiceTaxAsExciseHelper.SetGlobalECCNo(OldECCNo);
Member of Miscellaneous.Service Tax As Excise Helper


PostSalesInvoiceWithExcise@1500129 Method

The procedure PostSalesInvoiceWithExcise is available in codeunit 143003.

Syntax

PostSalesInvoiceWithExcise@1500129(
    PostingDate@1500004 : Date PostingDate, //Input parameter of type Date
    BaseAmount@1500003 : Decimal BaseAmount //Input parameter of type Decimal
);

Parameters

PostingDate
Input parameter of type Date
BaseAmount
Input parameter of type Decimal

Return Value

Code[20]

Remarks

The relevant search keywords are: Post, Sales, Invoice, Excise.

For a clarification about how this function works, refer to the code listed below.

      CreateSalesDocWithExcise(SalesHeader,SalesLine,PostingDate);
      SalesLine.VALIDATE("Unit Price",BaseAmount);
      SalesLine.MODIFY(TRUE);
      SalesLine.CalculateStructures(SalesHeader);
      SalesLine.AdjustStructureAmounts(SalesHeader);
      SalesLine.UpdateSalesLines(SalesHeader);
      SalesLine.FIND;
      SalesLine.VALIDATE("eCess Amount",0);
      SalesLine.VALIDATE("SHE Cess Amount",0);
      SalesLine.MODIFY(TRUE);

      PostedDocNo := NoSeriesManagement.GetNextNo(SalesHeader."Posting No. Series",PostingDate,FALSE);
      LibrarySales.PostSalesDocument(SalesHeader,TRUE,TRUE);

Example

The below example is extracted from the test automation codeunit 144043 to show one way of using this function.

      LastTransactionNo := Initialize;
      OldECCNo := ServiceTaxAsExciseHelper.SetNewGlobalECCNo;

      ApplyInvToAdvPmt(ServiceTaxEntryDetails,TRUE);
      ServiceTaxAsExciseHelper.SetServiceTaxAsExciseCredit(ServiceTaxEntryDetails);
      PostedSalesInvoiceDocNo :=
        ServiceTaxAsExciseHelper.PostSalesInvoiceWithExcise(
          ServiceTaxEntryDetails."Posting Date",ServiceTaxEntryDetails."Base Amount" DIV 3);

      ServiceTaxAsExciseHelper.PostExcisePayment(PostedSalesInvoiceDocNo,ServiceTaxEntryDetails);

      // Verify
      ServiceTaxAsExciseHelper.VerifyExcisePaidByServiceTax(ServiceTaxEntryDetails,LastTransactionNo);

      // TearDown
      ServiceTaxAsExciseHelper.SetGlobalECCNo(OldECCNo);
Member of Miscellaneous.Service Tax As Excise Helper


RoundExciseAmount@1500016 Method

The procedure RoundExciseAmount is available in codeunit 143003.

Syntax

RoundExciseAmount@1500016(
    ExciseDutyAmount@1280004 : Decimal ExciseDutyAmount //Input parameter of type Decimal
);

Parameters

ExciseDutyAmount
Input parameter of type Decimal

Return Value

Decimal

Remarks

The relevant search keywords are: Round, Excise, Amount.

For a clarification about how this function works, refer to the code listed below.

      WITH GLSetup DO BEGIN
        GET;
        CASE "Excise Rounding Type" OF
          "Excise Rounding Type"::Nearest:
            ExciseRoundingDirection := '=';
          "Excise Rounding Type"::Up:
            ExciseRoundingDirection := '>';
          "Excise Rounding Type"::Down:
            ExciseRoundingDirection := '<';
        END;
        IF "Excise Rounding Precision" <> 0 THEN
          ExciseRoundingPrecision := "Excise Rounding Precision"
        ELSE
          ExciseRoundingPrecision := 0.01;
        EXIT(ROUND(ExciseDutyAmount,ExciseRoundingPrecision,ExciseRoundingDirection));
      END;

Example

The below example is extracted from the test automation codeunit 144001 to show one way of using this function.

      WITH PurchaseLine DO
        LibraryVariableStorage.Enqueue(
          ServiceTaxAsExciseHelper.RoundExciseAmount(
            CalcExciseAmount("Direct Unit Cost","Qty. to Receive",ExcisePostingSetup,1)));

      ServiceTaxAsExciseHelper.OpenPurchaseOrderStatistics(PurchaseLine);
Member of Miscellaneous.Service Tax As Excise Helper


SetGlobalECCNo@1500000 Method

The procedure SetGlobalECCNo is available in codeunit 143003.

Syntax

SetGlobalECCNo@1500000(
    NewECCNo@1500001 : Code[20] NewECCNo //Input parameter of type Code
);

Parameters

NewECCNo
Input parameter of type Code

Return Value

Code[20]

Remarks

The relevant search keywords are: Set, Global, ECC, No.

For a clarification about how this function works, refer to the code listed below.

      WITH CompanyInfo DO BEGIN
        GET;
        OldECCNo := "E.C.C. No.";
        VALIDATE("E.C.C. No.",NewECCNo);
        MODIFY;
      END;

Example

The below example is extracted from the test automation codeunit 144043 to show one way of using this function.

      LastTransactionNo := Initialize;
      OldECCNo := ServiceTaxAsExciseHelper.SetNewGlobalECCNo;

      ApplyInvToAdvPmt(ServiceTaxEntryDetails,TRUE);
      ServiceTaxAsExciseHelper.SetServiceTaxAsExciseCredit(ServiceTaxEntryDetails);

      ServiceTaxAsExciseHelper.PostSalesInvoiceDirectExcise(
        ServiceTaxEntryDetails."Posting Date",ServiceTaxEntryDetails."Base Amount" DIV 3,
        ServiceTaxEntryDetails."Service Tax Group Code");

      // Verify
      ServiceTaxAsExciseHelper.VerifyExcisePaidByServiceTax(ServiceTaxEntryDetails,LastTransactionNo);

      // TearDown
      ServiceTaxAsExciseHelper.SetGlobalECCNo(OldECCNo);
Member of Miscellaneous.Service Tax As Excise Helper


SetNewGlobalECCNo@1500030 Method

The procedure SetNewGlobalECCNo is available in codeunit 143003.

Syntax

SetNewGlobalECCNo@1500030(
      //param element not supplied
);

Return Value

Code[20]

Remarks

The relevant search keywords are: Set, New, Global, ECC, No.

For a clarification about how this function works, refer to the code listed below.

      EXIT(SetGlobalECCNo(CreateECCNo));

Example

The below example is extracted from the test automation codeunit 144043 to show one way of using this function.

      LastTransactionNo := Initialize;
      OldECCNo := ServiceTaxAsExciseHelper.SetNewGlobalECCNo;

      ApplyInvToAdvPmt(ServiceTaxEntryDetails,TRUE);
      ServiceTaxAsExciseHelper.SetServiceTaxAsExciseCredit(ServiceTaxEntryDetails);

      ServiceTaxAsExciseHelper.PostSalesInvoiceDirectExcise(
        ServiceTaxEntryDetails."Posting Date",ServiceTaxEntryDetails."Base Amount" DIV 3,
        ServiceTaxEntryDetails."Service Tax Group Code");

      // Verify
      ServiceTaxAsExciseHelper.VerifyExcisePaidByServiceTax(ServiceTaxEntryDetails,LastTransactionNo);

      // TearDown
      ServiceTaxAsExciseHelper.SetGlobalECCNo(OldECCNo);
Member of Miscellaneous.Service Tax As Excise Helper


SetServiceTaxAsExciseCredit@1500092 Method

The procedure SetServiceTaxAsExciseCredit is available in codeunit 143003.

Syntax

SetServiceTaxAsExciseCredit@1500092(
    ServiceTaxEntryDetails@1500000 : Record 16474 ServiceTaxEntryDetails //Input parameter of type Record
);

Parameters

ServiceTaxEntryDetails
Input parameter of type Record

Remarks

The relevant search keywords are: Set, Service, Tax, As, Excise, Credit.

For a clarification about how this function works, refer to the code listed below.

      ServiceTaxEntryDetails.SETRANGE("Service Tax Registration No.",ServiceTaxEntryDetails."Service Tax Registration No.");
      ServiceTaxEntryDetails.SETFILTER("Remaining Credit",'<>0');
      ServiceTaxEntryDetails.MODIFYALL("Service Tax as Excise",TRUE);

Example

The below example is extracted from the test automation codeunit 144043 to show one way of using this function.

      LastTransactionNo := Initialize;
      OldECCNo := ServiceTaxAsExciseHelper.SetNewGlobalECCNo;

      ApplyInvToAdvPmt(ServiceTaxEntryDetails,TRUE);
      ServiceTaxAsExciseHelper.SetServiceTaxAsExciseCredit(ServiceTaxEntryDetails);

      ServiceTaxAsExciseHelper.PostSalesInvoiceDirectExcise(
        ServiceTaxEntryDetails."Posting Date",ServiceTaxEntryDetails."Base Amount" DIV 3,
        ServiceTaxEntryDetails."Service Tax Group Code");

      // Verify
      ServiceTaxAsExciseHelper.VerifyExcisePaidByServiceTax(ServiceTaxEntryDetails,LastTransactionNo);

      // TearDown
      ServiceTaxAsExciseHelper.SetGlobalECCNo(OldECCNo);
Member of Miscellaneous.Service Tax As Excise Helper


SetupItemLocationAndTaxes@1500017 Method

The procedure SetupItemLocationAndTaxes is available in codeunit 143003.

Syntax

SetupItemLocationAndTaxes@1500017(
    VAR Item@1500001 : Record 27 Item, //Reference parameter of type Record
    VAR Location@1500002 : Record 14 Location, //Reference parameter of type Record
    ExcisePostingSetup@1500003 : Record 13711 ExcisePostingSetup, //Input parameter of type Record
    FormCode@1500006 : Code[10] FormCode, //Input parameter of type Code
    StateCode@1500007 : Code[10] StateCode, //Input parameter of type Code
    TaxPercent@1500008 : Decimal TaxPercent //Input parameter of type Decimal
);

Parameters

Item
Reference parameter of type Record
Location
Reference parameter of type Record
ExcisePostingSetup
Input parameter of type Record
FormCode
Input parameter of type Code
StateCode
Input parameter of type Code
TaxPercent
Input parameter of type Decimal

Remarks

The relevant search keywords are: Setup, Item, Location, Taxes.

For a clarification about how this function works, refer to the code listed below.

      CreateItemWithTaxGroupAndExcise(Item,ExcisePostingSetup."Excise Prod. Posting Group");
      CreateLocationWithState(Location,ExcisePostingSetup."Excise Bus. Posting Group");
      SetupTaxes(Item."Tax Group Code",FormCode,Location.Code,StateCode,TaxPercent,
        TaxJurisdiction."Tax Type"::CST,TaxAreaLocations.Type::Vendor);
      SetupTaxes(Item."Tax Group Code",FormCode,Location.Code,StateCode,TaxPercent,
        TaxJurisdiction."Tax Type"::CST,TaxAreaLocations.Type::Customer);

Example

There are no examples available.
Member of Miscellaneous.Service Tax As Excise Helper


SetupSalesTax@1500013 Method

The procedure SetupSalesTax is available in codeunit 143003.

Syntax

SetupSalesTax@1500013(
    TaxAreaCode@1500000 : Code[20] TaxAreaCode, //Input parameter of type Code
    TaxGroupCode@1500005 : Code[10] TaxGroupCode, //Input parameter of type Code
    TaxBelowMax@1500003 : Decimal TaxBelowMax, //Input parameter of type Decimal
    TaxType@1500004 : Option TaxType, //Input parameter of type Option
    FormCode@1500006 : Code[10] FormCode //Input parameter of type Code
);

Parameters

TaxAreaCode
Input parameter of type Code
TaxGroupCode
Input parameter of type Code
TaxBelowMax
Input parameter of type Decimal
TaxType
Input parameter of type Option
FormCode
Input parameter of type Code

Remarks

The relevant search keywords are: Setup, Sales, Tax.

For a clarification about how this function works, refer to the code listed below.

      CreateTaxJurisdiction(TaxJurisdiction,TaxType);
      CreateTaxAreaLine(TaxAreaCode,TaxJurisdiction.Code);
      CreateTaxDetail(
        TaxDetail,TaxJurisdiction.Code,TaxGroupCode,TaxDetail."Tax Type"::"Sales Tax",WORKDATE,TaxBelowMax,FormCode);

Example

The below example is extracted from the test automation codeunit 144022 to show one way of using this function.

      CreatePurchaseLine(
        PurchaseLine,PurchaseHeader,PurchaseLine.Type::Item,ServiceTaxAsExciseHelper.CreateItemWithTaxGroup,1,7.31); // 1 and 7.31 are needed to trigger the inconsistent error.
      PurchaseLine.VALIDATE("Tax Area Code",VendorTaxAreaCode);
      PurchaseLine.MODIFY(TRUE);
      ServiceTaxAsExciseHelper.SetupSalesTax(
        PurchaseLine."Tax Area Code",PurchaseLine."Tax Group Code",1,TaxJurisdiction."Tax Type"::" ",''); // 1 is needed to trigger the inconsistent error.
Member of Miscellaneous.Service Tax As Excise Helper


UpdateStateAccounts@1500015 Method

The procedure UpdateStateAccounts is available in codeunit 143003.

Syntax

UpdateStateAccounts@1500015(
    StateCode@1500001 : Code[10] StateCode //Input parameter of type Code
);

Parameters

StateCode
Input parameter of type Code

Remarks

The relevant search keywords are: Update, State, Accounts.

For a clarification about how this function works, refer to the code listed below.

      WITH State DO BEGIN
        GET(StateCode);
        VALIDATE("CST Account (Sales)",CreateGLAccount);
        VALIDATE("Tax Account (Sales)",CreateGLAccount);
        VALIDATE("Tax Account (Purchases)",CreateGLAccount);
        MODIFY(TRUE);
      END;

Example

There are no examples available.
Member of Miscellaneous.Service Tax As Excise Helper


VerifyExcisePaidByServiceTax@1500003 Method

The procedure VerifyExcisePaidByServiceTax is available in codeunit 143003.

Syntax

VerifyExcisePaidByServiceTax@1500003(
    ServiceTaxEntryDetails@1500002 : Record 16474 ServiceTaxEntryDetails, //Input parameter of type Record
    LastTransactionNo@1500000 : Integer LastTransactionNo //Input parameter of type Integer
);

Parameters

ServiceTaxEntryDetails
Input parameter of type Record
LastTransactionNo
Input parameter of type Integer

Remarks

The relevant search keywords are: Verify, Excise, Paid, By, Service, Tax.

For a clarification about how this function works, refer to the code listed below.

      VerifyExciseIsPaid(LastTransactionNo);
      VerifyExciseTookCredit(ServiceTaxEntryDetails,LastTransactionNo);
      VerifyNegativeSTEntriesClosed(LastTransactionNo);

Example

The below example is extracted from the test automation codeunit 144043 to show one way of using this function.

      LastTransactionNo := Initialize;
      OldECCNo := ServiceTaxAsExciseHelper.SetNewGlobalECCNo;

      ApplyInvToAdvPmt(ServiceTaxEntryDetails,TRUE);
      ServiceTaxAsExciseHelper.SetServiceTaxAsExciseCredit(ServiceTaxEntryDetails);

      ServiceTaxAsExciseHelper.PostSalesInvoiceDirectExcise(
        ServiceTaxEntryDetails."Posting Date",ServiceTaxEntryDetails."Base Amount" DIV 3,
        ServiceTaxEntryDetails."Service Tax Group Code");

      // Verify
      ServiceTaxAsExciseHelper.VerifyExcisePaidByServiceTax(ServiceTaxEntryDetails,LastTransactionNo);

      // TearDown
      ServiceTaxAsExciseHelper.SetGlobalECCNo(OldECCNo);
Member of Miscellaneous.Service Tax As Excise Helper


Service Tax FCY Helper Class

Miscellaneous.Service Tax FCY Helper

COD143002 applies to ERM,IN.

Methods

Name | Description
ConvertFCYAmountToLCY@1500000 | The procedure ConvertFCYAmountToLCY is available in codeunit 143002.
CreateRandomExchangeRate@25 | The procedure CreateRandomExchangeRate is available in codeunit 143002.
GetSecondDocDate@1500018 | The procedure GetSecondDocDate is available in codeunit 143002.
GetThirdDocDate@1500029 | The procedure GetThirdDocDate is available in codeunit 143002.
InitExchRatesForSTReturnPeriod@1500010 | The procedure InitExchRatesForSTReturnPeriod is available in codeunit 143002.
SetCurrencyOnGenJnl@1500006 | The procedure SetCurrencyOnGenJnl is available in codeunit 143002.
SetFCYNonResPmtOnJnlLine@1500056 | The procedure SetFCYNonResPmtOnJnlLine is available in codeunit 143002.
SetNonResidentPmtOnTDSGroup@1500045 | The procedure SetNonResidentPmtOnTDSGroup is available in codeunit 143002.
SetupExchangeRates@1500027 | The procedure SetupExchangeRates is available in codeunit 143002.
VerifyServiceTaxAdvPmtBal@1500002 | The procedure VerifyServiceTaxAdvPmtBal is available in codeunit 143002.
VerifyServiceTaxAdvPmtBalances@1500025 | The procedure VerifyServiceTaxAdvPmtBalances is available in codeunit 143002.
VerifyServiceTaxInvBalances@1500015 | The procedure VerifyServiceTaxInvBalances is available in codeunit 143002.
VerifyServTaxAdvPmtBalRounding@1500001 | The procedure VerifyServTaxAdvPmtBalRounding is available in codeunit 143002.

See Also

Miscellaneous


ConvertFCYAmountToLCY@1500000 Method

The procedure ConvertFCYAmountToLCY is available in codeunit 143002.

Syntax

ConvertFCYAmountToLCY@1500000(
    GenJournalLine@1500000 : Record 81 GenJournalLine //Input parameter of type Record
);

Parameters

GenJournalLine
Input parameter of type Record

Return Value

Decimal

Remarks

The relevant search keywords are: Convert, FCY, Amount, To, LCY.

For a clarification about how this function works, refer to the code listed below.

      EXIT(ROUND(LibraryERM.ConvertCurrency(GenJournalLine.Amount,GenJournalLine."Currency Code",'',GenJournalLine."Posting Date")));

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;
      ServiceTaxTDSHelper.AdvPmtApplyBiggerInvDocPoTFcy(GenJournalLine,PmtGenJournalLine);

      // Verify
      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      GenJournalLine.Amount += ReverseServiceTaxHelper.CalculateServTaxTotal(GenJournalLine.Amount,ServiceTaxSetup) +
        ReverseServiceTaxHelper.CalculateKKCess(GenJournalLine.Amount,ServiceTaxSetup) +
        ReverseServiceTaxHelper.CalculateSBC(GenJournalLine.Amount,ServiceTaxSetup);
      GenJournalLine.Amount :=
        ServiceTaxFCYHelper.ConvertFCYAmountToLCY(GenJournalLine) - ServiceTaxFCYHelper.ConvertFCYAmountToLCY(PmtGenJournalLine);
      ServiceTaxTDSHelper.VerifyTDSEntryFromBase(GenJournalLine);
Member of Miscellaneous.Service Tax FCY Helper


CreateRandomExchangeRate@25 Method

The procedure CreateRandomExchangeRate is available in codeunit 143002.

Syntax

CreateRandomExchangeRate@25(
    CurrencyCode@1001 : Code[10] CurrencyCode, //Input parameter of type Code
    Date@1500000 : Date Date, //Input parameter of type Date
    PrevCurrExchangeRate@1500001 : Decimal PrevCurrExchangeRate, //Input parameter of type Decimal
    PrevRelationalCurrExchRate@1500002 : Integer PrevRelationalCurrExchRate //Input parameter of type Integer
);

Parameters

CurrencyCode
Input parameter of type Code
Date
Input parameter of type Date
PrevCurrExchangeRate
Input parameter of type Decimal
PrevRelationalCurrExchRate
Input parameter of type Integer

Remarks

The relevant search keywords are: Create, Random, Exchange, Rate.

For a clarification about how this function works, refer to the code listed below.

      WITH CurrencyExchangeRate DO BEGIN
        SETFILTER("Currency Code",CurrencyCode);
        SETRANGE("Starting Date",Date);
        IF NOT FINDFIRST THEN BEGIN
          INIT;
          VALIDATE("Currency Code",CurrencyCode);
          VALIDATE("Starting Date",Date);
          INSERT(TRUE);
          VALIDATE("Exchange Rate Amount",PrevCurrExchangeRate);
          VALIDATE("Adjustment Exch. Rate Amount","Exchange Rate Amount");
          VALIDATE("Relational Exch. Rate Amount",
            PrevRelationalCurrExchRate + LibraryRandom.RandInt(100));
          VALIDATE("Relational Adjmt Exch Rate Amt","Relational Exch. Rate Amount");
          MODIFY(TRUE);
        END;
      END;

Example

There are no examples available.
Member of Miscellaneous.Service Tax FCY Helper


GetSecondDocDate@1500018 Method

The procedure GetSecondDocDate is available in codeunit 143002.

Syntax

GetSecondDocDate@1500018(
    FirstDocDate@1500000 : Date FirstDocDate //Input parameter of type Date
);

Parameters

FirstDocDate
Input parameter of type Date

Return Value

Date

Remarks

The relevant search keywords are: Get, Second, Document, Date.

For a clarification about how this function works, refer to the code listed below.

      EXIT(CALCDATE('<+1M>',FirstDocDate));

Example

The below example is extracted from the test automation codeunit 144044 to show one way of using this function.

      LastTransactionNo := Initialize;

      PostAdvDocGenJnlPoT(GenJournalLine,GenJournalLine."Document Type"::Payment);
      ServiceTaxFCYHelper.SetupExchangeRates(GenJournalLine);

      PostPartialDoc(
        GenJournalLine,GenJournalLine."Document Type"::Invoice,
        ServiceTaxFCYHelper.GetSecondDocDate(GenJournalLine."Posting Date"),1,ApplyGenJournalLine);

      ReverseServiceTaxHelper.ApplyAndPostVendorEntry(
        VendLedgEntry."Document Type"::Payment,GenJournalLine."Document No.",
        VendLedgEntry."Document Type"::Invoice,ApplyGenJournalLine."Document No.");

      ServiceTaxFCYHelper.VerifyServiceTaxAdvPmtBalances(GenJournalLine,LastTransactionNo,TRUE);
Member of Miscellaneous.Service Tax FCY Helper


GetThirdDocDate@1500029 Method

The procedure GetThirdDocDate is available in codeunit 143002.

Syntax

GetThirdDocDate@1500029(
    FirstDocDate@1500000 : Date FirstDocDate //Input parameter of type Date
);

Parameters

FirstDocDate
Input parameter of type Date

Return Value

Date

Remarks

The relevant search keywords are: Get, Third, Document, Date.

For a clarification about how this function works, refer to the code listed below.

      EXIT(CALCDATE('<+2M>',FirstDocDate));

Example

The below example is extracted from the test automation codeunit 144044 to show one way of using this function.

      LastTransactionNo := Initialize;

      PostDocGenJnlPoT(GenJournalLine,GenJournalLine."Document Type"::Invoice);
      ServiceTaxFCYHelper.SetupExchangeRates(GenJournalLine);
      PostPartialApplyingDocReturn(GenJournalLine,GenJournalLine."Document Type"::"Credit Memo",
        ServiceTaxFCYHelper.GetSecondDocDate(GenJournalLine."Posting Date"),LibraryRandom.RandDec(1,1),ApplyGenJournalLine1);
      PostPartialApplyingDocReturn(GenJournalLine,GenJournalLine."Document Type"::"Credit Memo",
        ServiceTaxFCYHelper.GetThirdDocDate(GenJournalLine."Posting Date"),1,ApplyGenJournalLine2);

      ReverseServiceTaxHelper.UnapplyTwice(GenJournalLine."Document No.");

      Verify3UnappliedDocs(GenJournalLine,ApplyGenJournalLine1,ApplyGenJournalLine2,LastTransactionNo);
Member of Miscellaneous.Service Tax FCY Helper


InitExchRatesForSTReturnPeriod@1500010 Method

The procedure InitExchRatesForSTReturnPeriod is available in codeunit 143002.

Syntax

InitExchRatesForSTReturnPeriod@1500010(
    CurrencyCode@1500000 : Code[10] CurrencyCode //Input parameter of type Code
);

Parameters

CurrencyCode
Input parameter of type Code

Remarks

The relevant search keywords are: Init, Exchange, Rates, For, ST, Return, Period.

For a clarification about how this function works, refer to the code listed below.

      ReverseServiceTaxHelper.GetServiceTaxReturnPeriod(ServiceTaxReturnPeriod);
      CreateRandomExchangeRate(CurrencyCode,
        LibraryServiceTax.GetSrvTaxReturnPeriodStartDate(ServiceTaxReturnPeriod),100,100 + LibraryRandom.RandInt(100));

Example

There are no examples available.
Member of Miscellaneous.Service Tax FCY Helper


SetCurrencyOnGenJnl@1500006 Method

The procedure SetCurrencyOnGenJnl is available in codeunit 143002.

Syntax

SetCurrencyOnGenJnl@1500006(
    VAR GenJournalLine@1500000 : Record 81 GenJournalLine //Reference parameter of type Record
);

Parameters

GenJournalLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Set, Currency, On, General, Journal.

For a clarification about how this function works, refer to the code listed below.

      CurrencyCode := ReverseServiceTaxHelper.FindCurrencyCode;
      InitExchRatesForSTReturnPeriod(CurrencyCode);
      GenJournalLine.VALIDATE("Currency Code",CurrencyCode);
      GenJournalLine.MODIFY;

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      PaymentAmount := ServiceTaxTDSHelper.CalcPaymentAmount(InvoiceGenJnlLine,IncludeServTax);
      ReverseServiceTaxHelper.CreatePayment(
        PaymentGenJnlLine,InvoiceGenJnlLine."Account No.",PaymentAmount,
        InvoiceGenJnlLine."Posting Date",InvoiceGenJnlLine."Document Type"::Payment);
      ServiceTaxFCYHelper.SetCurrencyOnGenJnl(PaymentGenJnlLine);
      LibraryERM.PostGeneralJnlLine(PaymentGenJnlLine);
      EXIT(PaymentGenJnlLine."Document No.")
Member of Miscellaneous.Service Tax FCY Helper


SetFCYNonResPmtOnJnlLine@1500056 Method

The procedure SetFCYNonResPmtOnJnlLine is available in codeunit 143002.

Syntax

SetFCYNonResPmtOnJnlLine@1500056(
    VAR GenJournalLine@1500000 : Record 81 GenJournalLine //Reference parameter of type Record
);

Parameters

GenJournalLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Set, FCY, Non, Resource, Payment, On, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      SetCurrencyOnGenJnl(GenJournalLine);
      SetNonResidentPmtOnTDSGroup(GenJournalLine,TRUE);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      // Setup
      LastTransactionNo := Initialize;
      ServiceTaxTDSHelper.CreatePurchaseDocGenJnlPoT(InvoiceGenJournalLine,TRUE);
      ServiceTaxFCYHelper.SetFCYNonResPmtOnJnlLine(InvoiceGenJournalLine);
      LibraryTDS.SetInclServTaxOptionInGenJnl(InvoiceGenJournalLine,IncludeServTax);
      PaymentDocNo := PostPaymentFCY(InvoiceGenJournalLine,IncludeServTax);
      InvoiceGenJournalLine.VALIDATE("Applies-to Doc. Type",InvoiceGenJournalLine."Applies-to Doc. Type"::Payment);
      InvoiceGenJournalLine.VALIDATE("Applies-to Doc. No.",PaymentDocNo);
      InvoiceGenJournalLine.MODIFY;

      // Exercise
      LibraryERM.PostGeneralJnlLine(InvoiceGenJournalLine);

      // Restore
      ServiceTaxFCYHelper.SetNonResidentPmtOnTDSGroup(InvoiceGenJournalLine,FALSE);

      // Verify
      ServiceTaxFCYHelper.VerifyServiceTaxInvBalances(InvoiceGenJournalLine,LastTransactionNo);
      InvoiceGenJournalLine.Amount := ServiceTaxFCYHelper.ConvertFCYAmountToLCY(InvoiceGenJournalLine);
      ServiceTaxTDSHelper.VerifyTDSPostingInvoice(InvoiceGenJournalLine,IncludeServTax);
Member of Miscellaneous.Service Tax FCY Helper


SetNonResidentPmtOnTDSGroup@1500045 Method

The procedure SetNonResidentPmtOnTDSGroup is available in codeunit 143002.

Syntax

SetNonResidentPmtOnTDSGroup@1500045(
    GenJournalLine@1500000 : Record 81 GenJournalLine, //Input parameter of type Record
    NonResidentPayments@1500001 : Boolean NonResidentPayments //Input parameter of type Boolean
);

Parameters

GenJournalLine
Input parameter of type Record
NonResidentPayments
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, Non, Resident, Payment, On, TDS, Group.

For a clarification about how this function works, refer to the code listed below.

      WITH TDSGroup DO BEGIN
        SETRANGE("TDS Group",GenJournalLine."TDS Group");
        SETFILTER("Effective Date",STRSUBSTNO('<=%1',GenJournalLine."Posting Date"));
        FINDLAST;
        VALIDATE("Non Resident Payments",NonResidentPayments);
        MODIFY;
      END;
      COMMIT;

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      // Setup
      LastTransactionNo := Initialize;
      LibraryServiceTax.SetServiceTaxRounding;
      // Exercise
      PostAdvancePaymentPoTFCY(GenJournalLine,IncludeServTax);

      // Restore
      ServiceTaxFCYHelper.SetNonResidentPmtOnTDSGroup(GenJournalLine,FALSE);

      // Verify
      ServiceTaxFCYHelper.VerifyServiceTaxAdvPmtBalances(GenJournalLine,LastTransactionNo,FALSE);
      GenJournalLine.Amount := ServiceTaxFCYHelper.ConvertFCYAmountToLCY(GenJournalLine);
      ServiceTaxTDSHelper.VerifyTDSPostingAdvPmt(GenJournalLine,IncludeServTax);
      LibraryServiceTax.SetServiceTaxRoundingOne;
Member of Miscellaneous.Service Tax FCY Helper


SetupExchangeRates@1500027 Method

The procedure SetupExchangeRates is available in codeunit 143002.

Syntax

SetupExchangeRates@1500027(
    GenJournalLine@1500000 : Record 81 GenJournalLine //Input parameter of type Record
);

Parameters

GenJournalLine
Input parameter of type Record

Remarks

The relevant search keywords are: Setup, Exchange, Rates.

For a clarification about how this function works, refer to the code listed below.

      LibraryERM.FindExchRate(CurrencyExchangeRate,GenJournalLine."Currency Code",GenJournalLine."Posting Date");
      CreateRandomExchangeRate(GenJournalLine."Currency Code",GetSecondDocDate(GenJournalLine."Posting Date"),
        CurrencyExchangeRate."Exchange Rate Amount",CurrencyExchangeRate."Relational Exch. Rate Amount");
      LibraryERM.FindExchRate(CurrencyExchangeRate,GenJournalLine."Currency Code",GetSecondDocDate(GenJournalLine."Posting Date"));
      CreateRandomExchangeRate(GenJournalLine."Currency Code",GetThirdDocDate(GenJournalLine."Posting Date"),
        CurrencyExchangeRate."Exchange Rate Amount",CurrencyExchangeRate."Relational Exch. Rate Amount");

Example

The below example is extracted from the test automation codeunit 144044 to show one way of using this function.

      LastTransactionNo := Initialize;

      PostAdvDocGenJnlPoT(GenJournalLine,GenJournalLine."Document Type"::Payment);
      ServiceTaxFCYHelper.SetupExchangeRates(GenJournalLine);

      PostPartialDoc(
        GenJournalLine,GenJournalLine."Document Type"::Invoice,
        ServiceTaxFCYHelper.GetSecondDocDate(GenJournalLine."Posting Date"),1,ApplyGenJournalLine);

      ReverseServiceTaxHelper.ApplyAndPostVendorEntry(
        VendLedgEntry."Document Type"::Payment,GenJournalLine."Document No.",
        VendLedgEntry."Document Type"::Invoice,ApplyGenJournalLine."Document No.");

      ServiceTaxFCYHelper.VerifyServiceTaxAdvPmtBalances(GenJournalLine,LastTransactionNo,TRUE);
Member of Miscellaneous.Service Tax FCY Helper


VerifyServiceTaxAdvPmtBal@1500002 Method

The procedure VerifyServiceTaxAdvPmtBal is available in codeunit 143002.

Syntax

VerifyServiceTaxAdvPmtBal@1500002(
    VAR GenJournalLine@1500008 : Record 81 GenJournalLine, //Reference parameter of type Record
    VAR ServiceTaxSetup@1500002 : Record 16472 ServiceTaxSetup, //Reference parameter of type Record
    VAR ServiceTaxAmount@1500001 : Decimal ServiceTaxAmount, //Reference parameter of type Decimal
    VAR SBCAmount@1500004 : Decimal SBCAmount, //Reference parameter of type Decimal
    VAR KKCAmount@1500005 : Decimal KKCAmount, //Reference parameter of type Decimal
    LastTransactionNo@1500000 : Integer LastTransactionNo, //Input parameter of type Integer
    Applied@1500003 : Boolean Applied //Input parameter of type Boolean
);

Parameters

GenJournalLine
Reference parameter of type Record
ServiceTaxSetup
Reference parameter of type Record
ServiceTaxAmount
Reference parameter of type Decimal
SBCAmount
Reference parameter of type Decimal
KKCAmount
Reference parameter of type Decimal
LastTransactionNo
Input parameter of type Integer
Applied
Input parameter of type Boolean

Remarks

The relevant search keywords are: Verify, Service, Tax, Adv, Payment, Bal.

For a clarification about how this function works, refer to the code listed below.

      GenJournalLine.Amount := ConvertFCYAmountToLCY(GenJournalLine);
      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      ServiceTaxAmount := ReverseServiceTaxHelper.CalculateServTaxTotal(
        ReverseServiceTaxHelper.GetBaseAmountFromGenJnlLine(GenJournalLine),ServiceTaxSetup);
      SBCAmount :=
        ReverseServiceTaxHelper.CalculateSBC(ReverseServiceTaxHelper.GetBaseAmountFromGenJnlLine(GenJournalLine),ServiceTaxSetup);
      KKCAmount :=
        ReverseServiceTaxHelper.CalculateKKCess(ReverseServiceTaxHelper.GetBaseAmountFromGenJnlLine(GenJournalLine),ServiceTaxSetup);

      ServiceTaxVerify.STEntryDetailsRemainingCredit(LastTransactionNo,ServiceTaxAmount);
      ServiceTaxVerify.STEntryDetailsKKCRemainingCredit(LastTransactionNo,KKCAmount);

      ServiceTaxVerify.PostedInvoiceRounding(GenJournalLine."Posting Group",LastTransactionNo);

      IF Applied THEN BEGIN
        ServiceTaxVerify.STRecInterimAccBalance(ServiceTaxSetup,0);
        ServiceTaxVerify.SBCRecInterimAccBalance(ServiceTaxSetup,0);
        ServiceTaxVerify.KKCRecInterimAccBalance(ServiceTaxSetup,0);
      END ELSE BEGIN
        ServiceTaxVerify.STRecInterimAccBalance(ServiceTaxSetup,-ServiceTaxAmount);
        ServiceTaxVerify.SBCRecInterimAccBalance(ServiceTaxSetup,-SBCAmount);
        ServiceTaxVerify.KKCRecInterimAccBalance(ServiceTaxSetup,-KKCAmount);
      END;

Example

There are no examples available.
Member of Miscellaneous.Service Tax FCY Helper


VerifyServiceTaxAdvPmtBalances@1500025 Method

The procedure VerifyServiceTaxAdvPmtBalances is available in codeunit 143002.

Syntax

VerifyServiceTaxAdvPmtBalances@1500025(
    GenJournalLine@1500008 : Record 81 GenJournalLine, //Input parameter of type Record
    LastTransactionNo@1500000 : Integer LastTransactionNo, //Input parameter of type Integer
    Applied@1500001 : Boolean Applied //Input parameter of type Boolean
);

Parameters

GenJournalLine
Input parameter of type Record
LastTransactionNo
Input parameter of type Integer
Applied
Input parameter of type Boolean

Remarks

The relevant search keywords are: Verify, Service, Tax, Adv, Payment, Balances.

For a clarification about how this function works, refer to the code listed below.

      VerifyServiceTaxAdvPmtBal(GenJournalLine,ServiceTaxSetup,ServiceTaxAmount,SBCAmount,KKCAmount,LastTransactionNo,Applied);
      ServiceTaxVerify.STEntryDtlsFullTaxBalance(LastTransactionNo,ServiceTaxAmount);
      ServiceTaxVerify.STRecAccBalance(ServiceTaxSetup,ServiceTaxAmount);
      ServiceTaxVerify.STEntryDtlsSBCBalance(LastTransactionNo,SBCAmount);
      ServiceTaxVerify.SBCRecAccBalance(ServiceTaxSetup,SBCAmount);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      // Setup
      LastTransactionNo := Initialize;
      LibraryServiceTax.SetServiceTaxRounding;
      // Exercise
      PostAdvancePaymentPoTFCY(GenJournalLine,IncludeServTax);

      // Restore
      ServiceTaxFCYHelper.SetNonResidentPmtOnTDSGroup(GenJournalLine,FALSE);

      // Verify
      ServiceTaxFCYHelper.VerifyServiceTaxAdvPmtBalances(GenJournalLine,LastTransactionNo,FALSE);
      GenJournalLine.Amount := ServiceTaxFCYHelper.ConvertFCYAmountToLCY(GenJournalLine);
      ServiceTaxTDSHelper.VerifyTDSPostingAdvPmt(GenJournalLine,IncludeServTax);
      LibraryServiceTax.SetServiceTaxRoundingOne;
Member of Miscellaneous.Service Tax FCY Helper


VerifyServiceTaxInvBalances@1500015 Method

The procedure VerifyServiceTaxInvBalances is available in codeunit 143002.

Syntax

VerifyServiceTaxInvBalances@1500015(
    GenJournalLine@1500008 : Record 81 GenJournalLine, //Input parameter of type Record
    LastTransactionNo@1500000 : Integer LastTransactionNo //Input parameter of type Integer
);

Parameters

GenJournalLine
Input parameter of type Record
LastTransactionNo
Input parameter of type Integer

Remarks

The relevant search keywords are: Verify, Service, Tax, Invoice, Balances.

For a clarification about how this function works, refer to the code listed below.

      GenJournalLine.Amount := ConvertFCYAmountToLCY(GenJournalLine);
      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      ServiceTaxAmount := ReverseServiceTaxHelper.CalculateServTaxTotal(GenJournalLine.Amount,ServiceTaxSetup);
      SBCAmount := ReverseServiceTaxHelper.CalculateSBC(GenJournalLine.Amount,ServiceTaxSetup);
      KKCAmount := ReverseServiceTaxHelper.CalculateKKCess(GenJournalLine.Amount,ServiceTaxSetup);

      ServiceTaxVerify.STRecAccBalance(ServiceTaxSetup,-ServiceTaxAmount);
      ServiceTaxVerify.STRecInterimAccBalance(ServiceTaxSetup,0);
      ServiceTaxVerify.SBCRecAccBalance(ServiceTaxSetup,-SBCAmount);
      ServiceTaxVerify.SBCRecInterimAccBalance(ServiceTaxSetup,0);
      ServiceTaxVerify.KKCRecAccBalance(ServiceTaxSetup,-KKCAmount);
      ServiceTaxVerify.KKCRecInterimAccBalance(ServiceTaxSetup,0);

      ServiceTaxVerify.STEntryDtlsFullTaxBalance(LastTransactionNo,-ServiceTaxAmount);
      ServiceTaxVerify.STEntryDtlsSBCBalance(LastTransactionNo,-SBCAmount);
      ServiceTaxVerify.STEntryDtlsKKCBalance(LastTransactionNo,-KKCAmount);

      ServiceTaxVerify.STEntryDetailsRemainingCredit(LastTransactionNo,-ServiceTaxAmount);
      ServiceTaxVerify.STEntryDetailsKKCRemainingCredit(LastTransactionNo,-KKCAmount);

      ServiceTaxVerify.PostedInvoiceRounding(GenJournalLine."Posting Group",LastTransactionNo);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      // Setup
      LastTransactionNo := Initialize;
      ServiceTaxTDSHelper.CreatePurchaseDocGenJnlPoT(InvoiceGenJournalLine,TRUE);
      ServiceTaxFCYHelper.SetFCYNonResPmtOnJnlLine(InvoiceGenJournalLine);
      LibraryTDS.SetInclServTaxOptionInGenJnl(InvoiceGenJournalLine,IncludeServTax);
      PaymentDocNo := PostPaymentFCY(InvoiceGenJournalLine,IncludeServTax);
      InvoiceGenJournalLine.VALIDATE("Applies-to Doc. Type",InvoiceGenJournalLine."Applies-to Doc. Type"::Payment);
      InvoiceGenJournalLine.VALIDATE("Applies-to Doc. No.",PaymentDocNo);
      InvoiceGenJournalLine.MODIFY;

      // Exercise
      LibraryERM.PostGeneralJnlLine(InvoiceGenJournalLine);

      // Restore
      ServiceTaxFCYHelper.SetNonResidentPmtOnTDSGroup(InvoiceGenJournalLine,FALSE);

      // Verify
      ServiceTaxFCYHelper.VerifyServiceTaxInvBalances(InvoiceGenJournalLine,LastTransactionNo);
      InvoiceGenJournalLine.Amount := ServiceTaxFCYHelper.ConvertFCYAmountToLCY(InvoiceGenJournalLine);
      ServiceTaxTDSHelper.VerifyTDSPostingInvoice(InvoiceGenJournalLine,IncludeServTax);
Member of Miscellaneous.Service Tax FCY Helper


VerifyServTaxAdvPmtBalRounding@1500001 Method

The procedure VerifyServTaxAdvPmtBalRounding is available in codeunit 143002.

Syntax

VerifyServTaxAdvPmtBalRounding@1500001(
    GenJournalLine@1500008 : Record 81 GenJournalLine, //Input parameter of type Record
    LastTransactionNo@1500000 : Integer LastTransactionNo, //Input parameter of type Integer
    Applied@1500001 : Boolean Applied //Input parameter of type Boolean
);

Parameters

GenJournalLine
Input parameter of type Record
LastTransactionNo
Input parameter of type Integer
Applied
Input parameter of type Boolean

Remarks

The relevant search keywords are: Verify, Serv, Tax, Adv, Payment, Bal, Rounding.

For a clarification about how this function works, refer to the code listed below.

      VerifyServiceTaxAdvPmtBal(GenJournalLine,ServiceTaxSetup,ServiceTaxAmount,SBCAmount,KKCAmount,LastTransactionNo,Applied);
      ServiceTaxVerify.STEntryDtlsFullTaxBalNearly(LastTransactionNo,ServiceTaxAmount);
      ServiceTaxVerify.STRecAccBalanceNearly(ServiceTaxSetup,ServiceTaxAmount);
      ServiceTaxVerify.STEntryDtlsSBCBalNearly(LastTransactionNo,SBCAmount);
      ServiceTaxVerify.SBCRecAccBalanceNearly(ServiceTaxSetup,SBCAmount);
      ServiceTaxVerify.STEntryDtlsKKCBalNearly(LastTransactionNo,KKCAmount);
      ServiceTaxVerify.KKCRecAccBalanceNearly(ServiceTaxSetup,KKCAmount);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      // Setup
      LastTransactionNo := Initialize;

      // Advance Payment
      PostAdvancePaymentPoTFCY(GenJournalLine,IncludeServTax);

      // Invoice
      ServiceTaxTDSHelper.CreateInvoiceFromGenJournal(GenJournalLine);
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // Restore
      ServiceTaxFCYHelper.SetNonResidentPmtOnTDSGroup(GenJournalLine,FALSE);

      // Verify
      ServiceTaxFCYHelper.VerifyServTaxAdvPmtBalRounding(GenJournalLine,LastTransactionNo,TRUE);
      GenJournalLine.Amount := ServiceTaxFCYHelper.ConvertFCYAmountToLCY(GenJournalLine);
      ServiceTaxTDSHelper.VerifyTDSPostingAppliedInvoice(GenJournalLine,IncludeServTax);
Member of Miscellaneous.Service Tax FCY Helper


Service Tax Report Helper Class

Miscellaneous.Service Tax Report Helper

COD143007 applies to ERM,IN.

Methods

Name | Description
AssertRowCount@1500111 | The procedure AssertRowCount is available in codeunit 143007.
FindCurrentRowValueDecimal@1500093 | The procedure FindCurrentRowValueDecimal is available in codeunit 143007.
GetFullTaxAmount@1500098 | The procedure GetFullTaxAmount is available in codeunit 143007.
InputServiceDetailsReportHandler@1500003 | The procedure InputServiceDetailsReportHandler is available in codeunit 143007.
LoadDataSetFile@1500408 | The procedure LoadDataSetFile is available in codeunit 143007.
RunReportInputServiceDetails@1500011 | The procedure RunReportInputServiceDetails is available in codeunit 143007.
RunReportServiceTaxCreditRegister@1500010 | The procedure RunReportServiceTaxCreditRegister is available in codeunit 143007.
RunReportServiceTaxRegister@1500008 | The procedure RunReportServiceTaxRegister is available in codeunit 143007.
ServTaxCreditRegisterReportHandler@1500174 | The procedure ServTaxCreditRegisterReportHandler is available in codeunit 143007.
ServTaxRegisterReportHandler@1500092 | The procedure ServTaxRegisterReportHandler is available in codeunit 143007.
VerifyInputServiceDetails@1500021 | The procedure VerifyInputServiceDetails is available in codeunit 143007.
VerifyReportIsEmpty@1500330 | The procedure VerifyReportIsEmpty is available in codeunit 143007.
VerifyServTaxCreditRegisterAdvPmtInvCreditAvailed@1501001 | The procedure VerifyServTaxCreditRegisterAdvPmtInvCreditAvailed is available in codeunit 143007.
VerifyServTaxCreditRegisterApplication@1500005 | The procedure VerifyServTaxCreditRegisterApplication is available in codeunit 143007.
VerifyServTaxCreditRegisterCreditAvailedRow@1500009 | The procedure VerifyServTaxCreditRegisterCreditAvailedRow is available in codeunit 143007.
VerifyServTaxCreditRegisterCreditMemoInvCreditAvailed@1500007 | The procedure VerifyServTaxCreditRegisterCreditMemoInvCreditAvailed is available in codeunit 143007.
VerifyServTaxCreditRegisterServTaxRegNo@1500012 | The procedure VerifyServTaxCreditRegisterServTaxRegNo is available in codeunit 143007.
VerifyServTaxCreditRegisterTakenAsSalesCredit@1500006 | The procedure VerifyServTaxCreditRegisterTakenAsSalesCredit is available in codeunit 143007.
VerifyServTaxCreditRegisterUsedAsExcise@1500004 | The procedure VerifyServTaxCreditRegisterUsedAsExcise is available in codeunit 143007.
VerifyServTaxRegisterCrMAppliedToInvPoT@1500000 | The procedure VerifyServTaxRegisterCrMAppliedToInvPoT is available in codeunit 143007.
VerifyServTaxRegisterCrMAppliedToInvRevChrg@1500001 | The procedure VerifyServTaxRegisterCrMAppliedToInvRevChrg is available in codeunit 143007.
VerifyServTaxRegisterInvAppliedToAdvPmtPoT@1500002 | The procedure VerifyServTaxRegisterInvAppliedToAdvPmtPoT is available in codeunit 143007.

See Also

Miscellaneous


AssertRowCount@1500111 Method

The procedure AssertRowCount is available in codeunit 143007.

Syntax

AssertRowCount@1500111(
    ExpectedRowCount@1500000 : Integer ExpectedRowCount //Input parameter of type Integer
);

Parameters

ExpectedRowCount
Input parameter of type Integer

Remarks

The relevant search keywords are: Assert, Row, Count.

For a clarification about how this function works, refer to the code listed below.

      Assert.AreEqual(ExpectedRowCount,LibraryReportDataset.RowCount,WrongRowCountErr);

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      InitializeReportTest;
      ApplyPostAdvPaymentToDoc(ReverseChargeType::" ",TRUE,PurchaseDocumentType::Invoice,AdvPmtGenJnlLine,InvoiceGenJnlLine);
      ServiceTaxReportHelper.RunReportServiceTaxCreditRegister(InvoiceGenJnlLine,FALSE);
      ServiceTaxReportHelper.LoadDataSetFile;
      ServiceTaxReportHelper.AssertRowCount(1);
      ServiceTaxReportHelper.VerifyServTaxCreditRegisterApplication(InvoiceGenJnlLine."Service Tax Amount");
Member of Miscellaneous.Service Tax Report Helper


FindCurrentRowValueDecimal@1500093 Method

The procedure FindCurrentRowValueDecimal is available in codeunit 143007.

Syntax

FindCurrentRowValueDecimal@1500093(
    ElementName@1500000 : Text ElementName //Input parameter of type Text
);

Parameters

ElementName
Input parameter of type Text

Return Value

Decimal

Remarks

The relevant search keywords are: Find, Current, Row, Value, Decimal.

For a clarification about how this function works, refer to the code listed below.

      LibraryReportDataset.FindCurrentRowValue(ElementName,Variant);
      CurrentDecimalValue := Variant;

Example

There are no examples available.
Member of Miscellaneous.Service Tax Report Helper


GetFullTaxAmount@1500098 Method

The procedure GetFullTaxAmount is available in codeunit 143007.

Syntax

GetFullTaxAmount@1500098(
    AmountName@1500000 : Text AmountName, //Input parameter of type Text
    ECessName@1500001 : Text ECessName, //Input parameter of type Text
    SHECessName@1500002 : Text SHECessName //Input parameter of type Text
);

Parameters

AmountName
Input parameter of type Text
ECessName
Input parameter of type Text
SHECessName
Input parameter of type Text

Return Value

Decimal

Remarks

The relevant search keywords are: Get, Full, Tax, Amount.

For a clarification about how this function works, refer to the code listed below.

      Amount := FindCurrentRowValueDecimal(AmountName);
      ECess := FindCurrentRowValueDecimal(ECessName);
      SHECess := FindCurrentRowValueDecimal(SHECessName);
      EXIT(Amount + ECess + SHECess);

Example

There are no examples available.
Member of Miscellaneous.Service Tax Report Helper


InputServiceDetailsReportHandler@1500003 Method

The procedure InputServiceDetailsReportHandler is available in codeunit 143007.

Syntax

InputServiceDetailsReportHandler@1500003(
    VAR InputServiceDetails@1500000 : TestRequestPage 16474 InputServiceDetails //Reference parameter of type TestRequestPage
);

Parameters

InputServiceDetails
Reference parameter of type TestRequestPage

Remarks

The relevant search keywords are: Input, Service, Details, Report, Handler.

For a clarification about how this function works, refer to the code listed below.

      WITH ParamsGenJnlLine DO BEGIN
        InputServiceDetails.FromMonth.SETVALUE(0);
        InputServiceDetails.FromYear.SETVALUE(DATE2DMY("Posting Date",3));
        InputServiceDetails.ToMonth.SETVALUE(11);
        InputServiceDetails.ToYear.SETVALUE(DATE2DMY("Posting Date",3));
        InputServiceDetails.STGroup.SETVALUE("Service Tax Group Code");
        InputServiceDetails.STRegNo.SETVALUE("Service Tax Registration No.");
      END;
      InputServiceDetails.SAVEASXML(LibraryReportDataset.GetParametersFileName,LibraryReportDataset.GetFileName);

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      ServiceTaxReportHelper.InputServiceDetailsReportHandler(InputServiceDetails);
Member of Miscellaneous.Service Tax Report Helper


LoadDataSetFile@1500408 Method

The procedure LoadDataSetFile is available in codeunit 143007.

Syntax

LoadDataSetFile@1500408(
      //param element not supplied
);

Remarks

The relevant search keywords are: Load, Data, Set, File.

For a clarification about how this function works, refer to the code listed below.

      LibraryReportDataset.LoadDataSetFile;

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      InitializeReportTest;
      ApplyPostAdvPaymentToDoc(ReverseChargeType::" ",TRUE,PurchaseDocumentType::Invoice,AdvPmtGenJnlLine,InvoiceGenJnlLine);
      ServiceTaxReportHelper.RunReportServiceTaxCreditRegister(InvoiceGenJnlLine,FALSE);
      ServiceTaxReportHelper.LoadDataSetFile;
      ServiceTaxReportHelper.AssertRowCount(1);
      ServiceTaxReportHelper.VerifyServTaxCreditRegisterApplication(InvoiceGenJnlLine."Service Tax Amount");
Member of Miscellaneous.Service Tax Report Helper


RunReportInputServiceDetails@1500011 Method

The procedure RunReportInputServiceDetails is available in codeunit 143007.

Syntax

RunReportInputServiceDetails@1500011(
    GenJournalLine@1500000 : Record 81 GenJournalLine //Input parameter of type Record
);

Parameters

GenJournalLine
Input parameter of type Record

Remarks

The relevant search keywords are: Run, Report, Input, Service, Details.

For a clarification about how this function works, refer to the code listed below.

      ParamsGenJnlLine := GenJournalLine;
      REPORT.RUN(REPORT::"Input Service Details");

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      InitializeReportTest;
      PmtGenJournalLine.PoT := FALSE;
      LibraryServiceTax.SetServiceTaxRounding;
      PostedDocNo :=
        ApplyBiggerDocToAdvPmt(
          PmtGenJournalLine,PurchaseHeader."Document Type"::Invoice,ReverseChargeType::Standard,
          GLAccountNo,InvoiceBaseAmount,InvoiceTaxAmount,PaymentBaseAmount,PaymentTaxAmount);

      RemainingAmt := PaymentBaseAmount * 2;
      PmtDocNo :=
        ReverseServiceTaxHelper.PostPayment(
          PmtGenJournalLine."Account No.",RemainingAmt,PmtGenJournalLine."Posting Date",PmtGenJournalLine."Document Type"::Payment);
      ReverseServiceTaxHelper.ApplyAndPostVendorEntry(
        PurchaseHeader."Document Type"::Invoice,PostedDocNo,PmtGenJournalLine."Document Type"::Payment,PmtDocNo);
      ReverseServiceTaxHelper.PayServiceTax(
        PmtGenJournalLine."Service Tax Registration No.",PmtGenJournalLine."Service Tax Group Code",TRUE);

      COMMIT;
      ServiceTaxReportHelper.RunReportInputServiceDetails(PmtGenJournalLine);

      ServiceTaxSetup.FindOnDate(PmtGenJournalLine."Service Tax Group Code",PmtGenJournalLine."Posting Date");
      ServiceTaxReportHelper.VerifyInputServiceDetails(
        PaymentBaseAmount,RemainingAmt,PmtGenJournalLine."Document No.",PostedDocNo,ServiceTaxSetup);
Member of Miscellaneous.Service Tax Report Helper


RunReportServiceTaxCreditRegister@1500010 Method

The procedure RunReportServiceTaxCreditRegister is available in codeunit 143007.

Syntax

RunReportServiceTaxCreditRegister@1500010(
    GenJournalLine@1500000 : Record 81 GenJournalLine, //Input parameter of type Record
    NewPrintDetails@1500001 : Boolean NewPrintDetails //Input parameter of type Boolean
);

Parameters

GenJournalLine
Input parameter of type Record
NewPrintDetails
Input parameter of type Boolean

Remarks

The relevant search keywords are: Run, Report, Service, Tax, Credit, Register.

For a clarification about how this function works, refer to the code listed below.

      ParamsGenJnlLine := GenJournalLine;
      PrintDetails := NewPrintDetails;
      REPORT.RUN(REPORT::"Service Tax Credit Register");

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      Initialize;

      ReverseServiceTaxHelper.CreatePurchaseDoc(
        PurchaseHeader,PurchaseLine,PurchaseHeader."Document Type"::Invoice,ReverseChargeTypeOption::" ",0,TRUE);
      PostedPurchInvoiceDocNo := ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);

      PostedSalesInvoiceDocNo :=
        ReverseServiceTaxHelper.UseCreditToPayForSalesDoc(PostedPurchInvoiceDocNo,ServiceTaxEntryDetails);

      COMMIT;
      ReverseServiceTaxHelper.ConvertDocToJnlLine(PurchaseHeader,PurchaseLine,PostedPurchInvoiceDocNo,GenJournalLine);
      ServiceTaxReportHelper.RunReportServiceTaxCreditRegister(GenJournalLine,TRUE);

      ServiceTaxReportHelper.VerifyServTaxCreditRegisterTakenAsSalesCredit(PostedSalesInvoiceDocNo,ServiceTaxEntryDetails.FullTaxAmount);
Member of Miscellaneous.Service Tax Report Helper


RunReportServiceTaxRegister@1500008 Method

The procedure RunReportServiceTaxRegister is available in codeunit 143007.

Syntax

RunReportServiceTaxRegister@1500008(
    GenJournalLine@1500000 : Record 81 GenJournalLine //Input parameter of type Record
);

Parameters

GenJournalLine
Input parameter of type Record

Remarks

The relevant search keywords are: Run, Report, Service, Tax, Register.

For a clarification about how this function works, refer to the code listed below.

      ParamsGenJnlLine := GenJournalLine;
      REPORT.RUN(REPORT::"Service Tax Register");

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      Initialize;

      GenJournalLine.PoT := TRUE;
      PostedDocNo :=
        ApplyBiggerDocToAdvPmt(
          GenJournalLine,PurchaseHeader."Document Type"::Invoice,ReverseChargeType::" ",
          GLAccountNo,InvoiceBaseAmount,InvoiceTaxAmount,PaymentBaseAmount,PaymentTaxAmount);

      ServiceTaxReportHelper.RunReportServiceTaxRegister(GenJournalLine);

      ServiceTaxReportHelper.VerifyServTaxRegisterInvAppliedToAdvPmtPoT(
        GenJournalLine,PostedDocNo,InvoiceBaseAmount,InvoiceTaxAmount,PaymentBaseAmount,PaymentTaxAmount)
Member of Miscellaneous.Service Tax Report Helper


ServTaxCreditRegisterReportHandler@1500174 Method

The procedure ServTaxCreditRegisterReportHandler is available in codeunit 143007.

Syntax

ServTaxCreditRegisterReportHandler@1500174(
    VAR ServTaxCreditRegister@1500000 : TestRequestPage 16592 ServTaxCreditRegister //Reference parameter of type TestRequestPage
);

Parameters

ServTaxCreditRegister
Reference parameter of type TestRequestPage

Remarks

The relevant search keywords are: Serv, Tax, Credit, Register, Report, Handler.

For a clarification about how this function works, refer to the code listed below.

      WITH ParamsGenJnlLine DO BEGIN
        ServTaxCreditRegister.StartingDate.SETVALUE(CALCDATE('-CY',"Posting Date"));
        ServTaxCreditRegister.EndingDate.SETVALUE(CALCDATE('CY',"Posting Date"));
        ServTaxCreditRegister.STRegistrationNo.SETVALUE("Service Tax Registration No.");
      END;
      ServTaxCreditRegister.PrintDetails.SETVALUE(PrintDetails);
      ServTaxCreditRegister.SAVEASXML(LibraryReportDataset.GetParametersFileName,LibraryReportDataset.GetFileName);

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      ServiceTaxReportHelper.ServTaxCreditRegisterReportHandler(ServTaxCreditRegister);
Member of Miscellaneous.Service Tax Report Helper


ServTaxRegisterReportHandler@1500092 Method

The procedure ServTaxRegisterReportHandler is available in codeunit 143007.

Syntax

ServTaxRegisterReportHandler@1500092(
    VAR ServiceTaxRegister@1500000 : TestRequestPage 16473 ServiceTaxRegister //Reference parameter of type TestRequestPage
);

Parameters

ServiceTaxRegister
Reference parameter of type TestRequestPage

Remarks

The relevant search keywords are: Serv, Tax, Register, Report, Handler.

For a clarification about how this function works, refer to the code listed below.

      WITH ParamsGenJnlLine DO BEGIN
        ServiceTaxRegister.FromMonth.SETVALUE(0);
        ServiceTaxRegister.FromYear.SETVALUE(DATE2DMY("Posting Date",3));
        ServiceTaxRegister.ToMonth.SETVALUE(11);
        ServiceTaxRegister.ToYear.SETVALUE(DATE2DMY("Posting Date",3));
        ServiceTaxRegister.PurchaseSale.SETVALUE("Service Tax Type");
        ServiceTaxRegister.STGroup.SETVALUE("Service Tax Group Code");
        ServiceTaxRegister.STRegNo.SETVALUE("Service Tax Registration No.");
      END;
      ServiceTaxRegister.SAVEASXML(LibraryReportDataset.GetParametersFileName,LibraryReportDataset.GetFileName);

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      ServiceTaxReportHelper.ServTaxRegisterReportHandler(ServiceTaxRegister);
Member of Miscellaneous.Service Tax Report Helper


VerifyInputServiceDetails@1500021 Method

The procedure VerifyInputServiceDetails is available in codeunit 143007.

Syntax

VerifyInputServiceDetails@1500021(
    BaseAmount1@1500000 : Decimal BaseAmount1, //Input parameter of type Decimal
    BaseAmount2@1500001 : Decimal BaseAmount2, //Input parameter of type Decimal
    DocNo1@1500002 : Code[20] DocNo1, //Input parameter of type Code
    DocNo2@1500003 : Code[20] DocNo2, //Input parameter of type Code
    ServiceTaxSetup@1500004 : Record 16472 ServiceTaxSetup //Input parameter of type Record
);

Parameters

BaseAmount1
Input parameter of type Decimal
BaseAmount2
Input parameter of type Decimal
DocNo1
Input parameter of type Code
DocNo2
Input parameter of type Code
ServiceTaxSetup
Input parameter of type Record

Remarks

The relevant search keywords are: Verify, Input, Service, Details.

For a clarification about how this function works, refer to the code listed below.

      LibraryReportDataset.LoadDataSetFile;

      ServiceTax[1] := ReverseServiceTaxHelper.CalculateServTax(BaseAmount1,ServiceTaxSetup);
      ECess[1] := ReverseServiceTaxHelper.CalculateECess(BaseAmount1,ServiceTaxSetup);
      SHECess[1] := ReverseServiceTaxHelper.CalculateSHECess(BaseAmount1,ServiceTaxSetup);

      ServiceTax[2] := ReverseServiceTaxHelper.CalculateServTax(BaseAmount2,ServiceTaxSetup);
      ECess[2] := ReverseServiceTaxHelper.CalculateECess(BaseAmount2,ServiceTaxSetup);
      SHECess[2] := ReverseServiceTaxHelper.CalculateSHECess(BaseAmount2,ServiceTaxSetup);

      LibraryReportDataset.GetLastRow;
      LibraryReportDataset.AssertCurrentRowValue(
        'CreditTaken',ServiceTax[1] + ECess[1] + SHECess[1] + ServiceTax[2] + ECess[2] + SHECess[2]);
      LibraryReportDataset.AssertCurrentRowValue('CreditUtilized',0);
      LibraryReportDataset.AssertCurrentRowValue('OpeningBalance',0);
      LibraryReportDataset.AssertCurrentRowValue(
        'ClosingBalance',ServiceTax[1] + ECess[1] + SHECess[1] + ServiceTax[2] + ECess[2] + SHECess[2]);

      LibraryReportDataset.SetRange('STEntry__Document_No__',DocNo1);
      LibraryReportDataset.GetNextRow;
      LibraryReportDataset.AssertCurrentRowValue(
        'Service_Tax_Entry_Details__Service_Tax_Entry_Details___Service_Tax_Amount_',ServiceTax[1]);
      LibraryReportDataset.AssertCurrentRowValue(
        'Service_Tax_Entry_Details__Service_Tax_Entry_Details___Service_Tax_eCess_Amount_',ECess[1]);
      LibraryReportDataset.AssertCurrentRowValue(
        'Service_Tax_Entry_Details__Service_Tax_Entry_Details___Service_Tax_SHE_Cess_Amount_',SHECess[1]);
      LibraryReportDataset.SetRange('STEntry__Document_No__',DocNo2);
      LibraryReportDataset.GetNextRow;
      LibraryReportDataset.AssertCurrentRowValue(
        'Service_Tax_Entry_Details__Service_Tax_Entry_Details___Service_Tax_Amount_',ServiceTax[2]);
      LibraryReportDataset.AssertCurrentRowValue(
        'Service_Tax_Entry_Details__Service_Tax_Entry_Details___Service_Tax_eCess_Amount_',ECess[2]);
      LibraryReportDataset.AssertCurrentRowValue(
        'Service_Tax_Entry_Details__Service_Tax_Entry_Details___Service_Tax_SHE_Cess_Amount_',SHECess[2]);

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      InitializeReportTest;
      PmtGenJournalLine.PoT := FALSE;
      LibraryServiceTax.SetServiceTaxRounding;
      PostedDocNo :=
        ApplyBiggerDocToAdvPmt(
          PmtGenJournalLine,PurchaseHeader."Document Type"::Invoice,ReverseChargeType::Standard,
          GLAccountNo,InvoiceBaseAmount,InvoiceTaxAmount,PaymentBaseAmount,PaymentTaxAmount);

      RemainingAmt := PaymentBaseAmount * 2;
      PmtDocNo :=
        ReverseServiceTaxHelper.PostPayment(
          PmtGenJournalLine."Account No.",RemainingAmt,PmtGenJournalLine."Posting Date",PmtGenJournalLine."Document Type"::Payment);
      ReverseServiceTaxHelper.ApplyAndPostVendorEntry(
        PurchaseHeader."Document Type"::Invoice,PostedDocNo,PmtGenJournalLine."Document Type"::Payment,PmtDocNo);
      ReverseServiceTaxHelper.PayServiceTax(
        PmtGenJournalLine."Service Tax Registration No.",PmtGenJournalLine."Service Tax Group Code",TRUE);

      COMMIT;
      ServiceTaxReportHelper.RunReportInputServiceDetails(PmtGenJournalLine);

      ServiceTaxSetup.FindOnDate(PmtGenJournalLine."Service Tax Group Code",PmtGenJournalLine."Posting Date");
      ServiceTaxReportHelper.VerifyInputServiceDetails(
        PaymentBaseAmount,RemainingAmt,PmtGenJournalLine."Document No.",PostedDocNo,ServiceTaxSetup);
Member of Miscellaneous.Service Tax Report Helper


VerifyReportIsEmpty@1500330 Method

The procedure VerifyReportIsEmpty is available in codeunit 143007.

Syntax

VerifyReportIsEmpty@1500330(
      //param element not supplied
);

Remarks

The relevant search keywords are: Verify, Report, Is, Empty.

For a clarification about how this function works, refer to the code listed below.

      LibraryReportDataset.LoadDataSetFile;
      Assert.AreEqual(0,LibraryReportDataset.RowCount,WrongRowCountErr);

Example

The below example is extracted from the test automation codeunit 144033 to show one way of using this function.

      Initialize;

      ApplyDocOnCrMemoCoverAmount(
        PurchaseHeader."Document Type"::Invoice,PurchaseHeader."Service Type (Rev. Chrg.)"::Inward,ServiceTaxType::Standard,FALSE,InvoiceAmountIs::Greater,
        InvGenJournalLine,CrMemoGenJournalLine);

      ServiceTaxReportHelper.RunReportInputServiceDetails(InvGenJournalLine);

      ServiceTaxReportHelper.VerifyReportIsEmpty;
Member of Miscellaneous.Service Tax Report Helper


VerifyServTaxCreditRegisterAdvPmtInvCreditAvailed@1501001 Method

The procedure VerifyServTaxCreditRegisterAdvPmtInvCreditAvailed is available in codeunit 143007.

Syntax

VerifyServTaxCreditRegisterAdvPmtInvCreditAvailed@1501001(
    InvoiceBaseAmount@1500002 : Decimal InvoiceBaseAmount, //Input parameter of type Decimal
    InvoiceTaxAmount@1500001 : Decimal InvoiceTaxAmount, //Input parameter of type Decimal
    PaymentBaseAmount@1500003 : Decimal PaymentBaseAmount, //Input parameter of type Decimal
    PaymentTaxAmount@1500000 : Decimal PaymentTaxAmount //Input parameter of type Decimal
);

Parameters

InvoiceBaseAmount
Input parameter of type Decimal
InvoiceTaxAmount
Input parameter of type Decimal
PaymentBaseAmount
Input parameter of type Decimal
PaymentTaxAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Verify, Serv, Tax, Credit, Register, Adv, Payment, Invoice, Credit, Availed.

For a clarification about how this function works, refer to the code listed below.

      VerifyServTaxCreditRegisterCreditAvailedRow(PaymentBaseAmount,PaymentTaxAmount);
      VerifyServTaxCreditRegisterCreditAvailedRow(InvoiceBaseAmount,InvoiceTaxAmount);
      VerifyServTaxCreditRegisterCreditAvailedRow(-PaymentBaseAmount,-PaymentTaxAmount);

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      InitializeReportTest;
      PaymentJournalLine.PoT := TRUE;
      ApplyBiggerDocToAdvPmt(
        PaymentJournalLine,PurchaseHeader."Document Type"::Invoice,ReverseChargeType::" ",
        GLAccountNo,InvoiceBaseAmount,InvoiceTaxAmount,PaymentBaseAmount,PaymentTaxAmount);

      ServiceTaxReportHelper.RunReportServiceTaxCreditRegister(PaymentJournalLine,TRUE);

      // Verify
      ServiceTaxReportHelper.LoadDataSetFile;
      ServiceTaxReportHelper.AssertRowCount(4);
      ServiceTaxReportHelper.VerifyServTaxCreditRegisterApplication(InvoiceTaxAmount);
      ServiceTaxSetup.FindOnDate(PaymentJournalLine."Service Tax Group Code",PaymentJournalLine."Posting Date");
      SBCAmount := ReverseServiceTaxHelper.CalculateSBC(InvoiceBaseAmount,ServiceTaxSetup);
      KKCAmount := ReverseServiceTaxHelper.CalculateKKCess(InvoiceBaseAmount,ServiceTaxSetup);
      SBCPayAmount := ReverseServiceTaxHelper.CalculateSBC(PaymentBaseAmount,ServiceTaxSetup);
      KKCPayAmount := ReverseServiceTaxHelper.CalculateKKCess(PaymentBaseAmount,ServiceTaxSetup);

      ServiceTaxReportHelper.VerifyServTaxCreditRegisterAdvPmtInvCreditAvailed(
        InvoiceBaseAmount + SBCAmount + KKCAmount,InvoiceTaxAmount,
        PaymentBaseAmount + SBCPayAmount + KKCPayAmount,PaymentTaxAmount);
Member of Miscellaneous.Service Tax Report Helper


VerifyServTaxCreditRegisterApplication@1500005 Method

The procedure VerifyServTaxCreditRegisterApplication is available in codeunit 143007.

Syntax

VerifyServTaxCreditRegisterApplication@1500005(
    ServiceTaxAmount@1500000 : Decimal ServiceTaxAmount //Input parameter of type Decimal
);

Parameters

ServiceTaxAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Verify, Serv, Tax, Credit, Register, Application.

For a clarification about how this function works, refer to the code listed below.

      LibraryReportDataset.GetNextRow;
      Assert.AreEqual(ServiceTaxAmount,GetFullTaxAmount('CreditAvailed','CreditAvailedECess','CreditAvailedSHECess'),CreditAvailedErr);
      Assert.AreEqual(0,GetFullTaxAmount('OpeningBalance','OpeningBalanceEcess','OpeningBalanceSheCess'),OpeningBalanceNotZeroErr);
      Assert.AreEqual(0,GetFullTaxAmount('CreditUsed','CreditUsedECess','CreditUsedSHECess'),CreditUsedNotZeroErr);
      Assert.AreEqual(
        ServiceTaxAmount,GetFullTaxAmount('ClosingBalance','ClosingBalanceECess','ClosingBalanceSHECess'),ClosingBalanceErr);

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      InitializeReportTest;
      ApplyPostAdvPaymentToDoc(ReverseChargeType::" ",TRUE,PurchaseDocumentType::Invoice,AdvPmtGenJnlLine,InvoiceGenJnlLine);
      ServiceTaxReportHelper.RunReportServiceTaxCreditRegister(InvoiceGenJnlLine,FALSE);
      ServiceTaxReportHelper.LoadDataSetFile;
      ServiceTaxReportHelper.AssertRowCount(1);
      ServiceTaxReportHelper.VerifyServTaxCreditRegisterApplication(InvoiceGenJnlLine."Service Tax Amount");
Member of Miscellaneous.Service Tax Report Helper


VerifyServTaxCreditRegisterCreditAvailedRow@1500009 Method

The procedure VerifyServTaxCreditRegisterCreditAvailedRow is available in codeunit 143007.

Syntax

VerifyServTaxCreditRegisterCreditAvailedRow@1500009(
    BaseAmount@1500002 : Decimal BaseAmount, //Input parameter of type Decimal
    TaxAmount@1500001 : Decimal TaxAmount //Input parameter of type Decimal
);

Parameters

BaseAmount
Input parameter of type Decimal
TaxAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Verify, Serv, Tax, Credit, Register, Credit, Availed, Row.

For a clarification about how this function works, refer to the code listed below.

      LibraryReportDataset.GetNextRow;

      LibraryReportDataset.AssertCurrentRowValue('STEntryDetails_Amount',BaseAmount + TaxAmount);
      Assert.AreEqual(
        TaxAmount,
        GetFullTaxAmount(
          'STEntryDetails__Service_Tax_Amount_',
          'STEntryDetails__Service_Tax_eCess_Amount_',
          'STEntryDetails__Service_Tax_SHE_Cess_Amount_'),
        ServTaxCreditTakenReceivedErr);

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      InitializeReportTest;
      PostApplyAdvPmtInvPmt(AdvPmtGenJnlLine,PaymentBaseAmount,PaymentTaxAmount,InvoiceBaseAmount,InvoiceTaxAmount);

      ServiceTaxReportHelper.RunReportServiceTaxCreditRegister(AdvPmtGenJnlLine,TRUE);

      ServiceTaxReportHelper.LoadDataSetFile;
      ServiceTaxReportHelper.AssertRowCount(3);
      ServiceTaxReportHelper.VerifyServTaxCreditRegisterApplication(InvoiceTaxAmount);
      PaymentBaseAmount -= PaymentTaxAmount;
      ServiceTaxReportHelper.VerifyServTaxCreditRegisterCreditAvailedRow(PaymentBaseAmount,PaymentTaxAmount);
      InvoiceBaseAmount -= InvoiceTaxAmount;
      ServiceTaxReportHelper.VerifyServTaxCreditRegisterCreditAvailedRow(
        InvoiceBaseAmount - PaymentBaseAmount,InvoiceTaxAmount - PaymentTaxAmount);
Member of Miscellaneous.Service Tax Report Helper


VerifyServTaxCreditRegisterCreditMemoInvCreditAvailed@1500007 Method

The procedure VerifyServTaxCreditRegisterCreditMemoInvCreditAvailed is available in codeunit 143007.

Syntax

VerifyServTaxCreditRegisterCreditMemoInvCreditAvailed@1500007(
    InvoiceBaseAmount@1500002 : Decimal InvoiceBaseAmount, //Input parameter of type Decimal
    InvoiceTaxAmount@1500001 : Decimal InvoiceTaxAmount, //Input parameter of type Decimal
    CreditMemoBaseAmount@1500003 : Decimal CreditMemoBaseAmount, //Input parameter of type Decimal
    CreditMemoTaxAmount@1500000 : Decimal CreditMemoTaxAmount //Input parameter of type Decimal
);

Parameters

InvoiceBaseAmount
Input parameter of type Decimal
InvoiceTaxAmount
Input parameter of type Decimal
CreditMemoBaseAmount
Input parameter of type Decimal
CreditMemoTaxAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Verify, Serv, Tax, Credit, Register, Credit, Memo, Invoice, Credit, Availed.

For a clarification about how this function works, refer to the code listed below.

      VerifyServTaxCreditRegisterCreditAvailedRow(CreditMemoBaseAmount,CreditMemoTaxAmount);
      VerifyServTaxCreditRegisterCreditAvailedRow(InvoiceBaseAmount,InvoiceTaxAmount);

Example

The below example is extracted from the test automation codeunit 144033 to show one way of using this function.

      Initialize;

      ApplyDocOnCrMemoCoverAmount(
        InvGenJournalLine."Document Type"::Invoice,
        InvGenJournalLine."Service Type (Rev. Chrg.)"::" ",
        ServiceTaxType::" ",TRUE,InvoiceAmountIs::Greater,
        InvGenJournalLine,CrMemoGenJournalLine);

      ServiceTaxReportHelper.RunReportServiceTaxCreditRegister(InvGenJournalLine,TRUE);

      ServiceTaxSetup.FindOnDate(InvGenJournalLine."Service Tax Group Code",InvGenJournalLine."Posting Date");
      InvoiceTaxAmount := ReverseServiceTaxHelper.CalculateServTaxTotal(InvGenJournalLine.Amount,ServiceTaxSetup);
      CrMemoTaxAmount := ReverseServiceTaxHelper.CalculateServTaxTotal(-CrMemoGenJournalLine.Amount,ServiceTaxSetup);
      SBCAmount := ReverseServiceTaxHelper.CalculateSBC(InvGenJournalLine.Amount,ServiceTaxSetup);
      KKCAmount := ReverseServiceTaxHelper.CalculateKKCess(InvGenJournalLine.Amount,ServiceTaxSetup);
      CrKKCAmount := ReverseServiceTaxHelper.CalculateKKCess(-CrMemoGenJournalLine.Amount,ServiceTaxSetup);
      CrSBCAmount := ReverseServiceTaxHelper.CalculateSBC(-CrMemoGenJournalLine.Amount,ServiceTaxSetup);

      ServiceTaxReportHelper.LoadDataSetFile;
      ServiceTaxReportHelper.AssertRowCount(3);
      ServiceTaxReportHelper.VerifyServTaxCreditRegisterApplication(InvoiceTaxAmount + CrMemoTaxAmount);
      ServiceTaxReportHelper.VerifyServTaxCreditRegisterCreditMemoInvCreditAvailed(
        InvGenJournalLine.Amount + KKCAmount + SBCAmount,
        InvoiceTaxAmount,-CrMemoGenJournalLine.Amount + CrKKCAmount + CrSBCAmount,CrMemoTaxAmount);
Member of Miscellaneous.Service Tax Report Helper


VerifyServTaxCreditRegisterServTaxRegNo@1500012 Method

The procedure VerifyServTaxCreditRegisterServTaxRegNo is available in codeunit 143007.

Syntax

VerifyServTaxCreditRegisterServTaxRegNo@1500012(
    ServiceTaxRegNo@1500000 : Code[20] ServiceTaxRegNo //Input parameter of type Code
);

Parameters

ServiceTaxRegNo
Input parameter of type Code

Remarks

The relevant search keywords are: Verify, Serv, Tax, Credit, Register, Serv, Tax, Reg, No.

For a clarification about how this function works, refer to the code listed below.

      LibraryReportDataset.GetLastRow;
      LibraryReportDataset.AssertCurrentRowValue('ServiceTaxRegNo',ServiceTaxRegNo);

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      InitializeReportTest;

      PaymentJournalLine.PoT := TRUE;
      ApplyBiggerDocToAdvPmt(
        PaymentJournalLine,PurchaseHeader."Document Type"::Invoice,ReverseChargeType::" ",
        GLAccountNo,InvoiceBaseAmount,InvoiceTaxAmount,PaymentBaseAmount,PaymentTaxAmount);

      Vendor.GET(PaymentJournalLine."Account No.");
      Vendor."Service Tax Registration No." :=
        LibraryUtility.GenerateRandomCode(Vendor.FIELDNO("Service Tax Registration No."),DATABASE::Vendor);
      Vendor.MODIFY;
      COMMIT;

      ServiceTaxReportHelper.RunReportServiceTaxCreditRegister(PaymentJournalLine,TRUE);

      // Verify
      ServiceTaxReportHelper.LoadDataSetFile;
      ServiceTaxReportHelper.VerifyServTaxCreditRegisterServTaxRegNo(Vendor."Service Tax Registration No.");
Member of Miscellaneous.Service Tax Report Helper


VerifyServTaxCreditRegisterTakenAsSalesCredit@1500006 Method

The procedure VerifyServTaxCreditRegisterTakenAsSalesCredit is available in codeunit 143007.

Syntax

VerifyServTaxCreditRegisterTakenAsSalesCredit@1500006(
    SalesInvoiceNo@1500002 : Code[20] SalesInvoiceNo, //Input parameter of type Code
    FullServiceTaxAmount@1500000 : Decimal FullServiceTaxAmount //Input parameter of type Decimal
);

Parameters

SalesInvoiceNo
Input parameter of type Code
FullServiceTaxAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Verify, Serv, Tax, Credit, Register, Taken, As, Sales, Credit.

For a clarification about how this function works, refer to the code listed below.

      ServiceTaxEntryDetails.SETRANGE("Document No.",SalesInvoiceNo);
      ServiceTaxEntryDetails.FINDLAST;

      LibraryReportDataset.LoadDataSetFile;
      Assert.AreEqual(3,LibraryReportDataset.RowCount,WrongRowCountErr);

      LibraryReportDataset.GetNextRow; // Credit Utilized towards tax payment
      Assert.AreEqual(
        FullServiceTaxAmount + ServiceTaxEntryDetails.FullTaxAmount,
        GetFullTaxAmount('ClosingBalance','ClosingBalanceECess','ClosingBalanceSHECess'),ClosingBalanceErr);
      LibraryReportDataset.AssertCurrentRowValue('CreditUsedForSTPmt',-ServiceTaxEntryDetails."Service Tax Amount");
      LibraryReportDataset.AssertCurrentRowValue('CreditUsedForSTPmtECess',-ServiceTaxEntryDetails."Service Tax eCess Amount");
      LibraryReportDataset.AssertCurrentRowValue('CreditUsedForSTPmtSHECess',-ServiceTaxEntryDetails."Service Tax SHE Cess Amount");
      LibraryReportDataset.GetLastRow; // Credit Utilized during period
      LibraryReportDataset.AssertCurrentRowValue('STPmtDetails__Credit_availed_',-ServiceTaxEntryDetails."Service Tax Amount");
      LibraryReportDataset.AssertCurrentRowValue(
        'STPmtDetails__Credit_availed__eCess__',-ServiceTaxEntryDetails."Service Tax eCess Amount");
      LibraryReportDataset.AssertCurrentRowValue(
        'STPmtDetails__Credit_availed__SHECess__',-ServiceTaxEntryDetails."Service Tax SHE Cess Amount");

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      Initialize;

      ReverseServiceTaxHelper.CreatePurchaseDoc(
        PurchaseHeader,PurchaseLine,PurchaseHeader."Document Type"::Invoice,ReverseChargeTypeOption::" ",0,TRUE);
      PostedPurchInvoiceDocNo := ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);

      PostedSalesInvoiceDocNo :=
        ReverseServiceTaxHelper.UseCreditToPayForSalesDoc(PostedPurchInvoiceDocNo,ServiceTaxEntryDetails);

      COMMIT;
      ReverseServiceTaxHelper.ConvertDocToJnlLine(PurchaseHeader,PurchaseLine,PostedPurchInvoiceDocNo,GenJournalLine);
      ServiceTaxReportHelper.RunReportServiceTaxCreditRegister(GenJournalLine,TRUE);

      ServiceTaxReportHelper.VerifyServTaxCreditRegisterTakenAsSalesCredit(PostedSalesInvoiceDocNo,ServiceTaxEntryDetails.FullTaxAmount);
Member of Miscellaneous.Service Tax Report Helper


VerifyServTaxCreditRegisterUsedAsExcise@1500004 Method

The procedure VerifyServTaxCreditRegisterUsedAsExcise is available in codeunit 143007.

Syntax

VerifyServTaxCreditRegisterUsedAsExcise@1500004(
    SalesInvoiceNo@1500000 : Code[20] SalesInvoiceNo, //Input parameter of type Code
    FullServiceTaxAmount@1500002 : Decimal FullServiceTaxAmount //Input parameter of type Decimal
);

Parameters

SalesInvoiceNo
Input parameter of type Code
FullServiceTaxAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Verify, Serv, Tax, Credit, Register, Used, As, Excise.

For a clarification about how this function works, refer to the code listed below.

      ExciseEntry.SETRANGE("Document No.",SalesInvoiceNo);
      ExciseEntry.FINDLAST;

      LibraryReportDataset.LoadDataSetFile;
      Assert.AreEqual(3,LibraryReportDataset.RowCount,WrongRowCountErr);

      LibraryReportDataset.GetNextRow; // Credit Utilized towards excise payment
      Assert.AreEqual(
        FullServiceTaxAmount + ExciseEntry."BED Amount" + ExciseEntry."eCess Amount" + ExciseEntry."SHE Cess Amount",
        GetFullTaxAmount('ClosingBalance','ClosingBalanceECess','ClosingBalanceSHECess'),ClosingBalanceErr);
      LibraryReportDataset.AssertCurrentRowValue('CreditUsedForExcPmt',-ExciseEntry."BED Amount");
      LibraryReportDataset.AssertCurrentRowValue('CreditUsedForExcPmtECess',-ExciseEntry."eCess Amount");
      LibraryReportDataset.AssertCurrentRowValue('CreditUsedForExcPmtSHECess',-ExciseEntry."SHE Cess Amount");
      LibraryReportDataset.GetLastRow; // Credit Utilized during period
      LibraryReportDataset.AssertCurrentRowValue('STasExciseUtilisation2__ST_as_Excise_Utilisation_',-ExciseEntry."BED Amount");
      LibraryReportDataset.AssertCurrentRowValue(
        'STasExciseUtilisation2__ST_eCess_as_Excise_Utilisation_',-ExciseEntry."eCess Amount");
      LibraryReportDataset.AssertCurrentRowValue(
        'STasExciseUtilisation2__ST_SHECess_Excise_Utilisation_',-ExciseEntry."SHE Cess Amount");

Example

The below example is extracted from the test automation codeunit 144043 to show one way of using this function.

      isInitialized := FALSE;
      Initialize;
      OldECCNo := ServiceTaxAsExciseHelper.SetNewGlobalECCNo;

      ReverseServiceTaxHelper.CreateAndPostAdvancePayment(GenJournalLine,TRUE,0,0,0);
      ReverseServiceTaxHelper.GetServiceTaxEntryDetail(ServiceTaxEntryDetails,GenJournalLine."Document No.");
      ServiceTaxAsExciseHelper.SetServiceTaxAsExciseCredit(ServiceTaxEntryDetails);

      PostedSalesInvoiceNo :=
        ServiceTaxAsExciseHelper.PostSalesInvoiceDirectExcise(
          ServiceTaxEntryDetails."Posting Date",ServiceTaxEntryDetails."Base Amount" DIV 3,ServiceTaxEntryDetails."Service Tax Group Code");

      ServiceTaxReportHelper.RunReportServiceTaxCreditRegister(GenJournalLine,TRUE);

      ServiceTaxReportHelper.VerifyServTaxCreditRegisterUsedAsExcise(PostedSalesInvoiceNo,ServiceTaxEntryDetails.FullTaxAmount);

      ServiceTaxAsExciseHelper.SetGlobalECCNo(OldECCNo);
Member of Miscellaneous.Service Tax Report Helper


VerifyServTaxRegisterCrMAppliedToInvPoT@1500000 Method

The procedure VerifyServTaxRegisterCrMAppliedToInvPoT is available in codeunit 143007.

Syntax

VerifyServTaxRegisterCrMAppliedToInvPoT@1500000(
    InvGenJournalLine@1500001 : Record 81 InvGenJournalLine, //Input parameter of type Record
    CrMemoGenJournalLine@1500000 : Record 81 CrMemoGenJournalLine //Input parameter of type Record
);

Parameters

InvGenJournalLine
Input parameter of type Record
CrMemoGenJournalLine
Input parameter of type Record

Remarks

The relevant search keywords are: Verify, Serv, Tax, Register, Credit, M, Applied, To, Invoice, PoT.

For a clarification about how this function works, refer to the code listed below.

      CalcServiceTaxAmounts(InvGenJournalLine,CrMemoGenJournalLine);
      LibraryReportDataset.LoadDataSetFile;
      Assert.AreEqual(2,LibraryReportDataset.RowCount,WrongRowCountErr);

      LibraryReportDataset.GetNextRow;
      VerifyServTaxRegisterDetailsEntry(
        InvGenJournalLine."Document No.",
        InvGenJournalLine.Amount,InvGenJournalLine."Service Tax Amount");
      LibraryReportDataset.GetNextRow;
      VerifyServTaxRegisterDetailsEntry(
        CrMemoGenJournalLine."Document No.",
        -CrMemoGenJournalLine.Amount,-CrMemoGenJournalLine."Service Tax Amount");

Example

The below example is extracted from the test automation codeunit 144033 to show one way of using this function.

      Initialize;

      ApplyDocOnCrMemoCoverAmount(
        PurchaseHeader."Document Type"::Invoice,PurchaseHeader."Service Type (Rev. Chrg.)"::" ",ServiceTaxType::" ",
        TRUE,InvoiceAmountIs::Greater,InvGenJournalLine,CrMemoGenJournalLine);

      ServiceTaxReportHelper.RunReportServiceTaxRegister(InvGenJournalLine);

      ServiceTaxReportHelper.VerifyServTaxRegisterCrMAppliedToInvPoT(InvGenJournalLine,CrMemoGenJournalLine);
Member of Miscellaneous.Service Tax Report Helper


VerifyServTaxRegisterCrMAppliedToInvRevChrg@1500001 Method

The procedure VerifyServTaxRegisterCrMAppliedToInvRevChrg is available in codeunit 143007.

Syntax

VerifyServTaxRegisterCrMAppliedToInvRevChrg@1500001(
    InvGenJournalLine@1500001 : Record 81 InvGenJournalLine, //Input parameter of type Record
    CrMemoGenJournalLine@1500000 : Record 81 CrMemoGenJournalLine //Input parameter of type Record
);

Parameters

InvGenJournalLine
Input parameter of type Record
CrMemoGenJournalLine
Input parameter of type Record

Remarks

The relevant search keywords are: Verify, Serv, Tax, Register, Credit, M, Applied, To, Invoice, Rev, Chrg.

For a clarification about how this function works, refer to the code listed below.

      CalcServiceTaxAmounts(InvGenJournalLine,CrMemoGenJournalLine);
      LibraryReportDataset.LoadDataSetFile;
      Assert.AreEqual(2,LibraryReportDataset.RowCount,WrongRowCountErr);

      LibraryReportDataset.GetNextRow;
      VerifyServTaxRegisterDetailsEntry(
        InvGenJournalLine."Document No.",
        CrMemoGenJournalLine.Amount,CrMemoGenJournalLine."Service Tax Amount");

      LibraryReportDataset.GetNextRow;
      VerifyServTaxRegisterDetailsEntry(
        CrMemoGenJournalLine."Document No.",
        -CrMemoGenJournalLine.Amount,-CrMemoGenJournalLine."Service Tax Amount");

Example

The below example is extracted from the test automation codeunit 144033 to show one way of using this function.

      Initialize;

      ApplyDocOnCrMemoCoverAmount(
        PurchaseHeader."Document Type"::Invoice,PurchaseHeader."Service Type (Rev. Chrg.)"::Inward,ServiceTaxType::Standard,
        FALSE,InvoiceAmountIs::Greater,InvGenJournalLine,CrMemoGenJournalLine);

      ServiceTaxReportHelper.RunReportServiceTaxRegister(InvGenJournalLine);

      ServiceTaxReportHelper.VerifyServTaxRegisterCrMAppliedToInvRevChrg(InvGenJournalLine,CrMemoGenJournalLine);
Member of Miscellaneous.Service Tax Report Helper


VerifyServTaxRegisterInvAppliedToAdvPmtPoT@1500002 Method

The procedure VerifyServTaxRegisterInvAppliedToAdvPmtPoT is available in codeunit 143007.

Syntax

VerifyServTaxRegisterInvAppliedToAdvPmtPoT@1500002(
    GenJournalLine@1500000 : Record 81 GenJournalLine, //Input parameter of type Record
    PostedDocNo@1500001 : Code[20] PostedDocNo, //Input parameter of type Code
    InvoiceBaseAmount@1500005 : Decimal InvoiceBaseAmount, //Input parameter of type Decimal
    InvoiceTaxAmount@1500004 : Decimal InvoiceTaxAmount, //Input parameter of type Decimal
    PaymentBaseAmount@1500003 : Decimal PaymentBaseAmount, //Input parameter of type Decimal
    PaymentTaxAmount@1500002 : Decimal PaymentTaxAmount //Input parameter of type Decimal
);

Parameters

GenJournalLine
Input parameter of type Record
PostedDocNo
Input parameter of type Code
InvoiceBaseAmount
Input parameter of type Decimal
InvoiceTaxAmount
Input parameter of type Decimal
PaymentBaseAmount
Input parameter of type Decimal
PaymentTaxAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Verify, Serv, Tax, Register, Invoice, Applied, To, Adv, Payment, PoT.

For a clarification about how this function works, refer to the code listed below.

      LibraryReportDataset.LoadDataSetFile;
      Assert.AreEqual(3,LibraryReportDataset.RowCount,WrongRowCountErr);

      LibraryReportDataset.GetNextRow;
      VerifyServTaxRegisterDetailsEntry(PostedDocNo,InvoiceBaseAmount,InvoiceTaxAmount);
      LibraryReportDataset.GetNextRow;
      VerifyServTaxRegisterDetailsEntry(PostedDocNo,-PaymentBaseAmount,-PaymentTaxAmount);
      LibraryReportDataset.GetNextRow;
      VerifyServTaxRegisterDetailsEntry(GenJournalLine."Document No.",PaymentBaseAmount,PaymentTaxAmount);

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      Initialize;

      GenJournalLine.PoT := TRUE;
      PostedDocNo :=
        ApplyBiggerDocToAdvPmt(
          GenJournalLine,PurchaseHeader."Document Type"::Invoice,ReverseChargeType::" ",
          GLAccountNo,InvoiceBaseAmount,InvoiceTaxAmount,PaymentBaseAmount,PaymentTaxAmount);

      ServiceTaxReportHelper.RunReportServiceTaxRegister(GenJournalLine);

      ServiceTaxReportHelper.VerifyServTaxRegisterInvAppliedToAdvPmtPoT(
        GenJournalLine,PostedDocNo,InvoiceBaseAmount,InvoiceTaxAmount,PaymentBaseAmount,PaymentTaxAmount)
Member of Miscellaneous.Service Tax Report Helper


Service Tax Verify Class

Miscellaneous.Service Tax Verify

COD143004 applies to ERM,IN.

Methods

Name | Description
AccountBalance@1500058 | The procedure AccountBalance is available in codeunit 143004.
AccountBalanceByDocNo@1500078 | The procedure AccountBalanceByDocNo is available in codeunit 143004.
AdvPaymentOnlineAppGLBalance@1500067 | The procedure AdvPaymentOnlineAppGLBalance is available in codeunit 143004.
AdvPaymentOnlineAppSBCKKCGLBalance@1500115 | The procedure AdvPaymentOnlineAppSBCKKCGLBalance is available in codeunit 143004.
AdvPmtGLBalance@1500005 | The procedure AdvPmtGLBalance is available in codeunit 143004.
AppliedDocServiceTax@1500086 | The procedure AppliedDocServiceTax is available in codeunit 143004.
CalcKKCRemainingAmount@1500124 | The procedure CalcKKCRemainingAmount is available in codeunit 143004.
CalcRemainingTaxAmount@1500070 | The procedure CalcRemainingTaxAmount is available in codeunit 143004.
CalcServTaxEntryAmounts@1170000005 | The procedure CalcServTaxEntryAmounts is available in codeunit 143004.
CalcSTEntryDetailsBalances@1500015 | The procedure CalcSTEntryDetailsBalances is available in codeunit 143004.
CalcVendLedgEntryRemAmount@1500033 | The procedure CalcVendLedgEntryRemAmount is available in codeunit 143004.
CountOfServiceTaxEntries@1500145 | The procedure CountOfServiceTaxEntries is available in codeunit 143004.
CountOfUnappliedEntries@1500043 | The procedure CountOfUnappliedEntries is available in codeunit 143004.
DocHasClosedRemCredit@1500055 | The procedure DocHasClosedRemCredit is available in codeunit 143004.
GLBalanceReceivablesOnly@1500003 | The procedure GLBalanceReceivablesOnly is available in codeunit 143004.
GLBalanceRevCharge@1500001 | The procedure GLBalanceRevCharge is available in codeunit 143004.
GLBalancesOnPostedPurchaseDoc@1500013 | The procedure GLBalancesOnPostedPurchaseDoc is available in codeunit 143004.
GLEntriesCount@1500049 | The procedure GLEntriesCount is available in codeunit 143004.
GLEntriesForSTPmtEntries@1500098 | The procedure GLEntriesForSTPmtEntries is available in codeunit 143004.
GLEntriesForSTPmtEntriesForAmt@1500011 | The procedure GLEntriesForSTPmtEntriesForAmt is available in codeunit 143004.
GLEntriesForSTSBCKKCPmtEntriesForAmt@1500099 | The procedure GLEntriesForSTSBCKKCPmtEntriesForAmt is available in codeunit 143004.
GLEntry@1500040 | The procedure GLEntry is available in codeunit 143004.
GLEntryByAmount@1500029 | The procedure GLEntryByAmount is available in codeunit 143004.
GLEntryDoesNotExist@1500053 | The procedure GLEntryDoesNotExist is available in codeunit 143004.
GLEntryWithRounding@1500008 | The procedure GLEntryWithRounding is available in codeunit 143004.
GLKKCBalanceReceivablesOnly@1500004 | The procedure GLKKCBalanceReceivablesOnly is available in codeunit 143004.
GLKKCBalanceRevCharge@1500092 | The procedure GLKKCBalanceRevCharge is available in codeunit 143004.
GLSBCBalanceReceivablesOnly@1500091 | The procedure GLSBCBalanceReceivablesOnly is available in codeunit 143004.
GLSBCBalanceRevCharge@1500088 | The procedure GLSBCBalanceRevCharge is available in codeunit 143004.
InitialRemainingCredit@1500044 | The procedure InitialRemainingCredit is available in codeunit 143004.
KKCGLAccountsBalance@1500104 | The procedure KKCGLAccountsBalance is available in codeunit 143004.
KKCPayAccBalance@1500119 | The procedure KKCPayAccBalance is available in codeunit 143004.
KKCPayInterimAccBalance@1500117 | The procedure KKCPayInterimAccBalance is available in codeunit 143004.
KKCRecAccBalance@1500116 | The procedure KKCRecAccBalance is available in codeunit 143004.
KKCRecAccBalanceNearly@1500130 | The procedure KKCRecAccBalanceNearly is available in codeunit 143004.
KKCRecInterimAccBalance@1500114 | The procedure KKCRecInterimAccBalance is available in codeunit 143004.
PostedAdvPayment@1500031 | The procedure PostedAdvPayment is available in codeunit 143004.
PostedAdvPaymentBackCalc@1500101 | The procedure PostedAdvPaymentBackCalc is available in codeunit 143004.
PostedAdvPmtAndInvGLBalance@1500038 | The procedure PostedAdvPmtAndInvGLBalance is available in codeunit 143004.
PostedAdvPmtAndInvGLBalPartial@1500054 | The procedure PostedAdvPmtAndInvGLBalPartial is available in codeunit 143004.
PostedInvoiceRounding@1500075 | The procedure PostedInvoiceRounding is available in codeunit 143004.
PostedPmtAndInvGLBalPartial@1500062 | The procedure PostedPmtAndInvGLBalPartial is available in codeunit 143004.
PostedPurchDocGLBalance@1500045 | The procedure PostedPurchDocGLBalance is available in codeunit 143004.
PostedPurchDocGLKKCBalance@1500094 | The procedure PostedPurchDocGLKKCBalance is available in codeunit 143004.
PostedPurchDocGLSBCBalance@1500093 | The procedure PostedPurchDocGLSBCBalance is available in codeunit 143004.
PostedSBCKKCAdvPmtAndInvGLBalance@1500106 | The procedure PostedSBCKKCAdvPmtAndInvGLBalance is available in codeunit 143004.
PostedSBCKKCPmtAndInvGLBalPartial@1500100 | The procedure PostedSBCKKCPmtAndInvGLBalPartial is available in codeunit 143004.
PoTServTaxEntry@1500059 | The procedure PoTServTaxEntry is available in codeunit 143004.
RevChrgServTaxEntry@1500051 | The procedure RevChrgServTaxEntry is available in codeunit 143004.
ReversedDocument@1500063 | The procedure ReversedDocument is available in codeunit 143004.
SBCGLAccountsBalance@1500103 | The procedure SBCGLAccountsBalance is available in codeunit 143004.
SBCPayAccBalance@1500109 | The procedure SBCPayAccBalance is available in codeunit 143004.
SBCPayInterimAccBalance@1500108 | The procedure SBCPayInterimAccBalance is available in codeunit 143004.
SBCRecAccBalance@1500107 | The procedure SBCRecAccBalance is available in codeunit 143004.
SBCRecAccBalanceNearly@1500129 | The procedure SBCRecAccBalanceNearly is available in codeunit 143004.
SBCRecInterimAccBalance@1500105 | The procedure SBCRecInterimAccBalance is available in codeunit 143004.
ServiceTaxEntries@1500009 | The procedure ServiceTaxEntries is available in codeunit 143004.
ServTaxEntriesArePaid@1500056 | The procedure ServTaxEntriesArePaid is available in codeunit 143004.
ServTaxEntriesFor2Pmts@1500089 | The procedure ServTaxEntriesFor2Pmts is available in codeunit 143004.
ServTaxEntry@1500018 | The procedure ServTaxEntry is available in codeunit 143004.
ServTaxEntryDetails@1500061 | The procedure ServTaxEntryDetails is available in codeunit 143004.
ServTaxEntryStatus@1500081 | The procedure ServTaxEntryStatus is available in codeunit 143004.
ServTaxGLAccountsBalance@1560000 | The procedure ServTaxGLAccountsBalance is available in codeunit 143004.
ServTaxPaymentEntries@1500023 | The procedure ServTaxPaymentEntries is available in codeunit 143004.
SplitApplication@1500017 | The procedure SplitApplication is available in codeunit 143004.
SplitServTaxAccountsBalance@1500127 | The procedure SplitServTaxAccountsBalance is available in codeunit 143004.
STaxGLEntriesDoNotExist@1500050 | The procedure STaxGLEntriesDoNotExist is available in codeunit 143004.
STDetailAmounts@1500039 | The procedure STDetailAmounts is available in codeunit 143004.
STDetailAmountsAndStatus@1500072 | The procedure STDetailAmountsAndStatus is available in codeunit 143004.
STDetailsAfterPayRCToGovSplit@1500118 | The procedure STDetailsAfterPayRCToGovSplit is available in codeunit 143004.
STDetailStatus@1500073 | The procedure STDetailStatus is available in codeunit 143004.
STEntriesAfterTakeSalesCredit@1500024 | The procedure STEntriesAfterTakeSalesCredit is available in codeunit 143004.
STEntriesAppln@1500006 | The procedure STEntriesAppln is available in codeunit 143004.
STEntriesCanceledDocument@1500014 | The procedure STEntriesCanceledDocument is available in codeunit 143004.
STEntriesFullPurchFlow@1500010 | The procedure STEntriesFullPurchFlow is available in codeunit 143004.
STEntriesVsGLBalCrMPmt@1500064 | The procedure STEntriesVsGLBalCrMPmt is available in codeunit 143004.
STEntriesVsGLBalCrMPmtOutward@1500065 | The procedure STEntriesVsGLBalCrMPmtOutward is available in codeunit 143004.
STEntriesVsGLBalInvCrM@1500069 | The procedure STEntriesVsGLBalInvCrM is available in codeunit 143004.
STEntryBalances@1500066 | The procedure STEntryBalances is available in codeunit 143004.
STEntryDetailsForAccount@1500037 | The procedure STEntryDetailsForAccount is available in codeunit 143004.
STEntryDetailsKKCRemainingCredit@1500123 | The procedure STEntryDetailsKKCRemainingCredit is available in codeunit 143004.
STEntryDetailsOnDocNoSplit@1500000 | The procedure STEntryDetailsOnDocNoSplit is available in codeunit 143004.
STEntryDetailsPaidSrvTax@1500080 | The procedure STEntryDetailsPaidSrvTax is available in codeunit 143004.
STEntryDetailsPartialPay@1500028 | The procedure STEntryDetailsPartialPay is available in codeunit 143004.
STEntryDetailsRemainingCredit@1500012 | The procedure STEntryDetailsRemainingCredit is available in codeunit 143004.
STEntryDetailsRemRevChrgCredit@1500154 | The procedure STEntryDetailsRemRevChrgCredit is available in codeunit 143004.
STEntryDtlsBalancesAndStatuses@1500032 | The procedure STEntryDtlsBalancesAndStatuses is available in codeunit 143004.
STEntryDtlsFullTaxBalance@1500019 | The procedure STEntryDtlsFullTaxBalance is available in codeunit 143004.
STEntryDtlsFullTaxBalNearly@1500084 | The procedure STEntryDtlsFullTaxBalNearly is available in codeunit 143004.
STEntryDtlsKKCBalance@1500125 | The procedure STEntryDtlsKKCBalance is available in codeunit 143004.
STEntryDtlsKKCBalNearly@1500126 | The procedure STEntryDtlsKKCBalNearly is available in codeunit 143004.
STEntryDtlsSBCBalance@1500122 | The procedure STEntryDtlsSBCBalance is available in codeunit 143004.
STEntryDtlsSBCBalNearly@1500128 | The procedure STEntryDtlsSBCBalNearly is available in codeunit 143004.
STEntryFullKKCBalance@1500097 | The procedure STEntryFullKKCBalance is available in codeunit 143004.
STEntryFullSBCBalance@1500095 | The procedure STEntryFullSBCBalance is available in codeunit 143004.
STEntryFullTaxBalance@1500022 | The procedure STEntryFullTaxBalance is available in codeunit 143004.
STExpenseAccBalance@1500030 | The procedure STExpenseAccBalance is available in codeunit 143004.
STPayAccBalance@1500112 | The procedure STPayAccBalance is available in codeunit 143004.
STPayInterimAccBalance@1500111 | The procedure STPayInterimAccBalance is available in codeunit 143004.
STRecAccBalance@1500110 | The procedure STRecAccBalance is available in codeunit 143004.
STRecAccBalanceNearly@1500079 | The procedure STRecAccBalanceNearly is available in codeunit 143004.
STRecInterimAccBalance@1500025 | The procedure STRecInterimAccBalance is available in codeunit 143004.
UnappAdvPmtPartialSTEntrDetBal@1500047 | The procedure UnappAdvPmtPartialSTEntrDetBal is available in codeunit 143004.
UnappAdvPmtRemainingGLBalances@1500042 | The procedure UnappAdvPmtRemainingGLBalances is available in codeunit 143004.
UnappAdvPmtRemainingGLSBCKKCBalances@1500121 | The procedure UnappAdvPmtRemainingGLSBCKKCBalances is available in codeunit 143004.
UnappAdvPmtRemainSBCKKCEntryDetBal@1500120 | The procedure UnappAdvPmtRemainSBCKKCEntryDetBal is available in codeunit 143004.
UnappAdvPmtRemainSTEntryDetBal@1500041 | The procedure UnappAdvPmtRemainSTEntryDetBal is available in codeunit 143004.
UnappAdvPmtSTEntryDetBalances@1500046 | The procedure UnappAdvPmtSTEntryDetBalances is available in codeunit 143004.
UnappAdvRefundSTEntryDetBal@1500155 | The procedure UnappAdvRefundSTEntryDetBal is available in codeunit 143004.
UnappliedAdvSTEntryDetBalances@1500036 | The procedure UnappliedAdvSTEntryDetBalances is available in codeunit 143004.
UnappliedDtldVLEntries@1500020 | The procedure UnappliedDtldVLEntries is available in codeunit 143004.
UnappliedSTEntryDetails@1500035 | The procedure UnappliedSTEntryDetails is available in codeunit 143004.
UnappPmtRemainSTEntryDetBal@1500057 | The procedure UnappPmtRemainSTEntryDetBal is available in codeunit 143004.
UnappPmtRemainSTSBCKKCEntryDetBal@1500102 | The procedure UnappPmtRemainSTSBCKKCEntryDetBal is available in codeunit 143004.
VendorAndServicesEntries@1500113 | The procedure VendorAndServicesEntries is available in codeunit 143004.
VendorLedgerEntryOpen@1500052 | The procedure VendorLedgerEntryOpen is available in codeunit 143004.
VendorLedgerEntryRemAmt@1500152 | The procedure VendorLedgerEntryRemAmt is available in codeunit 143004.

See Also

Miscellaneous


AccountBalance@1500058 Method

The procedure AccountBalance is available in codeunit 143004.

Syntax

AccountBalance@1500058(
    AccountNo@1500000 : Code[20] AccountNo, //Input parameter of type Code
    ExpectedBalance@1500001 : Decimal ExpectedBalance //Input parameter of type Decimal
);

Parameters

AccountNo
Input parameter of type Code
ExpectedBalance
Input parameter of type Decimal

Remarks

The relevant search keywords are: Account, Balance.

For a clarification about how this function works, refer to the code listed below.

      GLAccount.GET(AccountNo);
      GLAccount.CALCFIELDS(Balance);
      Assert.AreEqual(ExpectedBalance,GLAccount.Balance,STRSUBSTNO(AccBalanceErr,GLAccount."No."));

Example

The below example is extracted from the test automation codeunit 144038 to show one way of using this function.

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      ServTaxAmount := CalculateTaxWithAbatement(GenJournalLine,ServiceTaxSetup);
      CalculateSBCKKCWithAbatement(GenJournalLine,ServiceTaxSetup,SBCAmount,KKCAmount);
      ServiceTaxVerify.AccountBalance(ReverseServiceTaxHelper.GetServTaxRecAcc(ServiceTaxSetup),ServTaxAmount);
      ServiceTaxVerify.AccountBalance(ReverseServiceTaxHelper.GetServTaxSBCRecAcc(ServiceTaxSetup),SBCAmount);
      ServiceTaxVerify.AccountBalance(ReverseServiceTaxHelper.GetKKCRecAcc(ServiceTaxSetup),KKCAmount);
      VerifySTEntryAbatement(GenJournalLine,ServiceTaxSetup);
      VerifySTEntryDetailAbatement(GenJournalLine,ServiceTaxSetup);
Member of Miscellaneous.Service Tax Verify


AccountBalanceByDocNo@1500078 Method

The procedure AccountBalanceByDocNo is available in codeunit 143004.

Syntax

AccountBalanceByDocNo@1500078(
    GLAccountNo@1500000 : Code[20] GLAccountNo, //Input parameter of type Code
    DocumentNo@1500003 : Code[20] DocumentNo, //Input parameter of type Code
    ExpectedBalance@1500001 : Decimal ExpectedBalance //Input parameter of type Decimal
);

Parameters

GLAccountNo
Input parameter of type Code
DocumentNo
Input parameter of type Code
ExpectedBalance
Input parameter of type Decimal

Remarks

The relevant search keywords are: Account, Balance, By, Document, No.

For a clarification about how this function works, refer to the code listed below.

      GLEntry.SETRANGE("G/L Account No.",GLAccountNo);
      GLEntry.SETRANGE("Document No.",DocumentNo);

      IF GLEntry.FINDSET THEN
        REPEAT
          ActualBalance += GLEntry.Amount;
        UNTIL GLEntry.NEXT = 0;

      GLSetup.GET;
      Assert.AreNearlyEqual(
        ExpectedBalance,ActualBalance,GLSetup."Service Tax Rounding Precision",STRSUBSTNO(AccBalanceErr,GLAccountNo));

Example

There are no examples available.
Member of Miscellaneous.Service Tax Verify


AdvPaymentOnlineAppGLBalance@1500067 Method

The procedure AdvPaymentOnlineAppGLBalance is available in codeunit 143004.

Syntax

AdvPaymentOnlineAppGLBalance@1500067(
    RevChargeType@1500003 : Option RevChargeType, //Input parameter of type Option
    ServiceTaxSetup@1500002 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    Amount@1500000 : Decimal Amount, //Input parameter of type Decimal
    PoT@1500004 : Boolean PoT //Input parameter of type Boolean
);

Parameters

RevChargeType
Input parameter of type Option
ServiceTaxSetup
Input parameter of type Record
Amount
Input parameter of type Decimal
PoT
Input parameter of type Boolean

Remarks

The relevant search keywords are: Adv, Payment, Online, App, General Ledger, Balance.

For a clarification about how this function works, refer to the code listed below.

      IF RevChargeType <> ReverseChargeType::" " THEN
        GLBalanceRevCharge(ServiceTaxSetup,Amount)
      ELSE
        IF PoT THEN
          STRecInterimAccBalance(ServiceTaxSetup,Amount)
        ELSE
          GLBalanceReceivablesOnly(ServiceTaxSetup,Amount)

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      // Setup
      LastTransactionNo := Initialize;

      // Exercise
      ApplyAdvPmtToInvoice(GenJournalLine,BaseAmount,TaxAmount,SBCAmount,KKCAmount,
        GenJournalLine."Document Type"::Invoice,ReverseChargeType::" ",FALSE);

      // Verify
      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      ServiceTaxVerify.AdvPaymentOnlineAppGLBalance(ReverseChargeType,ServiceTaxSetup,TaxAmount,FALSE);
      ServiceTaxVerify.AdvPaymentOnlineAppSBCKKCGLBalance(ReverseChargeType,ServiceTaxSetup,SBCAmount,KKCAmount,FALSE);

      // Service Tax Entries
      ServiceTaxVerify.STEntriesAppln(LastTransactionNo,GenJournalLine,BaseAmount,ReverseChargeType::" ");
Member of Miscellaneous.Service Tax Verify


AdvPaymentOnlineAppSBCKKCGLBalance@1500115 Method

The procedure AdvPaymentOnlineAppSBCKKCGLBalance is available in codeunit 143004.

Syntax

AdvPaymentOnlineAppSBCKKCGLBalance@1500115(
    RevChargeType@1500003 : Option RevChargeType, //Input parameter of type Option
    ServiceTaxSetup@1500002 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    SBCAmount@1500000 : Decimal SBCAmount, //Input parameter of type Decimal
    KKCAmount@1500001 : Decimal KKCAmount, //Input parameter of type Decimal
    PoT@1500004 : Boolean PoT //Input parameter of type Boolean
);

Parameters

RevChargeType
Input parameter of type Option
ServiceTaxSetup
Input parameter of type Record
SBCAmount
Input parameter of type Decimal
KKCAmount
Input parameter of type Decimal
PoT
Input parameter of type Boolean

Remarks

The relevant search keywords are: Adv, Payment, Online, App, SBCKKCGL, Balance.

For a clarification about how this function works, refer to the code listed below.

      IF RevChargeType <> ReverseChargeType::" " THEN BEGIN
        GLSBCBalanceRevCharge(ServiceTaxSetup,SBCAmount);
        GLKKCBalanceRevCharge(ServiceTaxSetup,KKCAmount);
      END ELSE
        IF PoT THEN BEGIN
          SBCRecInterimAccBalance(ServiceTaxSetup,SBCAmount);
          KKCRecInterimAccBalance(ServiceTaxSetup,KKCAmount);
        END ELSE BEGIN
          GLSBCBalanceReceivablesOnly(ServiceTaxSetup,SBCAmount);
          GLKKCBalanceReceivablesOnly(ServiceTaxSetup,KKCAmount);
        END;

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      // Setup
      LastTransactionNo := Initialize;

      // Exercise
      ApplyAdvPmtToInvoice(GenJournalLine,BaseAmount,TaxAmount,SBCAmount,KKCAmount,
        GenJournalLine."Document Type"::Invoice,ReverseChargeType::" ",FALSE);

      // Verify
      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      ServiceTaxVerify.AdvPaymentOnlineAppGLBalance(ReverseChargeType,ServiceTaxSetup,TaxAmount,FALSE);
      ServiceTaxVerify.AdvPaymentOnlineAppSBCKKCGLBalance(ReverseChargeType,ServiceTaxSetup,SBCAmount,KKCAmount,FALSE);

      // Service Tax Entries
      ServiceTaxVerify.STEntriesAppln(LastTransactionNo,GenJournalLine,BaseAmount,ReverseChargeType::" ");
Member of Miscellaneous.Service Tax Verify


AdvPmtGLBalance@1500005 Method

The procedure AdvPmtGLBalance is available in codeunit 143004.

Syntax

AdvPmtGLBalance@1500005(
    ServiceTaxSetup@1500000 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    ServiceTaxAmount@1500001 : Decimal ServiceTaxAmount, //Input parameter of type Decimal
    CurrentReverseChargeType@1500002 : Option CurrentReverseChargeType //Input parameter of type Option
);

Parameters

ServiceTaxSetup
Input parameter of type Record
ServiceTaxAmount
Input parameter of type Decimal
CurrentReverseChargeType
Input parameter of type Option

Remarks

The relevant search keywords are: Adv, Payment, General Ledger, Balance.

For a clarification about how this function works, refer to the code listed below.

      IF CurrentReverseChargeType = ReverseChargeType::" " THEN
        GLBalanceReceivablesOnly(ServiceTaxSetup,ServiceTaxAmount)
      ELSE
        GLBalanceRevCharge(ServiceTaxSetup,ServiceTaxAmount);

Example

The below example is extracted from the test automation codeunit 144039 to show one way of using this function.

      LastTransactionNo := Initialize;
      PartialInvoiceFactor := LibraryRandom.RandDec(1,1);
      LibraryServiceTax.SetServiceTaxRounding;
      GLSetup.GET;
      // Post Advance Payment
      AdvPaymentDocNo := ReverseServiceTaxHelper.CreateAndPostAdvancePayment(GenJournalLine,FALSE,
          ReverseServiceTaxHelper.GetReverseChargeServType(ReverseChargeType),ReverseChargeType,100);

      // Post 2 Invoice with Service Tax
      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      BaseAmount := ReverseServiceTaxHelper.GetBaseAmountFromAdvPayment(
          GenJournalLine.Amount,ReverseServiceTaxHelper.GetRevChrgPercent(GenJournalLine),ReverseChargeType,ServiceTaxSetup);

      PostedDocNo1 := PostPurchaseDocForAdvPayment(PurchaseHeader1,PurchaseLine,GenJournalLine,
          PurchaseHeader1."Document Type"::Invoice,ReverseChargeType,FALSE,PartialInvoiceFactor * BaseAmount);
      PostedDocNo2 := PostPurchaseDocForAdvPayment(PurchaseHeader2,PurchaseLine,GenJournalLine,
          PurchaseHeader1."Document Type"::Invoice,ReverseChargeType,FALSE,(1 - PartialInvoiceFactor) * BaseAmount);

      // Exercise: Apply the 2 Invoices to Advance Payment
      ReverseServiceTaxHelper.ApplyAndPostVendorEntry(PurchaseHeader1."Document Type"::Invoice,PostedDocNo1,
        VendorLedgerEntry."Document Type"::Payment,AdvPaymentDocNo);
      ReverseServiceTaxHelper.ApplyAndPostVendorEntry(PurchaseHeader1."Document Type"::Invoice,PostedDocNo2,
        VendorLedgerEntry."Document Type"::Payment,AdvPaymentDocNo);

      // Verify:
      ServiceTaxAmount := ReverseServiceTaxHelper.CalculateServTaxTotal(BaseAmount,ServiceTaxSetup);

      ServiceTaxVerify.AdvPmtGLBalance(ServiceTaxSetup,ServiceTaxAmount,ReverseChargeType);

      ServiceTaxVerify.VendorLedgerEntryOpen(PostedDocNo1,FALSE);
      ServiceTaxVerify.VendorLedgerEntryRemAmt(PostedDocNo2,-
        GLSetup."Service Tax Rounding Precision");
      ServiceTaxVerify.VendorLedgerEntryOpen(AdvPaymentDocNo,FALSE);

      ServiceTaxVerify.STEntriesAppln(LastTransactionNo,GenJournalLine,BaseAmount,ReverseChargeType);
Member of Miscellaneous.Service Tax Verify


AppliedDocServiceTax@1500086 Method

The procedure AppliedDocServiceTax is available in codeunit 143004.

Syntax

AppliedDocServiceTax@1500086(
    AdvPmtGenJnlLine@1500007 : Record 81 AdvPmtGenJnlLine, //Input parameter of type Record
    InvoiceGenJnlLine@1500003 : Record 81 InvoiceGenJnlLine, //Input parameter of type Record
    UseNearlyEqual@1500009 : Boolean UseNearlyEqual //Input parameter of type Boolean
);

Parameters

AdvPmtGenJnlLine
Input parameter of type Record
InvoiceGenJnlLine
Input parameter of type Record
UseNearlyEqual
Input parameter of type Boolean

Remarks

The relevant search keywords are: Applied, Document, Service, Tax.

For a clarification about how this function works, refer to the code listed below.

      ServiceTaxSetup.FindOnDate(AdvPmtGenJnlLine."Service Tax Group Code",AdvPmtGenJnlLine."Posting Date");
      ReverseServiceTaxHelper.CalcSplitAmounts(
        AdvPmtGenJnlLine,AdvPmtBaseAmount,AdvPmtPoTAmount,AdvPmtRevChrgAmount,Percentage,ServiceTaxSetup);
      PotAdvSBCKKCAmount :=
        ReverseServiceTaxHelper.CalculatePoTSBCandKKCAmount(AdvPmtBaseAmount,(100 - Percentage) / 100,ServiceTaxSetup);
      ReverseServiceTaxHelper.CalcSplitAmounts(
        InvoiceGenJnlLine,InvoiceBaseAmount,InvoicePoTAmount,InvoiceRevChrgAmount,Percentage,ServiceTaxSetup);
      PotInvSBCKKCAmount :=
        ReverseServiceTaxHelper.CalculatePoTSBCandKKCAmount(InvoiceBaseAmount,(100 - Percentage) / 100,ServiceTaxSetup);

      IF InvoiceGenJnlLine.Amount > AdvPmtGenJnlLine.Amount THEN BEGIN
        ApplnRatio := (AdvPmtBaseAmount + AdvPmtPoTAmount) / (InvoiceBaseAmount + InvoicePoTAmount);
        IF UseNearlyEqual THEN
          STRecAccBalanceNearly(
            ServiceTaxSetup,
            ReverseServiceTaxHelper.RoundServTax(
              (InvoicePoTAmount - PotInvSBCKKCAmount) * (1 - ApplnRatio) + (AdvPmtPoTAmount - PotAdvSBCKKCAmount)))
        ELSE
          STRecAccBalance(
            ServiceTaxSetup,
            ReverseServiceTaxHelper.RoundServTax(
              (InvoicePoTAmount - PotInvSBCKKCAmount) * (1 - ApplnRatio) + (AdvPmtPoTAmount - PotAdvSBCKKCAmount)));

        STRecInterimAccBalance(
          ServiceTaxSetup,
          ReverseServiceTaxHelper.RoundServTax(
            (InvoiceRevChrgAmount + PotInvSBCKKCAmount) * (1 - ApplnRatio) + (AdvPmtRevChrgAmount + PotAdvSBCKKCAmount)));
        STPayAccBalance(ServiceTaxSetup,ReverseServiceTaxHelper.RoundServTax(-AdvPmtRevChrgAmount - PotAdvSBCKKCAmount));
        STPayInterimAccBalance(
          ServiceTaxSetup,
          ReverseServiceTaxHelper.RoundServTax((-InvoiceRevChrgAmount - PotInvSBCKKCAmount) * (1 - ApplnRatio)));
      END;

      IF AdvPmtPoTAmount <> 0 THEN BEGIN
        PoTServTaxEntry(AdvPmtGenJnlLine."Document No.",AdvPmtBaseAmount,Percentage,FALSE,ServiceTaxSetup);
        PoTServTaxEntry(InvoiceGenJnlLine."Document No.",-AdvPmtBaseAmount,Percentage,FALSE,ServiceTaxSetup);
      END;
      AdvPmtRevChrgAmount +=
        ReverseServiceTaxHelper.CalculateKKCess(AdvPmtBaseAmount,ServiceTaxSetup) +
        ReverseServiceTaxHelper.CalculateSBC(AdvPmtBaseAmount,ServiceTaxSetup);
      IF AdvPmtRevChrgAmount <> 0 THEN BEGIN
        RevChrgServTaxEntry(AdvPmtGenJnlLine."Document No.",AdvPmtBaseAmount,Percentage,TRUE,ServiceTaxSetup);
        RevChrgServTaxEntry(InvoiceGenJnlLine."Document No.",-AdvPmtBaseAmount,Percentage,TRUE,ServiceTaxSetup);
      END;

Example

There are no examples available.
Member of Miscellaneous.Service Tax Verify


CalcKKCRemainingAmount@1500124 Method

The procedure CalcKKCRemainingAmount is available in codeunit 143004.

Syntax

CalcKKCRemainingAmount@1500124(
    LastTransactionNo@1500002 : Integer LastTransactionNo //Input parameter of type Integer
);

Parameters

LastTransactionNo
Input parameter of type Integer

Return Value

Decimal

Remarks

The relevant search keywords are: Calc, KKC, Remaining, Amount.

For a clarification about how this function works, refer to the code listed below.

      ServiceTaxEntry.SETRANGE(Type,ServiceTaxEntry.Type::Purchase);
      ServiceTaxEntry.SETFILTER("Transaction No.",'>%1',LastTransactionNo);
      ServiceTaxEntry.FINDSET;
      REPEAT
        ServiceTaxEntryDetails.SETCURRENTKEY("Service Tax Entry No.");
        ServiceTaxEntryDetails.SETRANGE("Service Tax Entry No.",ServiceTaxEntry."Entry No.");
        ServiceTaxEntryDetails.CALCSUMS("KK Cess Amount");
        KKCRemainingAmount += ServiceTaxEntryDetails.KKCessAmount;
      UNTIL ServiceTaxEntry.NEXT = 0;

Example

The below example is extracted from the test automation codeunit 144039 to show one way of using this function.

      LastTransactionNo := Initialize;
      AppAdvPmtToInvTakeSalesCredit(TRUE,InvoiceAmountIs::Smaller,ServiceTaxSetup);

      RemainingServiceTaxAmount := ServiceTaxVerify.CalcRemainingTaxAmount(LastTransactionNo);
      KKCRemainingAmount := ServiceTaxVerify.CalcKKCRemainingAmount(LastTransactionNo);

      ServiceTaxVerify.ServTaxGLAccountsBalance(ServiceTaxSetup,0,-RemainingServiceTaxAmount,0,0);
      ServiceTaxVerify.KKCGLAccountsBalance(ServiceTaxSetup,0,-KKCRemainingAmount,0,0);

      ServiceTaxVerify.STEntriesAfterTakeSalesCredit(LastTransactionNo);
Member of Miscellaneous.Service Tax Verify


CalcRemainingTaxAmount@1500070 Method

The procedure CalcRemainingTaxAmount is available in codeunit 143004.

Syntax

CalcRemainingTaxAmount@1500070(
    LastTransactionNo@1500002 : Integer LastTransactionNo //Input parameter of type Integer
);

Parameters

LastTransactionNo
Input parameter of type Integer

Return Value

Decimal

Remarks

The relevant search keywords are: Calc, Remaining, Tax, Amount.

For a clarification about how this function works, refer to the code listed below.

      ServiceTaxEntry.SETRANGE(Type,ServiceTaxEntry.Type::Purchase);
      ServiceTaxEntry.SETFILTER("Transaction No.",'>%1',LastTransactionNo);
      ServiceTaxEntry.FINDSET;
      REPEAT
        ServiceTaxEntryDetails.SETCURRENTKEY("Service Tax Entry No.");
        ServiceTaxEntryDetails.SETRANGE("Service Tax Entry No.",ServiceTaxEntry."Entry No.");
        ServiceTaxEntryDetails.CALCSUMS("Service Tax Amount","Service Tax eCess Amount","Service Tax SHE Cess Amount");
        RemainingTaxAmount += ServiceTaxEntryDetails.FullTaxAmount;
      UNTIL ServiceTaxEntry.NEXT = 0;

Example

The below example is extracted from the test automation codeunit 144039 to show one way of using this function.

      LastTransactionNo := Initialize;
      AppAdvPmtToInvTakeSalesCredit(TRUE,InvoiceAmountIs::Smaller,ServiceTaxSetup);

      RemainingServiceTaxAmount := ServiceTaxVerify.CalcRemainingTaxAmount(LastTransactionNo);
      KKCRemainingAmount := ServiceTaxVerify.CalcKKCRemainingAmount(LastTransactionNo);

      ServiceTaxVerify.ServTaxGLAccountsBalance(ServiceTaxSetup,0,-RemainingServiceTaxAmount,0,0);
      ServiceTaxVerify.KKCGLAccountsBalance(ServiceTaxSetup,0,-KKCRemainingAmount,0,0);

      ServiceTaxVerify.STEntriesAfterTakeSalesCredit(LastTransactionNo);
Member of Miscellaneous.Service Tax Verify


CalcServTaxEntryAmounts@1170000005 Method

The procedure CalcServTaxEntryAmounts is available in codeunit 143004.

Syntax

CalcServTaxEntryAmounts@1170000005(
    BaseAmount@1500001 : Decimal BaseAmount, //Input parameter of type Decimal
    Percentage@1170000000 : Integer Percentage, //Input parameter of type Integer
    ServTaxSetup@1500004 : Record 16472 ServTaxSetup, //Input parameter of type Record
    VAR SplitBaseAmount@1500007 : Decimal SplitBaseAmount, //Reference parameter of type Decimal
    VAR ServTaxAmount@1500008 : ARRAY [5] OF Decimal ServTaxAmount, //Reference Array parameter of type Decimal
    RevChrgPart@1500000 : Boolean RevChrgPart //Input parameter of type Boolean
);

Parameters

BaseAmount
Input parameter of type Decimal
Percentage
Input parameter of type Integer
ServTaxSetup
Input parameter of type Record
SplitBaseAmount
Reference parameter of type Decimal
ServTaxAmount
Reference Array parameter of type Decimal
RevChrgPart
Input parameter of type Boolean

Remarks

The relevant search keywords are: Calc, Serv, Tax, Entry, Amounts.

For a clarification about how this function works, refer to the code listed below.

      Factor := (100 - Percentage) / 100;
      ServTaxAmount[1] :=
        ReverseServiceTaxHelper.RoundServTax(Factor * ReverseServiceTaxHelper.CalculateServTax(BaseAmount,ServTaxSetup));
      ServTaxAmount[2] :=
        ReverseServiceTaxHelper.RoundServTax(Factor * ReverseServiceTaxHelper.CalculateECess(BaseAmount,ServTaxSetup));
      ServTaxAmount[3] :=
        ReverseServiceTaxHelper.RoundServTax(Factor * ReverseServiceTaxHelper.CalculateSHECess(BaseAmount,ServTaxSetup));
      ServTaxAmount[4] :=
        ReverseServiceTaxHelper.RoundServTax(Factor * ReverseServiceTaxHelper.CalculateSBC(BaseAmount,ServTaxSetup));
      ServTaxAmount[5] :=
        ReverseServiceTaxHelper.RoundServTax(Factor * ReverseServiceTaxHelper.CalculateKKCess(BaseAmount,ServTaxSetup));

      SplitBaseAmount := ROUND(BaseAmount * Factor);

      IF RevChrgPart THEN BEGIN
        ServTaxAmount[1] := ReverseServiceTaxHelper.CalculateServTax(BaseAmount,ServTaxSetup) - ServTaxAmount[1];
        ServTaxAmount[2] := ReverseServiceTaxHelper.CalculateECess(BaseAmount,ServTaxSetup) - ServTaxAmount[2];
        ServTaxAmount[3] := ReverseServiceTaxHelper.CalculateSHECess(BaseAmount,ServTaxSetup) - ServTaxAmount[3];
        ServTaxAmount[4] := ReverseServiceTaxHelper.CalculateSBC(BaseAmount,ServTaxSetup) - ServTaxAmount[4];
        ServTaxAmount[5] := ReverseServiceTaxHelper.CalculateKKCess(BaseAmount,ServTaxSetup) - ServTaxAmount[5];
        SplitBaseAmount := BaseAmount - SplitBaseAmount;
      END;

Example

The below example is extracted from the test automation codeunit 144040 to show one way of using this function.

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",
        GenJournalLine."Posting Date");
      Percentage := ReverseServiceTaxHelper.GetRevChrgPercent(GenJournalLine);
      ServiceTaxVerify.CalcServTaxEntryAmounts(InvBaseAmount,
        Percentage,ServiceTaxSetup,SplitBaseAmount,PoTServTaxAmount,FALSE);
      ServiceTaxVerify.CalcServTaxEntryAmounts(AdvPmtBaseAmount,
        Percentage,ServiceTaxSetup,SplitBaseAmount,RevChrgServTaxAmount,TRUE);

      WITH ExpectedServTaxEntryDetails DO BEGIN
        "Service Tax Amount" := PoTServTaxAmount[1] + RevChrgServTaxAmount[1];
        "Service Tax eCess Amount" := PoTServTaxAmount[2] + RevChrgServTaxAmount[2];
        "Service Tax SHE Cess Amount" := PoTServTaxAmount[3] + RevChrgServTaxAmount[3];
        "Service Tax SBC Amount" := PoTServTaxAmount[4] + RevChrgServTaxAmount[4];
        "KK Cess Amount" := PoTServTaxAmount[5] + RevChrgServTaxAmount[5];
        "Remaining Credit" := PoTServTaxAmount[1];
        "Remaining Credit (eCess)" := PoTServTaxAmount[2];
        "Remaining Credit (SHECess)" := PoTServTaxAmount[3];
        "Remaining Credit (KK Cess)" := PoTServTaxAmount[5];
        "Rev. Chrg. Remaining Credit" := RevChrgServTaxAmount[1];
        "Rev. Chrg. Rem. Credit (eCESS)" := RevChrgServTaxAmount[2];
        "Rev. Chrg. Rem. Cr. (SHECess)" := RevChrgServTaxAmount[3];
        "Rev. Chrg. Rem. Credit (KKC)" := RevChrgServTaxAmount[5];
        IF PaidToGov THEN BEGIN
          "Remaining Credit" += "Rev. Chrg. Remaining Credit";
          "Remaining Credit (eCess)" += "Rev. Chrg. Rem. Credit (eCESS)";
          "Remaining Credit (SHECess)" += "Rev. Chrg. Rem. Cr. (SHECess)";
          "Remaining Credit (KK Cess)" += "Rev. Chrg. Rem. Credit (KKC)";
          "Rev. Chrg. Remaining Credit" -= "Rev. Chrg. Remaining Credit";
          "Rev. Chrg. Rem. Credit (eCESS)" -= "Rev. Chrg. Rem. Credit (eCESS)";
          "Rev. Chrg. Rem. Cr. (SHECess)" -= "Rev. Chrg. Rem. Cr. (SHECess)";
          "Rev. Chrg. Rem. Credit (KKC)" -= "Rev. Chrg. Rem. Credit (KKC)";
        END;
      END;
Member of Miscellaneous.Service Tax Verify


CalcSTEntryDetailsBalances@1500015 Method

The procedure CalcSTEntryDetailsBalances is available in codeunit 143004.

Syntax

CalcSTEntryDetailsBalances@1500015(
    LastTransactionNo@1500000 : Integer LastTransactionNo, //Input parameter of type Integer
    VAR TotalSTEntryDetails@1500003 : Record 16474 TotalSTEntryDetails //Reference parameter of type Record
);

Parameters

LastTransactionNo
Input parameter of type Integer
TotalSTEntryDetails
Reference parameter of type Record

Remarks

The relevant search keywords are: Calc, ST, Entry, Details, Balances.

For a clarification about how this function works, refer to the code listed below.

      WITH TotalSTEntryDetails DO BEGIN
        STEntryDetails.COPYFILTERS(TotalSTEntryDetails);
        STEntryDetails.SETFILTER("Transaction No.",'>%1',LastTransactionNo);
        IF STEntryDetails.FINDSET THEN
          REPEAT
            IF NOT (STEntryDetails."Serv. Tax on Advance Payment" AND STEntryDetails."Corrective Application Entry") THEN
              CalcSTEntryDetailsSum(STEntryDetails,TotalSTEntryDetails);
          UNTIL STEntryDetails.NEXT = 0;
      END;

Example

The below example is extracted from the test automation codeunit 144034 to show one way of using this function.

      ServiceTaxVerify.VendorLedgerEntryOpen(GenJnlLine."Document No.",ABS(GenJnlLine.Amount) > ABS(CreditMemoAmount));
      ServiceTaxVerify.VendorLedgerEntryOpen(CrMemoDocNo,ABS(GenJnlLine.Amount) < ABS(CreditMemoAmount));

      ServiceTaxSetup.FindOnDate(GenJnlLine."Service Tax Group Code",GenJnlLine."Posting Date");
      ReverseServiceTaxHelper.CalcSplitAmounts(GenJnlLine,InvoiceBaseAmount,PoTAmount[1],RevChrgAmount[1],Percentage,ServiceTaxSetup);
      GenJnlLine.Amount := ABS(CreditMemoAmount);
      ReverseServiceTaxHelper.CalcSplitAmounts(GenJnlLine,CrMemoBaseAmount,PoTAmount[2],RevChrgAmount[2],Percentage,ServiceTaxSetup);

      ServiceTaxVerify.STEntriesVsGLBalInvCrM(LastTransactionNo);
      ServiceTaxVerify.CountOfServiceTaxEntries(LastTransactionNo,4,6);
      VerifySTEntriesBalance(LastTransactionNo,PoTAmount[1] - PoTAmount[2] + RevChrgAmount[1] - RevChrgAmount[2]);
      ServiceTaxVerify.CalcSTEntryDetailsBalances(LastTransactionNo,ServiceTaxEntryDetails);
      TotRemainCredit := ServiceTaxEntryDetails.FullRemainingSBCCredit + ServiceTaxEntryDetails.KKCessRemainingCredit;
      ServiceTaxVerify.STEntryDetailsRemainingCredit(LastTransactionNo,(PoTAmount[1] - PoTAmount[2]) - TotRemainCredit);
      ServiceTaxVerify.STEntryDetailsRemRevChrgCredit(LastTransactionNo,0);
      ServiceTaxVerify.DocHasClosedRemCredit(CrMemoDocNo);
Member of Miscellaneous.Service Tax Verify


CalcVendLedgEntryRemAmount@1500033 Method

The procedure CalcVendLedgEntryRemAmount is available in codeunit 143004.

Syntax

CalcVendLedgEntryRemAmount@1500033(
    DocumentNo@1500000 : Code[20] DocumentNo //Input parameter of type Code
);

Parameters

DocumentNo
Input parameter of type Code

Return Value

Decimal

Remarks

The relevant search keywords are: Calc, Vendor, Ledg, Entry, Rem, Amount.

For a clarification about how this function works, refer to the code listed below.

      FindLastPurchDocument(DocumentNo,VendLedgEntry);
      VendLedgEntry.CALCFIELDS("Remaining Amount");
      EXIT(VendLedgEntry."Remaining Amount");

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      Initialize;

      PostedPurchaseDocNo := PostPurchDocFromJnl(GenJournalLine,DocumentType,ReverseChargeType,PoT);

      PaymentAmount := -ServiceTaxVerify.CalcVendLedgEntryRemAmount(PostedPurchaseDocNo);
      PostedPaymentDocNo :=
        PostAndApplyPayment(
          GenJournalLine."Account No.",PaymentAmount,GenJournalLine."Posting Date",
          GenJournalLine."Document Type",PostedPurchaseDocNo,
          ReverseServiceTaxHelper.GetApplyingDocType(GenJournalLine."Document Type"));

      // values for further verification
      GenJournalLine."Applies-to Doc. No." := PostedPaymentDocNo;
      GenJournalLine."Document No." := PostedPurchaseDocNo;
      GenJournalLine."Service Tax Base Amount (LCY)" := -GenJournalLine.Amount;
Member of Miscellaneous.Service Tax Verify


CountOfServiceTaxEntries@1500145 Method

The procedure CountOfServiceTaxEntries is available in codeunit 143004.

Syntax

CountOfServiceTaxEntries@1500145(
    LastTransactionNo@1540000 : Integer LastTransactionNo, //Input parameter of type Integer
    NoOfServiceTaxEntries@1500001 : Integer NoOfServiceTaxEntries, //Input parameter of type Integer
    NoOfDetailsServiceTaxEntries@1500002 : Integer NoOfDetailsServiceTaxEntries //Input parameter of type Integer
);

Parameters

LastTransactionNo
Input parameter of type Integer
NoOfServiceTaxEntries
Input parameter of type Integer
NoOfDetailsServiceTaxEntries
Input parameter of type Integer

Remarks

The relevant search keywords are: Count, Of, Service, Tax, Entries.

For a clarification about how this function works, refer to the code listed below.

      ServTaxEntry.SETFILTER("Transaction No.",'>%1',LastTransactionNo);
      Assert.AreEqual(NoOfServiceTaxEntries,ServTaxEntry.COUNT,STRSUBSTNO(EntriesCountErr,ServTaxEntry.TABLENAME));

      IF ServTaxEntry.FINDSET THEN
        REPEAT
          ServTaxEntryDetail.SETRANGE("Service Tax Entry No.",ServTaxEntry."Entry No.");
          ActualNoOfDetailsServiceTaxEntries += ServTaxEntryDetail.COUNT;
        UNTIL ServTaxEntry.NEXT = 0;
      Assert.AreEqual(
        NoOfDetailsServiceTaxEntries,ActualNoOfDetailsServiceTaxEntries,STRSUBSTNO(EntriesCountErr,ServTaxEntryDetail.TABLENAME));

Example

The below example is extracted from the test automation codeunit 144034 to show one way of using this function.

      ServiceTaxVerify.VendorLedgerEntryOpen(GenJnlLine."Document No.",ABS(GenJnlLine.Amount) > ABS(CreditMemoAmount));
      ServiceTaxVerify.VendorLedgerEntryOpen(CrMemoDocNo,ABS(GenJnlLine.Amount) < ABS(CreditMemoAmount));

      ServiceTaxSetup.FindOnDate(GenJnlLine."Service Tax Group Code",GenJnlLine."Posting Date");
      ReverseServiceTaxHelper.CalcSplitAmounts(GenJnlLine,InvoiceBaseAmount,PoTAmount[1],RevChrgAmount[1],Percentage,ServiceTaxSetup);
      GenJnlLine.Amount := ABS(CreditMemoAmount);
      ReverseServiceTaxHelper.CalcSplitAmounts(GenJnlLine,CrMemoBaseAmount,PoTAmount[2],RevChrgAmount[2],Percentage,ServiceTaxSetup);

      ServiceTaxVerify.STEntriesVsGLBalInvCrM(LastTransactionNo);
      ServiceTaxVerify.CountOfServiceTaxEntries(LastTransactionNo,4,6);
      VerifySTEntriesBalance(LastTransactionNo,PoTAmount[1] - PoTAmount[2] + RevChrgAmount[1] - RevChrgAmount[2]);
      ServiceTaxVerify.CalcSTEntryDetailsBalances(LastTransactionNo,ServiceTaxEntryDetails);
      TotRemainCredit := ServiceTaxEntryDetails.FullRemainingSBCCredit + ServiceTaxEntryDetails.KKCessRemainingCredit;
      ServiceTaxVerify.STEntryDetailsRemainingCredit(LastTransactionNo,(PoTAmount[1] - PoTAmount[2]) - TotRemainCredit);
      ServiceTaxVerify.STEntryDetailsRemRevChrgCredit(LastTransactionNo,0);
      ServiceTaxVerify.DocHasClosedRemCredit(CrMemoDocNo);
Member of Miscellaneous.Service Tax Verify


CountOfUnappliedEntries@1500043 Method

The procedure CountOfUnappliedEntries is available in codeunit 143004.

Syntax

CountOfUnappliedEntries@1500043(
    ApplicationTransactionNo@1500000 : Integer ApplicationTransactionNo //Input parameter of type Integer
);

Parameters

ApplicationTransactionNo
Input parameter of type Integer

Remarks

The relevant search keywords are: Count, Of, Unapplied, Entries.

For a clarification about how this function works, refer to the code listed below.

      IF ReverseServiceTaxHelper.GetLastTransactionNo > ApplicationTransactionNo THEN BEGIN
        ServiceTaxEntryDetails.SETFILTER("Transaction No.",'>%1',ApplicationTransactionNo);
        UnappliedEntriesCount := ServiceTaxEntryDetails.COUNT;
      END ELSE BEGIN
        UnappliedEntriesCount := 0;
        ServiceTaxEntryDetails.SETRANGE("Transaction No.",ApplicationTransactionNo);
        IF ServiceTaxEntryDetails.FINDLAST THEN BEGIN
          ServiceTaxEntryDetails.RESET;
          ServiceTaxEntryDetails.SETFILTER("Entry No.",'>%1',ServiceTaxEntryDetails."Entry No.");
          IF ServiceTaxEntryDetails.FINDFIRST THEN BEGIN
            ServiceTaxEntryDetails.SETRANGE("Application No.",ServiceTaxEntryDetails."Application No.");
            UnappliedEntriesCount := ServiceTaxEntryDetails.COUNT;
          END;
        END;
      END;
      ServiceTaxEntryDetails.RESET;
      ServiceTaxEntryDetails.SETRANGE("Transaction No.",ApplicationTransactionNo);
      IF ServiceTaxEntryDetails.FINDFIRST THEN
        IF ServiceTaxEntryDetails.PoT THEN
          ServiceTaxEntryDetails.SETRANGE("Corrective Application Entry",TRUE);
      ApplicationEntriesCount := ServiceTaxEntryDetails.COUNT;
      Assert.AreEqual(ApplicationEntriesCount,UnappliedEntriesCount,UnappliedEntriesCountErr);

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      ServiceTaxSetup.FindOnDate(PurchaseLine."Service Tax Group",PurchaseHeader."Posting Date");

      IF RevChargeType = ReverseChargeTypeOption::" " THEN
        BaseAmount := ReverseServiceTaxHelper.CalcServTaxBaseAmountBackward(BaseAmount,ServiceTaxSetup,0);

      InvoiceTaxAmount := ReverseServiceTaxHelper.CalculateServTaxAmount(ServiceTaxSetup,BaseAmount,DocumentType);

      FirstPaymentTaxAmount := ReverseServiceTaxHelper.RoundServTax(PartialPaymentFactor * InvoiceTaxAmount);
      SecondPaymentTaxAmount := ReverseServiceTaxHelper.RoundServTax((1 - PartialPaymentFactor) * InvoiceTaxAmount);

      SBCAmount :=
        ReverseServiceTaxHelper.CalculateServTaxSBCAmount(ServiceTaxSetup,BaseAmount,DocumentType);
      KKCAmount :=
        ReverseServiceTaxHelper.CalculateKKCAmount(ServiceTaxSetup,BaseAmount,DocumentType);

      FirstPaymentSBCAmount := ReverseServiceTaxHelper.RoundServTax(PartialPaymentFactor * SBCAmount);
      FirstPaymentKKCAmount := ReverseServiceTaxHelper.RoundServTax(PartialPaymentFactor * KKCAmount);
      SecondPaymentSBCAmount := ReverseServiceTaxHelper.RoundServTax((1 - PartialPaymentFactor) * SBCAmount);
      SecondPaymentKKCAmount := ReverseServiceTaxHelper.RoundServTax((1 - PartialPaymentFactor) * KKCAmount);

      ServiceTaxVerify.CountOfUnappliedEntries(ApplyTransactionNo);

      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDoc,TRUE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedRemainingPayment,TRUE);

      ServiceTaxVerify.UnappPmtRemainSTEntryDetBal(FirstPaymentTaxAmount,SecondPaymentTaxAmount,LastTransactionNo,RevChargeType,PoT);
      ServiceTaxVerify.UnappPmtRemainSTSBCKKCEntryDetBal(FirstPaymentSBCAmount,SecondPaymentSBCAmount,
        FirstPaymentKKCAmount,SecondPaymentKKCAmount,
        LastTransactionNo,RevChargeType,PoT);

      IF RevChargeType = ReverseChargeTypeOption::" " THEN
        ServiceTaxVerify.VendorLedgerEntryRemAmt(
          PostedPurchaseDoc,-((1 - PartialPaymentFactor) * (BaseAmount + InvoiceTaxAmount + SBCAmount + KKCAmount)))
      ELSE
        ServiceTaxVerify.VendorLedgerEntryRemAmt(PostedPurchaseDoc,-((1 - PartialPaymentFactor) * BaseAmount));

      ServiceTaxVerify.PostedPmtAndInvGLBalPartial(
        ServiceTaxSetup,RevChargeType,PoT,InvoiceTaxAmount,FirstPaymentTaxAmount);
      ServiceTaxVerify.PostedSBCKKCPmtAndInvGLBalPartial(
        ServiceTaxSetup,RevChargeType,PoT,SBCAmount,FirstPaymentSBCAmount,KKCAmount,FirstPaymentKKCAmount);
Member of Miscellaneous.Service Tax Verify


DocHasClosedRemCredit@1500055 Method

The procedure DocHasClosedRemCredit is available in codeunit 143004.

Syntax

DocHasClosedRemCredit@1500055(
    DocumentNo@1500000 : Code[20] DocumentNo //Input parameter of type Code
);

Parameters

DocumentNo
Input parameter of type Code

Remarks

The relevant search keywords are: Document, Has, Closed, Rem, Credit.

For a clarification about how this function works, refer to the code listed below.

      ReverseServiceTaxHelper.GetServiceTaxEntryDetail(ServiceTaxEntryDetails,DocumentNo);
      IF ServiceTaxEntryDetails.FINDSET THEN
        REPEAT
          VerifyClosedRemCredit(ServiceTaxEntryDetails);
        UNTIL ServiceTaxEntryDetails.NEXT = 0;

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      Initialize;

      PostPmtAppliedToInvPoT(
        PurchaseLine."Document Type"::Invoice,TRUE,PurchaseLine,PostedPurchaseDocNo,PostedPaymentDocNo,ServiceTaxSetup);
      ReverseServiceTaxHelper.UseCreditToPayForSalesDoc(PostedPurchaseDocNo,ServiceTaxEntryDetails);

      ReverseServiceTaxHelper.UnapplyVendorLedgerEntry(PostedPurchaseDocNo);

      ServiceTaxVerify.DocHasClosedRemCredit(PostedPurchaseDocNo);
Member of Miscellaneous.Service Tax Verify


GLBalanceReceivablesOnly@1500003 Method

The procedure GLBalanceReceivablesOnly is available in codeunit 143004.

Syntax

GLBalanceReceivablesOnly@1500003(
    ServiceTaxSetup@1500000 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    ServiceTaxAmount@1500001 : Decimal ServiceTaxAmount //Input parameter of type Decimal
);

Parameters

ServiceTaxSetup
Input parameter of type Record
ServiceTaxAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: General Ledger, Balance, Receivables, Only.

For a clarification about how this function works, refer to the code listed below.

      ServTaxGLAccountsBalance(ServiceTaxSetup,ServiceTaxAmount,0,0,0);

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      WITH GenJournalLine DO BEGIN
        ServiceTaxSetup.FindOnDate("Service Tax Group Code","Posting Date");

        RealCreditClosed := FALSE;
        ServiceTaxVerify.ServTaxEntryDetails(
          STDetailsDocumentNo,"Service Tax Base Amount (LCY)",ServiceTaxSetup,NOT RealCreditClosed,RealCreditClosed);

        "Service Tax Amount" := ReverseServiceTaxHelper.CalculateServTaxTotal("Service Tax Base Amount (LCY)",ServiceTaxSetup);
        "Service Tax SBC Amount" := ReverseServiceTaxHelper.CalculateSBC("Service Tax Base Amount (LCY)",ServiceTaxSetup);
        "KK Cess Amount" := ReverseServiceTaxHelper.CalculateKKCess("Service Tax Base Amount (LCY)",ServiceTaxSetup);

        ServiceTaxVerify.GLBalanceReceivablesOnly(ServiceTaxSetup,"Service Tax Amount");
        ServiceTaxVerify.GLSBCBalanceReceivablesOnly(ServiceTaxSetup,"Service Tax SBC Amount");
        ServiceTaxVerify.GLKKCBalanceReceivablesOnly(ServiceTaxSetup,"KK Cess Amount");
      END;
Member of Miscellaneous.Service Tax Verify


GLBalanceRevCharge@1500001 Method

The procedure GLBalanceRevCharge is available in codeunit 143004.

Syntax

GLBalanceRevCharge@1500001(
    ServiceTaxSetup@1500000 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    ServiceTaxAmount@1500001 : Decimal ServiceTaxAmount //Input parameter of type Decimal
);

Parameters

ServiceTaxSetup
Input parameter of type Record
ServiceTaxAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: General Ledger, Balance, Rev, Charge.

For a clarification about how this function works, refer to the code listed below.

      ServTaxGLAccountsBalance(ServiceTaxSetup,0,ServiceTaxAmount,-ServiceTaxAmount,0);

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      Initialize;

      // Setup:
      ReverseServiceTaxHelper.CreatePurchaseDoc(PurchaseHeader,PurchaseLine,DocumentType,ReverseChargeTypeOption::Standard,100,FALSE);
      PartialPaymentFactor := LibraryRandom.RandDec(1,1);

      // Exercise
      PostedPurchaseDoc := ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);
      ServiceTaxSetup.FindOnDate(PurchaseLine."Service Tax Group",PurchaseHeader."Posting Date");

      PaymentAmount :=
        ReverseServiceTaxHelper.CalculatePayment(PurchaseLine."Document Type",PurchaseLine."Line Amount",ServiceTaxSetup,100);

      PostedPartialPayment := PostAndApplyPmt(PurchaseHeader,PartialPaymentFactor * PaymentAmount,PostedPurchaseDoc);
      PostedRemainingPayment := PostAndApplyPmt(PurchaseHeader,(1 - PartialPaymentFactor) * PaymentAmount,PostedPurchaseDoc);

      // Verify
      AccountNo := ReverseServiceTaxHelper.GetServTaxInterimRecAcc(ServiceTaxSetup);
      BaseAmount := ReverseServiceTaxHelper.CalculateServTaxBase(PurchaseLine."Line Amount",DocumentType);
      Amount := ReverseServiceTaxHelper.CalculateServTaxTotal(BaseAmount,ServiceTaxSetup);
      KKCAmount := ReverseServiceTaxHelper.CalculateKKCess(BaseAmount,ServiceTaxSetup);
      SBCAmount := ReverseServiceTaxHelper.CalculateSBC(BaseAmount,ServiceTaxSetup);

      ServiceTaxVerify.GLBalanceRevCharge(ServiceTaxSetup,Amount);
      ServiceTaxVerify.GLSBCBalanceRevCharge(ServiceTaxSetup,SBCAmount);
      ServiceTaxVerify.GLKKCBalanceRevCharge(ServiceTaxSetup,KKCAmount);

      AccountNo := ReverseServiceTaxHelper.GetServTaxInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,PartialPaymentFactor * Amount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(1 - PartialPaymentFactor) * Amount);
      AccountNo := ReverseServiceTaxHelper.GetServTaxSBCInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,PartialPaymentFactor * SBCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(1 - PartialPaymentFactor) * SBCAmount);
      AccountNo := ReverseServiceTaxHelper.GetKKCInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,PartialPaymentFactor * KKCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(1 - PartialPaymentFactor) * KKCAmount);

      AccountNo := ReverseServiceTaxHelper.GetServTaxPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,-PartialPaymentFactor * Amount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(PartialPaymentFactor - 1) * Amount);
      AccountNo := ReverseServiceTaxHelper.GetServTaxSBCPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,-PartialPaymentFactor * SBCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(PartialPaymentFactor - 1) * SBCAmount);
      AccountNo := ReverseServiceTaxHelper.GetKKCPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,-PartialPaymentFactor * KKCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(PartialPaymentFactor - 1) * KKCAmount);
      RevChargeCreditClosed := FALSE;
      RealCreditClosed := TRUE;
      ServiceTaxVerify.STEntryDetailsPartialPay(PostedPartialPayment,BaseAmount,ServiceTaxSetup,PartialPaymentFactor,0,FALSE,
        RevChargeCreditClosed,RealCreditClosed);
      ServiceTaxVerify.STEntryDetailsPartialPay(PostedRemainingPayment,BaseAmount,ServiceTaxSetup,1 - PartialPaymentFactor,0,FALSE,
        RevChargeCreditClosed,RealCreditClosed);

      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDoc,FALSE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPartialPayment,FALSE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedRemainingPayment,FALSE);
Member of Miscellaneous.Service Tax Verify


GLBalancesOnPostedPurchaseDoc@1500013 Method

The procedure GLBalancesOnPostedPurchaseDoc is available in codeunit 143004.

Syntax

GLBalancesOnPostedPurchaseDoc@1500013(
    PostingDate@1500008 : Date PostingDate, //Input parameter of type Date
    PurchaseLine@1500007 : Record 39 PurchaseLine, //Input parameter of type Record
    PostedPurchaseDoc@1500011 : Code[20] PostedPurchaseDoc, //Input parameter of type Code
    DocumentType@1500000 : Option DocumentType, //Input parameter of type Option
    RevChargeType@1500001 : Option RevChargeType, //Input parameter of type Option
    PoT@1500002 : Boolean PoT //Input parameter of type Boolean
);

Parameters

PostingDate
Input parameter of type Date
PurchaseLine
Input parameter of type Record
PostedPurchaseDoc
Input parameter of type Code
DocumentType
Input parameter of type Option
RevChargeType
Input parameter of type Option
PoT
Input parameter of type Boolean

Remarks

The relevant search keywords are: General Ledger, Balances, On, Posted, Purchase, Document.

For a clarification about how this function works, refer to the code listed below.

      ServiceTaxSetup.FindOnDate(PurchaseLine."Service Tax Group",PostingDate);
      ServiceTaxBase := ReverseServiceTaxHelper.CalculateServTaxBase(PurchaseLine."Line Amount",DocumentType);
      ServiceTaxAmount := ReverseServiceTaxHelper.CalculateServTaxTotal(ServiceTaxBase,ServiceTaxSetup);
      SBCAmount := ReverseServiceTaxHelper.CalculateSBC(ServiceTaxBase,ServiceTaxSetup);
      KKCAmount := ReverseServiceTaxHelper.CalculateKKCess(ServiceTaxBase,ServiceTaxSetup);

      ServTaxEntry(PostedPurchaseDoc,ServiceTaxBase,ServiceTaxSetup);

      PostedPurchDocGLBalance(ServiceTaxSetup,RevChargeType,PoT,ServiceTaxAmount);
      PostedPurchDocGLSBCBalance(ServiceTaxSetup,RevChargeType,PoT,SBCAmount);
      PostedPurchDocGLKKCBalance(ServiceTaxSetup,RevChargeType,PoT,KKCAmount);

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      Initialize;
      ValidateTaxTypeParameters(PoT,ReverseChargeType);

      // Setup
      ReverseServiceTaxHelper.CreatePurchaseDoc(PurchaseHeader,PurchaseLine,DocumentType,
        ReverseChargeType,100,PoT);

      // Exercise
      PostedPurchaseDoc := ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);

      // Verify
      ServiceTaxVerify.GLBalancesOnPostedPurchaseDoc(
        PurchaseHeader."Posting Date",PurchaseLine,PostedPurchaseDoc,DocumentType,ReverseChargeType,PoT);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDoc,TRUE);
Member of Miscellaneous.Service Tax Verify


GLEntriesCount@1500049 Method

The procedure GLEntriesCount is available in codeunit 143004.

Syntax

GLEntriesCount@1500049(
    DocType@1500001 : Option DocType, //Input parameter of type Option
    DocNo@1500000 : Code[20] DocNo, //Input parameter of type Code
    ExpectedCount@1500003 : Integer ExpectedCount //Input parameter of type Integer
);

Parameters

DocType
Input parameter of type Option
DocNo
Input parameter of type Code
ExpectedCount
Input parameter of type Integer

Remarks

The relevant search keywords are: General Ledger, Entries, Count.

For a clarification about how this function works, refer to the code listed below.

      GLEntry.SETRANGE("Document Type",DocType);
      GLEntry.SETRANGE("Document No.",DocNo);
      Assert.AreEqual(ExpectedCount,CountGLEntriesNotBalanced(GLEntry),STRSUBSTNO(GLEntryCountErr,DocNo));

Example

The below example is extracted from the test automation codeunit 144034 to show one way of using this function.

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      ReverseServiceTaxHelper.CalcSplitAmounts(GenJournalLine,BaseAmount,PoTAmount,RevChrgAmount,Percentage,ServiceTaxSetup);

      PoTSBCandKKCAmount := ReverseServiceTaxHelper.CalculatePoTSBCandKKCAmount(BaseAmount,(100 - Percentage) / 100,ServiceTaxSetup);

      AccountNo := ReverseServiceTaxHelper.GetServTaxRecAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(GenJournalLine."Document No.",AccountNo,PoTAmount - PoTSBCandKKCAmount);
      ServiceTaxVerify.STEntryDetailsOnDocNoSplit(GenJournalLine."Document No.",BaseAmount,Percentage,FALSE,ServiceTaxSetup,1);

      AccountNo := ReverseServiceTaxHelper.GetServTaxInterimRecAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(GenJournalLine."Document No.",AccountNo,RevChrgAmount + PoTSBCandKKCAmount);
      AccountNo := ReverseServiceTaxHelper.GetServTaxInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(GenJournalLine."Document No.",AccountNo,-RevChrgAmount - PoTSBCandKKCAmount);

      ServiceTaxVerify.PoTServTaxEntry(GenJournalLine."Document No.",BaseAmount,Percentage,FALSE,ServiceTaxSetup);
      ServiceTaxVerify.RevChrgServTaxEntry(GenJournalLine."Document No.",BaseAmount,Percentage,TRUE,ServiceTaxSetup);

      ServiceTaxVerify.GLEntry(GenJournalLine."Document No.",
        ReverseServiceTaxHelper.GetVendorPostingAccount(GenJournalLine."Account No."),-(BaseAmount + PoTAmount));
      ServiceTaxVerify.GLEntry(GenJournalLine."Document No.",GenJournalLine."Bal. Account No.",BaseAmount);

      ServiceTaxVerify.GLEntriesCount(ReverseServiceTaxHelper.GetPostingDocType(GenJournalLine."Document Type"),GenJournalLine.
        "Document No.",10);
Member of Miscellaneous.Service Tax Verify


GLEntriesForSTPmtEntries@1500098 Method

The procedure GLEntriesForSTPmtEntries is available in codeunit 143004.

Syntax

GLEntriesForSTPmtEntries@1500098(
    PurchLineAmount@1500005 : Decimal PurchLineAmount, //Input parameter of type Decimal
    DocumentType@1500006 : Option DocumentType, //Input parameter of type Option
    VAR BaseAmount@1500003 : Decimal BaseAmount, //Reference parameter of type Decimal
    ServiceTaxSetup@1500002 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    PostedPaymentDocNo@1500001 : Code[20] PostedPaymentDocNo, //Input parameter of type Code
    ServiceTypeRevChrg@1500000 : Option ServiceTypeRevChrg //Input parameter of type Option
);

Parameters

PurchLineAmount
Input parameter of type Decimal
DocumentType
Input parameter of type Option
BaseAmount
Reference parameter of type Decimal
ServiceTaxSetup
Input parameter of type Record
PostedPaymentDocNo
Input parameter of type Code
ServiceTypeRevChrg
Input parameter of type Option

Remarks

The relevant search keywords are: General Ledger, Entries, For, ST, Payment, Entries.

For a clarification about how this function works, refer to the code listed below.

      BaseAmount := ReverseServiceTaxHelper.CalculateServTaxBase(PurchLineAmount,DocumentType);
      Amount := ReverseServiceTaxHelper.CalculateServTaxTotal(BaseAmount,ServiceTaxSetup);
      SBCAmount := ReverseServiceTaxHelper.CalculateSBC(BaseAmount,ServiceTaxSetup);
      KKCAmount := ReverseServiceTaxHelper.CalculateKKCess(BaseAmount,ServiceTaxSetup);

      GLEntriesForSTPmtEntriesForAmt(Amount,ServiceTaxSetup,PostedPaymentDocNo,ServiceTypeRevChrg);
      GLEntriesForSTSBCKKCPmtEntriesForAmt(SBCAmount,KKCAmount,ServiceTaxSetup,PostedPaymentDocNo,ServiceTypeRevChrg);

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",
        GenJournalLine."Posting Date");
      ServiceTaxVerify.GLEntriesForSTPmtEntries(GenJournalLine.Amount,GenJournalLine."Document Type",
        BaseAmount,ServiceTaxSetup,PostedPaymentDocNo,GenJournalLine."Service Type (Rev. Chrg.)");
Member of Miscellaneous.Service Tax Verify


GLEntriesForSTPmtEntriesForAmt@1500011 Method

The procedure GLEntriesForSTPmtEntriesForAmt is available in codeunit 143004.

Syntax

GLEntriesForSTPmtEntriesForAmt@1500011(
    TotalServTaxAmount@1500005 : Decimal TotalServTaxAmount, //Input parameter of type Decimal
    ServiceTaxSetup@1500002 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    PostedPaymentDocNo@1500001 : Code[20] PostedPaymentDocNo, //Input parameter of type Code
    ServiceTypeRevChrg@1500000 : Option ServiceTypeRevChrg //Input parameter of type Option
);

Parameters

TotalServTaxAmount
Input parameter of type Decimal
ServiceTaxSetup
Input parameter of type Record
PostedPaymentDocNo
Input parameter of type Code
ServiceTypeRevChrg
Input parameter of type Option

Remarks

The relevant search keywords are: General Ledger, Entries, For, ST, Payment, Entries, For, Amt.

For a clarification about how this function works, refer to the code listed below.

      AccountNo := ReverseServiceTaxHelper.GetServTaxInterimRecAcc(ServiceTaxSetup);
      GLEntryWithRounding(PostedPaymentDocNo,AccountNo,-TotalServTaxAmount);

      IF ServiceTypeRevChrg <> ServiceTypeRevChrgOption::Inward THEN
        AccountNo := ReverseServiceTaxHelper.GetServTaxExpenseAcc(ServiceTaxSetup)
      ELSE
        AccountNo := ReverseServiceTaxHelper.GetServTaxRecAcc(ServiceTaxSetup);
      GLEntryWithRounding(PostedPaymentDocNo,AccountNo,TotalServTaxAmount);

      AccountNo := ReverseServiceTaxHelper.GetServTaxPayAcc(ServiceTaxSetup);
      GLEntryWithRounding(PostedPaymentDocNo,AccountNo,TotalServTaxAmount);

      GLEntriesCount(GLEntry."Document Type"::" ",PostedPaymentDocNo,8);

Example

The below example is extracted from the test automation codeunit 144034 to show one way of using this function.

      Initialize;
      ReverseServiceTaxHelper.SetupCompanyInfo;

      // Setup
      Percentage := LibraryRandom.RandIntInRange(10,90);
      ReverseServiceTaxHelper.CreatePurchaseDocFromGenJnl(GenJournalLine,GenJournalLine."Document Type"::Invoice,
        ServiceTypeRevChrg,ReverseChargeTypeOption::Standard,TRUE,Percentage);
      PostedDocNo := GenJournalLine."Document No.";
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      PartialFactor := GetPartialFactor;
      PaymentDocNo := ReverseServiceTaxHelper.PostPayment(GenJournalLine."Account No.",
          PartialFactor * ReverseServiceTaxHelper.CalculatePayment(GenJournalLine."Document Type"::Invoice,ABS(GenJournalLine.Amount),
            ServiceTaxSetup,Percentage),GenJournalLine."Posting Date",GenJournalLine."Document Type"::Payment);

      ReverseServiceTaxHelper.ApplyAndPostVendorEntry(GenJournalLine."Document Type"::Invoice,PostedDocNo,
        GenJournalLine."Document Type"::Payment,PaymentDocNo);

      // Exercise and Verify
      PaymentToGovDocNo :=
        ReverseServiceTaxHelper.PayServiceTax(
          GenJournalLine."Service Tax Registration No.",GenJournalLine."Service Tax Group Code",TRUE);

      // Verify
      ReverseServiceTaxHelper.CalcSplitAmounts(GenJournalLine,BaseAmount,PoTAmount,RevChrgAmount,Percentage,ServiceTaxSetup);
      PoTSBCandKKCAmount :=
        ReverseServiceTaxHelper.CalculatePoTSBCandKKCAmount(BaseAmount,(100 - Percentage) / 100,ServiceTaxSetup);
      ServiceTaxVerify.GLEntriesForSTPmtEntriesForAmt(
        (RevChrgAmount + PoTSBCandKKCAmount) * PartialFactor,ServiceTaxSetup,PaymentToGovDocNo,ServiceTypeRevChrg);

      // Real Service Tax Part - because the Real Service Tax Detail entry is created when posting the invoice for the whole amount
      // so partial factor is 1.
      ServiceTaxVerify.STDetailsAfterPayRCToGovSplit(GenJournalLine."Document No.",BaseAmount,Percentage,
        FALSE,ServiceTaxSetup,1,ServiceTypeRevChrg);
      // Rev charge Service Tax Part
      ServiceTaxVerify.STDetailsAfterPayRCToGovSplit(PaymentDocNo,BaseAmount,Percentage,
        TRUE,ServiceTaxSetup,PartialFactor,ServiceTypeRevChrg);
Member of Miscellaneous.Service Tax Verify


GLEntriesForSTSBCKKCPmtEntriesForAmt@1500099 Method

The procedure GLEntriesForSTSBCKKCPmtEntriesForAmt is available in codeunit 143004.

Syntax

GLEntriesForSTSBCKKCPmtEntriesForAmt@1500099(
    TotalSBCAmount@1500005 : Decimal TotalSBCAmount, //Input parameter of type Decimal
    TotalKKCAmount@1500003 : Decimal TotalKKCAmount, //Input parameter of type Decimal
    ServiceTaxSetup@1500002 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    PostedPaymentDocNo@1500001 : Code[20] PostedPaymentDocNo, //Input parameter of type Code
    ServiceTypeRevChrg@1500000 : Option ServiceTypeRevChrg //Input parameter of type Option
);

Parameters

TotalSBCAmount
Input parameter of type Decimal
TotalKKCAmount
Input parameter of type Decimal
ServiceTaxSetup
Input parameter of type Record
PostedPaymentDocNo
Input parameter of type Code
ServiceTypeRevChrg
Input parameter of type Option

Remarks

The relevant search keywords are: General Ledger, Entries, For, STSBCKKC, Payment, Entries, For, Amt.

For a clarification about how this function works, refer to the code listed below.

      AccountNo := ReverseServiceTaxHelper.GetServTaxSBCPayAcc(ServiceTaxSetup);
      GLEntryWithRounding(PostedPaymentDocNo,AccountNo,TotalSBCAmount);

      AccountNo := ReverseServiceTaxHelper.GetKKCInterimRecAcc(ServiceTaxSetup);
      GLEntryWithRounding(PostedPaymentDocNo,AccountNo,-TotalKKCAmount);

      IF ServiceTypeRevChrg <> ServiceTypeRevChrgOption::Inward THEN
        AccountNo := ReverseServiceTaxHelper.GetKKCExpenseAcc(ServiceTaxSetup)
      ELSE
        AccountNo := ReverseServiceTaxHelper.GetKKCRecAcc(ServiceTaxSetup);
      GLEntryWithRounding(PostedPaymentDocNo,AccountNo,TotalKKCAmount);

      AccountNo := ReverseServiceTaxHelper.GetKKCPayAcc(ServiceTaxSetup);
      GLEntryWithRounding(PostedPaymentDocNo,AccountNo,TotalKKCAmount);

Example

There are no examples available.
Member of Miscellaneous.Service Tax Verify


GLEntry@1500040 Method

The procedure GLEntry is available in codeunit 143004.

Syntax

GLEntry@1500040(
    DocumentNo@1500003 : Code[20] DocumentNo, //Input parameter of type Code
    GLAccountNo@1500000 : Code[20] GLAccountNo, //Input parameter of type Code
    Amount@1500001 : Decimal Amount //Input parameter of type Decimal
);

Parameters

DocumentNo
Input parameter of type Code
GLAccountNo
Input parameter of type Code
Amount
Input parameter of type Decimal

Remarks

The relevant search keywords are: General Ledger, Entry.

For a clarification about how this function works, refer to the code listed below.

      GLEntry.SETRANGE("Document No.",DocumentNo);
      GLEntry.SETRANGE("G/L Account No.",GLAccountNo);
      GLEntry.FINDLAST;
      IF Amount = 0 THEN
        Assert.AreEqual(Amount,GLEntry.Amount,STRSUBSTNO(AmountErr,GLEntry.TABLENAME))
      ELSE BEGIN
        GLSetup.GET;
        Assert.AreNearlyEqual(
          Amount,GLEntry.Amount,GLSetup."Service Tax Rounding Precision",STRSUBSTNO(AmountErr,GLEntry.TABLENAME));
      END;

Example

The below example is extracted from the test automation codeunit 144034 to show one way of using this function.

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      ReverseServiceTaxHelper.CalcSplitAmounts(GenJournalLine,BaseAmount,PoTAmount,RevChrgAmount,Percentage,ServiceTaxSetup);

      PoTSBCandKKCAmount := ReverseServiceTaxHelper.CalculatePoTSBCandKKCAmount(BaseAmount,(100 - Percentage) / 100,ServiceTaxSetup);

      AccountNo := ReverseServiceTaxHelper.GetServTaxRecAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(GenJournalLine."Document No.",AccountNo,PoTAmount - PoTSBCandKKCAmount);
      ServiceTaxVerify.STEntryDetailsOnDocNoSplit(GenJournalLine."Document No.",BaseAmount,Percentage,FALSE,ServiceTaxSetup,1);

      AccountNo := ReverseServiceTaxHelper.GetServTaxInterimRecAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(GenJournalLine."Document No.",AccountNo,RevChrgAmount + PoTSBCandKKCAmount);
      AccountNo := ReverseServiceTaxHelper.GetServTaxInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(GenJournalLine."Document No.",AccountNo,-RevChrgAmount - PoTSBCandKKCAmount);

      ServiceTaxVerify.PoTServTaxEntry(GenJournalLine."Document No.",BaseAmount,Percentage,FALSE,ServiceTaxSetup);
      ServiceTaxVerify.RevChrgServTaxEntry(GenJournalLine."Document No.",BaseAmount,Percentage,TRUE,ServiceTaxSetup);

      ServiceTaxVerify.GLEntry(GenJournalLine."Document No.",
        ReverseServiceTaxHelper.GetVendorPostingAccount(GenJournalLine."Account No."),-(BaseAmount + PoTAmount));
      ServiceTaxVerify.GLEntry(GenJournalLine."Document No.",GenJournalLine."Bal. Account No.",BaseAmount);

      ServiceTaxVerify.GLEntriesCount(ReverseServiceTaxHelper.GetPostingDocType(GenJournalLine."Document Type"),GenJournalLine.
        "Document No.",10);
Member of Miscellaneous.Service Tax Verify


GLEntryByAmount@1500029 Method

The procedure GLEntryByAmount is available in codeunit 143004.

Syntax

GLEntryByAmount@1500029(
    DocumentNo@1500003 : Code[20] DocumentNo, //Input parameter of type Code
    GLAccountNo@1500000 : Code[20] GLAccountNo, //Input parameter of type Code
    Amount@1500001 : Decimal Amount //Input parameter of type Decimal
);

Parameters

DocumentNo
Input parameter of type Code
GLAccountNo
Input parameter of type Code
Amount
Input parameter of type Decimal

Remarks

The relevant search keywords are: General Ledger, Entry, By, Amount.

For a clarification about how this function works, refer to the code listed below.

      GLEntry.SETRANGE("Document No.",DocumentNo);
      GLEntry.SETRANGE("G/L Account No.",GLAccountNo);
      GLEntry.SETFILTER(Amount,'%1',ReverseServiceTaxHelper.RoundServTax(Amount));
      Assert.IsTrue(GLEntry.FINDFIRST,STRSUBSTNO(GLEntryDetailedErr,DocumentNo,GLAccountNo,Amount));

Example

There are no examples available.
Member of Miscellaneous.Service Tax Verify


GLEntryDoesNotExist@1500053 Method

The procedure GLEntryDoesNotExist is available in codeunit 143004.

Syntax

GLEntryDoesNotExist@1500053(
    DocumentNo@1500003 : Code[20] DocumentNo, //Input parameter of type Code
    GLAccountNo@1500000 : Code[20] GLAccountNo //Input parameter of type Code
);

Parameters

DocumentNo
Input parameter of type Code
GLAccountNo
Input parameter of type Code

Remarks

The relevant search keywords are: General Ledger, Entry, Does, Not, Exist.

For a clarification about how this function works, refer to the code listed below.

      GLEntry.SETRANGE("G/L Account No.",GLAccountNo);
      GLEntry.SETRANGE("Document No.",DocumentNo);
      Assert.IsTrue(GLEntry.ISEMPTY,STRSUBSTNO(GLEntryErr,GLEntry.GETFILTERS))

Example

There are no examples available.
Member of Miscellaneous.Service Tax Verify


GLEntryWithRounding@1500008 Method

The procedure GLEntryWithRounding is available in codeunit 143004.

Syntax

GLEntryWithRounding@1500008(
    DocumentNo@1500003 : Code[20] DocumentNo, //Input parameter of type Code
    GLAccountNo@1500000 : Code[20] GLAccountNo, //Input parameter of type Code
    Amount@1500001 : Decimal Amount //Input parameter of type Decimal
);

Parameters

DocumentNo
Input parameter of type Code
GLAccountNo
Input parameter of type Code
Amount
Input parameter of type Decimal

Remarks

The relevant search keywords are: General Ledger, Entry, Rounding.

For a clarification about how this function works, refer to the code listed below.

      GLEntry.SETRANGE("Document No.",DocumentNo);
      GLEntry.SETRANGE("G/L Account No.",GLAccountNo);
      GLEntry.FINDLAST;
      Assert.AreEqual(ReverseServiceTaxHelper.RoundServTax(Amount),GLEntry.Amount,STRSUBSTNO(AmountErr,GLEntry.TABLENAME));

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      Initialize;

      // Setup:
      ReverseServiceTaxHelper.CreatePurchaseDoc(PurchaseHeader,PurchaseLine,DocumentType,ReverseChargeTypeOption::Standard,100,FALSE);
      PartialPaymentFactor := LibraryRandom.RandDec(1,1);

      // Exercise
      PostedPurchaseDoc := ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);
      ServiceTaxSetup.FindOnDate(PurchaseLine."Service Tax Group",PurchaseHeader."Posting Date");

      PaymentAmount :=
        ReverseServiceTaxHelper.CalculatePayment(PurchaseLine."Document Type",PurchaseLine."Line Amount",ServiceTaxSetup,100);

      PostedPartialPayment := PostAndApplyPmt(PurchaseHeader,PartialPaymentFactor * PaymentAmount,PostedPurchaseDoc);
      PostedRemainingPayment := PostAndApplyPmt(PurchaseHeader,(1 - PartialPaymentFactor) * PaymentAmount,PostedPurchaseDoc);

      // Verify
      AccountNo := ReverseServiceTaxHelper.GetServTaxInterimRecAcc(ServiceTaxSetup);
      BaseAmount := ReverseServiceTaxHelper.CalculateServTaxBase(PurchaseLine."Line Amount",DocumentType);
      Amount := ReverseServiceTaxHelper.CalculateServTaxTotal(BaseAmount,ServiceTaxSetup);
      KKCAmount := ReverseServiceTaxHelper.CalculateKKCess(BaseAmount,ServiceTaxSetup);
      SBCAmount := ReverseServiceTaxHelper.CalculateSBC(BaseAmount,ServiceTaxSetup);

      ServiceTaxVerify.GLBalanceRevCharge(ServiceTaxSetup,Amount);
      ServiceTaxVerify.GLSBCBalanceRevCharge(ServiceTaxSetup,SBCAmount);
      ServiceTaxVerify.GLKKCBalanceRevCharge(ServiceTaxSetup,KKCAmount);

      AccountNo := ReverseServiceTaxHelper.GetServTaxInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,PartialPaymentFactor * Amount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(1 - PartialPaymentFactor) * Amount);
      AccountNo := ReverseServiceTaxHelper.GetServTaxSBCInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,PartialPaymentFactor * SBCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(1 - PartialPaymentFactor) * SBCAmount);
      AccountNo := ReverseServiceTaxHelper.GetKKCInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,PartialPaymentFactor * KKCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(1 - PartialPaymentFactor) * KKCAmount);

      AccountNo := ReverseServiceTaxHelper.GetServTaxPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,-PartialPaymentFactor * Amount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(PartialPaymentFactor - 1) * Amount);
      AccountNo := ReverseServiceTaxHelper.GetServTaxSBCPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,-PartialPaymentFactor * SBCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(PartialPaymentFactor - 1) * SBCAmount);
      AccountNo := ReverseServiceTaxHelper.GetKKCPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,-PartialPaymentFactor * KKCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(PartialPaymentFactor - 1) * KKCAmount);
      RevChargeCreditClosed := FALSE;
      RealCreditClosed := TRUE;
      ServiceTaxVerify.STEntryDetailsPartialPay(PostedPartialPayment,BaseAmount,ServiceTaxSetup,PartialPaymentFactor,0,FALSE,
        RevChargeCreditClosed,RealCreditClosed);
      ServiceTaxVerify.STEntryDetailsPartialPay(PostedRemainingPayment,BaseAmount,ServiceTaxSetup,1 - PartialPaymentFactor,0,FALSE,
        RevChargeCreditClosed,RealCreditClosed);

      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDoc,FALSE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPartialPayment,FALSE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedRemainingPayment,FALSE);
Member of Miscellaneous.Service Tax Verify


GLKKCBalanceReceivablesOnly@1500004 Method

The procedure GLKKCBalanceReceivablesOnly is available in codeunit 143004.

Syntax

GLKKCBalanceReceivablesOnly@1500004(
    ServiceTaxSetup@1500000 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    KKCAmount@1500001 : Decimal KKCAmount //Input parameter of type Decimal
);

Parameters

ServiceTaxSetup
Input parameter of type Record
KKCAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: GLKKC, Balance, Receivables, Only.

For a clarification about how this function works, refer to the code listed below.

      KKCGLAccountsBalance(ServiceTaxSetup,KKCAmount,0,0,0);

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      WITH GenJournalLine DO BEGIN
        ServiceTaxSetup.FindOnDate("Service Tax Group Code","Posting Date");

        RealCreditClosed := FALSE;
        ServiceTaxVerify.ServTaxEntryDetails(
          STDetailsDocumentNo,"Service Tax Base Amount (LCY)",ServiceTaxSetup,NOT RealCreditClosed,RealCreditClosed);

        "Service Tax Amount" := ReverseServiceTaxHelper.CalculateServTaxTotal("Service Tax Base Amount (LCY)",ServiceTaxSetup);
        "Service Tax SBC Amount" := ReverseServiceTaxHelper.CalculateSBC("Service Tax Base Amount (LCY)",ServiceTaxSetup);
        "KK Cess Amount" := ReverseServiceTaxHelper.CalculateKKCess("Service Tax Base Amount (LCY)",ServiceTaxSetup);

        ServiceTaxVerify.GLBalanceReceivablesOnly(ServiceTaxSetup,"Service Tax Amount");
        ServiceTaxVerify.GLSBCBalanceReceivablesOnly(ServiceTaxSetup,"Service Tax SBC Amount");
        ServiceTaxVerify.GLKKCBalanceReceivablesOnly(ServiceTaxSetup,"KK Cess Amount");
      END;
Member of Miscellaneous.Service Tax Verify


GLKKCBalanceRevCharge@1500092 Method

The procedure GLKKCBalanceRevCharge is available in codeunit 143004.

Syntax

GLKKCBalanceRevCharge@1500092(
    ServiceTaxSetup@1500000 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    KKCAmount@1500001 : Decimal KKCAmount //Input parameter of type Decimal
);

Parameters

ServiceTaxSetup
Input parameter of type Record
KKCAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: GLKKC, Balance, Rev, Charge.

For a clarification about how this function works, refer to the code listed below.

      KKCGLAccountsBalance(ServiceTaxSetup,0,KKCAmount,-KKCAmount,0);

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      Initialize;

      // Setup:
      ReverseServiceTaxHelper.CreatePurchaseDoc(PurchaseHeader,PurchaseLine,DocumentType,ReverseChargeTypeOption::Standard,100,FALSE);
      PartialPaymentFactor := LibraryRandom.RandDec(1,1);

      // Exercise
      PostedPurchaseDoc := ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);
      ServiceTaxSetup.FindOnDate(PurchaseLine."Service Tax Group",PurchaseHeader."Posting Date");

      PaymentAmount :=
        ReverseServiceTaxHelper.CalculatePayment(PurchaseLine."Document Type",PurchaseLine."Line Amount",ServiceTaxSetup,100);

      PostedPartialPayment := PostAndApplyPmt(PurchaseHeader,PartialPaymentFactor * PaymentAmount,PostedPurchaseDoc);
      PostedRemainingPayment := PostAndApplyPmt(PurchaseHeader,(1 - PartialPaymentFactor) * PaymentAmount,PostedPurchaseDoc);

      // Verify
      AccountNo := ReverseServiceTaxHelper.GetServTaxInterimRecAcc(ServiceTaxSetup);
      BaseAmount := ReverseServiceTaxHelper.CalculateServTaxBase(PurchaseLine."Line Amount",DocumentType);
      Amount := ReverseServiceTaxHelper.CalculateServTaxTotal(BaseAmount,ServiceTaxSetup);
      KKCAmount := ReverseServiceTaxHelper.CalculateKKCess(BaseAmount,ServiceTaxSetup);
      SBCAmount := ReverseServiceTaxHelper.CalculateSBC(BaseAmount,ServiceTaxSetup);

      ServiceTaxVerify.GLBalanceRevCharge(ServiceTaxSetup,Amount);
      ServiceTaxVerify.GLSBCBalanceRevCharge(ServiceTaxSetup,SBCAmount);
      ServiceTaxVerify.GLKKCBalanceRevCharge(ServiceTaxSetup,KKCAmount);

      AccountNo := ReverseServiceTaxHelper.GetServTaxInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,PartialPaymentFactor * Amount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(1 - PartialPaymentFactor) * Amount);
      AccountNo := ReverseServiceTaxHelper.GetServTaxSBCInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,PartialPaymentFactor * SBCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(1 - PartialPaymentFactor) * SBCAmount);
      AccountNo := ReverseServiceTaxHelper.GetKKCInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,PartialPaymentFactor * KKCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(1 - PartialPaymentFactor) * KKCAmount);

      AccountNo := ReverseServiceTaxHelper.GetServTaxPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,-PartialPaymentFactor * Amount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(PartialPaymentFactor - 1) * Amount);
      AccountNo := ReverseServiceTaxHelper.GetServTaxSBCPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,-PartialPaymentFactor * SBCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(PartialPaymentFactor - 1) * SBCAmount);
      AccountNo := ReverseServiceTaxHelper.GetKKCPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,-PartialPaymentFactor * KKCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(PartialPaymentFactor - 1) * KKCAmount);
      RevChargeCreditClosed := FALSE;
      RealCreditClosed := TRUE;
      ServiceTaxVerify.STEntryDetailsPartialPay(PostedPartialPayment,BaseAmount,ServiceTaxSetup,PartialPaymentFactor,0,FALSE,
        RevChargeCreditClosed,RealCreditClosed);
      ServiceTaxVerify.STEntryDetailsPartialPay(PostedRemainingPayment,BaseAmount,ServiceTaxSetup,1 - PartialPaymentFactor,0,FALSE,
        RevChargeCreditClosed,RealCreditClosed);

      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDoc,FALSE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPartialPayment,FALSE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedRemainingPayment,FALSE);
Member of Miscellaneous.Service Tax Verify


GLSBCBalanceReceivablesOnly@1500091 Method

The procedure GLSBCBalanceReceivablesOnly is available in codeunit 143004.

Syntax

GLSBCBalanceReceivablesOnly@1500091(
    ServiceTaxSetup@1500000 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    SBCAmount@1500001 : Decimal SBCAmount //Input parameter of type Decimal
);

Parameters

ServiceTaxSetup
Input parameter of type Record
SBCAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: GLSBC, Balance, Receivables, Only.

For a clarification about how this function works, refer to the code listed below.

      SBCGLAccountsBalance(ServiceTaxSetup,SBCAmount,0,0,0);

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      WITH GenJournalLine DO BEGIN
        ServiceTaxSetup.FindOnDate("Service Tax Group Code","Posting Date");

        RealCreditClosed := FALSE;
        ServiceTaxVerify.ServTaxEntryDetails(
          STDetailsDocumentNo,"Service Tax Base Amount (LCY)",ServiceTaxSetup,NOT RealCreditClosed,RealCreditClosed);

        "Service Tax Amount" := ReverseServiceTaxHelper.CalculateServTaxTotal("Service Tax Base Amount (LCY)",ServiceTaxSetup);
        "Service Tax SBC Amount" := ReverseServiceTaxHelper.CalculateSBC("Service Tax Base Amount (LCY)",ServiceTaxSetup);
        "KK Cess Amount" := ReverseServiceTaxHelper.CalculateKKCess("Service Tax Base Amount (LCY)",ServiceTaxSetup);

        ServiceTaxVerify.GLBalanceReceivablesOnly(ServiceTaxSetup,"Service Tax Amount");
        ServiceTaxVerify.GLSBCBalanceReceivablesOnly(ServiceTaxSetup,"Service Tax SBC Amount");
        ServiceTaxVerify.GLKKCBalanceReceivablesOnly(ServiceTaxSetup,"KK Cess Amount");
      END;
Member of Miscellaneous.Service Tax Verify


GLSBCBalanceRevCharge@1500088 Method

The procedure GLSBCBalanceRevCharge is available in codeunit 143004.

Syntax

GLSBCBalanceRevCharge@1500088(
    ServiceTaxSetup@1500000 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    SBCAmount@1500001 : Decimal SBCAmount //Input parameter of type Decimal
);

Parameters

ServiceTaxSetup
Input parameter of type Record
SBCAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: GLSBC, Balance, Rev, Charge.

For a clarification about how this function works, refer to the code listed below.

      SBCGLAccountsBalance(ServiceTaxSetup,SBCAmount,0,-SBCAmount,0);

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      Initialize;

      // Setup:
      ReverseServiceTaxHelper.CreatePurchaseDoc(PurchaseHeader,PurchaseLine,DocumentType,ReverseChargeTypeOption::Standard,100,FALSE);
      PartialPaymentFactor := LibraryRandom.RandDec(1,1);

      // Exercise
      PostedPurchaseDoc := ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);
      ServiceTaxSetup.FindOnDate(PurchaseLine."Service Tax Group",PurchaseHeader."Posting Date");

      PaymentAmount :=
        ReverseServiceTaxHelper.CalculatePayment(PurchaseLine."Document Type",PurchaseLine."Line Amount",ServiceTaxSetup,100);

      PostedPartialPayment := PostAndApplyPmt(PurchaseHeader,PartialPaymentFactor * PaymentAmount,PostedPurchaseDoc);
      PostedRemainingPayment := PostAndApplyPmt(PurchaseHeader,(1 - PartialPaymentFactor) * PaymentAmount,PostedPurchaseDoc);

      // Verify
      AccountNo := ReverseServiceTaxHelper.GetServTaxInterimRecAcc(ServiceTaxSetup);
      BaseAmount := ReverseServiceTaxHelper.CalculateServTaxBase(PurchaseLine."Line Amount",DocumentType);
      Amount := ReverseServiceTaxHelper.CalculateServTaxTotal(BaseAmount,ServiceTaxSetup);
      KKCAmount := ReverseServiceTaxHelper.CalculateKKCess(BaseAmount,ServiceTaxSetup);
      SBCAmount := ReverseServiceTaxHelper.CalculateSBC(BaseAmount,ServiceTaxSetup);

      ServiceTaxVerify.GLBalanceRevCharge(ServiceTaxSetup,Amount);
      ServiceTaxVerify.GLSBCBalanceRevCharge(ServiceTaxSetup,SBCAmount);
      ServiceTaxVerify.GLKKCBalanceRevCharge(ServiceTaxSetup,KKCAmount);

      AccountNo := ReverseServiceTaxHelper.GetServTaxInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,PartialPaymentFactor * Amount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(1 - PartialPaymentFactor) * Amount);
      AccountNo := ReverseServiceTaxHelper.GetServTaxSBCInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,PartialPaymentFactor * SBCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(1 - PartialPaymentFactor) * SBCAmount);
      AccountNo := ReverseServiceTaxHelper.GetKKCInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,PartialPaymentFactor * KKCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(1 - PartialPaymentFactor) * KKCAmount);

      AccountNo := ReverseServiceTaxHelper.GetServTaxPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,-PartialPaymentFactor * Amount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(PartialPaymentFactor - 1) * Amount);
      AccountNo := ReverseServiceTaxHelper.GetServTaxSBCPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,-PartialPaymentFactor * SBCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(PartialPaymentFactor - 1) * SBCAmount);
      AccountNo := ReverseServiceTaxHelper.GetKKCPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,-PartialPaymentFactor * KKCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(PartialPaymentFactor - 1) * KKCAmount);
      RevChargeCreditClosed := FALSE;
      RealCreditClosed := TRUE;
      ServiceTaxVerify.STEntryDetailsPartialPay(PostedPartialPayment,BaseAmount,ServiceTaxSetup,PartialPaymentFactor,0,FALSE,
        RevChargeCreditClosed,RealCreditClosed);
      ServiceTaxVerify.STEntryDetailsPartialPay(PostedRemainingPayment,BaseAmount,ServiceTaxSetup,1 - PartialPaymentFactor,0,FALSE,
        RevChargeCreditClosed,RealCreditClosed);

      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDoc,FALSE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPartialPayment,FALSE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedRemainingPayment,FALSE);
Member of Miscellaneous.Service Tax Verify


InitialRemainingCredit@1500044 Method

The procedure InitialRemainingCredit is available in codeunit 143004.

Syntax

InitialRemainingCredit@1500044(
    LastTransactionNo@1500000 : Integer LastTransactionNo, //Input parameter of type Integer
    ApplicationTransactionNo@1500002 : Integer ApplicationTransactionNo //Input parameter of type Integer
);

Parameters

LastTransactionNo
Input parameter of type Integer
ApplicationTransactionNo
Input parameter of type Integer

Remarks

The relevant search keywords are: Initial, Remaining, Credit.

For a clarification about how this function works, refer to the code listed below.

      WITH ServiceTaxEntryDetails DO BEGIN
        SETFILTER("Transaction No.",'>%1&<%2',LastTransactionNo,ApplicationTransactionNo);
        SETRANGE("Corrective Application Entry",FALSE);
        Assert.IsTrue(COUNT > 0,'No entries to check Initial Remaining Credit');
        IF FINDSET THEN
          REPEAT
            Assert.AreEqual("Service Tax Amount","Remaining Credit",
              STRSUBSTNO(InitialRemCreditErr,FIELDCAPTION("Remaining Credit"),FIELDCAPTION("Service Tax Amount")));
            Assert.AreEqual("Service Tax eCess Amount","Remaining Credit (eCess)",
              STRSUBSTNO(InitialRemCreditErr,FIELDCAPTION("Remaining Credit (eCess)"),FIELDCAPTION("Service Tax eCess Amount")));
            Assert.AreEqual("Service Tax SHE Cess Amount","Remaining Credit (SHECess)",
              STRSUBSTNO(InitialRemCreditErr,FIELDCAPTION("Remaining Credit (SHECess)"),FIELDCAPTION("Service Tax SHE Cess Amount")));
            Assert.AreEqual("KK Cess Amount","Remaining Credit (KK Cess)",
              STRSUBSTNO(InitialRemCreditErr,FIELDCAPTION("Remaining Credit (KK Cess)"),FIELDCAPTION("KK Cess Amount")));
          UNTIL NEXT = 0;
      END;

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      LastTransactionNo := Initialize;
      ReverseServiceTaxHelper.SetupCompanyInfo;

      ApplyPostAdvPaymentToDoc(ReverseChargeType::" ",TRUE,PurchaseDocumentType::Invoice,AdvPmtGenJnlLine,InvoiceGenJnlLine);
      ReverseServiceTaxHelper.UseCreditToPayForSalesDoc(InvoiceGenJnlLine."Document No.",ServiceTaxEntryDetails);

      ReverseServiceTaxHelper.UnapplyVendorLedgerEntry(InvoiceGenJnlLine."Document No.");

      ServiceTaxVerify.InitialRemainingCredit(LastTransactionNo + 1,LastTransactionNo + 3);
      ServiceTaxVerify.DocHasClosedRemCredit(AdvPmtGenJnlLine."Document No.");
Member of Miscellaneous.Service Tax Verify


KKCGLAccountsBalance@1500104 Method

The procedure KKCGLAccountsBalance is available in codeunit 143004.

Syntax

KKCGLAccountsBalance@1500104(
    ServiceTaxSetup@1500000 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    ExpectedRecBalance@1500001 : Decimal ExpectedRecBalance, //Input parameter of type Decimal
    ExpectedRecInterimBalance@1500002 : Decimal ExpectedRecInterimBalance, //Input parameter of type Decimal
    ExpectedPayBalance@1500003 : Decimal ExpectedPayBalance, //Input parameter of type Decimal
    ExpectedPayInterimBalance@1500004 : Decimal ExpectedPayInterimBalance //Input parameter of type Decimal
);

Parameters

ServiceTaxSetup
Input parameter of type Record
ExpectedRecBalance
Input parameter of type Decimal
ExpectedRecInterimBalance
Input parameter of type Decimal
ExpectedPayBalance
Input parameter of type Decimal
ExpectedPayInterimBalance
Input parameter of type Decimal

Remarks

The relevant search keywords are: KKCGL, Accounts, Balance.

For a clarification about how this function works, refer to the code listed below.

      KKCRecAccBalance(ServiceTaxSetup,ExpectedRecBalance);
      KKCRecInterimAccBalance(ServiceTaxSetup,ExpectedRecInterimBalance);
      KKCPayAccBalance(ServiceTaxSetup,ExpectedPayBalance);
      KKCPayInterimAccBalance(ServiceTaxSetup,ExpectedPayInterimBalance);

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      Initialize;

      // Exercise
      PostPmtAppliedToInvPoT(DocumentType,PoT,PurchaseLine,PostedPurchaseDocNo,PostedPaymentDocNo,ServiceTaxSetup);

      // Verify
      BaseAmount := ReverseServiceTaxHelper.CalculateServTaxBase(PurchaseLine."Line Amount",DocumentType);
      Amount := ReverseServiceTaxHelper.CalculateServTaxTotal(BaseAmount,ServiceTaxSetup);
      KKCAmount := ReverseServiceTaxHelper.CalculateKKCess(BaseAmount,ServiceTaxSetup);
      SBCAmount := ReverseServiceTaxHelper.CalculateSBC(BaseAmount,ServiceTaxSetup);
      RevChargeCreditClosed := TRUE;
      RealCreditClosed := FALSE;

      IF PoT THEN
        ServiceTaxVerify.ServiceTaxEntries(PostedPurchaseDocNo,BaseAmount,ServiceTaxSetup,RevChargeCreditClosed,RealCreditClosed)
      ELSE BEGIN
        ServiceTaxVerify.ServTaxEntry(PostedPurchaseDocNo,BaseAmount,ServiceTaxSetup);
        ServiceTaxVerify.ServTaxEntryDetails(PostedPaymentDocNo,BaseAmount,ServiceTaxSetup,RevChargeCreditClosed,RealCreditClosed);
      END;

      ServiceTaxVerify.ServTaxGLAccountsBalance(ServiceTaxSetup,Amount,0,0,0);
      ServiceTaxVerify.KKCGLAccountsBalance(ServiceTaxSetup,KKCAmount,0,0,0);
      ServiceTaxVerify.SBCGLAccountsBalance(ServiceTaxSetup,SBCAmount,0,0,0);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDocNo,FALSE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPaymentDocNo,FALSE);
Member of Miscellaneous.Service Tax Verify


KKCPayAccBalance@1500119 Method

The procedure KKCPayAccBalance is available in codeunit 143004.

Syntax

KKCPayAccBalance@1500119(
    ServiceTaxSetup@1500003 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    Amount@1500001 : Decimal Amount //Input parameter of type Decimal
);

Parameters

ServiceTaxSetup
Input parameter of type Record
Amount
Input parameter of type Decimal

Remarks

The relevant search keywords are: KKC, Pay, Account, Balance.

For a clarification about how this function works, refer to the code listed below.

      AccountBalance(ReverseServiceTaxHelper.GetKKCPayAcc(ServiceTaxSetup),Amount);

Example

There are no examples available.
Member of Miscellaneous.Service Tax Verify


KKCPayInterimAccBalance@1500117 Method

The procedure KKCPayInterimAccBalance is available in codeunit 143004.

Syntax

KKCPayInterimAccBalance@1500117(
    ServiceTaxSetup@1500002 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    Amount@1500000 : Decimal Amount //Input parameter of type Decimal
);

Parameters

ServiceTaxSetup
Input parameter of type Record
Amount
Input parameter of type Decimal

Remarks

The relevant search keywords are: KKC, Pay, Interim, Account, Balance.

For a clarification about how this function works, refer to the code listed below.

      AccountBalance(ReverseServiceTaxHelper.GetKKCInterimPayAcc(ServiceTaxSetup),Amount);

Example

There are no examples available.
Member of Miscellaneous.Service Tax Verify


KKCRecAccBalance@1500116 Method

The procedure KKCRecAccBalance is available in codeunit 143004.

Syntax

KKCRecAccBalance@1500116(
    ServiceTaxSetup@1500002 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    Amount@1500000 : Decimal Amount //Input parameter of type Decimal
);

Parameters

ServiceTaxSetup
Input parameter of type Record
Amount
Input parameter of type Decimal

Remarks

The relevant search keywords are: KKC, Rec, Account, Balance.

For a clarification about how this function works, refer to the code listed below.

      AccountBalance(ReverseServiceTaxHelper.GetKKCRecAcc(ServiceTaxSetup),Amount);

Example

The below example is extracted from the test automation codeunit 144044 to show one way of using this function.

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      ServiceTaxVerify.STRecAccBalance(ServiceTaxSetup,0);
      ServiceTaxVerify.STRecInterimAccBalance(ServiceTaxSetup,0);
      ServiceTaxVerify.SBCRecAccBalance(ServiceTaxSetup,0);
      ServiceTaxVerify.SBCRecInterimAccBalance(ServiceTaxSetup,0);
      ServiceTaxVerify.KKCRecAccBalance(ServiceTaxSetup,0);
      ServiceTaxVerify.KKCRecInterimAccBalance(ServiceTaxSetup,0);
      ServiceTaxVerify.STEntryDtlsFullTaxBalance(LastTransactionNo,0);
      ServiceTaxVerify.STEntryDtlsSBCBalance(LastTransactionNo,0);
      ServiceTaxVerify.STEntryDtlsKKCBalance(LastTransactionNo,0);

      ServiceTaxVerify.STEntryDetailsRemainingCredit(LastTransactionNo,0);
      ServiceTaxVerify.STEntryDetailsKKCRemainingCredit(LastTransactionNo,0);

      ServiceTaxVerify.PostedInvoiceRounding(GenJournalLine."Posting Group",LastTransactionNo);
Member of Miscellaneous.Service Tax Verify


KKCRecAccBalanceNearly@1500130 Method

The procedure KKCRecAccBalanceNearly is available in codeunit 143004.

Syntax

KKCRecAccBalanceNearly@1500130(
    ServiceTaxSetup@1500002 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    Amount@1500000 : Decimal Amount //Input parameter of type Decimal
);

Parameters

ServiceTaxSetup
Input parameter of type Record
Amount
Input parameter of type Decimal

Remarks

The relevant search keywords are: KKC, Rec, Account, Balance, Nearly.

For a clarification about how this function works, refer to the code listed below.

      AccountNo := ReverseServiceTaxHelper.GetKKCRecAcc(ServiceTaxSetup);
      GLAccount.GET(AccountNo);
      GLAccount.CALCFIELDS(Balance);

      GLSetup.GET;
      Assert.AreNearlyEqual(
        Amount,GLAccount.Balance,GLSetup."Service Tax Rounding Precision",STRSUBSTNO(AccBalanceErr,GLAccount."No."));

Example

There are no examples available.
Member of Miscellaneous.Service Tax Verify


KKCRecInterimAccBalance@1500114 Method

The procedure KKCRecInterimAccBalance is available in codeunit 143004.

Syntax

KKCRecInterimAccBalance@1500114(
    ServiceTaxSetup@1500003 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    Amount@1500002 : Decimal Amount //Input parameter of type Decimal
);

Parameters

ServiceTaxSetup
Input parameter of type Record
Amount
Input parameter of type Decimal

Remarks

The relevant search keywords are: KKC, Rec, Interim, Account, Balance.

For a clarification about how this function works, refer to the code listed below.

      AccountBalance(ReverseServiceTaxHelper.GetKKCInterimRecAcc(ServiceTaxSetup),Amount);

Example

The below example is extracted from the test automation codeunit 144044 to show one way of using this function.

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      ServiceTaxVerify.STRecAccBalance(ServiceTaxSetup,0);
      ServiceTaxVerify.STRecInterimAccBalance(ServiceTaxSetup,0);
      ServiceTaxVerify.SBCRecAccBalance(ServiceTaxSetup,0);
      ServiceTaxVerify.SBCRecInterimAccBalance(ServiceTaxSetup,0);
      ServiceTaxVerify.KKCRecAccBalance(ServiceTaxSetup,0);
      ServiceTaxVerify.KKCRecInterimAccBalance(ServiceTaxSetup,0);
      ServiceTaxVerify.STEntryDtlsFullTaxBalance(LastTransactionNo,0);
      ServiceTaxVerify.STEntryDtlsSBCBalance(LastTransactionNo,0);
      ServiceTaxVerify.STEntryDtlsKKCBalance(LastTransactionNo,0);

      ServiceTaxVerify.STEntryDetailsRemainingCredit(LastTransactionNo,0);
      ServiceTaxVerify.STEntryDetailsKKCRemainingCredit(LastTransactionNo,0);

      ServiceTaxVerify.PostedInvoiceRounding(GenJournalLine."Posting Group",LastTransactionNo);
Member of Miscellaneous.Service Tax Verify


PostedAdvPayment@1500031 Method

The procedure PostedAdvPayment is available in codeunit 143004.

Syntax

PostedAdvPayment@1500031(
    GenJournalLine@1500008 : Record 81 GenJournalLine, //Input parameter of type Record
    TypeOfReverseCharge@1500000 : Option TypeOfReverseCharge, //Input parameter of type Option
    PoT@1500007 : Boolean PoT //Input parameter of type Boolean
);

Parameters

GenJournalLine
Input parameter of type Record
TypeOfReverseCharge
Input parameter of type Option
PoT
Input parameter of type Boolean

Remarks

The relevant search keywords are: Posted, Adv, Payment.

For a clarification about how this function works, refer to the code listed below.

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      ReverseServiceTaxHelper.GetBaseAndTaxAmountFromAdvPmt(
        BaseAmount,TaxAmount,ServiceTaxSetup,GenJournalLine.Amount,TypeOfReverseCharge,100);
      SBCandKKcAmount := ReverseServiceTaxHelper.CalculateKKCess(BaseAmount,ServiceTaxSetup) +
        ReverseServiceTaxHelper.CalculateSBC(BaseAmount,ServiceTaxSetup);
      PostedAdvPaymentGLBalance(ServiceTaxSetup,GenJournalLine."Document No.",TypeOfReverseCharge,PoT,TaxAmount);

      VendorAndServicesEntries(GenJournalLine."Document No.",GenJournalLine."Account No.",
        ReverseServiceTaxHelper.GetBankAccGLPostingAcc(GenJournalLine."Bal. Account No."),TRUE,-
        BaseAmount,-(TaxAmount + SBCandKKcAmount),
        TypeOfReverseCharge,FALSE);
      IF NOT PoT THEN
        ReverseServiceTaxHelper.GetBaseAndTaxAmountFromAdvPmt(
          BaseAmount,TaxAmount,ServiceTaxSetup,GenJournalLine.Amount,TypeOfReverseCharge,100);
      // Service Tax Entry is created.
      ServTaxEntry(GenJournalLine."Document No.",BaseAmount,ServiceTaxSetup);

      // If PoT or Reverse Charge, then Service Tax Entry Details is created
      IF PoT OR (TypeOfReverseCharge <> ReverseChargeType::" ") THEN BEGIN
        RevChargeCreditClosed := PoT;
        RealCreditClosed := NOT PoT;
        ServTaxEntryDetails(GenJournalLine."Document No.",BaseAmount,ServiceTaxSetup,RevChargeCreditClosed,RealCreditClosed);
      END;

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      Initialize;
      TypeOfReverseCharge := ReverseChargeType::" ";
      PoT := TRUE;

      // Post advance payment
      PostAdvancePaymentFwdCalc(GenJournalLine,TypeOfReverseCharge,PoT);

      // Verify
      ServiceTaxVerify.PostedAdvPayment(GenJournalLine,TypeOfReverseCharge,PoT);
Member of Miscellaneous.Service Tax Verify


PostedAdvPaymentBackCalc@1500101 Method

The procedure PostedAdvPaymentBackCalc is available in codeunit 143004.

Syntax

PostedAdvPaymentBackCalc@1500101(
    GenJournalLine@1500008 : Record 81 GenJournalLine, //Input parameter of type Record
    TypeOfReverseCharge@1500000 : Option TypeOfReverseCharge, //Input parameter of type Option
    PoT@1500007 : Boolean PoT //Input parameter of type Boolean
);

Parameters

GenJournalLine
Input parameter of type Record
TypeOfReverseCharge
Input parameter of type Option
PoT
Input parameter of type Boolean

Remarks

The relevant search keywords are: Posted, Adv, Payment, Back, Calc.

For a clarification about how this function works, refer to the code listed below.

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      ReverseServiceTaxHelper.GetBaseAndTaxAmountFromAdvPmt(
        BaseAmount,TaxAmount,ServiceTaxSetup,GenJournalLine.Amount,TypeOfReverseCharge,100);
      PostedAdvPaymentGLBalance(ServiceTaxSetup,GenJournalLine."Document No.",TypeOfReverseCharge,PoT,TaxAmount);
      ReverseServiceTaxHelper.GetKKCAndSBCmountFromAdvPmt(
        BaseAmount,SBCAmount,KKCAmount,ServiceTaxSetup,GenJournalLine.Amount,TypeOfReverseCharge,100);
      VendorAndServicesEntries(
        GenJournalLine."Document No.",GenJournalLine."Account No.",
        ReverseServiceTaxHelper.GetBankAccGLPostingAcc(GenJournalLine."Bal. Account No."),TRUE,-
        BaseAmount,-(TaxAmount + SBCAmount + KKCAmount),
        TypeOfReverseCharge,FALSE);
      IF NOT PoT THEN
        ReverseServiceTaxHelper.GetBaseAndTaxAmountFromAdvPmt(
          BaseAmount,TaxAmount,ServiceTaxSetup,GenJournalLine.Amount,TypeOfReverseCharge,100);
      // Service Tax Entry is created.
      ServTaxEntry(GenJournalLine."Document No.",BaseAmount,ServiceTaxSetup);

      // If PoT or Reverse Charge, then Service Tax Entry Details is created
      IF PoT OR (TypeOfReverseCharge <> ReverseChargeType::" ") THEN BEGIN
        RevChargeCreditClosed := PoT;
        RealCreditClosed := NOT PoT;
        ServTaxEntryDetails(GenJournalLine."Document No.",BaseAmount,ServiceTaxSetup,RevChargeCreditClosed,RealCreditClosed);
      END;

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      Initialize;

      // Post advance payment
      PostAdvancePayment(GenJournalLine,TypeOfReverseCharge,PoT);

      // Verify
      IF PoT THEN
        ServiceTaxVerify.PostedAdvPaymentBackCalc(GenJournalLine,TypeOfReverseCharge,PoT)
      ELSE
        ServiceTaxVerify.PostedAdvPayment(GenJournalLine,TypeOfReverseCharge,PoT);
Member of Miscellaneous.Service Tax Verify


PostedAdvPmtAndInvGLBalance@1500038 Method

The procedure PostedAdvPmtAndInvGLBalance is available in codeunit 143004.

Syntax

PostedAdvPmtAndInvGLBalance@1500038(
    ServiceTaxSetup@1500001 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    RevChargeType@1500003 : Option RevChargeType, //Input parameter of type Option
    PoT@1500004 : Boolean PoT, //Input parameter of type Boolean
    Amount@1500000 : Decimal Amount //Input parameter of type Decimal
);

Parameters

ServiceTaxSetup
Input parameter of type Record
RevChargeType
Input parameter of type Option
PoT
Input parameter of type Boolean
Amount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Posted, Adv, Payment, Invoice, General Ledger, Balance.

For a clarification about how this function works, refer to the code listed below.

      IF RevChargeType <> ReverseChargeType::" " THEN
        ServTaxGLAccountsBalance(ServiceTaxSetup,0,2 * Amount,-Amount,-Amount)
      ELSE
        IF PoT THEN
          ServTaxGLAccountsBalance(ServiceTaxSetup,2 * Amount,-Amount,0,0)
        ELSE
          ServTaxGLAccountsBalance(ServiceTaxSetup,0,Amount,0,0)

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      ServiceTaxVerify.UnappliedAdvSTEntryDetBalances(
        PaymentBaseAmount,PaymentGenJournalLine."Document Type",LastTransactionNo,PaymentGenJournalLine."Service Tax Group Code",
        PaymentGenJournalLine."Posting Date",RevChargeType,PoT);

      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDocNo,TRUE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PaymentGenJournalLine."Document No.",TRUE);
      ServiceTaxSetup.FindOnDate(PaymentGenJournalLine."Service Tax Group Code",PaymentGenJournalLine."Posting Date");
      ServiceTaxVerify.PostedAdvPmtAndInvGLBalance(ServiceTaxSetup,RevChargeType,PoT,PaymentTaxAmount);
      ServiceTaxVerify.UnappliedSTEntryDetails(ApplyTransactionNo);
Member of Miscellaneous.Service Tax Verify


PostedAdvPmtAndInvGLBalPartial@1500054 Method

The procedure PostedAdvPmtAndInvGLBalPartial is available in codeunit 143004.

Syntax

PostedAdvPmtAndInvGLBalPartial@1500054(
    ServiceTaxSetup@1500001 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    RevChargeType@1500003 : Option RevChargeType, //Input parameter of type Option
    DocumentType@1500007 : Option DocumentType, //Input parameter of type Option
    PoT@1500004 : Boolean PoT, //Input parameter of type Boolean
    AdvPmtAmount@1500000 : Decimal AdvPmtAmount, //Input parameter of type Decimal
    InvAmount@1500002 : Decimal InvAmount //Input parameter of type Decimal
);

Parameters

ServiceTaxSetup
Input parameter of type Record
RevChargeType
Input parameter of type Option
DocumentType
Input parameter of type Option
PoT
Input parameter of type Boolean
AdvPmtAmount
Input parameter of type Decimal
InvAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Posted, Adv, Payment, Invoice, General Ledger, Bal, Partial.

For a clarification about how this function works, refer to the code listed below.

      AdvPmtServTaxAmount := ReverseServiceTaxHelper.CalculateServTaxAmount(ServiceTaxSetup,AdvPmtAmount,DocumentType);
      AdvPmtSBCAmount := ReverseServiceTaxHelper.CalculateServTaxSBCAmount(ServiceTaxSetup,AdvPmtAmount,DocumentType);
      AdvPmtKKCAmount := ReverseServiceTaxHelper.CalculateKKCAmount(ServiceTaxSetup,AdvPmtAmount,DocumentType);
      InvServTaxAmount := ReverseServiceTaxHelper.CalculateServTaxAmount(ServiceTaxSetup,InvAmount,DocumentType);
      InvSBCAmount := ReverseServiceTaxHelper.CalculateServTaxSBCAmount(ServiceTaxSetup,InvAmount,DocumentType);
      InvKKCAmount := ReverseServiceTaxHelper.CalculateKKCAmount(ServiceTaxSetup,InvAmount,DocumentType);

      IF RevChargeType <> ReverseChargeType::" " THEN BEGIN
        ServTaxGLAccountsBalance(ServiceTaxSetup,0,AdvPmtServTaxAmount + InvServTaxAmount,-AdvPmtServTaxAmount,-InvServTaxAmount);
        SBCGLAccountsBalance(ServiceTaxSetup,InvSBCAmount,AdvPmtSBCAmount,-AdvPmtSBCAmount,-InvSBCAmount);
        KKCGLAccountsBalance(ServiceTaxSetup,0,AdvPmtKKCAmount + InvKKCAmount,-AdvPmtKKCAmount,-InvKKCAmount);
      END ELSE
        IF PoT THEN BEGIN
          ServTaxGLAccountsBalance(ServiceTaxSetup,AdvPmtServTaxAmount + InvServTaxAmount,-AdvPmtServTaxAmount,0,0);
          SBCGLAccountsBalance(ServiceTaxSetup,AdvPmtSBCAmount + InvSBCAmount,-AdvPmtSBCAmount,0,0);
          KKCGLAccountsBalance(ServiceTaxSetup,AdvPmtKKCAmount + InvKKCAmount,-AdvPmtKKCAmount,0,0);
        END ELSE BEGIN
          ServTaxGLAccountsBalance(ServiceTaxSetup,0,InvServTaxAmount,0,0);
          SBCGLAccountsBalance(ServiceTaxSetup,InvSBCAmount,0,0,0);
          KKCGLAccountsBalance(ServiceTaxSetup,0,InvKKCAmount,0,0);
        END;

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      ServiceTaxVerify.UnappAdvPmtPartialSTEntrDetBal(
        PaymentBaseAmount,InvoiceBaseAmount,DocumentType,LastTransactionNo,
        PaymentGenJournalLine."Service Tax Group Code",PaymentGenJournalLine."Posting Date",RevChargeType,PoT);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDocNo,TRUE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PaymentGenJournalLine."Document No.",TRUE);

      ServiceTaxSetup.FindOnDate(PaymentGenJournalLine."Service Tax Group Code",PaymentGenJournalLine."Posting Date");
      ServiceTaxVerify.PostedAdvPmtAndInvGLBalPartial(
        ServiceTaxSetup,RevChargeType,DocumentType,PoT,PaymentBaseAmount,InvoiceBaseAmount);

      ServiceTaxVerify.UnappliedSTEntryDetails(ApplyTransactionNo);
Member of Miscellaneous.Service Tax Verify


PostedInvoiceRounding@1500075 Method

The procedure PostedInvoiceRounding is available in codeunit 143004.

Syntax

PostedInvoiceRounding@1500075(
    PostingGroup@1500000 : Code[10] PostingGroup, //Input parameter of type Code
    LastTransactionNo@1500001 : Integer LastTransactionNo //Input parameter of type Integer
);

Parameters

PostingGroup
Input parameter of type Code
LastTransactionNo
Input parameter of type Integer

Remarks

The relevant search keywords are: Posted, Invoice, Rounding.

For a clarification about how this function works, refer to the code listed below.

      GLSetup.GET;
      WITH GLEntry DO BEGIN
        SETFILTER("Transaction No.",'>%1',LastTransactionNo);
        SETRANGE("G/L Account No.",GetInvoiceRoundingAccNo(PostingGroup));
        IF FINDSET THEN
          REPEAT
            Assert.AreNearlyEqual(0,Amount,GLSetup."Service Tax Rounding Precision",TooBigInvoiceRoundingErr);
          UNTIL NEXT = 0;
      END;

Example

The below example is extracted from the test automation codeunit 144044 to show one way of using this function.

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      ServiceTaxVerify.STRecAccBalance(ServiceTaxSetup,0);
      ServiceTaxVerify.STRecInterimAccBalance(ServiceTaxSetup,0);
      ServiceTaxVerify.SBCRecAccBalance(ServiceTaxSetup,0);
      ServiceTaxVerify.SBCRecInterimAccBalance(ServiceTaxSetup,0);
      ServiceTaxVerify.KKCRecAccBalance(ServiceTaxSetup,0);
      ServiceTaxVerify.KKCRecInterimAccBalance(ServiceTaxSetup,0);
      ServiceTaxVerify.STEntryDtlsFullTaxBalance(LastTransactionNo,0);
      ServiceTaxVerify.STEntryDtlsSBCBalance(LastTransactionNo,0);
      ServiceTaxVerify.STEntryDtlsKKCBalance(LastTransactionNo,0);

      ServiceTaxVerify.STEntryDetailsRemainingCredit(LastTransactionNo,0);
      ServiceTaxVerify.STEntryDetailsKKCRemainingCredit(LastTransactionNo,0);

      ServiceTaxVerify.PostedInvoiceRounding(GenJournalLine."Posting Group",LastTransactionNo);
Member of Miscellaneous.Service Tax Verify


PostedPmtAndInvGLBalPartial@1500062 Method

The procedure PostedPmtAndInvGLBalPartial is available in codeunit 143004.

Syntax

PostedPmtAndInvGLBalPartial@1500062(
    ServiceTaxSetup@1500001 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    RevChargeType@1500003 : Option RevChargeType, //Input parameter of type Option
    PoT@1500004 : Boolean PoT, //Input parameter of type Boolean
    InvoiceTaxAmount@1500000 : Decimal InvoiceTaxAmount, //Input parameter of type Decimal
    PaymentTaxAmount@1500002 : Decimal PaymentTaxAmount //Input parameter of type Decimal
);

Parameters

ServiceTaxSetup
Input parameter of type Record
RevChargeType
Input parameter of type Option
PoT
Input parameter of type Boolean
InvoiceTaxAmount
Input parameter of type Decimal
PaymentTaxAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Posted, Payment, Invoice, General Ledger, Bal, Partial.

For a clarification about how this function works, refer to the code listed below.

      IF RevChargeType <> ReverseChargeType::" " THEN
        ServTaxGLAccountsBalance(ServiceTaxSetup,0,InvoiceTaxAmount,-PaymentTaxAmount,PaymentTaxAmount - InvoiceTaxAmount)
      ELSE
        IF PoT THEN
          ServTaxGLAccountsBalance(ServiceTaxSetup,InvoiceTaxAmount,0,0,0)
        ELSE
          ServTaxGLAccountsBalance(ServiceTaxSetup,PaymentTaxAmount,InvoiceTaxAmount - PaymentTaxAmount,0,0)

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      ServiceTaxSetup.FindOnDate(PurchaseLine."Service Tax Group",PurchaseHeader."Posting Date");

      IF RevChargeType = ReverseChargeTypeOption::" " THEN
        BaseAmount := ReverseServiceTaxHelper.CalcServTaxBaseAmountBackward(BaseAmount,ServiceTaxSetup,0);

      InvoiceTaxAmount := ReverseServiceTaxHelper.CalculateServTaxAmount(ServiceTaxSetup,BaseAmount,DocumentType);

      FirstPaymentTaxAmount := ReverseServiceTaxHelper.RoundServTax(PartialPaymentFactor * InvoiceTaxAmount);
      SecondPaymentTaxAmount := ReverseServiceTaxHelper.RoundServTax((1 - PartialPaymentFactor) * InvoiceTaxAmount);

      SBCAmount :=
        ReverseServiceTaxHelper.CalculateServTaxSBCAmount(ServiceTaxSetup,BaseAmount,DocumentType);
      KKCAmount :=
        ReverseServiceTaxHelper.CalculateKKCAmount(ServiceTaxSetup,BaseAmount,DocumentType);

      FirstPaymentSBCAmount := ReverseServiceTaxHelper.RoundServTax(PartialPaymentFactor * SBCAmount);
      FirstPaymentKKCAmount := ReverseServiceTaxHelper.RoundServTax(PartialPaymentFactor * KKCAmount);
      SecondPaymentSBCAmount := ReverseServiceTaxHelper.RoundServTax((1 - PartialPaymentFactor) * SBCAmount);
      SecondPaymentKKCAmount := ReverseServiceTaxHelper.RoundServTax((1 - PartialPaymentFactor) * KKCAmount);

      ServiceTaxVerify.CountOfUnappliedEntries(ApplyTransactionNo);

      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDoc,TRUE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedRemainingPayment,TRUE);

      ServiceTaxVerify.UnappPmtRemainSTEntryDetBal(FirstPaymentTaxAmount,SecondPaymentTaxAmount,LastTransactionNo,RevChargeType,PoT);
      ServiceTaxVerify.UnappPmtRemainSTSBCKKCEntryDetBal(FirstPaymentSBCAmount,SecondPaymentSBCAmount,
        FirstPaymentKKCAmount,SecondPaymentKKCAmount,
        LastTransactionNo,RevChargeType,PoT);

      IF RevChargeType = ReverseChargeTypeOption::" " THEN
        ServiceTaxVerify.VendorLedgerEntryRemAmt(
          PostedPurchaseDoc,-((1 - PartialPaymentFactor) * (BaseAmount + InvoiceTaxAmount + SBCAmount + KKCAmount)))
      ELSE
        ServiceTaxVerify.VendorLedgerEntryRemAmt(PostedPurchaseDoc,-((1 - PartialPaymentFactor) * BaseAmount));

      ServiceTaxVerify.PostedPmtAndInvGLBalPartial(
        ServiceTaxSetup,RevChargeType,PoT,InvoiceTaxAmount,FirstPaymentTaxAmount);
      ServiceTaxVerify.PostedSBCKKCPmtAndInvGLBalPartial(
        ServiceTaxSetup,RevChargeType,PoT,SBCAmount,FirstPaymentSBCAmount,KKCAmount,FirstPaymentKKCAmount);
Member of Miscellaneous.Service Tax Verify


PostedPurchDocGLBalance@1500045 Method

The procedure PostedPurchDocGLBalance is available in codeunit 143004.

Syntax

PostedPurchDocGLBalance@1500045(
    ServiceTaxSetup@1500001 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    RevChargeType@1500003 : Option RevChargeType, //Input parameter of type Option
    PoT@1500004 : Boolean PoT, //Input parameter of type Boolean
    Amount@1500000 : Decimal Amount //Input parameter of type Decimal
);

Parameters

ServiceTaxSetup
Input parameter of type Record
RevChargeType
Input parameter of type Option
PoT
Input parameter of type Boolean
Amount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Posted, Purchase, Document, General Ledger, Balance.

For a clarification about how this function works, refer to the code listed below.

      IF RevChargeType <> ReverseChargeType::" " THEN
        ServTaxGLAccountsBalance(ServiceTaxSetup,0,Amount,0,-Amount)
      ELSE
        IF PoT THEN
          GLBalanceReceivablesOnly(ServiceTaxSetup,Amount)
        ELSE
          ServTaxGLAccountsBalance(ServiceTaxSetup,0,Amount,0,0);

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      LastTransactionNo := Initialize;

      // Setup:
      PoT := ReverseChargeType = ReverseChargeTypeOption::" ";
      ReverseServiceTaxHelper.CreatePurchaseDoc(
        PurchaseHeader,PurchaseLine,PurchaseHeader."Document Type"::Invoice,ReverseChargeType,100,PoT);

      // Exercise
      PostedDocNo1 := ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);
      PostedDocNo2 := PostAndApplyCrMemo(PurchaseHeader,PostedDocNo1,InvAmountIs);

      // Verify
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedDocNo1,InvAmountIs = InvoiceAmountIs::Greater);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedDocNo2,InvAmountIs = InvoiceAmountIs::Smaller);

      ServiceTaxSetup.FindOnDate(PurchaseLine."Service Tax Group",PurchaseHeader."Posting Date");
      InvoiceBaseAmount := ReverseServiceTaxHelper.CalculateServTaxBase(PurchaseLine."Line Amount",PurchaseHeader."Document Type");
      InvoiceTaxAmount := ReverseServiceTaxHelper.CalculateServTaxTotal(InvoiceBaseAmount,ServiceTaxSetup);
      CrMemoBaseAmount := -InvoiceBaseAmount / ReverseServiceTaxHelper.GetPurchInvAmountFactor(InvAmountIs);
      CrMemoTaxAmount := ReverseServiceTaxHelper.CalculateServTaxTotal(CrMemoBaseAmount,ServiceTaxSetup);

      ServiceTaxVerify.ServTaxEntry(PostedDocNo1,InvoiceBaseAmount,ServiceTaxSetup);
      ServiceTaxVerify.ServTaxEntry(PostedDocNo2,CrMemoBaseAmount,ServiceTaxSetup);

      ServiceTaxVerify.PostedPurchDocGLBalance(ServiceTaxSetup,ReverseChargeType,PoT,InvoiceTaxAmount + CrMemoTaxAmount);

      IF ReverseChargeType = ReverseChargeTypeOption::" " THEN
        IF PoT THEN BEGIN
          ServiceTaxVerify.STEntryDetailsRemainingCredit(LastTransactionNo,InvoiceTaxAmount + CrMemoTaxAmount);
          ServiceTaxVerify.ServTaxEntriesArePaid(ReverseServiceTaxHelper.GetLastTransactionNo);
        END ELSE
          ServiceTaxVerify.STEntryDetailsRemainingCredit(LastTransactionNo,0)
      ELSE
        ServiceTaxVerify.STEntryDetailsRemRevChrgCredit(LastTransactionNo,0);

      IF InvAmountIs = InvoiceAmountIs::Greater THEN
        SmallerDocumentNo := PostedDocNo2
      ELSE
        SmallerDocumentNo := PostedDocNo1;
      ServiceTaxVerify.DocHasClosedRemCredit(SmallerDocumentNo);
Member of Miscellaneous.Service Tax Verify


PostedPurchDocGLKKCBalance@1500094 Method

The procedure PostedPurchDocGLKKCBalance is available in codeunit 143004.

Syntax

PostedPurchDocGLKKCBalance@1500094(
    ServiceTaxSetup@1500001 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    RevChargeType@1500003 : Option RevChargeType, //Input parameter of type Option
    PoT@1500004 : Boolean PoT, //Input parameter of type Boolean
    Amount@1500000 : Decimal Amount //Input parameter of type Decimal
);

Parameters

ServiceTaxSetup
Input parameter of type Record
RevChargeType
Input parameter of type Option
PoT
Input parameter of type Boolean
Amount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Posted, Purchase, Document, GLKKC, Balance.

For a clarification about how this function works, refer to the code listed below.

      IF RevChargeType <> ReverseChargeType::" " THEN
        KKCGLAccountsBalance(ServiceTaxSetup,0,Amount,0,-Amount)
      ELSE
        IF PoT THEN
          GLKKCBalanceReceivablesOnly(ServiceTaxSetup,Amount)
        ELSE
          KKCGLAccountsBalance(ServiceTaxSetup,0,Amount,0,0);

Example

There are no examples available.
Member of Miscellaneous.Service Tax Verify


PostedPurchDocGLSBCBalance@1500093 Method

The procedure PostedPurchDocGLSBCBalance is available in codeunit 143004.

Syntax

PostedPurchDocGLSBCBalance@1500093(
    ServiceTaxSetup@1500001 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    RevChargeType@1500003 : Option RevChargeType, //Input parameter of type Option
    PoT@1500004 : Boolean PoT, //Input parameter of type Boolean
    Amount@1500000 : Decimal Amount //Input parameter of type Decimal
);

Parameters

ServiceTaxSetup
Input parameter of type Record
RevChargeType
Input parameter of type Option
PoT
Input parameter of type Boolean
Amount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Posted, Purchase, Document, GLSBC, Balance.

For a clarification about how this function works, refer to the code listed below.

      IF RevChargeType <> ReverseChargeType::" " THEN
        SBCGLAccountsBalance(ServiceTaxSetup,Amount,0,0,-Amount)
      ELSE
        IF PoT THEN
          GLSBCBalanceReceivablesOnly(ServiceTaxSetup,Amount)
        ELSE
          SBCGLAccountsBalance(ServiceTaxSetup,Amount,0,0,0);

Example

There are no examples available.
Member of Miscellaneous.Service Tax Verify


PostedSBCKKCAdvPmtAndInvGLBalance@1500106 Method

The procedure PostedSBCKKCAdvPmtAndInvGLBalance is available in codeunit 143004.

Syntax

PostedSBCKKCAdvPmtAndInvGLBalance@1500106(
    ServiceTaxSetup@1500001 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    RevChargeType@1500003 : Option RevChargeType, //Input parameter of type Option
    PoT@1500004 : Boolean PoT, //Input parameter of type Boolean
    SBCAmount@1500000 : Decimal SBCAmount, //Input parameter of type Decimal
    KKCAmount@1500002 : Decimal KKCAmount //Input parameter of type Decimal
);

Parameters

ServiceTaxSetup
Input parameter of type Record
RevChargeType
Input parameter of type Option
PoT
Input parameter of type Boolean
SBCAmount
Input parameter of type Decimal
KKCAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Posted, SBCKKC, Adv, Payment, Invoice, General Ledger, Balance.

For a clarification about how this function works, refer to the code listed below.

      IF RevChargeType <> ReverseChargeType::" " THEN BEGIN
        SBCGLAccountsBalance(ServiceTaxSetup,SBCAmount,SBCAmount,-SBCAmount,-SBCAmount);
        KKCGLAccountsBalance(ServiceTaxSetup,0,2 * KKCAmount,-KKCAmount,-KKCAmount);
      END ELSE
        IF PoT THEN BEGIN
          SBCGLAccountsBalance(ServiceTaxSetup,2 * SBCAmount,-SBCAmount,0,0);
          KKCGLAccountsBalance(ServiceTaxSetup,2 * KKCAmount,-KKCAmount,0,0);
        END ELSE BEGIN
          SBCGLAccountsBalance(ServiceTaxSetup,SBCAmount,0,0,0);
          KKCGLAccountsBalance(ServiceTaxSetup,0,KKCAmount,0,0);
        END;

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      ServiceTaxSetup.FindOnDate(PaymentGenJournalLine."Service Tax Group Code",PaymentGenJournalLine."Posting Date");
      ServiceTaxVerify.PostedSBCKKCAdvPmtAndInvGLBalance(ServiceTaxSetup,RevChargeType,PoT,PaymentSBCAmount,PaymentKKCAmount);
Member of Miscellaneous.Service Tax Verify


PostedSBCKKCPmtAndInvGLBalPartial@1500100 Method

The procedure PostedSBCKKCPmtAndInvGLBalPartial is available in codeunit 143004.

Syntax

PostedSBCKKCPmtAndInvGLBalPartial@1500100(
    ServiceTaxSetup@1500001 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    RevChargeType@1500003 : Option RevChargeType, //Input parameter of type Option
    PoT@1500004 : Boolean PoT, //Input parameter of type Boolean
    SBCInvoiceTaxAmount@1500000 : Decimal SBCInvoiceTaxAmount, //Input parameter of type Decimal
    SBCPaymentTaxAmount@1500002 : Decimal SBCPaymentTaxAmount, //Input parameter of type Decimal
    KKCInvoiceTaxAmount@1500006 : Decimal KKCInvoiceTaxAmount, //Input parameter of type Decimal
    KKCPaymentTaxAmount@1500005 : Decimal KKCPaymentTaxAmount //Input parameter of type Decimal
);

Parameters

ServiceTaxSetup
Input parameter of type Record
RevChargeType
Input parameter of type Option
PoT
Input parameter of type Boolean
SBCInvoiceTaxAmount
Input parameter of type Decimal
SBCPaymentTaxAmount
Input parameter of type Decimal
KKCInvoiceTaxAmount
Input parameter of type Decimal
KKCPaymentTaxAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Posted, SBCKKC, Payment, Invoice, General Ledger, Bal, Partial.

For a clarification about how this function works, refer to the code listed below.

      IF RevChargeType <> ReverseChargeType::" " THEN BEGIN
        SBCGLAccountsBalance(
          ServiceTaxSetup,SBCInvoiceTaxAmount,0,-SBCPaymentTaxAmount,
          SBCPaymentTaxAmount - SBCInvoiceTaxAmount);
        KKCGLAccountsBalance(
          ServiceTaxSetup,0,KKCInvoiceTaxAmount,-KKCPaymentTaxAmount,
          KKCPaymentTaxAmount - KKCInvoiceTaxAmount);
      END ELSE
        IF PoT THEN BEGIN
          SBCGLAccountsBalance(ServiceTaxSetup,SBCInvoiceTaxAmount,0,0,0);
          KKCGLAccountsBalance(ServiceTaxSetup,KKCInvoiceTaxAmount,0,0,0);
        END ELSE BEGIN
          SBCGLAccountsBalance(ServiceTaxSetup,SBCInvoiceTaxAmount,0,0,0);
          KKCGLAccountsBalance(
            ServiceTaxSetup,KKCPaymentTaxAmount,
            KKCInvoiceTaxAmount - KKCPaymentTaxAmount,0,0);
        END;

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      ServiceTaxSetup.FindOnDate(PurchaseLine."Service Tax Group",PurchaseHeader."Posting Date");

      IF RevChargeType = ReverseChargeTypeOption::" " THEN
        BaseAmount := ReverseServiceTaxHelper.CalcServTaxBaseAmountBackward(BaseAmount,ServiceTaxSetup,0);

      InvoiceTaxAmount := ReverseServiceTaxHelper.CalculateServTaxAmount(ServiceTaxSetup,BaseAmount,DocumentType);

      FirstPaymentTaxAmount := ReverseServiceTaxHelper.RoundServTax(PartialPaymentFactor * InvoiceTaxAmount);
      SecondPaymentTaxAmount := ReverseServiceTaxHelper.RoundServTax((1 - PartialPaymentFactor) * InvoiceTaxAmount);

      SBCAmount :=
        ReverseServiceTaxHelper.CalculateServTaxSBCAmount(ServiceTaxSetup,BaseAmount,DocumentType);
      KKCAmount :=
        ReverseServiceTaxHelper.CalculateKKCAmount(ServiceTaxSetup,BaseAmount,DocumentType);

      FirstPaymentSBCAmount := ReverseServiceTaxHelper.RoundServTax(PartialPaymentFactor * SBCAmount);
      FirstPaymentKKCAmount := ReverseServiceTaxHelper.RoundServTax(PartialPaymentFactor * KKCAmount);
      SecondPaymentSBCAmount := ReverseServiceTaxHelper.RoundServTax((1 - PartialPaymentFactor) * SBCAmount);
      SecondPaymentKKCAmount := ReverseServiceTaxHelper.RoundServTax((1 - PartialPaymentFactor) * KKCAmount);

      ServiceTaxVerify.CountOfUnappliedEntries(ApplyTransactionNo);

      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDoc,TRUE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedRemainingPayment,TRUE);

      ServiceTaxVerify.UnappPmtRemainSTEntryDetBal(FirstPaymentTaxAmount,SecondPaymentTaxAmount,LastTransactionNo,RevChargeType,PoT);
      ServiceTaxVerify.UnappPmtRemainSTSBCKKCEntryDetBal(FirstPaymentSBCAmount,SecondPaymentSBCAmount,
        FirstPaymentKKCAmount,SecondPaymentKKCAmount,
        LastTransactionNo,RevChargeType,PoT);

      IF RevChargeType = ReverseChargeTypeOption::" " THEN
        ServiceTaxVerify.VendorLedgerEntryRemAmt(
          PostedPurchaseDoc,-((1 - PartialPaymentFactor) * (BaseAmount + InvoiceTaxAmount + SBCAmount + KKCAmount)))
      ELSE
        ServiceTaxVerify.VendorLedgerEntryRemAmt(PostedPurchaseDoc,-((1 - PartialPaymentFactor) * BaseAmount));

      ServiceTaxVerify.PostedPmtAndInvGLBalPartial(
        ServiceTaxSetup,RevChargeType,PoT,InvoiceTaxAmount,FirstPaymentTaxAmount);
      ServiceTaxVerify.PostedSBCKKCPmtAndInvGLBalPartial(
        ServiceTaxSetup,RevChargeType,PoT,SBCAmount,FirstPaymentSBCAmount,KKCAmount,FirstPaymentKKCAmount);
Member of Miscellaneous.Service Tax Verify


PoTServTaxEntry@1500059 Method

The procedure PoTServTaxEntry is available in codeunit 143004.

Syntax

PoTServTaxEntry@1500059(
    DocumentNo@1500003 : Code[20] DocumentNo, //Input parameter of type Code
    BaseAmount@1500001 : Decimal BaseAmount, //Input parameter of type Decimal
    Percentage@1170000000 : Integer Percentage, //Input parameter of type Integer
    RevChrgPart@1500000 : Boolean RevChrgPart, //Input parameter of type Boolean
    ServTaxSetup@1500004 : Record 16472 ServTaxSetup //Input parameter of type Record
);

Parameters

DocumentNo
Input parameter of type Code
BaseAmount
Input parameter of type Decimal
Percentage
Input parameter of type Integer
RevChrgPart
Input parameter of type Boolean
ServTaxSetup
Input parameter of type Record

Remarks

The relevant search keywords are: Po, T, Serv, Tax, Entry.

For a clarification about how this function works, refer to the code listed below.

      ServiceTaxEntry.SETRANGE("Document No.",DocumentNo);
      ServiceTaxEntry.SETRANGE("Reverse Charge",FALSE);
      ServiceTaxEntry.SETRANGE(PoT,TRUE);
      ServiceTaxEntry.FINDLAST;
      VerifyServTaxEntryAmounts(ServiceTaxEntry,BaseAmount,Percentage,RevChrgPart,ServTaxSetup);

Example

The below example is extracted from the test automation codeunit 144034 to show one way of using this function.

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      ReverseServiceTaxHelper.CalcSplitAmounts(GenJournalLine,BaseAmount,PoTAmount,RevChrgAmount,Percentage,ServiceTaxSetup);

      PoTSBCandKKCAmount := ReverseServiceTaxHelper.CalculatePoTSBCandKKCAmount(BaseAmount,(100 - Percentage) / 100,ServiceTaxSetup);

      AccountNo := ReverseServiceTaxHelper.GetServTaxRecAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(GenJournalLine."Document No.",AccountNo,PoTAmount - PoTSBCandKKCAmount);
      ServiceTaxVerify.STEntryDetailsOnDocNoSplit(GenJournalLine."Document No.",BaseAmount,Percentage,FALSE,ServiceTaxSetup,1);

      AccountNo := ReverseServiceTaxHelper.GetServTaxInterimRecAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(GenJournalLine."Document No.",AccountNo,RevChrgAmount + PoTSBCandKKCAmount);
      AccountNo := ReverseServiceTaxHelper.GetServTaxInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(GenJournalLine."Document No.",AccountNo,-RevChrgAmount - PoTSBCandKKCAmount);

      ServiceTaxVerify.PoTServTaxEntry(GenJournalLine."Document No.",BaseAmount,Percentage,FALSE,ServiceTaxSetup);
      ServiceTaxVerify.RevChrgServTaxEntry(GenJournalLine."Document No.",BaseAmount,Percentage,TRUE,ServiceTaxSetup);

      ServiceTaxVerify.GLEntry(GenJournalLine."Document No.",
        ReverseServiceTaxHelper.GetVendorPostingAccount(GenJournalLine."Account No."),-(BaseAmount + PoTAmount));
      ServiceTaxVerify.GLEntry(GenJournalLine."Document No.",GenJournalLine."Bal. Account No.",BaseAmount);

      ServiceTaxVerify.GLEntriesCount(ReverseServiceTaxHelper.GetPostingDocType(GenJournalLine."Document Type"),GenJournalLine.
        "Document No.",10);
Member of Miscellaneous.Service Tax Verify


RevChrgServTaxEntry@1500051 Method

The procedure RevChrgServTaxEntry is available in codeunit 143004.

Syntax

RevChrgServTaxEntry@1500051(
    DocumentNo@1500003 : Code[20] DocumentNo, //Input parameter of type Code
    BaseAmount@1500001 : Decimal BaseAmount, //Input parameter of type Decimal
    Percentage@1170000000 : Integer Percentage, //Input parameter of type Integer
    RevChrgPart@1500000 : Boolean RevChrgPart, //Input parameter of type Boolean
    ServTaxSetup@1500004 : Record 16472 ServTaxSetup //Input parameter of type Record
);

Parameters

DocumentNo
Input parameter of type Code
BaseAmount
Input parameter of type Decimal
Percentage
Input parameter of type Integer
RevChrgPart
Input parameter of type Boolean
ServTaxSetup
Input parameter of type Record

Remarks

The relevant search keywords are: Rev, Chrg, Serv, Tax, Entry.

For a clarification about how this function works, refer to the code listed below.

      ServiceTaxEntry.SETRANGE("Document No.",DocumentNo);
      ServiceTaxEntry.SETRANGE("Reverse Charge",TRUE);
      ServiceTaxEntry.SETRANGE(PoT,FALSE);
      ServiceTaxEntry.FINDLAST;
      VerifyServTaxEntryAmounts(ServiceTaxEntry,BaseAmount,Percentage,RevChrgPart,ServTaxSetup);

Example

The below example is extracted from the test automation codeunit 144034 to show one way of using this function.

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      ReverseServiceTaxHelper.CalcSplitAmounts(GenJournalLine,BaseAmount,PoTAmount,RevChrgAmount,Percentage,ServiceTaxSetup);

      PoTSBCandKKCAmount := ReverseServiceTaxHelper.CalculatePoTSBCandKKCAmount(BaseAmount,(100 - Percentage) / 100,ServiceTaxSetup);

      AccountNo := ReverseServiceTaxHelper.GetServTaxRecAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(GenJournalLine."Document No.",AccountNo,PoTAmount - PoTSBCandKKCAmount);
      ServiceTaxVerify.STEntryDetailsOnDocNoSplit(GenJournalLine."Document No.",BaseAmount,Percentage,FALSE,ServiceTaxSetup,1);

      AccountNo := ReverseServiceTaxHelper.GetServTaxInterimRecAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(GenJournalLine."Document No.",AccountNo,RevChrgAmount + PoTSBCandKKCAmount);
      AccountNo := ReverseServiceTaxHelper.GetServTaxInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(GenJournalLine."Document No.",AccountNo,-RevChrgAmount - PoTSBCandKKCAmount);

      ServiceTaxVerify.PoTServTaxEntry(GenJournalLine."Document No.",BaseAmount,Percentage,FALSE,ServiceTaxSetup);
      ServiceTaxVerify.RevChrgServTaxEntry(GenJournalLine."Document No.",BaseAmount,Percentage,TRUE,ServiceTaxSetup);

      ServiceTaxVerify.GLEntry(GenJournalLine."Document No.",
        ReverseServiceTaxHelper.GetVendorPostingAccount(GenJournalLine."Account No."),-(BaseAmount + PoTAmount));
      ServiceTaxVerify.GLEntry(GenJournalLine."Document No.",GenJournalLine."Bal. Account No.",BaseAmount);

      ServiceTaxVerify.GLEntriesCount(ReverseServiceTaxHelper.GetPostingDocType(GenJournalLine."Document Type"),GenJournalLine.
        "Document No.",10);
Member of Miscellaneous.Service Tax Verify


ReversedDocument@1500063 Method

The procedure ReversedDocument is available in codeunit 143004.

Syntax

ReversedDocument@1500063(
    DocumentNo@1500000 : Code[20] DocumentNo, //Input parameter of type Code
    LastTransactionNo@1500001 : Integer LastTransactionNo //Input parameter of type Integer
);

Parameters

DocumentNo
Input parameter of type Code
LastTransactionNo
Input parameter of type Integer

Remarks

The relevant search keywords are: Reversed, Document.

For a clarification about how this function works, refer to the code listed below.

      STEntryFullTaxBalance(LastTransactionNo,0);
      STEntryFullSBCBalance(LastTransactionNo,0);
      STEntryFullKKCBalance(LastTransactionNo,0);
      DocHasClosedRemCredit(DocumentNo);

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      LastTransactionNo := Initialize;

      PostPurchDocFromJnl(GenJournalLine,DocumentType,ReverseChargeType,PoT);

      ReverseServiceTaxHelper.ReverseDocument(GenJournalLine."Document No.");

      ServiceTaxVerify.ReversedDocument(GenJournalLine."Document No.",LastTransactionNo);
Member of Miscellaneous.Service Tax Verify


SBCGLAccountsBalance@1500103 Method

The procedure SBCGLAccountsBalance is available in codeunit 143004.

Syntax

SBCGLAccountsBalance@1500103(
    ServiceTaxSetup@1500000 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    ExpectedRecBalance@1500001 : Decimal ExpectedRecBalance, //Input parameter of type Decimal
    ExpectedRecInterimBalance@1500002 : Decimal ExpectedRecInterimBalance, //Input parameter of type Decimal
    ExpectedPayBalance@1500003 : Decimal ExpectedPayBalance, //Input parameter of type Decimal
    ExpectedPayInterimBalance@1500004 : Decimal ExpectedPayInterimBalance //Input parameter of type Decimal
);

Parameters

ServiceTaxSetup
Input parameter of type Record
ExpectedRecBalance
Input parameter of type Decimal
ExpectedRecInterimBalance
Input parameter of type Decimal
ExpectedPayBalance
Input parameter of type Decimal
ExpectedPayInterimBalance
Input parameter of type Decimal

Remarks

The relevant search keywords are: SBCGL, Accounts, Balance.

For a clarification about how this function works, refer to the code listed below.

      SBCRecAccBalance(ServiceTaxSetup,ExpectedRecBalance);
      SBCRecInterimAccBalance(ServiceTaxSetup,ExpectedRecInterimBalance);
      SBCPayAccBalance(ServiceTaxSetup,ExpectedPayBalance);
      SBCPayInterimAccBalance(ServiceTaxSetup,ExpectedPayInterimBalance);

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      Initialize;

      // Exercise
      PostPmtAppliedToInvPoT(DocumentType,PoT,PurchaseLine,PostedPurchaseDocNo,PostedPaymentDocNo,ServiceTaxSetup);

      // Verify
      BaseAmount := ReverseServiceTaxHelper.CalculateServTaxBase(PurchaseLine."Line Amount",DocumentType);
      Amount := ReverseServiceTaxHelper.CalculateServTaxTotal(BaseAmount,ServiceTaxSetup);
      KKCAmount := ReverseServiceTaxHelper.CalculateKKCess(BaseAmount,ServiceTaxSetup);
      SBCAmount := ReverseServiceTaxHelper.CalculateSBC(BaseAmount,ServiceTaxSetup);
      RevChargeCreditClosed := TRUE;
      RealCreditClosed := FALSE;

      IF PoT THEN
        ServiceTaxVerify.ServiceTaxEntries(PostedPurchaseDocNo,BaseAmount,ServiceTaxSetup,RevChargeCreditClosed,RealCreditClosed)
      ELSE BEGIN
        ServiceTaxVerify.ServTaxEntry(PostedPurchaseDocNo,BaseAmount,ServiceTaxSetup);
        ServiceTaxVerify.ServTaxEntryDetails(PostedPaymentDocNo,BaseAmount,ServiceTaxSetup,RevChargeCreditClosed,RealCreditClosed);
      END;

      ServiceTaxVerify.ServTaxGLAccountsBalance(ServiceTaxSetup,Amount,0,0,0);
      ServiceTaxVerify.KKCGLAccountsBalance(ServiceTaxSetup,KKCAmount,0,0,0);
      ServiceTaxVerify.SBCGLAccountsBalance(ServiceTaxSetup,SBCAmount,0,0,0);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDocNo,FALSE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPaymentDocNo,FALSE);
Member of Miscellaneous.Service Tax Verify


SBCPayAccBalance@1500109 Method

The procedure SBCPayAccBalance is available in codeunit 143004.

Syntax

SBCPayAccBalance@1500109(
    ServiceTaxSetup@1500003 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    Amount@1500001 : Decimal Amount //Input parameter of type Decimal
);

Parameters

ServiceTaxSetup
Input parameter of type Record
Amount
Input parameter of type Decimal

Remarks

The relevant search keywords are: SBC, Pay, Account, Balance.

For a clarification about how this function works, refer to the code listed below.

      AccountBalance(ReverseServiceTaxHelper.GetServTaxSBCPayAcc(ServiceTaxSetup),Amount);

Example

There are no examples available.
Member of Miscellaneous.Service Tax Verify


SBCPayInterimAccBalance@1500108 Method

The procedure SBCPayInterimAccBalance is available in codeunit 143004.

Syntax

SBCPayInterimAccBalance@1500108(
    ServiceTaxSetup@1500002 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    Amount@1500000 : Decimal Amount //Input parameter of type Decimal
);

Parameters

ServiceTaxSetup
Input parameter of type Record
Amount
Input parameter of type Decimal

Remarks

The relevant search keywords are: SBC, Pay, Interim, Account, Balance.

For a clarification about how this function works, refer to the code listed below.

      AccountBalance(ReverseServiceTaxHelper.GetServTaxSBCInterimPayAcc(ServiceTaxSetup),Amount);

Example

There are no examples available.
Member of Miscellaneous.Service Tax Verify


SBCRecAccBalance@1500107 Method

The procedure SBCRecAccBalance is available in codeunit 143004.

Syntax

SBCRecAccBalance@1500107(
    ServiceTaxSetup@1500002 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    Amount@1500000 : Decimal Amount //Input parameter of type Decimal
);

Parameters

ServiceTaxSetup
Input parameter of type Record
Amount
Input parameter of type Decimal

Remarks

The relevant search keywords are: SBC, Rec, Account, Balance.

For a clarification about how this function works, refer to the code listed below.

      AccountBalance(ReverseServiceTaxHelper.GetServTaxSBCRecAcc(ServiceTaxSetup),Amount);

Example

The below example is extracted from the test automation codeunit 144044 to show one way of using this function.

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      ServiceTaxVerify.STRecAccBalance(ServiceTaxSetup,0);
      ServiceTaxVerify.STRecInterimAccBalance(ServiceTaxSetup,0);
      ServiceTaxVerify.SBCRecAccBalance(ServiceTaxSetup,0);
      ServiceTaxVerify.SBCRecInterimAccBalance(ServiceTaxSetup,0);
      ServiceTaxVerify.KKCRecAccBalance(ServiceTaxSetup,0);
      ServiceTaxVerify.KKCRecInterimAccBalance(ServiceTaxSetup,0);
      ServiceTaxVerify.STEntryDtlsFullTaxBalance(LastTransactionNo,0);
      ServiceTaxVerify.STEntryDtlsSBCBalance(LastTransactionNo,0);
      ServiceTaxVerify.STEntryDtlsKKCBalance(LastTransactionNo,0);

      ServiceTaxVerify.STEntryDetailsRemainingCredit(LastTransactionNo,0);
      ServiceTaxVerify.STEntryDetailsKKCRemainingCredit(LastTransactionNo,0);

      ServiceTaxVerify.PostedInvoiceRounding(GenJournalLine."Posting Group",LastTransactionNo);
Member of Miscellaneous.Service Tax Verify


SBCRecAccBalanceNearly@1500129 Method

The procedure SBCRecAccBalanceNearly is available in codeunit 143004.

Syntax

SBCRecAccBalanceNearly@1500129(
    ServiceTaxSetup@1500002 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    Amount@1500000 : Decimal Amount //Input parameter of type Decimal
);

Parameters

ServiceTaxSetup
Input parameter of type Record
Amount
Input parameter of type Decimal

Remarks

The relevant search keywords are: SBC, Rec, Account, Balance, Nearly.

For a clarification about how this function works, refer to the code listed below.

      AccountNo := ReverseServiceTaxHelper.GetServTaxSBCRecAcc(ServiceTaxSetup);
      GLAccount.GET(AccountNo);
      GLAccount.CALCFIELDS(Balance);

      GLSetup.GET;
      Assert.AreNearlyEqual(
        Amount,GLAccount.Balance,GLSetup."Service Tax Rounding Precision",STRSUBSTNO(AccBalanceErr,GLAccount."No."));

Example

There are no examples available.
Member of Miscellaneous.Service Tax Verify


SBCRecInterimAccBalance@1500105 Method

The procedure SBCRecInterimAccBalance is available in codeunit 143004.

Syntax

SBCRecInterimAccBalance@1500105(
    ServiceTaxSetup@1500003 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    Amount@1500002 : Decimal Amount //Input parameter of type Decimal
);

Parameters

ServiceTaxSetup
Input parameter of type Record
Amount
Input parameter of type Decimal

Remarks

The relevant search keywords are: SBC, Rec, Interim, Account, Balance.

For a clarification about how this function works, refer to the code listed below.

      AccountBalance(ReverseServiceTaxHelper.GetServTaxSBCInterimRecAcc(ServiceTaxSetup),Amount);

Example

The below example is extracted from the test automation codeunit 144044 to show one way of using this function.

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      ServiceTaxVerify.STRecAccBalance(ServiceTaxSetup,0);
      ServiceTaxVerify.STRecInterimAccBalance(ServiceTaxSetup,0);
      ServiceTaxVerify.SBCRecAccBalance(ServiceTaxSetup,0);
      ServiceTaxVerify.SBCRecInterimAccBalance(ServiceTaxSetup,0);
      ServiceTaxVerify.KKCRecAccBalance(ServiceTaxSetup,0);
      ServiceTaxVerify.KKCRecInterimAccBalance(ServiceTaxSetup,0);
      ServiceTaxVerify.STEntryDtlsFullTaxBalance(LastTransactionNo,0);
      ServiceTaxVerify.STEntryDtlsSBCBalance(LastTransactionNo,0);
      ServiceTaxVerify.STEntryDtlsKKCBalance(LastTransactionNo,0);

      ServiceTaxVerify.STEntryDetailsRemainingCredit(LastTransactionNo,0);
      ServiceTaxVerify.STEntryDetailsKKCRemainingCredit(LastTransactionNo,0);

      ServiceTaxVerify.PostedInvoiceRounding(GenJournalLine."Posting Group",LastTransactionNo);
Member of Miscellaneous.Service Tax Verify


ServiceTaxEntries@1500009 Method

The procedure ServiceTaxEntries is available in codeunit 143004.

Syntax

ServiceTaxEntries@1500009(
    PostedDocNo@1500000 : Code[20] PostedDocNo, //Input parameter of type Code
    Amount@1500001 : Decimal Amount, //Input parameter of type Decimal
    ServiceTaxSetup@1500002 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    RevChargeCreditClosed@1500003 : Boolean RevChargeCreditClosed, //Input parameter of type Boolean
    RealCreditClosed@1500004 : Boolean RealCreditClosed //Input parameter of type Boolean
);

Parameters

PostedDocNo
Input parameter of type Code
Amount
Input parameter of type Decimal
ServiceTaxSetup
Input parameter of type Record
RevChargeCreditClosed
Input parameter of type Boolean
RealCreditClosed
Input parameter of type Boolean

Remarks

The relevant search keywords are: Service, Tax, Entries.

For a clarification about how this function works, refer to the code listed below.

      ServTaxEntry(PostedDocNo,Amount,ServiceTaxSetup);
      ServTaxEntryDetails(PostedDocNo,Amount,ServiceTaxSetup,RevChargeCreditClosed,RealCreditClosed);

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      Initialize;

      // Exercise
      PostPmtAppliedToInvPoT(DocumentType,PoT,PurchaseLine,PostedPurchaseDocNo,PostedPaymentDocNo,ServiceTaxSetup);

      // Verify
      BaseAmount := ReverseServiceTaxHelper.CalculateServTaxBase(PurchaseLine."Line Amount",DocumentType);
      Amount := ReverseServiceTaxHelper.CalculateServTaxTotal(BaseAmount,ServiceTaxSetup);
      KKCAmount := ReverseServiceTaxHelper.CalculateKKCess(BaseAmount,ServiceTaxSetup);
      SBCAmount := ReverseServiceTaxHelper.CalculateSBC(BaseAmount,ServiceTaxSetup);
      RevChargeCreditClosed := TRUE;
      RealCreditClosed := FALSE;

      IF PoT THEN
        ServiceTaxVerify.ServiceTaxEntries(PostedPurchaseDocNo,BaseAmount,ServiceTaxSetup,RevChargeCreditClosed,RealCreditClosed)
      ELSE BEGIN
        ServiceTaxVerify.ServTaxEntry(PostedPurchaseDocNo,BaseAmount,ServiceTaxSetup);
        ServiceTaxVerify.ServTaxEntryDetails(PostedPaymentDocNo,BaseAmount,ServiceTaxSetup,RevChargeCreditClosed,RealCreditClosed);
      END;

      ServiceTaxVerify.ServTaxGLAccountsBalance(ServiceTaxSetup,Amount,0,0,0);
      ServiceTaxVerify.KKCGLAccountsBalance(ServiceTaxSetup,KKCAmount,0,0,0);
      ServiceTaxVerify.SBCGLAccountsBalance(ServiceTaxSetup,SBCAmount,0,0,0);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDocNo,FALSE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPaymentDocNo,FALSE);
Member of Miscellaneous.Service Tax Verify


ServTaxEntriesArePaid@1500056 Method

The procedure ServTaxEntriesArePaid is available in codeunit 143004.

Syntax

ServTaxEntriesArePaid@1500056(
    ApplicationTransactionNo@1500000 : Integer ApplicationTransactionNo //Input parameter of type Integer
);

Parameters

ApplicationTransactionNo
Input parameter of type Integer

Remarks

The relevant search keywords are: Serv, Tax, Entries, Are, Paid.

For a clarification about how this function works, refer to the code listed below.

      ServiceTaxEntryDetails.SETRANGE("Transaction No.",ApplicationTransactionNo);
      ServiceTaxEntryDetails.SETRANGE("Corrective Application Entry",FALSE);
      ServiceTaxEntryDetails.SETRANGE("Serv. Tax on Advance Payment",FALSE);
      IF ServiceTaxEntryDetails.FINDSET THEN
        REPEAT
          ServiceTaxEntry.GET(ServiceTaxEntryDetails."Service Tax Entry No.");
          ServiceTaxEntry.CALCFIELDS("Amount Received/Paid");
          IF ServiceTaxEntryDetails."Reverse Charge" THEN
            ExpectedAmount := ServiceTaxEntry."Service Tax Base Amount"
          ELSE
            ExpectedAmount := ServiceTaxEntry."Amount Including Service Tax";
          Assert.AreEqual(
            ExpectedAmount,ServiceTaxEntry."Amount Received/Paid",ServiceTaxEntry.FIELDCAPTION("Amount Received/Paid"));
        UNTIL ServiceTaxEntryDetails.NEXT = 0;

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      LastTransactionNo := Initialize;

      // Setup:
      PoT := ReverseChargeType = ReverseChargeTypeOption::" ";
      ReverseServiceTaxHelper.CreatePurchaseDoc(
        PurchaseHeader,PurchaseLine,PurchaseHeader."Document Type"::Invoice,ReverseChargeType,100,PoT);

      // Exercise
      PostedDocNo1 := ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);
      PostedDocNo2 := PostAndApplyCrMemo(PurchaseHeader,PostedDocNo1,InvAmountIs);

      // Verify
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedDocNo1,InvAmountIs = InvoiceAmountIs::Greater);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedDocNo2,InvAmountIs = InvoiceAmountIs::Smaller);

      ServiceTaxSetup.FindOnDate(PurchaseLine."Service Tax Group",PurchaseHeader."Posting Date");
      InvoiceBaseAmount := ReverseServiceTaxHelper.CalculateServTaxBase(PurchaseLine."Line Amount",PurchaseHeader."Document Type");
      InvoiceTaxAmount := ReverseServiceTaxHelper.CalculateServTaxTotal(InvoiceBaseAmount,ServiceTaxSetup);
      CrMemoBaseAmount := -InvoiceBaseAmount / ReverseServiceTaxHelper.GetPurchInvAmountFactor(InvAmountIs);
      CrMemoTaxAmount := ReverseServiceTaxHelper.CalculateServTaxTotal(CrMemoBaseAmount,ServiceTaxSetup);

      ServiceTaxVerify.ServTaxEntry(PostedDocNo1,InvoiceBaseAmount,ServiceTaxSetup);
      ServiceTaxVerify.ServTaxEntry(PostedDocNo2,CrMemoBaseAmount,ServiceTaxSetup);

      ServiceTaxVerify.PostedPurchDocGLBalance(ServiceTaxSetup,ReverseChargeType,PoT,InvoiceTaxAmount + CrMemoTaxAmount);

      IF ReverseChargeType = ReverseChargeTypeOption::" " THEN
        IF PoT THEN BEGIN
          ServiceTaxVerify.STEntryDetailsRemainingCredit(LastTransactionNo,InvoiceTaxAmount + CrMemoTaxAmount);
          ServiceTaxVerify.ServTaxEntriesArePaid(ReverseServiceTaxHelper.GetLastTransactionNo);
        END ELSE
          ServiceTaxVerify.STEntryDetailsRemainingCredit(LastTransactionNo,0)
      ELSE
        ServiceTaxVerify.STEntryDetailsRemRevChrgCredit(LastTransactionNo,0);

      IF InvAmountIs = InvoiceAmountIs::Greater THEN
        SmallerDocumentNo := PostedDocNo2
      ELSE
        SmallerDocumentNo := PostedDocNo1;
      ServiceTaxVerify.DocHasClosedRemCredit(SmallerDocumentNo);
Member of Miscellaneous.Service Tax Verify


ServTaxEntriesFor2Pmts@1500089 Method

The procedure ServTaxEntriesFor2Pmts is available in codeunit 143004.

Syntax

ServTaxEntriesFor2Pmts@1500089(
    PurchLineAmount@1500000 : Decimal PurchLineAmount, //Input parameter of type Decimal
    DocumentType@1500001 : Option DocumentType, //Input parameter of type Option
    ServiceTaxSetup@1500002 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    PostedPaymentDocNo@1500003 : Code[20] PostedPaymentDocNo, //Input parameter of type Code
    ServiceTypeRevChrg@1500004 : Option ServiceTypeRevChrg, //Input parameter of type Option
    PartialPaymentFactor@1500011 : Decimal PartialPaymentFactor //Input parameter of type Decimal
);

Parameters

PurchLineAmount
Input parameter of type Decimal
DocumentType
Input parameter of type Option
ServiceTaxSetup
Input parameter of type Record
PostedPaymentDocNo
Input parameter of type Code
ServiceTypeRevChrg
Input parameter of type Option
PartialPaymentFactor
Input parameter of type Decimal

Remarks

The relevant search keywords are: Serv, Tax, Entries, For2, Pmts.

For a clarification about how this function works, refer to the code listed below.

      VerifyServTaxPmtEntriesHelper(PurchLineAmount,DocumentType,ServiceTaxSetup,PostedPaymentDocNo,ServiceTypeRevChrg,
        PartialPaymentFactor);

Example

The below example is extracted from the test automation codeunit 144034 to show one way of using this function.

      Initialize;
      ReverseServiceTaxHelper.SetupCompanyInfo;

      // Setup
      Percentage := LibraryRandom.RandIntInRange(10,90);
      ReverseServiceTaxHelper.CreatePurchaseDocFromGenJnl(GenJournalLine,GenJournalLine."Document Type"::Invoice,
        ServiceTypeRevChrg,ReverseChargeTypeOption::Standard,TRUE,Percentage);
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      PartialPaymentFactor := GetPartialFactor;
      PostAndApply2Payments(GenJournalLine,ServiceTaxSetup,PartialPaymentFactor,Percentage);

      // Exercise
      PaymentToGovDocNo := ReverseServiceTaxHelper.PayServiceTax(GenJournalLine."Service Tax Registration No.",
          GenJournalLine."Service Tax Group Code",TRUE);

      // Verify
      RevChrgBase := ReverseServiceTaxHelper.RoundAmount(Percentage / 100 * ABS(GenJournalLine.Amount));
      ServiceTaxVerify.ServTaxEntriesFor2Pmts(RevChrgBase,GenJournalLine."Document Type"::Invoice,
        ServiceTaxSetup,PaymentToGovDocNo,ServiceTypeRevChrg,PartialPaymentFactor);
Member of Miscellaneous.Service Tax Verify


ServTaxEntry@1500018 Method

The procedure ServTaxEntry is available in codeunit 143004.

Syntax

ServTaxEntry@1500018(
    DocumentNo@1500003 : Code[20] DocumentNo, //Input parameter of type Code
    BaseAmount@1500001 : Decimal BaseAmount, //Input parameter of type Decimal
    ServTaxSetup@1500004 : Record 16472 ServTaxSetup //Input parameter of type Record
);

Parameters

DocumentNo
Input parameter of type Code
BaseAmount
Input parameter of type Decimal
ServTaxSetup
Input parameter of type Record

Remarks

The relevant search keywords are: Serv, Tax, Entry.

For a clarification about how this function works, refer to the code listed below.

      ServiceTaxEntry.SETRANGE("Document No.",DocumentNo);
      ServiceTaxEntry.FINDLAST;
      VerifyServTaxEntryAmounts(ServiceTaxEntry,BaseAmount,0,FALSE,ServTaxSetup);

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      LastTransactionNo := Initialize;

      // Setup:
      PoT := ReverseChargeType = ReverseChargeTypeOption::" ";
      ReverseServiceTaxHelper.CreatePurchaseDoc(
        PurchaseHeader,PurchaseLine,PurchaseHeader."Document Type"::Invoice,ReverseChargeType,100,PoT);

      // Exercise
      PostedDocNo1 := ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);
      PostedDocNo2 := PostAndApplyCrMemo(PurchaseHeader,PostedDocNo1,InvAmountIs);

      // Verify
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedDocNo1,InvAmountIs = InvoiceAmountIs::Greater);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedDocNo2,InvAmountIs = InvoiceAmountIs::Smaller);

      ServiceTaxSetup.FindOnDate(PurchaseLine."Service Tax Group",PurchaseHeader."Posting Date");
      InvoiceBaseAmount := ReverseServiceTaxHelper.CalculateServTaxBase(PurchaseLine."Line Amount",PurchaseHeader."Document Type");
      InvoiceTaxAmount := ReverseServiceTaxHelper.CalculateServTaxTotal(InvoiceBaseAmount,ServiceTaxSetup);
      CrMemoBaseAmount := -InvoiceBaseAmount / ReverseServiceTaxHelper.GetPurchInvAmountFactor(InvAmountIs);
      CrMemoTaxAmount := ReverseServiceTaxHelper.CalculateServTaxTotal(CrMemoBaseAmount,ServiceTaxSetup);

      ServiceTaxVerify.ServTaxEntry(PostedDocNo1,InvoiceBaseAmount,ServiceTaxSetup);
      ServiceTaxVerify.ServTaxEntry(PostedDocNo2,CrMemoBaseAmount,ServiceTaxSetup);

      ServiceTaxVerify.PostedPurchDocGLBalance(ServiceTaxSetup,ReverseChargeType,PoT,InvoiceTaxAmount + CrMemoTaxAmount);

      IF ReverseChargeType = ReverseChargeTypeOption::" " THEN
        IF PoT THEN BEGIN
          ServiceTaxVerify.STEntryDetailsRemainingCredit(LastTransactionNo,InvoiceTaxAmount + CrMemoTaxAmount);
          ServiceTaxVerify.ServTaxEntriesArePaid(ReverseServiceTaxHelper.GetLastTransactionNo);
        END ELSE
          ServiceTaxVerify.STEntryDetailsRemainingCredit(LastTransactionNo,0)
      ELSE
        ServiceTaxVerify.STEntryDetailsRemRevChrgCredit(LastTransactionNo,0);

      IF InvAmountIs = InvoiceAmountIs::Greater THEN
        SmallerDocumentNo := PostedDocNo2
      ELSE
        SmallerDocumentNo := PostedDocNo1;
      ServiceTaxVerify.DocHasClosedRemCredit(SmallerDocumentNo);
Member of Miscellaneous.Service Tax Verify


ServTaxEntryDetails@1500061 Method

The procedure ServTaxEntryDetails is available in codeunit 143004.

Syntax

ServTaxEntryDetails@1500061(
    DocumentNo@1500003 : Code[20] DocumentNo, //Input parameter of type Code
    BaseAmount@1500001 : Decimal BaseAmount, //Input parameter of type Decimal
    ServTaxSetup@1500000 : Record 16472 ServTaxSetup, //Input parameter of type Record
    RevChargeCreditClosed@1500004 : Boolean RevChargeCreditClosed, //Input parameter of type Boolean
    RealCreditClosed@1500005 : Boolean RealCreditClosed //Input parameter of type Boolean
);

Parameters

DocumentNo
Input parameter of type Code
BaseAmount
Input parameter of type Decimal
ServTaxSetup
Input parameter of type Record
RevChargeCreditClosed
Input parameter of type Boolean
RealCreditClosed
Input parameter of type Boolean

Remarks

The relevant search keywords are: Serv, Tax, Entry, Details.

For a clarification about how this function works, refer to the code listed below.

      ReverseServiceTaxHelper.GetServiceTaxEntryDetail(ServiceTaxEntryDetails,DocumentNo);
      PartialPaymentFactor := 0;
      SplitPercentage := 0;
      RevChargePart := FALSE;
      STDetailAmountsAndStatus(
        ServiceTaxEntryDetails,BaseAmount,ServTaxSetup,PartialPaymentFactor,RevChargeCreditClosed,
        RealCreditClosed,SplitPercentage,RevChargePart);

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      Initialize;

      // Exercise
      PostPmtAppliedToInvPoT(DocumentType,PoT,PurchaseLine,PostedPurchaseDocNo,PostedPaymentDocNo,ServiceTaxSetup);

      // Verify
      BaseAmount := ReverseServiceTaxHelper.CalculateServTaxBase(PurchaseLine."Line Amount",DocumentType);
      Amount := ReverseServiceTaxHelper.CalculateServTaxTotal(BaseAmount,ServiceTaxSetup);
      KKCAmount := ReverseServiceTaxHelper.CalculateKKCess(BaseAmount,ServiceTaxSetup);
      SBCAmount := ReverseServiceTaxHelper.CalculateSBC(BaseAmount,ServiceTaxSetup);
      RevChargeCreditClosed := TRUE;
      RealCreditClosed := FALSE;

      IF PoT THEN
        ServiceTaxVerify.ServiceTaxEntries(PostedPurchaseDocNo,BaseAmount,ServiceTaxSetup,RevChargeCreditClosed,RealCreditClosed)
      ELSE BEGIN
        ServiceTaxVerify.ServTaxEntry(PostedPurchaseDocNo,BaseAmount,ServiceTaxSetup);
        ServiceTaxVerify.ServTaxEntryDetails(PostedPaymentDocNo,BaseAmount,ServiceTaxSetup,RevChargeCreditClosed,RealCreditClosed);
      END;

      ServiceTaxVerify.ServTaxGLAccountsBalance(ServiceTaxSetup,Amount,0,0,0);
      ServiceTaxVerify.KKCGLAccountsBalance(ServiceTaxSetup,KKCAmount,0,0,0);
      ServiceTaxVerify.SBCGLAccountsBalance(ServiceTaxSetup,SBCAmount,0,0,0);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDocNo,FALSE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPaymentDocNo,FALSE);
Member of Miscellaneous.Service Tax Verify


ServTaxEntryStatus@1500081 Method

The procedure ServTaxEntryStatus is available in codeunit 143004.

Syntax

ServTaxEntryStatus@1500081(
    DocumentNo@1500003 : Code[20] DocumentNo, //Input parameter of type Code
    RevChargeCreditClosed@1500004 : Boolean RevChargeCreditClosed, //Input parameter of type Boolean
    RealCreditClosed@1500005 : Boolean RealCreditClosed //Input parameter of type Boolean
);

Parameters

DocumentNo
Input parameter of type Code
RevChargeCreditClosed
Input parameter of type Boolean
RealCreditClosed
Input parameter of type Boolean

Remarks

The relevant search keywords are: Serv, Tax, Entry, Status.

For a clarification about how this function works, refer to the code listed below.

      ReverseServiceTaxHelper.GetServiceTaxEntryDetail(ServiceTaxEntryDetails,DocumentNo);
      STDetailStatus(ServiceTaxEntryDetails,RevChargeCreditClosed,RealCreditClosed);

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      RevChargeCreditClosed := TRUE;
      RealCreditClosed := TRUE;
      ServiceTaxVerify.ServTaxEntryDetails(PostedDocNo,BaseAmount,ServiceTaxSetup,RevChargeCreditClosed,RealCreditClosed);
      ServiceTaxVerify.ServTaxEntryStatus(PostedSalesInvoiceDocNo,RevChargeCreditClosed,RealCreditClosed);
Member of Miscellaneous.Service Tax Verify


ServTaxGLAccountsBalance@1560000 Method

The procedure ServTaxGLAccountsBalance is available in codeunit 143004.

Syntax

ServTaxGLAccountsBalance@1560000(
    ServiceTaxSetup@1500000 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    ExpectedRecBalance@1500001 : Decimal ExpectedRecBalance, //Input parameter of type Decimal
    ExpectedRecInterimBalance@1500002 : Decimal ExpectedRecInterimBalance, //Input parameter of type Decimal
    ExpectedPayBalance@1500003 : Decimal ExpectedPayBalance, //Input parameter of type Decimal
    ExpectedPayInterimBalance@1500004 : Decimal ExpectedPayInterimBalance //Input parameter of type Decimal
);

Parameters

ServiceTaxSetup
Input parameter of type Record
ExpectedRecBalance
Input parameter of type Decimal
ExpectedRecInterimBalance
Input parameter of type Decimal
ExpectedPayBalance
Input parameter of type Decimal
ExpectedPayInterimBalance
Input parameter of type Decimal

Remarks

The relevant search keywords are: Serv, Tax, General Ledger, Accounts, Balance.

For a clarification about how this function works, refer to the code listed below.

      STRecAccBalance(ServiceTaxSetup,ExpectedRecBalance);
      STRecInterimAccBalance(ServiceTaxSetup,ExpectedRecInterimBalance);
      STPayAccBalance(ServiceTaxSetup,ExpectedPayBalance);
      STPayInterimAccBalance(ServiceTaxSetup,ExpectedPayInterimBalance);

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      Initialize;

      // Exercise
      PostPmtAppliedToInvPoT(DocumentType,PoT,PurchaseLine,PostedPurchaseDocNo,PostedPaymentDocNo,ServiceTaxSetup);

      // Verify
      BaseAmount := ReverseServiceTaxHelper.CalculateServTaxBase(PurchaseLine."Line Amount",DocumentType);
      Amount := ReverseServiceTaxHelper.CalculateServTaxTotal(BaseAmount,ServiceTaxSetup);
      KKCAmount := ReverseServiceTaxHelper.CalculateKKCess(BaseAmount,ServiceTaxSetup);
      SBCAmount := ReverseServiceTaxHelper.CalculateSBC(BaseAmount,ServiceTaxSetup);
      RevChargeCreditClosed := TRUE;
      RealCreditClosed := FALSE;

      IF PoT THEN
        ServiceTaxVerify.ServiceTaxEntries(PostedPurchaseDocNo,BaseAmount,ServiceTaxSetup,RevChargeCreditClosed,RealCreditClosed)
      ELSE BEGIN
        ServiceTaxVerify.ServTaxEntry(PostedPurchaseDocNo,BaseAmount,ServiceTaxSetup);
        ServiceTaxVerify.ServTaxEntryDetails(PostedPaymentDocNo,BaseAmount,ServiceTaxSetup,RevChargeCreditClosed,RealCreditClosed);
      END;

      ServiceTaxVerify.ServTaxGLAccountsBalance(ServiceTaxSetup,Amount,0,0,0);
      ServiceTaxVerify.KKCGLAccountsBalance(ServiceTaxSetup,KKCAmount,0,0,0);
      ServiceTaxVerify.SBCGLAccountsBalance(ServiceTaxSetup,SBCAmount,0,0,0);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDocNo,FALSE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPaymentDocNo,FALSE);
Member of Miscellaneous.Service Tax Verify


ServTaxPaymentEntries@1500023 Method

The procedure ServTaxPaymentEntries is available in codeunit 143004.

Syntax

ServTaxPaymentEntries@1500023(
    PurchLineAmount@1500000 : Decimal PurchLineAmount, //Input parameter of type Decimal
    DocumentType@1500001 : Option DocumentType, //Input parameter of type Option
    ServiceTaxSetup@1500002 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    PostedPaymentDocNo@1500003 : Code[20] PostedPaymentDocNo, //Input parameter of type Code
    ServiceTypeRevChrg@1500004 : Option ServiceTypeRevChrg //Input parameter of type Option
);

Parameters

PurchLineAmount
Input parameter of type Decimal
DocumentType
Input parameter of type Option
ServiceTaxSetup
Input parameter of type Record
PostedPaymentDocNo
Input parameter of type Code
ServiceTypeRevChrg
Input parameter of type Option

Remarks

The relevant search keywords are: Serv, Tax, Payment, Entries.

For a clarification about how this function works, refer to the code listed below.

      PartialPaymentFactor := 1; // Full payment
      VerifyServTaxPmtEntriesHelper(PurchLineAmount,DocumentType,ServiceTaxSetup,PostedPaymentDocNo,ServiceTypeRevChrg,
        PartialPaymentFactor);

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      Initialize;

      // Setup:
      PostRevChargeInvAndApplyPmt(ServiceTaxRegNo,ServiceTaxGroup,ServiceTaxSetup,PurchaseHeader,PurchaseLine,DocumentType,
        SrvTypeRevChrg,ReverseChargeType);

      // Exercise:
      PostedPayToGovDocNo := LibraryServiceTax.PayServiceTax(ServiceTaxRegNo.Code,ServiceTaxGroup.Code,TRUE);

      // Verify:
      ServiceTaxVerify.ServTaxPaymentEntries(PurchaseLine."Line Amount",DocumentType,ServiceTaxSetup,
        PostedPayToGovDocNo,SrvTypeRevChrg);
Member of Miscellaneous.Service Tax Verify


SplitApplication@1500017 Method

The procedure SplitApplication is available in codeunit 143004.

Syntax

SplitApplication@1500017(
    GenJnlLine@1500000 : Record 81 GenJnlLine, //Input parameter of type Record
    PaymentDocNo@1500010 : Code[20] PaymentDocNo, //Input parameter of type Code
    LastTransactionNo@1500001 : Integer LastTransactionNo //Input parameter of type Integer
);

Parameters

GenJnlLine
Input parameter of type Record
PaymentDocNo
Input parameter of type Code
LastTransactionNo
Input parameter of type Integer

Remarks

The relevant search keywords are: Split, Application.

For a clarification about how this function works, refer to the code listed below.

      VendorLedgerEntryOpen(GenJnlLine."Document No.",FALSE);
      VendorLedgerEntryOpen(PaymentDocNo,FALSE);

      ServiceTaxSetup.FindOnDate(GenJnlLine."Service Tax Group Code",GenJnlLine."Posting Date");
      ReverseServiceTaxHelper.CalcSplitAmounts(GenJnlLine,BaseAmount,PoTAmount,RevChrgAmount,Percentage,ServiceTaxSetup);
      PoTSBCandKKCAmount :=
        ReverseServiceTaxHelper.CalculatePoTSBCandKKCAmount(BaseAmount,(100 - Percentage) / 100,ServiceTaxSetup);
      SplitServTaxAccountsBalance(ServiceTaxSetup,PoTAmount - PoTSBCandKKCAmount,RevChrgAmount + PoTSBCandKKCAmount,1);

      CountOfServiceTaxEntries(LastTransactionNo,2,2);

      STEntryDetailsOnDocNoSplit(PaymentDocNo,BaseAmount,Percentage,TRUE,ServiceTaxSetup,1); // Rev charge Service Tax Part
      STEntryDetailsOnDocNoSplit(GenJnlLine."Document No.",BaseAmount,Percentage,FALSE,ServiceTaxSetup,1); // Real Service Tax Part

Example

The below example is extracted from the test automation codeunit 144034 to show one way of using this function.

      LastTransactionNo := Initialize;

      // Setup
      CreateDocument(PurchaseHeader,PurchaseLine,DocumentType);
      PurchaseHeader.VALIDATE("Payment Method Code",ReverseServiceTaxHelper.FindPmtMethodWithBalAcc);
      PurchaseHeader.MODIFY;

      // Exercise
      PostedDocNo := ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);

      // Verify
      ReverseServiceTaxHelper.ConvertDocToJnlLine(PurchaseHeader,PurchaseLine,PostedDocNo,GenJnlLine);
      ServiceTaxVerify.SplitApplication(GenJnlLine,PostedDocNo,LastTransactionNo);
Member of Miscellaneous.Service Tax Verify


SplitServTaxAccountsBalance@1500127 Method

The procedure SplitServTaxAccountsBalance is available in codeunit 143004.

Syntax

SplitServTaxAccountsBalance@1500127(
    ServiceTaxSetup@1500003 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    PoTAmount@1500000 : Decimal PoTAmount, //Input parameter of type Decimal
    RevChrgAmount@1500001 : Decimal RevChrgAmount, //Input parameter of type Decimal
    PaidRevChrgPartFactor@1500002 : Decimal PaidRevChrgPartFactor //Input parameter of type Decimal
);

Parameters

ServiceTaxSetup
Input parameter of type Record
PoTAmount
Input parameter of type Decimal
RevChrgAmount
Input parameter of type Decimal
PaidRevChrgPartFactor
Input parameter of type Decimal

Remarks

The relevant search keywords are: Split, Serv, Tax, Accounts, Balance.

For a clarification about how this function works, refer to the code listed below.

      PartialRevChrgAmount := ReverseServiceTaxHelper.RoundServTax(PaidRevChrgPartFactor * RevChrgAmount);

      STPayInterimAccBalance(ServiceTaxSetup,PartialRevChrgAmount - RevChrgAmount);
      STRecInterimAccBalance(ServiceTaxSetup,RevChrgAmount);
      STPayAccBalance(ServiceTaxSetup,-PartialRevChrgAmount);
      STRecAccBalance(ServiceTaxSetup,PoTAmount);

Example

The below example is extracted from the test automation codeunit 144034 to show one way of using this function.

      ServiceTaxVerify.VendorLedgerEntryOpen(GenJournalLine."Document No.",TRUE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PaymentDocNo,FALSE);

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      ReverseServiceTaxHelper.CalcSplitAmounts(GenJournalLine,BaseAmount,PoTAmount,RevChrgAmount,Percentage,ServiceTaxSetup);
      PoTSBCandKKCAmount :=
        ReverseServiceTaxHelper.CalculatePoTSBCandKKCAmount(BaseAmount,(100 - Percentage) / 100,ServiceTaxSetup);
      ServiceTaxVerify.SplitServTaxAccountsBalance(
        ServiceTaxSetup,PoTAmount - PoTSBCandKKCAmount,RevChrgAmount + PoTSBCandKKCAmount,PartialFactor);

      ServiceTaxVerify.CountOfServiceTaxEntries(LastTransactionNo,2,2);

      // Real Service Tax Part - because the Real Service Tax Detail entry is created when posting the invoice for the whole amount
      // so partial factor is 1.
      ServiceTaxVerify.STEntryDetailsOnDocNoSplit(GenJournalLine."Document No.",BaseAmount,Percentage,FALSE,ServiceTaxSetup,1);
      // Rev charge Service Tax Part
      ServiceTaxVerify.STEntryDetailsOnDocNoSplit(PaymentDocNo,BaseAmount,Percentage,TRUE,ServiceTaxSetup,PartialFactor);
Member of Miscellaneous.Service Tax Verify


STaxGLEntriesDoNotExist@1500050 Method

The procedure STaxGLEntriesDoNotExist is available in codeunit 143004.

Syntax

STaxGLEntriesDoNotExist@1500050(
    ServiceTaxSetup@1500000 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    DocumentNo@1500003 : Code[20] DocumentNo //Input parameter of type Code
);

Parameters

ServiceTaxSetup
Input parameter of type Record
DocumentNo
Input parameter of type Code

Remarks

The relevant search keywords are: S, Tax, General Ledger, Entries, Do, Not, Exist.

For a clarification about how this function works, refer to the code listed below.

      GLEntryDoesNotExist(DocumentNo,ReverseServiceTaxHelper.GetServTaxPayAcc(ServiceTaxSetup));
      GLEntryDoesNotExist(DocumentNo,ReverseServiceTaxHelper.GetServTaxInterimPayAcc(ServiceTaxSetup));
      GLEntryDoesNotExist(DocumentNo,ReverseServiceTaxHelper.GetServTaxRecAcc(ServiceTaxSetup));
      GLEntryDoesNotExist(DocumentNo,ReverseServiceTaxHelper.GetServTaxInterimRecAcc(ServiceTaxSetup));

Example

There are no examples available.
Member of Miscellaneous.Service Tax Verify


STDetailAmounts@1500039 Method

The procedure STDetailAmounts is available in codeunit 143004.

Syntax

STDetailAmounts@1500039(
    ServiceTaxEntryDetails@1500007 : Record 16474 ServiceTaxEntryDetails, //Input parameter of type Record
    BaseAmount@1500006 : Decimal BaseAmount, //Input parameter of type Decimal
    ServTaxSetup@1500005 : Record 16472 ServTaxSetup, //Input parameter of type Record
    PartialPaymentFactor@1500004 : Decimal PartialPaymentFactor, //Input parameter of type Decimal
    RevChargeCreditClosed@1500003 : Boolean RevChargeCreditClosed, //Input parameter of type Boolean
    RealCreditClosed@1500002 : Boolean RealCreditClosed, //Input parameter of type Boolean
    Percentage@1500001 : Integer Percentage, //Input parameter of type Integer
    RevChargePart@1500000 : Boolean RevChargePart //Input parameter of type Boolean
);

Parameters

ServiceTaxEntryDetails
Input parameter of type Record
BaseAmount
Input parameter of type Decimal
ServTaxSetup
Input parameter of type Record
PartialPaymentFactor
Input parameter of type Decimal
RevChargeCreditClosed
Input parameter of type Boolean
RealCreditClosed
Input parameter of type Boolean
Percentage
Input parameter of type Integer
RevChargePart
Input parameter of type Boolean

Remarks

The relevant search keywords are: ST, Detail, Amounts.

For a clarification about how this function works, refer to the code listed below.

      IF ServiceTaxEntryDetails."Reverse Charge" THEN
        VerifyRCRemCrSTEntryAmounts(
          ServiceTaxEntryDetails,BaseAmount,Percentage,ServTaxSetup,RevChargeCreditClosed,PartialPaymentFactor,RevChargePart);

      // This is the case where only Reverse Charge Invoice has been posted and not paid to Government yet.
      // In this case, we will not validate the real credit fields because they are not touched yet.
      IF ServiceTaxEntryDetails."Reverse Charge" AND NOT RevChargeCreditClosed AND RealCreditClosed THEN
        EXIT;

      VerifyNonRCRemCrSTEntryAmounts(
        ServiceTaxEntryDetails,BaseAmount,Percentage,ServTaxSetup,RealCreditClosed,PartialPaymentFactor,RevChargePart);

Example

There are no examples available.
Member of Miscellaneous.Service Tax Verify


STDetailAmountsAndStatus@1500072 Method

The procedure STDetailAmountsAndStatus is available in codeunit 143004.

Syntax

STDetailAmountsAndStatus@1500072(
    ServiceTaxEntryDetails@1500000 : Record 16474 ServiceTaxEntryDetails, //Input parameter of type Record
    BaseAmount@1500002 : Decimal BaseAmount, //Input parameter of type Decimal
    ServTaxSetup@1500001 : Record 16472 ServTaxSetup, //Input parameter of type Record
    PartialPaymentFactor@1500003 : Decimal PartialPaymentFactor, //Input parameter of type Decimal
    RevChargeCreditClosed@1500008 : Boolean RevChargeCreditClosed, //Input parameter of type Boolean
    RealCreditClosed@1500007 : Boolean RealCreditClosed, //Input parameter of type Boolean
    Percentage@1500006 : Integer Percentage, //Input parameter of type Integer
    RevChargePart@1500004 : Boolean RevChargePart //Input parameter of type Boolean
);

Parameters

ServiceTaxEntryDetails
Input parameter of type Record
BaseAmount
Input parameter of type Decimal
ServTaxSetup
Input parameter of type Record
PartialPaymentFactor
Input parameter of type Decimal
RevChargeCreditClosed
Input parameter of type Boolean
RealCreditClosed
Input parameter of type Boolean
Percentage
Input parameter of type Integer
RevChargePart
Input parameter of type Boolean

Remarks

The relevant search keywords are: ST, Detail, Amounts, Status.

For a clarification about how this function works, refer to the code listed below.

      STDetailAmounts(
        ServiceTaxEntryDetails,BaseAmount,ServTaxSetup,PartialPaymentFactor,
        RevChargeCreditClosed,RealCreditClosed,Percentage,RevChargePart);
      STDetailStatus(ServiceTaxEntryDetails,RevChargeCreditClosed,RealCreditClosed);

Example

There are no examples available.
Member of Miscellaneous.Service Tax Verify


STDetailsAfterPayRCToGovSplit@1500118 Method

The procedure STDetailsAfterPayRCToGovSplit is available in codeunit 143004.

Syntax

STDetailsAfterPayRCToGovSplit@1500118(
    DocumentNo@1500003 : Code[20] DocumentNo, //Input parameter of type Code
    BaseAmount@1500001 : Decimal BaseAmount, //Input parameter of type Decimal
    Percentage@1500004 : Integer Percentage, //Input parameter of type Integer
    RevChrgPart@1500005 : Boolean RevChrgPart, //Input parameter of type Boolean
    ServTaxSetup@1500000 : Record 16472 ServTaxSetup, //Input parameter of type Record
    PartialPaymentFactor@1500007 : Decimal PartialPaymentFactor, //Input parameter of type Decimal
    ServiceTypeRevChrg@1500002 : Option ServiceTypeRevChrg //Input parameter of type Option
);

Parameters

DocumentNo
Input parameter of type Code
BaseAmount
Input parameter of type Decimal
Percentage
Input parameter of type Integer
RevChrgPart
Input parameter of type Boolean
ServTaxSetup
Input parameter of type Record
PartialPaymentFactor
Input parameter of type Decimal
ServiceTypeRevChrg
Input parameter of type Option

Remarks

The relevant search keywords are: ST, Details, After, Pay, RC, To, Gov, Split.

For a clarification about how this function works, refer to the code listed below.

      RevChargeCreditClosed := TRUE;
      IF RevChrgPart THEN
        RealCreditClosed := ServiceTypeRevChrg = GenJournalLine."Service Type (Rev. Chrg.)"::Outward
      ELSE
        RealCreditClosed := FALSE;
      STDetailsHelperSplit(DocumentNo,BaseAmount,Percentage,RevChrgPart,
        ServTaxSetup,PartialPaymentFactor,RevChargeCreditClosed,RealCreditClosed);

Example

The below example is extracted from the test automation codeunit 144034 to show one way of using this function.

      Initialize;
      ReverseServiceTaxHelper.SetupCompanyInfo;

      // Setup
      Percentage := LibraryRandom.RandIntInRange(10,90);
      ReverseServiceTaxHelper.CreatePurchaseDocFromGenJnl(GenJournalLine,GenJournalLine."Document Type"::Invoice,
        ServiceTypeRevChrg,ReverseChargeTypeOption::Standard,TRUE,Percentage);
      PostedDocNo := GenJournalLine."Document No.";
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      PartialFactor := GetPartialFactor;
      PaymentDocNo := ReverseServiceTaxHelper.PostPayment(GenJournalLine."Account No.",
          PartialFactor * ReverseServiceTaxHelper.CalculatePayment(GenJournalLine."Document Type"::Invoice,ABS(GenJournalLine.Amount),
            ServiceTaxSetup,Percentage),GenJournalLine."Posting Date",GenJournalLine."Document Type"::Payment);

      ReverseServiceTaxHelper.ApplyAndPostVendorEntry(GenJournalLine."Document Type"::Invoice,PostedDocNo,
        GenJournalLine."Document Type"::Payment,PaymentDocNo);

      // Exercise and Verify
      PaymentToGovDocNo :=
        ReverseServiceTaxHelper.PayServiceTax(
          GenJournalLine."Service Tax Registration No.",GenJournalLine."Service Tax Group Code",TRUE);

      // Verify
      ReverseServiceTaxHelper.CalcSplitAmounts(GenJournalLine,BaseAmount,PoTAmount,RevChrgAmount,Percentage,ServiceTaxSetup);
      PoTSBCandKKCAmount :=
        ReverseServiceTaxHelper.CalculatePoTSBCandKKCAmount(BaseAmount,(100 - Percentage) / 100,ServiceTaxSetup);
      ServiceTaxVerify.GLEntriesForSTPmtEntriesForAmt(
        (RevChrgAmount + PoTSBCandKKCAmount) * PartialFactor,ServiceTaxSetup,PaymentToGovDocNo,ServiceTypeRevChrg);

      // Real Service Tax Part - because the Real Service Tax Detail entry is created when posting the invoice for the whole amount
      // so partial factor is 1.
      ServiceTaxVerify.STDetailsAfterPayRCToGovSplit(GenJournalLine."Document No.",BaseAmount,Percentage,
        FALSE,ServiceTaxSetup,1,ServiceTypeRevChrg);
      // Rev charge Service Tax Part
      ServiceTaxVerify.STDetailsAfterPayRCToGovSplit(PaymentDocNo,BaseAmount,Percentage,
        TRUE,ServiceTaxSetup,PartialFactor,ServiceTypeRevChrg);
Member of Miscellaneous.Service Tax Verify


STDetailStatus@1500073 Method

The procedure STDetailStatus is available in codeunit 143004.

Syntax

STDetailStatus@1500073(
    ServiceTaxEntryDetails@1500007 : Record 16474 ServiceTaxEntryDetails, //Input parameter of type Record
    RevChargeCreditClosed@1500003 : Boolean RevChargeCreditClosed, //Input parameter of type Boolean
    RealCreditClosed@1500002 : Boolean RealCreditClosed //Input parameter of type Boolean
);

Parameters

ServiceTaxEntryDetails
Input parameter of type Record
RevChargeCreditClosed
Input parameter of type Boolean
RealCreditClosed
Input parameter of type Boolean

Remarks

The relevant search keywords are: ST, Detail, Status.

For a clarification about how this function works, refer to the code listed below.

      IF ServiceTaxEntryDetails."Reverse Charge" THEN
        VerifyRCRemCrSTEntryStatus(ServiceTaxEntryDetails,RevChargeCreditClosed);

      // This is the case where only Reverse Charge Invoice has been posted and not paid to Government yet.
      // In this case, we will not validate the real credit fields because they are not touched yet.
      IF ServiceTaxEntryDetails."Reverse Charge" AND NOT RevChargeCreditClosed AND RealCreditClosed THEN
        EXIT;

      VerifyNonRCRemCrStEntryStatus(ServiceTaxEntryDetails,RealCreditClosed);

Example

There are no examples available.
Member of Miscellaneous.Service Tax Verify


STEntriesAfterTakeSalesCredit@1500024 Method

The procedure STEntriesAfterTakeSalesCredit is available in codeunit 143004.

Syntax

STEntriesAfterTakeSalesCredit@1500024(
    LastTransactionNo@1500000 : Integer LastTransactionNo //Input parameter of type Integer
);

Parameters

LastTransactionNo
Input parameter of type Integer

Remarks

The relevant search keywords are: ST, Entries, After, Take, Sales, Credit.

For a clarification about how this function works, refer to the code listed below.

      CalcSTEntryDetailsBalances(LastTransactionNo,TotalSTEntryDetails);

      WITH TotalSTEntryDetails DO BEGIN
        Assert.AreEqual(0,"Remaining Credit",
          STRSUBSTNO(ServiceTaxFieldBalanceErr,FIELDCAPTION("Remaining Credit"),TABLECAPTION));
        Assert.AreEqual(0,"Remaining Credit (eCess)",
          STRSUBSTNO(ServiceTaxFieldBalanceErr,FIELDCAPTION("Remaining Credit (eCess)"),TABLECAPTION));
        Assert.AreEqual(0,"Remaining Credit (SHECess)",
          STRSUBSTNO(ServiceTaxFieldBalanceErr,FIELDCAPTION("Remaining Credit (SHECess)"),TABLECAPTION));
        Assert.AreEqual(0,"Remaining Credit (KK Cess)",
          STRSUBSTNO(ServiceTaxFieldBalanceErr,FIELDCAPTION("Remaining Credit (KK Cess)"),TABLECAPTION));
      END;

      STEntryDetailsStatuses(LastTransactionNo);

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      LastTransactionNo := Initialize;
      ReverseServiceTaxHelper.SetupCompanyInfo;

      // Setup
      DocumentType := PurchaseHeader."Document Type"::Invoice;
      SrvTypeRevChrg := PurchaseHeader."Service Type (Rev. Chrg.)"::Inward;
      ReverseChargeTypeParam := ReverseChargeType::Standard;

      AdvPmtRCApplyAdvPmtToInvPayST(PostedAdvancePaymentDocNo,PostedPayRCToGovDocNo,PostedPurchInvoiceDocNo,
        ServiceTaxSetup,BaseAmount,TaxAmount,
        DocumentType,SrvTypeRevChrg,ReverseChargeTypeParam,GenJournalLine);

      // Exercise
      PostSlsInvPaySTUseCrAvailable(PostedSalesInvoiceDocNo,PostedAdvancePaymentDocNo);

      // Verify:
      ServiceTaxVerify.STEntriesAfterTakeSalesCredit(LastTransactionNo);
Member of Miscellaneous.Service Tax Verify


STEntriesAppln@1500006 Method

The procedure STEntriesAppln is available in codeunit 143004.

Syntax

STEntriesAppln@1500006(
    LastTransactionNo@1500000 : Integer LastTransactionNo, //Input parameter of type Integer
    GenJnlLine@1500001 : Record 81 GenJnlLine, //Input parameter of type Record
    BaseAmount@1500002 : Decimal BaseAmount, //Input parameter of type Decimal
    RevChargeTypeParam@1500004 : Option RevChargeTypeParam //Input parameter of type Option
);

Parameters

LastTransactionNo
Input parameter of type Integer
GenJnlLine
Input parameter of type Record
BaseAmount
Input parameter of type Decimal
RevChargeTypeParam
Input parameter of type Option

Remarks

The relevant search keywords are: ST, Entries, Application.

For a clarification about how this function works, refer to the code listed below.

      IF RevChargeTypeParam = ReverseChargeType::" " THEN
        STEntriesFullPurchFlow(LastTransactionNo,GenJnlLine,BaseAmount,RevChargeTypeParam)
      ELSE
        STEntriesRevChrgAppln(LastTransactionNo,GenJnlLine,BaseAmount);

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      // Setup
      LastTransactionNo := Initialize;

      // Exercise
      ApplyAdvPmtToInvoice(GenJournalLine,BaseAmount,TaxAmount,SBCAmount,KKCAmount,
        GenJournalLine."Document Type"::Invoice,ReverseChargeType::" ",FALSE);

      // Verify
      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      ServiceTaxVerify.AdvPaymentOnlineAppGLBalance(ReverseChargeType,ServiceTaxSetup,TaxAmount,FALSE);
      ServiceTaxVerify.AdvPaymentOnlineAppSBCKKCGLBalance(ReverseChargeType,ServiceTaxSetup,SBCAmount,KKCAmount,FALSE);

      // Service Tax Entries
      ServiceTaxVerify.STEntriesAppln(LastTransactionNo,GenJournalLine,BaseAmount,ReverseChargeType::" ");
Member of Miscellaneous.Service Tax Verify


STEntriesCanceledDocument@1500014 Method

The procedure STEntriesCanceledDocument is available in codeunit 143004.

Syntax

STEntriesCanceledDocument@1500014(
    LastTransactionNo@1500000 : Integer LastTransactionNo //Input parameter of type Integer
);

Parameters

LastTransactionNo
Input parameter of type Integer

Remarks

The relevant search keywords are: ST, Entries, Canceled, Document.

For a clarification about how this function works, refer to the code listed below.

      ExpectedServTaxEntry.INIT; // Expect balances = 0
      ExpectedServTaxEntryDetails.INIT; // Expect balances = 0

      STEntryBalances(LastTransactionNo,ExpectedServTaxEntry);
      STEntryDtlsBalancesAndStatuses(LastTransactionNo,ExpectedServTaxEntryDetails);

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      ServiceTaxSetup.FindOnDate(AdvPmtGenJnlLine."Service Tax Group Code",AdvPmtGenJnlLine."Posting Date");
      ServiceTaxVerify.STEntriesCanceledDocument(LastTransactionNo);
      ServiceTaxVerify.VendorLedgerEntryOpen(AdvPmtGenJnlLine."Document No.",FALSE);
      ServiceTaxVerify.VendorLedgerEntryOpen(RefundGenJnlLine."Document No.",FALSE);
      ServiceTaxVerify.ServTaxGLAccountsBalance(ServiceTaxSetup,0,0,0,0);
Member of Miscellaneous.Service Tax Verify


STEntriesFullPurchFlow@1500010 Method

The procedure STEntriesFullPurchFlow is available in codeunit 143004.

Syntax

STEntriesFullPurchFlow@1500010(
    LastTransactionNo@1500000 : Integer LastTransactionNo, //Input parameter of type Integer
    GenJnlLine@1500001 : Record 81 GenJnlLine, //Input parameter of type Record
    BaseAmount@1500002 : Decimal BaseAmount, //Input parameter of type Decimal
    RevChargeType@1500004 : Option RevChargeType //Input parameter of type Option
);

Parameters

LastTransactionNo
Input parameter of type Integer
GenJnlLine
Input parameter of type Record
BaseAmount
Input parameter of type Decimal
RevChargeType
Input parameter of type Option

Remarks

The relevant search keywords are: ST, Entries, Full, Purchase, Flow.

For a clarification about how this function works, refer to the code listed below.

      ReverseServiceTaxHelper.FillExpectedAmntsSTEntry(GenJnlLine,BaseAmount,ExpectedServTaxEntry);
      ReverseServiceTaxHelper.FillExpectedAmntsFullPurchFlow(ExpectedServTaxEntryDetails,ExpectedServTaxEntry);

      IF (NOT GenJnlLine.PoT) AND (RevChargeType = ReverseChargeType::" ") THEN
        DoubleExpectedAmntsSTEntry(ExpectedServTaxEntry);

      STEntryBalances(LastTransactionNo,ExpectedServTaxEntry);

      IF GenJnlLine."Service Type (Rev. Chrg.)" = GenJnlLine."Service Type (Rev. Chrg.)"::Outward THEN
        UpdateExpectedAmountsOutward(GenJnlLine,ExpectedServTaxEntryDetails);

      STEntryDtlsBalancesAndStatuses(LastTransactionNo,ExpectedServTaxEntryDetails);

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      LastTransactionNo := Initialize;
      ReverseServiceTaxHelper.SetupCompanyInfo;

      DocumentType := PurchaseHeader."Document Type"::Invoice;
      ReverseChargeTypeParam := ReverseChargeType::Standard;
      AdvPmtRCApplyAdvPmtToInvPayST(PostedAdvancePaymentDocNo,PostedPayRCToGovDocNo,PostedPurchInvoiceDocNo,
        ServiceTaxSetup,BaseAmount,TaxAmount,
        DocumentType,SrvTypeRevChrg,ReverseChargeTypeParam,GenJournalLine);

      // Verify
      VerifyGLEntriesForPayToGov(GenJournalLine,PostedPayRCToGovDocNo);
      ServiceTaxVerify.STEntriesFullPurchFlow(LastTransactionNo,GenJournalLine,BaseAmount,ReverseChargeTypeParam);
Member of Miscellaneous.Service Tax Verify


STEntriesVsGLBalCrMPmt@1500064 Method

The procedure STEntriesVsGLBalCrMPmt is available in codeunit 143004.

Syntax

STEntriesVsGLBalCrMPmt@1500064(
    LastTransactionNo@1500000 : Integer LastTransactionNo //Input parameter of type Integer
);

Parameters

LastTransactionNo
Input parameter of type Integer

Remarks

The relevant search keywords are: ST, Entries, Vs, General Ledger, Bal, Credit, M, Payment.

For a clarification about how this function works, refer to the code listed below.

      CalcSTEntryDetailsBalances(LastTransactionNo,TotalSTEntryDetails);
      GLSetup.GET;
      WITH TotalSTEntryDetails DO BEGIN
        ServiceTaxSetup.FindOnDate("Service Tax Group Code","Posting Date");
        ApproxTotalTaxAmount := ReverseServiceTaxHelper.CalculateServTaxTotal("Base Amount",ServiceTaxSetup);
        ApproxTotalKKCAmount := ReverseServiceTaxHelper.CalculateKKCess("Base Amount",ServiceTaxSetup);
        Assert.AreNearlyEqual(
          ApproxTotalTaxAmount,FullRemainingCredit + FullRevChargeRemainingCredit,GLSetup."Service Tax Rounding Precision",
          STRSUBSTNO(ServiceTaxFieldBalanceErr,FIELDCAPTION("Remaining Credit"),TABLECAPTION));
        Assert.AreNearlyEqual(
          ApproxTotalKKCAmount,KKCessRemainingCredit + KKcessRevChargeRemainingCredit,
          GLSetup."Service Tax Rounding Precision",
          STRSUBSTNO(ServiceTaxFieldBalanceErr,FIELDCAPTION("Remaining Credit (KK Cess)"),TABLECAPTION));
        ServTaxGLAccountsBalance(
          ServiceTaxSetup,FullRemainingCredit,FullRevChargeRemainingCredit,-FullRevChargeRemainingCredit,0);
        KKCGLAccountsBalance(
          ServiceTaxSetup,KKCessRemainingCredit,KKcessRevChargeRemainingCredit,-KKcessRevChargeRemainingCredit,0);
      END;
      STEntryDetailsStatuses(LastTransactionNo);

Example

The below example is extracted from the test automation codeunit 144034 to show one way of using this function.

      LastTransactionNo := Initialize;
      ReverseServiceTaxHelper.SetupCompanyInfo;

      ApplCrMemoAndPmtToInvPayToGov(GenJournalLine."Service Type (Rev. Chrg.)"::Inward,InvoiceDocNo,CrMemoDocNo);

      ServiceTaxVerify.DocHasClosedRemCredit(CrMemoDocNo);
      ServiceTaxVerify.STEntryDetailsRemRevChrgCredit(LastTransactionNo,0);
      ServiceTaxVerify.STEntriesVsGLBalCrMPmt(LastTransactionNo);
Member of Miscellaneous.Service Tax Verify


STEntriesVsGLBalCrMPmtOutward@1500065 Method

The procedure STEntriesVsGLBalCrMPmtOutward is available in codeunit 143004.

Syntax

STEntriesVsGLBalCrMPmtOutward@1500065(
    LastTransactionNo@1500000 : Integer LastTransactionNo //Input parameter of type Integer
);

Parameters

LastTransactionNo
Input parameter of type Integer

Remarks

The relevant search keywords are: ST, Entries, Vs, General Ledger, Bal, Credit, M, Payment, Outward.

For a clarification about how this function works, refer to the code listed below.

      CalcSTEntryDetailsBalances(LastTransactionNo,TotalSTEntryDetails);
      TotalSTEntryDetailsRevChrg.SETRANGE("Reverse Charge",TRUE);
      CalcSTEntryDetailsBalances(LastTransactionNo,TotalSTEntryDetailsRevChrg);

      GLSetup.GET;
      WITH TotalSTEntryDetails DO BEGIN
        ServiceTaxSetup.FindOnDate("Service Tax Group Code","Posting Date");
        ApproxTotalTaxAmount := ReverseServiceTaxHelper.CalculateServTaxTotal("Base Amount",ServiceTaxSetup);
        ApproxTotalKKCAmount := ReverseServiceTaxHelper.CalculateKKCess("Base Amount",ServiceTaxSetup);

        Assert.AreNearlyEqual(
          ApproxTotalTaxAmount,FullRemainingCredit + TotalSTEntryDetailsRevChrg.FullTaxAmount,
          2 * GLSetup."Service Tax Rounding Precision",
          STRSUBSTNO(ServiceTaxFieldBalanceErr,FIELDCAPTION("Remaining Credit"),TABLECAPTION));
        Assert.AreNearlyEqual(
          ApproxTotalKKCAmount,KKCessRemainingCredit + TotalSTEntryDetailsRevChrg.KKCessAmount,
          2 * GLSetup."Service Tax Rounding Precision",
          STRSUBSTNO(ServiceTaxFieldBalanceErr,FIELDCAPTION("Remaining Credit (KK Cess)"),TABLECAPTION));
        ServTaxGLAccountsBalance(
          ServiceTaxSetup,FullRemainingCredit,FullRevChargeRemainingCredit,-FullRevChargeRemainingCredit,0);
        KKCGLAccountsBalance(
          ServiceTaxSetup,KKCessRemainingCredit,KKcessRevChargeRemainingCredit,-KKcessRevChargeRemainingCredit,0);
      END;
      STEntryDetailsStatuses(LastTransactionNo);

Example

The below example is extracted from the test automation codeunit 144034 to show one way of using this function.

      LastTransactionNo := Initialize;
      ReverseServiceTaxHelper.SetupCompanyInfo;

      ApplCrMemoAndPmtToInvPayToGov(GenJournalLine."Service Type (Rev. Chrg.)"::Outward,InvoiceDocNo,CrMemoDocNo);

      ServiceTaxVerify.DocHasClosedRemCredit(CrMemoDocNo);
      ServiceTaxVerify.STEntryDetailsRemRevChrgCredit(LastTransactionNo,0);
      ServiceTaxVerify.STEntriesVsGLBalCrMPmtOutward(LastTransactionNo);
Member of Miscellaneous.Service Tax Verify


STEntriesVsGLBalInvCrM@1500069 Method

The procedure STEntriesVsGLBalInvCrM is available in codeunit 143004.

Syntax

STEntriesVsGLBalInvCrM@1500069(
    LastTransactionNo@1500000 : Integer LastTransactionNo //Input parameter of type Integer
);

Parameters

LastTransactionNo
Input parameter of type Integer

Remarks

The relevant search keywords are: ST, Entries, Vs, General Ledger, Bal, Invoice, CrM.

For a clarification about how this function works, refer to the code listed below.

      CalcSTEntryDetailsBalances(LastTransactionNo,TotalSTEntryDetails);
      TotalSTEntryRevChrg.SETRANGE("Reverse Charge",TRUE);
      CalcSTEntryBalances(LastTransactionNo,TotalSTEntryRevChrg);

      GLSetup.GET;
      WITH TotalSTEntryDetails DO BEGIN
        ServiceTaxSetup.FindOnDate("Service Tax Group Code","Posting Date");
        ApproxTotalTaxAmount := ReverseServiceTaxHelper.CalculateServTaxTotal("Base Amount",ServiceTaxSetup);
        ApproxTotalKKCAmount := ReverseServiceTaxHelper.CalculateKKCess("Base Amount",ServiceTaxSetup);
        Assert.AreNearlyEqual(
          ApproxTotalTaxAmount,FullRemainingCredit + FullRevChargeRemainingCredit,GLSetup."Service Tax Rounding Precision",
          STRSUBSTNO(ServiceTaxFieldBalanceErr,FIELDCAPTION("Remaining Credit"),TABLECAPTION));
        Assert.AreNearlyEqual(
          ApproxTotalKKCAmount,KKCessRemainingCredit + KKcessRevChargeRemainingCredit,
          GLSetup."Service Tax Rounding Precision",
          STRSUBSTNO(ServiceTaxFieldBalanceErr,FIELDCAPTION("Remaining Credit (KK Cess)"),TABLECAPTION));
        ServTaxGLAccountsBalance(
          ServiceTaxSetup,FullRemainingCredit,TotalSTEntryRevChrg.FullTaxAmount,0,-TotalSTEntryRevChrg.FullTaxAmount);
        KKCGLAccountsBalance(
          ServiceTaxSetup,KKCessRemainingCredit,TotalSTEntryRevChrg.KKCessAmount,0,-TotalSTEntryRevChrg.KKCessAmount);
      END;
      STEntryDetailsStatuses(LastTransactionNo);

Example

The below example is extracted from the test automation codeunit 144034 to show one way of using this function.

      ServiceTaxVerify.VendorLedgerEntryOpen(GenJnlLine."Document No.",ABS(GenJnlLine.Amount) > ABS(CreditMemoAmount));
      ServiceTaxVerify.VendorLedgerEntryOpen(CrMemoDocNo,ABS(GenJnlLine.Amount) < ABS(CreditMemoAmount));

      ServiceTaxSetup.FindOnDate(GenJnlLine."Service Tax Group Code",GenJnlLine."Posting Date");
      ReverseServiceTaxHelper.CalcSplitAmounts(GenJnlLine,InvoiceBaseAmount,PoTAmount[1],RevChrgAmount[1],Percentage,ServiceTaxSetup);
      GenJnlLine.Amount := ABS(CreditMemoAmount);
      ReverseServiceTaxHelper.CalcSplitAmounts(GenJnlLine,CrMemoBaseAmount,PoTAmount[2],RevChrgAmount[2],Percentage,ServiceTaxSetup);

      ServiceTaxVerify.STEntriesVsGLBalInvCrM(LastTransactionNo);
      ServiceTaxVerify.CountOfServiceTaxEntries(LastTransactionNo,4,6);
      VerifySTEntriesBalance(LastTransactionNo,PoTAmount[1] - PoTAmount[2] + RevChrgAmount[1] - RevChrgAmount[2]);
      ServiceTaxVerify.CalcSTEntryDetailsBalances(LastTransactionNo,ServiceTaxEntryDetails);
      TotRemainCredit := ServiceTaxEntryDetails.FullRemainingSBCCredit + ServiceTaxEntryDetails.KKCessRemainingCredit;
      ServiceTaxVerify.STEntryDetailsRemainingCredit(LastTransactionNo,(PoTAmount[1] - PoTAmount[2]) - TotRemainCredit);
      ServiceTaxVerify.STEntryDetailsRemRevChrgCredit(LastTransactionNo,0);
      ServiceTaxVerify.DocHasClosedRemCredit(CrMemoDocNo);
Member of Miscellaneous.Service Tax Verify


STEntryBalances@1500066 Method

The procedure STEntryBalances is available in codeunit 143004.

Syntax

STEntryBalances@1500066(
    LastTransactionNo@1500000 : Integer LastTransactionNo, //Input parameter of type Integer
    ExpectedServTaxEntry@1500005 : Record 16473 ExpectedServTaxEntry //Input parameter of type Record
);

Parameters

LastTransactionNo
Input parameter of type Integer
ExpectedServTaxEntry
Input parameter of type Record

Remarks

The relevant search keywords are: ST, Entry, Balances.

For a clarification about how this function works, refer to the code listed below.

      CalcSTEntryBalances(LastTransactionNo,TotalSTEntry);

      GLSetup.GET;
      WITH TotalSTEntry DO BEGIN
        Assert.AreNearlyEqual(
          ExpectedServTaxEntry."Service Tax Amount","Service Tax Amount",GLSetup."Service Tax Rounding Precision",
          STRSUBSTNO(ServiceTaxFieldBalanceErr,FIELDCAPTION("Service Tax Amount"),TABLECAPTION));
        Assert.AreNearlyEqual(
          ExpectedServTaxEntry."Service Tax SBC Amount","Service Tax SBC Amount",GLSetup."Service Tax Rounding Precision",
          STRSUBSTNO(ServiceTaxFieldBalanceErr,FIELDCAPTION("Service Tax SBC Amount"),TABLECAPTION));
        Assert.AreNearlyEqual(
          ExpectedServTaxEntry."KK Cess Amount","KK Cess Amount",GLSetup."Service Tax Rounding Precision",
          STRSUBSTNO(ServiceTaxFieldBalanceErr,FIELDCAPTION("KK Cess Amount"),TABLECAPTION));
        Assert.AreNearlyEqual(ExpectedServTaxEntry."eCess Amount","eCess Amount",GLSetup."Service Tax Rounding Precision",
          STRSUBSTNO(ServiceTaxFieldBalanceErr,FIELDCAPTION("eCess Amount"),TABLECAPTION));
        Assert.AreNearlyEqual(ExpectedServTaxEntry."SHE Cess Amount","SHE Cess Amount",GLSetup."Service Tax Rounding Precision",
          STRSUBSTNO(ServiceTaxFieldBalanceErr,FIELDCAPTION("SHE Cess Amount"),TABLECAPTION));
      END;

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      ReverseServiceTaxHelper.FillExpectedAmntsSTEntry(PmtGenJnlLine,PmtBaseAmount + InvBaseAmount,ExpectedServTaxEntry);
      ServiceTaxVerify.STEntryBalances(LastTransactionNo,ExpectedServTaxEntry);

      IF PmtBaseAmount < InvBaseAmount THEN
        ReverseServiceTaxHelper.FillExpectedAmntsSTEntry(PmtGenJnlLine,PmtBaseAmount,ExpectedServTaxEntry)
      ELSE
        ReverseServiceTaxHelper.FillExpectedAmntsSTEntry(PmtGenJnlLine,InvBaseAmount,ExpectedServTaxEntry);

      ReverseServiceTaxHelper.FillExpectedAmntsFullPurchFlow(ExpectedServTaxEntryDetails,ExpectedServTaxEntry);
      ServiceTaxVerify.STEntryDtlsBalancesAndStatuses(LastTransactionNo,ExpectedServTaxEntryDetails);
Member of Miscellaneous.Service Tax Verify


STEntryDetailsForAccount@1500037 Method

The procedure STEntryDetailsForAccount is available in codeunit 143004.

Syntax

STEntryDetailsForAccount@1500037(
    DocumentNo@1500003 : Code[20] DocumentNo, //Input parameter of type Code
    AccountNo@1500004 : Code[20] AccountNo, //Input parameter of type Code
    BaseAmount@1500001 : Decimal BaseAmount, //Input parameter of type Decimal
    ServTaxSetup@1500000 : Record 16472 ServTaxSetup, //Input parameter of type Record
    RevChargeCreditClosed@1500008 : Boolean RevChargeCreditClosed, //Input parameter of type Boolean
    RealCreditClosed@1500007 : Boolean RealCreditClosed //Input parameter of type Boolean
);

Parameters

DocumentNo
Input parameter of type Code
AccountNo
Input parameter of type Code
BaseAmount
Input parameter of type Decimal
ServTaxSetup
Input parameter of type Record
RevChargeCreditClosed
Input parameter of type Boolean
RealCreditClosed
Input parameter of type Boolean

Remarks

The relevant search keywords are: ST, Entry, Details, For, Account.

For a clarification about how this function works, refer to the code listed below.

      ServiceTaxEntryDetails.SETRANGE("Document No.",DocumentNo);
      ServiceTaxEntryDetails.SETRANGE("GL Account",AccountNo);
      ServiceTaxEntryDetails.FINDLAST;
      PartialPaymentFactor := 0;
      SplitPercentage := 0;
      STDetailAmountsAndStatus(ServiceTaxEntryDetails,BaseAmount,ServTaxSetup,PartialPaymentFactor,RevChargeCreditClosed,
        RealCreditClosed,SplitPercentage,FALSE);

Example

The below example is extracted from the test automation codeunit 144039 to show one way of using this function.

      Initialize;

      // Post Purchase Invoice 1
      VendorNo := ReverseServiceTaxHelper.CreateVendor;
      PostedDocNo1 := ReverseServiceTaxHelper.PostPurchaseDocForVendor(
          PurchaseHeader1,PurchaseLine1,VendorNo,DocumentType,ReverseChargeType,FALSE);
      PostedDocNo2 := ReverseServiceTaxHelper.PostPurchaseDocForVendor(
          PurchaseHeader2,PurchaseLine2,VendorNo,DocumentType,ReverseChargeType,FALSE);

      // Post Payment
      ServiceTaxSetup1.FindOnDate(PurchaseLine1."Service Tax Group",PurchaseHeader1."Posting Date");
      ServiceTaxSetup2.FindOnDate(PurchaseLine2."Service Tax Group",PurchaseHeader2."Posting Date");
      PaymentDocNo := ReverseServiceTaxHelper.PostPayment(PurchaseHeader1."Pay-to Vendor No.",
          ReverseServiceTaxHelper.CalculatePayment(PurchaseLine1."Document Type",PurchaseLine1."Line Amount",ServiceTaxSetup1,100) +
          ReverseServiceTaxHelper.CalculatePayment(PurchaseLine2."Document Type",PurchaseLine2."Line Amount",ServiceTaxSetup2,100),
          PurchaseHeader1."Posting Date",ReverseServiceTaxHelper.GetApplyingDocType(DocumentType));

      // Exercise:
      ReverseServiceTaxHelper.ApplyAndPostVendorEntry(PurchaseHeader1."Document Type"::Invoice,PostedDocNo1,
        VendorLedgerEntry."Document Type"::Payment,PaymentDocNo);
      ReverseServiceTaxHelper.ApplyAndPostVendorEntry(PurchaseHeader1."Document Type"::Invoice,PostedDocNo2,
        VendorLedgerEntry."Document Type"::Payment,PaymentDocNo);

      // Verify:
      BaseAmount := ReverseServiceTaxHelper.CalculateServTaxBase(PurchaseLine1."Line Amount",DocumentType);
      ServiceTaxAmount := ReverseServiceTaxHelper.CalculateServTaxTotal(BaseAmount,ServiceTaxSetup1);
      SBCAmount := ReverseServiceTaxHelper.CalculateSBC(BaseAmount,ServiceTaxSetup1);
      KKCAmount := ReverseServiceTaxHelper.CalculateKKCess(BaseAmount,ServiceTaxSetup1);
      ServiceTaxVerify.GLBalanceRevCharge(ServiceTaxSetup1,ServiceTaxAmount);
      ServiceTaxVerify.GLSBCBalanceRevCharge(ServiceTaxSetup1,SBCAmount);
      ServiceTaxVerify.GLKKCBalanceRevCharge(ServiceTaxSetup1,KKCAmount);

      RevChargeCreditClosed := ReverseChargeType = ServiceTaxType::" ";
      RealCreditClosed := ReverseChargeType <> ServiceTaxType::" ";
      AccountNo := ReverseServiceTaxHelper.GetServTaxPayAcc(ServiceTaxSetup1);
      ServiceTaxVerify.STEntryDetailsForAccount(PaymentDocNo,AccountNo,BaseAmount,ServiceTaxSetup1,
        RevChargeCreditClosed,RealCreditClosed);

      BaseAmount := ReverseServiceTaxHelper.CalculateServTaxBase(PurchaseLine2."Line Amount",DocumentType);
      ServiceTaxAmount := ReverseServiceTaxHelper.CalculateServTaxTotal(BaseAmount,ServiceTaxSetup2);
      SBCAmount := ReverseServiceTaxHelper.CalculateSBC(BaseAmount,ServiceTaxSetup2);
      KKCAmount := ReverseServiceTaxHelper.CalculateKKCess(BaseAmount,ServiceTaxSetup2);

      ServiceTaxVerify.GLBalanceRevCharge(ServiceTaxSetup2,ServiceTaxAmount);
      ServiceTaxVerify.GLSBCBalanceRevCharge(ServiceTaxSetup2,SBCAmount);
      ServiceTaxVerify.GLKKCBalanceRevCharge(ServiceTaxSetup2,KKCAmount);

      AccountNo := ReverseServiceTaxHelper.GetServTaxPayAcc(ServiceTaxSetup2);
      ServiceTaxVerify.STEntryDetailsForAccount(PaymentDocNo,AccountNo,BaseAmount,ServiceTaxSetup2,
        RevChargeCreditClosed,RealCreditClosed);

      ServiceTaxVerify.VendorLedgerEntryOpen(PostedDocNo1,FALSE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedDocNo2,FALSE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PaymentDocNo,FALSE);
Member of Miscellaneous.Service Tax Verify


STEntryDetailsKKCRemainingCredit@1500123 Method

The procedure STEntryDetailsKKCRemainingCredit is available in codeunit 143004.

Syntax

STEntryDetailsKKCRemainingCredit@1500123(
    LastTransactionNo@1500000 : Integer LastTransactionNo, //Input parameter of type Integer
    KKCRemainingCredit@1500002 : Decimal KKCRemainingCredit //Input parameter of type Decimal
);

Parameters

LastTransactionNo
Input parameter of type Integer
KKCRemainingCredit
Input parameter of type Decimal

Remarks

The relevant search keywords are: ST, Entry, Details, KKC, Remaining, Credit.

For a clarification about how this function works, refer to the code listed below.

      CalcSTEntryDetailsBalances(LastTransactionNo,ServiceTaxEntryDetails);

      GLSetup.GET;
      WITH ServiceTaxEntryDetails DO
        Assert.AreNearlyEqual(
          KKCRemainingCredit,KKCessRemainingCredit,GLSetup."Service Tax Rounding Precision",
          STRSUBSTNO(ServiceTaxFieldBalanceErr,FIELDCAPTION("Remaining Credit (KK Cess)"),TABLECAPTION));

      STEntryDetailsStatuses(LastTransactionNo);

Example

The below example is extracted from the test automation codeunit 144039 to show one way of using this function.

      LastTransactionNo := Initialize;
      AppAdvPmtToInvTakeSalesCredit(TRUE,InvoiceAmountIs::Greater,ServiceTaxSetup);

      ServiceTaxVerify.CalcSTEntryDetailsBalances(LastTransactionNo,TotalSTEntryDetails);
      RemainingServiceTaxAmount := TotalSTEntryDetails.FullRemainingCredit;
      KKCRemainingAmount := TotalSTEntryDetails.KKCessRemainingCredit;
      ServiceTaxVerify.ServTaxGLAccountsBalance(ServiceTaxSetup,RemainingServiceTaxAmount,0,0,0);
      ServiceTaxVerify.KKCGLAccountsBalance(ServiceTaxSetup,KKCRemainingAmount,0,0,0);
      ServiceTaxVerify.STEntryDetailsRemainingCredit(LastTransactionNo,RemainingServiceTaxAmount);
      ServiceTaxVerify.STEntryDetailsKKCRemainingCredit(LastTransactionNo,KKCRemainingAmount);
Member of Miscellaneous.Service Tax Verify


STEntryDetailsOnDocNoSplit@1500000 Method

The procedure STEntryDetailsOnDocNoSplit is available in codeunit 143004.

Syntax

STEntryDetailsOnDocNoSplit@1500000(
    DocumentNo@1500003 : Code[20] DocumentNo, //Input parameter of type Code
    BaseAmount@1500001 : Decimal BaseAmount, //Input parameter of type Decimal
    Percentage@1500004 : Integer Percentage, //Input parameter of type Integer
    RevChrgPart@1500005 : Boolean RevChrgPart, //Input parameter of type Boolean
    ServTaxSetup@1500000 : Record 16472 ServTaxSetup, //Input parameter of type Record
    PartialPaymentFactor@1500007 : Decimal PartialPaymentFactor //Input parameter of type Decimal
);

Parameters

DocumentNo
Input parameter of type Code
BaseAmount
Input parameter of type Decimal
Percentage
Input parameter of type Integer
RevChrgPart
Input parameter of type Boolean
ServTaxSetup
Input parameter of type Record
PartialPaymentFactor
Input parameter of type Decimal

Remarks

The relevant search keywords are: ST, Entry, Details, On, Document, No, Split.

For a clarification about how this function works, refer to the code listed below.

      RevChargeCreditClosed := NOT RevChrgPart;
      RealCreditClosed := RevChrgPart;
      STDetailsHelperSplit(DocumentNo,BaseAmount,Percentage,RevChrgPart,ServTaxSetup,PartialPaymentFactor,RevChargeCreditClosed,
        RealCreditClosed);

Example

The below example is extracted from the test automation codeunit 144034 to show one way of using this function.

      ServiceTaxVerify.VendorLedgerEntryOpen(GenJournalLine."Document No.",TRUE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PaymentDocNo,FALSE);

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      ReverseServiceTaxHelper.CalcSplitAmounts(GenJournalLine,BaseAmount,PoTAmount,RevChrgAmount,Percentage,ServiceTaxSetup);
      PoTSBCandKKCAmount :=
        ReverseServiceTaxHelper.CalculatePoTSBCandKKCAmount(BaseAmount,(100 - Percentage) / 100,ServiceTaxSetup);
      ServiceTaxVerify.SplitServTaxAccountsBalance(
        ServiceTaxSetup,PoTAmount - PoTSBCandKKCAmount,RevChrgAmount + PoTSBCandKKCAmount,PartialFactor);

      ServiceTaxVerify.CountOfServiceTaxEntries(LastTransactionNo,2,2);

      // Real Service Tax Part - because the Real Service Tax Detail entry is created when posting the invoice for the whole amount
      // so partial factor is 1.
      ServiceTaxVerify.STEntryDetailsOnDocNoSplit(GenJournalLine."Document No.",BaseAmount,Percentage,FALSE,ServiceTaxSetup,1);
      // Rev charge Service Tax Part
      ServiceTaxVerify.STEntryDetailsOnDocNoSplit(PaymentDocNo,BaseAmount,Percentage,TRUE,ServiceTaxSetup,PartialFactor);
Member of Miscellaneous.Service Tax Verify


STEntryDetailsPaidSrvTax@1500080 Method

The procedure STEntryDetailsPaidSrvTax is available in codeunit 143004.

Syntax

STEntryDetailsPaidSrvTax@1500080(
    PaymentDocNo@1500003 : Code[20] PaymentDocNo, //Input parameter of type Code
    BaseAmount@1500001 : Decimal BaseAmount, //Input parameter of type Decimal
    ServTaxSetup@1500000 : Record 16472 ServTaxSetup, //Input parameter of type Record
    RevChargeCreditClosed@1500007 : Boolean RevChargeCreditClosed, //Input parameter of type Boolean
    RealCreditClosed@1500006 : Boolean RealCreditClosed, //Input parameter of type Boolean
    PartialPaymentFactor@1500005 : Decimal PartialPaymentFactor //Input parameter of type Decimal
);

Parameters

PaymentDocNo
Input parameter of type Code
BaseAmount
Input parameter of type Decimal
ServTaxSetup
Input parameter of type Record
RevChargeCreditClosed
Input parameter of type Boolean
RealCreditClosed
Input parameter of type Boolean
PartialPaymentFactor
Input parameter of type Decimal

Remarks

The relevant search keywords are: ST, Entry, Details, Paid, Srv, Tax.

For a clarification about how this function works, refer to the code listed below.

      ServiceTaxEntryDetails.SETRANGE("Reverse Charge Pmt. Doc. No.",PaymentDocNo);
      ServiceTaxEntryDetails.FIND('+');
      SplitPercentage := 0;
      // If partial payment then check the last 2 detail entries.
      RevChargePart := FALSE;
      STDetailAmountsAndStatus(ServiceTaxEntryDetails,BaseAmount,ServTaxSetup,1 - PartialPaymentFactor,RevChargeCreditClosed,
        RealCreditClosed,SplitPercentage,RevChargePart);

      IF PartialPaymentFactor <> 1 THEN BEGIN
        ServiceTaxEntryDetails.NEXT(-1);
        STDetailAmountsAndStatus(ServiceTaxEntryDetails,BaseAmount,ServTaxSetup,PartialPaymentFactor,RevChargeCreditClosed,
          RealCreditClosed,SplitPercentage,RevChargePart);
      END;

Example

There are no examples available.
Member of Miscellaneous.Service Tax Verify


STEntryDetailsPartialPay@1500028 Method

The procedure STEntryDetailsPartialPay is available in codeunit 143004.

Syntax

STEntryDetailsPartialPay@1500028(
    DocumentNo@1500003 : Code[20] DocumentNo, //Input parameter of type Code
    BaseAmount@1500001 : Decimal BaseAmount, //Input parameter of type Decimal
    ServTaxSetup@1500000 : Record 16472 ServTaxSetup, //Input parameter of type Record
    PartialPaymentFactor@1500004 : Decimal PartialPaymentFactor, //Input parameter of type Decimal
    SplitPercentage@1500006 : Integer SplitPercentage, //Input parameter of type Integer
    RevChrgPart@1500005 : Boolean RevChrgPart, //Input parameter of type Boolean
    RevChargeCreditClosed@1500008 : Boolean RevChargeCreditClosed, //Input parameter of type Boolean
    RealCreditClosed@1500007 : Boolean RealCreditClosed //Input parameter of type Boolean
);

Parameters

DocumentNo
Input parameter of type Code
BaseAmount
Input parameter of type Decimal
ServTaxSetup
Input parameter of type Record
PartialPaymentFactor
Input parameter of type Decimal
SplitPercentage
Input parameter of type Integer
RevChrgPart
Input parameter of type Boolean
RevChargeCreditClosed
Input parameter of type Boolean
RealCreditClosed
Input parameter of type Boolean

Remarks

The relevant search keywords are: ST, Entry, Details, Partial, Pay.

For a clarification about how this function works, refer to the code listed below.

      ReverseServiceTaxHelper.GetServiceTaxEntryDetail(ServiceTaxEntryDetails,DocumentNo);
      STDetailAmountsAndStatus(ServiceTaxEntryDetails,BaseAmount,ServTaxSetup,PartialPaymentFactor,
        RevChargeCreditClosed,RealCreditClosed,SplitPercentage,RevChrgPart);

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      Initialize;

      // Setup:
      ReverseServiceTaxHelper.CreatePurchaseDoc(PurchaseHeader,PurchaseLine,DocumentType,ReverseChargeTypeOption::Standard,100,FALSE);
      PartialPaymentFactor := LibraryRandom.RandDec(1,1);

      // Exercise
      PostedPurchaseDoc := ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);
      ServiceTaxSetup.FindOnDate(PurchaseLine."Service Tax Group",PurchaseHeader."Posting Date");

      PaymentAmount :=
        ReverseServiceTaxHelper.CalculatePayment(PurchaseLine."Document Type",PurchaseLine."Line Amount",ServiceTaxSetup,100);

      PostedPartialPayment := PostAndApplyPmt(PurchaseHeader,PartialPaymentFactor * PaymentAmount,PostedPurchaseDoc);
      PostedRemainingPayment := PostAndApplyPmt(PurchaseHeader,(1 - PartialPaymentFactor) * PaymentAmount,PostedPurchaseDoc);

      // Verify
      AccountNo := ReverseServiceTaxHelper.GetServTaxInterimRecAcc(ServiceTaxSetup);
      BaseAmount := ReverseServiceTaxHelper.CalculateServTaxBase(PurchaseLine."Line Amount",DocumentType);
      Amount := ReverseServiceTaxHelper.CalculateServTaxTotal(BaseAmount,ServiceTaxSetup);
      KKCAmount := ReverseServiceTaxHelper.CalculateKKCess(BaseAmount,ServiceTaxSetup);
      SBCAmount := ReverseServiceTaxHelper.CalculateSBC(BaseAmount,ServiceTaxSetup);

      ServiceTaxVerify.GLBalanceRevCharge(ServiceTaxSetup,Amount);
      ServiceTaxVerify.GLSBCBalanceRevCharge(ServiceTaxSetup,SBCAmount);
      ServiceTaxVerify.GLKKCBalanceRevCharge(ServiceTaxSetup,KKCAmount);

      AccountNo := ReverseServiceTaxHelper.GetServTaxInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,PartialPaymentFactor * Amount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(1 - PartialPaymentFactor) * Amount);
      AccountNo := ReverseServiceTaxHelper.GetServTaxSBCInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,PartialPaymentFactor * SBCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(1 - PartialPaymentFactor) * SBCAmount);
      AccountNo := ReverseServiceTaxHelper.GetKKCInterimPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,PartialPaymentFactor * KKCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(1 - PartialPaymentFactor) * KKCAmount);

      AccountNo := ReverseServiceTaxHelper.GetServTaxPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,-PartialPaymentFactor * Amount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(PartialPaymentFactor - 1) * Amount);
      AccountNo := ReverseServiceTaxHelper.GetServTaxSBCPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,-PartialPaymentFactor * SBCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(PartialPaymentFactor - 1) * SBCAmount);
      AccountNo := ReverseServiceTaxHelper.GetKKCPayAcc(ServiceTaxSetup);
      ServiceTaxVerify.GLEntryWithRounding(PostedPartialPayment,AccountNo,-PartialPaymentFactor * KKCAmount);
      ServiceTaxVerify.GLEntryWithRounding(PostedRemainingPayment,AccountNo,(PartialPaymentFactor - 1) * KKCAmount);
      RevChargeCreditClosed := FALSE;
      RealCreditClosed := TRUE;
      ServiceTaxVerify.STEntryDetailsPartialPay(PostedPartialPayment,BaseAmount,ServiceTaxSetup,PartialPaymentFactor,0,FALSE,
        RevChargeCreditClosed,RealCreditClosed);
      ServiceTaxVerify.STEntryDetailsPartialPay(PostedRemainingPayment,BaseAmount,ServiceTaxSetup,1 - PartialPaymentFactor,0,FALSE,
        RevChargeCreditClosed,RealCreditClosed);

      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDoc,FALSE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPartialPayment,FALSE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedRemainingPayment,FALSE);
Member of Miscellaneous.Service Tax Verify


STEntryDetailsRemainingCredit@1500012 Method

The procedure STEntryDetailsRemainingCredit is available in codeunit 143004.

Syntax

STEntryDetailsRemainingCredit@1500012(
    LastTransactionNo@1500000 : Integer LastTransactionNo, //Input parameter of type Integer
    RemainingCredit@1500002 : Decimal RemainingCredit //Input parameter of type Decimal
);

Parameters

LastTransactionNo
Input parameter of type Integer
RemainingCredit
Input parameter of type Decimal

Remarks

The relevant search keywords are: ST, Entry, Details, Remaining, Credit.

For a clarification about how this function works, refer to the code listed below.

      CalcSTEntryDetailsBalances(LastTransactionNo,TotalSTEntryDetails);

      GLSetup.GET;
      WITH TotalSTEntryDetails DO
        Assert.AreNearlyEqual(
          RemainingCredit,FullRemainingCredit,GLSetup."Service Tax Rounding Precision",
          STRSUBSTNO(ServiceTaxFieldBalanceErr,FIELDCAPTION("Remaining Credit"),TABLECAPTION));

      STEntryDetailsStatuses(LastTransactionNo);

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      LastTransactionNo := Initialize;

      // Setup:
      PoT := ReverseChargeType = ReverseChargeTypeOption::" ";
      ReverseServiceTaxHelper.CreatePurchaseDoc(
        PurchaseHeader,PurchaseLine,PurchaseHeader."Document Type"::Invoice,ReverseChargeType,100,PoT);

      // Exercise
      PostedDocNo1 := ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);
      PostedDocNo2 := PostAndApplyCrMemo(PurchaseHeader,PostedDocNo1,InvAmountIs);

      // Verify
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedDocNo1,InvAmountIs = InvoiceAmountIs::Greater);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedDocNo2,InvAmountIs = InvoiceAmountIs::Smaller);

      ServiceTaxSetup.FindOnDate(PurchaseLine."Service Tax Group",PurchaseHeader."Posting Date");
      InvoiceBaseAmount := ReverseServiceTaxHelper.CalculateServTaxBase(PurchaseLine."Line Amount",PurchaseHeader."Document Type");
      InvoiceTaxAmount := ReverseServiceTaxHelper.CalculateServTaxTotal(InvoiceBaseAmount,ServiceTaxSetup);
      CrMemoBaseAmount := -InvoiceBaseAmount / ReverseServiceTaxHelper.GetPurchInvAmountFactor(InvAmountIs);
      CrMemoTaxAmount := ReverseServiceTaxHelper.CalculateServTaxTotal(CrMemoBaseAmount,ServiceTaxSetup);

      ServiceTaxVerify.ServTaxEntry(PostedDocNo1,InvoiceBaseAmount,ServiceTaxSetup);
      ServiceTaxVerify.ServTaxEntry(PostedDocNo2,CrMemoBaseAmount,ServiceTaxSetup);

      ServiceTaxVerify.PostedPurchDocGLBalance(ServiceTaxSetup,ReverseChargeType,PoT,InvoiceTaxAmount + CrMemoTaxAmount);

      IF ReverseChargeType = ReverseChargeTypeOption::" " THEN
        IF PoT THEN BEGIN
          ServiceTaxVerify.STEntryDetailsRemainingCredit(LastTransactionNo,InvoiceTaxAmount + CrMemoTaxAmount);
          ServiceTaxVerify.ServTaxEntriesArePaid(ReverseServiceTaxHelper.GetLastTransactionNo);
        END ELSE
          ServiceTaxVerify.STEntryDetailsRemainingCredit(LastTransactionNo,0)
      ELSE
        ServiceTaxVerify.STEntryDetailsRemRevChrgCredit(LastTransactionNo,0);

      IF InvAmountIs = InvoiceAmountIs::Greater THEN
        SmallerDocumentNo := PostedDocNo2
      ELSE
        SmallerDocumentNo := PostedDocNo1;
      ServiceTaxVerify.DocHasClosedRemCredit(SmallerDocumentNo);
Member of Miscellaneous.Service Tax Verify


STEntryDetailsRemRevChrgCredit@1500154 Method

The procedure STEntryDetailsRemRevChrgCredit is available in codeunit 143004.

Syntax

STEntryDetailsRemRevChrgCredit@1500154(
    LastTransactionNo@1500000 : Integer LastTransactionNo, //Input parameter of type Integer
    RemainingCredit@1500002 : Decimal RemainingCredit //Input parameter of type Decimal
);

Parameters

LastTransactionNo
Input parameter of type Integer
RemainingCredit
Input parameter of type Decimal

Remarks

The relevant search keywords are: ST, Entry, Details, Rem, Rev, Chrg, Credit.

For a clarification about how this function works, refer to the code listed below.

      CalcSTEntryDetailsBalances(LastTransactionNo,TotalSTEntryDetails);

      GLSetup.GET;
      WITH TotalSTEntryDetails DO
        Assert.AreNearlyEqual(
          RemainingCredit,FullRevChargeRemainingCredit,GLSetup."Service Tax Rounding Precision",
          STRSUBSTNO(ServiceTaxFieldBalanceErr,FIELDCAPTION("Rev. Chrg. Remaining Credit"),TABLECAPTION));

      STEntryDetailsStatuses(LastTransactionNo);

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      LastTransactionNo := Initialize;

      // Setup:
      PoT := ReverseChargeType = ReverseChargeTypeOption::" ";
      ReverseServiceTaxHelper.CreatePurchaseDoc(
        PurchaseHeader,PurchaseLine,PurchaseHeader."Document Type"::Invoice,ReverseChargeType,100,PoT);

      // Exercise
      PostedDocNo1 := ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);
      PostedDocNo2 := PostAndApplyCrMemo(PurchaseHeader,PostedDocNo1,InvAmountIs);

      // Verify
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedDocNo1,InvAmountIs = InvoiceAmountIs::Greater);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedDocNo2,InvAmountIs = InvoiceAmountIs::Smaller);

      ServiceTaxSetup.FindOnDate(PurchaseLine."Service Tax Group",PurchaseHeader."Posting Date");
      InvoiceBaseAmount := ReverseServiceTaxHelper.CalculateServTaxBase(PurchaseLine."Line Amount",PurchaseHeader."Document Type");
      InvoiceTaxAmount := ReverseServiceTaxHelper.CalculateServTaxTotal(InvoiceBaseAmount,ServiceTaxSetup);
      CrMemoBaseAmount := -InvoiceBaseAmount / ReverseServiceTaxHelper.GetPurchInvAmountFactor(InvAmountIs);
      CrMemoTaxAmount := ReverseServiceTaxHelper.CalculateServTaxTotal(CrMemoBaseAmount,ServiceTaxSetup);

      ServiceTaxVerify.ServTaxEntry(PostedDocNo1,InvoiceBaseAmount,ServiceTaxSetup);
      ServiceTaxVerify.ServTaxEntry(PostedDocNo2,CrMemoBaseAmount,ServiceTaxSetup);

      ServiceTaxVerify.PostedPurchDocGLBalance(ServiceTaxSetup,ReverseChargeType,PoT,InvoiceTaxAmount + CrMemoTaxAmount);

      IF ReverseChargeType = ReverseChargeTypeOption::" " THEN
        IF PoT THEN BEGIN
          ServiceTaxVerify.STEntryDetailsRemainingCredit(LastTransactionNo,InvoiceTaxAmount + CrMemoTaxAmount);
          ServiceTaxVerify.ServTaxEntriesArePaid(ReverseServiceTaxHelper.GetLastTransactionNo);
        END ELSE
          ServiceTaxVerify.STEntryDetailsRemainingCredit(LastTransactionNo,0)
      ELSE
        ServiceTaxVerify.STEntryDetailsRemRevChrgCredit(LastTransactionNo,0);

      IF InvAmountIs = InvoiceAmountIs::Greater THEN
        SmallerDocumentNo := PostedDocNo2
      ELSE
        SmallerDocumentNo := PostedDocNo1;
      ServiceTaxVerify.DocHasClosedRemCredit(SmallerDocumentNo);
Member of Miscellaneous.Service Tax Verify


STEntryDtlsBalancesAndStatuses@1500032 Method

The procedure STEntryDtlsBalancesAndStatuses is available in codeunit 143004.

Syntax

STEntryDtlsBalancesAndStatuses@1500032(
    LastTransactionNo@1500000 : Integer LastTransactionNo, //Input parameter of type Integer
    ExpectedServTaxEntryDetails@1500001 : Record 16474 ExpectedServTaxEntryDetails //Input parameter of type Record
);

Parameters

LastTransactionNo
Input parameter of type Integer
ExpectedServTaxEntryDetails
Input parameter of type Record

Remarks

The relevant search keywords are: ST, Entry, Dtls, Balances, Statuses.

For a clarification about how this function works, refer to the code listed below.

      CalcSTEntryDetailsBalances(LastTransactionNo,TotalSTEntryDetails);

      GLSetup.GET;
      WITH TotalSTEntryDetails DO BEGIN
        Assert.AreNearlyEqual(
          ExpectedServTaxEntryDetails."Service Tax Amount","Service Tax Amount",GLSetup."Service Tax Rounding Precision",
          STRSUBSTNO(ServiceTaxFieldBalanceErr,FIELDCAPTION("Service Tax Amount"),TABLECAPTION));
        Assert.AreNearlyEqual(
          ExpectedServTaxEntryDetails."Service Tax SBC Amount","Service Tax SBC Amount",
          GLSetup."Service Tax Rounding Precision",
          STRSUBSTNO(ServiceTaxFieldBalanceErr,FIELDCAPTION("Service Tax SBC Amount"),TABLECAPTION));
        Assert.AreNearlyEqual(
          ExpectedServTaxEntryDetails."KK Cess Amount","KK Cess Amount",GLSetup."Service Tax Rounding Precision",
          STRSUBSTNO(ServiceTaxFieldBalanceErr,FIELDCAPTION("KK Cess Amount"),TABLECAPTION));
        Assert.AreNearlyEqual(
          ExpectedServTaxEntryDetails."Service Tax eCess Amount","Service Tax eCess Amount",GLSetup."Service Tax Rounding Precision",
          STRSUBSTNO(ServiceTaxFieldBalanceErr,FIELDCAPTION("Service Tax eCess Amount"),TABLECAPTION));
        Assert.AreNearlyEqual(
          ExpectedServTaxEntryDetails."Service Tax SHE Cess Amount","Service Tax SHE Cess Amount",
          GLSetup."Service Tax Rounding Precision",
          STRSUBSTNO(ServiceTaxFieldBalanceErr,FIELDCAPTION("Service Tax SHE Cess Amount"),TABLECAPTION));
        Assert.AreNearlyEqual(
          ExpectedServTaxEntryDetails."Remaining Credit","Remaining Credit",GLSetup."Service Tax Rounding Precision",
          STRSUBSTNO(ServiceTaxFieldBalanceErr,FIELDCAPTION("Remaining Credit")));
        Assert.AreNearlyEqual(
          ExpectedServTaxEntryDetails."Remaining Credit (KK Cess)","Remaining Credit (KK Cess)",
          GLSetup."Service Tax Rounding Precision",
          STRSUBSTNO(ServiceTaxFieldBalanceErr,FIELDCAPTION("Remaining Credit (KK Cess)")));
        Assert.AreNearlyEqual(
          ExpectedServTaxEntryDetails."Remaining Credit (eCess)","Remaining Credit (eCess)",
          GLSetup."Service Tax Rounding Precision",
          STRSUBSTNO(ServiceTaxFieldBalanceErr,FIELDCAPTION("Remaining Credit (eCess)"),TABLECAPTION));
        Assert.AreNearlyEqual(
          ExpectedServTaxEntryDetails."Remaining Credit (SHECess)","Remaining Credit (SHECess)",
          GLSetup."Service Tax Rounding Precision",
          STRSUBSTNO(ServiceTaxFieldBalanceErr,FIELDCAPTION("Remaining Credit (SHECess)"),TABLECAPTION));
        Assert.AreNearlyEqual(
          ExpectedServTaxEntryDetails."Rev. Chrg. Remaining Credit","Rev. Chrg. Remaining Credit",
          GLSetup."Service Tax Rounding Precision",
          STRSUBSTNO(ServiceTaxFieldBalanceErr,FIELDCAPTION("Rev. Chrg. Remaining Credit"),TABLECAPTION));
        Assert.AreNearlyEqual(
          ExpectedServTaxEntryDetails."Rev. Chrg. Rem. Credit (KKC)","Rev. Chrg. Rem. Credit (KKC)",
          GLSetup."Service Tax Rounding Precision",
          STRSUBSTNO(ServiceTaxFieldBalanceErr,FIELDCAPTION("Rev. Chrg. Rem. Credit (KKC)"),TABLECAPTION));
        Assert.AreNearlyEqual(
          ExpectedServTaxEntryDetails."Rev. Chrg. Rem. Credit (eCESS)","Rev. Chrg. Rem. Credit (eCESS)",
          GLSetup."Service Tax Rounding Precision",
          STRSUBSTNO(ServiceTaxFieldBalanceErr,FIELDCAPTION("Rev. Chrg. Rem. Credit (eCESS)"),TABLECAPTION));
        Assert.AreNearlyEqual(
          ExpectedServTaxEntryDetails."Rev. Chrg. Rem. Cr. (SHECess)","Rev. Chrg. Rem. Cr. (SHECess)",
          GLSetup."Service Tax Rounding Precision",
          STRSUBSTNO(ServiceTaxFieldBalanceErr,FIELDCAPTION("Rev. Chrg. Rem. Cr. (SHECess)"),TABLECAPTION));
      END;

      STEntryDetailsStatuses(LastTransactionNo);

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      ReverseServiceTaxHelper.FillExpectedAmntsSTEntry(PmtGenJnlLine,PmtBaseAmount + InvBaseAmount,ExpectedServTaxEntry);
      ServiceTaxVerify.STEntryBalances(LastTransactionNo,ExpectedServTaxEntry);

      IF PmtBaseAmount < InvBaseAmount THEN
        ReverseServiceTaxHelper.FillExpectedAmntsSTEntry(PmtGenJnlLine,PmtBaseAmount,ExpectedServTaxEntry)
      ELSE
        ReverseServiceTaxHelper.FillExpectedAmntsSTEntry(PmtGenJnlLine,InvBaseAmount,ExpectedServTaxEntry);

      ReverseServiceTaxHelper.FillExpectedAmntsFullPurchFlow(ExpectedServTaxEntryDetails,ExpectedServTaxEntry);
      ServiceTaxVerify.STEntryDtlsBalancesAndStatuses(LastTransactionNo,ExpectedServTaxEntryDetails);
Member of Miscellaneous.Service Tax Verify


STEntryDtlsFullTaxBalance@1500019 Method

The procedure STEntryDtlsFullTaxBalance is available in codeunit 143004.

Syntax

STEntryDtlsFullTaxBalance@1500019(
    LastTransactionNo@1500000 : Integer LastTransactionNo, //Input parameter of type Integer
    ExpectedFullTaxAmount@1500005 : Decimal ExpectedFullTaxAmount //Input parameter of type Decimal
);

Parameters

LastTransactionNo
Input parameter of type Integer
ExpectedFullTaxAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: ST, Entry, Dtls, Full, Tax, Balance.

For a clarification about how this function works, refer to the code listed below.

      CalcSTEntryDetailsBalances(LastTransactionNo,TotalSTEntryDetails);
      Assert.AreEqual(
        ExpectedFullTaxAmount,TotalSTEntryDetails.FullTaxAmount,STRSUBSTNO(FullServiceTaxBalanceErr,TotalSTEntryDetails.TABLECAPTION));

Example

The below example is extracted from the test automation codeunit 144041 to show one way of using this function.

      LastTransactionNo := Initialize;

      GenJournalLine.PoT := TRUE;
      CreateAndPostAdvancePayment(GenJournalLine);

      ConvertPaymentToRefund(GenJournalLine);
      ReverseServiceTaxHelper.RunGenJnlPostLine(GenJournalLine);

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      ServiceTaxVerify.ServTaxGLAccountsBalance(ServiceTaxSetup,0,0,0,0);
      ServiceTaxVerify.SBCGLAccountsBalance(ServiceTaxSetup,0,0,0,0);
      ServiceTaxVerify.KKCGLAccountsBalance(ServiceTaxSetup,0,0,0,0);

      ServiceTaxVerify.STEntryDtlsFullTaxBalance(LastTransactionNo,0);
      ServiceTaxVerify.STEntryDtlsSBCBalance(LastTransactionNo,0);
      ServiceTaxVerify.STEntryDtlsKKCBalance(LastTransactionNo,0);
Member of Miscellaneous.Service Tax Verify


STEntryDtlsFullTaxBalNearly@1500084 Method

The procedure STEntryDtlsFullTaxBalNearly is available in codeunit 143004.

Syntax

STEntryDtlsFullTaxBalNearly@1500084(
    LastTransactionNo@1500000 : Integer LastTransactionNo, //Input parameter of type Integer
    ExpectedFullTaxAmount@1500005 : Decimal ExpectedFullTaxAmount //Input parameter of type Decimal
);

Parameters

LastTransactionNo
Input parameter of type Integer
ExpectedFullTaxAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: ST, Entry, Dtls, Full, Tax, Bal, Nearly.

For a clarification about how this function works, refer to the code listed below.

      CalcSTEntryDetailsBalances(LastTransactionNo,TotalSTEntryDetails);

      GLSetup.GET;
      Assert.AreNearlyEqual(
        ExpectedFullTaxAmount,TotalSTEntryDetails.FullTaxAmount,GLSetup."Service Tax Rounding Precision",
        STRSUBSTNO(FullServiceTaxBalanceErr,TotalSTEntryDetails.TABLECAPTION));

Example

There are no examples available.
Member of Miscellaneous.Service Tax Verify


STEntryDtlsKKCBalance@1500125 Method

The procedure STEntryDtlsKKCBalance is available in codeunit 143004.

Syntax

STEntryDtlsKKCBalance@1500125(
    LastTransactionNo@1500000 : Integer LastTransactionNo, //Input parameter of type Integer
    ExpectedKKCessAmount@1500005 : Decimal ExpectedKKCessAmount //Input parameter of type Decimal
);

Parameters

LastTransactionNo
Input parameter of type Integer
ExpectedKKCessAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: ST, Entry, Dtls, KKC, Balance.

For a clarification about how this function works, refer to the code listed below.

      CalcSTEntryDetailsBalances(LastTransactionNo,ServiceTaxEntryDetails);
      Assert.AreEqual(
        ExpectedKKCessAmount,ServiceTaxEntryDetails.KKCessAmount,FullKKCBalanceErr);

Example

The below example is extracted from the test automation codeunit 144041 to show one way of using this function.

      LastTransactionNo := Initialize;

      GenJournalLine.PoT := TRUE;
      CreateAndPostAdvancePayment(GenJournalLine);

      ConvertPaymentToRefund(GenJournalLine);
      ReverseServiceTaxHelper.RunGenJnlPostLine(GenJournalLine);

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      ServiceTaxVerify.ServTaxGLAccountsBalance(ServiceTaxSetup,0,0,0,0);
      ServiceTaxVerify.SBCGLAccountsBalance(ServiceTaxSetup,0,0,0,0);
      ServiceTaxVerify.KKCGLAccountsBalance(ServiceTaxSetup,0,0,0,0);

      ServiceTaxVerify.STEntryDtlsFullTaxBalance(LastTransactionNo,0);
      ServiceTaxVerify.STEntryDtlsSBCBalance(LastTransactionNo,0);
      ServiceTaxVerify.STEntryDtlsKKCBalance(LastTransactionNo,0);
Member of Miscellaneous.Service Tax Verify


STEntryDtlsKKCBalNearly@1500126 Method

The procedure STEntryDtlsKKCBalNearly is available in codeunit 143004.

Syntax

STEntryDtlsKKCBalNearly@1500126(
    LastTransactionNo@1500000 : Integer LastTransactionNo, //Input parameter of type Integer
    ExpectedKKCAmount@1500005 : Decimal ExpectedKKCAmount //Input parameter of type Decimal
);

Parameters

LastTransactionNo
Input parameter of type Integer
ExpectedKKCAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: ST, Entry, Dtls, KKC, Bal, Nearly.

For a clarification about how this function works, refer to the code listed below.

      CalcSTEntryDetailsBalances(LastTransactionNo,ServiceTaxEntryDetails);

      GLSetup.GET;
      Assert.AreNearlyEqual(
        ExpectedKKCAmount,ServiceTaxEntryDetails.KKCessAmount,GLSetup."Service Tax Rounding Precision",
        FullKKCBalanceErr);

Example

There are no examples available.
Member of Miscellaneous.Service Tax Verify


STEntryDtlsSBCBalance@1500122 Method

The procedure STEntryDtlsSBCBalance is available in codeunit 143004.

Syntax

STEntryDtlsSBCBalance@1500122(
    LastTransactionNo@1500000 : Integer LastTransactionNo, //Input parameter of type Integer
    ExpectedSBCAmount@1500005 : Decimal ExpectedSBCAmount //Input parameter of type Decimal
);

Parameters

LastTransactionNo
Input parameter of type Integer
ExpectedSBCAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: ST, Entry, Dtls, SBC, Balance.

For a clarification about how this function works, refer to the code listed below.

      CalcSTEntryDetailsBalances(LastTransactionNo,ServiceTaxEntryDetails);
      Assert.AreEqual(
        ExpectedSBCAmount,ServiceTaxEntryDetails.FullTaxSBCAmount,FullSBCBalanceErr);

Example

The below example is extracted from the test automation codeunit 144041 to show one way of using this function.

      LastTransactionNo := Initialize;

      GenJournalLine.PoT := TRUE;
      CreateAndPostAdvancePayment(GenJournalLine);

      ConvertPaymentToRefund(GenJournalLine);
      ReverseServiceTaxHelper.RunGenJnlPostLine(GenJournalLine);

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      ServiceTaxVerify.ServTaxGLAccountsBalance(ServiceTaxSetup,0,0,0,0);
      ServiceTaxVerify.SBCGLAccountsBalance(ServiceTaxSetup,0,0,0,0);
      ServiceTaxVerify.KKCGLAccountsBalance(ServiceTaxSetup,0,0,0,0);

      ServiceTaxVerify.STEntryDtlsFullTaxBalance(LastTransactionNo,0);
      ServiceTaxVerify.STEntryDtlsSBCBalance(LastTransactionNo,0);
      ServiceTaxVerify.STEntryDtlsKKCBalance(LastTransactionNo,0);
Member of Miscellaneous.Service Tax Verify


STEntryDtlsSBCBalNearly@1500128 Method

The procedure STEntryDtlsSBCBalNearly is available in codeunit 143004.

Syntax

STEntryDtlsSBCBalNearly@1500128(
    LastTransactionNo@1500000 : Integer LastTransactionNo, //Input parameter of type Integer
    ExpectedSBCAmount@1500005 : Decimal ExpectedSBCAmount //Input parameter of type Decimal
);

Parameters

LastTransactionNo
Input parameter of type Integer
ExpectedSBCAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: ST, Entry, Dtls, SBC, Bal, Nearly.

For a clarification about how this function works, refer to the code listed below.

      CalcSTEntryDetailsBalances(LastTransactionNo,ServiceTaxEntryDetails);

      GLSetup.GET;
      Assert.AreNearlyEqual(
        ExpectedSBCAmount,ServiceTaxEntryDetails.FullTaxSBCAmount,
        GLSetup."Service Tax Rounding Precision",FullSBCBalanceErr);

Example

There are no examples available.
Member of Miscellaneous.Service Tax Verify


STEntryFullKKCBalance@1500097 Method

The procedure STEntryFullKKCBalance is available in codeunit 143004.

Syntax

STEntryFullKKCBalance@1500097(
    LastTransactionNo@1500000 : Integer LastTransactionNo, //Input parameter of type Integer
    ExpectedKKCAmount@1500005 : Decimal ExpectedKKCAmount //Input parameter of type Decimal
);

Parameters

LastTransactionNo
Input parameter of type Integer
ExpectedKKCAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: ST, Entry, Full, KKC, Balance.

For a clarification about how this function works, refer to the code listed below.

      CalcSTEntryBalances(LastTransactionNo,ServiceTaxEntry);
      Assert.AreEqual(
        ExpectedKKCAmount,ServiceTaxEntry.KKCessAmount,
        STRSUBSTNO(FullServiceTaxBalanceErr,ServiceTaxEntry.TABLECAPTION));

Example

The below example is extracted from the test automation codeunit 144041 to show one way of using this function.

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      TaxAmount := ReverseServiceTaxHelper.CalculateServTaxTotal(GenJournalLine."Service Tax Base Amount (LCY)",ServiceTaxSetup);
      SBCAmount := ReverseServiceTaxHelper.CalculateSBC(GenJournalLine."Service Tax Base Amount (LCY)",ServiceTaxSetup);
      KKCAmount := ReverseServiceTaxHelper.CalculateKKCess(GenJournalLine."Service Tax Base Amount (LCY)",ServiceTaxSetup);

      IF GenJournalLine."Document Type" = GenJournalLine."Document Type"::"Credit Memo" THEN BEGIN
        TaxAmount := -TaxAmount;
        SBCAmount := -SBCAmount;
        KKCAmount := -KKCAmount;
      END;

      ServiceTaxVerify.ServTaxGLAccountsBalance(ServiceTaxSetup,0,0,TaxAmount,0);
      ServiceTaxVerify.STEntryDtlsFullTaxBalance(LastTransactionNo,TaxAmount);
      ServiceTaxVerify.STEntryFullTaxBalance(LastTransactionNo,TaxAmount);
      ServiceTaxVerify.SBCGLAccountsBalance(ServiceTaxSetup,0,0,SBCAmount,0);
      ServiceTaxVerify.STEntryDtlsSBCBalance(LastTransactionNo,SBCAmount);
      ServiceTaxVerify.STEntryFullSBCBalance(LastTransactionNo,SBCAmount);
      ServiceTaxVerify.KKCGLAccountsBalance(ServiceTaxSetup,0,0,KKCAmount,0);
      ServiceTaxVerify.STEntryDtlsKKCBalance(LastTransactionNo,KKCAmount);
      ServiceTaxVerify.STEntryFullKKCBalance(LastTransactionNo,KKCAmount);
Member of Miscellaneous.Service Tax Verify


STEntryFullSBCBalance@1500095 Method

The procedure STEntryFullSBCBalance is available in codeunit 143004.

Syntax

STEntryFullSBCBalance@1500095(
    LastTransactionNo@1500000 : Integer LastTransactionNo, //Input parameter of type Integer
    ExpectedSBCAmount@1500005 : Decimal ExpectedSBCAmount //Input parameter of type Decimal
);

Parameters

LastTransactionNo
Input parameter of type Integer
ExpectedSBCAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: ST, Entry, Full, SBC, Balance.

For a clarification about how this function works, refer to the code listed below.

      CalcSTEntryBalances(LastTransactionNo,ServiceTaxEntry);
      Assert.AreEqual(
        ExpectedSBCAmount,ServiceTaxEntry.FullTaxSBCAmount,
        STRSUBSTNO(FullServiceTaxBalanceErr,ServiceTaxEntry.TABLECAPTION));

Example

The below example is extracted from the test automation codeunit 144041 to show one way of using this function.

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      TaxAmount := ReverseServiceTaxHelper.CalculateServTaxTotal(GenJournalLine."Service Tax Base Amount (LCY)",ServiceTaxSetup);
      SBCAmount := ReverseServiceTaxHelper.CalculateSBC(GenJournalLine."Service Tax Base Amount (LCY)",ServiceTaxSetup);
      KKCAmount := ReverseServiceTaxHelper.CalculateKKCess(GenJournalLine."Service Tax Base Amount (LCY)",ServiceTaxSetup);

      IF GenJournalLine."Document Type" = GenJournalLine."Document Type"::"Credit Memo" THEN BEGIN
        TaxAmount := -TaxAmount;
        SBCAmount := -SBCAmount;
        KKCAmount := -KKCAmount;
      END;

      ServiceTaxVerify.ServTaxGLAccountsBalance(ServiceTaxSetup,0,0,TaxAmount,0);
      ServiceTaxVerify.STEntryDtlsFullTaxBalance(LastTransactionNo,TaxAmount);
      ServiceTaxVerify.STEntryFullTaxBalance(LastTransactionNo,TaxAmount);
      ServiceTaxVerify.SBCGLAccountsBalance(ServiceTaxSetup,0,0,SBCAmount,0);
      ServiceTaxVerify.STEntryDtlsSBCBalance(LastTransactionNo,SBCAmount);
      ServiceTaxVerify.STEntryFullSBCBalance(LastTransactionNo,SBCAmount);
      ServiceTaxVerify.KKCGLAccountsBalance(ServiceTaxSetup,0,0,KKCAmount,0);
      ServiceTaxVerify.STEntryDtlsKKCBalance(LastTransactionNo,KKCAmount);
      ServiceTaxVerify.STEntryFullKKCBalance(LastTransactionNo,KKCAmount);
Member of Miscellaneous.Service Tax Verify


STEntryFullTaxBalance@1500022 Method

The procedure STEntryFullTaxBalance is available in codeunit 143004.

Syntax

STEntryFullTaxBalance@1500022(
    LastTransactionNo@1500000 : Integer LastTransactionNo, //Input parameter of type Integer
    ExpectedFullTaxAmount@1500005 : Decimal ExpectedFullTaxAmount //Input parameter of type Decimal
);

Parameters

LastTransactionNo
Input parameter of type Integer
ExpectedFullTaxAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: ST, Entry, Full, Tax, Balance.

For a clarification about how this function works, refer to the code listed below.

      CalcSTEntryBalances(LastTransactionNo,TotalSTEntry);
      Assert.AreEqual(
        ExpectedFullTaxAmount,TotalSTEntry.FullTaxAmount,STRSUBSTNO(FullServiceTaxBalanceErr,TotalSTEntry.TABLECAPTION));

Example

The below example is extracted from the test automation codeunit 144041 to show one way of using this function.

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      TaxAmount := ReverseServiceTaxHelper.CalculateServTaxTotal(GenJournalLine."Service Tax Base Amount (LCY)",ServiceTaxSetup);
      SBCAmount := ReverseServiceTaxHelper.CalculateSBC(GenJournalLine."Service Tax Base Amount (LCY)",ServiceTaxSetup);
      KKCAmount := ReverseServiceTaxHelper.CalculateKKCess(GenJournalLine."Service Tax Base Amount (LCY)",ServiceTaxSetup);

      IF GenJournalLine."Document Type" = GenJournalLine."Document Type"::"Credit Memo" THEN BEGIN
        TaxAmount := -TaxAmount;
        SBCAmount := -SBCAmount;
        KKCAmount := -KKCAmount;
      END;

      ServiceTaxVerify.ServTaxGLAccountsBalance(ServiceTaxSetup,0,0,TaxAmount,0);
      ServiceTaxVerify.STEntryDtlsFullTaxBalance(LastTransactionNo,TaxAmount);
      ServiceTaxVerify.STEntryFullTaxBalance(LastTransactionNo,TaxAmount);
      ServiceTaxVerify.SBCGLAccountsBalance(ServiceTaxSetup,0,0,SBCAmount,0);
      ServiceTaxVerify.STEntryDtlsSBCBalance(LastTransactionNo,SBCAmount);
      ServiceTaxVerify.STEntryFullSBCBalance(LastTransactionNo,SBCAmount);
      ServiceTaxVerify.KKCGLAccountsBalance(ServiceTaxSetup,0,0,KKCAmount,0);
      ServiceTaxVerify.STEntryDtlsKKCBalance(LastTransactionNo,KKCAmount);
      ServiceTaxVerify.STEntryFullKKCBalance(LastTransactionNo,KKCAmount);
Member of Miscellaneous.Service Tax Verify


STExpenseAccBalance@1500030 Method

The procedure STExpenseAccBalance is available in codeunit 143004.

Syntax

STExpenseAccBalance@1500030(
    ServiceTaxSetup@1500003 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    Amount@1500001 : Decimal Amount //Input parameter of type Decimal
);

Parameters

ServiceTaxSetup
Input parameter of type Record
Amount
Input parameter of type Decimal

Remarks

The relevant search keywords are: ST, Expense, Account, Balance.

For a clarification about how this function works, refer to the code listed below.

      AccountBalance(ReverseServiceTaxHelper.GetServTaxExpenseAcc(ServiceTaxSetup),Amount);

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      PaySrvTaxBeforeApplyAdvPmt(PurchaseHeader."Service Type (Rev. Chrg.)"::Outward,ServiceTaxSetup,ExpectedTaxAmount);
      ServiceTaxVerify.STExpenseAccBalance(ServiceTaxSetup,ExpectedTaxAmount);
Member of Miscellaneous.Service Tax Verify


STPayAccBalance@1500112 Method

The procedure STPayAccBalance is available in codeunit 143004.

Syntax

STPayAccBalance@1500112(
    ServiceTaxSetup@1500003 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    Amount@1500001 : Decimal Amount //Input parameter of type Decimal
);

Parameters

ServiceTaxSetup
Input parameter of type Record
Amount
Input parameter of type Decimal

Remarks

The relevant search keywords are: ST, Pay, Account, Balance.

For a clarification about how this function works, refer to the code listed below.

      AccountBalance(ReverseServiceTaxHelper.GetServTaxPayAcc(ServiceTaxSetup),Amount);

Example

The below example is extracted from the test automation codeunit 144034 to show one way of using this function.

      ServiceTaxSetup.FindOnDate(GenJnlLine."Service Tax Group Code",GenJnlLine."Posting Date");
      ReverseServiceTaxHelper.CalcSplitAmounts(GenJnlLine,InvoiceBaseAmount,PoTAmount[1],RevChrgAmount[1],Percentage,ServiceTaxSetup);
      TotSBCandKKcAmount :=
        ReverseServiceTaxHelper.CalculatePoTSBCandKKCAmount(InvoiceBaseAmount,(100 - Percentage) / 100,ServiceTaxSetup);
      GenJnlLine.Amount := CancelledAmount;
      ReverseServiceTaxHelper.CalcSplitAmounts(
        GenJnlLine,CreditMemoBaseAmount,PoTAmount[2],RevChrgAmount[2],Percentage,ServiceTaxSetup);
      CrTotSBCandKKcAmount :=
        ReverseServiceTaxHelper.CalculatePoTSBCandKKCAmount(CreditMemoBaseAmount,(100 - Percentage) / 100,ServiceTaxSetup);

      ServiceTaxVerify.STPayInterimAccBalance(
        ServiceTaxSetup,(RevChrgAmount[2] - RevChrgAmount[1]) - (TotSBCandKKcAmount - CrTotSBCandKKcAmount));
      ServiceTaxVerify.STRecInterimAccBalance(
        ServiceTaxSetup,RevChrgAmount[1] - RevChrgAmount[2] + (TotSBCandKKcAmount - CrTotSBCandKKcAmount));
      ServiceTaxVerify.STPayAccBalance(ServiceTaxSetup,0);
      ServiceTaxVerify.STRecAccBalance(
        ServiceTaxSetup,(PoTAmount[1] - PoTAmount[2]) - (TotSBCandKKcAmount - CrTotSBCandKKcAmount));

      ServiceTaxVerify.STEntryDetailsRemainingCredit(
        LastTransactionNo,(PoTAmount[1] - PoTAmount[2]) - (TotSBCandKKcAmount - CrTotSBCandKKcAmount));
      ServiceTaxVerify.STEntryDetailsRemRevChrgCredit(LastTransactionNo,0);
Member of Miscellaneous.Service Tax Verify


STPayInterimAccBalance@1500111 Method

The procedure STPayInterimAccBalance is available in codeunit 143004.

Syntax

STPayInterimAccBalance@1500111(
    ServiceTaxSetup@1500002 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    Amount@1500000 : Decimal Amount //Input parameter of type Decimal
);

Parameters

ServiceTaxSetup
Input parameter of type Record
Amount
Input parameter of type Decimal

Remarks

The relevant search keywords are: ST, Pay, Interim, Account, Balance.

For a clarification about how this function works, refer to the code listed below.

      AccountBalance(ReverseServiceTaxHelper.GetServTaxInterimPayAcc(ServiceTaxSetup),Amount);

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      LastTransactionNo := Initialize;

      GenJournalLine.PoT := PoT;
      PostedDocNo :=
        ApplyBiggerDocToAdvPmt(
          GenJournalLine,DocumentType,RevChargeType,
          GLAccountNo,InvoiceBaseAmount,InvoiceTaxAmount,PaymentBaseAmount,PaymentTaxAmount);

      // Verify
      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      IF RevChargeType = ReverseChargeType::" " THEN
        IF NOT PoT THEN BEGIN
          VerifySTEntriesNoPoTPartialApp(LastTransactionNo,GenJournalLine,PaymentBaseAmount,InvoiceBaseAmount);
          ServiceTaxVerify.ServTaxGLAccountsBalance(ServiceTaxSetup,PaymentTaxAmount,InvoiceTaxAmount - PaymentTaxAmount,0,0);
        END ELSE BEGIN
          ServiceTaxVerify.STEntriesFullPurchFlow(LastTransactionNo,GenJournalLine,InvoiceBaseAmount,RevChargeType);
          ServiceTaxVerify.GLBalanceReceivablesOnly(ServiceTaxSetup,InvoiceTaxAmount);
        END
      ELSE BEGIN
        VerifySTEntriesRevCPartialApp(LastTransactionNo,GenJournalLine,PaymentBaseAmount,InvoiceBaseAmount);
        ServiceTaxVerify.STRecInterimAccBalance(ServiceTaxSetup,InvoiceTaxAmount);
        ServiceTaxVerify.STPayInterimAccBalance(ServiceTaxSetup,PaymentTaxAmount - InvoiceTaxAmount);
      END;

      // vendor ledger entry
      ServiceTaxVerify.VendorLedgerEntryOpen(GenJournalLine."Document No.",FALSE);

      // vendor and services
      KKCAmount := ReverseServiceTaxHelper.CalculateSBC(InvoiceBaseAmount,ServiceTaxSetup);
      SBCAmount := ReverseServiceTaxHelper.CalculateKKCess(InvoiceBaseAmount,ServiceTaxSetup);
      ServiceTaxVerify.VendorAndServicesEntries(PostedDocNo,GenJournalLine."Account No.",
        GLAccountNo,TRUE,InvoiceBaseAmount,InvoiceTaxAmount + KKCAmount + SBCAmount,RevChargeType,TRUE);
Member of Miscellaneous.Service Tax Verify


STRecAccBalance@1500110 Method

The procedure STRecAccBalance is available in codeunit 143004.

Syntax

STRecAccBalance@1500110(
    ServiceTaxSetup@1500002 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    Amount@1500000 : Decimal Amount //Input parameter of type Decimal
);

Parameters

ServiceTaxSetup
Input parameter of type Record
Amount
Input parameter of type Decimal

Remarks

The relevant search keywords are: ST, Rec, Account, Balance.

For a clarification about how this function works, refer to the code listed below.

      AccountBalance(ReverseServiceTaxHelper.GetServTaxRecAcc(ServiceTaxSetup),Amount);

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      PaySrvTaxBeforeApplyAdvPmt(PurchaseHeader."Service Type (Rev. Chrg.)"::Inward,ServiceTaxSetup,ExpectedTaxAmount);
      ServiceTaxVerify.STRecAccBalance(ServiceTaxSetup,ExpectedTaxAmount);
Member of Miscellaneous.Service Tax Verify


STRecAccBalanceNearly@1500079 Method

The procedure STRecAccBalanceNearly is available in codeunit 143004.

Syntax

STRecAccBalanceNearly@1500079(
    ServiceTaxSetup@1500002 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    Amount@1500000 : Decimal Amount //Input parameter of type Decimal
);

Parameters

ServiceTaxSetup
Input parameter of type Record
Amount
Input parameter of type Decimal

Remarks

The relevant search keywords are: ST, Rec, Account, Balance, Nearly.

For a clarification about how this function works, refer to the code listed below.

      AccountNo := ReverseServiceTaxHelper.GetServTaxRecAcc(ServiceTaxSetup);
      GLAccount.GET(AccountNo);
      GLAccount.CALCFIELDS(Balance);

      GLSetup.GET;
      Assert.AreNearlyEqual(
        Amount,GLAccount.Balance,GLSetup."Service Tax Rounding Precision",STRSUBSTNO(AccBalanceErr,GLAccount."No."));

Example

There are no examples available.
Member of Miscellaneous.Service Tax Verify


STRecInterimAccBalance@1500025 Method

The procedure STRecInterimAccBalance is available in codeunit 143004.

Syntax

STRecInterimAccBalance@1500025(
    ServiceTaxSetup@1500003 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    Amount@1500002 : Decimal Amount //Input parameter of type Decimal
);

Parameters

ServiceTaxSetup
Input parameter of type Record
Amount
Input parameter of type Decimal

Remarks

The relevant search keywords are: ST, Rec, Interim, Account, Balance.

For a clarification about how this function works, refer to the code listed below.

      AccountBalance(ReverseServiceTaxHelper.GetServTaxInterimRecAcc(ServiceTaxSetup),Amount);

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      LastTransactionNo := Initialize;

      GenJournalLine.PoT := PoT;
      PostedDocNo :=
        ApplyBiggerDocToAdvPmt(
          GenJournalLine,DocumentType,RevChargeType,
          GLAccountNo,InvoiceBaseAmount,InvoiceTaxAmount,PaymentBaseAmount,PaymentTaxAmount);

      // Verify
      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      IF RevChargeType = ReverseChargeType::" " THEN
        IF NOT PoT THEN BEGIN
          VerifySTEntriesNoPoTPartialApp(LastTransactionNo,GenJournalLine,PaymentBaseAmount,InvoiceBaseAmount);
          ServiceTaxVerify.ServTaxGLAccountsBalance(ServiceTaxSetup,PaymentTaxAmount,InvoiceTaxAmount - PaymentTaxAmount,0,0);
        END ELSE BEGIN
          ServiceTaxVerify.STEntriesFullPurchFlow(LastTransactionNo,GenJournalLine,InvoiceBaseAmount,RevChargeType);
          ServiceTaxVerify.GLBalanceReceivablesOnly(ServiceTaxSetup,InvoiceTaxAmount);
        END
      ELSE BEGIN
        VerifySTEntriesRevCPartialApp(LastTransactionNo,GenJournalLine,PaymentBaseAmount,InvoiceBaseAmount);
        ServiceTaxVerify.STRecInterimAccBalance(ServiceTaxSetup,InvoiceTaxAmount);
        ServiceTaxVerify.STPayInterimAccBalance(ServiceTaxSetup,PaymentTaxAmount - InvoiceTaxAmount);
      END;

      // vendor ledger entry
      ServiceTaxVerify.VendorLedgerEntryOpen(GenJournalLine."Document No.",FALSE);

      // vendor and services
      KKCAmount := ReverseServiceTaxHelper.CalculateSBC(InvoiceBaseAmount,ServiceTaxSetup);
      SBCAmount := ReverseServiceTaxHelper.CalculateKKCess(InvoiceBaseAmount,ServiceTaxSetup);
      ServiceTaxVerify.VendorAndServicesEntries(PostedDocNo,GenJournalLine."Account No.",
        GLAccountNo,TRUE,InvoiceBaseAmount,InvoiceTaxAmount + KKCAmount + SBCAmount,RevChargeType,TRUE);
Member of Miscellaneous.Service Tax Verify


UnappAdvPmtPartialSTEntrDetBal@1500047 Method

The procedure UnappAdvPmtPartialSTEntrDetBal is available in codeunit 143004.

Syntax

UnappAdvPmtPartialSTEntrDetBal@1500047(
    AdvancePaymentAmount@1500011 : Decimal AdvancePaymentAmount, //Input parameter of type Decimal
    PurchaseLineAmount@1500002 : Decimal PurchaseLineAmount, //Input parameter of type Decimal
    DocumentType@1500004 : Option DocumentType, //Input parameter of type Option
    LastTransactionNo@1500006 : Integer LastTransactionNo, //Input parameter of type Integer
    ServiceTaxGroupCode@1500009 : Code[20] ServiceTaxGroupCode, //Input parameter of type Code
    PostingDate@1500010 : Date PostingDate, //Input parameter of type Date
    RevChargeType@1500001 : Option RevChargeType, //Input parameter of type Option
    PoT@1500000 : Boolean PoT //Input parameter of type Boolean
);

Parameters

AdvancePaymentAmount
Input parameter of type Decimal
PurchaseLineAmount
Input parameter of type Decimal
DocumentType
Input parameter of type Option
LastTransactionNo
Input parameter of type Integer
ServiceTaxGroupCode
Input parameter of type Code
PostingDate
Input parameter of type Date
RevChargeType
Input parameter of type Option
PoT
Input parameter of type Boolean

Remarks

The relevant search keywords are: Unapp, Adv, Payment, Partial, ST, Entr, Det, Bal.

For a clarification about how this function works, refer to the code listed below.

      CalcSTEntryDetailsBalances(LastTransactionNo,TotalSTEntryDetails);
      ServiceTaxSetup.FindOnDate(ServiceTaxGroupCode,PostingDate);
      InvServTaxAmount := ReverseServiceTaxHelper.CalculateServTaxAmount(ServiceTaxSetup,PurchaseLineAmount,DocumentType);
      InvSBCAmount := ReverseServiceTaxHelper.CalculateServTaxSBCAmount(ServiceTaxSetup,PurchaseLineAmount,DocumentType);
      InvKKCAmount := ReverseServiceTaxHelper.CalculateKKCAmount(ServiceTaxSetup,PurchaseLineAmount,DocumentType);
      AdvPmtServTaxAmount := ReverseServiceTaxHelper.CalculateServTaxAmount(ServiceTaxSetup,AdvancePaymentAmount,DocumentType);
      AdvPmtSBCAmount := ReverseServiceTaxHelper.CalculateServTaxSBCAmount(ServiceTaxSetup,AdvancePaymentAmount,DocumentType);
      AdvPmtKKCAmount := ReverseServiceTaxHelper.CalculateKKCAmount(ServiceTaxSetup,AdvancePaymentAmount,DocumentType);

      IF PoT THEN BEGIN
        Assert.AreEqual(InvServTaxAmount + AdvPmtServTaxAmount,TotalSTEntryDetails.FullTaxAmount,ServiceTaxBalanceErr);
        Assert.AreEqual(InvServTaxAmount + AdvPmtServTaxAmount,TotalSTEntryDetails.FullRemainingCredit,RemainingCreditBalErr);
        Assert.AreEqual(0,TotalSTEntryDetails.FullRevChargeRemainingCredit,RevChargeRemCrBalErr);
        Assert.AreEqual(InvSBCAmount + AdvPmtSBCAmount,TotalSTEntryDetails.FullTaxSBCAmount,SBCBalanceErr);
        Assert.AreEqual(InvKKCAmount + AdvPmtKKCAmount,TotalSTEntryDetails.KKCessAmount,KKCBalanceErr);
        Assert.AreEqual(InvKKCAmount + AdvPmtKKCAmount,TotalSTEntryDetails.KKCessRemainingCredit,KKCRemainingCreditBalErr);
        Assert.AreEqual(0,TotalSTEntryDetails.KKcessRevChargeRemainingCredit,KKCRevChargeRemCrBalErr);
      END ELSE
        IF RevChargeType = ReverseChargeType::" " THEN BEGIN
          Assert.AreEqual(0,TotalSTEntryDetails.FullTaxAmount,ServiceTaxBalanceErr);
          Assert.AreEqual(0,TotalSTEntryDetails.FullRemainingCredit,RemainingCreditBalErr);
          Assert.AreEqual(0,TotalSTEntryDetails.FullRevChargeRemainingCredit,RevChargeRemCrBalErr);
          Assert.AreEqual(0,TotalSTEntryDetails.FullTaxSBCAmount,SBCBalanceErr);
          Assert.AreEqual(0,TotalSTEntryDetails.KKCessAmount,KKCBalanceErr);
          Assert.AreEqual(0,TotalSTEntryDetails.KKCessRemainingCredit,KKCRemainingCreditBalErr);
          Assert.AreEqual(0,TotalSTEntryDetails.KKcessRevChargeRemainingCredit,KKCRevChargeRemCrBalErr);
        END ELSE BEGIN
          Assert.AreEqual(AdvPmtServTaxAmount,TotalSTEntryDetails.FullTaxAmount,ServiceTaxBalanceErr);
          Assert.AreEqual(0,TotalSTEntryDetails.FullRemainingCredit,RemainingCreditBalErr);
          Assert.AreEqual(AdvPmtServTaxAmount,TotalSTEntryDetails.FullRevChargeRemainingCredit,RevChargeRemCrBalErr);
          Assert.AreEqual(AdvPmtSBCAmount,TotalSTEntryDetails.FullTaxSBCAmount,SBCBalanceErr);
          Assert.AreEqual(AdvPmtKKCAmount,TotalSTEntryDetails.KKCessAmount,KKCBalanceErr);
          Assert.AreEqual(0,TotalSTEntryDetails.KKCessRemainingCredit,KKCRemainingCreditBalErr);
          Assert.AreEqual(AdvPmtKKCAmount,TotalSTEntryDetails.KKcessRevChargeRemainingCredit,KKCRevChargeRemCrBalErr);
        END;

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      ServiceTaxVerify.UnappAdvPmtPartialSTEntrDetBal(
        PaymentBaseAmount,InvoiceBaseAmount,DocumentType,LastTransactionNo,
        PaymentGenJournalLine."Service Tax Group Code",PaymentGenJournalLine."Posting Date",RevChargeType,PoT);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDocNo,TRUE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PaymentGenJournalLine."Document No.",TRUE);

      ServiceTaxSetup.FindOnDate(PaymentGenJournalLine."Service Tax Group Code",PaymentGenJournalLine."Posting Date");
      ServiceTaxVerify.PostedAdvPmtAndInvGLBalPartial(
        ServiceTaxSetup,RevChargeType,DocumentType,PoT,PaymentBaseAmount,InvoiceBaseAmount);

      ServiceTaxVerify.UnappliedSTEntryDetails(ApplyTransactionNo);
Member of Miscellaneous.Service Tax Verify


UnappAdvPmtRemainingGLBalances@1500042 Method

The procedure UnappAdvPmtRemainingGLBalances is available in codeunit 143004.

Syntax

UnappAdvPmtRemainingGLBalances@1500042(
    ServiceTaxSetup@1500001 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    RevChargeType@1500003 : Option RevChargeType, //Input parameter of type Option
    PoT@1500004 : Boolean PoT, //Input parameter of type Boolean
    AdvancePaymentTaxAmount@1500000 : Decimal AdvancePaymentTaxAmount, //Input parameter of type Decimal
    FirstInvoiceTaxAmount@1500002 : Decimal FirstInvoiceTaxAmount //Input parameter of type Decimal
);

Parameters

ServiceTaxSetup
Input parameter of type Record
RevChargeType
Input parameter of type Option
PoT
Input parameter of type Boolean
AdvancePaymentTaxAmount
Input parameter of type Decimal
FirstInvoiceTaxAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Unapp, Adv, Payment, Remaining, General Ledger, Balances.

For a clarification about how this function works, refer to the code listed below.

      SecondInvoiceTaxAmount := AdvancePaymentTaxAmount - FirstInvoiceTaxAmount;
      IF RevChargeType <> ReverseChargeType::" " THEN
        ServTaxGLAccountsBalance(
          ServiceTaxSetup,0,AdvancePaymentTaxAmount + SecondInvoiceTaxAmount,-AdvancePaymentTaxAmount,-SecondInvoiceTaxAmount)
      ELSE
        IF PoT THEN
          ServTaxGLAccountsBalance(ServiceTaxSetup,AdvancePaymentTaxAmount + SecondInvoiceTaxAmount,-SecondInvoiceTaxAmount,0,0)
        ELSE
          ServTaxGLAccountsBalance(ServiceTaxSetup,FirstInvoiceTaxAmount,SecondInvoiceTaxAmount,0,0)

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      ServiceTaxVerify.UnappAdvPmtRemainSTEntryDetBal(
        AdvPaymentTaxAmount,FirstInvoiceTaxAmount,LastTransactionNo,RevChargeType,PoT);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDocNo,TRUE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PaymentGenJournalLine."Document No.",TRUE);
      ServiceTaxSetup.FindOnDate(PaymentGenJournalLine."Service Tax Group Code",PaymentGenJournalLine."Posting Date");
      ServiceTaxVerify.UnappAdvPmtRemainingGLBalances(ServiceTaxSetup,RevChargeType,PoT,AdvPaymentTaxAmount,FirstInvoiceTaxAmount);
Member of Miscellaneous.Service Tax Verify


UnappAdvPmtRemainingGLSBCKKCBalances@1500121 Method

The procedure UnappAdvPmtRemainingGLSBCKKCBalances is available in codeunit 143004.

Syntax

UnappAdvPmtRemainingGLSBCKKCBalances@1500121(
    ServiceTaxSetup@1500001 : Record 16472 ServiceTaxSetup, //Input parameter of type Record
    RevChargeType@1500003 : Option RevChargeType, //Input parameter of type Option
    PoT@1500004 : Boolean PoT, //Input parameter of type Boolean
    AdvancePaymentSBCAmount@1500000 : Decimal AdvancePaymentSBCAmount, //Input parameter of type Decimal
    FirstInvoiceSBCAmount@1500002 : Decimal FirstInvoiceSBCAmount, //Input parameter of type Decimal
    AdvancePaymentKKCAmount@1500007 : Decimal AdvancePaymentKKCAmount, //Input parameter of type Decimal
    FirstInvoiceKKCAmount@1500006 : Decimal FirstInvoiceKKCAmount //Input parameter of type Decimal
);

Parameters

ServiceTaxSetup
Input parameter of type Record
RevChargeType
Input parameter of type Option
PoT
Input parameter of type Boolean
AdvancePaymentSBCAmount
Input parameter of type Decimal
FirstInvoiceSBCAmount
Input parameter of type Decimal
AdvancePaymentKKCAmount
Input parameter of type Decimal
FirstInvoiceKKCAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Unapp, Adv, Payment, Remaining, GLSBCKKC, Balances.

For a clarification about how this function works, refer to the code listed below.

      SecondInvoiceSBCAmount := AdvancePaymentSBCAmount - FirstInvoiceSBCAmount;
      SecondInvoiceKKCAmount := AdvancePaymentKKCAmount - FirstInvoiceKKCAmount;

      IF RevChargeType <> ReverseChargeType::" " THEN BEGIN
        SBCGLAccountsBalance(
          ServiceTaxSetup,AdvancePaymentSBCAmount,SecondInvoiceSBCAmount,-AdvancePaymentSBCAmount,-SecondInvoiceSBCAmount);
        KKCGLAccountsBalance(
          ServiceTaxSetup,0,AdvancePaymentKKCAmount + SecondInvoiceKKCAmount,-AdvancePaymentKKCAmount,-SecondInvoiceKKCAmount)
      END ELSE
        IF PoT THEN BEGIN
          SBCGLAccountsBalance(ServiceTaxSetup,AdvancePaymentSBCAmount + SecondInvoiceSBCAmount,-SecondInvoiceSBCAmount,0,0);
          KKCGLAccountsBalance(ServiceTaxSetup,AdvancePaymentKKCAmount + SecondInvoiceKKCAmount,-SecondInvoiceKKCAmount,0,0);
        END ELSE BEGIN
          SBCGLAccountsBalance(ServiceTaxSetup,FirstInvoiceSBCAmount + SecondInvoiceSBCAmount,0,0,0);
          KKCGLAccountsBalance(ServiceTaxSetup,FirstInvoiceKKCAmount,SecondInvoiceKKCAmount,0,0);
        END;

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      ServiceTaxVerify.UnappAdvPmtRemainSBCKKCEntryDetBal(AdvPaymentSBCAmount,FirstInvoiceSBCAmount,
        AdvPaymentKKCAmount,FirstInvoiceKKCAmount,LastTransactionNo,RevChargeType,PoT);
      ServiceTaxSetup.FindOnDate(PaymentGenJournalLine."Service Tax Group Code",PaymentGenJournalLine."Posting Date");
      ServiceTaxVerify.UnappAdvPmtRemainingGLSBCKKCBalances(ServiceTaxSetup,RevChargeType,PoT,AdvPaymentSBCAmount,
        FirstInvoiceSBCAmount,AdvPaymentKKCAmount,FirstInvoiceKKCAmount);
Member of Miscellaneous.Service Tax Verify


UnappAdvPmtRemainSBCKKCEntryDetBal@1500120 Method

The procedure UnappAdvPmtRemainSBCKKCEntryDetBal is available in codeunit 143004.

Syntax

UnappAdvPmtRemainSBCKKCEntryDetBal@1500120(
    AdvancePaymentSBCAmount@1500002 : Decimal AdvancePaymentSBCAmount, //Input parameter of type Decimal
    FirstInvoiceSBCAmount@1500001 : Decimal FirstInvoiceSBCAmount, //Input parameter of type Decimal
    AdvancePaymentKKCAmount@1500004 : Decimal AdvancePaymentKKCAmount, //Input parameter of type Decimal
    FirstInvoiceKKCAmount@1500003 : Decimal FirstInvoiceKKCAmount, //Input parameter of type Decimal
    LastTransactionNo@1500006 : Integer LastTransactionNo, //Input parameter of type Integer
    ReverseCharge@1500011 : Option ReverseCharge, //Input parameter of type Option
    PoT@1500000 : Boolean PoT //Input parameter of type Boolean
);

Parameters

AdvancePaymentSBCAmount
Input parameter of type Decimal
FirstInvoiceSBCAmount
Input parameter of type Decimal
AdvancePaymentKKCAmount
Input parameter of type Decimal
FirstInvoiceKKCAmount
Input parameter of type Decimal
LastTransactionNo
Input parameter of type Integer
ReverseCharge
Input parameter of type Option
PoT
Input parameter of type Boolean

Remarks

The relevant search keywords are: Unapp, Adv, Payment, Remain, SBCKKC, Entry, Det, Bal.

For a clarification about how this function works, refer to the code listed below.

      CalcSTEntryDetailsBalances(LastTransactionNo,ServiceTaxEntryDetails);
      SecondInvoiceSBCAmount := AdvancePaymentSBCAmount - FirstInvoiceSBCAmount;
      SecondInvoiceKKCAmount := AdvancePaymentKKCAmount - FirstInvoiceKKCAmount;

      IF PoT THEN BEGIN
        Assert.AreEqual(AdvancePaymentSBCAmount + SecondInvoiceSBCAmount,ServiceTaxEntryDetails.FullTaxSBCAmount,SBCBalanceErr);
        Assert.AreEqual(AdvancePaymentKKCAmount + SecondInvoiceKKCAmount,ServiceTaxEntryDetails.KKCessAmount,KKCBalanceErr);
        Assert.AreEqual(
          AdvancePaymentKKCAmount + SecondInvoiceKKCAmount,ServiceTaxEntryDetails.KKCessRemainingCredit,KKCRemainingCreditBalErr);
        Assert.AreEqual(0,ServiceTaxEntryDetails.KKcessRevChargeRemainingCredit,KKCRevChargeRemCrBalErr);
      END ELSE
        IF ReverseCharge = ReverseChargeType::" " THEN BEGIN
          Assert.AreEqual(FirstInvoiceSBCAmount,ServiceTaxEntryDetails.FullTaxSBCAmount,SBCBalanceErr);
          Assert.AreEqual(FirstInvoiceKKCAmount,ServiceTaxEntryDetails.KKCessAmount,KKCBalanceErr);
          Assert.AreEqual(FirstInvoiceKKCAmount,ServiceTaxEntryDetails.KKCessRemainingCredit,KKCRemainingCreditBalErr);
          Assert.AreEqual(0,ServiceTaxEntryDetails.KKcessRevChargeRemainingCredit,KKCRevChargeRemCrBalErr);
        END ELSE BEGIN
          Assert.AreEqual(AdvancePaymentSBCAmount,ServiceTaxEntryDetails.FullTaxSBCAmount,SBCBalanceErr);
          Assert.AreEqual(AdvancePaymentKKCAmount,ServiceTaxEntryDetails.KKCessAmount,KKCBalanceErr);
          Assert.AreEqual(0,ServiceTaxEntryDetails.KKCessRemainingCredit,KKCRemainingCreditBalErr);
          Assert.AreEqual(AdvancePaymentKKCAmount,ServiceTaxEntryDetails.KKcessRevChargeRemainingCredit,KKCRevChargeRemCrBalErr);
        END;

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      ServiceTaxVerify.UnappAdvPmtRemainSBCKKCEntryDetBal(AdvPaymentSBCAmount,FirstInvoiceSBCAmount,
        AdvPaymentKKCAmount,FirstInvoiceKKCAmount,LastTransactionNo,RevChargeType,PoT);
      ServiceTaxSetup.FindOnDate(PaymentGenJournalLine."Service Tax Group Code",PaymentGenJournalLine."Posting Date");
      ServiceTaxVerify.UnappAdvPmtRemainingGLSBCKKCBalances(ServiceTaxSetup,RevChargeType,PoT,AdvPaymentSBCAmount,
        FirstInvoiceSBCAmount,AdvPaymentKKCAmount,FirstInvoiceKKCAmount);
Member of Miscellaneous.Service Tax Verify


UnappAdvPmtRemainSTEntryDetBal@1500041 Method

The procedure UnappAdvPmtRemainSTEntryDetBal is available in codeunit 143004.

Syntax

UnappAdvPmtRemainSTEntryDetBal@1500041(
    AdvancePaymentTaxAmount@1500002 : Decimal AdvancePaymentTaxAmount, //Input parameter of type Decimal
    FirstInvoiceTaxAmount@1500001 : Decimal FirstInvoiceTaxAmount, //Input parameter of type Decimal
    LastTransactionNo@1500006 : Integer LastTransactionNo, //Input parameter of type Integer
    ReverseCharge@1500011 : Option ReverseCharge, //Input parameter of type Option
    PoT@1500000 : Boolean PoT //Input parameter of type Boolean
);

Parameters

AdvancePaymentTaxAmount
Input parameter of type Decimal
FirstInvoiceTaxAmount
Input parameter of type Decimal
LastTransactionNo
Input parameter of type Integer
ReverseCharge
Input parameter of type Option
PoT
Input parameter of type Boolean

Remarks

The relevant search keywords are: Unapp, Adv, Payment, Remain, ST, Entry, Det, Bal.

For a clarification about how this function works, refer to the code listed below.

      CalcSTEntryDetailsBalances(LastTransactionNo,TotalSTEntryDetails);
      SecondInvoiceTaxAmount := AdvancePaymentTaxAmount - FirstInvoiceTaxAmount;

      IF PoT THEN BEGIN
        Assert.AreEqual(AdvancePaymentTaxAmount + SecondInvoiceTaxAmount,TotalSTEntryDetails.FullTaxAmount,ServiceTaxBalanceErr);
        Assert.AreEqual(
          AdvancePaymentTaxAmount + SecondInvoiceTaxAmount,TotalSTEntryDetails.FullRemainingCredit,RemainingCreditBalErr);
        Assert.AreEqual(0,TotalSTEntryDetails.FullRevChargeRemainingCredit,RevChargeRemCrBalErr);
      END ELSE
        IF ReverseCharge = ReverseChargeType::" " THEN BEGIN
          Assert.AreEqual(FirstInvoiceTaxAmount,TotalSTEntryDetails.FullTaxAmount,ServiceTaxBalanceErr);
          Assert.AreEqual(FirstInvoiceTaxAmount,TotalSTEntryDetails.FullRemainingCredit,RemainingCreditBalErr);
          Assert.AreEqual(0,TotalSTEntryDetails.FullRevChargeRemainingCredit,RevChargeRemCrBalErr);
        END ELSE BEGIN
          Assert.AreEqual(AdvancePaymentTaxAmount,TotalSTEntryDetails.FullTaxAmount,ServiceTaxBalanceErr);
          Assert.AreEqual(0,TotalSTEntryDetails.FullRemainingCredit,RemainingCreditBalErr);
          Assert.AreEqual(AdvancePaymentTaxAmount,TotalSTEntryDetails.FullRevChargeRemainingCredit,RevChargeRemCrBalErr);
        END;

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      ServiceTaxVerify.UnappAdvPmtRemainSTEntryDetBal(
        AdvPaymentTaxAmount,FirstInvoiceTaxAmount,LastTransactionNo,RevChargeType,PoT);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDocNo,TRUE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PaymentGenJournalLine."Document No.",TRUE);
      ServiceTaxSetup.FindOnDate(PaymentGenJournalLine."Service Tax Group Code",PaymentGenJournalLine."Posting Date");
      ServiceTaxVerify.UnappAdvPmtRemainingGLBalances(ServiceTaxSetup,RevChargeType,PoT,AdvPaymentTaxAmount,FirstInvoiceTaxAmount);
Member of Miscellaneous.Service Tax Verify


UnappAdvPmtSTEntryDetBalances@1500046 Method

The procedure UnappAdvPmtSTEntryDetBalances is available in codeunit 143004.

Syntax

UnappAdvPmtSTEntryDetBalances@1500046(
    PurchaseLineAmount@1500002 : Decimal PurchaseLineAmount, //Input parameter of type Decimal
    DocumentType@1500004 : Option DocumentType, //Input parameter of type Option
    LastTransactionNo@1500006 : Integer LastTransactionNo, //Input parameter of type Integer
    ServiceTaxGroupCode@1500009 : Code[20] ServiceTaxGroupCode, //Input parameter of type Code
    PostingDate@1500010 : Date PostingDate, //Input parameter of type Date
    PoT@1500000 : Boolean PoT //Input parameter of type Boolean
);

Parameters

PurchaseLineAmount
Input parameter of type Decimal
DocumentType
Input parameter of type Option
LastTransactionNo
Input parameter of type Integer
ServiceTaxGroupCode
Input parameter of type Code
PostingDate
Input parameter of type Date
PoT
Input parameter of type Boolean

Remarks

The relevant search keywords are: Unapp, Adv, Payment, ST, Entry, Det, Balances.

For a clarification about how this function works, refer to the code listed below.

      CalcSTEntryDetailsBalances(LastTransactionNo,TotalSTEntryDetails);
      ServiceTaxSetup.FindOnDate(ServiceTaxGroupCode,PostingDate);
      ServiceTaxAmount := ReverseServiceTaxHelper.CalculateServTaxAmount(ServiceTaxSetup,PurchaseLineAmount,DocumentType);
      SBCAmount := ReverseServiceTaxHelper.CalculateServTaxSBCAmount(ServiceTaxSetup,PurchaseLineAmount,DocumentType);
      KKCAmount := ReverseServiceTaxHelper.CalculateKKCAmount(ServiceTaxSetup,PurchaseLineAmount,DocumentType);

      IF PoT THEN BEGIN
        Assert.AreEqual(ServiceTaxAmount,TotalSTEntryDetails.FullTaxAmount,ServiceTaxBalanceErr);
        Assert.AreEqual(SBCAmount,TotalSTEntryDetails.FullTaxSBCAmount,SBCBalanceErr);
        Assert.AreEqual(KKCAmount,TotalSTEntryDetails.KKCessAmount,KKCBalanceErr);
        Assert.AreEqual(ServiceTaxAmount,TotalSTEntryDetails.FullRemainingCredit,RemainingCreditBalErr);
        Assert.AreEqual(KKCAmount,TotalSTEntryDetails.KKCessRemainingCredit,KKCRemainingCreditBalErr);
        Assert.AreEqual(0,TotalSTEntryDetails.FullRevChargeRemainingCredit,RevChargeRemCrBalErr);
        Assert.AreEqual(0,TotalSTEntryDetails.KKcessRevChargeRemainingCredit,KKCRevChargeRemCrBalErr);
      END ELSE BEGIN
        Assert.AreEqual(0,TotalSTEntryDetails.FullTaxAmount,ServiceTaxBalanceErr);
        Assert.AreEqual(0,TotalSTEntryDetails.FullTaxSBCAmount,SBCBalanceErr);
        Assert.AreEqual(0,TotalSTEntryDetails.KKCessAmount,KKCBalanceErr);
        Assert.AreEqual(0,TotalSTEntryDetails.FullRemainingCredit,RemainingCreditBalErr);
        Assert.AreEqual(0,TotalSTEntryDetails.KKCessRemainingCredit,KKCRemainingCreditBalErr);
        Assert.AreEqual(0,TotalSTEntryDetails.FullRevChargeRemainingCredit,RevChargeRemCrBalErr);
        Assert.AreEqual(0,TotalSTEntryDetails.KKcessRevChargeRemainingCredit,KKCRevChargeRemCrBalErr);
      END;

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      ServiceTaxVerify.VendorLedgerEntryRemAmt(PostedPartialPayment,Amount);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDoc,TRUE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPartialPayment,TRUE);

      ServiceTaxVerify.UnappAdvPmtSTEntryDetBalances(
        PurchaseLine."Line Amount",DocumentType,LastTransactionNo,
        PurchaseLine."Service Tax Group",PurchaseHeader."Posting Date",PoT);
      ServiceTaxVerify.UnappliedSTEntryDetails(ApplyTransactionNo);

      ServiceTaxVerify.GLBalancesOnPostedPurchaseDoc(
        PurchaseHeader."Posting Date",PurchaseLine,PostedPurchaseDoc,DocumentType,RevChargeType,PoT);
Member of Miscellaneous.Service Tax Verify


UnappAdvRefundSTEntryDetBal@1500155 Method

The procedure UnappAdvRefundSTEntryDetBal is available in codeunit 143004.

Syntax

UnappAdvRefundSTEntryDetBal@1500155(
    LastTransactionNo@1500006 : Integer LastTransactionNo //Input parameter of type Integer
);

Parameters

LastTransactionNo
Input parameter of type Integer

Remarks

The relevant search keywords are: Unapp, Adv, Refund, ST, Entry, Det, Bal.

For a clarification about how this function works, refer to the code listed below.

      CalcSTEntryDetailsBalances(LastTransactionNo,TotalSTEntryDetails);
      Assert.AreEqual(0,TotalSTEntryDetails.FullTaxAmount,ServiceTaxBalanceErr);
      Assert.AreEqual(0,TotalSTEntryDetails.FullRemainingCredit,RemainingCreditBalErr);
      Assert.AreEqual(0,TotalSTEntryDetails.FullRevChargeRemainingCredit,RevChargeRemCrBalErr);
      Assert.AreEqual(0,TotalSTEntryDetails.FullTaxSBCAmount,SBCBalanceErr);
      Assert.AreEqual(0,TotalSTEntryDetails.KKCessAmount,KKCBalanceErr);
      Assert.AreEqual(0,TotalSTEntryDetails.KKCessRemainingCredit,KKCRemainingCreditBalErr);
      Assert.AreEqual(0,TotalSTEntryDetails.KKcessRevChargeRemainingCredit,KKCRevChargeRemCrBalErr)

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      ServiceTaxVerify.UnappAdvRefundSTEntryDetBal(LastTransactionNo);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDocNo,TRUE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PaymentGenJournalLine."Document No.",TRUE);
      ServiceTaxSetup.FindOnDate(PaymentGenJournalLine."Service Tax Group Code",PaymentGenJournalLine."Posting Date");
      ServiceTaxVerify.ServTaxGLAccountsBalance(ServiceTaxSetup,0,0,0,0);
      ServiceTaxVerify.SBCGLAccountsBalance(ServiceTaxSetup,0,0,0,0);
      ServiceTaxVerify.KKCGLAccountsBalance(ServiceTaxSetup,0,0,0,0);
      ServiceTaxVerify.UnappliedSTEntryDetails(ApplyTransactionNo);
Member of Miscellaneous.Service Tax Verify


UnappliedAdvSTEntryDetBalances@1500036 Method

The procedure UnappliedAdvSTEntryDetBalances is available in codeunit 143004.

Syntax

UnappliedAdvSTEntryDetBalances@1500036(
    PurchaseLineAmount@1500002 : Decimal PurchaseLineAmount, //Input parameter of type Decimal
    DocumentType@1500004 : Option DocumentType, //Input parameter of type Option
    LastTransactionNo@1500006 : Integer LastTransactionNo, //Input parameter of type Integer
    ServiceTaxGroupCode@1500009 : Code[20] ServiceTaxGroupCode, //Input parameter of type Code
    PostingDate@1500010 : Date PostingDate, //Input parameter of type Date
    RevChargeType@1500001 : Option RevChargeType, //Input parameter of type Option
    PoT@1500000 : Boolean PoT //Input parameter of type Boolean
);

Parameters

PurchaseLineAmount
Input parameter of type Decimal
DocumentType
Input parameter of type Option
LastTransactionNo
Input parameter of type Integer
ServiceTaxGroupCode
Input parameter of type Code
PostingDate
Input parameter of type Date
RevChargeType
Input parameter of type Option
PoT
Input parameter of type Boolean

Remarks

The relevant search keywords are: Unapplied, Adv, ST, Entry, Det, Balances.

For a clarification about how this function works, refer to the code listed below.

      UnappAdvPmtPartialSTEntrDetBal(
        PurchaseLineAmount,PurchaseLineAmount,DocumentType,LastTransactionNo,ServiceTaxGroupCode,PostingDate,RevChargeType,PoT);

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      ServiceTaxVerify.UnappliedAdvSTEntryDetBalances(
        PaymentBaseAmount,PaymentGenJournalLine."Document Type",LastTransactionNo,PaymentGenJournalLine."Service Tax Group Code",
        PaymentGenJournalLine."Posting Date",RevChargeType,PoT);

      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDocNo,TRUE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PaymentGenJournalLine."Document No.",TRUE);
      ServiceTaxSetup.FindOnDate(PaymentGenJournalLine."Service Tax Group Code",PaymentGenJournalLine."Posting Date");
      ServiceTaxVerify.PostedAdvPmtAndInvGLBalance(ServiceTaxSetup,RevChargeType,PoT,PaymentTaxAmount);
      ServiceTaxVerify.UnappliedSTEntryDetails(ApplyTransactionNo);
Member of Miscellaneous.Service Tax Verify


UnappliedDtldVLEntries@1500020 Method

The procedure UnappliedDtldVLEntries is available in codeunit 143004.

Syntax

UnappliedDtldVLEntries@1500020(
    DocumentNo@1500001 : Code[20] DocumentNo //Input parameter of type Code
);

Parameters

DocumentNo
Input parameter of type Code

Remarks

The relevant search keywords are: Unapplied, Dtld, VL, Entries.

For a clarification about how this function works, refer to the code listed below.

      VendLedgEntry.SETRANGE("Document No.",DocumentNo);
      VendLedgEntry.FINDLAST;

      DtldVendLedgEntry.SETRANGE("Vendor Ledger Entry No.",VendLedgEntry."Entry No.");
      DtldVendLedgEntry.SETRANGE("Entry Type",DtldVendLedgEntry."Entry Type"::Application);
      DtldVendLedgEntry.SETRANGE(Unapplied,TRUE);
      Assert.IsFalse(DtldVendLedgEntry.ISEMPTY,NoUnappliedEntriesErr);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;
      IncludeServTax := TRUE;
      ServiceTaxTDSHelper.InvGenJnlPoTAppliesToPmt(GenJournalLine,IncludeServTax);

      ReverseServiceTaxHelper.UnapplyVendorLedgerEntry(GenJournalLine."Document No.");

      // Verify
      ServiceTaxVerify.UnappliedDtldVLEntries(GenJournalLine."Document No.");
      ServiceTaxTDSHelper.VerifyTDSPostingInvoice(GenJournalLine,IncludeServTax);
Member of Miscellaneous.Service Tax Verify


UnappliedSTEntryDetails@1500035 Method

The procedure UnappliedSTEntryDetails is available in codeunit 143004.

Syntax

UnappliedSTEntryDetails@1500035(
    ApplyTransactionNo@1500000 : Integer ApplyTransactionNo //Input parameter of type Integer
);

Parameters

ApplyTransactionNo
Input parameter of type Integer

Remarks

The relevant search keywords are: Unapplied, ST, Entry, Details.

For a clarification about how this function works, refer to the code listed below.

      WITH STEntryDetails DO BEGIN
        SETFILTER("Transaction No.",'>=%1',ApplyTransactionNo);
        IF FINDSET THEN
          REPEAT
            IF NOT (PoT AND NOT "Corrective Application Entry") THEN
              VerifyClosedRemCredit(STEntryDetails);
          UNTIL NEXT = 0;

        VerifyServTaxEntriesAreNotPaid(ApplyTransactionNo);
        CountOfUnappliedEntries(ApplyTransactionNo);
      END;

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      ServiceTaxVerify.VendorLedgerEntryRemAmt(PostedPartialPayment,Amount);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDoc,TRUE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPartialPayment,TRUE);

      ServiceTaxVerify.UnappAdvPmtSTEntryDetBalances(
        PurchaseLine."Line Amount",DocumentType,LastTransactionNo,
        PurchaseLine."Service Tax Group",PurchaseHeader."Posting Date",PoT);
      ServiceTaxVerify.UnappliedSTEntryDetails(ApplyTransactionNo);

      ServiceTaxVerify.GLBalancesOnPostedPurchaseDoc(
        PurchaseHeader."Posting Date",PurchaseLine,PostedPurchaseDoc,DocumentType,RevChargeType,PoT);
Member of Miscellaneous.Service Tax Verify


UnappPmtRemainSTEntryDetBal@1500057 Method

The procedure UnappPmtRemainSTEntryDetBal is available in codeunit 143004.

Syntax

UnappPmtRemainSTEntryDetBal@1500057(
    FirstAppliedAmount@1500002 : Decimal FirstAppliedAmount, //Input parameter of type Decimal
    SecondAppliedAmount@1500001 : Decimal SecondAppliedAmount, //Input parameter of type Decimal
    LastTransactionNo@1500006 : Integer LastTransactionNo, //Input parameter of type Integer
    ReverseCharge@1500011 : Option ReverseCharge, //Input parameter of type Option
    PoT@1500000 : Boolean PoT //Input parameter of type Boolean
);

Parameters

FirstAppliedAmount
Input parameter of type Decimal
SecondAppliedAmount
Input parameter of type Decimal
LastTransactionNo
Input parameter of type Integer
ReverseCharge
Input parameter of type Option
PoT
Input parameter of type Boolean

Remarks

The relevant search keywords are: Unapp, Payment, Remain, ST, Entry, Det, Bal.

For a clarification about how this function works, refer to the code listed below.

      CalcSTEntryDetailsBalances(LastTransactionNo,TotalSTEntryDetails);

      IF PoT THEN BEGIN
        Assert.AreEqual(FirstAppliedAmount + SecondAppliedAmount,TotalSTEntryDetails.FullTaxAmount,ServiceTaxBalanceErr);
        Assert.AreEqual(FirstAppliedAmount + SecondAppliedAmount,TotalSTEntryDetails.FullRemainingCredit,RemainingCreditBalErr);
        Assert.AreEqual(0,TotalSTEntryDetails.FullRevChargeRemainingCredit,RevChargeRemCrBalErr);
      END ELSE
        IF ReverseCharge = ReverseChargeType::" " THEN BEGIN
          GLSetup.GET;
          Assert.AreNearlyEqual(
            FirstAppliedAmount,TotalSTEntryDetails.FullTaxAmount,
            GLSetup."Service Tax Rounding Precision",ServiceTaxBalanceErr);
          Assert.AreNearlyEqual(
            FirstAppliedAmount,TotalSTEntryDetails.FullRemainingCredit,
            GLSetup."Service Tax Rounding Precision",RemainingCreditBalErr);
          Assert.AreEqual(0,TotalSTEntryDetails.FullRevChargeRemainingCredit,RevChargeRemCrBalErr);
        END ELSE BEGIN
          Assert.AreEqual(FirstAppliedAmount,TotalSTEntryDetails.FullTaxAmount,ServiceTaxBalanceErr);
          Assert.AreEqual(0,TotalSTEntryDetails.FullRemainingCredit,RemainingCreditBalErr);
          Assert.AreEqual(FirstAppliedAmount,TotalSTEntryDetails.FullRevChargeRemainingCredit,RevChargeRemCrBalErr);
        END;

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      ServiceTaxSetup.FindOnDate(PurchaseLine."Service Tax Group",PurchaseHeader."Posting Date");

      IF RevChargeType = ReverseChargeTypeOption::" " THEN
        BaseAmount := ReverseServiceTaxHelper.CalcServTaxBaseAmountBackward(BaseAmount,ServiceTaxSetup,0);

      InvoiceTaxAmount := ReverseServiceTaxHelper.CalculateServTaxAmount(ServiceTaxSetup,BaseAmount,DocumentType);

      FirstPaymentTaxAmount := ReverseServiceTaxHelper.RoundServTax(PartialPaymentFactor * InvoiceTaxAmount);
      SecondPaymentTaxAmount := ReverseServiceTaxHelper.RoundServTax((1 - PartialPaymentFactor) * InvoiceTaxAmount);

      SBCAmount :=
        ReverseServiceTaxHelper.CalculateServTaxSBCAmount(ServiceTaxSetup,BaseAmount,DocumentType);
      KKCAmount :=
        ReverseServiceTaxHelper.CalculateKKCAmount(ServiceTaxSetup,BaseAmount,DocumentType);

      FirstPaymentSBCAmount := ReverseServiceTaxHelper.RoundServTax(PartialPaymentFactor * SBCAmount);
      FirstPaymentKKCAmount := ReverseServiceTaxHelper.RoundServTax(PartialPaymentFactor * KKCAmount);
      SecondPaymentSBCAmount := ReverseServiceTaxHelper.RoundServTax((1 - PartialPaymentFactor) * SBCAmount);
      SecondPaymentKKCAmount := ReverseServiceTaxHelper.RoundServTax((1 - PartialPaymentFactor) * KKCAmount);

      ServiceTaxVerify.CountOfUnappliedEntries(ApplyTransactionNo);

      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDoc,TRUE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedRemainingPayment,TRUE);

      ServiceTaxVerify.UnappPmtRemainSTEntryDetBal(FirstPaymentTaxAmount,SecondPaymentTaxAmount,LastTransactionNo,RevChargeType,PoT);
      ServiceTaxVerify.UnappPmtRemainSTSBCKKCEntryDetBal(FirstPaymentSBCAmount,SecondPaymentSBCAmount,
        FirstPaymentKKCAmount,SecondPaymentKKCAmount,
        LastTransactionNo,RevChargeType,PoT);

      IF RevChargeType = ReverseChargeTypeOption::" " THEN
        ServiceTaxVerify.VendorLedgerEntryRemAmt(
          PostedPurchaseDoc,-((1 - PartialPaymentFactor) * (BaseAmount + InvoiceTaxAmount + SBCAmount + KKCAmount)))
      ELSE
        ServiceTaxVerify.VendorLedgerEntryRemAmt(PostedPurchaseDoc,-((1 - PartialPaymentFactor) * BaseAmount));

      ServiceTaxVerify.PostedPmtAndInvGLBalPartial(
        ServiceTaxSetup,RevChargeType,PoT,InvoiceTaxAmount,FirstPaymentTaxAmount);
      ServiceTaxVerify.PostedSBCKKCPmtAndInvGLBalPartial(
        ServiceTaxSetup,RevChargeType,PoT,SBCAmount,FirstPaymentSBCAmount,KKCAmount,FirstPaymentKKCAmount);
Member of Miscellaneous.Service Tax Verify


UnappPmtRemainSTSBCKKCEntryDetBal@1500102 Method

The procedure UnappPmtRemainSTSBCKKCEntryDetBal is available in codeunit 143004.

Syntax

UnappPmtRemainSTSBCKKCEntryDetBal@1500102(
    FirstAppliedSBCAmount@1500002 : Decimal FirstAppliedSBCAmount, //Input parameter of type Decimal
    SecondAppliedSBCAmount@1500001 : Decimal SecondAppliedSBCAmount, //Input parameter of type Decimal
    FirstAppliedKKCAmount@1500007 : Decimal FirstAppliedKKCAmount, //Input parameter of type Decimal
    SecondAppliedKKCAmount@1500004 : Decimal SecondAppliedKKCAmount, //Input parameter of type Decimal
    LastTransactionNo@1500006 : Integer LastTransactionNo, //Input parameter of type Integer
    ReverseCharge@1500011 : Option ReverseCharge, //Input parameter of type Option
    PoT@1500000 : Boolean PoT //Input parameter of type Boolean
);

Parameters

FirstAppliedSBCAmount
Input parameter of type Decimal
SecondAppliedSBCAmount
Input parameter of type Decimal
FirstAppliedKKCAmount
Input parameter of type Decimal
SecondAppliedKKCAmount
Input parameter of type Decimal
LastTransactionNo
Input parameter of type Integer
ReverseCharge
Input parameter of type Option
PoT
Input parameter of type Boolean

Remarks

The relevant search keywords are: Unapp, Payment, Remain, STSBCKKC, Entry, Det, Bal.

For a clarification about how this function works, refer to the code listed below.

      CalcSTEntryDetailsBalances(LastTransactionNo,ServiceTaxEntryDetails);

      IF PoT THEN BEGIN
        Assert.AreEqual(FirstAppliedSBCAmount + SecondAppliedSBCAmount,ServiceTaxEntryDetails.FullTaxSBCAmount,SBCBalanceErr);
        Assert.AreEqual(FirstAppliedKKCAmount + SecondAppliedKKCAmount,ServiceTaxEntryDetails.KKCessAmount,KKCBalanceErr);
        Assert.AreEqual(FirstAppliedKKCAmount + SecondAppliedKKCAmount,ServiceTaxEntryDetails.KKCessRemainingCredit,
          KKCRemainingCreditBalErr);
        Assert.AreEqual(0,ServiceTaxEntryDetails.KKcessRevChargeRemainingCredit,KKCRevChargeRemCrBalErr);
      END ELSE
        IF ReverseCharge = ReverseChargeType::" " THEN BEGIN
          GLSetup.GET;
          Assert.AreNearlyEqual(
            FirstAppliedSBCAmount,ServiceTaxEntryDetails.FullTaxSBCAmount,
            GLSetup."Service Tax Rounding Precision",SBCBalanceErr);
          Assert.AreNearlyEqual(
            FirstAppliedKKCAmount,ServiceTaxEntryDetails.KKCessAmount,
            GLSetup."Service Tax Rounding Precision",KKCBalanceErr);
          Assert.AreNearlyEqual(
            FirstAppliedKKCAmount,ServiceTaxEntryDetails.KKCessRemainingCredit,
            GLSetup."Service Tax Rounding Precision",KKCRemainingCreditBalErr);
          Assert.AreEqual(0,ServiceTaxEntryDetails.KKcessRevChargeRemainingCredit,KKCRevChargeRemCrBalErr);
        END ELSE BEGIN
          Assert.AreEqual(FirstAppliedSBCAmount,ServiceTaxEntryDetails.FullTaxSBCAmount,SBCBalanceErr);
          Assert.AreEqual(FirstAppliedKKCAmount,ServiceTaxEntryDetails.KKCessAmount,KKCBalanceErr);
          Assert.AreEqual(0,ServiceTaxEntryDetails.KKCessRemainingCredit,KKCRemainingCreditBalErr);
          Assert.AreEqual(FirstAppliedKKCAmount,ServiceTaxEntryDetails.KKcessRevChargeRemainingCredit,
            KKCRevChargeRemCrBalErr);
        END;

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      ServiceTaxSetup.FindOnDate(PurchaseLine."Service Tax Group",PurchaseHeader."Posting Date");

      IF RevChargeType = ReverseChargeTypeOption::" " THEN
        BaseAmount := ReverseServiceTaxHelper.CalcServTaxBaseAmountBackward(BaseAmount,ServiceTaxSetup,0);

      InvoiceTaxAmount := ReverseServiceTaxHelper.CalculateServTaxAmount(ServiceTaxSetup,BaseAmount,DocumentType);

      FirstPaymentTaxAmount := ReverseServiceTaxHelper.RoundServTax(PartialPaymentFactor * InvoiceTaxAmount);
      SecondPaymentTaxAmount := ReverseServiceTaxHelper.RoundServTax((1 - PartialPaymentFactor) * InvoiceTaxAmount);

      SBCAmount :=
        ReverseServiceTaxHelper.CalculateServTaxSBCAmount(ServiceTaxSetup,BaseAmount,DocumentType);
      KKCAmount :=
        ReverseServiceTaxHelper.CalculateKKCAmount(ServiceTaxSetup,BaseAmount,DocumentType);

      FirstPaymentSBCAmount := ReverseServiceTaxHelper.RoundServTax(PartialPaymentFactor * SBCAmount);
      FirstPaymentKKCAmount := ReverseServiceTaxHelper.RoundServTax(PartialPaymentFactor * KKCAmount);
      SecondPaymentSBCAmount := ReverseServiceTaxHelper.RoundServTax((1 - PartialPaymentFactor) * SBCAmount);
      SecondPaymentKKCAmount := ReverseServiceTaxHelper.RoundServTax((1 - PartialPaymentFactor) * KKCAmount);

      ServiceTaxVerify.CountOfUnappliedEntries(ApplyTransactionNo);

      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDoc,TRUE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedRemainingPayment,TRUE);

      ServiceTaxVerify.UnappPmtRemainSTEntryDetBal(FirstPaymentTaxAmount,SecondPaymentTaxAmount,LastTransactionNo,RevChargeType,PoT);
      ServiceTaxVerify.UnappPmtRemainSTSBCKKCEntryDetBal(FirstPaymentSBCAmount,SecondPaymentSBCAmount,
        FirstPaymentKKCAmount,SecondPaymentKKCAmount,
        LastTransactionNo,RevChargeType,PoT);

      IF RevChargeType = ReverseChargeTypeOption::" " THEN
        ServiceTaxVerify.VendorLedgerEntryRemAmt(
          PostedPurchaseDoc,-((1 - PartialPaymentFactor) * (BaseAmount + InvoiceTaxAmount + SBCAmount + KKCAmount)))
      ELSE
        ServiceTaxVerify.VendorLedgerEntryRemAmt(PostedPurchaseDoc,-((1 - PartialPaymentFactor) * BaseAmount));

      ServiceTaxVerify.PostedPmtAndInvGLBalPartial(
        ServiceTaxSetup,RevChargeType,PoT,InvoiceTaxAmount,FirstPaymentTaxAmount);
      ServiceTaxVerify.PostedSBCKKCPmtAndInvGLBalPartial(
        ServiceTaxSetup,RevChargeType,PoT,SBCAmount,FirstPaymentSBCAmount,KKCAmount,FirstPaymentKKCAmount);
Member of Miscellaneous.Service Tax Verify


VendorAndServicesEntries@1500113 Method

The procedure VendorAndServicesEntries is available in codeunit 143004.

Syntax

VendorAndServicesEntries@1500113(
    PostedDocNo@1500007 : Code[20] PostedDocNo, //Input parameter of type Code
    VendorNo@1500009 : Code[20] VendorNo, //Input parameter of type Code
    ReversedGLAccount@1500010 : Code[20] ReversedGLAccount, //Input parameter of type Code
    VendorEntryOpen@1500011 : Boolean VendorEntryOpen, //Input parameter of type Boolean
    BaseAmount@1500001 : Decimal BaseAmount, //Input parameter of type Decimal
    TaxAmount@1500000 : Decimal TaxAmount, //Input parameter of type Decimal
    RevChargeType@1500002 : Option RevChargeType, //Input parameter of type Option
    IsInvoiceOrOrder@1500004 : Boolean IsInvoiceOrOrder //Input parameter of type Boolean
);

Parameters

PostedDocNo
Input parameter of type Code
VendorNo
Input parameter of type Code
ReversedGLAccount
Input parameter of type Code
VendorEntryOpen
Input parameter of type Boolean
BaseAmount
Input parameter of type Decimal
TaxAmount
Input parameter of type Decimal
RevChargeType
Input parameter of type Option
IsInvoiceOrOrder
Input parameter of type Boolean

Remarks

The relevant search keywords are: Vendor, Services, Entries.

For a clarification about how this function works, refer to the code listed below.

      IF RevChargeType = ReverseChargeType::" " THEN
        Amount := BaseAmount + TaxAmount
      ELSE
        Amount := BaseAmount;

      // Vendors, Domestic
      VendorLedgerEntryOpen(PostedDocNo,VendorEntryOpen);
      GLEntry(PostedDocNo,ReverseServiceTaxHelper.GetVendorPostingAccount(VendorNo),-Amount);

      // Services
      IF IsInvoiceOrOrder THEN
        AccountBalance(ReversedGLAccount,BaseAmount)
      ELSE
        GLEntry(PostedDocNo,ReversedGLAccount,Amount)

Example

The below example is extracted from the test automation codeunit 144032 to show one way of using this function.

      LastTransactionNo := Initialize;

      GenJournalLine.PoT := PoT;
      PostedDocNo :=
        ApplyBiggerDocToAdvPmt(
          GenJournalLine,DocumentType,RevChargeType,
          GLAccountNo,InvoiceBaseAmount,InvoiceTaxAmount,PaymentBaseAmount,PaymentTaxAmount);

      // Verify
      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      IF RevChargeType = ReverseChargeType::" " THEN
        IF NOT PoT THEN BEGIN
          VerifySTEntriesNoPoTPartialApp(LastTransactionNo,GenJournalLine,PaymentBaseAmount,InvoiceBaseAmount);
          ServiceTaxVerify.ServTaxGLAccountsBalance(ServiceTaxSetup,PaymentTaxAmount,InvoiceTaxAmount - PaymentTaxAmount,0,0);
        END ELSE BEGIN
          ServiceTaxVerify.STEntriesFullPurchFlow(LastTransactionNo,GenJournalLine,InvoiceBaseAmount,RevChargeType);
          ServiceTaxVerify.GLBalanceReceivablesOnly(ServiceTaxSetup,InvoiceTaxAmount);
        END
      ELSE BEGIN
        VerifySTEntriesRevCPartialApp(LastTransactionNo,GenJournalLine,PaymentBaseAmount,InvoiceBaseAmount);
        ServiceTaxVerify.STRecInterimAccBalance(ServiceTaxSetup,InvoiceTaxAmount);
        ServiceTaxVerify.STPayInterimAccBalance(ServiceTaxSetup,PaymentTaxAmount - InvoiceTaxAmount);
      END;

      // vendor ledger entry
      ServiceTaxVerify.VendorLedgerEntryOpen(GenJournalLine."Document No.",FALSE);

      // vendor and services
      KKCAmount := ReverseServiceTaxHelper.CalculateSBC(InvoiceBaseAmount,ServiceTaxSetup);
      SBCAmount := ReverseServiceTaxHelper.CalculateKKCess(InvoiceBaseAmount,ServiceTaxSetup);
      ServiceTaxVerify.VendorAndServicesEntries(PostedDocNo,GenJournalLine."Account No.",
        GLAccountNo,TRUE,InvoiceBaseAmount,InvoiceTaxAmount + KKCAmount + SBCAmount,RevChargeType,TRUE);
Member of Miscellaneous.Service Tax Verify


VendorLedgerEntryOpen@1500052 Method

The procedure VendorLedgerEntryOpen is available in codeunit 143004.

Syntax

VendorLedgerEntryOpen@1500052(
    DocumentNo@1500003 : Code[20] DocumentNo, //Input parameter of type Code
    Open@1500001 : Boolean Open //Input parameter of type Boolean
);

Parameters

DocumentNo
Input parameter of type Code
Open
Input parameter of type Boolean

Remarks

The relevant search keywords are: Vendor, Ledger, Entry, Open.

For a clarification about how this function works, refer to the code listed below.

      FindLastPurchDocument(DocumentNo,VendorLedgerEntry);
      Assert.AreEqual(Open,VendorLedgerEntry.Open,UnexpectedVendLedgEntryOpenErr);

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      LastTransactionNo := Initialize;

      // Setup:
      PoT := ReverseChargeType = ReverseChargeTypeOption::" ";
      ReverseServiceTaxHelper.CreatePurchaseDoc(
        PurchaseHeader,PurchaseLine,PurchaseHeader."Document Type"::Invoice,ReverseChargeType,100,PoT);

      // Exercise
      PostedDocNo1 := ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);
      PostedDocNo2 := PostAndApplyCrMemo(PurchaseHeader,PostedDocNo1,InvAmountIs);

      // Verify
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedDocNo1,InvAmountIs = InvoiceAmountIs::Greater);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedDocNo2,InvAmountIs = InvoiceAmountIs::Smaller);

      ServiceTaxSetup.FindOnDate(PurchaseLine."Service Tax Group",PurchaseHeader."Posting Date");
      InvoiceBaseAmount := ReverseServiceTaxHelper.CalculateServTaxBase(PurchaseLine."Line Amount",PurchaseHeader."Document Type");
      InvoiceTaxAmount := ReverseServiceTaxHelper.CalculateServTaxTotal(InvoiceBaseAmount,ServiceTaxSetup);
      CrMemoBaseAmount := -InvoiceBaseAmount / ReverseServiceTaxHelper.GetPurchInvAmountFactor(InvAmountIs);
      CrMemoTaxAmount := ReverseServiceTaxHelper.CalculateServTaxTotal(CrMemoBaseAmount,ServiceTaxSetup);

      ServiceTaxVerify.ServTaxEntry(PostedDocNo1,InvoiceBaseAmount,ServiceTaxSetup);
      ServiceTaxVerify.ServTaxEntry(PostedDocNo2,CrMemoBaseAmount,ServiceTaxSetup);

      ServiceTaxVerify.PostedPurchDocGLBalance(ServiceTaxSetup,ReverseChargeType,PoT,InvoiceTaxAmount + CrMemoTaxAmount);

      IF ReverseChargeType = ReverseChargeTypeOption::" " THEN
        IF PoT THEN BEGIN
          ServiceTaxVerify.STEntryDetailsRemainingCredit(LastTransactionNo,InvoiceTaxAmount + CrMemoTaxAmount);
          ServiceTaxVerify.ServTaxEntriesArePaid(ReverseServiceTaxHelper.GetLastTransactionNo);
        END ELSE
          ServiceTaxVerify.STEntryDetailsRemainingCredit(LastTransactionNo,0)
      ELSE
        ServiceTaxVerify.STEntryDetailsRemRevChrgCredit(LastTransactionNo,0);

      IF InvAmountIs = InvoiceAmountIs::Greater THEN
        SmallerDocumentNo := PostedDocNo2
      ELSE
        SmallerDocumentNo := PostedDocNo1;
      ServiceTaxVerify.DocHasClosedRemCredit(SmallerDocumentNo);
Member of Miscellaneous.Service Tax Verify


VendorLedgerEntryRemAmt@1500152 Method

The procedure VendorLedgerEntryRemAmt is available in codeunit 143004.

Syntax

VendorLedgerEntryRemAmt@1500152(
    DocumentNo@1500003 : Code[20] DocumentNo, //Input parameter of type Code
    ExpectedRemAmount@1500001 : Decimal ExpectedRemAmount //Input parameter of type Decimal
);

Parameters

DocumentNo
Input parameter of type Code
ExpectedRemAmount
Input parameter of type Decimal

Remarks

The relevant search keywords are: Vendor, Ledger, Entry, Rem, Amt.

For a clarification about how this function works, refer to the code listed below.

      GLSetup.GET;
      Assert.AreNearlyEqual(
        ExpectedRemAmount,CalcVendLedgEntryRemAmount(DocumentNo),
        GLSetup."Service Tax Rounding Precision",STRSUBSTNO(AmountErr,VendorLedgerEntry.TABLECAPTION));

Example

The below example is extracted from the test automation codeunit 144031 to show one way of using this function.

      ServiceTaxVerify.VendorLedgerEntryRemAmt(PostedPartialPayment,Amount);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPurchaseDoc,TRUE);
      ServiceTaxVerify.VendorLedgerEntryOpen(PostedPartialPayment,TRUE);

      ServiceTaxVerify.UnappAdvPmtSTEntryDetBalances(
        PurchaseLine."Line Amount",DocumentType,LastTransactionNo,
        PurchaseLine."Service Tax Group",PurchaseHeader."Posting Date",PoT);
      ServiceTaxVerify.UnappliedSTEntryDetails(ApplyTransactionNo);

      ServiceTaxVerify.GLBalancesOnPostedPurchaseDoc(
        PurchaseHeader."Posting Date",PurchaseLine,PostedPurchaseDoc,DocumentType,RevChargeType,PoT);
Member of Miscellaneous.Service Tax Verify


Service Tax With TDS Helper Class

Miscellaneous.Service Tax With TDS Helper

COD143005 applies to ERM,IN.

Methods

Name | Description
AddLineToNODNOCSetup@1500088 | The procedure AddLineToNODNOCSetup is available in codeunit 143005.
AddPoTToAdvPmtAmount@1500095 | The procedure AddPoTToAdvPmtAmount is available in codeunit 143005.
AdvPaymentPoT@1500042 | The procedure AdvPaymentPoT is available in codeunit 143005.
AdvPaymentRevChrg@1500047 | The procedure AdvPaymentRevChrg is available in codeunit 143005.
AdvPaymentSplit@1500052 | The procedure AdvPaymentSplit is available in codeunit 143005.
AdvPmtApplyBiggerInvDocPoT@1500085 | The procedure AdvPmtApplyBiggerInvDocPoT is available in codeunit 143005.
AdvPmtApplyBiggerInvDocPoTFcy@1500043 | The procedure AdvPmtApplyBiggerInvDocPoTFcy is available in codeunit 143005.
AdvPmtApplyBiggerInvDocRevChrg@1500099 | The procedure AdvPmtApplyBiggerInvDocRevChrg is available in codeunit 143005.
AdvPmtApplyBiggerInvGenJnlPoT@1560060 | The procedure AdvPmtApplyBiggerInvGenJnlPoT is available in codeunit 143005.
AdvPmtApplyBiggerInvSplit@1500054 | The procedure AdvPmtApplyBiggerInvSplit is available in codeunit 143005.
AdvPmtApplyBigInvGenJnlRevChrg@1500103 | The procedure AdvPmtApplyBigInvGenJnlRevChrg is available in codeunit 143005.
AdvPmtApplyInvDocSplit@1500055 | The procedure AdvPmtApplyInvDocSplit is available in codeunit 143005.
AdvPmtApplyInvGenJnl@1500063 | The procedure AdvPmtApplyInvGenJnl is available in codeunit 143005.
ApplyAndPostBiggerInvGenJnl@1500061 | The procedure ApplyAndPostBiggerInvGenJnl is available in codeunit 143005.
ApplyAndPostInvoiceDoc@1500057 | The procedure ApplyAndPostInvoiceDoc is available in codeunit 143005.
ApplyAndPostInvoiceGenJnl@1500065 | The procedure ApplyAndPostInvoiceGenJnl is available in codeunit 143005.
ApplyAndPostPayment@1500040 | The procedure ApplyAndPostPayment is available in codeunit 143005.
CalcPaymentAmount@1500083 | The procedure CalcPaymentAmount is available in codeunit 143005.
CalcTDSAmounts@1500022 | The procedure CalcTDSAmounts is available in codeunit 143005.
ConvertDocToJnlLine@1500021 | The procedure ConvertDocToJnlLine is available in codeunit 143005.
CreateAdvPmt@1500050 | The procedure CreateAdvPmt is available in codeunit 143005.
CreateAdvPmtPoT@1500045 | The procedure CreateAdvPmtPoT is available in codeunit 143005.
CreateAdvPmtRevChrg@1500051 | The procedure CreateAdvPmtRevChrg is available in codeunit 143005.
CreateAdvPmtSplit@1500060 | The procedure CreateAdvPmtSplit is available in codeunit 143005.
CreateAdvRefundPoT@1500046 | The procedure CreateAdvRefundPoT is available in codeunit 143005.
CreateCrMemoDocPoT@1500016 | The procedure CreateCrMemoDocPoT is available in codeunit 143005.
CreateCrMemoGenJnlPoT@1500029 | The procedure CreateCrMemoGenJnlPoT is available in codeunit 143005.
CreateDeductoryCodeAndUpdateOnCompanyInformation@1500150 | The procedure CreateDeductoryCodeAndUpdateOnCompanyInformation is available in codeunit 143005.
CreateGenJnlForVendor@1500013 | The procedure CreateGenJnlForVendor is available in codeunit 143005.
CreateInvoiceFromGenJournal@1500067 | The procedure CreateInvoiceFromGenJournal is available in codeunit 143005.
CreateNODNOCSetup@3 | The procedure CreateNODNOCSetup is available in codeunit 143005.
CreatePurchaseDocGenJnlPoT@1500012 | The procedure CreatePurchaseDocGenJnlPoT is available in codeunit 143005.
CreatePurchaseDocGenJnlRevChrg@1500006 | The procedure CreatePurchaseDocGenJnlRevChrg is available in codeunit 143005.
CreatePurchaseDocGenJnlSplit@1500027 | The procedure CreatePurchaseDocGenJnlSplit is available in codeunit 143005.
CreatePurchaseDocPoT@1500003 | The procedure CreatePurchaseDocPoT is available in codeunit 143005.
CreatePurchaseDocRevChrg@1500005 | The procedure CreatePurchaseDocRevChrg is available in codeunit 143005.
CreatePurchaseDocSplit@1500028 | The procedure CreatePurchaseDocSplit is available in codeunit 143005.
CreateVendorWithPANNo@1500058 | The procedure CreateVendorWithPANNo is available in codeunit 143005.
GetBiggerAmount@1500076 | The procedure GetBiggerAmount is available in codeunit 143005.
InvDocPoT@1500018 | The procedure InvDocPoT is available in codeunit 143005.
InvDocPoTAppliesToPmt@1500075 | The procedure InvDocPoTAppliesToPmt is available in codeunit 143005.
InvDocRevChrg@1500033 | The procedure InvDocRevChrg is available in codeunit 143005.
InvDocSplit@1500037 | The procedure InvDocSplit is available in codeunit 143005.
InvDocSplitGenJnl@1500044 | The procedure InvDocSplitGenJnl is available in codeunit 143005.
InvGenJnlPoT@1500032 | The procedure InvGenJnlPoT is available in codeunit 143005.
InvGenJnlPoTAppliesToPmt@1500104 | The procedure InvGenJnlPoTAppliesToPmt is available in codeunit 143005.
InvGenJnlRevChrg@1500034 | The procedure InvGenJnlRevChrg is available in codeunit 143005.
InvGenJnlSplit@1500038 | The procedure InvGenJnlSplit is available in codeunit 143005.
OfflineAppSplit@1500049 | The procedure OfflineAppSplit is available in codeunit 143005.
PostAdvPaymentPoT@1500071 | The procedure PostAdvPaymentPoT is available in codeunit 143005.
PostInvAppliesToAdvPmtPoT@1500069 | The procedure PostInvAppliesToAdvPmtPoT is available in codeunit 143005.
PostInvoiceGenJnl@1500056 | The procedure PostInvoiceGenJnl is available in codeunit 143005.
PostPayment@1500082 | The procedure PostPayment is available in codeunit 143005.
RemoveTDSFromGenJournal@1500026 | The procedure RemoveTDSFromGenJournal is available in codeunit 143005.
RemoveWorkTaxFromGenJournal@1500025 | The procedure RemoveWorkTaxFromGenJournal is available in codeunit 143005.
SetTDSTaxType@1500002 | The procedure SetTDSTaxType is available in codeunit 143005.
SetupIncomeTaxAccountingPeriod@1500004 | The procedure SetupIncomeTaxAccountingPeriod is available in codeunit 143005.
UpdateInclServTaxOption@1500009 | The procedure UpdateInclServTaxOption is available in codeunit 143005.
UseTDSTax@1500007 | The procedure UseTDSTax is available in codeunit 143005.
UseWorkTax@1500008 | The procedure UseWorkTax is available in codeunit 143005.
VerifyNoTDSOnAppliedInvoice@1500079 | The procedure VerifyNoTDSOnAppliedInvoice is available in codeunit 143005.
VerifyPostingAppliedBigInv@1500068 | The procedure VerifyPostingAppliedBigInv is available in codeunit 143005.
VerifyServTaxRevChrg@1500039 | The procedure VerifyServTaxRevChrg is available in codeunit 143005.
VerifyServTaxSplit@1500035 | The procedure VerifyServTaxSplit is available in codeunit 143005.
VerifyServTaxSplitAdvPmt@1500059 | The procedure VerifyServTaxSplitAdvPmt is available in codeunit 143005.
VerifySTBaseIsTDSBase@1500048 | The procedure VerifySTBaseIsTDSBase is available in codeunit 143005.
VerifySTBaseIsTDSBaseRounding@1500077 | The procedure VerifySTBaseIsTDSBaseRounding is available in codeunit 143005.
VerifySTEntryDetail@1500031 | The procedure VerifySTEntryDetail is available in codeunit 143005.
VerifyTDSEntry@1500078 | The procedure VerifyTDSEntry is available in codeunit 143005.
VerifyTDSEntryFromBase@1500053 | The procedure VerifyTDSEntryFromBase is available in codeunit 143005.
VerifyTDSPostingAdvPmt@1500041 | The procedure VerifyTDSPostingAdvPmt is available in codeunit 143005.
VerifyTDSPostingAppliedBigInv@1500072 | The procedure VerifyTDSPostingAppliedBigInv is available in codeunit 143005.
VerifyTDSPostingAppliedInvoice@1500064 | The procedure VerifyTDSPostingAppliedInvoice is available in codeunit 143005.
VerifyTDSPostingBigInv@1500073 | The procedure VerifyTDSPostingBigInv is available in codeunit 143005.
VerifyTDSPostingBigInvRounding@1500070 | The procedure VerifyTDSPostingBigInvRounding is available in codeunit 143005.
VerifyTDSPostingInvoice@1500000 | The procedure VerifyTDSPostingInvoice is available in codeunit 143005.
VerifyWTaxPostingAppliedBigInv@1500024 | The procedure VerifyWTaxPostingAppliedBigInv is available in codeunit 143005.

See Also

Miscellaneous


AddLineToNODNOCSetup@1500088 Method

The procedure AddLineToNODNOCSetup is available in codeunit 143005.

Syntax

AddLineToNODNOCSetup@1500088(
    VAR NODNOCHeader@1040 : Record 13786 NODNOCHeader, //Reference parameter of type Record
    CodeContractor@1044 : Code[10] CodeContractor //Input parameter of type Code
);

Parameters

NODNOCHeader
Reference parameter of type Record
CodeContractor
Input parameter of type Code

Remarks

The relevant search keywords are: Add, Line, To, NODNOC, Setup.

For a clarification about how this function works, refer to the code listed below.

      LibraryTDS.CreateNODNOCLines(NODNOCLines,NODNOCHeader,CodeContractor,TRUE,'',0);

Example

There are no examples available.
Member of Miscellaneous.Service Tax With TDS Helper


AddPoTToAdvPmtAmount@1500095 Method

The procedure AddPoTToAdvPmtAmount is available in codeunit 143005.

Syntax

AddPoTToAdvPmtAmount@1500095(
    VAR GenJournalLine@1500000 : Record 81 GenJournalLine //Reference parameter of type Record
);

Parameters

GenJournalLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Add, Po, T, To, Adv, Payment, Amount.

For a clarification about how this function works, refer to the code listed below.

      GenJournalLine.VALIDATE(Amount,GenJournalLine.Amount + CalcPoTForAdvPmt(GenJournalLine));
      GenJournalLine.MODIFY;

Example

There are no examples available.
Member of Miscellaneous.Service Tax With TDS Helper


AdvPaymentPoT@1500042 Method

The procedure AdvPaymentPoT is available in codeunit 143005.

Syntax

AdvPaymentPoT@1500042(
    IncludeServTax@1500004 : Boolean IncludeServTax //Input parameter of type Boolean
);

Parameters

IncludeServTax
Input parameter of type Boolean

Remarks

The relevant search keywords are: Adv, Payment, PoT.

For a clarification about how this function works, refer to the code listed below.

      // Setup
      CreateAdvPmtPoT(GenJournalLine);
      LibraryTDS.SetInclServTaxOptionInGenJnl(GenJournalLine,IncludeServTax);

      // Exercise
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // Verify
      VerifyTDSPostingAdvPmt(GenJournalLine,IncludeServTax);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;
      ServiceTaxTDSHelper.AdvPaymentPoT(FALSE);
Member of Miscellaneous.Service Tax With TDS Helper


AdvPaymentRevChrg@1500047 Method

The procedure AdvPaymentRevChrg is available in codeunit 143005.

Syntax

AdvPaymentRevChrg@1500047(
    IncludeServTax@1500004 : Boolean IncludeServTax //Input parameter of type Boolean
);

Parameters

IncludeServTax
Input parameter of type Boolean

Remarks

The relevant search keywords are: Adv, Payment, Rev, Chrg.

For a clarification about how this function works, refer to the code listed below.

      // Setup
      CreateAdvPmtRevChrg(GenJournalLine);
      LibraryTDS.SetInclServTaxOptionInGenJnl(GenJournalLine,IncludeServTax);

      // Exercise
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // Verify
      VerifyTDSPostingAdvPmt(GenJournalLine,FALSE);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;
      ServiceTaxTDSHelper.AdvPaymentRevChrg(FALSE);
Member of Miscellaneous.Service Tax With TDS Helper


AdvPaymentSplit@1500052 Method

The procedure AdvPaymentSplit is available in codeunit 143005.

Syntax

AdvPaymentSplit@1500052(
    IncludeServTax@1500004 : Boolean IncludeServTax //Input parameter of type Boolean
);

Parameters

IncludeServTax
Input parameter of type Boolean

Remarks

The relevant search keywords are: Adv, Payment, Split.

For a clarification about how this function works, refer to the code listed below.

      // Setup
      CreateAdvPmtSplit(GenJournalLine);
      GenJournalLine.VALIDATE(Amount,LibraryRandom.RandDec(100000,2));
      LibraryTDS.SetInclServTaxOptionInGenJnl(GenJournalLine,IncludeServTax);

      // Exercise
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // Verify
      VerifyServTaxSplitAdvPmt(GenJournalLine);
      VerifyTDSPostingAdvPmt(GenJournalLine,IncludeServTax);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;
      ServiceTaxTDSHelper.AdvPaymentSplit(FALSE);
Member of Miscellaneous.Service Tax With TDS Helper


AdvPmtApplyBiggerInvDocPoT@1500085 Method

The procedure AdvPmtApplyBiggerInvDocPoT is available in codeunit 143005.

Syntax

AdvPmtApplyBiggerInvDocPoT@1500085(
      //param element not supplied
);

Remarks

The relevant search keywords are: Adv, Payment, Apply, Bigger, Invoice, Document, PoT.

For a clarification about how this function works, refer to the code listed below.

      // Setup
      CreateAdvPmtPoT(GenJournalLine);
      LibraryTDS.SetInclServTaxOptionInGenJnl(GenJournalLine,TRUE);

      LibraryERM.PostGeneralJnlLine(GenJournalLine);
      PmtGenJournalLine := GenJournalLine;
      // Exercise
      GenJournalLine.Amount := GetBiggerAmount(GenJournalLine.Amount);
      ApplyAndPostInvoiceDoc(GenJournalLine);

      // Verify
      ServiceTaxVerify.AppliedDocServiceTax(PmtGenJournalLine,GenJournalLine,FALSE);
      IF UseTDSTax THEN
        VerifyTDSPostingAppliedBigInv(GenJournalLine,PmtGenJournalLine,TRUE);
      IF UseWorkTax THEN
        VerifyWTaxPostingAppliedBigInv(GenJournalLine,PmtGenJournalLine,TRUE);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;
      ServiceTaxTDSHelper.AdvPmtApplyBiggerInvDocPoT;
Member of Miscellaneous.Service Tax With TDS Helper


AdvPmtApplyBiggerInvDocPoTFcy@1500043 Method

The procedure AdvPmtApplyBiggerInvDocPoTFcy is available in codeunit 143005.

Syntax

AdvPmtApplyBiggerInvDocPoTFcy@1500043(
    VAR GenJournalLine@1500001 : Record 81 GenJournalLine, //Reference parameter of type Record
    VAR PmtGenJournalLine@1500000 : Record 81 PmtGenJournalLine //Reference parameter of type Record
);

Parameters

GenJournalLine
Reference parameter of type Record
PmtGenJournalLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Adv, Payment, Apply, Bigger, Invoice, Document, Po, T, Fcy.

For a clarification about how this function works, refer to the code listed below.

      // Setup
      CreateAdvPmtPoT(GenJournalLine);
      LibraryTDS.SetInclServTaxOptionInGenJnl(GenJournalLine,TRUE);
      ServiceTaxFCYHelper.SetFCYNonResPmtOnJnlLine(GenJournalLine);

      LibraryERM.PostGeneralJnlLine(GenJournalLine);
      PmtGenJournalLine := GenJournalLine;
      // Exercise
      GenJournalLine.Amount := GetBiggerAmount(GenJournalLine.Amount);
      ApplyAndPostInvoiceDoc(GenJournalLine);

      // Restore
      ServiceTaxFCYHelper.SetNonResidentPmtOnTDSGroup(GenJournalLine,FALSE);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;
      ServiceTaxTDSHelper.AdvPmtApplyBiggerInvDocPoTFcy(GenJournalLine,PmtGenJournalLine);

      // Verify
      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      GenJournalLine.Amount += ReverseServiceTaxHelper.CalculateServTaxTotal(GenJournalLine.Amount,ServiceTaxSetup) +
        ReverseServiceTaxHelper.CalculateKKCess(GenJournalLine.Amount,ServiceTaxSetup) +
        ReverseServiceTaxHelper.CalculateSBC(GenJournalLine.Amount,ServiceTaxSetup);
      GenJournalLine.Amount :=
        ServiceTaxFCYHelper.ConvertFCYAmountToLCY(GenJournalLine) - ServiceTaxFCYHelper.ConvertFCYAmountToLCY(PmtGenJournalLine);
      ServiceTaxTDSHelper.VerifyTDSEntryFromBase(GenJournalLine);
Member of Miscellaneous.Service Tax With TDS Helper


AdvPmtApplyBiggerInvDocRevChrg@1500099 Method

The procedure AdvPmtApplyBiggerInvDocRevChrg is available in codeunit 143005.

Syntax

AdvPmtApplyBiggerInvDocRevChrg@1500099(
      //param element not supplied
);

Remarks

The relevant search keywords are: Adv, Payment, Apply, Bigger, Invoice, Document, Rev, Chrg.

For a clarification about how this function works, refer to the code listed below.

      // Setup
      CreateAdvPmtRevChrg(GenJournalLine);
      LibraryTDS.SetInclServTaxOptionInGenJnl(GenJournalLine,TRUE);
      LibraryERM.PostGeneralJnlLine(GenJournalLine);
      PmtGenJournalLine := GenJournalLine;

      // Exercise
      GenJournalLine.Amount := GetBiggerAmount(GenJournalLine.Amount);
      ApplyAndPostInvoiceDoc(GenJournalLine);

      // Verify
      ServiceTaxVerify.AppliedDocServiceTax(PmtGenJournalLine,GenJournalLine,FALSE);
      IF UseTDSTax THEN
        VerifyTDSPostingAppliedBigInv(GenJournalLine,PmtGenJournalLine,FALSE);
      IF UseWorkTax THEN
        VerifyWTaxPostingAppliedBigInv(GenJournalLine,PmtGenJournalLine,FALSE);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;
      ServiceTaxTDSHelper.AdvPmtApplyBiggerInvDocRevChrg;
Member of Miscellaneous.Service Tax With TDS Helper


AdvPmtApplyBiggerInvGenJnlPoT@1560060 Method

The procedure AdvPmtApplyBiggerInvGenJnlPoT is available in codeunit 143005.

Syntax

AdvPmtApplyBiggerInvGenJnlPoT@1560060(
    TDSBaseInclServTax@1500001 : Boolean TDSBaseInclServTax //Input parameter of type Boolean
);

Parameters

TDSBaseInclServTax
Input parameter of type Boolean

Remarks

The relevant search keywords are: Adv, Payment, Apply, Bigger, Invoice, General, Journal, PoT.

For a clarification about how this function works, refer to the code listed below.

      // Exercise
      PostInvAppliesToAdvPmtPoT(GenJournalLine,PmtGenJournalLine,TDSBaseInclServTax);

      // Verify
      VerifyPostingAppliedBigInv(GenJournalLine,PmtGenJournalLine,TDSBaseInclServTax);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;
      ServiceTaxTDSHelper.AdvPmtApplyBiggerInvGenJnlPoT(FALSE);
Member of Miscellaneous.Service Tax With TDS Helper


AdvPmtApplyBiggerInvSplit@1500054 Method

The procedure AdvPmtApplyBiggerInvSplit is available in codeunit 143005.

Syntax

AdvPmtApplyBiggerInvSplit@1500054(
    IncludeServiceTaxInTDSBase@1500001 : Boolean IncludeServiceTaxInTDSBase //Input parameter of type Boolean
);

Parameters

IncludeServiceTaxInTDSBase
Input parameter of type Boolean

Remarks

The relevant search keywords are: Adv, Payment, Apply, Bigger, Invoice, Split.

For a clarification about how this function works, refer to the code listed below.

      // Setup
      CreateAdvPmtSplit(GenJournalLine);
      GenJournalLine.VALIDATE(Amount,LibraryRandom.RandDec(20000,2));
      LibraryTDS.SetInclServTaxOptionInGenJnl(GenJournalLine,IncludeServiceTaxInTDSBase);
      LibraryERM.PostGeneralJnlLine(GenJournalLine);
      PmtGenJournalLine := GenJournalLine;

      // Exercise
      GenJournalLine.Amount := GetBiggerAmount(GenJournalLine.Amount);
      ApplyAndPostInvoiceDoc(GenJournalLine);

      // Verify
      ServiceTaxVerify.AppliedDocServiceTax(PmtGenJournalLine,GenJournalLine,FALSE);

      IF UseTDSTax THEN
        VerifyTDSPostingAppliedBigInv(GenJournalLine,PmtGenJournalLine,IncludeServiceTaxInTDSBase);
      IF UseWorkTax THEN
        VerifyWTaxPostingAppliedBigInv(GenJournalLine,PmtGenJournalLine,IncludeServiceTaxInTDSBase);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;
      ServiceTaxTDSHelper.AdvPmtApplyBiggerInvSplit(FALSE);
Member of Miscellaneous.Service Tax With TDS Helper


AdvPmtApplyBigInvGenJnlRevChrg@1500103 Method

The procedure AdvPmtApplyBigInvGenJnlRevChrg is available in codeunit 143005.

Syntax

AdvPmtApplyBigInvGenJnlRevChrg@1500103(
      //param element not supplied
);

Remarks

The relevant search keywords are: Adv, Payment, Apply, Big, Invoice, General, Journal, Rev, Chrg.

For a clarification about how this function works, refer to the code listed below.

      // Setup
      LibraryServiceTax.SetServiceTaxRounding;
      CreateAdvPmtRevChrg(GenJournalLine);
      LibraryTDS.SetInclServTaxOptionInGenJnl(GenJournalLine,TRUE);
      PmtGenJournalLine := GenJournalLine;
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // Exercise
      ApplyAndPostBiggerInvGenJnl(GenJournalLine);

      // Verify
      ServiceTaxVerify.AppliedDocServiceTax(PmtGenJournalLine,GenJournalLine,FALSE);
      IF UseTDSTax THEN
        VerifyTDSPostingAppliedBigInv(GenJournalLine,PmtGenJournalLine,FALSE);
      IF UseWorkTax THEN
        VerifyWTaxPostingAppliedBigInv(GenJournalLine,PmtGenJournalLine,FALSE);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;
      ServiceTaxTDSHelper.AdvPmtApplyBigInvGenJnlRevChrg;
Member of Miscellaneous.Service Tax With TDS Helper


AdvPmtApplyInvDocSplit@1500055 Method

The procedure AdvPmtApplyInvDocSplit is available in codeunit 143005.

Syntax

AdvPmtApplyInvDocSplit@1500055(
    IncludeServiceTaxInTDSBase@1500000 : Boolean IncludeServiceTaxInTDSBase //Input parameter of type Boolean
);

Parameters

IncludeServiceTaxInTDSBase
Input parameter of type Boolean

Remarks

The relevant search keywords are: Adv, Payment, Apply, Invoice, Document, Split.

For a clarification about how this function works, refer to the code listed below.

      // Setup
      CreateAdvPmtSplit(AdvPmtGenJnlLine);
      LibraryTDS.SetInclServTaxOptionInGenJnl(AdvPmtGenJnlLine,IncludeServiceTaxInTDSBase);
      LibraryERM.PostGeneralJnlLine(AdvPmtGenJnlLine);

      // Exercise
      InvoiceGenJnlLine := AdvPmtGenJnlLine;
      ApplyAndPostInvoiceDoc(InvoiceGenJnlLine);

      // Verify
      ServiceTaxVerify.AppliedDocServiceTax(AdvPmtGenJnlLine,InvoiceGenJnlLine,FALSE);
      VerifyTDSPostingAppliedInvoice(InvoiceGenJnlLine,IncludeServiceTaxInTDSBase);
      VerifyServTaxSplit(InvoiceGenJnlLine);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;
      ServiceTaxTDSHelper.AdvPmtApplyInvDocSplit(FALSE);
Member of Miscellaneous.Service Tax With TDS Helper


AdvPmtApplyInvGenJnl@1500063 Method

The procedure AdvPmtApplyInvGenJnl is available in codeunit 143005.

Syntax

AdvPmtApplyInvGenJnl@1500063(
    PoT@1500001 : Boolean PoT, //Input parameter of type Boolean
    RevCharge@1500002 : Boolean RevCharge //Input parameter of type Boolean
);

Parameters

PoT
Input parameter of type Boolean
RevCharge
Input parameter of type Boolean

Remarks

The relevant search keywords are: Adv, Payment, Apply, Invoice, General, Journal.

For a clarification about how this function works, refer to the code listed below.

      VerifyParameterIntegrity(PoT,RevCharge);
      // Setup
      IF PoT THEN
        CreateAdvPmtPoT(AdvPmtGenJnlLine);
      IF RevCharge THEN
        CreateAdvPmtRevChrg(AdvPmtGenJnlLine);

      LibraryTDS.SetInclServTaxOptionInGenJnl(AdvPmtGenJnlLine,TRUE);
      LibraryERM.PostGeneralJnlLine(AdvPmtGenJnlLine);

      // Exercise
      InvoiceGenJnlLine := AdvPmtGenJnlLine;
      ApplyAndPostInvoiceGenJnl(InvoiceGenJnlLine);

      // Verify
      ServiceTaxVerify.AppliedDocServiceTax(AdvPmtGenJnlLine,InvoiceGenJnlLine,FALSE);
      IF RevCharge THEN
        VerifyTDSPostingAppliedInvoice(InvoiceGenJnlLine,FALSE)
      ELSE
        VerifyTDSPostingAppliedInvoice(InvoiceGenJnlLine,TRUE);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;
      ServiceTaxTDSHelper.AdvPmtApplyInvGenJnl(TRUE,FALSE);
Member of Miscellaneous.Service Tax With TDS Helper


ApplyAndPostBiggerInvGenJnl@1500061 Method

The procedure ApplyAndPostBiggerInvGenJnl is available in codeunit 143005.

Syntax

ApplyAndPostBiggerInvGenJnl@1500061(
    VAR GenJournalLine@1500000 : Record 81 GenJournalLine //Reference parameter of type Record
);

Parameters

GenJournalLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Apply, Post, Bigger, Invoice, General, Journal.

For a clarification about how this function works, refer to the code listed below.

      CreateInvoiceFromGenJournal(GenJournalLine);
      GenJournalLine.VALIDATE(Amount,GetBiggerAmount(GenJournalLine.Amount));
      GenJournalLine.MODIFY;
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

Example

There are no examples available.
Member of Miscellaneous.Service Tax With TDS Helper


ApplyAndPostInvoiceDoc@1500057 Method

The procedure ApplyAndPostInvoiceDoc is available in codeunit 143005.

Syntax

ApplyAndPostInvoiceDoc@1500057(
    VAR GenJournalLine@1500000 : Record 81 GenJournalLine //Reference parameter of type Record
);

Parameters

GenJournalLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Apply, Post, Invoice, Document.

For a clarification about how this function works, refer to the code listed below.

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      ServiceTaxType := ReverseServiceTaxHelper.GetServTaxType(
          GenJournalLine."Service Tax Group Code",GenJournalLine."Account No.",GenJournalLine."Service Tax Registration No.");
      BaseAmount := ReverseServiceTaxHelper.GetBaseAmountFromGenJnlLine(GenJournalLine);

      ReverseServiceTaxHelper.CreateDocAndApplyAdvPayment(PurchaseHeader,PurchaseLine,GenJournalLine,
        PurchaseHeader."Document Type"::Invoice,ServiceTaxType,
        ReverseServiceTaxHelper.GetRevChrgPercent(GenJournalLine),GenJournalLine.PoT,BaseAmount);

      ValidatePurchLineNOD(PurchaseLine,GenJournalLine."TDS Nature of Deduction",GenJournalLine."Work Tax Nature Of Deduction");

      UpdateInclServTaxOption(PurchaseHeader,GenJournalLine."Include Serv. Tax in TDS Base");

      InvoiceDocumentNo := ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);
      ConvertDocToJnlLine(
        PurchaseHeader,PurchaseLine,InvoiceDocumentNo,GenJournalLine);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;

      // Setup
      ServiceTaxTDSHelper.CreateAdvPmt(GenJournalLine,0,ReverseChargeTypeOption::" ",FALSE);
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // Exercise
      ServiceTaxTDSHelper.ApplyAndPostInvoiceDoc(GenJournalLine);

      // Verify
      ServiceTaxTDSHelper.VerifyTDSPostingAppliedInvoice(GenJournalLine,FALSE);
Member of Miscellaneous.Service Tax With TDS Helper


ApplyAndPostInvoiceGenJnl@1500065 Method

The procedure ApplyAndPostInvoiceGenJnl is available in codeunit 143005.

Syntax

ApplyAndPostInvoiceGenJnl@1500065(
    VAR GenJournalLine@1500000 : Record 81 GenJournalLine //Reference parameter of type Record
);

Parameters

GenJournalLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Apply, Post, Invoice, General, Journal.

For a clarification about how this function works, refer to the code listed below.

      CreateInvoiceFromGenJournal(GenJournalLine);
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;

      // Setup
      ServiceTaxTDSHelper.CreateAdvPmtPoT(GenJournalLine);
      LibraryTDS.SetInclServTaxOptionInGenJnl(GenJournalLine,TRUE);
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // Exercise
      ServiceTaxTDSHelper.RemoveTDSFromGenJournal(GenJournalLine,FALSE);
      ASSERTERROR ServiceTaxTDSHelper.ApplyAndPostInvoiceGenJnl(GenJournalLine);

      // Verify
      Assert.ExpectedError(DiffTDSOnAppliedDocsErr);
Member of Miscellaneous.Service Tax With TDS Helper


ApplyAndPostPayment@1500040 Method

The procedure ApplyAndPostPayment is available in codeunit 143005.

Syntax

ApplyAndPostPayment@1500040(
    GenJournalLine@1500000 : Record 81 GenJournalLine, //Input parameter of type Record
    PaymentAmount@1500001 : Decimal PaymentAmount //Input parameter of type Decimal
);

Parameters

GenJournalLine
Input parameter of type Record
PaymentAmount
Input parameter of type Decimal

Return Value

Code[20]

Remarks

The relevant search keywords are: Apply, Post, Payment.

For a clarification about how this function works, refer to the code listed below.

      ReverseServiceTaxHelper.CreatePaymentWithOnlineAppl(
        GenJournalLine,ReverseServiceTaxHelper.GetApplyingDocType(GenJournalLine."Document Type"),PaymentAmount);
      LibraryERM.PostGeneralJnlLine(GenJournalLine);
      EXIT(GenJournalLine."Document No.");

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;

      // Setup
      ServiceTaxTDSHelper.CreatePurchaseDocGenJnlRevChrg(GenJournalLine);
      LibraryTDS.SetInclServTaxOptionInGenJnl(GenJournalLine,TRUE);

      // Exercise
      LibraryERM.PostGeneralJnlLine(GenJournalLine);
      PaymentDocNo :=
        ServiceTaxTDSHelper.ApplyAndPostPayment(GenJournalLine,ServiceTaxTDSHelper.CalcPaymentAmount(GenJournalLine,TRUE));

      // Verify
      ServiceTaxTDSHelper.VerifyServTaxRevChrg(GenJournalLine);
      ServiceTaxTDSHelper.VerifySTEntryDetail(GenJournalLine,PaymentDocNo,1);
      ServiceTaxTDSHelper.VerifySTBaseIsTDSBase(GenJournalLine."Document No.",TRUE,GenJournalLine.IsServTaxRevChrgSplit);
Member of Miscellaneous.Service Tax With TDS Helper


CalcPaymentAmount@1500083 Method

The procedure CalcPaymentAmount is available in codeunit 143005.

Syntax

CalcPaymentAmount@1500083(
    GenJournalLine@1500000 : Record 81 GenJournalLine, //Input parameter of type Record
    IncludeServTax@1500001 : Boolean IncludeServTax //Input parameter of type Boolean
);

Parameters

GenJournalLine
Input parameter of type Record
IncludeServTax
Input parameter of type Boolean

Return Value

Decimal

Remarks

The relevant search keywords are: Calc, Payment, Amount.

For a clarification about how this function works, refer to the code listed below.

      CalcTDSAmounts(ExpectedTDSAmounts,GenJournalLine,VendorLEAmount,IncludeServTax);
      EXIT(VendorLEAmount);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;

      // Setup
      ServiceTaxTDSHelper.CreatePurchaseDocGenJnlRevChrg(GenJournalLine);
      LibraryTDS.SetInclServTaxOptionInGenJnl(GenJournalLine,TRUE);

      // Exercise
      LibraryERM.PostGeneralJnlLine(GenJournalLine);
      PaymentDocNo :=
        ServiceTaxTDSHelper.ApplyAndPostPayment(GenJournalLine,ServiceTaxTDSHelper.CalcPaymentAmount(GenJournalLine,TRUE));

      // Verify
      ServiceTaxTDSHelper.VerifyServTaxRevChrg(GenJournalLine);
      ServiceTaxTDSHelper.VerifySTEntryDetail(GenJournalLine,PaymentDocNo,1);
      ServiceTaxTDSHelper.VerifySTBaseIsTDSBase(GenJournalLine."Document No.",TRUE,GenJournalLine.IsServTaxRevChrgSplit);
Member of Miscellaneous.Service Tax With TDS Helper


CalcTDSAmounts@1500022 Method

The procedure CalcTDSAmounts is available in codeunit 143005.

Syntax

CalcTDSAmounts@1500022(
    VAR ExpectedTDSAmounts@1500013 : Record 13729 ExpectedTDSAmounts, //Reference parameter of type Record
    GenJournalLine@1500000 : Record 81 GenJournalLine, //Input parameter of type Record
    VAR VendorLEAmount@1500007 : Decimal VendorLEAmount, //Reference parameter of type Decimal
    IncludeServTax@1500003 : Boolean IncludeServTax //Input parameter of type Boolean
);

Parameters

ExpectedTDSAmounts
Reference parameter of type Record
GenJournalLine
Input parameter of type Record
VendorLEAmount
Reference parameter of type Decimal
IncludeServTax
Input parameter of type Boolean

Remarks

The relevant search keywords are: Calc, TDS, Amounts.

For a clarification about how this function works, refer to the code listed below.

      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      ReverseServiceTaxHelper.CalcServTaxAmounts(GenJournalLine,ServTaxBase,PoTAmount,ServiceTaxSetup);

      WITH ExpectedTDSAmounts DO BEGIN
        TaxBaseAmount := ServTaxBase;
        IF IncludeServTax THEN
          TaxBaseAmount += PoTAmount;
        "Base Includes Service Tax" := IncludeServTax;

        CalcTDSAmountsFromBase(ExpectedTDSAmounts,GenJournalLine,TaxBaseAmount);

        VendorLEAmount := ServTaxBase + PoTAmount - "Total TDS Including SHE CESS" - "Work Tax Amount";
      END;

Example

There are no examples available.
Member of Miscellaneous.Service Tax With TDS Helper


ConvertDocToJnlLine@1500021 Method

The procedure ConvertDocToJnlLine is available in codeunit 143005.

Syntax

ConvertDocToJnlLine@1500021(
    PurchaseHeader@1500000 : Record 38 PurchaseHeader, //Input parameter of type Record
    PurchaseLine@1500002 : Record 39 PurchaseLine, //Input parameter of type Record
    PostedDocNo@1500003 : Code[20] PostedDocNo, //Input parameter of type Code
    VAR GenJnlLine@1500001 : Record 81 GenJnlLine //Reference parameter of type Record
);

Parameters

PurchaseHeader
Input parameter of type Record
PurchaseLine
Input parameter of type Record
PostedDocNo
Input parameter of type Code
GenJnlLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Convert, Document, To, Journal, Line.

For a clarification about how this function works, refer to the code listed below.

      ReverseServiceTaxHelper.ConvertDocToJnlLine(PurchaseHeader,PurchaseLine,PostedDocNo,GenJnlLine);
      WITH GenJnlLine DO BEGIN
        "Include Serv. Tax in TDS Base" := FindFirstInclSTaxOptInStruct(PurchaseHeader.Structure);
        "TDS Group" := PurchaseLine."TDS Group";
        "Work Tax Group" := PurchaseLine."Work Tax Group";
        "TDS Nature of Deduction" := PurchaseLine."TDS Nature of Deduction";
        "Work Tax Nature Of Deduction" := PurchaseLine."Work Tax Nature Of Deduction";
        "Assessee Code" := PurchaseLine."Assessee Code";
        "Concessional Code" := PurchaseLine."Concessional Code";
        "System-Created Entry" := TRUE; // marker for a converted doc
        "Posting Group" := PurchaseLine."Posting Group";
        "Currency Code" := PurchaseHeader."Currency Code";
        IF "Currency Code" <> '' THEN
          "Amount (LCY)" :=
            LibraryERM.ConvertCurrency(Amount,"Currency Code",'',"Posting Date");
      END;

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;

      // Setup
      ServiceTaxTDSHelper.CreatePurchaseDocPoT(PurchaseHeader,PurchaseLine,FALSE);
      ServiceTaxTDSHelper.UpdateInclServTaxOption(PurchaseHeader,TRUE);

      // Exercise
      PostedDocNo := ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);

      // Verify
      ServiceTaxTDSHelper.ConvertDocToJnlLine(PurchaseHeader,PurchaseLine,PostedDocNo,GenJournalLine);
      ServiceTaxTDSHelper.VerifyTDSPostingInvoice(GenJournalLine,TRUE);
Member of Miscellaneous.Service Tax With TDS Helper


CreateAdvPmt@1500050 Method

The procedure CreateAdvPmt is available in codeunit 143005.

Syntax

CreateAdvPmt@1500050(
    VAR GenJournalLine@1500003 : Record 81 GenJournalLine, //Reference parameter of type Record
    ReverseChargePercentage@1500006 : Integer ReverseChargePercentage, //Input parameter of type Integer
    ReverseChargeType@1500004 : Option ReverseChargeType, //Input parameter of type Option
    PoT@1500005 : Boolean PoT //Input parameter of type Boolean
);

Parameters

GenJournalLine
Reference parameter of type Record
ReverseChargePercentage
Input parameter of type Integer
ReverseChargeType
Input parameter of type Option
PoT
Input parameter of type Boolean

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Adv, Payment.

For a clarification about how this function works, refer to the code listed below.

      SetupTax(VendorNo,TDSNODCode,WorkTaxNODCode);
      CreateGenJnlForVendor(GenJournalLine,GenJournalLine."Document Type"::Payment,
        ReverseChargeType,PoT,ReverseChargePercentage,VendorNo);
      GenJournalLine.VALIDATE("Serv. Tax on Advance Payment",TRUE);
      ValidateGenJnlNOD(GenJournalLine,TDSNODCode,WorkTaxNODCode);
      AddPoTToAdvPmtAmount(GenJournalLine);
      EXIT(GenJournalLine."Document No.");

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;

      ServiceTaxTDSHelper.CreateAdvPmt(GenJournalLine,0,ReverseChargeTypeOption::" ",FALSE);

      // Exercise
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // Verify
      ServiceTaxTDSHelper.VerifyTDSPostingAdvPmt(GenJournalLine,FALSE);
Member of Miscellaneous.Service Tax With TDS Helper


CreateAdvPmtPoT@1500045 Method

The procedure CreateAdvPmtPoT is available in codeunit 143005.

Syntax

CreateAdvPmtPoT@1500045(
    VAR GenJournalLine@1500003 : Record 81 GenJournalLine //Reference parameter of type Record
);

Parameters

GenJournalLine
Reference parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Adv, Payment, PoT.

For a clarification about how this function works, refer to the code listed below.

      EXIT(CreateAdvPmt(GenJournalLine,0,ReverseChargeTypeOption::" ",TRUE));

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;

      // Setup
      ServiceTaxTDSHelper.CreateAdvPmtPoT(GenJournalLine);
      LibraryTDS.SetInclServTaxOptionInGenJnl(GenJournalLine,TRUE);
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // Exercise
      ServiceTaxTDSHelper.ApplyAndPostInvoiceDoc(GenJournalLine);

      // Verify
      ServiceTaxTDSHelper.VerifyTDSPostingAppliedInvoice(GenJournalLine,TRUE);
Member of Miscellaneous.Service Tax With TDS Helper


CreateAdvPmtRevChrg@1500051 Method

The procedure CreateAdvPmtRevChrg is available in codeunit 143005.

Syntax

CreateAdvPmtRevChrg@1500051(
    VAR GenJournalLine@1500003 : Record 81 GenJournalLine //Reference parameter of type Record
);

Parameters

GenJournalLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Adv, Payment, Rev, Chrg.

For a clarification about how this function works, refer to the code listed below.

      CreateAdvPmt(GenJournalLine,100,ReverseChargeTypeOption::Standard,FALSE);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;

      // Setup
      ServiceTaxTDSHelper.CreateAdvPmtRevChrg(GenJournalLine);
      LibraryTDS.SetInclServTaxOptionInGenJnl(GenJournalLine,TRUE);
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // Exercise
      ServiceTaxTDSHelper.ApplyAndPostInvoiceDoc(GenJournalLine);

      // Verify
      ServiceTaxTDSHelper.VerifyTDSPostingAppliedInvoice(GenJournalLine,FALSE);
Member of Miscellaneous.Service Tax With TDS Helper


CreateAdvPmtSplit@1500060 Method

The procedure CreateAdvPmtSplit is available in codeunit 143005.

Syntax

CreateAdvPmtSplit@1500060(
    VAR GenJournalLine@1500003 : Record 81 GenJournalLine //Reference parameter of type Record
);

Parameters

GenJournalLine
Reference parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Adv, Payment, Split.

For a clarification about how this function works, refer to the code listed below.

      EXIT(CreateAdvPmt(GenJournalLine,LibraryRandom.RandIntInRange(10,90),ReverseChargeTypeOption::Standard,TRUE));

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;

      // Setup
      ServiceTaxTDSHelper.CreateAdvPmtSplit(GenJournalLine);
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // Exercise
      GenJournalLine."Include Serv. Tax in TDS Base" := TRUE;
      ASSERTERROR ServiceTaxTDSHelper.ApplyAndPostInvoiceDoc(GenJournalLine);
      Assert.ExpectedError(DiffTDSBaseIncludesServTaxErr);
Member of Miscellaneous.Service Tax With TDS Helper


CreateAdvRefundPoT@1500046 Method

The procedure CreateAdvRefundPoT is available in codeunit 143005.

Syntax

CreateAdvRefundPoT@1500046(
    VAR GenJournalLine@1500003 : Record 81 GenJournalLine //Reference parameter of type Record
);

Parameters

GenJournalLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Adv, Refund, PoT.

For a clarification about how this function works, refer to the code listed below.

      SetupTax(VendorNo,TDSNODCode,WorkTaxNODCode);
      CreateGenJnlForVendor(GenJournalLine,GenJournalLine."Document Type"::Refund,
        ReverseChargeTypeOption::" ",TRUE,0,VendorNo);
      GenJournalLine.VALIDATE("Serv. Tax on Advance Payment",TRUE);
      ValidateGenJnlNOD(GenJournalLine,TDSNODCode,WorkTaxNODCode);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;

      // Setup
      ServiceTaxTDSHelper.CreateAdvRefundPoT(GenJournalLine);

      // Exercise
      ASSERTERROR LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // Verify
      Assert.ExpectedError(CrMemoJnlTDSErr);
Member of Miscellaneous.Service Tax With TDS Helper


CreateCrMemoDocPoT@1500016 Method

The procedure CreateCrMemoDocPoT is available in codeunit 143005.

Syntax

CreateCrMemoDocPoT@1500016(
    VAR PurchaseHeader@1500003 : Record 38 PurchaseHeader, //Reference parameter of type Record
    VAR PurchaseLine@1500002 : Record 39 PurchaseLine //Reference parameter of type Record
);

Parameters

PurchaseHeader
Reference parameter of type Record
PurchaseLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Crediteate, Credit, Memo, Document, PoT.

For a clarification about how this function works, refer to the code listed below.

      SetupTax(VendorNo,TDSNODCode,WorkTaxNODCode);
      ReverseServiceTaxHelper.CreatePurchaseDocForVendor(PurchaseHeader,PurchaseLine,VendorNo,
        PurchaseHeader."Document Type"::"Credit Memo",ReverseChargeTypeOption::" ",0,TRUE);
      ValidatePurchLineNOD(PurchaseLine,TDSNODCode,WorkTaxNODCode);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;

      // Setup
      ServiceTaxTDSHelper.CreateCrMemoDocPoT(PurchaseHeader,PurchaseLine);

      // Exercise
      ASSERTERROR ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);

      // Verify
      Assert.ExpectedError(CrMemoDocTDSErr);
Member of Miscellaneous.Service Tax With TDS Helper


CreateCrMemoGenJnlPoT@1500029 Method

The procedure CreateCrMemoGenJnlPoT is available in codeunit 143005.

Syntax

CreateCrMemoGenJnlPoT@1500029(
    VAR GenJournalLine@1500003 : Record 81 GenJournalLine //Reference parameter of type Record
);

Parameters

GenJournalLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Crediteate, Credit, Memo, General, Journal, PoT.

For a clarification about how this function works, refer to the code listed below.

      SetupTax(VendorNo,TDSNODCode,WorkTaxNODCode);
      CreateGenJnlForVendor(GenJournalLine,GenJournalLine."Document Type"::"Credit Memo",
        ReverseChargeTypeOption::" ",TRUE,0,VendorNo);
      ValidateGenJnlNOD(GenJournalLine,TDSNODCode,WorkTaxNODCode);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;

      // Setup
      ServiceTaxTDSHelper.CreateCrMemoGenJnlPoT(GenJournalLine);

      // Exercise
      ASSERTERROR LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // Verify
      Assert.ExpectedError(CrMemoJnlTDSErr);
Member of Miscellaneous.Service Tax With TDS Helper


CreateDeductoryCodeAndUpdateOnCompanyInformation@1500150 Method

The procedure CreateDeductoryCodeAndUpdateOnCompanyInformation is available in codeunit 143005.

Syntax

CreateDeductoryCodeAndUpdateOnCompanyInformation@1500150(
      //param element not supplied
);

Remarks

The relevant search keywords are: Create, Deductory, Code, Update, On, Company, Information.

For a clarification about how this function works, refer to the code listed below.

      CompanyInformation.GET;
      IF DeductorCategory.FINDFIRST THEN
        CompanyInformation.VALIDATE("Deductor Category",DeductorCategory.Code)
      ELSE BEGIN
        LibraryERM.CreateDeductorCategory(DeductorCategory);
        CompanyInformation.VALIDATE("Deductor Category",DeductorCategory.Code);
      END;
      CompanyInformation.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 144013 to show one way of using this function.

      LibrarySetupStorage.Restore;
      IF isInitialized THEN
        EXIT;
      GeneralLedgerSetup.GET;
      CompanyInformation.GET;
      LibraryTDS.CreateDeductoryCodeAndUpdateOnCompanyInformation(CompanyInformation);
      LibraryTDS.UpdateTDSNilChallanInGeneralLedgerSetup;
      LibraryTDS.CreateIncomeTaxAccPeriod(IncomeTaxAccountingPeriod);
      LibraryTDS.CreateIncomeTaxPeriod(IncomeTaxPeriodSetup,IncomeTaxAccountingPeriod."No.",1);
      LibraryTDS.CreateAssesseeandNODNOCSetup(
        NodNocHeader,TDSNatureOfDeduction,TDSSetup,'',ServiceTaxWithTDSHelper.CreateVendorWithPANNo,NodNocHeader.Type::Vendor,
        IncomeTaxAccountingPeriod."Starting Date");
      isInitialized := TRUE;
      COMMIT;
      LibrarySetupStorage.Save(DATABASE::"Company Information");
Member of Miscellaneous.Service Tax With TDS Helper


CreateGenJnlForVendor@1500013 Method

The procedure CreateGenJnlForVendor is available in codeunit 143005.

Syntax

CreateGenJnlForVendor@1500013(
    VAR GenJournalLine@1500004 : Record 81 GenJournalLine, //Reference parameter of type Record
    DocumentType@1500003 : Option DocumentType, //Input parameter of type Option
    ReverseChargeType@1500002 : Option ReverseChargeType, //Input parameter of type Option
    PoT@1500001 : Boolean PoT, //Input parameter of type Boolean
    Percentage@1500000 : Integer Percentage, //Input parameter of type Integer
    VendorNo@1500010 : Code[20] VendorNo //Input parameter of type Code
);

Parameters

GenJournalLine
Reference parameter of type Record
DocumentType
Input parameter of type Option
ReverseChargeType
Input parameter of type Option
PoT
Input parameter of type Boolean
Percentage
Input parameter of type Integer
VendorNo
Input parameter of type Code

Remarks

The relevant search keywords are: Create, General, Journal, For, Vendor.

For a clarification about how this function works, refer to the code listed below.

      ReverseServiceTaxHelper.CreateGenJournalBatch(GenJournalBatch);
      Amount := ReverseServiceTaxHelper.GetAmountSignInJournalLine(DocumentType) * LibraryRandom.RandDec(100000,2);
      LibraryServiceTax.CreateServiceTaxRegistrationNo(ServTaxRegNos);
      ReverseServiceTaxHelper.CreateServiceTaxGroupSetup(ServiceTaxGroup);
      ReverseServiceTaxHelper.GetServiceTaxReturnPeriod(ServiceTaxReturnPeriod);
      ReverseServiceTaxHelper.CreateJnlLineWithSTNoSetup(
        GenJournalLine,GenJournalBatch,DocumentType,
        ReverseServiceTaxHelper.GetReverseChargeServType(ReverseChargeType),VendorNo,Amount,
        LibraryServiceTax.GetDateWithinSrvTaxPeriod(ServiceTaxReturnPeriod),ServTaxRegNos.Code,ServiceTaxGroup.Code);
      ReverseServiceTaxHelper.CreateSTRevChrgSetupFromJnl(GenJournalLine,ReverseChargeType,Percentage);
      GenJournalLine.VALIDATE("Party Type",GenJournalLine."Party Type"::Vendor);
      GenJournalLine.VALIDATE("Party Code",VendorNo);
      GenJournalLine.VALIDATE(PoT,PoT);
      GenJournalLine.MODIFY(TRUE);

Example

There are no examples available.
Member of Miscellaneous.Service Tax With TDS Helper


CreateInvoiceFromGenJournal@1500067 Method

The procedure CreateInvoiceFromGenJournal is available in codeunit 143005.

Syntax

CreateInvoiceFromGenJournal@1500067(
    VAR GenJournalLine@1500000 : Record 81 GenJournalLine //Reference parameter of type Record
);

Parameters

GenJournalLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Invoice, From, General, Journal.

For a clarification about how this function works, refer to the code listed below.

      ReverseServiceTaxHelper.CreateGenJournalBatch(GenJournalBatch);
      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      ServiceTaxType :=
        ReverseServiceTaxHelper.GetServTaxType(
          GenJournalLine."Service Tax Group Code",GenJournalLine."Account No.",GenJournalLine."Service Tax Registration No.");
      BaseAmount :=
        ReverseServiceTaxHelper.GetBaseAmountFromAdvPayment(ABS(GenJournalLine.Amount),
          ReverseServiceTaxHelper.GetRevChrgPercent(GenJournalLine),ServiceTaxType,ServiceTaxSetup);
      WITH GenJournalLine DO BEGIN
        ReverseServiceTaxHelper.CreateJnlLineWithSTNoSetup(GenJournalLine2,GenJournalBatch,"Document Type"::Invoice,
          "Service Type (Rev. Chrg.)","Account No.",-BaseAmount,"Posting Date","Service Tax Registration No.",
          "Service Tax Group Code");
        GenJournalLine2.VALIDATE("Party Type","Party Type"::Vendor);
        GenJournalLine2.VALIDATE("Party Code","Account No.");
        GenJournalLine2.VALIDATE(PoT,PoT);
        GenJournalLine2.VALIDATE("Applies-to Doc. Type","Document Type");
        GenJournalLine2.VALIDATE("Applies-to Doc. No.","Document No.");
        GenJournalLine2.VALIDATE("TDS Nature of Deduction","TDS Nature of Deduction");
        GenJournalLine2.VALIDATE("Work Tax Nature Of Deduction","Work Tax Nature Of Deduction");
        GenJournalLine2.VALIDATE("Include Serv. Tax in TDS Base","Include Serv. Tax in TDS Base");
        GenJournalLine2.VALIDATE("Currency Code","Currency Code");
      END;
      GenJournalLine2.MODIFY(TRUE);
      GenJournalLine := GenJournalLine2;

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      // Setup
      LastTransactionNo := Initialize;

      // Advance Payment
      PostAdvancePaymentPoTFCY(GenJournalLine,IncludeServTax);

      // Invoice
      ServiceTaxTDSHelper.CreateInvoiceFromGenJournal(GenJournalLine);
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // Restore
      ServiceTaxFCYHelper.SetNonResidentPmtOnTDSGroup(GenJournalLine,FALSE);

      // Verify
      ServiceTaxFCYHelper.VerifyServTaxAdvPmtBalRounding(GenJournalLine,LastTransactionNo,TRUE);
      GenJournalLine.Amount := ServiceTaxFCYHelper.ConvertFCYAmountToLCY(GenJournalLine);
      ServiceTaxTDSHelper.VerifyTDSPostingAppliedInvoice(GenJournalLine,IncludeServTax);
Member of Miscellaneous.Service Tax With TDS Helper


CreateNODNOCSetup@3 Method

The procedure CreateNODNOCSetup is available in codeunit 143005.

Syntax

CreateNODNOCSetup@3(
    VAR NODNOCHeader@1040 : Record 13786 NODNOCHeader, //Reference parameter of type Record
    Type@1041 : Option Type, //Input parameter of type Option
    No@1042 : Code[20] No, //Input parameter of type Code
    AssesseeCode@1043 : Code[10] AssesseeCode, //Input parameter of type Code
    CodeContractor@1044 : Code[10] CodeContractor //Input parameter of type Code
);

Parameters

NODNOCHeader
Reference parameter of type Record
Type
Input parameter of type Option
No
Input parameter of type Code
AssesseeCode
Input parameter of type Code
CodeContractor
Input parameter of type Code

Remarks

The relevant search keywords are: Create, NODNOC, Setup.

For a clarification about how this function works, refer to the code listed below.

      LibraryTDS.CreateNODNOCHeader(NODNOCHeader,Type,No,AssesseeCode);
      LibraryTDS.CreateNODNOCLines(NODNOCLines,NODNOCHeader,CodeContractor,TRUE,'',0);

Example

The below example is extracted from the test automation codeunit 144060 to show one way of using this function.

      Initialize;
      GLSetup.VALIDATE("TCS Rounding Precision",1);
      GLSetup.VALIDATE("TCS Rounding Type",RoundingType);
      GLSetup.MODIFY(TRUE);
      LibraryTCS.CreateIncomeTaxAccountingPeriod;
      LibraryERM.CreateAssesseeCode(AssesseeCode);
      LibraryTCS.CreateTCSNatureCollectionAndTCSSetup(TcsNatureOfCollection,TCSSetup,TCSSetup."TCS Type"::E,AssesseeCode.Code);
      LibraryTCS.CreateNODNOCSetup(NocHeader,NocHeader.Type::Customer,LibraryTCS.CreateCustomer,AssesseeCode.Code,
        TcsNatureOfCollection.Code,TRUE,TRUE,TRUE);
Member of Miscellaneous.Service Tax With TDS Helper


CreatePurchaseDocGenJnlPoT@1500012 Method

The procedure CreatePurchaseDocGenJnlPoT is available in codeunit 143005.

Syntax

CreatePurchaseDocGenJnlPoT@1500012(
    VAR GenJournalLine@1500003 : Record 81 GenJournalLine, //Reference parameter of type Record
    PoT@1500002 : Boolean PoT //Input parameter of type Boolean
);

Parameters

GenJournalLine
Reference parameter of type Record
PoT
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, Purchase, Document, General, Journal, PoT.

For a clarification about how this function works, refer to the code listed below.

      SetupTax(VendorNo,TDSNODCode,WorkTaxNODCode);
      CreateGenJnlForVendor(
        GenJournalLine,GenJournalLine."Document Type"::Invoice,ReverseChargeTypeOption::" ",PoT,0,VendorNo);

      ValidateGenJnlNOD(GenJournalLine,TDSNODCode,WorkTaxNODCode);

      GenJournalLine.MODIFY(TRUE);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;

      // Setup
      ServiceTaxTDSHelper.CreatePurchaseDocGenJnlPoT(GenJournalLine,FALSE);
      LibraryTDS.SetInclServTaxOptionInGenJnl(GenJournalLine,TRUE);

      // Exercise
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // Verify
      ServiceTaxTDSHelper.VerifyTDSPostingInvoice(GenJournalLine,TRUE);
Member of Miscellaneous.Service Tax With TDS Helper


CreatePurchaseDocGenJnlRevChrg@1500006 Method

The procedure CreatePurchaseDocGenJnlRevChrg is available in codeunit 143005.

Syntax

CreatePurchaseDocGenJnlRevChrg@1500006(
    VAR GenJournalLine@1500003 : Record 81 GenJournalLine //Reference parameter of type Record
);

Parameters

GenJournalLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Purchase, Document, General, Journal, Rev, Chrg.

For a clarification about how this function works, refer to the code listed below.

      SetupTax(VendorNo,TDSNODCode,WorkTaxNODCode);
      CreateGenJnlForVendor(GenJournalLine,GenJournalLine."Document Type"::Invoice,
        ReverseChargeTypeOption::Standard,FALSE,100,VendorNo);
      ValidateGenJnlNOD(GenJournalLine,TDSNODCode,WorkTaxNODCode);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;

      // Setup
      ServiceTaxTDSHelper.CreatePurchaseDocGenJnlRevChrg(GenJournalLine);
      LibraryTDS.SetInclServTaxOptionInGenJnl(GenJournalLine,TRUE);

      // Exercise
      LibraryERM.PostGeneralJnlLine(GenJournalLine);
      PaymentDocNo :=
        ServiceTaxTDSHelper.ApplyAndPostPayment(GenJournalLine,ServiceTaxTDSHelper.CalcPaymentAmount(GenJournalLine,TRUE));

      // Verify
      ServiceTaxTDSHelper.VerifyServTaxRevChrg(GenJournalLine);
      ServiceTaxTDSHelper.VerifySTEntryDetail(GenJournalLine,PaymentDocNo,1);
      ServiceTaxTDSHelper.VerifySTBaseIsTDSBase(GenJournalLine."Document No.",TRUE,GenJournalLine.IsServTaxRevChrgSplit);
Member of Miscellaneous.Service Tax With TDS Helper


CreatePurchaseDocGenJnlSplit@1500027 Method

The procedure CreatePurchaseDocGenJnlSplit is available in codeunit 143005.

Syntax

CreatePurchaseDocGenJnlSplit@1500027(
    VAR GenJournalLine@1500003 : Record 81 GenJournalLine //Reference parameter of type Record
);

Parameters

GenJournalLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Purchase, Document, General, Journal, Split.

For a clarification about how this function works, refer to the code listed below.

      SetupTax(VendorNo,TDSNODCode,WorkTaxNODCode);
      CreateGenJnlForVendor(GenJournalLine,GenJournalLine."Document Type"::Invoice,
        ReverseChargeTypeOption::Standard,TRUE,LibraryRandom.RandIntInRange(10,90),VendorNo);
      ValidateGenJnlNOD(GenJournalLine,TDSNODCode,WorkTaxNODCode);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;

      // Setup
      ServiceTaxTDSHelper.CreatePurchaseDocGenJnlSplit(GenJournalLine);
      LibraryTDS.SetInclServTaxOptionInGenJnl(GenJournalLine,TRUE);

      // Exercise
      LibraryERM.PostGeneralJnlLine(GenJournalLine);
      PaymentDocNo :=
        ServiceTaxTDSHelper.ApplyAndPostPayment(GenJournalLine,ServiceTaxTDSHelper.CalcPaymentAmount(GenJournalLine,TRUE));

      // Verify
      ServiceTaxTDSHelper.VerifyServTaxSplit(GenJournalLine);
      ServiceTaxTDSHelper.VerifySTEntryDetail(GenJournalLine,PaymentDocNo,1);
      ServiceTaxTDSHelper.VerifySTBaseIsTDSBase(GenJournalLine."Document No.",TRUE,GenJournalLine.IsServTaxRevChrgSplit);
Member of Miscellaneous.Service Tax With TDS Helper


CreatePurchaseDocPoT@1500003 Method

The procedure CreatePurchaseDocPoT is available in codeunit 143005.

Syntax

CreatePurchaseDocPoT@1500003(
    VAR PurchaseHeader@1500003 : Record 38 PurchaseHeader, //Reference parameter of type Record
    VAR PurchaseLine@1500002 : Record 39 PurchaseLine, //Reference parameter of type Record
    PoT@1500004 : Boolean PoT //Input parameter of type Boolean
);

Parameters

PurchaseHeader
Reference parameter of type Record
PurchaseLine
Reference parameter of type Record
PoT
Input parameter of type Boolean

Remarks

The relevant search keywords are: Create, Purchase, Document, PoT.

For a clarification about how this function works, refer to the code listed below.

      SetupTax(VendorNo,TDSNODCode,WorkTaxNODCode);
      ReverseServiceTaxHelper.CreatePurchaseDocForVendor(PurchaseHeader,PurchaseLine,VendorNo,
        PurchaseHeader."Document Type"::Invoice,ReverseChargeTypeOption::" ",0,PoT);
      ValidatePurchLineNOD(PurchaseLine,TDSNODCode,WorkTaxNODCode);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;

      // Setup
      ServiceTaxTDSHelper.CreatePurchaseDocPoT(PurchaseHeader,PurchaseLine,FALSE);
      ServiceTaxTDSHelper.UpdateInclServTaxOption(PurchaseHeader,TRUE);

      // Exercise
      PostedDocNo := ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);

      // Verify
      ServiceTaxTDSHelper.ConvertDocToJnlLine(PurchaseHeader,PurchaseLine,PostedDocNo,GenJournalLine);
      ServiceTaxTDSHelper.VerifyTDSPostingInvoice(GenJournalLine,TRUE);
Member of Miscellaneous.Service Tax With TDS Helper


CreatePurchaseDocRevChrg@1500005 Method

The procedure CreatePurchaseDocRevChrg is available in codeunit 143005.

Syntax

CreatePurchaseDocRevChrg@1500005(
    VAR PurchaseHeader@1500003 : Record 38 PurchaseHeader, //Reference parameter of type Record
    VAR PurchaseLine@1500002 : Record 39 PurchaseLine //Reference parameter of type Record
);

Parameters

PurchaseHeader
Reference parameter of type Record
PurchaseLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Purchase, Document, Rev, Chrg.

For a clarification about how this function works, refer to the code listed below.

      SetupTax(VendorNo,TDSNODCode,WorkTaxNODCode);
      ReverseServiceTaxHelper.CreatePurchaseDocForVendor(PurchaseHeader,PurchaseLine,VendorNo,
        PurchaseHeader."Document Type"::Invoice,ReverseChargeTypeOption::Standard,100,FALSE);
      ValidatePurchLineNOD(PurchaseLine,TDSNODCode,WorkTaxNODCode);

Example

There are no examples available.
Member of Miscellaneous.Service Tax With TDS Helper


CreatePurchaseDocSplit@1500028 Method

The procedure CreatePurchaseDocSplit is available in codeunit 143005.

Syntax

CreatePurchaseDocSplit@1500028(
    VAR PurchaseHeader@1500003 : Record 38 PurchaseHeader, //Reference parameter of type Record
    VAR PurchaseLine@1500002 : Record 39 PurchaseLine //Reference parameter of type Record
);

Parameters

PurchaseHeader
Reference parameter of type Record
PurchaseLine
Reference parameter of type Record

Remarks

The relevant search keywords are: Create, Purchase, Document, Split.

For a clarification about how this function works, refer to the code listed below.

      SetupTax(VendorNo,TDSNODCode,WorkTaxNODCode);
      ReverseServiceTaxHelper.CreatePurchaseDocForVendor(PurchaseHeader,PurchaseLine,VendorNo,
        PurchaseHeader."Document Type"::Invoice,ReverseChargeTypeOption::Standard,LibraryRandom.RandIntInRange(10,90),TRUE);
      ValidatePurchLineNOD(PurchaseLine,TDSNODCode,WorkTaxNODCode);

Example

There are no examples available.
Member of Miscellaneous.Service Tax With TDS Helper


CreateVendorWithPANNo@1500058 Method

The procedure CreateVendorWithPANNo is available in codeunit 143005.

Syntax

CreateVendorWithPANNo@1500058(
      //param element not supplied
);

Return Value

Code[20]

Remarks

The relevant search keywords are: Create, Vendor, PAN, No.

For a clarification about how this function works, refer to the code listed below.

      Vendor.GET(ReverseServiceTaxHelper.CreateVendor);
      Vendor.VALIDATE("P.A.N. No.",'ACFPH4256B'); // Valid P.A.N. No. is required
      Vendor.MODIFY(TRUE);
      EXIT(Vendor."No.");

Example

The below example is extracted from the test automation codeunit 144076 to show one way of using this function.

      LibraryTDS.CreateIncomeTaxAccPeriod(IncomeTaxAccountingPeriod);
      LibraryTDS.CreateIncomeTaxPeriod(IncomeTaxPeriodSetup,IncomeTaxAccountingPeriod."No.",IncomeTaxPeriodSetup.Quarter::Q1);
      LibraryTDS.UpdateTDSNilChallanInGeneralLedgerSetup;
      IF ForeignVendor THEN BEGIN
        LibraryERM.CreateCountryRegion(CountryRegion);
        CurrencyCode :=
          LibraryERM.CreateCurrencyWithExchangeRate(IncomeTaxAccountingPeriod."Starting Date",LibraryRandom.RandDec(10,2),
            LibraryRandom.RandDec(10,2));
        LibraryTDS.CreateForeignVendorWithPANAPPLIED(Vendor,CurrencyCode,CountryRegion.Code);
        VendorNo := Vendor."No.";
      END ELSE
        VendorNo := ServiceTaxWithTDSHelper.CreateVendorWithPANNo;
      LibraryTDS.CreateAssesseeandNODNOCSetup(
        NodNocHeader,TdsNatureOfDeduction,TDSSetup,CountryRegion.Code,VendorNo,NodNocHeader.Type::Vendor,
        IncomeTaxAccountingPeriod."Starting Date");
      TDSAccount := LibraryTDS.CreateAndUpdateTDSAccNo(TDSSetup);
      WORKDATE := IncomeTaxAccountingPeriod."Starting Date";
Member of Miscellaneous.Service Tax With TDS Helper


GetBiggerAmount@1500076 Method

The procedure GetBiggerAmount is available in codeunit 143005.

Syntax

GetBiggerAmount@1500076(
    Amount@1500000 : Decimal Amount //Input parameter of type Decimal
);

Parameters

Amount
Input parameter of type Decimal

Return Value

Decimal

Remarks

The relevant search keywords are: Get, Bigger, Amount.

For a clarification about how this function works, refer to the code listed below.

      EXIT(Amount * (100 + LibraryRandom.RandIntInRange(10,200)) / 100);

Example

There are no examples available.
Member of Miscellaneous.Service Tax With TDS Helper


InvDocPoT@1500018 Method

The procedure InvDocPoT is available in codeunit 143005.

Syntax

InvDocPoT@1500018(
    IncludeServTax@1500004 : Boolean IncludeServTax //Input parameter of type Boolean
);

Parameters

IncludeServTax
Input parameter of type Boolean

Remarks

The relevant search keywords are: Invoice, Document, PoT.

For a clarification about how this function works, refer to the code listed below.

      // Setup
      CreatePurchaseDocPoT(PurchaseHeader,PurchaseLine,TRUE);
      UpdateInclServTaxOption(PurchaseHeader,IncludeServTax);

      // Exercise
      PostedDocNo := ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);

      // Verify
      ConvertDocToJnlLine(PurchaseHeader,PurchaseLine,PostedDocNo,GenJournalLine);
      VerifyTDSPostingInvoice(GenJournalLine,IncludeServTax);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;
      ServiceTaxTDSHelper.InvDocPoT(TRUE);
Member of Miscellaneous.Service Tax With TDS Helper


InvDocPoTAppliesToPmt@1500075 Method

The procedure InvDocPoTAppliesToPmt is available in codeunit 143005.

Syntax

InvDocPoTAppliesToPmt@1500075(
      //param element not supplied
);

Remarks

The relevant search keywords are: Invoice, Document, Po, T, Applies, To, Payment.

For a clarification about how this function works, refer to the code listed below.

      // Setup
      IncludeServTax := TRUE;
      CreatePurchaseDocPoT(PurchaseHeader,PurchaseLine,TRUE);
      UpdateInclServTaxOption(PurchaseHeader,IncludeServTax);
      ConvertDocToJnlLine(PurchaseHeader,PurchaseLine,PostedDocNo,GenJournalLine);
      PmtDocNo := PostPayment(GenJournalLine,IncludeServTax);
      PurchaseHeader.VALIDATE("Applies-to Doc. Type",PurchaseHeader."Applies-to Doc. Type"::Payment);
      PurchaseHeader.VALIDATE("Applies-to Doc. No.",PmtDocNo);
      PurchaseHeader.MODIFY;
      // Exercise
      PostedDocNo := ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);

      // Verify
      ConvertDocToJnlLine(PurchaseHeader,PurchaseLine,PostedDocNo,GenJournalLine);
      VerifyTDSPostingInvoice(GenJournalLine,IncludeServTax);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;
      ServiceTaxTDSHelper.InvDocPoTAppliesToPmt;
Member of Miscellaneous.Service Tax With TDS Helper


InvDocRevChrg@1500033 Method

The procedure InvDocRevChrg is available in codeunit 143005.

Syntax

InvDocRevChrg@1500033(
    IncludeServTax@1500004 : Boolean IncludeServTax //Input parameter of type Boolean
);

Parameters

IncludeServTax
Input parameter of type Boolean

Remarks

The relevant search keywords are: Invoice, Document, Rev, Chrg.

For a clarification about how this function works, refer to the code listed below.

      // Setup
      CreatePurchaseDocRevChrg(PurchaseHeader,PurchaseLine);
      UpdateInclServTaxOption(PurchaseHeader,IncludeServTax);

      // Exercise
      PostedDocNo := ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);

      // Verify
      ConvertDocToJnlLine(PurchaseHeader,PurchaseLine,PostedDocNo,GenJournalLine);
      VerifyTDSPostingInvoice(GenJournalLine,FALSE);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;
      ServiceTaxTDSHelper.InvDocRevChrg(TRUE);
Member of Miscellaneous.Service Tax With TDS Helper


InvDocSplit@1500037 Method

The procedure InvDocSplit is available in codeunit 143005.

Syntax

InvDocSplit@1500037(
    IncludeServTax@1500004 : Boolean IncludeServTax //Input parameter of type Boolean
);

Parameters

IncludeServTax
Input parameter of type Boolean

Remarks

The relevant search keywords are: Invoice, Document, Split.

For a clarification about how this function works, refer to the code listed below.

      InvDocSplitGenJnl(GenJournalLine,IncludeServTax);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;
      ServiceTaxTDSHelper.InvDocSplit(TRUE);
Member of Miscellaneous.Service Tax With TDS Helper


InvDocSplitGenJnl@1500044 Method

The procedure InvDocSplitGenJnl is available in codeunit 143005.

Syntax

InvDocSplitGenJnl@1500044(
    VAR GenJournalLine@1500005 : Record 81 GenJournalLine, //Reference parameter of type Record
    IncludeServTax@1500004 : Boolean IncludeServTax //Input parameter of type Boolean
);

Parameters

GenJournalLine
Reference parameter of type Record
IncludeServTax
Input parameter of type Boolean

Return Value

Code[20]

Remarks

The relevant search keywords are: Invoice, Document, Split, General, Journal.

For a clarification about how this function works, refer to the code listed below.

      // Setup
      LibraryServiceTax.SetServiceTaxRounding;
      CreatePurchaseDocSplit(PurchaseHeader,PurchaseLine);
      UpdateInclServTaxOption(PurchaseHeader,IncludeServTax);

      // Exercise
      PostedDocNo := ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);

      // Verify
      ConvertDocToJnlLine(PurchaseHeader,PurchaseLine,PostedDocNo,GenJournalLine);
      VerifyTDSPostingInvoice(GenJournalLine,IncludeServTax);

Example

There are no examples available.
Member of Miscellaneous.Service Tax With TDS Helper


InvGenJnlPoT@1500032 Method

The procedure InvGenJnlPoT is available in codeunit 143005.

Syntax

InvGenJnlPoT@1500032(
    IncludeServTax@1500004 : Boolean IncludeServTax //Input parameter of type Boolean
);

Parameters

IncludeServTax
Input parameter of type Boolean

Remarks

The relevant search keywords are: Invoice, General, Journal, PoT.

For a clarification about how this function works, refer to the code listed below.

      // Setup
      CreatePurchaseDocGenJnlPoT(GenJournalLine,TRUE);
      LibraryTDS.SetInclServTaxOptionInGenJnl(GenJournalLine,IncludeServTax);

      // Exercise
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // Verify
      VerifyTDSPostingInvoice(GenJournalLine,IncludeServTax);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;
      ServiceTaxTDSHelper.InvGenJnlPoT(TRUE);
Member of Miscellaneous.Service Tax With TDS Helper


InvGenJnlPoTAppliesToPmt@1500104 Method

The procedure InvGenJnlPoTAppliesToPmt is available in codeunit 143005.

Syntax

InvGenJnlPoTAppliesToPmt@1500104(
    VAR GenJournalLine@1500001 : Record 81 GenJournalLine, //Reference parameter of type Record
    IncludeServTax@1500000 : Boolean IncludeServTax //Input parameter of type Boolean
);

Parameters

GenJournalLine
Reference parameter of type Record
IncludeServTax
Input parameter of type Boolean

Remarks

The relevant search keywords are: Invoice, General, Journal, Po, T, Applies, To, Payment.

For a clarification about how this function works, refer to the code listed below.

      // Setup
      IncludeServTax := TRUE;
      CreatePurchaseDocGenJnlPoT(GenJournalLine,TRUE);
      LibraryTDS.SetInclServTaxOptionInGenJnl(GenJournalLine,IncludeServTax);
      PmtDocNo := PostPayment(GenJournalLine,IncludeServTax);
      GenJournalLine.VALIDATE("Applies-to Doc. Type",GenJournalLine."Applies-to Doc. Type"::Payment);
      GenJournalLine.VALIDATE("Applies-to Doc. No.",PmtDocNo);
      GenJournalLine.MODIFY;

      // Exercise
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;
      IncludeServTax := TRUE;
      ServiceTaxTDSHelper.InvGenJnlPoTAppliesToPmt(GenJournalLine,IncludeServTax);

      // Verify
      ServiceTaxTDSHelper.VerifyTDSPostingInvoice(GenJournalLine,IncludeServTax);
Member of Miscellaneous.Service Tax With TDS Helper


InvGenJnlRevChrg@1500034 Method

The procedure InvGenJnlRevChrg is available in codeunit 143005.

Syntax

InvGenJnlRevChrg@1500034(
    IncludeServTax@1500004 : Boolean IncludeServTax //Input parameter of type Boolean
);

Parameters

IncludeServTax
Input parameter of type Boolean

Remarks

The relevant search keywords are: Invoice, General, Journal, Rev, Chrg.

For a clarification about how this function works, refer to the code listed below.

      // Setup
      CreatePurchaseDocGenJnlRevChrg(GenJournalLine);
      LibraryTDS.SetInclServTaxOptionInGenJnl(GenJournalLine,IncludeServTax);

      // Exercise
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // Verify
      VerifyTDSPostingInvoice(GenJournalLine,FALSE);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;
      ServiceTaxTDSHelper.InvGenJnlRevChrg(TRUE);
Member of Miscellaneous.Service Tax With TDS Helper


InvGenJnlSplit@1500038 Method

The procedure InvGenJnlSplit is available in codeunit 143005.

Syntax

InvGenJnlSplit@1500038(
    IncludeServTax@1500004 : Boolean IncludeServTax //Input parameter of type Boolean
);

Parameters

IncludeServTax
Input parameter of type Boolean

Remarks

The relevant search keywords are: Invoice, General, Journal, Split.

For a clarification about how this function works, refer to the code listed below.

      // Setup
      CreatePurchaseDocGenJnlSplit(GenJournalLine);
      LibraryTDS.SetInclServTaxOptionInGenJnl(GenJournalLine,IncludeServTax);

      // Exercise
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // Verify
      VerifyTDSPostingInvoice(GenJournalLine,IncludeServTax);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;
      ServiceTaxTDSHelper.InvGenJnlSplit(TRUE);
Member of Miscellaneous.Service Tax With TDS Helper


OfflineAppSplit@1500049 Method

The procedure OfflineAppSplit is available in codeunit 143005.

Syntax

OfflineAppSplit@1500049(
    LastTransactionNo@1500001 : Integer LastTransactionNo, //Input parameter of type Integer
    ApplyToInvoice@1500005 : Boolean ApplyToInvoice //Input parameter of type Boolean
);

Parameters

LastTransactionNo
Input parameter of type Integer
ApplyToInvoice
Input parameter of type Boolean

Remarks

The relevant search keywords are: Offline, App, Split.

For a clarification about how this function works, refer to the code listed below.

      IncludeServiceTax := TRUE;

      // Setup
      InvoiceDocNo := InvDocSplitGenJnl(GenJournalLine,IncludeServiceTax);
      PaymentDocNo := PostPayment(GenJournalLine,IncludeServiceTax);

      // Exercise - apply offline
      IF ApplyToInvoice THEN
        ReverseServiceTaxHelper.ApplyAndPostVendorEntry(
          GenJournalLine."Document Type"::Invoice,InvoiceDocNo,
          GenJournalLine."Document Type"::Payment,PaymentDocNo)
      ELSE
        ReverseServiceTaxHelper.ApplyAndPostVendorEntry(
          GenJournalLine."Document Type"::Payment,PaymentDocNo,
          GenJournalLine."Document Type"::Invoice,InvoiceDocNo);

      // Verify
      GenJournalLine."Document No." := InvoiceDocNo;
      ServiceTaxVerify.SplitApplication(GenJournalLine,PaymentDocNo,LastTransactionNo);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      LastTransactionNo := Initialize;
      ServiceTaxTDSHelper.OfflineAppSplit(LastTransactionNo,TRUE);
Member of Miscellaneous.Service Tax With TDS Helper


PostAdvPaymentPoT@1500071 Method

The procedure PostAdvPaymentPoT is available in codeunit 143005.

Syntax

PostAdvPaymentPoT@1500071(
    VAR GenJournalLine@1500001 : Record 81 GenJournalLine, //Reference parameter of type Record
    VAR TDSBaseInclServTax@1500000 : Boolean TDSBaseInclServTax //Reference parameter of type Boolean
);

Parameters

GenJournalLine
Reference parameter of type Record
TDSBaseInclServTax
Reference parameter of type Boolean

Remarks

The relevant search keywords are: Post, Adv, Payment, PoT.

For a clarification about how this function works, refer to the code listed below.

      CreateAdvPmtPoT(GenJournalLine);
      LibraryTDS.SetInclServTaxOptionInGenJnl(GenJournalLine,TDSBaseInclServTax);
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

Example

There are no examples available.
Member of Miscellaneous.Service Tax With TDS Helper


PostInvAppliesToAdvPmtPoT@1500069 Method

The procedure PostInvAppliesToAdvPmtPoT is available in codeunit 143005.

Syntax

PostInvAppliesToAdvPmtPoT@1500069(
    VAR InvoiceGenJournalLine@1500002 : Record 81 InvoiceGenJournalLine, //Reference parameter of type Record
    VAR PaymentGenJournalLine@1500001 : Record 81 PaymentGenJournalLine, //Reference parameter of type Record
    TDSBaseInclServTax@1500000 : Boolean TDSBaseInclServTax //Input parameter of type Boolean
);

Parameters

InvoiceGenJournalLine
Reference parameter of type Record
PaymentGenJournalLine
Reference parameter of type Record
TDSBaseInclServTax
Input parameter of type Boolean

Remarks

The relevant search keywords are: Post, Invoice, Applies, To, Adv, Payment, PoT.

For a clarification about how this function works, refer to the code listed below.

      // Setup
      PostAdvPaymentPoT(PaymentGenJournalLine,TDSBaseInclServTax);

      // Exercise
      InvoiceGenJournalLine := PaymentGenJournalLine;
      ApplyAndPostBiggerInvGenJnl(InvoiceGenJournalLine);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;
      ServiceTaxTDSHelper.PostInvAppliesToAdvPmtPoT(InvGenJournalLine,PmtGenJournalLine,FALSE);

      ASSERTERROR ReverseServiceTaxHelper.UnapplyVendorLedgerEntry(InvGenJournalLine."Document No.");
      Assert.ExpectedError(UnapplyErr);
Member of Miscellaneous.Service Tax With TDS Helper


PostInvoiceGenJnl@1500056 Method

The procedure PostInvoiceGenJnl is available in codeunit 143005.

Syntax

PostInvoiceGenJnl@1500056(
    VAR GenJournalLine@1500000 : Record 81 GenJournalLine //Reference parameter of type Record
);

Parameters

GenJournalLine
Reference parameter of type Record

Return Value

Code[20]

Remarks

The relevant search keywords are: Post, Invoice, General, Journal.

For a clarification about how this function works, refer to the code listed below.

      CreateInvoiceFromGenJournal(GenJournalLine);
      GenJournalLine.VALIDATE("Applies-to Doc. Type",0);
      GenJournalLine.VALIDATE("Applies-to Doc. No.",'');
      GenJournalLine.MODIFY;
      LibraryERM.PostGeneralJnlLine(GenJournalLine);
      EXIT(GenJournalLine."Document No.");

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;

      // Setup
      AdvPmtDocNo := ServiceTaxTDSHelper.CreateAdvPmtPoT(GenJournalLine);
      LibraryERM.PostGeneralJnlLine(GenJournalLine);
      InvoiceDocNo := ServiceTaxTDSHelper.PostInvoiceGenJnl(GenJournalLine);

      // Exercise
      ASSERTERROR
        ReverseServiceTaxHelper.ApplyAndPostVendorEntry(
          GenJournalLine."Document Type"::Invoice,InvoiceDocNo,
          GenJournalLine."Document Type"::Payment,AdvPmtDocNo);
      // Verify
      Assert.ExpectedError(OfflineApplnAdvPmtWithTDSErr);
Member of Miscellaneous.Service Tax With TDS Helper


PostPayment@1500082 Method

The procedure PostPayment is available in codeunit 143005.

Syntax

PostPayment@1500082(
    GenJournalLine@1500000 : Record 81 GenJournalLine, //Input parameter of type Record
    IncludeServTax@1500001 : Boolean IncludeServTax //Input parameter of type Boolean
);

Parameters

GenJournalLine
Input parameter of type Record
IncludeServTax
Input parameter of type Boolean

Return Value

Code[20]

Remarks

The relevant search keywords are: Post, Payment.

For a clarification about how this function works, refer to the code listed below.

      PaymentAmount := CalcPaymentAmount(GenJournalLine,IncludeServTax);
      EXIT(
        ReverseServiceTaxHelper.PostPayment(
          GenJournalLine."Account No.",PaymentAmount,GenJournalLine."Posting Date",GenJournalLine."Document Type"::Payment));

Example

There are no examples available.
Member of Miscellaneous.Service Tax With TDS Helper


RemoveTDSFromGenJournal@1500026 Method

The procedure RemoveTDSFromGenJournal is available in codeunit 143005.

Syntax

RemoveTDSFromGenJournal@1500026(
    VAR GeneralJournalLine@1500000 : Record 81 GeneralJournalLine, //Reference parameter of type Record
    ModifyRecord@1500001 : Boolean ModifyRecord //Input parameter of type Boolean
);

Parameters

GeneralJournalLine
Reference parameter of type Record
ModifyRecord
Input parameter of type Boolean

Remarks

The relevant search keywords are: Remove, TDS, From, General, Journal.

For a clarification about how this function works, refer to the code listed below.

      WITH GeneralJournalLine DO BEGIN
        VALIDATE("TDS Nature of Deduction",'');
        VALIDATE("TDS/TCS Amt Incl Surcharge",0);
        VALIDATE("TDS/TCS %",0);
        VALIDATE("TDS/TCS Amount",0);
        VALIDATE("TDS/TCS Base Amount",0);
        VALIDATE("Bal. TDS/TCS Including SHECESS",0);
        VALIDATE("Balance TDS/TCS Amount",0);
        IF ModifyRecord THEN
          MODIFY(TRUE)
      END;

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;

      // Setup
      ServiceTaxTDSHelper.CreateAdvPmtPoT(GenJournalLine);
      LibraryERM.PostGeneralJnlLine(GenJournalLine);
      // Exercise
      ServiceTaxTDSHelper.RemoveTDSFromGenJournal(GenJournalLine,FALSE);
      ASSERTERROR ServiceTaxTDSHelper.ApplyAndPostInvoiceDoc(GenJournalLine);

      // Verify
      Assert.ExpectedError(DiffTDSOnAppliedDocsErr);
Member of Miscellaneous.Service Tax With TDS Helper


RemoveWorkTaxFromGenJournal@1500025 Method

The procedure RemoveWorkTaxFromGenJournal is available in codeunit 143005.

Syntax

RemoveWorkTaxFromGenJournal@1500025(
    VAR GeneralJournalLine@1500000 : Record 81 GeneralJournalLine, //Reference parameter of type Record
    ModifyRecord@1500001 : Boolean ModifyRecord //Input parameter of type Boolean
);

Parameters

GeneralJournalLine
Reference parameter of type Record
ModifyRecord
Input parameter of type Boolean

Remarks

The relevant search keywords are: Remove, Work, Tax, From, General, Journal.

For a clarification about how this function works, refer to the code listed below.

      WITH GeneralJournalLine DO BEGIN
        VALIDATE("Work Tax Nature Of Deduction",'');
        VALIDATE("Work Tax Base Amount",0);
        VALIDATE("Work Tax %",0);
        VALIDATE("Work Tax Amount",0);
        VALIDATE("Balance Work Tax Amount",0);
        IF ModifyRecord THEN
          MODIFY(TRUE)
      END;

Example

The below example is extracted from the test automation codeunit 144036 to show one way of using this function.

      Initialize;

      // Setup
      ServiceTaxTDSHelper.CreateAdvPmtPoT(GenJournalLine);
      LibraryERM.PostGeneralJnlLine(GenJournalLine);
      // Exercise
      ServiceTaxTDSHelper.RemoveWorkTaxFromGenJournal(GenJournalLine,FALSE);
      ASSERTERROR ServiceTaxTDSHelper.ApplyAndPostInvoiceDoc(GenJournalLine);

      // Verify
      Assert.ExpectedError(DiffWorkTaxOnAppliedDocsErr);
Member of Miscellaneous.Service Tax With TDS Helper


SetTDSTaxType@1500002 Method

The procedure SetTDSTaxType is available in codeunit 143005.

Syntax

SetTDSTaxType@1500002(
    TDSTax@1500000 : Boolean TDSTax, //Input parameter of type Boolean
    WorkTax@1500001 : Boolean WorkTax //Input parameter of type Boolean
);

Parameters

TDSTax
Input parameter of type Boolean
WorkTax
Input parameter of type Boolean

Remarks

The relevant search keywords are: Set, TDS, Tax, Type.

For a clarification about how this function works, refer to the code listed below.

      IF TestSetup.GET THEN BEGIN
        UpdateTestSetupTaxType(TestSetup,TDSTax,WorkTax);
        TestSetup.MODIFY;
      END ELSE BEGIN
        TestSetup.INIT;
        UpdateTestSetupTaxType(TestSetup,TDSTax,WorkTax);
        TestSetup.INSERT;
      END;

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      LibraryRandom.SetSeed(1);

      IF isInitialized THEN
        EXIT(ReverseServiceTaxHelper.GetLastTransactionNo);

      LibraryServiceTax.CreateServiceTaxReturnPeriod;
      ReverseServiceTaxHelper.SetupCompanyInfo;
      ServiceTaxTDSHelper.SetTDSTaxType(TRUE,FALSE);
      ServiceTaxTDSHelper.SetupIncomeTaxAccountingPeriod;
      ServiceTaxTDSHelper.CreateDeductoryCodeAndUpdateOnCompanyInformation;
      COMMIT;

      isInitialized := TRUE;

      EXIT(ReverseServiceTaxHelper.GetLastTransactionNo);
Member of Miscellaneous.Service Tax With TDS Helper


SetupIncomeTaxAccountingPeriod@1500004 Method

The procedure SetupIncomeTaxAccountingPeriod is available in codeunit 143005.

Syntax

SetupIncomeTaxAccountingPeriod@1500004(
      //param element not supplied
);

Remarks

The relevant search keywords are: Setup, Income, Tax, Accounting, Period.

For a clarification about how this function works, refer to the code listed below.

      ReverseServiceTaxHelper.GetServiceTaxReturnPeriod(ServiceTaxReturnPeriod);
      LibraryTDS.CreateTDSTCSFiscalYear(IncomeTaxAccPeriod,LibraryServiceTax.GetSrvTaxReturnPeriodStartDate(ServiceTaxReturnPeriod));
      LibraryTDS.CreateIncomeTaxPeriodQuarters(IncomeTaxAccPeriod."No.");

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      LibraryRandom.SetSeed(1);

      IF isInitialized THEN
        EXIT(ReverseServiceTaxHelper.GetLastTransactionNo);

      LibraryServiceTax.CreateServiceTaxReturnPeriod;
      ReverseServiceTaxHelper.SetupCompanyInfo;
      ServiceTaxTDSHelper.SetTDSTaxType(TRUE,FALSE);
      ServiceTaxTDSHelper.SetupIncomeTaxAccountingPeriod;
      ServiceTaxTDSHelper.CreateDeductoryCodeAndUpdateOnCompanyInformation;
      COMMIT;

      isInitialized := TRUE;

      EXIT(ReverseServiceTaxHelper.GetLastTransactionNo);
Member of Miscellaneous.Service Tax With TDS Helper


UpdateInclServTaxOption@1500009 Method

The procedure UpdateInclServTaxOption is available in codeunit 143005.

Syntax

UpdateInclServTaxOption@1500009(
    VAR PurchaseHeader@1500001 : Record 38 PurchaseHeader, //Reference parameter of type Record
    Value@1500000 : Boolean Value //Input parameter of type Boolean
);

Parameters

PurchaseHeader
Reference parameter of type Record
Value
Input parameter of type Boolean

Remarks

The relevant search keywords are: Update, Incl, Serv, Tax, Option.

For a clarification about how this function works, refer to the code listed below.

      LibraryTDS.SetInclServTaxOptionInStruct(PurchaseHeader.Structure,Value);
      PoT := PurchaseHeader.PoT;
      PurchaseHeader.VALIDATE(Structure);
      PurchaseHeader.VALIDATE(PoT,PoT);
      PurchaseHeader.MODIFY;

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;

      // Setup
      ServiceTaxTDSHelper.CreatePurchaseDocPoT(PurchaseHeader,PurchaseLine,FALSE);
      ServiceTaxTDSHelper.UpdateInclServTaxOption(PurchaseHeader,TRUE);

      // Exercise
      PostedDocNo := ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);

      // Verify
      ServiceTaxTDSHelper.ConvertDocToJnlLine(PurchaseHeader,PurchaseLine,PostedDocNo,GenJournalLine);
      ServiceTaxTDSHelper.VerifyTDSPostingInvoice(GenJournalLine,TRUE);
Member of Miscellaneous.Service Tax With TDS Helper


UseTDSTax@1500007 Method

The procedure UseTDSTax is available in codeunit 143005.

Syntax

UseTDSTax@1500007(
      //param element not supplied
);

Return Value

Boolean

Remarks

The relevant search keywords are: Use, TDS, Tax.

For a clarification about how this function works, refer to the code listed below.

      TestSetup.GET;
      EXIT(TestSetup."Use TDS Tax");

Example

There are no examples available.
Member of Miscellaneous.Service Tax With TDS Helper


UseWorkTax@1500008 Method

The procedure UseWorkTax is available in codeunit 143005.

Syntax

UseWorkTax@1500008(
      //param element not supplied
);

Return Value

Boolean

Remarks

The relevant search keywords are: Use, Work, Tax.

For a clarification about how this function works, refer to the code listed below.

      TestSetup.GET;
      EXIT(TestSetup."Use Work Tax");

Example

There are no examples available.
Member of Miscellaneous.Service Tax With TDS Helper


VerifyNoTDSOnAppliedInvoice@1500079 Method

The procedure VerifyNoTDSOnAppliedInvoice is available in codeunit 143005.

Syntax

VerifyNoTDSOnAppliedInvoice@1500079(
    GenJournalLine@1500000 : Record 81 GenJournalLine //Input parameter of type Record
);

Parameters

GenJournalLine
Input parameter of type Record

Remarks

The relevant search keywords are: Verify, No, TDS, On, Applied, Invoice.

For a clarification about how this function works, refer to the code listed below.

      WITH GenJournalLine DO BEGIN
        TDSEntry.SETRANGE("Document Type","Document Type");
        TDSEntry.SETRANGE("Document No.","Document No.");
        Assert.IsTrue(TDSEntry.ISEMPTY,STRSUBSTNO('There must be no TDS Entry for %1 %2',"Document Type","Document No."));
      END;

Example

There are no examples available.
Member of Miscellaneous.Service Tax With TDS Helper


VerifyPostingAppliedBigInv@1500068 Method

The procedure VerifyPostingAppliedBigInv is available in codeunit 143005.

Syntax

VerifyPostingAppliedBigInv@1500068(
    InvoiceGenJournalLine@1500000 : Record 81 InvoiceGenJournalLine, //Input parameter of type Record
    PaymentGenJournalLine@1500006 : Record 81 PaymentGenJournalLine, //Input parameter of type Record
    TDSBaseInclServTax@1500003 : Boolean TDSBaseInclServTax //Input parameter of type Boolean
);

Parameters

InvoiceGenJournalLine
Input parameter of type Record
PaymentGenJournalLine
Input parameter of type Record
TDSBaseInclServTax
Input parameter of type Boolean

Remarks

The relevant search keywords are: Verify, Posting, Applied, Big, Invoice.

For a clarification about how this function works, refer to the code listed below.

      ServiceTaxVerify.AppliedDocServiceTax(PaymentGenJournalLine,InvoiceGenJournalLine,FALSE);
      IF UseTDSTax THEN
        VerifyTDSPostingAppliedBigInv(InvoiceGenJournalLine,PaymentGenJournalLine,TDSBaseInclServTax);
      IF UseWorkTax THEN
        VerifyWTaxPostingAppliedBigInv(InvoiceGenJournalLine,PaymentGenJournalLine,TDSBaseInclServTax);

Example

There are no examples available.
Member of Miscellaneous.Service Tax With TDS Helper


VerifyServTaxRevChrg@1500039 Method

The procedure VerifyServTaxRevChrg is available in codeunit 143005.

Syntax

VerifyServTaxRevChrg@1500039(
    GenJournalLine@1500000 : Record 81 GenJournalLine //Input parameter of type Record
);

Parameters

GenJournalLine
Input parameter of type Record

Remarks

The relevant search keywords are: Verify, Serv, Tax, Rev, Chrg.

For a clarification about how this function works, refer to the code listed below.

      ServTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      ServTaxAmount :=
        ReverseServiceTaxHelper.CalculateServTaxTotal(
          ReverseServiceTaxHelper.CalculateServTaxBase(
            ABS(GenJournalLine.Amount),GenJournalLine."Document Type"),
          ServTaxSetup);

      ServiceTaxVerify.ServTaxGLAccountsBalance(ServTaxSetup,0,ServTaxAmount,-ServTaxAmount,0);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;

      // Setup
      ServiceTaxTDSHelper.CreatePurchaseDocGenJnlRevChrg(GenJournalLine);
      LibraryTDS.SetInclServTaxOptionInGenJnl(GenJournalLine,TRUE);

      // Exercise
      LibraryERM.PostGeneralJnlLine(GenJournalLine);
      PaymentDocNo :=
        ServiceTaxTDSHelper.ApplyAndPostPayment(GenJournalLine,ServiceTaxTDSHelper.CalcPaymentAmount(GenJournalLine,TRUE));

      // Verify
      ServiceTaxTDSHelper.VerifyServTaxRevChrg(GenJournalLine);
      ServiceTaxTDSHelper.VerifySTEntryDetail(GenJournalLine,PaymentDocNo,1);
      ServiceTaxTDSHelper.VerifySTBaseIsTDSBase(GenJournalLine."Document No.",TRUE,GenJournalLine.IsServTaxRevChrgSplit);
Member of Miscellaneous.Service Tax With TDS Helper


VerifyServTaxSplit@1500035 Method

The procedure VerifyServTaxSplit is available in codeunit 143005.

Syntax

VerifyServTaxSplit@1500035(
    GenJournalLine@1500000 : Record 81 GenJournalLine //Input parameter of type Record
);

Parameters

GenJournalLine
Input parameter of type Record

Remarks

The relevant search keywords are: Verify, Serv, Tax, Split.

For a clarification about how this function works, refer to the code listed below.

      ServTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      CalcSplitAmounts(GenJournalLine,PoTAmount,RevChrgAmount,ServTaxSetup);

      ServiceTaxVerify.ServTaxGLAccountsBalance(ServTaxSetup,PoTAmount,RevChrgAmount,-RevChrgAmount,0);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;

      // Setup
      ServiceTaxTDSHelper.CreatePurchaseDocGenJnlSplit(GenJournalLine);
      LibraryTDS.SetInclServTaxOptionInGenJnl(GenJournalLine,TRUE);

      // Exercise
      LibraryERM.PostGeneralJnlLine(GenJournalLine);
      PaymentDocNo :=
        ServiceTaxTDSHelper.ApplyAndPostPayment(GenJournalLine,ServiceTaxTDSHelper.CalcPaymentAmount(GenJournalLine,TRUE));

      // Verify
      ServiceTaxTDSHelper.VerifyServTaxSplit(GenJournalLine);
      ServiceTaxTDSHelper.VerifySTEntryDetail(GenJournalLine,PaymentDocNo,1);
      ServiceTaxTDSHelper.VerifySTBaseIsTDSBase(GenJournalLine."Document No.",TRUE,GenJournalLine.IsServTaxRevChrgSplit);
Member of Miscellaneous.Service Tax With TDS Helper


VerifyServTaxSplitAdvPmt@1500059 Method

The procedure VerifyServTaxSplitAdvPmt is available in codeunit 143005.

Syntax

VerifyServTaxSplitAdvPmt@1500059(
    GenJournalLine@1500000 : Record 81 GenJournalLine //Input parameter of type Record
);

Parameters

GenJournalLine
Input parameter of type Record

Remarks

The relevant search keywords are: Verify, Serv, Tax, Split, Adv, Payment.

For a clarification about how this function works, refer to the code listed below.

      ServTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      CalcSplitAmounts(GenJournalLine,PoTAmount,RevChrgAmount,ServTaxSetup);

      ServiceTaxVerify.ServTaxGLAccountsBalance(ServTaxSetup,PoTAmount,RevChrgAmount - PoTAmount,-RevChrgAmount,0);

Example

There are no examples available.
Member of Miscellaneous.Service Tax With TDS Helper


VerifySTBaseIsTDSBase@1500048 Method

The procedure VerifySTBaseIsTDSBase is available in codeunit 143005.

Syntax

VerifySTBaseIsTDSBase@1500048(
    DocumentNo@1500000 : Code[20] DocumentNo, //Input parameter of type Code
    IncludeServTax@1500006 : Boolean IncludeServTax, //Input parameter of type Boolean
    STRoundingPrecision@1500003 : Boolean STRoundingPrecision //Input parameter of type Boolean
);

Parameters

DocumentNo
Input parameter of type Code
IncludeServTax
Input parameter of type Boolean
STRoundingPrecision
Input parameter of type Boolean

Remarks

The relevant search keywords are: Verify, ST, Base, Is, TDS, Base.

For a clarification about how this function works, refer to the code listed below.

      VerifySTBaseIsTDSBaseRounding(DocumentNo,IncludeServTax,STRoundingPrecision,FALSE);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;

      // Setup
      ServiceTaxTDSHelper.CreatePurchaseDocGenJnlRevChrg(GenJournalLine);
      LibraryTDS.SetInclServTaxOptionInGenJnl(GenJournalLine,TRUE);

      // Exercise
      LibraryERM.PostGeneralJnlLine(GenJournalLine);
      PaymentDocNo :=
        ServiceTaxTDSHelper.ApplyAndPostPayment(GenJournalLine,ServiceTaxTDSHelper.CalcPaymentAmount(GenJournalLine,TRUE));

      // Verify
      ServiceTaxTDSHelper.VerifyServTaxRevChrg(GenJournalLine);
      ServiceTaxTDSHelper.VerifySTEntryDetail(GenJournalLine,PaymentDocNo,1);
      ServiceTaxTDSHelper.VerifySTBaseIsTDSBase(GenJournalLine."Document No.",TRUE,GenJournalLine.IsServTaxRevChrgSplit);
Member of Miscellaneous.Service Tax With TDS Helper


VerifySTBaseIsTDSBaseRounding@1500077 Method

The procedure VerifySTBaseIsTDSBaseRounding is available in codeunit 143005.

Syntax

VerifySTBaseIsTDSBaseRounding@1500077(
    DocumentNo@1500000 : Code[20] DocumentNo, //Input parameter of type Code
    IncludeServTax@1500006 : Boolean IncludeServTax, //Input parameter of type Boolean
    STRoundingPrecision@1500003 : Boolean STRoundingPrecision, //Input parameter of type Boolean
    DoubleRounding@1500008 : Boolean DoubleRounding //Input parameter of type Boolean
);

Parameters

DocumentNo
Input parameter of type Code
IncludeServTax
Input parameter of type Boolean
STRoundingPrecision
Input parameter of type Boolean
DoubleRounding
Input parameter of type Boolean

Remarks

The relevant search keywords are: Verify, ST, Base, Is, TDS, Base, Rounding.

For a clarification about how this function works, refer to the code listed below.

      TDSEntry.SETRANGE("Document No.",DocumentNo);
      IF NOT TDSEntry.FINDLAST OR (TDSEntry."TDS Base Amount" = 0) THEN
        EXIT;

      ServiceTaxEntry.SETRANGE("Document No.",DocumentNo);
      IF ServiceTaxEntry.FINDSET THEN
        REPEAT
          IF NOT ServiceTaxEntry."Reverse Charge" AND IncludeServTax THEN
            ExpectedTDSBase += ServiceTaxEntry."Amount Including Service Tax"
          ELSE
            ExpectedTDSBase += ServiceTaxEntry."Service Tax Base Amount";
        UNTIL ServiceTaxEntry.NEXT = 0
      ELSE
        EXIT;

      GLSetup.GET;
      RoundingPrecision := GLSetup."Amount Rounding Precision";
      IF STRoundingPrecision THEN
        RoundingPrecision := GLSetup."Service Tax Rounding Precision";
      IF DoubleRounding THEN
        RoundingPrecision := RoundingPrecision * 2;
      Assert.AreNearlyEqual(
        ExpectedTDSBase,TDSEntry."TDS Base Amount",RoundingPrecision,TDSBaseRoundingErr)

Example

There are no examples available.
Member of Miscellaneous.Service Tax With TDS Helper


VerifySTEntryDetail@1500031 Method

The procedure VerifySTEntryDetail is available in codeunit 143005.

Syntax

VerifySTEntryDetail@1500031(
    GenJournalLine@1500005 : Record 81 GenJournalLine, //Input parameter of type Record
    PaymentDocNo@1500006 : Code[20] PaymentDocNo, //Input parameter of type Code
    PartialPaymentFactor@1500003 : Decimal PartialPaymentFactor //Input parameter of type Decimal
);

Parameters

GenJournalLine
Input parameter of type Record
PaymentDocNo
Input parameter of type Code
PartialPaymentFactor
Input parameter of type Decimal

Remarks

The relevant search keywords are: Verify, ST, Entry, Detail.

For a clarification about how this function works, refer to the code listed below.

      ServTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      CalcSplitAmounts(GenJournalLine,PoTAmount,RevChrgAmount,ServTaxSetup);
      ServTaxEntryDetail.SETRANGE("Document Type",GenJournalLine."Document Type"::Payment);
      ServTaxEntryDetail.SETRANGE("Document No.",PaymentDocNo);
      ServTaxEntryDetail.SETRANGE("Reverse Charge",TRUE);
      ServTaxEntryDetail.FINDLAST;
      ServTaxAmount := ServTaxEntryDetail."Service Tax Amount" + ServTaxEntryDetail."Service Tax eCess Amount" +
        ServTaxEntryDetail."Service Tax SHE Cess Amount";
      GLSetup.GET;
      Assert.AreNearlyEqual(
        ReverseServiceTaxHelper.RoundAmount(RevChrgAmount * PartialPaymentFactor),ServTaxAmount,
        GLSetup."Service Tax Rounding Precision",
        STRSUBSTNO(AmountErr,'Total Service Tax Amount',ServTaxEntryDetail.TABLECAPTION));

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;

      // Setup
      ServiceTaxTDSHelper.CreatePurchaseDocGenJnlRevChrg(GenJournalLine);
      LibraryTDS.SetInclServTaxOptionInGenJnl(GenJournalLine,TRUE);

      // Exercise
      LibraryERM.PostGeneralJnlLine(GenJournalLine);
      PaymentDocNo :=
        ServiceTaxTDSHelper.ApplyAndPostPayment(GenJournalLine,ServiceTaxTDSHelper.CalcPaymentAmount(GenJournalLine,TRUE));

      // Verify
      ServiceTaxTDSHelper.VerifyServTaxRevChrg(GenJournalLine);
      ServiceTaxTDSHelper.VerifySTEntryDetail(GenJournalLine,PaymentDocNo,1);
      ServiceTaxTDSHelper.VerifySTBaseIsTDSBase(GenJournalLine."Document No.",TRUE,GenJournalLine.IsServTaxRevChrgSplit);
Member of Miscellaneous.Service Tax With TDS Helper


VerifyTDSEntry@1500078 Method

The procedure VerifyTDSEntry is available in codeunit 143005.

Syntax

VerifyTDSEntry@1500078(
    ExpectedTDSEntryAmounts@1500005 : Record 13729 ExpectedTDSEntryAmounts, //Input parameter of type Record
    DocumentNo@1500000 : Code[20] DocumentNo, //Input parameter of type Code
    DocumentType@1500001 : Option DocumentType, //Input parameter of type Option
    DoubleRoundingPrecision@1500004 : Boolean DoubleRoundingPrecision //Input parameter of type Boolean
);

Parameters

ExpectedTDSEntryAmounts
Input parameter of type Record
DocumentNo
Input parameter of type Code
DocumentType
Input parameter of type Option
DoubleRoundingPrecision
Input parameter of type Boolean

Remarks

The relevant search keywords are: Verify, TDS, Entry.

For a clarification about how this function works, refer to the code listed below.

      TDSEntry.SETRANGE("Document No.",DocumentNo);
      TDSEntry.SETRANGE("Document Type",DocumentType);
      TDSEntry.FINDLAST;

      GLSetup.GET;
      RoundingPrecision := GLSetup."Service Tax Rounding Precision";
      IF DoubleRoundingPrecision THEN
        RoundingPrecision := RoundingPrecision * 2;
      Assert.AreEqual(
        ExpectedTDSEntryAmounts."Base Includes Service Tax",TDSEntry."Base Includes Service Tax",
        STRSUBSTNO(AmountErr,TDSEntry.FIELDNAME("Base Includes Service Tax"),TDSEntry.TABLECAPTION));
      Assert.AreEqual(
        ExpectedTDSEntryAmounts."TDS Amount",TDSEntry."TDS Amount",
        STRSUBSTNO(AmountErr,TDSEntry.FIELDNAME("TDS Amount"),TDSEntry.TABLECAPTION));
      Assert.AreNearlyEqual(
        ExpectedTDSEntryAmounts."TDS Base Amount",TDSEntry."TDS Base Amount",
        RoundingPrecision,
        STRSUBSTNO(AmountErr,TDSEntry.FIELDNAME("TDS Base Amount"),TDSEntry.TABLECAPTION));
      Assert.AreEqual(
        ExpectedTDSEntryAmounts."eCESS Amount",TDSEntry."eCESS Amount",
        STRSUBSTNO(AmountErr,TDSEntry.FIELDNAME("eCESS Amount"),TDSEntry.TABLECAPTION));
      Assert.AreEqual(
        ExpectedTDSEntryAmounts."SHE Cess Amount",TDSEntry."SHE Cess Amount",
        STRSUBSTNO(AmountErr,TDSEntry.FIELDNAME("SHE Cess Amount"),TDSEntry.TABLECAPTION));
      Assert.AreEqual(
        ExpectedTDSEntryAmounts."Work Tax Amount",TDSEntry."Work Tax Amount",
        STRSUBSTNO(AmountErr,TDSEntry.FIELDNAME("Work Tax Amount"),TDSEntry.TABLECAPTION));
      Assert.AreNearlyEqual(
        ExpectedTDSEntryAmounts."Work Tax Base Amount",TDSEntry."Work Tax Base Amount",
        GLSetup."Service Tax Rounding Precision",
        STRSUBSTNO(AmountErr,TDSEntry.FIELDNAME("Work Tax Base Amount"),TDSEntry.TABLECAPTION));

Example

The below example is extracted from the test automation codeunit 144056 to show one way of using this function.

      //[SCENARIO 164267] Posting of General journal with TDS & Foreign currency after executing additional Currency report .
      //[FEATURE] [General Journal]

      // [GIVEN] Create Setup for NODNOC,Assessee Setup and Vendor with Country &foreign currency For General Journals
      Initialize;
      CreateIncomeTaxAccountingPeriod;
      CreateDeductoryCodeAndUpdateOnCompanyInformation;
      LibraryERM.CreateCountryRegion(CountryRegion);
      LibraryPurchase.CreateVendor(Vendor);
      Vendor.VALIDATE("Currency Code",LibraryERM.CreateCurrencyWithRandomExchRates);
      Vendor.VALIDATE("Country/Region Code",CountryRegion.Code);
      Vendor.VALIDATE("P.A.N. No.",LibraryUtility.GenerateRandomCode(Vendor.FIELDNO("P.A.N. No."),DATABASE::Vendor));
      Vendor.MODIFY(TRUE);
      LibraryTDS.CreateAssesseeandNODNOCSetup(NODNOCHeader,TDSNatureDeduction,TDSSetup,
        CountryRegion.Code,Vendor."No.",NODNOCHeader.Type::Vendor,WORKDATE);
      Amount := LibraryRandom.RandDec(1000,2);

      //[WHEN] Create General Journals With Foreign Currency and Creating Balance account along with this line
      LibraryERM.CreateGenJournalTemplate(GenJournalTemplate);
      LibraryERM.CreateGenJournalBatch(GenJournalBatch,GenJournalTemplate.Name);
      LibraryERM.CreateGeneralJnlLineWithBalAcc(
        GenJournalLine,GenJournalTemplate.Name,GenJournalBatch.Name,GenJournalLine."Document Type"::Payment,
        GenJournalLine."Account Type"::Vendor,Vendor."No.",GenJournalLine."Bal. Account Type"::"Bank Account",
        LibraryERM.CreateBankAccountNo,Amount);
      GenJournalLine.VALIDATE("Party Type",GenJournalLine."Party Type"::Vendor);
      GenJournalLine.VALIDATE("Party Code",Vendor."No.");
      GenJournalLine.VALIDATE("TDS Nature of Deduction",TDSNatureDeduction.Code);
      GenJournalLine.MODIFY(TRUE);
      LibraryTDS.CalcTDSAmountsFromBase(ExpectedTDSEntry,TDSSetup,GenJournalLine."Amount (LCY)");
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      //[THEN] G/l entries and TDS Entries are created,which are calculated using tds setup defined
      VerifyGLEntryCount(GenJournalLine."Document No.",3);
      VerifyGLEntry(GenJournalLine."Document Type"::Payment,GenJournalLine."Document No.",GenJournalLine."Amount (LCY)");
      ServiceTaxWithTDSHelper.VerifyTDSEntry(
        ExpectedTDSEntry,GenJournalLine."Document No.",GenJournalLine."Document Type"::Payment,FALSE);
Member of Miscellaneous.Service Tax With TDS Helper


VerifyTDSEntryFromBase@1500053 Method

The procedure VerifyTDSEntryFromBase is available in codeunit 143005.

Syntax

VerifyTDSEntryFromBase@1500053(
    GenJournalLine@1500000 : Record 81 GenJournalLine //Input parameter of type Record
);

Parameters

GenJournalLine
Input parameter of type Record

Remarks

The relevant search keywords are: Verify, TDS, Entry, From, Base.

For a clarification about how this function works, refer to the code listed below.

      CalcTDSAmountsFromBase(ExpectedTDSEntry,GenJournalLine,GenJournalLine.Amount);

      GLSetup.GET;
      RoundingPrecision := GLSetup."Service Tax Rounding Precision";

      TDSEntry.SETRANGE("Document Type",GenJournalLine."Document Type");
      TDSEntry.SETRANGE("Document No.",GenJournalLine."Document No.");
      TDSEntry.FINDLAST;

      Assert.AreEqual(
        ExpectedTDSEntry."TDS Base Amount",TDSEntry."TDS Base Amount",
        STRSUBSTNO(AmountErr,TDSEntry.FIELDNAME("TDS Base Amount"),TDSEntry.TABLECAPTION));
      Assert.AreNearlyEqual(
        ExpectedTDSEntry."TDS Amount",TDSEntry."TDS Amount",RoundingPrecision,
        STRSUBSTNO(AmountErr,TDSEntry.FIELDNAME("TDS Amount"),TDSEntry.TABLECAPTION));
      Assert.AreNearlyEqual(
        ExpectedTDSEntry."eCESS Amount",TDSEntry."eCESS Amount",RoundingPrecision,
        STRSUBSTNO(AmountErr,TDSEntry.FIELDNAME("eCESS Amount"),TDSEntry.TABLECAPTION));
      Assert.AreNearlyEqual(
        ExpectedTDSEntry."SHE Cess Amount",TDSEntry."SHE Cess Amount",RoundingPrecision,
        STRSUBSTNO(AmountErr,TDSEntry.FIELDNAME("SHE Cess Amount"),TDSEntry.TABLECAPTION));

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;
      ServiceTaxTDSHelper.AdvPmtApplyBiggerInvDocPoTFcy(GenJournalLine,PmtGenJournalLine);

      // Verify
      ServiceTaxSetup.FindOnDate(GenJournalLine."Service Tax Group Code",GenJournalLine."Posting Date");
      GenJournalLine.Amount += ReverseServiceTaxHelper.CalculateServTaxTotal(GenJournalLine.Amount,ServiceTaxSetup) +
        ReverseServiceTaxHelper.CalculateKKCess(GenJournalLine.Amount,ServiceTaxSetup) +
        ReverseServiceTaxHelper.CalculateSBC(GenJournalLine.Amount,ServiceTaxSetup);
      GenJournalLine.Amount :=
        ServiceTaxFCYHelper.ConvertFCYAmountToLCY(GenJournalLine) - ServiceTaxFCYHelper.ConvertFCYAmountToLCY(PmtGenJournalLine);
      ServiceTaxTDSHelper.VerifyTDSEntryFromBase(GenJournalLine);
Member of Miscellaneous.Service Tax With TDS Helper


VerifyTDSPostingAdvPmt@1500041 Method

The procedure VerifyTDSPostingAdvPmt is available in codeunit 143005.

Syntax

VerifyTDSPostingAdvPmt@1500041(
    GenJournalLine@1500000 : Record 81 GenJournalLine, //Input parameter of type Record
    IncludeServTax@1500003 : Boolean IncludeServTax //Input parameter of type Boolean
);

Parameters

GenJournalLine
Input parameter of type Record
IncludeServTax
Input parameter of type Boolean

Remarks

The relevant search keywords are: Verify, TDS, Posting, Adv, Payment.

For a clarification about how this function works, refer to the code listed below.

      CalcTDSAmounts(ExpectedTDSAmounts,GenJournalLine,BankLEAmount,IncludeServTax);
      VendorLEAmount :=
        BankLEAmount + ExpectedTDSAmounts."Total TDS Including SHE CESS" + ExpectedTDSAmounts."Work Tax Amount";

      IF UseTDSTax THEN
        ServiceTaxVerify.GLEntry(GenJournalLine."Document No.",
          GetTDSAccount(GenJournalLine),
          -ExpectedTDSAmounts."Total TDS Including SHE CESS");

      IF UseWorkTax THEN
        ServiceTaxVerify.GLEntry(GenJournalLine."Document No.",
          GetWorkTaxTDSAccount(GenJournalLine),
          -ExpectedTDSAmounts."Work Tax Amount");

      ServiceTaxVerify.GLEntry(GenJournalLine."Document No.",
        ReverseServiceTaxHelper.GetBankAccGLPostingAcc(GenJournalLine."Bal. Account No."),
        -BankLEAmount);

      VerifyTDSEntry(ExpectedTDSAmounts,GenJournalLine."Document No.",GenJournalLine."Document Type",FALSE);
      ServiceTaxVerify.GLEntry(GenJournalLine."Document No.",
        ReverseServiceTaxHelper.GetVendorPostingAccount(GenJournalLine."Account No."),
        VendorLEAmount);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;

      ServiceTaxTDSHelper.CreateAdvPmt(GenJournalLine,0,ReverseChargeTypeOption::" ",FALSE);

      // Exercise
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // Verify
      ServiceTaxTDSHelper.VerifyTDSPostingAdvPmt(GenJournalLine,FALSE);
Member of Miscellaneous.Service Tax With TDS Helper


VerifyTDSPostingAppliedBigInv@1500072 Method

The procedure VerifyTDSPostingAppliedBigInv is available in codeunit 143005.

Syntax

VerifyTDSPostingAppliedBigInv@1500072(
    InvoiceGenJournalLine@1500000 : Record 81 InvoiceGenJournalLine, //Input parameter of type Record
    PmtGenJournalLine@1500006 : Record 81 PmtGenJournalLine, //Input parameter of type Record
    IncludeServTax@1500003 : Boolean IncludeServTax //Input parameter of type Boolean
);

Parameters

InvoiceGenJournalLine
Input parameter of type Record
PmtGenJournalLine
Input parameter of type Record
IncludeServTax
Input parameter of type Boolean

Remarks

The relevant search keywords are: Verify, TDS, Posting, Applied, Big, Invoice.

For a clarification about how this function works, refer to the code listed below.

      VerifyTDSPostingBigInv(InvoiceGenJournalLine,PmtGenJournalLine,IncludeServTax);
      VerifySTBaseIsTDSBase(InvoiceGenJournalLine."Document No.",IncludeServTax,TRUE);

Example

There are no examples available.
Member of Miscellaneous.Service Tax With TDS Helper


VerifyTDSPostingAppliedInvoice@1500064 Method

The procedure VerifyTDSPostingAppliedInvoice is available in codeunit 143005.

Syntax

VerifyTDSPostingAppliedInvoice@1500064(
    GenJournalLine@1500000 : Record 81 GenJournalLine, //Input parameter of type Record
    IncludeServTax@1500003 : Boolean IncludeServTax //Input parameter of type Boolean
);

Parameters

GenJournalLine
Input parameter of type Record
IncludeServTax
Input parameter of type Boolean

Remarks

The relevant search keywords are: Verify, TDS, Posting, Applied, Invoice.

For a clarification about how this function works, refer to the code listed below.

      CalcTDSAmounts(ExpectedTDSAmounts,GenJournalLine,BankLEAmount,IncludeServTax);
      VendorLEAmount :=
        BankLEAmount + ExpectedTDSAmounts."Total TDS Including SHE CESS" + ExpectedTDSAmounts."Work Tax Amount";

      // Entries with Amount = 0 created Purchase Invoice
      IF UseTDSTax THEN BEGIN
        IF GenJournalLine."System-Created Entry" THEN
          ServiceTaxVerify.GLEntry(GenJournalLine."Document No.",GetTDSAccount(GenJournalLine),0)
        ELSE
          ServiceTaxVerify.GLEntryDoesNotExist(GenJournalLine."Document No.",GetTDSAccount(GenJournalLine));
        ZeroTDSAmounts.INIT;
        ZeroTDSAmounts."Base Includes Service Tax" := IncludeServTax;
        VerifyTDSEntry(ZeroTDSAmounts,GenJournalLine."Document No.",GenJournalLine."Document Type",FALSE);
      END;

      IF UseWorkTax THEN
        ServiceTaxVerify.GLEntryDoesNotExist(
          GenJournalLine."Document No.",GetWorkTaxTDSAccount(GenJournalLine));

      ServiceTaxVerify.GLEntry(GenJournalLine."Document No.",
        ReverseServiceTaxHelper.GetVendorPostingAccount(GenJournalLine."Account No."),
        -VendorLEAmount);

      VerifySTBaseIsTDSBase(GenJournalLine."Document No.",IncludeServTax,GenJournalLine.IsServTaxRevChrgSplit);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;

      // Setup
      ServiceTaxTDSHelper.CreateAdvPmt(GenJournalLine,0,ReverseChargeTypeOption::" ",FALSE);
      LibraryERM.PostGeneralJnlLine(GenJournalLine);

      // Exercise
      ServiceTaxTDSHelper.ApplyAndPostInvoiceDoc(GenJournalLine);

      // Verify
      ServiceTaxTDSHelper.VerifyTDSPostingAppliedInvoice(GenJournalLine,FALSE);
Member of Miscellaneous.Service Tax With TDS Helper


VerifyTDSPostingBigInv@1500073 Method

The procedure VerifyTDSPostingBigInv is available in codeunit 143005.

Syntax

VerifyTDSPostingBigInv@1500073(
    InvoiceGenJournalLine@1500000 : Record 81 InvoiceGenJournalLine, //Input parameter of type Record
    PmtGenJournalLine@1500006 : Record 81 PmtGenJournalLine, //Input parameter of type Record
    IncludeServTax@1500003 : Boolean IncludeServTax //Input parameter of type Boolean
);

Parameters

InvoiceGenJournalLine
Input parameter of type Record
PmtGenJournalLine
Input parameter of type Record
IncludeServTax
Input parameter of type Boolean

Remarks

The relevant search keywords are: Verify, TDS, Posting, Big, Invoice.

For a clarification about how this function works, refer to the code listed below.

      CalcTDSAmounts(ExpectedPmtTDSAmounts,PmtGenJournalLine,BankLEAmount,IncludeServTax);
      CalcTDSAmounts(ExpectedTDSAmounts,InvoiceGenJournalLine,BankLEAmount,IncludeServTax);

      ExpectedTDSAmounts."TDS Base Amount" -= ExpectedPmtTDSAmounts."TDS Base Amount";
      CalcTDSAmountsFromBase(ExpectedTDSAmounts,InvoiceGenJournalLine,ExpectedTDSAmounts."TDS Base Amount");

      ServiceTaxVerify.GLEntry(InvoiceGenJournalLine."Document No.",
        GetTDSAccount(InvoiceGenJournalLine),-ExpectedTDSAmounts."Total TDS Including SHE CESS");

      ServiceTaxVerify.VendorLedgerEntryOpen(PmtGenJournalLine."Document No.",FALSE);
      ServiceTaxVerify.VendorLedgerEntryOpen(InvoiceGenJournalLine."Document No.",TRUE);

      VerifyTDSEntry(ExpectedPmtTDSAmounts,PmtGenJournalLine."Document No.",PmtGenJournalLine."Document Type",TRUE);
      VerifyTDSEntry(ExpectedTDSAmounts,InvoiceGenJournalLine."Document No.",InvoiceGenJournalLine."Document Type",TRUE);

Example

There are no examples available.
Member of Miscellaneous.Service Tax With TDS Helper


VerifyTDSPostingBigInvRounding@1500070 Method

The procedure VerifyTDSPostingBigInvRounding is available in codeunit 143005.

Syntax

VerifyTDSPostingBigInvRounding@1500070(
    InvoiceGenJournalLine@1500000 : Record 81 InvoiceGenJournalLine, //Input parameter of type Record
    PmtGenJournalLine@1500006 : Record 81 PmtGenJournalLine, //Input parameter of type Record
    IncludeServTax@1500003 : Boolean IncludeServTax //Input parameter of type Boolean
);

Parameters

InvoiceGenJournalLine
Input parameter of type Record
PmtGenJournalLine
Input parameter of type Record
IncludeServTax
Input parameter of type Boolean

Remarks

The relevant search keywords are: Verify, TDS, Posting, Big, Invoice, Rounding.

For a clarification about how this function works, refer to the code listed below.

      VerifyTDSPostingBigInv(InvoiceGenJournalLine,PmtGenJournalLine,IncludeServTax);
      VerifySTBaseIsTDSBaseRounding(InvoiceGenJournalLine."Document No.",IncludeServTax,TRUE,TRUE);

Example

There are no examples available.
Member of Miscellaneous.Service Tax With TDS Helper


VerifyTDSPostingInvoice@1500000 Method

The procedure VerifyTDSPostingInvoice is available in codeunit 143005.

Syntax

VerifyTDSPostingInvoice@1500000(
    GenJournalLine@1500000 : Record 81 GenJournalLine, //Input parameter of type Record
    IncludeServTax@1500003 : Boolean IncludeServTax //Input parameter of type Boolean
);

Parameters

GenJournalLine
Input parameter of type Record
IncludeServTax
Input parameter of type Boolean

Remarks

The relevant search keywords are: Verify, TDS, Posting, Invoice.

For a clarification about how this function works, refer to the code listed below.

      CalcTDSAmounts(ExpectedTDSAmounts,GenJournalLine,VendorLEAmount,IncludeServTax);

      IF UseTDSTax THEN
        ServiceTaxVerify.GLEntry(GenJournalLine."Document No.",
          GetTDSAccount(GenJournalLine),
          -ExpectedTDSAmounts."Total TDS Including SHE CESS");

      IF UseWorkTax THEN
        ServiceTaxVerify.GLEntry(GenJournalLine."Document No.",
          GetWorkTaxTDSAccount(GenJournalLine),
          -ExpectedTDSAmounts."Work Tax Amount");

      ServiceTaxVerify.AccountBalanceByDocNo(
        ReverseServiceTaxHelper.GetVendorPostingAccount(GenJournalLine."Account No."),
        GenJournalLine."Document No.",-VendorLEAmount);

      VerifyTDSEntry(ExpectedTDSAmounts,GenJournalLine."Document No.",GenJournalLine."Document Type",FALSE);
      VerifySTBaseIsTDSBase(GenJournalLine."Document No.",IncludeServTax,GenJournalLine.IsServTaxRevChrgSplit);

Example

The below example is extracted from the test automation codeunit 144035 to show one way of using this function.

      Initialize;

      // Setup
      ServiceTaxTDSHelper.CreatePurchaseDocPoT(PurchaseHeader,PurchaseLine,FALSE);
      ServiceTaxTDSHelper.UpdateInclServTaxOption(PurchaseHeader,TRUE);

      // Exercise
      PostedDocNo := ReverseServiceTaxHelper.PostPurchaseDoc(PurchaseHeader);

      // Verify
      ServiceTaxTDSHelper.ConvertDocToJnlLine(PurchaseHeader,PurchaseLine,PostedDocNo,GenJournalLine);
      ServiceTaxTDSHelper.VerifyTDSPostingInvoice(GenJournalLine,TRUE);
Member of Miscellaneous.Service Tax With TDS Helper


VerifyWTaxPostingAppliedBigInv@1500024 Method

The procedure VerifyWTaxPostingAppliedBigInv is available in codeunit 143005.

Syntax

VerifyWTaxPostingAppliedBigInv@1500024(
    GenJournalLine@1500000 : Record 81 GenJournalLine, //Input parameter of type Record
    PmtGenJournalLine@1500006 : Record 81 PmtGenJournalLine, //Input parameter of type Record
    IncludeServTax@1500003 : Boolean IncludeServTax //Input parameter of type Boolean
);

Parameters

GenJournalLine
Input parameter of type Record
PmtGenJournalLine
Input parameter of type Record
IncludeServTax
Input parameter of type Boolean

Remarks

The relevant search keywords are: Verify, W, Tax, Posting, Applied, Big, Invoice.

For a clarification about how this function works, refer to the code listed below.

      CalcTDSAmounts(ExpectedPmtTDSAmounts,PmtGenJournalLine,BankLEAmount,IncludeServTax);
      CalcTDSAmounts(ExpectedTDSAmounts,GenJournalLine,BankLEAmount,IncludeServTax);

      ExpectedTDSAmounts."Work Tax Base Amount" -= ExpectedPmtTDSAmounts."Work Tax Base Amount";
      CalcTDSAmountsFromBase(ExpectedTDSAmounts,GenJournalLine,ExpectedTDSAmounts."Work Tax Base Amount");

      ServiceTaxVerify.GLEntry(GenJournalLine."Document No.",
        GetWorkTaxTDSAccount(GenJournalLine),-ExpectedTDSAmounts."Work Tax Amount");

      ServiceTaxVerify.VendorLedgerEntryOpen(PmtGenJournalLine."Document No.",FALSE);
      ServiceTaxVerify.VendorLedgerEntryOpen(GenJournalLine."Document No.",TRUE);

      VerifySTBaseIsTDSBase(GenJournalLine."Document No.",IncludeServTax,TRUE);
      VerifyTDSEntry(ExpectedPmtTDSAmounts,PmtGenJournalLine."Document No.",PmtGenJournalLine."Document Type",FALSE);
      VerifyTDSEntry(ExpectedTDSAmounts,GenJournalLine."Document No.",GenJournalLine."Document Type",FALSE);

Example

There are no examples available.
Member of Miscellaneous.Service Tax With TDS Helper


Namespaces
Lib
Miscellaneous