// VAR Changed by Xie Yu Fan.Fandy 谢宇帆 inventJournalTable createPLInventJournalTrans(boolean _autoPostJournal = false) { InventJournalTable inventJournalTable; InventJournalTrans inventJournalTrans; inventJournalCheckPost inventJournalCheckPost; InventJournalNameId inventJournalNameId = InventParameters::find().YIP_LossProfitJounalNameSection; InventTable inventTable = InventTable::find(this.ItemId); YIP_InventTransferSectionDetails details; InventTransferLine line; boolean checkBeforReceive() { boolean ret = true; YIP_InventTransferSectionDetails table; int lastSectionId; ; if (!inventJournalNameId) ret = checkFailed("请在库存参数中设置默认的盈亏日记账名称."); if (inventJournalNameId && inventJournalName::find(inventJournalNameId).JournalType != InventJournalType::LossProfit) ret = checkFailed(strfmt("%1 必须为 %2 日记账.", inventJournalNameId, InventJournalType::LossProfit)); /* select firstonly details index hint SectionIndex where details.TransferId == this.TransferId && details.InventTransId == this.InventTransId && details.LineNum == this.LineNum && details.TransferStatus< InventTransferStatus::Received; if (details) { ret = checkFailed(strfmt("发货、收货明细行尚未全部确认[%1,%2,%3].", this.TransferId, this.InventTransId, this.ItemId)); } lastSectionId = YIP_InventTranferSection::getLastSectionId(this.TransferId); select sum(QtyReceive) from table where table.InventTransId == this.InventTransId && table.LineNum == this.LineNum && table.SectionId == lastSectionId && table.TransferStatus == InventTransferStatus::Received; if (!table.QtyReceive) { throw checkFailed(strfmt("尚未完全交货.")); } */ return ret; } ; if (!checkBeforReceive()) throw error("取消盈亏日记账."); line = this.inventTransferLine(); // header inventJournalTable.clear(); InventJournalTable.initValue(); InventJournalTable.initFromInventJournalName(InventJournalName::find(inventJournalNameId)); InventJournalTable.JournalType = InventJournalType::LossProfit; InventJournalTable.Description += strfmt("(%1,%2,%3)", this.TransferId, this.InventTransId, this.ItemId); InventJournalTable.NumOfLines = 1; InventJournalTable.write(); // lines inventJournalTrans.clear(); inventJournalTrans.initValue(); inventJournalTrans.initFromInventJournalTable(InventJournalTable); inventJournalTrans.initFromInventTable(inventTable); inventJournalTrans.Dimension = line.inventTransferTable().YIP_Dimension; inventJournalTrans.YIP_PackQty = line.YIP_getQtyReceivedSection() - line.YIP_getQtyShippedSection(); inventJournalTrans.modifiedField(fieldnum(InventJournalTrans, YIP_PackQty)); inventJournalTrans.Qty = inventJournalTrans.YIP_Convert2InventQty(inventJournalTrans.YIP_PackQty); inventJournalTrans.InventDimId = line.inventDimReceive().inventDimId; inventJournalTrans.setCostPrice(inventJournalTrans.InventDimId, inventJournalTrans.inventDim(), inventJournalTrans.inventTableModuleInvent()); inventJournalTrans.write(); if (_autoPostJournal) { inventJournalCheckPost = InventJournalCheckPost::newPostJournal(inventJournalTable); inventJournalCheckPost.run(); } return InventJournalTable; }