Hi,
I need generate voucher with CustVendVoucher with the goal replicate method post of TrvPost, but only generate the voucher without transactions. This is my code:
public static Voucher grwPostCustVendTransactions( TrvExpTable _trvExpTable,
CustVendAC _custVendAccount,
AmountCur _transactionAmount,
CurrencyCode _transactionCurrency,
TrvDateStd _transDate,
ExchRate _exchRate,
TransTxt _transTxt,
InvoiceId _invoiceId,
DimensionDefault _defaultDimension = 0)
{
DimensionDefault defaultDimension;
VendVoucher custVendVoucher;
SysModule module;
LedgerTransTxt ledgerTransTxt = LedgerTransTxt::None;
PostingProfile postingProfile = '';
VendTable vendTable;
CustVoucher custVoucher;
VendTrans vendTrans;
CustTrans custTrans;
Voucher voucherNum;
TrvExpTrans trvExpTrans;
LedgerVoucher ledgerVoucher;
NumberSequenceCode voucherSeriesCode;
LedgerVoucherObject ledgerVoucherObject;
NumberSequenceReference numberSequenceReference;
LedgerVoucherTransObject ledgerVoucherTransObject, ledgerVoucherTransObject2;
numberSequenceReference = TrvParameters::numRefExpenseVoucher();
if(numberSequenceReference.RecId == 0)
{
error("@SYS305186");
return "";
}
voucherSeriesCode = numberSequenceReference.numberSequenceTable().NumberSequence;
voucherNum = NumberSeq::newGetVoucherFromCode(voucherSeriesCode, NumberSeqScopeFactory::createDataAreaScope(), true).voucher();
module = SysModule::Vend;
ledgerVoucher = LedgerVoucher::newLedgerPost(DetailSummary::Detail, SysModule::Ledger, voucherSeriesCode);
ledgerVoucherObject = LedgerVoucherObject::newVoucher( voucherNum,
today(),
SysModule::Ledger);
ledgerVoucher.addVoucher(ledgerVoucherObject);
defaultDimension = VendTable::find(_custVendAccount).DefaultDimension;
// Initialize custVendVoucher
custVendVoucher = CustVendVoucher::construct(module,
_custVendAccount,
_transactionAmount,
_transactionCurrency,
ledgerTransTxt,
defaultDimension,
postingProfile,
LedgerPostingType::VendBalance);
custVendVoucher.parmTransDate(_transDate);
custVendVoucher.parmExchRate(_exchRate);
custVendVoucher.parmTransVoucher(voucherNum);
custVendVoucher.parmTransTxt(_transTxt);
custVendVoucher.parmDocumentDate(_trvExpTable.trvReportDate());
custVendVoucher.parmDocumentNum(_trvExpTable.ExpNumber);
custVendVoucher.parmInvoiceId(_invoiceId);
custVendVoucher.parmCustVendNegInstStatus(CustVendNegInstStatus::Invoiced);
custVendVoucher.parmApproved(NoYes::Yes);
custVendVoucher.parmApprover(currentWorker());
//agregar las transacciones
ledgerVoucherTransObject = ledgerVoucherTransObject::newBasicDefault(ledgerVoucherObject, LedgerPostingType::LedgerJournal,
DimensionStorage::accountNum2LedgerDimension(vendTable.AccountNum,LedgerJournalACType::Vend), _transactionCurrency,
_transactionAmount, _transactionAmount, _transactionAmount);
ledgerVoucherTransObject2 = ledgerVoucherTransObject::newBasicDefault(ledgerVoucherObject, LedgerPostingType::LedgerJournal,
DimensionStorage::accountNum2LedgerDimension(vendTable.AccountNum,LedgerJournalACType::Vend), _transactionCurrency,
-1*_transactionAmount, -1*_transactionAmount, -1*_transactionAmount);
ledgerVoucherObject.addTrans(ledgerVoucherTransObject);
ledgerVoucherObject.addTrans(ledgerVoucherTransObject2);
//
if(module == SysModule::Vend)
{
vendTable = VendTable::find(_custVendAccount);
if(vendTable)
{
custVendVoucher.parmPaymId(vendTable.PaymId);
custVendVoucher.parmPaymMode(vendTable.PaymMode);
custVendVoucher.parmPaymTermId(vendTable.PaymTermId);
custVendVoucher.parmPaymSpec(vendTable.PaymSpec);
custVendVoucher.parmThirdPartyBankAccountId(vendtable.BankAccount);
custVendVoucher.parmTransType(LedgerTransType::Vend);
}
}
/*if(module == SysModule::Cust)
{
custVoucher = custVendVoucher;
custVoucher.setTransRef(CustTransRefType::Invoice, _invoiceId );
}*/
//Post custVendVoucher
if (custVendVoucher.validate())
{
if(module == SysModule::Vend)
{
custVendVoucher.post(ledgerVoucher, vendTrans);
}
else
{
custVendVoucher.post(ledgerVoucher, custTrans);
}
}
return voucherNum;
}
And, for test, I create the next job:
static void EAVTEST3(Args _args)
{
TrvPost::grwPostCustVendTransactions(TrvExpTable::find("DVINCG0000691"),
"DVIP0000046",
300,
Ledger::accountingCurrency(),
today(),
100,
"TEST_GRW",
"INV6");
info("termino");
}
*This post is locked for comments
I have the same question (0)

Report
All responses (
Answers (