Olá Pessoal,
Tudo bem?
Precisei criar um diário de contrato de preço/desconto no Microsoft Dynamics AX 2012 via X++. Estou compartilhando com vocês caso venham a precisar.
private PriceDiscAdmTable createPriceDiscAdmTable() { PriceDiscAdmName priceDiscAdmName; journalName = ProdImportDataStandardLESI::find().JournalName; if (journalName) { priceDiscAdmName = PriceDiscAdmName::find(journalName); if (priceDiscAdmName) { priceDiscAdmTable.clear(); priceDiscAdmTable.initFromPriceDiscAdmName(priceDiscAdmName); if (priceDiscAdmTable.validateWrite()) { priceDiscAdmTable.insert(); } } else { throw error ('O nome do diário de preço e desconto informado não existe'); } } else { throw error ('O nome do diário de preço e desconto não foi parametrizado'); } return priceDiscAdmTable; } private void createPriceDiscAdmTrans(ItemId _itemId, AmountCur _amountValue, PriceDiscAdmTable _priceDiscAdmTable) { PriceDiscAdmTrans priceDiscAdmTransLocal; str accountRelation; TableGroupAll accountCode; TableGroupAll itemCode; InventDim inventDim; TransDate fromDateLocal; TransDate toDateLocal; str itemRelation; itemCode = TableGroupAll::Table; itemRelation = _itemId; inventDim.InventSiteId = '001'; inventDim = inventDim::findOrCreate(inventDim); fromDateLocal = today(); priceDiscAdmTransLocal.clear(); priceDiscAdmTransLocal.initValue(); priceDiscAdmTransLocal.JournalNum = _priceDiscAdmTable.JournalNum; if (moduleInventCustVend == ModuleInventCustVend::Vend) { priceDiscAdmTransLocal.relation = PriceType::PricePurch; accountCode = TableGroupAll::Table; accountRelation = '000012'; } else if (moduleInventCustVend == ModuleInventCustVend::Cust) { priceDiscAdmTransLocal.relation = PriceType::PriceSales; accountCode = TableGroupAll::All; accountRelation = ""; } priceDiscAdmTransLocal.AccountCode = accountCode; priceDiscAdmTransLocal.AccountRelation = accountRelation; priceDiscAdmTransLocal.initFromAccountCode(); priceDiscAdmTransLocal.ItemCode = itemCode; priceDiscAdmTransLocal.ItemRelation = itemRelation; priceDiscAdmTransLocal.initFromItemCode(); priceDiscAdmTransLocal.InventDimId = inventDim.inventDimId; priceDiscAdmTransLocal.Amount = _amountValue; priceDiscAdmTransLocal.FromDate = fromDateLocal; priceDiscAdmTransLocal.ToDate = toDateLocal; if (!priceDiscAdmTransLocal.Currency) { priceDiscAdmTransLocal.Currency = CompanyInfo::standardCurrency(); } priceDiscAdmTransLocal.insert(); } |
Leave a reply