22.03.2015, 01:28 | #1 |
Талантливый разгвоздяй
|
AX 2012 R2, R3: Утверждение спланированных заказов и Договоры
AX 2012 R2 CU7, R3 CU8.
При утверждении спланированных заказов в AX 2012 R2, R3 есть возможность группировать заказы по договорам, если включены соответствующие параметры сводного планирования. Хочу разобраться по какому принципу системы подбирает наиболее подходящий договор, но столкнулся с отсутствуем документации по теме. Копнул глубже и нашел такой нетленный код: \Data Dictionary\Tables\AgreementLine\Methods\getAgreementLinesForOrderLine X++: /// <summary> /// Retrieves the list of the agreement lines that match to the sales or purchase line. /// </summary> /// <param name="_salesPurchLine"> /// The sales or purchase line for which to find the agreement lines. /// </param> /// <param name="_matchingAgreement"> /// The record ID of the agreement header. /// </param> /// <param name="_getAll"> /// A Boolean value that indicates whether to retrieve all agreement lines that match; optional. /// </param> /// <returns> /// The list of the found agreement lines packed into the container. /// </returns> /// <remarks> /// If the <paramref name="_getAll" /> parameter is false, the optimization will be done. The agreement /// lines will not be added to the list if they have lower priority than the lines already added to the /// list. The item based agreement lines have more priority than the category based agreement lines.If /// the <paramref name="_getAll" /> parameter is true, all found agreement lines will be added to the /// list. /// </remarks> public server static container getAgreementLinesForOrderLine(SalesPurchLine _salesPurchLine, AgreementHeaderRecId _matchingAgreement, boolean _getAll = false) { SalesLine salesLine; PurchLine purchLine; date expDate; ProjId projId; AgreementLineQuantityCommitment agreementLineQuantity; AgreementLineVolumeCommitment agreementLineVolume; AgreementHeader agreementHeader; PurchAgreementHeader purchAgreementHeader; SalesAgreementHeader salesAgreementHeader; Common salesPurchAgreementHeader; fieldId custVendAccountFieldId; CustVendAC custVendAccount; InventDim inventDim; InventDim salesPurchLineInventDim = _salesPurchLine.inventDim(); EcoResCategoryId category = _salesPurchLine.Category; EcoResCategoryId rootCategory; EcoResCategoryNamedHierarchyRole hierarchyRole; List resultList = new List(Types::Record); List categoryList = new List(Types::Record); List rootCategoryList = new List(Types::Record); #localmacro.AgreementLineSelect //%1 AgreementLine subtype table select %1 where (!_matchingAgreement || %1.Agreement == _matchingAgreement) && %1.IsDeleted == NoYes::No && %1.expirationDate >= expDate && %1.effectiveDate <= expDate && ((_salesPurchLine.TableId == tablenum(PurchLine) && (%1.ProjectProjId == projId || %1.ProjectProjId == '')) || (_salesPurchLine.TableId == tablenum(SalesLine) && %1.ProjectProjId == projId)) && %1.InventDimDataAreaId == appl.company().dataArea(tablenum(InventDim)) && ((_salesPurchLine.ItemId && %1.ItemId == _salesPurchLine.ItemId && %1.ItemDataAreaId == appl.company().dataArea(tablenum(InventTable))) || (!%1.ItemId && (%1.Category == category || %1.Category == rootCategory))) #endmacro #localmacro.AgreementLineQuantityCommitmentCondition (_salesPurchLine.LineDeliveryType != LineDeliveryType::OrderLineWithMultipleDeliveries || AgreementLineQuantity.IsMaxEnforced == NoYes::No || AgreementLineQuantity.ProductUnitOfMeasure == _salesPurchLine.PurchSalesUnit) #endmacro #localmacro.AgreementLineHeaderExistsJoin //%1 AgreementLine subtype table exists join agreementHeader where agreementHeader.RecId == %1.Agreement && agreementHeader.IsDeleted == NoYes::No && agreementHeader.AgreementState == AgreementState::Effective #endmacro #localmacro.AgreementVendCustAccountExistsJoin //%1 - AgreementLine subtype table exists join salesPurchAgreementHeader where salesPurchAgreementHeader.RecId == %1.Agreement && (_matchingAgreement || (salesPurchAgreementHeader.(custVendAccountFieldId) == custVendAccount)) #endmacro void addToList(AgreementLine _aLine) { if (_getAll) { resultList.addEnd(_aLine); } else { if (_aLine.ItemId) { resultList.addEnd(_aLine); } else if (resultList.empty()) //do not add the category agreement lines if item agreement lines are already found { if (_aLine.Category != rootCategory) { categoryList.addEnd(_aLine); } else if (categoryList.empty()) //do not add the root category agreement lines if category agreement lines are already found { rootCategoryList.addEnd(_aLine); } } } } switch (_salesPurchLine.TableId) { case tableNum(SalesLine): salesLine = _salesPurchLine; expDate = salesLine.ShippingDateRequested ? salesLine.ShippingDateRequested : systemDateGet(); projId = salesLine.ProjId; hierarchyRole = EcoResCategoryNamedHierarchyRole::Sales; salesPurchAgreementHeader = salesAgreementHeader; custVendAccount = salesLine.CustAccount; custVendAccountFieldId = fieldNum(SalesAgreementHeader, CustAccount); break; case tableNum(PurchLine): purchLine = _salesPurchLine; expDate = purchLine.DeliveryDate ? purchLine.DeliveryDate : systemDateGet(); projId = purchLine.ProjId; hierarchyRole = EcoResCategoryNamedHierarchyRole::Procurement; salesPurchAgreementHeader = purchAgreementHeader; custVendAccount = purchLine.VendAccount; custVendAccountFieldId = fieldNum(PurchAgreementHeader, VendAccount); break; } if (!category) { category = EcoResProductCategory::findByItemIdCategoryHierarchyRole(_salesPurchLine.ItemId, hierarchyRole).Category; } rootCategory = EcoResCategory::getRoot(EcoResCategoryHierarchyRole::getHierarchiesByRole(hierarchyRole).CategoryHierarchy).RecId; while #AgreementLineSelect(AgreementLineQuantity) && #AgreementLineQuantityCommitmentCondition #AgreementInventDimExistsJoin(AgreementLineQuantity.InventDimId, inventDim, salesPurchLineInventDim) #AgreementLineHeaderExistsJoin(AgreementLineQuantity) && (agreementLineQuantity.IsPriceInformationMandatory == NoYes::No || agreementHeader.Currency == _salesPurchLine.CurrencyCode) #AgreementVendCustAccountExistsJoin(AgreementLineQuantity) { addToList(agreementLineQuantity); } while #AgreementLineSelect(AgreementLineVolume) #AgreementInventDimExistsJoin(agreementLineVolume.InventDimId, inventDim, salesPurchLineInventDim) #AgreementLineHeaderExistsJoin(AgreementLineVolume) && agreementHeader.Currency == _salesPurchLine.CurrencyCode #AgreementVendCustAccountExistsJoin(AgreementLineVolume) { addToList(agreementLineVolume); } if (_getAll || !resultList.empty()) { return resultList.pack(); } if (!categoryList.empty()) { return categoryList.pack(); } return rootCategoryList.pack(); } X++: while #AgreementLineSelect(AgreementLineQuantity)
&& #AgreementLineQuantityCommitmentCondition
#AgreementInventDimExistsJoin(AgreementLineQuantity.InventDimId, inventDim, salesPurchLineInventDim)
#AgreementLineHeaderExistsJoin(AgreementLineQuantity)
&& (agreementLineQuantity.IsPriceInformationMandatory == NoYes::No
|| agreementHeader.Currency == _salesPurchLine.CurrencyCode)
#AgreementVendCustAccountExistsJoin(AgreementLineQuantity)
{
addToList(agreementLineQuantity);
}
Последний раз редактировалось Kabardian; 22.03.2015 в 02:06. Причина: Восстановление темы |
|
22.03.2015, 09:42 | #2 |
Участник
|
3. Определение в \Macros\AgreementInventDimExistsJoin
__________________
AxAssist 2012 - Productivity Tool for Dynamics AX 2012/2009/4.0/3.0 |
|
|
За это сообщение автора поблагодарили: Kabardian (1). |
22.03.2015, 11:38 | #3 |
Талантливый разгвоздяй
|
|
|
22.03.2015, 12:13 | #4 |
Участник
|
Цитата:
xpp компилятор заменяеть макрос из AOT на тело макроса перед компиляцией. Далее копилирует то что получилось. Если у вас в макросе код, то компилятор вставит этот код в тело метода и откомпилирует то что получилось. Если у вас в макросе кучу #define, тогда имеет смысл вставить их в начале метода, чтобы #define были видны во всем методе. Посмотрите макросы начинающиеся на InventDim*.
__________________
AxAssist 2012 - Productivity Tool for Dynamics AX 2012/2009/4.0/3.0 Последний раз редактировалось Alex_KD; 22.03.2015 в 12:19. |
|
22.03.2015, 12:33 | #5 |
Талантливый разгвоздяй
|
|
|
|
|