Thursday, 8 October 2020

Moving project from one environment to another (On perm)

 C:\AOSService\PackagesLocalDirectory\bin>ModelUtil.exe -export -metadatastorepath=C:\AosService\PackagesLocalDirectory -modelname="EEMC2DBarcode" -outputpath=c:\temp


C:\AOSService\PackagesLocalDirectory\bin>ModelUtil.exe -import -metadatastorepath=C:\AosService\PackagesLocalDirectory -file=c:\temp\EEMC2DBarcode-EEMC.axmodel

create Ledger dimension from value && get value(cust) from dimension

ledgerJournalTransUpdate.OffsetLedgerDimension = LedgerDynamicAccountHelper::getDynamicAccountFromAccountNumber(BankAccount.valueStr(),LedgerJournalACType::Bank);


To retrive cutomer value :

LedgerDynamicAccountHelper::getAccountNumberFromDynamicAccount(ledgerJournalTrans.LedgerDimension); 

Modify value inside default dimension

 salestable.DefaultDimension = EemcFOC::getNewDefaultDimension(salestable.DefaultDimension,"Worker" ,HcmWorker::find(salestable.WORKERSALESRESPONSIBLE).PersonnelNumber);

Sales responsible / sales taker lookup filter

 [ExtensionOf(classStr(HcmWorkerLookup))]

final class EEMCHcmWorkerLookup_Extension

{

    public Query updateQuery(HcmWorkerRecId _workerRecId, Query _queryToUpdate)

    {

        _queryToUpdate =next updateQuery( _workerRecId ,  _queryToUpdate);

        if(includeContractors==true&&CustParameters::find().SalesManWorker==true)

        {

            _queryToUpdate.dataSourceTable(tableNum(HcmWorker)).addRange(fieldNum(HcmWorker,SalesMan)).value(queryValue(1));

            _queryToUpdate.dataSourceName('HcmEmployment').addRange(fieldNum(HcmEmployment, EmploymentType)).value(queryValue(HcmEmploymentType::Employee));

        }

        return _queryToUpdate;

    }

}

COC for Form method

 [ExtensionOf(formStr(PurchReqTable))]

final class FCC_PurchReqTable_Extension

{

    void setFieldAccess()

    {

        next setFieldAccess();

        PurchReqLine  purchReqLine;

        FormDataSource fds;

        fds = this.purchReqLine_ds;


        fds.object(fieldNum(PurchReqLine, PurchPrice)).allowEdit(true);

        fds.object(fieldNum(PurchReqLine, PurchUnitOfMeasure)).allowEdit(true);

        

    }


}

Packingslip as Invoice Id while posting sales invoice

 [ExtensionOf(ClassStr(SalesInvoiceJournalCreateBase))]

final class salesInvoiceJournalCreateBase_Extension

{

    protected void initJournalHeader()

    {

        Str60                           packingslipId;

        SalesParmSubTable               SalesParmSubTableRef;

        CustPackingSlipJour             custPackingSlipJour;

        custInvoiceJour                 custInvoiceJourLocal;

        EEMC_PackingSlipConsumedTmp     packingSlipConsumedTmp;

        EEMC_PackingSlipTmp             packingSlipTmp, packingSlipTmpUpdate;

        CustParameters                  custParameters  =   CustParameters::find();


        next initJournalHeader();

        

        if(custParameters.EEMC_PackingSlipTOInvoice == NoYes::Yes)

        {

            while select SalesParmSubTableRef where SalesParmSubTableRef.ParmId==salesParmTable.ParmId && SalesParmSubTableRef.JournalRefTableId ==tableNum(CustPackingSlipJour)

            {

                select packingSlipTmp where packingSlipTmp.PackingSlipId == CustPackingSlipJour::findRecId(SalesParmSubTableRef.JournalRefRecId).PackingSlipId;

                if(!packingSlipTmp)

                {

                    packingslipId = CustPackingSlipJour::findRecId(SalesParmSubTableRef.JournalRefRecId).PackingSlipId;

                    packingSlipTmp.PackingSlipId = packingslipId;

                    packingSlipTmp.insert();

                }

            }

            select firstonly packingSlipTmp where packingSlipTmp.Marked == NoYes::No;

            if(packingSlipTmp)

            {

                if(packingSlipTmp.PackingSlipId  && custParameters.EEMC_PackingSlipTOInvoice == NoYes::Yes)

                {

                    if(custParameters.EEMC_InvoiceNonDuplicating == NoYes::Yes)

                    {

                        select custInvoiceJourLocal where custInvoiceJourLocal.InvoiceId == packingSlipTmp.PackingSlipId;

                        if(!custInvoiceJourLocal)

                        {

                            custInvoiceJour.InvoiceId       = packingSlipTmp.PackingSlipId;

                            custInvoiceJour.EEMC_InvoiceId  = packingSlipTmp.PackingSlipId;


                            select forupdate packingSlipTmpUpdate where packingSlipTmpUpdate.RecId == packingSlipTmp.RecId;

                            ttsbegin;

                            packingSlipTmpUpdate.Marked = NoYes::Yes;

                            packingSlipTmpUpdate.update();

                            ttscommit;

                            info(strFmt("Invoice Id : %1", packingSlipTmp.PackingSlipId));

                        }

                        else

                        {

                            throw error(strFmt("Invoice number : %1 Can't be duplicated", custInvoiceJourLocal.InvoiceId));

                        }

                    }

                    else

                    {

                        custInvoiceJour.InvoiceId       = packingSlipTmp.PackingSlipId;

                        custInvoiceJour.EEMC_InvoiceId  = packingSlipTmp.PackingSlipId;


                        select forupdate packingSlipTmpUpdate where packingSlipTmpUpdate.RecId == packingSlipTmp.RecId;

                        ttsbegin;

                        packingSlipTmpUpdate.Marked = NoYes::Yes;

                        packingSlipTmpUpdate.update();

                        ttscommit;

                        info(strFmt("Invoice Id : %1", packingSlipTmp.PackingSlipId));

                    }

                }

            }

        }

        else

        {

            select firstonly SalesParmSubTableRef where SalesParmSubTableRef.ParmId==salesParmTable.ParmId && SalesParmSubTableRef.JournalRefTableId ==tableNum(CustPackingSlipJour);

            if(CustPackingSlipJour::findRecId(SalesParmSubTableRef.JournalRefRecId).PackingSlipId  && CustParameters::find().UseDeliveryNoteAsInvoice==NoYes::Yes)

            custInvoiceJour.InvoiceId= CustPackingSlipJour::findRecId(SalesParmSubTableRef.JournalRefRecId).PackingSlipId;

            if(!custInvoiceJour.InvoiceId)

            custInvoiceJour.InvoiceId       = this.getJournalNumber();

        }

    }


}

Packingslip duplicate control while posting packingslip

 [ExtensionOf(ClassStr(SalesPackingSlipJournalCreate))]

final class EEMCSalesPackingSlipJournalCreate_Extension

{

    protected void initJournalHeader()

    {

        CustPackingSlipJour         custPackingSlipJourLocal;

        CustParameters              custParameters  =   CustParameters::find();


        if(custParameters.EEMC_PackingSlipNonDuplicating == NoYes::Yes)

        {

            select custPackingSlipJourLocal where custPackingSlipJourLocal.PackingSlipId == this.getJournalNumber();

            if(custPackingSlipJourLocal)

            {

                throw error(strFmt("Packingslip Id : %1 can't be duplicated", custPackingSlipJourLocal.PackingSlipId));

            }

        }

        next initJournalHeader();

    }


}