Код:
protected void postLedgerTrans(kasRRepRepairLine _repairLine)
{
LedgerVoucher ledgerVoucher;
LedgerVoucherObject ledgerVoucherObject;
LedgerVoucherTransObject ledgerVoucherTransObject;
TransactionTxt transactionTxt;
LedgerBondClient_RU ledgerBondClient;
NumberSeq numberSeq;
Voucher voucherId;
kasRRepEquipmentTable equipmentTable;
kasRRepEquipmentGroup equipmentGroup;
TransDate transDate = _repairLine.FinishDate;
AmountMST amount = _repairLine.Rate * _repairLine.duration();
;
numberSeq = NumberSeq::newGetNum(ProdParameters::numRefProdJournalVoucherId());
voucherId = numberSeq.num();
transactionTxt = new TransactionTxt();
transactionTxt.setType(LedgerTransTxt::None);
transactionTxt.setDate(transDate);
transactionTxt.setVoucher(voucherId);
transactionTxt.txt(_repairLine.Note);
ledgerVoucherObject = LedgerVoucherObject::newVoucher(voucherId,
transDate,
SysModule::System,
LedgerTransType::None,
NoYes::No);
ledgerVoucher = LedgerVoucher::newLedgerPost(DetailSummary::Summary, SysModule::System, voucherId);
ledgerVoucher.parmVoucherSeriesCode(numberSeq.parmNumberSequenceCode());
ledgerVoucher.AddVoucher(ledgerVoucherObject);
ledgerBondClient = ledgerVoucher.findLedgerVoucherObject().ledgerBondClient_RU();
select firstonly equipmentTable
index hint EquipmentIdx
join equipmentGroup
index hint EquipmentGroupIDX
where equipmentTable.EquipmentID == _repairLine.EquipmentID &&
equipmentGroup.EquipmentGroupID == equipmentTable.EquipmentGroupID;
if (ledgerBondClient)
{
ledgerBondClient.addNewLogObject();
}
ledgerVoucherTransObject =
LedgerVoucherTransObject::newCreateTrans(ledgerVoucher.findLedgerVoucherObject(),
LedgerPostingType::Allocation,
equipmentGroup.AccountNum,
Dimensions::emptyDimension(),
CompanyInfo::standardCurrency(),
amount,
_repairLine.RecId);
ledgerVoucherTransObject.parmTransTxt(transactionTxt.txt());
ledgerVoucher.addTrans(ledgerVoucherTransObject);
ledgerVoucherTransObject =
LedgerVoucherTransObject::newCreateTrans(ledgerVoucher.findLedgerVoucherObject(),
LedgerPostingType::Allocation,
kasRRepRepairType::find(_repairLine.RepairTypeID).AccountNum,
Dimensions::emptyDimension(),
CompanyInfo::standardCurrency(),
-(amount),
_repairLine.RecId);
ledgerVoucherTransObject.parmTransTxt(transactionTxt.txt());
ledgerVoucher.addTrans(ledgerVoucherTransObject);
if (ledgerBondClient)
{
if (ledgerBondClient.currentLogLength() == 2)
ledgerBondClient.bondLastVRef2CurrentLog();
ledgerBondClient.removeCurrentLogObject();
}
ledgerVoucher.end();
}