Case How to validate production from sales order while advanced payment condition not meet
story:
we have 2 company using the same AX, both company use intercompany to create order from first company to second company
first company are selling stuff, and the second are manufacture company
when the first company have order from customer, the first creating sales order, then converted to purchase order, and converted to intercompany sales order on the second company
the second company will create production based on these sales order
the problem is, when the second company create the production, sometime the real sales order should not be processed because one or two things, for example, the sales order from company should finalize the advance payment before the second company can proceed
based on these case, we made some custom on ax 2012, the goal is, when the second company were create the production order based on this sales order, they must check it first from the first company sales order, was the sales order had fulfill the advance payment or not, if not, the production cannot be proceed
the solution is, we made custom on: SalesLineType (classes), and SalesLine (Table)
see the picture below:
on modified formProduction method:
void formProduction(Object element) { Args args; FormRun formProduction; boolean BisaProduksi; ; if (!salesLine.RecId || !salesLine.InventTransId) throw error("@SYS24669"); if (!salesLine.inventTable().inventItemType().canBeProduced()) throw error("@SYS24822"); if(!InventItemOrderSetupMap::find(salesLine.ItemId, InventItemOrderSetupMap::module2SetupType(ModuleInventPurchSales::Invent), salesLine.InventDimId).checkNotStopped()) { return; } BisaProduksi = SalesLine.RON_CekDPDiPabrikJobTest(SalesLine.SalesId); if(!BisaProduksi) { return; } if (!ProdTableReferences::hasSalesLineProductions(salesLine)) { if (salesLine.SalesType == SalesType::ItemReq && !salesLine.RemainInventPhysical) throw error("@SYS122589"); args = new Args(); args.name(formStr(ProdTableCreate)); args.caller(element); args.record(salesLine); formProduction = classfactory.formRunClass(args); formProduction.init(); formProduction.run(); formProduction.wait(); if (salesLine.dataSource()) { salesLine.dataSource().reread(); salesLine.dataSource().refresh(); } } if (formProduction && formProduction.closedOk() || !formProduction) { args = new Args(); args.name(formStr(ProdTable)); args.caller(element); args.record(salesLine); formProduction = classfactory.formRunClass(args); formProduction.init(); formProduction.run(); formProduction.wait(); } }
create new Method on SalesLine (Table) call RON_CekDPDiPabrikJobTest
and paste the source like below:
boolean RON_CekDPDiPabrikJobTest(String30 NoSO) { SalesTable salesTable_A; SalesTable salesTable_D; PurchTable purchTable_B; str interCompanyID; LedgerJournalTable ledgerJournalTable_C; boolean sudahdp; sudahdp = true; interCompanyID = ""; while select * from salesTable_A where salesTable_A.SalesId==NoSO { interCompanyID = salesTable_A.InterCompanyCompanyId; while select crossCompany * from purchTable_B where purchTable_B.dataAreaId==salesTable_A.InterCompanyCompanyId && purchTable_B.PurchId==salesTable_A.InterCompanyPurchId && purchTable_B.PurchStatus==PurchStatus::Backorder { while select crossCompany * from salesTable_D where salesTable_D.dataAreaId==purchTable_B.dataAreaId && salesTable_D.SalesId==purchTable_B.InterCompanyOriginalSalesId && salesTable_D.SDX_RequireAdvance==NoYes::Yes { sudahdp = false; while select crossCompany * from ledgerJournalTable_C where ledgerJournalTable_C.dataAreaId==salesTable_D.dataAreaId && ledgerJournalTable_C.SDX_SalesId==salesTable_D.SalesId { sudahdp = true; } } } } if(!sudahdp) { info(strFmt("Cannot proceed, the original Sales Order has not fulfill yet in advanced payment %1 entity %2 ", NoSO, interCompanyID)); } return sudahdp; }
I hope this help
-RF-