![]() |
#5 |
Участник
|
Цитата:
Проблема действительно есть. И мы её лечили таким же способом как предлагает Aquarius. У нас тоже Ax2009 SP5 Когда делали сторно дважды в разных месяцах, то номер возвращаемого лота заполнен автоматом. (Мы это делали через немедленное получение, получалось что номера лота и лота возврата совпадали, хотя по-моему для обсуждаемой проблемы это несущественно) Пример исправления : Класс InventCostItemDim Исправление в двух методах : X++: protected void updateTransIdReturnReceipt( InventTransId _inventTransId, InventTransId _inventTransIdReturn, Price _costPrice = 0 // if 0 then it will be recalculated ) { InventTrans receipt; InventTrans issue; CostAmount adjustNow; boolean onHandIsAdjusted; ; if (!_inventTransId || !_inventTransIdReturn) return; if (!_costPrice) { // GRD_R3790_FixInventCostItemDim_pkoz //pkoz 20.09.2011 --> if ( InventCostItemDim::is3790_FixInentTransIdReturn()) { select sum(Qty), sum(CostAmountAdjustment), sum(CostAmountPosted) from issue index hint TransIdIdx where issue.InventTransId == _inventTransIdReturn && issue.StatusReceipt == StatusReceipt::None && issue.StatusIssue == StatusIssue::Sold && issue.PackingSlipReturned == 0 && issue.InventTransIdReturn == _inventTransId && issue.DateStatus <= inventClosing.TransDate; if (!issue.Qty ) { select sum(Qty), sum(CostAmountAdjustment), sum(CostAmountPosted) from issue index hint TransIdIdx where issue.InventTransId == _inventTransIdReturn && issue.StatusReceipt == StatusReceipt::None && issue.StatusIssue == StatusIssue::Sold && issue.PackingSlipReturned == 0 && issue.InventTransIdReturn == _inventTransId; } } else // GRD_R3790_FixInventCostItemDim_pkoz //pkoz 20.09.2011 <-- select sum(Qty), sum(CostAmountAdjustment), sum(CostAmountPosted) from issue index hint TransIdIdx where issue.InventTransId == _inventTransIdReturn && issue.StatusReceipt == StatusReceipt::None && issue.StatusIssue == StatusIssue::Sold && issue.PackingSlipReturned == 0 && issue.InventTransIdReturn == _inventTransId; if (!issue.Qty ) return; _costPrice = (issue.costAmountPosted + issue.costAmountAdjustment) / issue.Qty; } onHandIsAdjusted = InventAdj::isOnhandAdjusted(_inventTransId, _inventTransIdReturn, ''); while select forupdate receipt index hint TransIdIdx where receipt.InventTransId == _inventTransId && receipt.StatusReceipt == StatusReceipt::Purchased && receipt.StatusIssue == StatusIssue::None && receipt.PackingSlipReturned == 0 && receipt.InventTransIdReturn == _inventTransIdReturn && receipt.DateStatus <= inventClosing.TransDate { adjustNow = Currency::amount(receipt.Qty * _costPrice - receipt.CostAmountPosted - receipt.CostAmountAdjustment,standardCurrency); if (adjustNow) { receipt.CostAmountAdjustment += adjustNow; this.createAdjustSettlement(receipt, adjustNow, ''); // The adjustment for a std cost item will always be // reverted to bring the item cost down to std cost // So there is no need to create an adjustment. /* <SYS> if (!this.inventModelGroup(receipt.ItemId).inventModelType().stdCostBased()) </SYS> */ // <GEEU> if (! this.inventModelType_RU(receipt.ItemId).stdCostBased()) // </GEEU> { if (onHandIsAdjusted) { this.createErrorAdjustment(receipt, -adjustNow); } if (this.costValue(receipt) < 0) this.createErrorAdjustment(receipt, -adjustNow); if ((inventClosing.AdjustmentType == InventAdjustmentType::Closing) && (abs(adjustNow) < inventClosing.MinTransferValue || inventClosing.NumOfIteration >= inventClosing.MaxIterations)) { this.createErrorAdjustment(receipt, -adjustNow); } } else { /* <SYS> this.inventModelGroup(receipt.ItemId).inventModelType().postUpdateFinancialAdjustment(receipt, inventClosing.Voucher, inventClosing.TransDate, adjustNow); </SYS> */ // <GEEU> this.inventModelType_RU(receipt.ItemId).postUpdateFinancialAdjustment(receipt, inventClosing.Voucher, inventClosing.TransDate, adjustNow); // </GEEU> } this.updateCostAmountStd(receipt); receipt.update(); } mapInventTrans.insert(receipt.RecId, receipt); } } X++: /// <summary> /// Adjust the cost of item return receipts to that of the corresponding issues. /// </summary> /// <param name="_itemId"> /// The item ID for which to adjust the return receipts. /// </param> protected void updateItemReturnAdjustments(ItemId _itemId = inventCostList.ItemId) { InventTrans inventTrans; InventTrans issue; Price costPrice; CostAmount adjustment; // <GEEU> InventDim inventDim; InventLocation inventLocation; // </GEEU> ; while select sum(Qty), sum(CostAmountAdjustment), sum(CostAmountPosted) from inventTrans index hint StatusItemIdx group by InventTransId, InventTransIdReturn where inventTrans.ItemId == _itemId && inventTrans.ValueOpen == InventTransOpen::Yes && inventTrans.StatusReceipt == StatusReceipt::Purchased && inventTrans.StatusIssue == StatusIssue::None && inventTrans.DateStatus <= inventClosing.TransDate && inventTrans.PackingSlipReturned == 0 && inventTrans.InventTransIdReturn != '' && ( inventTrans.TransType == InventTransType::Sales || inventTrans.TransType == InventTransType::BOMLine || inventTrans.TransType == InventTransType::InventLossProfit || inventTrans.TransType == InventTransType::InventTransaction || inventTrans.TransType == InventTransType::Project || inventTrans.TransType == InventTransType::ProdLine // <GEEU> || (inventTrans.TransType == InventTransType::ProdRelease_RU && featuresRUIsEnabled_RU) // </GEEU> ) { // GRD_R3790_FixInventCostItemDim_pkoz //pkoz 20.09.2011 --> if ( InventCostItemDim::is3790_FixInentTransIdReturn()) { select sum(Qty), sum(CostAmountAdjustment), sum(CostAmountPosted) from issue index hint TransIdIdx where issue.InventTransId == inventTrans.InventTransIdReturn && issue.StatusReceipt == StatusReceipt::None && issue.StatusIssue == StatusIssue::Sold && issue.PackingSlipReturned == 0 && issue.InventTransIdReturn == inventTrans.InventTransId && issue.DateStatus <= inventClosing.TransDate; if (!issue.Qty) { select sum(Qty), sum(CostAmountAdjustment), sum(CostAmountPosted) from issue index hint TransIdIdx where issue.InventTransId == inventTrans.InventTransIdReturn && issue.StatusReceipt == StatusReceipt::None && issue.StatusIssue == StatusIssue::Sold && issue.PackingSlipReturned == 0 && issue.InventTransIdReturn == inventTrans.InventTransId; } } else // GRD_R3790_FixInventCostItemDim_pkoz //pkoz 20.09.2011 <-- select sum(Qty), sum(CostAmountAdjustment), sum(CostAmountPosted) from issue index hint TransIdIdx where issue.InventTransId == inventTrans.InventTransIdReturn && issue.StatusReceipt == StatusReceipt::None && issue.StatusIssue == StatusIssue::Sold && issue.PackingSlipReturned == 0 && issue.InventTransIdReturn == inventTrans.InventTransId; if (issue.Qty) { costPrice = (issue.CostAmountPosted + issue.CostAmountAdjustment) / issue.Qty; adjustment = Currency::amount(inventTrans.Qty * costPrice - inventTrans.CostAmountPosted - inventTrans.CostAmountAdjustment,standardCurrency); if (abs(adjustment) >= inventClosing.MinTransferValue && !InventAdj::isOnhandAdjusted(inventTrans.InventTransId, inventTrans.InventTransIdReturn, '')) this.updateTransIdReturnReceipt(inventTrans.InventTransId, inventTrans.InventTransIdReturn, costPrice); } } // <GEEU> if (! featuresRUIsEnabled_RU) return; while select sum(Qty), sum(CostAmountAdjustment), sum(CostAmountPosted) from inventTrans index hint StatusItemIdx group by InventTransId, InventTransIdReturn where inventTrans.ItemId == _itemId && inventTrans.ValueOpen == InventTransOpen::Yes && inventTrans.StatusReceipt == StatusReceipt::Purchased && inventTrans.StatusIssue == StatusIssue::None && inventTrans.DateStatus <= inventClosing.TransDate && inventTrans.PackingSlipReturned == 0 && inventTrans.InventTransIdReturn != '' && (inventTrans.TransType == InventTransType::TransferOrderScrap || inventTrans.TransType == InventTransType::TransferOrderShip || inventTrans.TransType == InventTransType::TransferOrderReceive) exists join inventDim where inventDim.InventDimId == inventTrans.InventDimId exists join inventLocation where inventLocation.InventLocationId == inventDim.InventLocationId && (inventTrans.TransType == InventTransType::TransferOrderScrap || (inventTrans.TransType == InventTransType::TransferOrderShip && inventLocation.InventLocationType == InventLocationType::Standard) || (inventTrans.TransType == InventTransType::TransferOrderReceive && inventLocation.InventLocationType == InventLocationType::Transit)) { select sum(Qty), sum(CostAmountAdjustment), sum(CostAmountPosted) from issue index hint TransIdIdx where issue.InventTransId == inventTrans.InventTransIdReturn && issue.StatusReceipt == StatusReceipt::None && issue.StatusIssue == StatusIssue::Sold && issue.PackingSlipReturned == 0 && issue.InventTransIdReturn == inventTrans.InventTransId; if (issue.Qty) { costPrice = (issue.CostAmountPosted + issue.CostAmountAdjustment) / issue.Qty; adjustment = Currency::amount(inventTrans.Qty * costPrice - inventTrans.CostAmountPosted - inventTrans.CostAmountAdjustment,standardCurrency); if (abs(adjustment) >= inventClosing.MinTransferValue && !InventAdj::isOnhandAdjusted(inventTrans.InventTransId, inventTrans.InventTransIdReturn, '')) this.updateTransIdReturnReceipt(inventTrans.InventTransId, inventTrans.InventTransIdReturn, costPrice); } } // </GEEU> } |
|
|
За это сообщение автора поблагодарили: gl00mie (5), Aquarius (1). |