public void copyLedgerSetup()
{
Ledger fromLedger = Ledger::findByLegalEntity(CompanyInfo::findDataArea(fromCompany).RecId);
Ledger toLedger = Ledger::findByLegalEntity(CompanyInfo::findDataArea(toCompany).RecId);
LedgerStructure fromLedgerStructure, toLedgerStructure;
LedgerGainLossAccount fromLedgerGainLossAccount, toLedgerGainLossAccount;
if (fromLedger && !toLedger)
{
toLedger.data(fromLedger);
toLedger.PrimaryForLegalEntity = CompanyInfo::findDataArea(toCompany).RecId;
toLedger.Name = toCompany;
toLedger.doInsert();
while select fromLedgerStructure
where fromLedgerStructure.Ledger == fromLedger.RecId
{
toLedgerStructure.data(fromLedgerStructure);
toLedgerStructure.Ledger = toLedger.RecId;
toLedgerStructure.insert();
}
while select fromLedgerGainLossAccount
where fromLedgerGainLossAccount.Ledger == fromLedger.RecId
{
toLedgerGainLossAccount.data(fromLedgerGainLossAccount);
toLedgerGainLossAccount.Ledger = toLedger.RecId;
toLedgerGainLossAccount.insert();
}
}
}
No comments:
Post a Comment