Announcements
I am working on the Invoice Journal form, where clicking the Debit Note button successfully creates a Ledger Journal Transaction in LedgerJournalTrans
. The LedgerDimension
is set correctly using the getLedgerDim
method, and the transaction is recorded under the Vendor account. However, the Business Unit and Vendor financial dimensions are not updating in LedgerJournalTransDimension
.I also want to update service accounting code under taxinformation menu it would be very helpful if you have some idea about how can i do it. Beside if you have any suggestion about my code snippet i will be very happy to listen and improve .
The getLedgerDim
method is already used to derive the ledger dimension, but it seems that LedgerJournalTransDimension
is not being explicitly updated. How can I ensure that the Business Unit and Vendor dimensions are properly assigned when creating the ledger transaction? Should I explicitly insert/update LedgerJournalTransDimension
, or is there another recommended approach to fix this issue?
NOTE: I removed some fields to keep the snippet meaningful and smaller those are working fine and i think it has no relation with my question .
service accounting code and financial dimension remains blank i was talking about ss for reference:
[Control("Button")]
class DebitNoteBtn
{
public void clicked()
{
super();
FormButtonControl generateButton = element.control(element.controlId(formControlStr(AcxBulkTagDestroy, btnGenerate))) as FormButtonControl;
AcxBulkTagDestroyDetail acxBulkTagDestroyDetailSel;
LedgerJournalTable ledgerJournalTable;
InventItemGroupItem inventItemGroupItem;
LedgerJournalTrans ledgerJournalTransVendInvoice;
RecId offsetLedgerDimension;
str journalId, vendorAccountNum, businessUnit;
real makingCharges, grossWeightSum, otherChargesSum;
ItemId itemId;
MainAccountNum offsetAccountNum = 'xxxxxxxx';
container conOffsetValues;
vendorAccountNum = AcxBulkTagDestroy_AccountId.text();
businessUnit = AcxBulkTagDestroy.InventSiteId;
if (vendorAccountNum == "")
{
error("Vendor Account Number cannot be blank");
AcxBulkTagDestroy_ds.refresh();
return;
}
acxBulkTagDestroyDetailSel = AcxBulkTagDestroyDetail_DS.cursor();
if (!acxBulkTagDestroyDetailSel)
{
error("No detail record selected");
return;
}
select sum(OtherChargesAmount), sum(GrossWeight), ItemId from acxBulkTagDestroyDetailSel
where acxBulkTagDestroyDetailSel.BulkTagDestroyNo == AcxBulkTagDestroy.BulkTagDestroyNo;
otherChargesSum = acxBulkTagDestroyDetailSel.OtherChargesAmount;
grossWeightSum = acxBulkTagDestroyDetailSel.GrossWeight;
select firstOnly acxBulkTagDestroyDetailSel
join inventItemGroupItem
where acxBulkTagDestroyDetailSel.BulkTagDestroyNo == AcxBulkTagDestroy.BulkTagDestroyNo
&& inventItemGroupItem.ItemId == acxBulkTagDestroyDetailSel.ItemId;
itemId = inventItemGroupItem.ItemGroupId;
if (AcxBulkTagDestroy.JournalNum)
{
error("Debit note is already generated for this entry.");
return;
}
ttsBegin;
try
{
ledgerJournalTable.JournalName = 'DBS/ADR/22';
ledgerJournalTable.Name = "Debit Note-22";
ledgerJournalTable.initValue();
ledgerJournalTable.insert();
journalId = ledgerJournalTable.JournalNum;
ledgerJournalTransVendInvoice.initValue();
ledgerJournalTransVendInvoice.JournalNum = journalId;
ledgerJournalTransVendInvoice.Voucher =NumberSeq::newGetNum(LedgerParameters::numRefLedgerTempVoucher()).num();
ledgerJournalTransVendInvoice.LedgerDimension = LedgerDynamicAccountHelper::getDynamicAccountFromAccountNumber(vendorAccountNum, LedgerJournalACType::Vend);
ledgerJournalTransVendInvoice.AccountType = LedgerJournalACType::Vend;
ledgerJournalTransVendInvoice.OffsetAccountType = LedgerJournalACType::Ledger;
ledgerJournalTransVendInvoice.Payment = '100% Advance';
ledgerJournalTransVendInvoice.TransactionType = LedgerTransType::Vend;
conOffsetValues += businessUnit;
conOffsetValues += itemId;
conOffsetValues += vendorAccountNum;
offsetLedgerDimension = this.getLedgerDim(offsetAccountNum, vendorAccountNum, businessUnit, itemId);
ledgerJournalTransVendInvoice.OffsetLedgerDimension = offsetLedgerDimension;
ledgerJournalTransVendInvoice.insert();
AcxBulkTagDestroy.JournalNum = journalId;
generateButton.enabled(true);
AcxBulkTagDestroy_AccountId.enabled(false);
AcxBulkTagDestroy_ds.research(true);
ttsCommit;
}
catch (Exception::Error)
{
ttsAbort;
error("Error occurred during journal creation or data insertion. Please try again.");
}
}
public int64 getLedgerDim(MainAccountNum _mainAccountNum, str _vendorAccountNum, str _businessUnit, str _itemId)
{
LedgerAccountContract ledgerAccountContract = new LedgerAccountContract();
DimensionAttributeValueContract dimensionAttributeValueContract;
List valueContracts = new List(Types::Class);
MainAccount mainAccount = MainAccount::findByMainAccountId(_mainAccountNum);
ledgerAccountContract.parmMainAccount(mainAccount.MainAccountId);
dimensionAttributeValueContract = DimensionAttributeValueContract::construct('BusinessUnit', _businessUnit);
valueContracts.addEnd(dimensionAttributeValueContract);
dimensionAttributeValueContract = DimensionAttributeValueContract::construct('ItemGroup', _itemId);
valueContracts.addEnd(dimensionAttributeValueContract);
dimensionAttributeValueContract = DimensionAttributeValueContract::construct('Vendor', _vendorAccountNum);
valueContracts.addEnd(dimensionAttributeValueContract);
ledgerAccountContract.parmValues(valueContracts);
DimensionStorage dimStorage = DimensionServiceProvider::buildDimensionStorageForLedgerAccount(ledgerAccountContract);
DimensionAttributeValueCombination dimensionAttributeValueCombination = DimensionAttributeValueCombination::find(dimStorage.save());
return dimensionAttributeValueCombination.RecId;
}
}
ledgerJournalTransVendInvoice.OffsetLedgerDimension = offsetLedgerDimension;
ledgerJournalTransVendInvoice.insert();
TransTaxInformation transTaxInfo =
TransTaxInformationHelper::findOrCreateTransTaxInformationByRecord(ledgerJournalTransVendInvoice);
if (transTaxInfo)
{
//transTaxInfo.selectForUpdate(true);
transTaxInfo.ServiceCode = 4587;
// transTaxInfo.update();
}
AcxBulkTagDestroy.JournalNum = journalId;
generateButton.enabled(true);
AcxBulkTagDestroy_AccountId.enabled(false);
AcxBulkTagDestroy_ds.research(true);
ttsCommit;
André Arnaud de Cal...
293,663
Super User 2025 Season 1
Martin Dráb
232,672
Most Valuable Professional
nmaenpaa
101,158
Moderator