Ax 2012\D365 : Cheque creation code
public void createCheque(Args args)
{
LedgerJournalTrans ledgerJournalTrans;
BankAccountTable bankAccountTable;
BankChequeTable bankChequeTable;
DimensionAttributeValueCombination dimensionAttributeValueCombination;
select firstonly forupdate ledgerJournalTrans
where ledgerJournalTrans.JournalNum == '12345' &&
ledgerJournalTrans.linenum == 1; ledgerJournalTrans.LineNum == 1;
if (ledgerJournalTrans.AmountCurDebit)
{
select firstonly DisplayValue
from dimensionAttributeValueCombination
where dimensionAttributeValueCombination.RecId == ledgerJournalTrans.LedgerDimension;
bankChequeTable.clear();
bankChequeTable.ChequeNum = ledgerJournalTrans.PLI_BankChequeNum;
bankChequeTable.ChequeStatus = ChequeStatus::Payment;
bankChequeTable.AccountID = bankAccountTable.AccountId;
bankChequeTable.RecipientType = BankChequeRecipientType::Cust;
bankChequeTable.AmountCur = ledgerJournalTrans.AmountCurDebit;
bankChequeTable.BankCurrencyAmount = ledgerJournalTrans.AmountCurDebit;
bankChequeTable.RecipientCompany = ledgerJournalTrans.Company;
bankChequeTable.TransDate = staging.TransactionDate ;
bankChequeTable.CurrencyCode = ledgerjournalTrans.CurrencyCode;
bankChequeTable.BankCurrency = ledgerjournalTrans.CurrencyCode;
bankChequeTable.RecipientAccountNum = dimensionAttributeValueCombination.DisplayValue;
bankChequeTable.Voucher = ledgerjournalTrans.Voucher;
bankChequeTable.RecipientTransVoucher = ledgerjournalTrans.Voucher;
bankChequeTable.SourceTableId = ledgerjournalTrans.TableId;
bankChequeTable.SourceRecId = ledgerjournalTrans.RecId;
if (BankChequeTable::exist(ledgerJournalTrans.PLI_BankChequeNum, ledgerjournalTrans.PLI_Account))
{
checkFailed(strfmt("@SYS24139", bankChequeTable.ChequeNum));
throw error("@SYS18447");
}
bankChequeTable.insert();
ttsbegin;
ledgerJournalTrans.BankChequeNum = bankChequeTable.ChequeNum;
ledgerjournalTrans.PaymentStatus = CustVendPaymStatus::Sent;
ledgerJournalTrans.PaymReference = bankChequeTable.ChequeNum;
ledgerJournalTrans.update();
ttscommit;
}
}
{
LedgerJournalTrans ledgerJournalTrans;
BankAccountTable bankAccountTable;
BankChequeTable bankChequeTable;
DimensionAttributeValueCombination dimensionAttributeValueCombination;
select firstonly forupdate ledgerJournalTrans
where ledgerJournalTrans.JournalNum == '12345' &&
ledgerJournalTrans.linenum == 1; ledgerJournalTrans.LineNum == 1;
if (ledgerJournalTrans.AmountCurDebit)
{
select firstonly DisplayValue
from dimensionAttributeValueCombination
where dimensionAttributeValueCombination.RecId == ledgerJournalTrans.LedgerDimension;
bankChequeTable.clear();
bankChequeTable.ChequeNum = ledgerJournalTrans.PLI_BankChequeNum;
bankChequeTable.ChequeStatus = ChequeStatus::Payment;
bankChequeTable.AccountID = bankAccountTable.AccountId;
bankChequeTable.RecipientType = BankChequeRecipientType::Cust;
bankChequeTable.AmountCur = ledgerJournalTrans.AmountCurDebit;
bankChequeTable.BankCurrencyAmount = ledgerJournalTrans.AmountCurDebit;
bankChequeTable.RecipientCompany = ledgerJournalTrans.Company;
bankChequeTable.TransDate = staging.TransactionDate ;
bankChequeTable.CurrencyCode = ledgerjournalTrans.CurrencyCode;
bankChequeTable.BankCurrency = ledgerjournalTrans.CurrencyCode;
bankChequeTable.RecipientAccountNum = dimensionAttributeValueCombination.DisplayValue;
bankChequeTable.Voucher = ledgerjournalTrans.Voucher;
bankChequeTable.RecipientTransVoucher = ledgerjournalTrans.Voucher;
bankChequeTable.SourceTableId = ledgerjournalTrans.TableId;
bankChequeTable.SourceRecId = ledgerjournalTrans.RecId;
if (BankChequeTable::exist(ledgerJournalTrans.PLI_BankChequeNum, ledgerjournalTrans.PLI_Account))
{
checkFailed(strfmt("@SYS24139", bankChequeTable.ChequeNum));
throw error("@SYS18447");
}
bankChequeTable.insert();
ttsbegin;
ledgerJournalTrans.BankChequeNum = bankChequeTable.ChequeNum;
ledgerjournalTrans.PaymentStatus = CustVendPaymStatus::Sent;
ledgerJournalTrans.PaymReference = bankChequeTable.ChequeNum;
ledgerJournalTrans.update();
ttscommit;
}
}
No comments:
Post a Comment